ArrayList<To_Sender_Person> Load_Sender_Person(Long Time, int num) { ArrayList<To_Sender_Person> Sender_Person_List = new ArrayList<To_Sender_Person>(); DBCursor Personcur; SendMailColl = SendMailDB.getCollection(Time.toString()); Personcur = SendMailColl.find(new BasicDBObject("sending", false)); if (Personcur.count() != 0) { for (int i = 0; i < num; i++) { if (!Personcur.hasNext()) break; To_Sender_Person Temp_Person = new To_Sender_Person(); Temp_Person.ObjectID = Personcur.next().get("_id").toString(); Temp_Person.To_Adress = Personcur.curr().get("toaddress").toString(); Temp_Person.Key = Integer.parseInt(Personcur.curr().get("key").toString()); Sender_Person_List.add(Temp_Person); } } Boolean True; True = true; for (To_Sender_Person person : Sender_Person_List) { BasicDBObject newDocument3 = new BasicDBObject().append("$set", new BasicDBObject().append("sending", True)); ObjectId id = new ObjectId(person.ObjectID); SendMailColl.update(new BasicDBObject().append("_id", id), newDocument3); } return Sender_Person_List; }
ArrayList<Person> Load_GroupList(String G_Name) { ArrayList<Person> PersonList = new ArrayList<Person>(); GroupColl = AdressDB.getCollection(G_Name); if (GroupColl.getCount() != 0) { DBCursor cur; cur = GroupColl.find(); while (cur.hasNext()) { Person P_Temp = new Person(); P_Temp.ObjectID = cur.next().get("_id").toString(); P_Temp.Name = cur.curr().get("name").toString(); P_Temp.Mail_Address = cur.curr().get("mail").toString(); P_Temp.Phone = cur.curr().get("phone").toString(); PersonList.add(P_Temp); } } else { System.out.println("그룹에 사람 없음"); } return PersonList; }
@Override public void getLocations() { final BasicDBObject query = new BasicDBObject(); final BasicDBObject fields = new BasicDBObject(); query.put("Request details.Request type", POST); query.put("Request details.Reply code", SUCCESS_REPLY_CODE); fields.put("Host location", 1); fields.put("Server details.Server location", 1); fields.put("_id", 0); final DBCursor result = table.find(query, fields); final StringBuilder locations = new StringBuilder(); while (result.hasNext()) { final String hostLocation = (String) result.next().get("Host location"); final BasicDBObject requestDetails = (BasicDBObject) result.curr().get("Server details"); final String serverLocation = requestDetails.getString("Server location"); locations.append(hostLocation + " - " + serverLocation + "\n"); } System.out.println("getLocations:"); System.out.println(locations); }
void printResults() { DBCursor cur; cur = GroupColl.find(); while (cur.hasNext()) { System.out.println( cur.next().get("index") + "," + cur.curr().get("name") + "," + cur.curr().get("mail") + "," + cur.curr().get("phone")); } }
ArrayList<Send_Mail> Add_Mail_List(DBCursor cur) { ArrayList<Send_Mail> Mail = new ArrayList<Send_Mail>(); while (cur.hasNext()) { Send_Mail Mail_Temp = new Send_Mail(); Mail_Temp.From_Adress = cur.next().get("from_adress").toString(); Mail_Temp.Mail_Content = cur.curr().get("content").toString(); Mail_Temp.Mail_Title = cur.curr().get("title").toString(); Mail_Temp.Send_Num = Integer.parseInt(cur.curr().get("num").toString()); Mail_Temp.Send_Time = Long.parseLong(cur.curr().get("time").toString()); Mail_Temp.UserName = cur.curr().get("username").toString(); Mail.add(Mail_Temp); } return Mail; }
// 删除指定id的语料 public void deletecorpus() throws UnknownHostException { String message = "请输入要读取的文本编号!"; long idm = 1; Object obj = JOptionPane.showInputDialog(null, message, idm); String obj1 = (String) obj; if (obj1 == null) { return; } long id1 = Long.parseLong(obj1); MongoClient mc = null; DB db = null; mc = new MongoClient("127.0.0.1", 27017); db = mc.getDB("corpus"); DBCollection textsave = null; if (Readcorpustype == "熟语料") { textsave = db.getCollection("ripe"); } else if (Readcorpustype == "生语料") { textsave = db.getCollection("raw"); } else if (Readcorpustype == null) { JOptionPane.showMessageDialog(null, "请在帮助菜单中设置语料类型!"); return; } DBCursor cursor = textsave.find(); Gson gson = new Gson(); long countoftextsave = textsave.getCount(); long counti = 0; long uid = -1; while (cursor.hasNext()) { DBObject st = cursor.next(); Savetext u = gson.fromJson(st.toString(), Savetext.class); counti++; uid = u.id; if (uid == id1) { ReadDbobject = cursor.curr(); textsave.remove(ReadDbobject); System.out.println("删除成功"); break; } else if (uid != id1) { continue; } } if ((counti == countoftextsave) && (uid != id1)) { JOptionPane.showMessageDialog(null, "wrong id!"); return; } }
ArrayList<User> Load_UserList() { ArrayList<User> User_List = new ArrayList<User>(); UserColl = UserDB.getCollection("User"); if (UserColl.getCount() != 0) { DBCursor cur; cur = UserColl.find(); while (cur.hasNext()) { User U_Temp = new User(); U_Temp.ID = cur.next().get("id").toString(); U_Temp.PW = cur.curr().get("password").toString(); U_Temp.Key = null; User_List.add(U_Temp); } } return User_List; }
private boolean checkMatch( int candidate, int lowerIndex, DBCursor upper, Integer lowerOffset, Integer upperOffset) { int prime1, prime2, test; List<Integer> currentLower = _lower; if (_emergencyLower != null && _emergencyLower.size() > 0) currentLower = _emergencyLower; while (lowerIndex < currentLower.size() && upper.hasNext()) { prime1 = (Integer) currentLower.get(lowerIndex); prime2 = (Integer) upper.curr().get("prime"); test = prime1 + prime2; _numTests++; if (test == candidate) { _collector.emit(new Values(candidate, prime1, prime2, _numTests)); return true; } else if (test < candidate) { lowerIndex++; } else if (test > candidate) { upper.next(); } } if (lowerIndex == currentLower.size()) { DBCursor cur = getBottomPrimesChunk(candidate, CHUNK_SIZE, lowerOffset += CHUNK_SIZE); _emergencyLower.clear(); while (cur.hasNext()) _emergencyLower.add((Integer) cur.next().get("prime")); return checkMatch(candidate, 0, upper, lowerOffset, upperOffset); } else if (!upper.hasNext()) return checkMatch( candidate, lowerIndex, getTopPrimesChunk(candidate, CHUNK_SIZE, upperOffset += CHUNK_SIZE), lowerOffset, upperOffset); // this means there are no more primes to look through that are less than the candidate // if conjecture is true this should never happen _collector.emit(new Values(candidate, null, null, _numTests)); return false; }
ArrayList<To_Person> Load_Client_person(Long Time) { ArrayList<To_Person> Client_Person_List = new ArrayList<To_Person>(); DBCursor Personcur; SendMailColl = SendMailDB.getCollection(Time.toString()); Personcur = SendMailColl.find(); while (Personcur.hasNext()) { To_Person P_Temp = new To_Person(); P_Temp.ObjectID = Personcur.next().get("_id").toString(); P_Temp.Sending = Boolean.valueOf(Personcur.curr().get("sending").toString()); P_Temp.Check_Time = Long.parseLong(Personcur.curr().get("checktime").toString()); P_Temp.To_Adress = Personcur.curr().get("toaddress").toString(); P_Temp.Cord = Personcur.curr().get("cord").toString(); P_Temp.Group_Name = Personcur.curr().get("group_name").toString(); P_Temp.Key = Integer.parseInt(Personcur.curr().get("key").toString()); Client_Person_List.add(P_Temp); } return Client_Person_List; }
// 根据id读取语料 public void readMongo() throws UnknownHostException { // new XialaLiebiaoTest(); String message = "请输入要读取的文本编号!"; long idm = 1; Object obj = JOptionPane.showInputDialog(null, message, idm); String obj1 = (String) obj; if (obj1 == null) { return; } id = Long.parseLong(obj1); MongoClient mc = null; DB db = null; mc = new MongoClient("127.0.0.1", 27017); db = mc.getDB("corpus"); DBCollection textsave = null; if (Readcorpustype == "熟语料") { textsave = db.getCollection("ripe"); } else if (Readcorpustype == "生语料") { textsave = db.getCollection("raw"); } else if (Readcorpustype == null) { JOptionPane.showMessageDialog(null, "请在帮助菜单中设置语料类型!"); return; } DBCursor cursor = textsave.find(); // SimpleAttributeSet att=new SimpleAttributeSet(); Gson gson = new Gson(); long countoftextsave = textsave.getCount(); long counti = 0; long uid = -1; while (cursor.hasNext()) { DBObject st = cursor.next(); Savetext u = gson.fromJson(st.toString(), Savetext.class); counti++; uid = u.id; if (uid == id) { editorDockable1.text.setText(u.TermListString1); termList = u.TermList1; fileContent1 = u.MetaData1; keywordList = u.Keyword1; sentenceList = u.KeySentence1; summaryList = u.Summary1; TermListString1 = u.TermListString1; for (int i = 0; i < termList.size(); i++) { randomColor(); setColorss(termList.get(i).toString(), new Color(r, g, b)); } ReadDbobject = cursor.curr(); break; } else if (uid != id) { continue; } } if ((counti == countoftextsave) && (uid != id)) { JOptionPane.showMessageDialog(null, "wrong id!"); return; } System.out.println(countoftextsave); System.out.println(counti); System.out.println(ReadDbobject); }
@Command( aliases = {"data"}, usage = "<player> <options>", desc = "Displays a summary of data applicable to a player", min = 1, max = 2) @CommandPermissions({"oresomedata.view"}) public void transact(CommandContext args, CommandSender sender) { DB database = MongoDatabaseManager.mongo.getDB(MongoDatabaseManager.mongodb_db); DBCollection playerTable = database.getCollection("players"); BasicDBObject searchQuery = new BasicDBObject(); searchQuery.put("name", args.getString(0)); DBCursor cursor = playerTable.find(searchQuery); if (cursor.size() > 0) { if (cursor.size() == 1) { BasicDBObject playerDocument = (BasicDBObject) cursor.curr(); StringBuilder overview = new StringBuilder(); StringBuilder statisticString = new StringBuilder(); StringBuilder raidHouseString = new StringBuilder(); overview.append( ChatColor.GREEN + "++++++++ " + ChatColor.AQUA + args.getString(0) + ChatColor.GREEN + " ++++++++\n"); overview.append(ChatColor.GOLD + "UUID: " + playerDocument.getString("uuid") + "\n"); overview.append(ChatColor.GOLD + "Coins: " + playerDocument.getString("coins") + "\n"); if (playerDocument.get("statistics") != null) { BasicDBObject statistics = (BasicDBObject) playerDocument.get("statistics"); statisticString.append(ChatColor.GREEN + "--------- Stats --------\n"); statisticString.append(ChatColor.GOLD + "Kills: " + statistics.getString("kills") + "\n"); statisticString.append( ChatColor.GOLD + "Deaths: " + statistics.getString("deaths") + "\n"); statisticString.append( ChatColor.GOLD + "K/D Ratio: " + statistics.getString("ks") + "\n"); statisticString.append( ChatColor.GOLD + "FFA Wins: " + statistics.getString("ffawins") + "\n"); statisticString.append( ChatColor.GOLD + "Infection Wins: " + statistics.getString("infectionwins") + "\n"); statisticString.append( ChatColor.GOLD + "Highest Streak: " + statistics.getString("highestkillstreak") + "\n"); // statisticString.append(ChatColor.GREEN + "-------- -------- --------\n"); } if (playerDocument.get("raidhouse") != null) { BasicDBObject raidHouse = (BasicDBObject) playerDocument.get("raidhouse"); raidHouseString.append(ChatColor.GREEN + "-------- RaidHouse --------\n"); raidHouseString.append( ChatColor.GOLD + "Recognition: " + raidHouse.getString("recognition") + "\n"); raidHouseString.append(ChatColor.GOLD + "Tier: " + raidHouse.getString("tier") + "\n"); raidHouseString.append( ChatColor.GOLD + "Total Raids: " + raidHouse.getString("totalraids") + "\n"); raidHouseString.append( ChatColor.GOLD + "Successful Raids: " + raidHouse.getString("successfulraids") + "\n"); raidHouseString.append( ChatColor.GOLD + "Failed Raids: " + raidHouse.getString("failedraids") + "\n"); raidHouseString.append( ChatColor.GOLD + "Reroll Amount: " + raidHouse.getString("rerollamount") + "\n"); // raidHouseString.append(ChatColor.GREEN + "-------- -------- --------\n"); } // sender.sendMessage(ChatColor.GREEN + "++++++++ ++++++++ ++++++++"); SortedMap<Integer, String> map = new TreeMap<Integer, String>(); if (overview.toString().length() > 0) { map.put(1, overview.toString()); } if (statisticString.toString().length() > 0) { map.put(2, statisticString.toString()); } if (raidHouseString.length() > 0) { map.put(3, raidHouseString.toString()); } if (args.getString(1) != null) { paginate(sender, map, Integer.parseInt(args.getString(1)), 7); } else { paginate(sender, map, 1, 7); } } else { sender.sendMessage( ChatColor.RED + "More than one result was found! Are you sure you spelt the player's name correctly?"); } } else { } }