List of usage examples for com.mongodb DBCursor next
@Override
public DBObject next()
From source file:com.fliker.Modal.GuidancePreview.java
public String getNumberOfBlogsTopics(String blogid, String userid) { String topicnumber = ""; int topiccount = 0; MongoConnection mongoconint = new MongoConnection(); DBCursor blogcursor = mongoconint.getDBObject("blogid", blogid, "Blog"); if (blogcursor.hasNext()) { DBObject eventObj = blogcursor.next(); String[] topics = (String[]) eventObj.get("topicid"); for (int s = 0; s < topics.length; s++) { MongoConnection mongocontop = new MongoConnection(); DBCursor topiccursor = mongoconint.getDBObject("topicid", topics[s], "Topic"); if (topiccursor.hasNext()) { DBObject topicObj = blogcursor.next(); if (((String) topicObj.get("topiccreateduserid")).equalsIgnoreCase(userid)) { topiccount++;// w w w. j a va 2 s . com } } } } topicnumber = Integer.toString(topiccount); return topicnumber; }
From source file:com.fliker.Modal.GuidancePreview.java
public BasicDBList getGuidanceCosumeruserid(String guidanceid) { // TODO Auto-generated method stub BasicDBList useridlist = new BasicDBList(); MongoConnection mongocon = new MongoConnection(); DBCursor resultcursor = mongocon.getDBObject("guidanceid", guidanceid, "GuidanceContent"); if (resultcursor.hasNext()) { DBObject theObj = resultcursor.next(); useridlist = (BasicDBList) theObj.get("consumeruserid"); }/*www. j a v a 2 s . co m*/ return useridlist; }
From source file:com.fliker.Modal.GuidancePreview.java
public String getGuidanceProvideruserid(String guidanceid) { // TODO Auto-generated method stub String userid = ""; MongoConnection mongocon = new MongoConnection(); DBCursor resultcursor = mongocon.getDBObject("guidanceid", guidanceid, "GuidanceContent"); if (resultcursor.hasNext()) { DBObject theObj = resultcursor.next(); userid = (String) theObj.get("provideruserid"); }/*ww w. j a v a 2 s . c om*/ return userid; }
From source file:com.fliker.Modal.GuidancePreview.java
public String getGuidanceType(String guidanceid, String accessuserid) { // TODO Auto-generated method stub String guidancetype = ""; MongoConnection mongocon = new MongoConnection(); DBCursor resultcursor = mongocon.getDBObject("guidanceid", guidanceid, "GuidanceContent"); if (resultcursor.hasNext()) { DBObject theObj = resultcursor.next(); if (((String) theObj.get("consumeruserid")).equalsIgnoreCase(accessuserid)) { guidancetype = "consumer"; } else if (((String) theObj.get("provideruserid")).equalsIgnoreCase(accessuserid)) { guidancetype = "provider"; }/* w w w . j a v a2 s. c om*/ } return guidancetype; }
From source file:com.fliker.Modal.GuidancePreview.java
public String formAssignmentList(String guidanceid, String userid, String contenttype) { // TODO Auto-generated method stub ArrayList assignmentlist = new ArrayList(); StringBuffer contentbuff = new StringBuffer(); contentbuff.append("["); MongoConnection mongocon = new MongoConnection(); Assignment assignment = new Assignment(); DBCursor resultcursor = mongocon.getDBObject("guidanceid", guidanceid, "GuidanceAssignment"); if (resultcursor.hasNext()) { DBObject theObj = resultcursor.next(); String[] assignments = (String[]) theObj.get("assignmentids"); for (int d = 0; d < assignments.length; d++) { MongoConnection mongoconassign = new MongoConnection(); DBCursor asigncursor = mongoconassign.getDBObject("assignmentid", assignments[d], "Assignment"); if (asigncursor.hasNext()) { DBObject assignObj = asigncursor.next(); String[] sharedids = (String[]) assignObj.get("assignmentshareids"); boolean contains = Arrays.asList(sharedids).contains(userid); if (contains == true) { assignment.setAssignmentanswersheet((String[]) assignObj.get("assignmentanswersheet")); assignment.setAssignmentenddatetime((String) assignObj.get("assignmentenddatetime")); assignment.setAssignmentid((String) assignObj.get("assignmentid")); assignment.setAssignmentquestionsets((String[]) assignObj.get("assignmentquestionsets")); assignment.setAssignmentstartdatetime((String) assignObj.get("assignmentstartdatetime")); assignment.setAverageVelocity((String) assignObj.get("averageVelocity")); assignment.setNoOfQuestions((String) assignObj.get("noOfQuestions")); assignment.setPercentagescore((String) assignObj.get("percentagescore")); assignment.setAssignmentdescription((String) assignObj.get("assignmentdescription")); assignment.setAssignmentname((String) assignObj.get("assignmentname")); assignment.setAssignmentsubject((String) assignObj.get("assignmentsubject")); assignment.setAssignmentcreatedby((String) assignObj.get("assignmentcreatedby")); DateFunctionality datefunc = new DateFunctionality(); String assignmentstatus = ""; String datediff = datefunc.getDateDiffference( (String) assignObj.get("assignmentstartdatetime"), (String) assignObj.get("assignmentenddatetime")); if (Integer.valueOf(datediff) < 1) { assignmentstatus = "<span class='label label-default'>INACTIVE</span>"; } else { assignmentstatus = "<span class='label label-success'>ACTIVE</span>"; }//from w ww . j ava 2 s .co m String content = "{" + "\"" + "name" + "\"" + ":" + "\"" + "\"" + (String) assignObj.get("assignmentname") + "<br><small class='text-muted'><i>" + (String) assignObj.get("assignmentsubject") + "<i></small>" + "\"" + "," + "\"" + "est" + "\"" + ":" + "\"" + "<td><div class='progress progress-xs' data-progressbar-value='" + (String) assignObj.get("percentagescore") + "'><div class='progress-bar'></div></div></td>" + "\"" + "," + "\"" + "contacts" + "\"" + ":" + "\"" + "<div class='project-members'><a href='javascript:void(0)'><img src='/Fliker/imageFromUserid/" + (String) assignObj.get("assignmentcreatedby") + "' class='offline' alt='user'></a> </div> " + "\"" + "," + "\"" + "status" + "\"" + ":" + "\"" + assignmentstatus + "\"" + "," + "\"" + "target-actual" + "\"" + ":" + "\"" + "<span style='margin-top:5px' class='sparkline display-inline' data-sparkline-type='compositebar' data-sparkline-height='18px' data-sparkline-barcolor='#aafaaf' data-sparkline-line-width='2.5' data-sparkline-line-val='[6,4,7,8,47,9,9,8,3,2,2,5,6,7,4,1,5,7,6]' data-sparkline-bar-val='[6,4,7,8,47,9,9,8,3,2,2,5,6,7,9,9,5,7,6]'></span>" + "\"" + "," + "\"" + "actual" + "\"" + ":" + "\"" + "<span class='sparkline text-align-center' data-sparkline-type='line' data-sparkline-width='100%' data-sparkline-height='25px'>20,-35,70</span>" + "\"" + "," + "\"" + "tracker" + "\"" + ":" + "\"" + "<span class='onoffswitch'><input type='checkbox' name='start_interval' class='onoffswitch-checkbox' id='track' name='" + (String) assignObj.get("assignmentid") + "' checked='checked'><label class='onoffswitch-label' for='st1'><span class='onoffswitch-inner' data-swchon-text='ON' data-swchoff-text='OFF'></span><span class='onoffswitch-switch'></span></label></span>" + "\"" + "," + "\"" + "starts" + "\"" + ":" + "\"" + (String) assignObj.get("assignmentstartdatetime") + "\"" + "," + "\"" + "ends" + "\"" + ":" + "\"" + "<strong>" + (String) assignObj.get("assignmentstartdatetime") + "</strong>" + "\"" + "," + "\"" + "comments" + "\"" + ":" + "\"" + (String) assignObj.get("assignmentdescription") + "\"" + "," + "\"" + "action" + "\"" + ":" + "\"" + "<button class='btn btn-xs btn-success' id='" + (String) assignObj.get("assignmentid") + " onclick='openAssignment(" + (String) assignObj.get("assignmentid") + ")''>Open Assignment</button>" + "\"" + "}"; contentbuff.append(content); } } } } contentbuff.append("]"); return contentbuff.toString(); }
From source file:com.fliker.Modal.GuidancePreview.java
public ArrayList getGuidanceUnPublishDetails(String userids) { // TODO Auto-generated method stub ArrayList guidancelist = new ArrayList<Post>(); MongoConnection mongocon = new MongoConnection(); Assignment assignment = new Assignment(); DBCursor resultcursor = mongocon.getDBObject("userid", userids, "GuidanceSelection"); while (resultcursor.hasNext()) { DBObject dbj = resultcursor.next(); HashMap totalSet = new HashMap(); totalSet.put("guidanceid", (String) dbj.get("guidanceid")); totalSet.put("guidanceSubject", (String) dbj.get("guidanceSubject")); totalSet.put("guidancelocation", (String) dbj.get("guidancelocation")); totalSet.put("guidanceduration", (String) dbj.get("guidanceduration")); totalSet.put("guidancereason", (String) dbj.get("guidancereason")); long startTime2 = System.nanoTime(); DBCursor guidcontentcursor = mongocon.getDBObject("guidanceid", (String) dbj.get("guidanceid"), "GuidanceContent"); while (guidcontentcursor.hasNext()) { DBObject guidcontdbj = guidcontentcursor.next(); BasicDBList cosumerlist = (BasicDBList) guidcontdbj.get("consumeruserid"); totalSet.put("consumerids", cosumerlist); }/*from w ww . j a v a2 s. c o m*/ long endTime2 = System.nanoTime(); long duration2 = endTime2 - startTime2; System.out.println(" Time2 >>" + duration2); long startTime1 = System.nanoTime(); ProfilePreview profprev = new ProfilePreview(); ArrayList profileinfo = profprev.getProfileInfo((String) dbj.get("userid")); for (int m = 0; m < profileinfo.size(); m++) { if (profileinfo.get(m) instanceof Profile) { Profile profileinfos = (Profile) profileinfo.get(m); totalSet.put("providerprofileid", profileinfos.getProfileid()); totalSet.put("providerprofileimage", profileinfos.getProfileImageid()); totalSet.put("providername", profileinfos.getName()); } } long endTime1 = System.nanoTime(); long duration1 = endTime1 - startTime1; System.out.println(" Time1 >>" + duration1); totalSet.put("provideruserid", (String) dbj.get("userid")); guidancelist.add(totalSet); } return guidancelist; }
From source file:com.fliker.Modal.GuidancePreview.java
public HashMap getAllGuidanceProvidingSubjectList(String userid) { // TODO Auto-generated method stub GuidancePreview guidprev = new GuidancePreview(); HashMap guidanceidset = new HashMap(); MongoConnection mongocon = new MongoConnection(); Assignment assignment = new Assignment(); DBCursor resultcursor = mongocon.getDBObject("userid", userid, "GuidanceSelection"); while (resultcursor.hasNext()) { DBObject dbj = resultcursor.next(); String provideid = (String) dbj.get("guidanceflag"); if (provideid.equalsIgnoreCase("provide")) { String guidancesubject = (String) dbj.get("guidanceSubject"); MongoConnection mongoconsub = new MongoConnection(); DBCursor resultsubject = mongoconsub.getDBObject("guidanceSubject", guidancesubject, "GuidanceSelection"); while (resultsubject.hasNext()) { DBObject thesubdbj = resultsubject.next(); String guidanceflag = (String) thesubdbj.get("guidanceflag"); if (guidanceflag.equalsIgnoreCase("consume")) { ArrayList guidanceproviderlist = guidprev .checkGuidanceTake((String) thesubdbj.get("userid"), guidancesubject); HashMap guidanceinfo = new HashMap(); guidanceinfo.put("guidancepresent", guidanceproviderlist); guidanceinfo.put("guidancereason", (String) thesubdbj.get("guidancereason")); guidanceinfo.put("guidancelocation", (String) thesubdbj.get("guidancelocation")); guidanceinfo.put("guidanceduration", (String) thesubdbj.get("guidanceduration")); guidanceinfo.put("guidanceuserid", (String) thesubdbj.get("userid")); guidanceidset.put((String) thesubdbj.get("guidanceid"), guidanceinfo); }//ww w .j a v a 2 s . com } } } return guidanceidset; }
From source file:com.fliker.Modal.GuidancePreview.java
public ArrayList checkGuidanceTake(String userid, String guidancesubject) { //String guidanceids = ""; ArrayList guidanceidlist = new ArrayList(); ProfilePreview profprev = new ProfilePreview(); ArrayList profilelist = profprev.getProfileInfo(userid); //String[] guidancelist = new String[0]; for (int m = 0; m < profilelist.size(); m++) { if (profilelist.get(m) instanceof Profile) { Profile profileinform = (Profile) profilelist.get(m); String[] guidancelist = profileinform.getGuidanceids(); if (guidancelist != null) { for (int n = 0; n < guidancelist.length; n++) { MongoConnection mongoconsub = new MongoConnection(); DBCursor resultsubject = mongoconsub.getDBObject("guidanceid", guidancelist[n], "GuidanceSelection"); if (resultsubject.hasNext()) { DBObject thesubdbj = resultsubject.next(); String guidancesubj = (String) thesubdbj.get("guidanceSubject"); if (guidancesubj.equalsIgnoreCase(guidancesubject)) { guidanceidlist.add((String) thesubdbj.get("userid")); }/* w w w.j av a 2 s. c o m*/ } } } } } return guidanceidlist; }
From source file:com.fliker.Modal.GuidancePreview.java
public HashMap getAllGuidanceConsumingSubjectList(String userid) { // TODO Auto-generated method stub GuidancePreview guidprev = new GuidancePreview(); HashMap guidanceidset = new HashMap(); MongoConnection mongocon = new MongoConnection(); Assignment assignment = new Assignment(); DBCursor resultcursor = mongocon.getDBObject("userid", userid, "GuidanceSelection"); while (resultcursor.hasNext()) { DBObject dbj = resultcursor.next(); String provideid = (String) dbj.get("guidanceflag"); if (provideid.equalsIgnoreCase("consume")) { String guidancesubject = (String) dbj.get("guidanceSubject"); /*MongoConnection mongoconguid = new MongoConnection(); DBCursor resultguid = mongoconguid.getDBObject("guidanceid", guidanceid, "GuidanceSelection"); if(resultguid.hasNext()){*/ /*DBObject thedbj = resultguid.next(); String guidsubject = (String)dbj.get("guidanceSubject");*/ MongoConnection mongoconsub = new MongoConnection(); DBCursor resultsubject = mongoconsub.getDBObject("guidanceSubject", guidancesubject, "GuidanceSelection"); while (resultsubject.hasNext()) { DBObject thesubdbj = resultsubject.next(); String guidanceflag = (String) thesubdbj.get("guidanceflag"); if (guidanceflag.equalsIgnoreCase("provide")) { HashMap guidanceinfo = new HashMap(); guidanceinfo.put("guidancereason", (String) thesubdbj.get("guidancereason")); guidanceinfo.put("guidancelocation", (String) thesubdbj.get("guidancelocation")); guidanceinfo.put("guidanceduration", (String) thesubdbj.get("guidanceduration")); guidanceinfo.put("guidanceuserid", (String) thesubdbj.get("userid")); guidanceinfo.put("guidancesubject", (String) thesubdbj.get("guidanceSubject")); ProfilePreview profprev = new ProfilePreview(); ArrayList profileinfolist = profprev.getProfileInfo((String) thesubdbj.get("userid")); String profileid = ""; String profilename = ""; String profileimage = ""; for (int m = 0; m < profileinfolist.size(); m++) { if (profileinfolist.get(m) instanceof Profile) { Profile profileinform = (Profile) profileinfolist.get(m); profileid = profileinform.getProfileid(); profilename = profileinform.getName(); profileimage = profileinform.getProfileImageid(); }//from w ww .j av a 2s . c om } guidanceinfo.put("guidanceprofileid", profileid); guidanceinfo.put("guidanceprofilename", profilename); guidanceinfo.put("guidanceprofileimage", profileimage); guidanceidset.put((String) thesubdbj.get("guidanceid"), guidanceinfo); } } } } return guidanceidset; }
From source file:com.fliker.Modal.GuidancePreview.java
public void pagingGuide(String guidanceid, String userid) { // TODO Auto-generated method stub ArrayList subjectlist = new ArrayList(); MongoConnection mongoconsub = new MongoConnection(); DBCursor resultcursorsub = mongoconsub.getDBObject("userid", userid, "GuidanceSelection"); while (resultcursorsub.hasNext()) { DBObject subdbj = resultcursorsub.next(); String subject = (String) subdbj.get("guidanceSubject"); String guidancetoid = (String) subdbj.get("guidanceid"); subjectlist.add(subject + "::" + guidancetoid); }//from w w w . j a v a2s. co m MongoConnection mongocon = new MongoConnection(); DBCursor resultcursor = mongocon.getDBObject("guidanceid", guidanceid, "GuidanceSelection"); while (resultcursor.hasNext()) { DBObject dbj = resultcursor.next(); String currentsubject = (String) dbj.get("guidanceSubject"); for (int i = 0; i < subjectlist.size(); i++) { String subjecttocheck = ((String) subjectlist.get(i)).split("::")[0]; String guidancetocheck = ((String) subjectlist.get(i)).split("::")[1]; if (currentsubject.equalsIgnoreCase(subjecttocheck)) { MongoConnection mongoconnpage = new MongoConnection(); mongoconnpage.updateObject(new BasicDBObject("guidanceid", guidanceid), new BasicDBObject("$push", new BasicDBObject("guidancepaging", guidancetocheck)), "GuidanceSelection"); } } } }