List of usage examples for com.mongodb DBCursor hasNext
@Override public boolean hasNext()
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"; }//from w ww . jav a2 s . c o m } 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 www. j a v a 2 s .c o 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 w w. j a v a 2 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); }//w w w.j a va 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")); }//from w w w. j av a2s.co 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 w w.j a v a 2 s .c o m*/ } 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 ww w . j av a2s . c o 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"); } } } }
From source file:com.fliker.Modal.GuidancePreview.java
public void saveGuidanceAchievementInfo(String achievementdesc, String achievementname, String token, String userid, String guidanceid) { // TODO Auto-generated method stub String fileid = ""; MongoConnection mongocon = new MongoConnection(); DBCursor resultcursor = mongocon.getDBObject("tempid", token, "FileUnionTimeFrame"); while (resultcursor.hasNext()) { DBObject dbj = resultcursor.next(); String userids = (String) dbj.get("userid"); if (userids.equalsIgnoreCase(userid)) { fileid = (String) dbj.get("fileid"); }/*from w w w.ja va 2 s .c o m*/ } JSONObject jsonobj = new JSONObject(); jsonobj.put("achievement", achievementname); jsonobj.put("achievementdescription", achievementdesc); jsonobj.put("achievementtoken", token); jsonobj.put("achievementfile", fileid); String jsonstr = jsonobj.toJSONString(); System.out.println("jsonstr >>" + jsonstr); mongocon.updateObject(new BasicDBObject("guidanceinfoid", guidanceid), new BasicDBObject("$push", new BasicDBObject("guidanceachievements", jsonstr)), "GuidanceInfo"); }
From source file:com.fliker.Modal.GuidancePreview.java
public void saveFileToStudentsShare(String userids, String fileid, String guidanceid) { // TODO Auto-generated method stub GuidancePreview guidprev = new GuidancePreview(); if (userids.equalsIgnoreCase("All")) { MongoConnection mongocon = new MongoConnection(); DBCursor profilecursor = mongocon.getDBObject("guidanceid", guidanceid, "GuidanceContent"); while (profilecursor.hasNext()) { DBObject basicdbj = profilecursor.next(); BasicDBList userlist = (BasicDBList) basicdbj.get("consumeruserid"); for (int k = 0; k < userlist.size(); k++) { DBCursor profileusercursor = mongocon.getDBObject("userid", (String) userlist.get(k), "Profile"); while (profileusercursor.hasNext()) { DBObject basicprofdbj = profileusercursor.next(); BasicDBList guidancelist = (BasicDBList) basicprofdbj.get("guidanceids"); for (int g = 0; g < guidancelist.size(); g++) { DBCursor resultcursor = mongocon.getDBObject("guidanceid", (String) guidancelist.get(g), "GuidanceEntry"); while (resultcursor.hasNext()) { DBObject dbj = resultcursor.next(); String consumeguidanceid = (String) dbj.get("consumeguidanceid"); if (consumeguidanceid.equalsIgnoreCase(guidanceid)) { String sharetokenid = (String) dbj.get("sharetokenid"); mongocon.updateObject(new BasicDBObject("guidanceshareid", sharetokenid), new BasicDBObject("$push", new BasicDBObject("guidancefileids", fileid)), "GuidanceEntryShare"); }/*from www . ja v a 2s. c o m*/ } } } } } } else { String[] useridrow = userids.split(","); for (int i = 0; i < useridrow.length; i++) { MongoConnection mongocon = new MongoConnection(); DBCursor profilecursor = mongocon.getDBObject("userid", useridrow[i], "Profile"); while (profilecursor.hasNext()) { DBObject basicdbj = profilecursor.next(); BasicDBList guidancelist = (BasicDBList) basicdbj.get("guidanceids"); for (int g = 0; g < guidancelist.size(); g++) { DBCursor resultcursor = mongocon.getDBObject("guidanceid", (String) guidancelist.get(g), "GuidanceEntry"); while (resultcursor.hasNext()) { DBObject dbj = resultcursor.next(); String consumeguidanceid = (String) dbj.get("consumeguidanceid"); if (consumeguidanceid.equalsIgnoreCase(guidanceid)) { String sharetokenid = (String) dbj.get("sharetokenid"); mongocon.updateObject(new BasicDBObject("guidanceshareid", sharetokenid), new BasicDBObject("$push", new BasicDBObject("guidancefileids", fileid)), "GuidanceEntryShare"); } } } } } } GuidanceFileShare guidfileshare = new GuidanceFileShare(); if (userids.equalsIgnoreCase("All")) { String[] AllUser = { "All" }; guidfileshare.setConsumerids(AllUser); } else { String[] useridnew = userids.split(","); guidfileshare.setConsumerids(useridnew); } guidfileshare.setGuidancefileid(fileid); guidfileshare.setGuidanceid(guidanceid); MongoConnection mongocon = new MongoConnection(); BasicDBObject basicreqobjsearch = guidprev.formGuidShareDBObject(guidfileshare); mongocon.saveObject(basicreqobjsearch, "GuidanceDashFileShare"); }
From source file:com.fliker.Modal.GuidancePreview.java
public String getFileInfoId(String tokenui, String userid) { // TODO Auto-generated method stub String fileid = ""; MongoConnection mongocon = new MongoConnection(); DBCursor filecursor = mongocon.getDBObject("tempid", tokenui, "FileUnionTimeFrame"); while (filecursor.hasNext()) { DBObject basicdbj = filecursor.next(); String user = (String) basicdbj.get("userid"); if (user.equalsIgnoreCase(fileid)) { String context = (String) basicdbj.get("context"); if (context.contains("GuidanceID ::" + tokenui)) { fileid = (String) basicdbj.get("fileid"); }/*from w w w. jav a2s. c o m*/ } } return fileid; }