List of usage examples for com.mongodb DBCursor next
@Override
public DBObject next()
From source file:com.fliker.Modal.GuidancePreview.java
public void saveInterest(String guidanceid, String userid) { // TODO Auto-generated method stub MongoConnection mongocon = new MongoConnection(); boolean userpresent = false; DBCursor guidrstcursor = mongocon.getDBObject("guidanceid", guidanceid, "GuidanceSelection"); while (guidrstcursor.hasNext()) { DBObject guiderstdbj = guidrstcursor.next(); BasicDBList interestuserlist = (BasicDBList) guiderstdbj.get("guidanceinterest"); for (int m = 0; m < interestuserlist.size(); m++) { if (userid.equalsIgnoreCase((String) interestuserlist.get(m))) { userpresent = true;/*from www .ja v a 2 s. c o m*/ } } } if (!userpresent) { mongocon.updateObject(new BasicDBObject("guidanceid", guidanceid), new BasicDBObject("$push", new BasicDBObject("guidanceinterest", userid)), "GuidanceEntryShare"); } }
From source file:com.fliker.Modal.GuidancePreview.java
public void createGuidanceEntry(String guidanceid, String userid) { // TODO Auto-generated method stub String[] assignmentids = null; String[] quizids = null;/*from w w w.ja v a 2s . c o m*/ String sharedid = ""; String dashboardid = ""; String calendarid = ""; String projectid = ""; MongoConnection mongocon = new MongoConnection(); DBCursor guidrstcursor = mongocon.getDBObject("guidanceid", guidanceid, "GuidanceContent"); while (guidrstcursor.hasNext()) { DBObject guiderstdbj = guidrstcursor.next(); BasicDBList assignlist = (BasicDBList) guiderstdbj.get("assignmentids"); if (assignlist != null) { assignmentids = assignlist.toArray(new String[assignlist.size()]); } else { assignmentids = new String[0]; } BasicDBList quizlist = (BasicDBList) guiderstdbj.get("quizids"); if (quizlist != null) { quizids = quizlist.toArray(new String[quizlist.size()]); } else { quizids = new String[0]; } sharedid = (String) guiderstdbj.get("sharetokenid"); dashboardid = (String) guiderstdbj.get("dashboardid"); calendarid = (String) guiderstdbj.get("timetableid"); projectid = (String) guiderstdbj.get("projectid"); } List filelisttoadd = new ArrayList(); DBCursor guidsharecursor = mongocon.getDBObject("guidancesharedid", sharedid, "GuidanceContentShare"); while (guidsharecursor.hasNext()) { DBObject guidesharedbj = guidsharecursor.next(); BasicDBList sharedfilelist = (BasicDBList) guidesharedbj.get("guidancefilelistid"); for (int x = 0; x < sharedfilelist.size(); x++) { DBCursor guidfilesharecursor = mongocon.getDBObject("guidancefileid", (String) sharedfilelist.get(x), "GuidanceDashFileShare"); while (guidfilesharecursor.hasNext()) { DBObject guidefilesharedbj = guidfilesharecursor.next(); BasicDBList userlist = (BasicDBList) guidefilesharedbj.get("consumerids"); for (int s = 0; s < userlist.size(); s++) { if (((String) userlist.get(s)).equalsIgnoreCase("All")) { filelisttoadd.add((String) sharedfilelist.get(x)); } } } } } String[] events = null; DBCursor guidcallcursor = mongocon.getDBObject("guidancecalendarid", calendarid, "GuidanceContentCalendar"); while (guidcallcursor.hasNext()) { DBObject guidecaldbj = guidcallcursor.next(); BasicDBList calendarlist = (BasicDBList) guidecaldbj.get("guidancecalendareventid"); events = calendarlist.toArray(new String[calendarlist.size()]); } GuidancePreview guidprev = new GuidancePreview(); String uniqueid = ""; try { uniqueid = guidprev.makeSHA1Hash(guidanceid + userid); } catch (NoSuchAlgorithmException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (UnsupportedEncodingException e) { // TODO Auto-generated catch block e.printStackTrace(); } GuidanceEntryShare guidentrshare = new GuidanceEntryShare(); guidentrshare.setGuidancecontentshareid(sharedid); String[] sharedfileto = (String[]) filelisttoadd.toArray(new String[filelisttoadd.size()]); guidentrshare.setFileids(sharedfileto); guidentrshare.setGuidanceshareid(uniqueid); MongoConnection mongoconsearch = new MongoConnection(); BasicDBObject basicguishareobj = guidprev.formEntryShareDBObject(guidentrshare); mongoconsearch.saveObject(basicguishareobj, "GuidanceEntryShare"); GuidanceContentDashBoardSet guiddasborset = new GuidanceContentDashBoardSet(); guiddasborset.setGuidancedashboardid(dashboardid); String[] guidancedashdataid = new String[0]; guiddasborset.setGuidancedashdataid(guidancedashdataid); guiddasborset.setGuidanceentrydashid(uniqueid); guiddasborset.setGuidanceuserid(userid); GuidanceEntryDashboard guideentrydash = new GuidanceEntryDashboard(); guideentrydash.setGuidanceentrydashid(uniqueid); guideentrydash.setGuidanceentrydashdataid(guidancedashdataid); BasicDBObject guidashentryobj = guidprev.formDashBoardEntryDBObject(guideentrydash); mongoconsearch.saveObject(guidashentryobj, "GuidanceEntryDashboard"); BasicDBObject basicguidashsetobj = guidprev.formDashBoardSetDBObject(guiddasborset); mongoconsearch.saveObject(basicguidashsetobj, "GuidanceContentDashBoardSet"); GuidanceEntryCalendar guidentrycal = new GuidanceEntryCalendar(); guidentrycal.setGuidancecalendarid(uniqueid); guidentrycal.setEventids(events); BasicDBObject basicguicalobj = guidprev.formEntryCalendarDBObject(guidentrycal); mongoconsearch.saveObject(basicguicalobj, "GuidanceEntryCalendar"); GuidanceEntry guideentry = new GuidanceEntry(); guideentry.setAssignmentids(assignmentids); guideentry.setQuizids(quizids); guideentry.setAverageVelocity(""); guideentry.setConsumeguidanceid(guidanceid); guideentry.setDashboardid(uniqueid); guideentry.setProjectid(""); guideentry.setSharetokenid(uniqueid); String[] topicid = new String[0]; guideentry.setTopicid(topicid); guideentry.setTimetableid(uniqueid); guideentry.setGuidanceid(uniqueid); guideentry.setProjectid(projectid); guideentry.setUserid(userid); BasicDBObject basicguientryobj = guidprev.formEntryGuidanceDBObject(guideentry); mongoconsearch.saveObject(basicguientryobj, "GuidanceEntry"); mongocon.updateObject(new BasicDBObject("guidanceid", guidanceid), new BasicDBObject("$push", new BasicDBObject("consumeruserid", userid)), "GuidanceContent"); mongocon.updateObject(new BasicDBObject("userid", userid), new BasicDBObject("$push", new BasicDBObject("guidanceids", guidanceid)), "Profile"); }
From source file:com.fliker.Modal.GuidancePreview.java
public ArrayList getAllGuidanceConsuming(String userid) { // TODO Auto-generated method stub ArrayList guidancelist = new ArrayList<Post>(); MongoConnection mongocon = new MongoConnection(); Assignment assignment = new Assignment(); DBCursor resultcursor = mongocon.getDBObject("userid", userid, "GuidanceEntry"); while (resultcursor.hasNext()) { DBObject dbj = resultcursor.next(); HashMap totalSet = new HashMap(); String guidid = (String) dbj.get("consumeguidanceid"); DBCursor guidcursor = mongocon.getDBObject("guidanceid", guidid, "GuidanceSelection"); while (guidcursor.hasNext()) { DBObject guiddbj = guidcursor.next(); totalSet.put("guidanceid", (String) guiddbj.get("guidanceid")); totalSet.put("guidancesubject", (String) guiddbj.get("guidanceSubject")); totalSet.put("guidancelocation", (String) guiddbj.get("guidancelocation")); totalSet.put("guidanceduration", (String) guiddbj.get("guidanceduration")); totalSet.put("guidancereason", (String) guiddbj.get("guidancereason")); ProfilePreview profprev = new ProfilePreview(); ArrayList profileinfo = profprev.getProfileInfo((String) guiddbj.get("userid")); for (int m = 0; m < profileinfo.size(); m++) { if (profileinfo.get(m) instanceof Profile) { Profile profileinfos = (Profile) profileinfo.get(m); totalSet.put("guidanceprofileid", profileinfos.getProfileid()); totalSet.put("profileImage", profileinfos.getProfileImageid()); totalSet.put("guidanceprofilename", profileinfos.getName()); }/*from ww w. j a va 2 s .c om*/ } totalSet.put("guidanceuserid", (String) guiddbj.get("userid")); guidancelist.add(totalSet); } } return guidancelist; }
From source file:com.fliker.Modal.GuidancePreview.java
public ArrayList getGuidanceEntryData(String guidanceid, String userid) { // TODO Auto-generated method stub ArrayList dashdatalist = new ArrayList(); GuidancePreview guidprev = new GuidancePreview(); MongoConnection mongocon = new MongoConnection(); DBCursor resultcursor = mongocon.getDBObject("guidanceid", guidanceid, "GuidanceEntryDashboard"); while (resultcursor.hasNext()) { DBObject dbj = resultcursor.next(); HashMap specificationmap = new HashMap(); BasicDBList guidancedashdata = (BasicDBList) dbj.get("specificationset"); if (guidancedashdata != null) { for (int x = 0; x < guidancedashdata.size(); x++) { DBCursor dashdatacursor = mongocon.getDBObject("guidancespecificationid", (String) guidancedashdata.get(x), "GuidanceEntrySpecification"); while (dashdatacursor.hasNext()) { DBObject dashdatadbj = dashdatacursor.next(); if (guidanceid.equalsIgnoreCase((String) dashdatadbj.get("guidanceid"))) { if (userid.equalsIgnoreCase((String) dashdatadbj.get("userid"))) { BasicDBList specificationlist = (BasicDBList) dashdatadbj.get("specifications"); for (int i = 0; i < specificationlist.size(); i++) { DBCursor specdatacursor = mongocon.getDBObject("specificationid", (String) specificationlist.get(i), "GuidanceSpecificationData"); while (specdatacursor.hasNext()) { DBObject specdatadbj = specdatacursor.next(); specificationmap.put( (String) specdatadbj.get("specificationname") + ":" + (String) specdatadbj.get("specificationdetails"), (BasicDBList) specdatadbj.get("specificationremarks")); }// w w w. jav a2 s . c o m } } } } } } BasicDBList helpremarks = (BasicDBList) dbj.get("helpremark"); BasicDBList levelremark = (BasicDBList) dbj.get("levelremark"); specificationmap.put("helpremark", helpremarks); specificationmap.put("levelremark", levelremark); dashdatalist.add(specificationmap); } return dashdatalist; }
From source file:com.fliker.Modal.GuidancePreview.java
public ArrayList getSpecificationData(String guidanceid) { // TODO Auto-generated method stub MongoConnection mongocon = new MongoConnection(); DBCursor resultcursor = mongocon.getDBObject("guidanceid", guidanceid, "GuidanceContent"); if (resultcursor.hasNext()) { DBObject dbj = resultcursor.next(); HashMap specificationdata = new HashMap(); BasicDBList specificids = (BasicDBList) dbj.get("specification"); for (int k = 0; k < specificids.size(); k++) { DBCursor specifcursor = mongocon.getDBObject("specificationid", (String) specificids.get(k), "GuidanceSpecificationData"); while (specifcursor.hasNext()) { DBObject specificdbj = specifcursor.next(); }//from w ww. ja v a 2 s .c o m } } return null; }
From source file:com.fliker.Modal.GuidancePreview.java
public ArrayList getGuidanceAssignmentData(String guidanceid) { // TODO Auto-generated method stub ArrayList guidanceassignlist = new ArrayList(); MongoConnection mongocon = new MongoConnection(); DBCursor resultcursor = mongocon.getDBObject("guidanceid", guidanceid, "GuidanceContent"); if (resultcursor.hasNext()) { DBObject dbj = resultcursor.next(); BasicDBList assignmentids = (BasicDBList) dbj.get("assignmentids"); for (int k = 0; k < assignmentids.size(); k++) { HashMap assignmap = new HashMap(); DBCursor assigndatacursor = mongocon.getDBObject("assignmentid", (String) assignmentids.get(k), "GuidanceAssignmentSet"); while (assigndatacursor.hasNext()) { DBObject assigndatadbj = assigndatacursor.next(); assignmap.put("assignmentname", (String) assigndatadbj.get("assignmentname")); }/* ww w . j ava 2 s. c o m*/ DBCursor assigncursor = mongocon.getDBObject("assignmentid", (String) assignmentids.get(k), "GuidanceEntryAssignment"); while (assigncursor.hasNext()) { DBObject assigndbj = assigncursor.next(); assignmap.put("entryassignmentid", (String) assigndbj.get("guidanceentryassignid")); assignmap.put("userid", (String) assigndbj.get("userid")); assignmap.put("feedbackid", (String) assigndbj.get("feedbackid")); assignmap.put("remarkid", (String) assigndbj.get("remarkid")); ArrayList feedbacklist = new ArrayList(); DBCursor feedbackcursor = mongocon.getDBObject("feedbackid", (String) assigndbj.get("feedbackid"), "GuidanceFeedback"); while (feedbackcursor.hasNext()) { DBObject feedbackdbj = feedbackcursor.next(); feedbacklist.add(feedbackdbj.get("feedback")); } assignmap.put("feedback", feedbacklist); ArrayList remarklist = new ArrayList(); DBCursor remarkcursor = mongocon.getDBObject("remarkid", (String) assigndbj.get("remarkid"), "GuidanceRemarks"); while (remarkcursor.hasNext()) { DBObject remarkdbj = remarkcursor.next(); remarklist.add((BasicDBList) remarkdbj.get("remarks")); } assignmap.put("remarks", remarklist); } guidanceassignlist.add(assignmap); } } return guidanceassignlist; }
From source file:com.fliker.Modal.GuidancePreview.java
public HashMap getGuidanceQuizData(String guidanceid) { // TODO Auto-generated method stub ArrayList guidancequizlist = new ArrayList(); MongoConnection mongocon = new MongoConnection(); HashMap quizlistmap = new HashMap(); DBCursor resultcursor = mongocon.getDBObject("guidanceid", guidanceid, "GuidanceContent"); if (resultcursor.hasNext()) { DBObject dbj = resultcursor.next(); BasicDBList quizlist = (BasicDBList) dbj.get("quizids"); for (int k = 0; k < quizlist.size(); k++) { HashMap quizmap = new HashMap(); DBCursor quizlinkcursor = mongocon.getDBObject("quizid", (String) quizlist.get(k), "GuidanceQuizLink"); while (quizlinkcursor.hasNext()) { DBObject quizdbj = quizlinkcursor.next(); quizmap.put("quizid", quizdbj.get("quizid")); DBCursor quizdatcursor = mongocon.getDBObject("quizid", (String) quizdbj.get("quizid"), "GuidanceContentQuiz"); if (quizdatcursor.hasNext()) { DBObject quizdatdbj = quizdatcursor.next(); quizmap.put("quizname", quizdbj.get("quizname")); quizmap.put("quizdescription", quizdbj.get("quizdescription")); quizmap.put("quizdatetime", quizdbj.get("quizdatetime")); }/*from ww w .j a va 2 s . c om*/ quizmap.put("shareduserids", (BasicDBList) quizdbj.get("shareduserids")); /*ArrayList feedbacklist = new ArrayList(); BasicDBList feedbcklist = (BasicDBList)quizdbj.get("guidancefeedbackid"); for(int x=0;x<feedbcklist.size();x++){ DBCursor feedbackcursor = mongocon.getDBObject("feedbackid", (String)feedbcklist.get(x), "GuidanceFeedback"); while(feedbackcursor.hasNext()){ DBObject feedbackdbj = feedbackcursor.next(); feedbacklist.add(feedbackdbj.get("feedback")); } } quizmap.put("feedback", feedbacklist); ArrayList remarklist = new ArrayList(); BasicDBList remrklst = (BasicDBList)quizdbj.get("guidanceremarkid"); for(int h=0;h<remrklst.size();h++){ DBCursor remarkcursor = mongocon.getDBObject("remarkid", (String)remrklst.get(h), "GuidanceRemarks"); while(remarkcursor.hasNext()){ DBObject remarkdbj = remarkcursor.next(); remarklist.add((BasicDBList)remarkdbj.get("remarks")); } } quizmap.put("remarks", remarklist);*/ } quizlistmap.put((String) quizlist.get(k), quizmap); } } return quizlistmap; }
From source file:com.fliker.Modal.GuidancePreview.java
public ArrayList getTempSaveAssignments(String guidanceid, String accessuserid) { // TODO Auto-generated method stub MongoConnection mongocon = new MongoConnection(); DBCursor resultcursor = mongocon.getDBObject("guidanceid", guidanceid, "GuidanceTempContentAssignment"); ArrayList tempsaveassignlist = new ArrayList(); while (resultcursor.hasNext()) { DBObject dbj = resultcursor.next(); HashMap tempassignmap = new HashMap(); if (((String) dbj.get("userid")).equalsIgnoreCase(accessuserid)) { tempassignmap.put("tempassignmentid", (String) dbj.get("tempcontentassignmentid")); tempassignmap.put("assignquestionset", (BasicDBList) dbj.get("assingmentquestionset")); tempassignmap.put("savedatetime", (String) dbj.get("savedatetime")); tempassignmap.put("createdatetime", (String) dbj.get("creationdate")); tempsaveassignlist.add(tempassignmap); }//from w ww .j a v a 2s .c o m } return tempsaveassignlist; }
From source file:com.fliker.Modal.GuidancePreview.java
public ArrayList getTempSaveQuiz(String guidanceid, String accessuserid) { // TODO Auto-generated method stub MongoConnection mongocon = new MongoConnection(); DBCursor resultcursor = mongocon.getDBObject("guidanceid", guidanceid, "GuidanceContentTempQuiz"); ArrayList tempsavequizlist = new ArrayList(); while (resultcursor.hasNext()) { DBObject dbj = resultcursor.next(); if (((String) dbj.get("userid")).equalsIgnoreCase(accessuserid)) { HashMap tempquizmap = new HashMap(); tempquizmap.put("quizname", (String) dbj.get("quizname")); tempquizmap.put("quizdescription", (String) dbj.get("quizdescription")); tempquizmap.put("tempquizid", (String) dbj.get("tempquizid")); tempquizmap.put("quizid", (String) dbj.get("quizid"));//savedatetime tempquizmap.put("savetime", (String) dbj.get("savedatetime")); //tempquizmap.put("questionset", (BasicDBList)dbj.get("questionset")); tempsavequizlist.add(tempquizmap); }/*from w ww . ja v a 2 s . co m*/ } return tempsavequizlist; }
From source file:com.fliker.Modal.GuidancePreview.java
public String createTempQuizContent(String quizname, String quizdesc, String quiztoken, String guidanceid, String userid) {/* ww w . j av a 2 s . c o m*/ // TODO Auto-generated method stub MongoConnection mongocon = new MongoConnection(); DBCursor resultcursor = mongocon.getDBObject("tempquizid", quiztoken, "GuidanceContentTempQuiz"); ArrayList tempsavequizlist = new ArrayList(); if (resultcursor.hasNext()) { DBObject dbj = resultcursor.next(); String quizid = (String) dbj.get("quizid"); return quizid; } else { GuidanceContentTempQuiz guidconttempquiz = new GuidanceContentTempQuiz(); guidconttempquiz.setGuidanceid(guidanceid); guidconttempquiz.setQuizdescription(quizdesc); guidconttempquiz.setQuizname(quizname); guidconttempquiz.setTempquizid(quiztoken); guidconttempquiz.setUserid(userid); SimpleDateFormat formatter = new SimpleDateFormat("EEEE, MMM dd, yyyy HH:mm:ss a"); //String dateInString = "Friday, Jun 7, 2013 12:10:56 PM";//example Date datepack = new Date(); DateFunctionality datefunc = new DateFunctionality(); String savedatetime = formatter.format(datepack); guidconttempquiz.setSavedatetime(savedatetime); String[] questionset = new String[0]; guidconttempquiz.setQuestionset(questionset); GuidancePreview guidprev = new GuidancePreview(); String uniqueid = ""; try { uniqueid = guidprev.makeSHA1Hash(quizname + quizdesc); } catch (NoSuchAlgorithmException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (UnsupportedEncodingException e) { // TODO Auto-generated catch block e.printStackTrace(); } guidconttempquiz.setQuizid(uniqueid); MongoConnection mongoconsearch = new MongoConnection(); BasicDBObject basicguishareobj = guidprev.formGuidTempContQuizDBObject(guidconttempquiz); mongoconsearch.saveObject(basicguishareobj, "GuidanceContentTempQuiz"); return uniqueid; } }