CS 340 Milestone One Guidelines And Rubric
Overview:For This Assignment, You Will Implement The Fundamental Operations Of Create, Read, Update, And Delete (CRUD) In Either Python Or Java. You Will Use The Language-Specific MongoDB Driver To Create CRUD Functional Access To Your Document Collection.
At This Point In The Course, You Will Need To Select The Programming Language You Would Like To Use. (You May Choose Whichever Language You Prefer, But Considering The Opportunities In Your Program, We Do Recommend Python.) Keep In Mind That You Must Use Your Chosen Programming Language For The Remainder Of The Course (Milestone Two And The Final Project) Because Your Assignments Will Build On Each Other Starting With This Milestone.
Reminders
- To Create A Code File In Codio, Right-Click On The Briefcase Icon Next To Your Codio Project And SelectNew File. Refer ToThis VideoFor Further Guidance.
- To Download A Code File In Codio, Right-Click On The Document Icon Next To Your Codio Text File And SelectDownload.
- Type All Python Code Into Your Codio Terminal Manually, Especially When Running The Python Example Code Below. Python Is Space-Sensitive And Does Not Copy Into The Codio Terminal Well.
Prior To Completing The Prompt For This Assignment, Run The Following Code In Your Chosen Language.
Example Python Code To Insert A Document
Import Json From Bson Import Json_util From Pymongo Import MongoClient
Connection = MongoClient(‘Localhost’, 27017) Db = Connection[‘MyDB’] Collection = Db[‘MyCollection’]
Def Insert_document(Document):
Try: Result=Collection.Save(Document) Except ValidationError As Ve: Abort(400, Str(Ve)) Return Result
Def Main():
MyDocument = { “KeyName” : “Test Value Data”}
Print Insert_document(MyDocument)
Main()
—————————————
Example Java Code
To Run With Maven, First Create A Project:
Mvn Archetype:Generate -DgroupId=Com.Snhu.App -DartifactId=Example-App -DarchetypeArtifactId=Maven-Archetype- Quickstart -DinteractiveMode=False
Then Use The Following Text For The Pom.Xml File:
Xsi:SchemaLocation=”Http://Maven.Apache.Org/POM/4.0.0 Http://Maven.Apache.Org/Maven-V4_0_0.Xsd”> 4.0.0 Com.Snhu.App Example-App Jar 1.0-SNAPSHOT Example-App Http://Maven.Apache.Org
Org.Mongodb Mongo-Java-Driver 2.13.3
Junit Junit 3.8.1 Test
Org.Apache.Maven.Plugins Maven-Assembly-Plugin 2.4
Jar-With-Dependencies
Assemble-All Package
Single
Org.Apache.Maven.Plugins Maven-Jar-Plugin
True Fully.Qualified.MainClass
Use The Following Code For TheExample-App/Src/Main/Java/Com/Snhu/App/App.JavaFile:
Package Com.Snhu.App;
Import Com.Mongodb.BasicDBObject; Import Com.Mongodb.BulkWriteOperation; Import Com.Mongodb.BulkWriteResult; Import Com.Mongodb.Cursor; Import Com.Mongodb.DB; Import Com.Mongodb.DBCollection;
Import Com.Mongodb.DBCursor; Import Com.Mongodb.DBObject; Import Com.Mongodb.MongoClient; Import Com.Mongodb.ParallelScanOptions; Import Com.Mongodb.ServerAddress;
Import Java.Util.List; Import Java.Util.Set; Import Java.Io.IOException; Import Java.Io.ObjectInputStream; Import Java.Io.ObjectOutputStream; Import Java.Lang.ClassNotFoundException; Import Java.Net.InetAddress; Import Java.Net.Socket; Import Java.Net.UnknownHostException;
Import Static Java.Util.Concurrent.TimeUnit.SECONDS;
Public Class App {
Public Static Void Create_document(BasicDBObject Doc) {
Try {
MongoClient MongoClient = New MongoClient( “Localhost” ); DB Db = MongoClient.GetDB( “MyDB” ); DBCollection Coll = Db.GetCollection(“MyCollection”); Coll.Insert(Doc); } Catch (UnknownHostException E) { E.PrintStackTrace(); } Catch (IOException E) { E.PrintStackTrace(); } Catch (Exception E) { E.PrintStackTrace(); } }
Public Static Void Main( String[] Args ) {
BasicDBObject Doc = New BasicDBObject(“KeyName”, “Test Value Data”);
Create_document(Doc);
} }
Prompt:After Completing The Textbook Reading For This Module And Reviewing The Other Resources, Use The Codio Editor And Your Choice Of Python Or Java To Complete The Following Tasks In Codio. For Each Task, Provide A Text File (Either A.JavaOr.PyFile) Of Your Code And Screenshots Of Execution As Evidence.
- Develop A Function ToCreateA Document In The MongoDB Database “City” In The Collection “Inspections.” Be Sure It Can Handle Error Conditions
Gracefully.
- Input -> Argument To Function Will Be Set Of Key/Value Pairs In The Data Type Acceptable To The MongoDB Driver Insert API Call B. Return -> True If Successful Insert Else False (Require A Screenshot) 2. Develop A Function ToReadA Document In The MongoDB Database “City” In The Collection “Inspections.” Be Sure It Can Handle Error Conditions Gracefully.
- Input -> Arguments To Function Should Be The Key/Value Lookup Pair To Use With The MongoDB Driver Find API Call B. Return -> Result In JSON Format If Successful Else MongoDB Returned Error Message 3. Develop A Function ToUpdateA Document In The MongoDB Database “City” In The Collection “Inspections.” Be Sure It Can Handle Error Conditions
Gracefully.
- Input -> Arguments To Function Should Be The Key/Value Lookup Pair To Use With The MongoDB Driver Find API Call. Last Argument To Function Will
Be Set Of Key/Value Pairs In The Data Type Acceptable To The MongoDB Driver Insert API Call. B. Return -> Result In JSON Format If Successful Else MongoDB Returned Error Message 4. Develop A Function ToDeleteA Document In The MongoDB Database “City” In The Collection “Inspections.” Be Sure It Can Handle Error Conditions
Gracefully.
- Input -> Arguments To Function Should Be The Key/Value Lookup Pair To Use With The MongoDB Driver Find API Call B. Return -> Result In JSON Format If Successful Else MongoDB Returned Error Message
Specifically, The Following Must Be Addressed In Your Submission:
- Database Create, Read, Update, And Delete Functions Using Programming Language: Use Code Submission And Screenshots To Demonstrate MongoDB Interactions.
Rubric
Guidelines For Submission:You Must Submit Two Files For This Assignment:
- A Microsoft Word Document (Or Equivalent) With Double Spacing, 12-Point Times New Roman Font, One-Inch Margins, And The Appropriate Screenshots
- A Text File (Either.JavaOr.Py) Containing Your Code
Critical Elements Proficient (100%) Needs Improvement (75%) Not Evident (0%) Value Create FunctionDevelops Function To Create A Document
In Chosen Programming Language That Both Compiles Successfully And Contains Required Functionality
Develops Function To Create A Document In Chosen Programming Language That May Compile Successfully But Does Not Contain Required Functionality
Does Not Develop Function To Create A Document
25
Read FunctionDevelops Function To Read A Document
In Chosen Programming Language That Both Compiles Successfully And Contains Required Functionality
Develops Function To Read A Document In Chosen Programming Language That May Compile Successfully But Does Not Contain Required Functionality
Does Not Develop Function To Read A Document
25
Update FunctionDevelops Function To Update A
Document In Chosen Programming Language That Both Compiles Successfully And Contains Required Functionality
Develops Function To Update A Document In Chosen Programming Language That May Compile Successfully But Does Not Contain Required Functionality
Does Not Develop Function To Update A Document
25
Delete FunctionDevelops Function To Delete A
Document In Chosen Programming Language That Both Compiles Successfully And Contains Required Functionality
Develops Function To Delete A Document In Chosen Programming Language That May Compile Successfully But Does Not Contain Required Functionality
Does Not Develop Function To Delete A Document
25
Total 100%