List of usage examples for com.mongodb DBCursor hasNext
@Override public boolean hasNext()
From source file:com.fliker.Modal.GuidancePreview.java
public ArrayList getAllGuidanceFiles(String guidanceid) { // TODO Auto-generated method stub ArrayList existingfiles = new ArrayList(); MongoConnection mongocon = new MongoConnection(); DBCursor filecursor = mongocon.getDBObject("guidancesharedid", guidanceid, "GuidanceContentShare"); while (filecursor.hasNext()) { DBObject basicdbj = filecursor.next(); BasicDBList filelist = (BasicDBList) basicdbj.get("guidancefilelistid"); for (int t = 0; t < filelist.size(); t++) { String filename = ""; String filesize = ""; DBCursor filenamecursor = mongocon.getDBObject("fileid", (String) filelist.get(t), "fileupload"); if (filenamecursor.hasNext()) { DBObject filedbj = filenamecursor.next(); existingfiles.add((String) filelist.get(t) + ":" + (String) filedbj.get("name") + ":" + (String) filedbj.get("size") + ":" + (String) filedbj.get("type")); }//from w w w. j ava 2s. c o m } } return existingfiles; }
From source file:com.fliker.Modal.GuidancePreview.java
public ArrayList fileExisting(String guidanceid) { // TODO Auto-generated method stub ArrayList filelst = new ArrayList(); FileUpload fileupload = new FileUpload(); MongoConnection mongocon = new MongoConnection(); DBCursor filecursor = mongocon.getDBObject("guidancesharedid", guidanceid, "GuidanceContentShare"); while (filecursor.hasNext()) { DBObject basicdbj = filecursor.next(); BasicDBList filelist = (BasicDBList) basicdbj.get("guidancefilelistid"); for (int t = 0; t < filelist.size(); t++) { DBCursor fileitemcursor = mongocon.getDBObject("id", (String) filelist.get(t), "fileupload"); while (fileitemcursor.hasNext()) { DBObject filedbj = fileitemcursor.next(); fileupload.setFileid((String) filedbj.get("id")); fileupload.setName((String) filedbj.get("name")); fileupload.setType((String) filedbj.get("type")); fileupload.setSize((Long) filedbj.get("size")); filelst.add(fileupload); }/* www. j a v a 2 s. c om*/ } } return filelst; }
From source file:com.fliker.Modal.GuidancePreview.java
public ArrayList getUnSharedConsumers(String fileid, String guidanceid) { // TODO Auto-generated method stub ArrayList consumerlist = new ArrayList(); ArrayList totaluserlst = new ArrayList(); ArrayList shareduserlst = new ArrayList(); MongoConnection mongocon = new MongoConnection(); DBCursor filecursor = mongocon.getDBObject("guidanceid", guidanceid, "GuidanceContent"); while (filecursor.hasNext()) { DBObject basicdbj = filecursor.next(); BasicDBList consumerlst = (BasicDBList) basicdbj.get("consumeruserid"); for (int m = 0; m < consumerlst.size(); m++) { totaluserlst.add((String) consumerlst.get(m)); }//from w w w .j a v a 2 s .c o m } DBCursor usercursor = mongocon.getDBObject("guidancefileid", fileid, "GuidanceDashFileShare"); while (usercursor.hasNext()) { DBObject userdbj = usercursor.next(); BasicDBList sharedconsumerlst = (BasicDBList) userdbj.get("consumerids"); for (int n = 0; n < sharedconsumerlst.size(); n++) { shareduserlst.add((String) sharedconsumerlst.get(n)); } } for (int t = 0; t < totaluserlst.size(); t++) { boolean isnotexist = false; String consumer = (String) totaluserlst.get(t); for (int i = 0; i < shareduserlst.size(); i++) { String sharedconsumer = (String) shareduserlst.get(i); if (consumer.equalsIgnoreCase(sharedconsumer)) { isnotexist = true; } } shareduserlst.add(consumer); } return shareduserlst; }
From source file:com.fliker.Modal.GuidancePreview.java
public ArrayList getAllEvent(String guidanceid) { // TODO Auto-generated method stub ArrayList alleventlist = new ArrayList(); MongoConnection mongocon = new MongoConnection(); DBCursor filecursor = mongocon.getDBObject("guidancecalendarid", guidanceid, "GuidanceContentCalendar"); while (filecursor.hasNext()) { DBObject basicdbj = filecursor.next(); BasicDBList eventobj = (BasicDBList) basicdbj.get("guidancecalendareventid"); for (int i = 0; i < eventobj.size(); i++) { DBCursor eventcursor = mongocon.getDBObject("eventid", (String) eventobj.get(i), "Event"); while (eventcursor.hasNext()) { DBObject eventdbj = eventcursor.next(); Events events = new Events(); events.setEvensharedbyuserid((String) eventdbj.get("evensharedbyuserid")); events.setEventDescription((String) eventdbj.get("eventDescription")); events.setEventendtime((String) eventdbj.get("eventendtime")); events.setEvententryid((String) eventdbj.get("evententryid")); events.setEventid((String) eventdbj.get("eventid")); events.setEventMonth((String) eventdbj.get("eventMonth")); events.setEventoccurance((String) eventdbj.get("eventoccurance")); events.setEventpriority((String) eventdbj.get("eventpriority")); BasicDBList eventsharedtouserids = (BasicDBList) eventdbj.get("eventsharedtouserids"); ArrayList eventlist = new ArrayList(); for (int m = 0; m < eventsharedtouserids.size(); m++) { eventlist.add((String) eventsharedtouserids.get(m)); }/*from w w w. jav a2 s .c o m*/ events.setEventsharedtouserids((String[]) eventlist.toArray(new String[eventlist.size()])); events.setEventstarttime((String) eventdbj.get("eventstarttime")); events.setEventtitle((String) eventdbj.get("eventtitle")); events.setEventWeekDay((String) eventdbj.get("eventWeekDay")); events.setEventYear((String) eventdbj.get("eventYear")); alleventlist.add(events); } } } return alleventlist; }
From source file:com.fliker.Modal.GuidancePreview.java
public HashMap getAvailableTime(String guidanceid, String entrydatetime, String entryendtime) { // TODO Auto-generated method stub HashMap profileavailable = new HashMap(); MongoConnection mongocon = new MongoConnection(); DBCursor guidecursor = mongocon.getDBObject("guidanceid", guidanceid, "GuidanceContent"); while (guidecursor.hasNext()) { DBObject guidedbj = guidecursor.next(); BasicDBList consumerlist = (BasicDBList) guidedbj.get("consumeruserid"); for (int m = 0; m < consumerlist.size(); m++) { ProfilePreview profprev = new ProfilePreview(); String eventAvail = profprev.getProfileEventList((String) consumerlist.get(m), entrydatetime, entryendtime);//from w w w. j a v a 2 s . c om if (eventAvail.equalsIgnoreCase("true")) { Profile profileinfo = profprev.getProfileData((String) consumerlist.get(m)); profileavailable.put("true", profileinfo); } else { Profile profileinfo = profprev.getProfileData((String) consumerlist.get(m)); profileavailable.put("false", profileinfo); } } } return profileavailable; }
From source file:com.fliker.Modal.GuidancePreview.java
public HashMap getGuidanceInfo(String guidanceid) { // TODO Auto-generated method stub HashMap guidaninfomap = new HashMap(); MongoConnection mongocon = new MongoConnection(); DBCursor guidecursor = mongocon.getDBObject("guidanceinfoid", guidanceid, "GuidanceInfo"); while (guidecursor.hasNext()) { DBObject guidedbj = guidecursor.next(); guidaninfomap.put("Description", (String) guidedbj.get("guidancedescription")); guidaninfomap.put("Price", (String) guidedbj.get("guidanceprice")); guidaninfomap.put("Experience", (String) guidedbj.get("guidancesubjectexperience")); ArrayList endorsementlist = new ArrayList(); BasicDBList endorsebylist = (BasicDBList) guidedbj.get("guidanceendorseby"); for (int m = 0; m < endorsebylist.size(); m++) { DBCursor endorsecursor = mongocon.getDBObject("companyid", (String) endorsebylist.get(m), "Company"); while (endorsecursor.hasNext()) { DBObject companydbj = endorsecursor.next(); endorsementlist.add((String) companydbj.get("companylogoid")); }// ww w . j a va2 s. c om } guidaninfomap.put("Endorsement", endorsementlist); BasicDBList achievementlist = (BasicDBList) guidedbj.get("guidanceachievements"); guidaninfomap.put("Achievement", achievementlist); DBCursor dashcursor = mongocon.getDBObject("guidancecontentDashid", guidanceid, "GuidanceContentDash"); if (dashcursor.hasNext()) { DBObject dashdbj = dashcursor.next(); BasicDBList dashdatalist = (BasicDBList) guidedbj.get("guidancedashdataid"); int remarkavg = 0; if (dashdatalist != null) { int totaldash = dashdatalist.size(); int dashcount = 0; for (int j = 0; j < dashdatalist.size(); j++) { DBCursor dashdatacursor = mongocon.getDBObject("guidancedashdataid", guidanceid, "GuidanceContentDashData"); while (dashdatacursor.hasNext()) { DBObject dashdatadbj = dashdatacursor.next(); String levelrem = (String) dashdatadbj.get("guidancedashlevelremark"); String helpremark = (String) dashdatadbj.get("guidancedashhelpremark"); dashcount = dashcount + (Integer.parseInt(levelrem) + Integer.parseInt(helpremark)) / 2; } } if (totaldash > 0 && dashcount > 0) { remarkavg = dashcount / totaldash; } } guidaninfomap.put("Remarks", remarkavg); BasicDBList locationlist = (BasicDBList) guidedbj.get("guidancelocationids"); guidaninfomap.put("Locations", locationlist); } DBCursor guidrstcursor = mongocon.getDBObject("guidanceid", guidanceid, "GuidanceSelection"); while (guidrstcursor.hasNext()) { DBObject guiderstdbj = guidrstcursor.next(); guidaninfomap.put("Subject", (String) guiderstdbj.get("guidanceSubject")); guidaninfomap.put("GuidanceType", (String) guiderstdbj.get("guidencetype")); guidaninfomap.put("GuidanceDuration", (String) guiderstdbj.get("guidanceduration")); BasicDBList guidinterlist = (BasicDBList) guidedbj.get("guidanceinterest"); guidaninfomap.put("GuidanceInterest", guidinterlist); guidaninfomap.put("Userid", (String) guiderstdbj.get("userid")); } } return guidaninfomap; }
From source file:com.fliker.Modal.GuidancePreview.java
public HashMap getBillDetail(String billid) { // TODO Auto-generated method stub HashMap billmap = new HashMap(); MongoConnection mongocon = new MongoConnection(); DBCursor guidecursor = mongocon.getDBObject("billid", billid, "Bill"); if (guidecursor.hasNext()) { DBObject guidedbj = guidecursor.next(); billmap.put("billid", (String) guidedbj.get("billid")); billmap.put("contractid", (String) guidedbj.get("contractid")); billmap.put("planid", (String) guidedbj.get("planid")); billmap.put("licenseid", (String) guidedbj.get("licenseid")); billmap.put("invoiceid", (String) guidedbj.get("invoiceid")); billmap.put("payfromid", (String) guidedbj.get("payfromid")); billmap.put("paytoid", (String) guidedbj.get("paytoid")); billmap.put("totalamount", (String) guidedbj.get("totalamount")); billmap.put("item", (String) guidedbj.get("item")); billmap.put("paymentmethods", (String) guidedbj.get("paymentmethods")); billmap.put("billdate", (String) guidedbj.get("billdate")); billmap.put("billlocaldate", (String) guidedbj.get("billlocaldate")); }//w w w.j a v a 2 s .co m return billmap; }
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;// www .j ava2s. 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 www. jav a 2 s .co 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()); }/* ww w. j a v a2 s . c om*/ } totalSet.put("guidanceuserid", (String) guiddbj.get("userid")); guidancelist.add(totalSet); } } return guidancelist; }