List of usage examples for java.util TreeMap keySet
public Set<K> keySet()
From source file:Main.java
public static void main(String[] args) { TreeMap<String, String> treeMap = new TreeMap<String, String>(); treeMap.put("1", "One"); treeMap.put("3", "Three"); treeMap.put("2", "Two"); Set st = treeMap.keySet(); Iterator itr = st.iterator(); while (itr.hasNext()) { System.out.println(itr.next()); }//from w ww. ja v a 2 s . c o m st.remove("1"); System.out.println(treeMap.containsKey("1")); }
From source file:Main.java
public static void main(String[] args) { TreeMap<Integer, String> treemap = new TreeMap<Integer, String>(); // populating tree map treemap.put(2, "two"); treemap.put(1, "one"); treemap.put(3, "three"); treemap.put(6, "six"); treemap.put(5, "from java2s.com"); // creating set Set set = treemap.keySet(); // getting set view System.out.println("Checking values of the set"); System.out.println("Value is: " + set); }
From source file:module.entities.UsernameChecker.CheckOpengovUsernames.java
/** * @param args the command line arguments *///w w w.j av a 2 s . c o m public static void main(String[] args) throws SQLException, IOException { // args = new String[1]; // args[0] = "searchConf.txt"; Date d = new Date(); long milTime = d.getTime(); long execStart = System.nanoTime(); Timestamp startTime = new Timestamp(milTime); long lStartTime; long lEndTime = 0; int status_id = 1; JSONObject obj = new JSONObject(); if (args.length != 1) { System.out.println("None or too many argument parameters where defined! " + "\nPlease provide ONLY the configuration file name as the only argument."); } else { try { configFile = args[0]; initLexicons(); Database.init(); lStartTime = System.currentTimeMillis(); System.out.println("Opengov username identification process started at: " + startTime); usernameCheckerId = Database.LogUsernameChecker(lStartTime); TreeMap<Integer, String> OpenGovUsernames = Database.GetOpenGovUsers(); HashSet<ReportEntry> report_names = new HashSet<>(); if (OpenGovUsernames.size() > 0) { for (int userID : OpenGovUsernames.keySet()) { String DBusername = Normalizer .normalize(OpenGovUsernames.get(userID).toUpperCase(locale), Normalizer.Form.NFD) .replaceAll("\\p{M}", ""); String username = ""; int type; String[] splitUsername = DBusername.split(" "); if (checkNameInLexicons(splitUsername)) { for (String splText : splitUsername) { username += splText + " "; } type = 1; } else if (checkOrgInLexicons(splitUsername)) { for (String splText : splitUsername) { username += splText + " "; } type = 2; } else { username = DBusername; type = -1; } ReportEntry cerEntry = new ReportEntry(userID, username.trim(), type); report_names.add(cerEntry); } status_id = 2; obj.put("message", "Opengov username checker finished with no errors"); obj.put("details", ""); Database.UpdateOpengovUsersReportName(report_names); lEndTime = System.currentTimeMillis(); } else { status_id = 2; obj.put("message", "Opengov username checker finished with no errors"); obj.put("details", "No usernames needed to be checked"); lEndTime = System.currentTimeMillis(); } } catch (Exception ex) { System.err.println(ex.getMessage()); status_id = 3; obj.put("message", "Opengov username checker encountered an error"); obj.put("details", ex.getMessage().toString()); lEndTime = System.currentTimeMillis(); } } long execEnd = System.nanoTime(); long executionTime = (execEnd - execStart); System.out.println("Total process time: " + (((executionTime / 1000000) / 1000) / 60) + " minutes."); Database.UpdateLogUsernameChecker(lEndTime, status_id, usernameCheckerId, obj); Database.closeConnection(); }
From source file:module.entities.NameFinder.RegexNameFinder.java
/** * @param args the command line arguments *//* www . j av a2 s . c o m*/ public static void main(String[] args) throws SQLException, IOException { if (args.length == 1) { Config.configFile = args[0]; } long lStartTime = System.currentTimeMillis(); Timestamp startTime = new Timestamp(lStartTime); System.out.println("Regex Name Finder process started at: " + startTime); DB.initPostgres(); regexerId = DB.LogRegexFinder(lStartTime); initLexicons(); JSONObject obj = new JSONObject(); TreeMap<Integer, String> consultations = DB.getDemocracitConsultationBody(); Document doc; int count = 0; TreeMap<Integer, String> consFoundNames = new TreeMap<>(); TreeMap<Integer, String> consFoundRoles = new TreeMap<>(); for (int consId : consultations.keySet()) { String consBody = consultations.get(consId); String signName = "", roleName = ""; doc = Jsoup.parse(consBody); Elements allPars = new Elements(); Elements paragraphs = doc.select("p"); for (Element par : paragraphs) { if (par.html().contains("<br>")) { String out = "<p>" + par.html().replaceAll("<br>", "</p><p>") + "</p>"; Document internal_doc = Jsoup.parse(out); Elements subparagraphs = internal_doc.select("p"); allPars.addAll(subparagraphs); } else { allPars.add(par); } // System.out.println(formatedText); } String signature = getSignatureFromParagraphs(allPars); // System.out.println(signature); if (signature.contains("#")) { String[] sign_tokens = signature.split("#"); signName = sign_tokens[0]; if (sign_tokens.length > 1) { roleName = sign_tokens[1]; } consFoundNames.put(consId, signName.trim()); consFoundRoles.put(consId, roleName.trim()); count++; } else { System.err.println("--" + consId); } // } DB.insertDemocracitConsultationMinister(consFoundNames, consFoundRoles); TreeMap<Integer, String> consultationsCompletedText = DB.getDemocracitCompletedConsultationBody(); Document doc2; TreeMap<Integer, String> complConsFoundNames = new TreeMap<>(); int count2 = 0; for (int consId : consultationsCompletedText.keySet()) { String consBody = consultationsCompletedText.get(consId); String signName = "", roleName = ""; doc2 = Jsoup.parse(consBody); // if (doc.text().contains("<br>")) { // doc.text().replaceAll("(<[Bb][Rr]>)+", "<p>"); // } Elements allPars = new Elements(); Elements paragraphs = doc2.select("p"); for (Element par : paragraphs) { if (par.html().contains("<br>")) { String out = "<p>" + par.html().replaceAll("<br>", "</p><p>") + "</p>"; Document internal_doc = Jsoup.parse(out); Elements subparagraphs = internal_doc.select("p"); allPars.addAll(subparagraphs); } else { allPars.add(par); } } String signature = getSignatureFromParagraphs(allPars); if (signature.contains("#")) { String[] sign_tokens = signature.split("#"); signName = sign_tokens[0]; if (sign_tokens.length > 1) { roleName = sign_tokens[1]; } consFoundNames.put(consId, signName.trim()); consFoundRoles.put(consId, roleName.trim()); // System.out.println(consId); // System.out.println(signName.trim()); // System.out.println("***************"); count2++; } else { System.err.println("++" + consId); } } DB.insertDemocracitConsultationMinister(complConsFoundNames, consFoundRoles); long lEndTime = System.currentTimeMillis(); System.out.println("Regex Name Finder process finished at: " + startTime); obj.put("message", "Regex Name Finder finished with no errors"); obj.put("details", ""); DB.UpdateLogRegexFinder(lEndTime, regexerId, obj); DB.close(); }
From source file:SortedMapDemo.java
public static void main(String[] args) { TreeMap sortedMap = new TreeMap(); sortedMap.put("Adobe", "Mountain View, CA"); sortedMap.put("IBM", "White Plains, NY"); sortedMap.put("Learning Tree", "Los Angeles, CA"); sortedMap.put("Microsoft", "Redmond, WA"); sortedMap.put("Netscape", "Mountain View, CA"); sortedMap.put("O'Reilly", "Sebastopol, CA"); sortedMap.put("Sun", "Mountain View, CA"); System.out.println(sortedMap); Object low = sortedMap.firstKey(), high = sortedMap.lastKey(); System.out.println(low);//from w w w. j a v a2 s. co m System.out.println(high); Iterator it = sortedMap.keySet().iterator(); for (int i = 0; i <= 6; i++) { if (i == 3) low = it.next(); if (i == 6) high = it.next(); else it.next(); } System.out.println(low); System.out.println(high); System.out.println(sortedMap.subMap(low, high)); System.out.println(sortedMap.headMap(high)); System.out.println(sortedMap.tailMap(low)); }
From source file:com.github.xbn.examples.io.non_xbn.SizeOrderAllFilesInDirXmpl.java
public static final void main(String[] ignored) { File fDir = (new File("R:\\jeffy\\programming\\sandbox\\xbnjava\\xbn\\")); Collection<File> cllf = FileUtils.listFiles(fDir, (new String[] { "java" }), true); //Add all file paths to a Map, keyed by size. //It's actually a map of lists-of-files, to //allow multiple files that happen to have the //same length. TreeMap<Long, List<File>> tmFilesBySize = new TreeMap<Long, List<File>>(); Iterator<File> itrf = cllf.iterator(); while (itrf.hasNext()) { File f = itrf.next();/* ww w . j ava 2 s. c o m*/ Long LLen = f.length(); if (!tmFilesBySize.containsKey(LLen)) { ArrayList<File> alf = new ArrayList<File>(); alf.add(f); tmFilesBySize.put(LLen, alf); } else { tmFilesBySize.get(LLen).add(f); } } //Iterate backwards by key through the map. For each //List<File>, iterate through the files, printing out //its size and path. ArrayList<Long> alSize = new ArrayList<Long>(tmFilesBySize.keySet()); for (int i = alSize.size() - 1; i >= 0; i--) { itrf = tmFilesBySize.get(alSize.get(i)).iterator(); while (itrf.hasNext()) { File f = itrf.next(); System.out.println(f.length() + ": " + f.getPath()); } } }
From source file:subsets.GenerateGFKMatrix.java
public static void main(String args[]) { CollectionTools ct = new CollectionTools(); GenerateGFKMatrix gfk = new GenerateGFKMatrix(); TreeMap<String, HashSet> SmartCube_SCAttribut = gfk.get_AType_Relation_BType("SmartCube", "SCAttribut", "MEMBER_OF", 1); TreeMap<String, HashSet> SCAttribut_BCAttribut_part1 = gfk.get_AType_Relation_BType("SCAttribut", "BCAttribut", "TRANSITION", -1); TreeMap<String, HashSet> SCAttribut_SCAlgo = gfk.get_AType_Relation_BType("SCAttribut", "SCAlgorithmen", "DERIVED_BY", -1); TreeMap<String, HashSet> SCAlgo_BCAttribut = gfk.get_AType_Relation_BType("SCAlgorithmen", "BCAttribut", "USES", -1); gfk.get_AType_Relation_BType("Meldekonzept", "BCAttribut", "USES", -1); //MATCH (c:Codeliste)<-[:MEMBER_OF]-(cd:Code) WHERE c.Name = "Geschaeftsfallkategorie_CL" RETURN c,cd HashSet gfks = gfk.getGFKs(); TreeMap<String, String> Meldekonzepte_formbeschreibung = gfk.getMeldekonzepte_formbeschreibung(); TreeMap<String, HashSet> Meldekonzept_GFK = new TreeMap(); for (String mk : Meldekonzepte_formbeschreibung.keySet()) { String form_beschreibung = Meldekonzepte_formbeschreibung.get(mk); Iterator it = gfks.iterator(); while (it.hasNext()) { String gfkategorie = (String) it.next(); if (form_beschreibung.contains(gfkategorie)) { HashSet dummy = Meldekonzept_GFK.get(mk); if (dummy == null) { dummy = new HashSet(); dummy.add(gfkategorie); Meldekonzept_GFK.put(mk, dummy); }// w w w . j a va 2 s . co m dummy.add(gfkategorie); } } } TreeMap<String, HashSet> SmartCube_BCAttribut = ct .join_string_hashset_and_string_hashset(SmartCube_SCAttribut, SCAttribut_BCAttribut_part1); TreeMap<String, HashSet> SmartCube_SCAlgo = ct.join_string_hashset_and_string_hashset(SmartCube_SCAttribut, SCAttribut_SCAlgo); TreeMap<String, HashSet> SCAttribut_BCAttribut_part2 = ct .join_string_hashset_and_string_hashset(SmartCube_SCAlgo, SCAlgo_BCAttribut); TreeMap<String, HashSet> SCAttribut_BCAttribut = new TreeMap(); SCAttribut_BCAttribut.putAll(SCAttribut_BCAttribut_part1); SCAttribut_BCAttribut.putAll(SCAttribut_BCAttribut_part2); //TreeMap<String,JSONObject> SC_BC_Dependency = gfk.get_SC_BC_Dependency(); //Achtung: in der Klasse GenerateSCSubset sind alle Subsets definiert GenerateSCSubset gensubset = new GenerateSCSubset(); //Erzeuge alle Smart Cube Matrizen // TreeMap<String,TreeMap<String, HashSet>> dependency_structure= new TreeMap(); // // // ArrayList<Cube> all_cubes = gensubset.getCubeDependency_ArrayList(); // // //get all relevant Dimensions // //GFK - MappingTabelle GFK : TreeMap<String (GFK), Set of BC Attribute > TreeMap<String, HashSet> GFK_BCAttribut = new TreeMap(); //Hier wird eigentlcihe Dependency Matrix aufgebaut for (int i = 0; i < all_cubes.size(); i++) { System.out.println(((Cube) all_cubes.get(i)).Bezeichnung); Cube cube = all_cubes.get(i); for (String mk : cube.Meldekonzept_SCDimensionen.keySet()) { HashSet scattribute_pro_meldekonzept = cube.Meldekonzept_SCDimensionen.get(mk); Iterator it = scattribute_pro_meldekonzept.iterator(); //Meldekonzept get BCAttribute = MK_Basic Cube Attribut HashSet geschaeftsfallkategorien = Meldekonzept_GFK.get(mk); HashSet Meldekonzept_BCDependency = new HashSet(); //schritt fr schritt durchgehen while (it.hasNext()) {//gehe Attribute pro Meldekonzept druch String SCAttribut = (String) it.next(); HashSet BasicCubeAttribute = SCAttribut_BCAttribut.get(SCAttribut); // // // Fehler - SCAttribut_BCAttribut : Diese Datenstruktur enthaelt auch Cubes anstatt NUR SCAttribute // // //BasicCubeAttribute kann null sein ? Meldekonzept_BCDependency.addAll(BasicCubeAttribute); } Iterator gfk_iterator = geschaeftsfallkategorien.iterator(); while (gfk_iterator.hasNext()) { String gfkategorie = (String) gfk_iterator.next(); HashSet dummy = new HashSet(); dummy.addAll(Meldekonzept_BCDependency); GFK_BCAttribut.put(gfkategorie, dummy); } } all_cubes.get(i).showMeldekonzept_SCDimensionen(); } System.out.println("Test1234"); }
From source file:version1.Neo4jTest.Wiki2Neo4j.java
public static void main(final String[] args) { System.out.println("Starting"); Wiki2Neo4j hello = new Wiki2Neo4j(); HTMLParser wikiparser = new HTMLParser("frischwo01", "winter2014"); WikiLinks wikilinks = new WikiLinks(); String SC_Attribute_link = wikilinks.sc_attribute_link; String BC_Entitaeten_link = "https://www.myoenb.com/wiki/display/TES/.Entitaeten+des+Basic+Cubes+v2.0"; String BC_Attribute_link = wikilinks.basiccubeatttribute; String Meldekonzepte_link = wikilinks.meldekonzepte_link; String SC_Algorithmen_link = "https://www.myoenb.com/wiki/display/TES/.Algorithmen+v3.11"; String BC_Algorithmen_link = "https://www.myoenb.com/wiki/display/TES/.Algorithmen+des+Basic+Cubes+v3.11"; //working//from ww w . ja v a 2s .co m // String SC_Attribute_link = "https://www.myoenb.com/wiki/display/TES/.Smart+Cube+Attribute+v2.0"; // String BC_Entitaeten_link = "https://www.myoenb.com/wiki/display/TES/.Entitaeten+des+Basic+Cubes+v2.0"; // String BC_Attribute_link = "https://www.myoenb.com/wiki/display/TES/.Attribute+des+Basic+Cubes+v2.0"; // String Meldekonzepte_link = wikilinks.meldekonzepte_link; // String SC_Algorithmen_link = "https://www.myoenb.com/wiki/display/TES/.Algorithmen+v0.00"; // String BC_Algorithmen_link = "https://www.myoenb.com/wiki/display/TES/.Algorithmen+des+Basic+Cubes+v1.1"; //String SmartCubes_link = "https://www.myoenb.com/wiki/display/TES/.Smart+Cubes+Metabeschreibung+v1.2"; GenerateSCSubset gebsubset = new GenerateSCSubset(); ArrayList<Cube> all_cubes = new ArrayList(); gebsubset.setup_all_Cubes(all_cubes); boolean parseCL = true; deleteFileOrDirectory(new File(DB_PATH));//loescht Graph Database //Initialisiere Datenbank am Anfang hello.graphDb = new GraphDatabaseFactory().newEmbeddedDatabase(DB_PATH); registerShutdownHook(hello.graphDb); boolean parsing_false = true; ArrayList codelisteArrayList = null; if (parseCL) { while (parsing_false) { try { codelisteArrayList = wikiparser .Codelisten("https://www.myoenb.com/wiki/display/TES/.Codelisten+des+Basic+Cubes+v2.0"); if (codelisteArrayList.size() > 1) parsing_false = false; } catch (Exception e) { System.out.println(e.toString()); } } for (int i = 0; i < codelisteArrayList.size(); i++) { Codeliste codeliset = (Codeliste) codelisteArrayList.get(i); System.out.println("adding Codelist"); hello.addCodeliste2Db(codeliset); } } TreeMap<String, TreeMap> SmartCubes = new TreeMap(); //wikiparser.ParseObject(SmartCubes_link,"-Cube"); TreeMap<String, TreeMap> SC_Attribute = wikiparser.ParseObject(SC_Attribute_link, "_"); TreeMap<String, TreeMap> BC_Attribute = wikiparser.ParseObject(BC_Attribute_link, "_"); TreeMap<String, TreeMap> BCEntitaeten = wikiparser.ParseObject(BC_Entitaeten_link, "_"); TreeMap<String, TreeMap> Meldekonzepte = wikiparser.ParseObject(Meldekonzepte_link, "_"); TreeMap<String, TreeMap> SC_Algorithmen = wikiparser.ParseObject(SC_Algorithmen_link, "_"); TreeMap<String, TreeMap> BC_Algorithmen = wikiparser.ParseObject(BC_Algorithmen_link, "_"); // TreeMap<String,String> scattribut1 = new TreeMap(); // scattribut1.put("Bezeichnung des Smart Cube Attributs", "XYZ"); // TreeMap<String,String> bcattribut1 = new TreeMap(); // bcattribut1.put("Bezeichnung des BC Attributs", "ABC"); // //TreeMap<String, TreeMap> SC_Attribute = new TreeMap(); // TreeMap<String, TreeMap> BC_Attribute = new TreeMap(); // //SC_Attribute.put("scattribut1", scattribut1); // BC_Attribute.put("bcattribut1", bcattribut1); TreeMap<String, String> BC = new TreeMap(); BC.put("name", "BasicCube"); TreeMap<String, TreeMap> test = new TreeMap(); test.put("Basic Cube", BC); hello.addNodes2Db("BasicCube", "name", test); for (int i = 0; i < all_cubes.size(); i++) { Cube cube = all_cubes.get(i); TreeMap<String, String> dummy = new TreeMap(); dummy.put("Bezeichnung des Smart Cubes", cube.getCubelongName()); SmartCubes.put(cube.getCubelongName(), dummy); } hello.addNodes2Db("SmartCube", "Bezeichnung des Smart Cubes", SmartCubes); hello.addNodes2Db("SCAttribut", "Bezeichnung des Smart Cube Attributs", SC_Attribute); hello.addNodes2Db("BCAttribut", "Bezeichnung des BC Attributs", BC_Attribute); hello.addNodes2Db("Meldekonzept", "Bezeichnung des Meldekonzepts", Meldekonzepte); hello.addNodes2Db("BCEntitaet", "Name der Entitaet", BCEntitaeten); hello.addNodes2Db("SCAlgorithmen", "Bezeichnung des Algorithmus", SC_Algorithmen); hello.addNodes2Db("BCAlgorithmen", "Bezeichnung des Algorithmus", BC_Algorithmen); hello.addCubeProperties(all_cubes); System.out.println("Adding addiional nodes"); hello.connectEnititestoAttributes("BCEntitaet", "Beschreibende Attribute", RelTypes.MEMBER_OF, -1); hello.connectEnititestoAttributes("Codeliste", "Kommtvorin", RelTypes.MEMBER_OF, 1); //hello.connectEnititestoAttributes("SCAttribut","Algorithmus/Entstehung/Bildung",RelTypes.TRANSITION,-1); //use of an anominous class -> in future lamdba expression hello.connectObjecttoObject("SCAttribut", "Algorithmus/Entstehung/Bildung", RelTypes.TRANSITION, -1, new Executable() { @Override public void execute(Node hitnode, org.neo4j.kernel.EmbeddedGraphDatabase graphDb, TreeMap<String, Node> string_node, String x) { // TODO Auto-generated method stub if (x.contains("1:1")) { for (String key : string_node.keySet()) { if (x.contains(key.toString())) { Node nodex = string_node.get(key); Relationship relationship = hitnode.createRelationshipTo(nodex, RelTypes.TRANSITION); hello.addDependency((String) hitnode.getProperty("name"), (String) nodex.getProperty("name")); //hier direkte Ueberleitung einfuehren // Node ueberleitung_node = string_node.get("1zu1Ueberleitung"); // // if (ueberleitung_node == null){ // ueberleitung_node = graphDb.createNode((org.neo4j.graphdb.Label) DynamicLabel.label("SCAlgorithmen")); // ueberleitung_node.setProperty("name", "1zu1Ueberleitung"); // ueberleitung_node.setProperty("Bezeichnung des Algorithmus","1zu1Ueberleitung"); // string_node.put("1zu1Ueberleitung", ueberleitung_node); // } // // relationship = hitnode.createRelationshipTo(ueberleitung_node, RelTypes.DERIVED_BY); // relationship = ueberleitung_node.createRelationshipTo(nodex, RelTypes.USES); } } } else { //Attribut wird abgeleitet try (Transaction tx = graphDb.beginTx()) { IndexManager indexMan = graphDb.index(); Index<Node> index = indexMan.forNodes("SCAlgorithmen"); IndexHits<Node> hits = index.get("SCAlgorithmen", "xyz"); String parts[] = x.split("\\("); String part1 = parts[0].replace(" ", ""); try { for (Node bcalgos : hits) { try { String name = (String) bcalgos .getProperty("Bezeichnung des Algorithmus"); if (x.replace(" ", "").contains(name)) {//(x.contains(name)){ Relationship relationship = hitnode.createRelationshipTo(bcalgos, RelTypes.DERIVED_BY); hello.addDependency((String) hitnode.getProperty("name"), (String) bcalgos.getProperty("name")); //relationship.setProperty( "message", "brave Neo4j"); } } catch (Exception e) { System.out.println(e.toString()); } } //end node iteration } finally { hits.close(); } tx.success(); } //ende Attribut wird abgeleitet } } }); hello.connectObjecttoObject("Meldekonzept", "Formale Beschreibung", RelTypes.USES, -1, new Executable() { //Verbinde die SC Algorithmen - aber ausschlielich mit Basic Cube Attributen @Override public void execute(Node hitnode, org.neo4j.kernel.EmbeddedGraphDatabase graphDb, TreeMap<String, Node> string_node, String x) { // TODO Auto-generated method stub try (Transaction tx = graphDb.beginTx()) { IndexManager indexMan = graphDb.index(); Index<Node> index = indexMan.forNodes("BCAttribut"); IndexHits<Node> hits = index.get("BCAttribut", "xyz"); try { for (Node bcattribut : hits) { try { String name = (String) bcattribut.getProperty("Bezeichnung des BC Attributs"); if (x.contains(name)) {//(x.contains(name)){ Relationship relationship = hitnode.createRelationshipTo(bcattribut, RelTypes.USES); hello.addDependency((String) hitnode.getProperty("name"), (String) bcattribut.getProperty("name")); //relationship.setProperty( "message", "brave Neo4j"); } } catch (Exception e) { System.out.println(e.toString()); } } //end node iteration } finally { hits.close(); } tx.success(); } //ende Attribut wird abgeleitet } }); hello.connectObjecttoObject("SCAlgorithmen", "Formale Beschreibung", RelTypes.USES, -1, new Executable() { //Verbinde die SC Algorithmen - aber ausschlielich mit Basic Cube Attributen @Override public void execute(Node hitnode, org.neo4j.kernel.EmbeddedGraphDatabase graphDb, TreeMap<String, Node> string_node, String x) { // TODO Auto-generated method stub try (Transaction tx = graphDb.beginTx()) { IndexManager indexMan = graphDb.index(); Index<Node> index = indexMan.forNodes("BCAttribut"); IndexHits<Node> hits = index.get("BCAttribut", "xyz"); try { for (Node bcattribut : hits) { try { String name = (String) bcattribut.getProperty("Bezeichnung des BC Attributs"); if (x.contains(name)) {//(x.contains(name)){ Relationship relationship = hitnode.createRelationshipTo(bcattribut, RelTypes.USES); hello.addDependency((String) hitnode.getProperty("name"), (String) bcattribut.getProperty("name")); //relationship.setProperty( "message", "brave Neo4j"); } } catch (Exception e) { System.out.println(e.toString()); } } //end node iteration } finally { hits.close(); } tx.success(); } //ende Attribut wird abgeleitet } }); //hello.connectEnititestoAttributes("BCAlgorithmen","Formale Beschreibung",RelTypes.USES); hello.connectEnititestoAttributes("BCAlgorithmen", "Kommt vor in/wird verwendet fr", RelTypes.USES, 1); //hello.connectEnititestoAttributes("SCAlgorithmen","Formale Beschreibung",RelTypes.USES,1); hello.connectEnitites_to_Node("BCEntitaet", "BasicCube", RelTypes.MEMBER_OF); hello.connectCubetoAttributes(all_cubes, RelTypes.MEMBER_OF); hello.graphDb.shutdown(); System.out.println("Check" + hello.Attribute_Dependency.toString()); JSONObject json_dep = new JSONObject(); for (String key : hello.Attribute_Dependency.keySet()) { HashSet x = hello.Attribute_Dependency.get(key); java.util.Iterator it = x.iterator(); while (it.hasNext()) { try { json_dep.append(key, (String) it.next()); //json_dep.put(key, (String) it.next()); } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } } } String content = json_dep.toString(); try { //String content = json_smartcube.toString(); File file = new File("C://Users//frisch//Desktop//json_export" + "//" + "Cube_Dependency.json"); // if file doesnt exists, then create it if (!file.exists()) { file.createNewFile(); } FileWriter fw = new FileWriter(file.getAbsoluteFile()); BufferedWriter bw = new BufferedWriter(fw); bw.write(content); bw.close(); System.out.println("Done"); } catch (IOException e) { e.printStackTrace(); } System.out.println("Ende"); //} //hello.createDb(); //hello.addNodes2Db(BCAttribute); //hello.removeData(); }
From source file:org.openestate.io.immoxml.ImmoXmlJavadocBindings.java
public static void main(String[] args) { TreeSet<String> elementNames = new TreeSet<String>(); TreeMap<String, String> typeNames = new TreeMap<String, String>(); for (Class clazz : ClassFinder.find(ImmoXmlUtils.PACKAGE)) { XmlRootElement element = (XmlRootElement) clazz.getAnnotation(XmlRootElement.class); if (element != null) { elementNames.add(element.name()); continue; }/*from w w w . j a v a2 s. c o m*/ XmlType type = (XmlType) clazz.getAnnotation(XmlType.class); if (type != null) { typeNames.put(type.name(), clazz.getSimpleName()); continue; } } System.out.println(StringUtils.repeat("-", 50)); System.out.println("XML elements"); System.out.println(StringUtils.repeat("-", 50)); for (String name : elementNames) { System.out.println("\n" + "<jaxb:bindings node=\"/xsd:schema/xsd:element[@name='" + name + "']\">\n" + " <jaxb:class>\n" + " <jaxb:javadoc><![CDATA[Java class for <" + name + "> element.]]></jaxb:javadoc>\n" + " </jaxb:class>\n" + "</jaxb:bindings>"); } System.out.println(""); System.out.println(StringUtils.repeat("-", 50)); System.out.println("XML types"); System.out.println(StringUtils.repeat("-", 50)); for (String name : typeNames.keySet()) { System.out.println("\n" + "<jaxb:bindings node=\"/xsd:schema/xsd:complexType[@name='" + name + "']\">\n" + " <jaxb:class name=\"" + typeNames.get(name) + "\">\n" + " <jaxb:javadoc><![CDATA[Java class for \"" + name + "\" complex type.]]></jaxb:javadoc>\n" + " </jaxb:class>\n" + "</jaxb:bindings>"); } System.out.println(""); }
From source file:com.inkubator.common.util.NewMain.java
/** * @param args the command line arguments *///w ww .j a va 2 s . c o m public static void main(String[] args) throws IOException { File file1 = new File( "C:\\Users\\deni.fahri\\AppData\\Roaming\\Skype\\My Skype Received Files\\JSON_Ek\\Surabaya\\Page1.txt"); File file2 = new File( "C:\\Users\\deni.fahri\\AppData\\Roaming\\Skype\\My Skype Received Files\\JSON_Ek\\Surabaya\\Page2.txt"); // File file3 = new File("C:\\Users\\deni.fahri\\AppData\\Roaming\\Skype\\My Skype Received Files\\json\\json\\menado\\page3.txt"); File file3 = new File( "C:\\Users\\deni.fahri\\AppData\\Roaming\\Skype\\My Skype Received Files\\JSON_Ek\\Surabaya\\Page3.txt"); File file4 = new File( "C:\\Users\\deni.fahri\\AppData\\Roaming\\Skype\\My Skype Received Files\\JSON_Ek\\Surabaya\\Page4.txt"); File file5 = new File( "C:\\Users\\deni.fahri\\AppData\\Roaming\\Skype\\My Skype Received Files\\JSON_Ek\\Surabaya\\Page5.txt"); File file6 = new File( "C:\\Users\\deni.fahri\\AppData\\Roaming\\Skype\\My Skype Received Files\\JSON_Ek\\Surabaya\\Page6.txt"); // File file7 = new File("C:\\Users\\deni.fahri\\AppData\\Roaming\\Skype\\My Skype Received Files\\Bandung\\Bandung\\Page 7.txt"); // File file8 = new File("C:\\Users\\deni.fahri\\AppData\\Roaming\\Skype\\My Skype Received Files\\Bandung\\Bandung\\Page 8.txt"); // File file9 = new File("C:\\Users\\deni.fahri\\AppData\\Roaming\\Skype\\My Skype Received Files\\Bandung\\Bandung\\Page 9.txt"); // File file10 = new File("C:\\Users\\deni.fahri\\AppData\\Roaming\\Skype\\My Skype Received Files\\Bandung\\Bandung\\Page 10.txt"); // File file11 = new File("C:\\Users\\deni.fahri\\AppData\\Roaming\\Skype\\My Skype Received Files\\Bandung\\Bandung\\Page 11.txt"); // File file12 = new File("C:\\Users\\deni.fahri\\AppData\\Roaming\\Skype\\My Skype Received Files\\Bandung\\Bandung\\Page 12.txt"); // File file13 = new File("C:\\Users\\deni.fahri\\AppData\\Roaming\\Skype\\My Skype Received Files\\Bandung\\Bandung\\Page 13.txt"); // File file14 = new File("C:\\Users\\deni.fahri\\AppData\\Roaming\\Skype\\My Skype Received Files\\Bandung\\Bandung\\Page 14.txt"); // File file15 = new File("C:\\Users\\deni.fahri\\AppData\\Roaming\\Skype\\My Skype Received Files\\Bandung\\Bandung\\Page 15.txt"); // File file16 = new File("C:\\Users\\deni.fahri\\Downloads\\page16.txt"); // File file2 = new File("C:\\Users\\deni.fahri\\Documents\\hasil.txt"); String agoda = FilesUtil.getAsStringFromFile(file1); String agoda1 = FilesUtil.getAsStringFromFile(file2); String agoda2 = FilesUtil.getAsStringFromFile(file3); String agoda3 = FilesUtil.getAsStringFromFile(file4); String agoda4 = FilesUtil.getAsStringFromFile(file5); String agoda5 = FilesUtil.getAsStringFromFile(file6); // String agoda6 = FilesUtil.getAsStringFromFile(file7); // String agoda7 = FilesUtil.getAsStringFromFile(file8); // String agoda8 = FilesUtil.getAsStringFromFile(file9); // String agoda9 = FilesUtil.getAsStringFromFile(file10); // String agoda10 = FilesUtil.getAsStringFromFile(file11); // String agoda11 = FilesUtil.getAsStringFromFile(file12); // String agoda12 = FilesUtil.getAsStringFromFile(file13); // String agoda13 = FilesUtil.getAsStringFromFile(file14); // String agoda14 = FilesUtil.getAsStringFromFile(file15); // String agoda15 = FilesUtil.getAsStringFromFile(file16); //// System.out.println(" Test Nya adalah :" + agoda); //// String a=StringUtils.substringAfter("\"HotelTranslatedName\":", agoda); //// System.out.println(" hasil; "+a); //// // TODO code application logic here //// System.out.println("Nilai " + JsonConverter.getValueByKeyStatic(agoda, "HotelTranslatedName")); TypeToken<List<HotelModel>> token = new TypeToken<List<HotelModel>>() { }; Gson gson = new GsonBuilder().create(); // List<HotelModel> data = new ArrayList<>(); // HotelModel hotelModel = new HotelModel(); // hotelModel.setAddress("sdfsdffsfsdfsdfdsfdsf"); // hotelModel.setAccommodationName("Aku"); // HotelModel hotelModel1 = new HotelModel(); // hotelModel1.setAddress("sdfsdffsfsdfsdfdsfdsf"); // hotelModel1.setAccommodationName("Avvvku"); // HotelModel hotelModel2 = new HotelModel(); // hotelModel2.setAddress("sdfsdffsfsdfsdfdsfdsf"); // hotelModel2.setAccommodationName("Akvvvu"); // data.add(hotelModel); // data.add(hotelModel1); // data.add(hotelModel2); // String json = gson.toJson(data); List<HotelModel> total = new ArrayList<>(); List<HotelModel> data1 = new ArrayList<>(); List<HotelModel> data2 = new ArrayList<>(); List<HotelModel> data3 = new ArrayList<>(); List<HotelModel> data4 = new ArrayList<>(); List<HotelModel> data5 = new ArrayList<>(); List<HotelModel> data6 = new ArrayList<>(); List<HotelModel> data7 = new ArrayList<>(); List<HotelModel> data8 = new ArrayList<>(); List<HotelModel> data9 = new ArrayList<>(); List<HotelModel> data10 = new ArrayList<>(); List<HotelModel> data11 = new ArrayList<>(); List<HotelModel> data12 = new ArrayList<>(); List<HotelModel> data13 = new ArrayList<>(); List<HotelModel> data14 = new ArrayList<>(); List<HotelModel> data15 = new ArrayList<>(); List<HotelModel> data16 = new ArrayList<>(); data1 = gson.fromJson(agoda, token.getType()); data2 = gson.fromJson(agoda1, token.getType()); data3 = gson.fromJson(agoda2, token.getType()); data4 = gson.fromJson(agoda3, token.getType()); data5 = gson.fromJson(agoda4, token.getType()); data6 = gson.fromJson(agoda5, token.getType()); // data7 = gson.fromJson(agoda6, token.getType()); // data8 = gson.fromJson(agoda7, token.getType()); // data9 = gson.fromJson(agoda8, token.getType()); // data10 = gson.fromJson(agoda9, token.getType()); // data11 = gson.fromJson(agoda10, token.getType()); // data12 = gson.fromJson(agoda11, token.getType()); // data13 = gson.fromJson(agoda12, token.getType()); // data14 = gson.fromJson(agoda13, token.getType()); // data15 = gson.fromJson(agoda14, token.getType()); // data16 = gson.fromJson(agoda15, token.getType()); total.addAll(data1); total.addAll(data2); total.addAll(data3); total.addAll(data4); total.addAll(data5); total.addAll(data6); // total.addAll(data7); // total.addAll(data8); // total.addAll(data9); // total.addAll(data10); // total.addAll(data11); // total.addAll(data12); // total.addAll(data13); // total.addAll(data14); // total.addAll(data15); // total.addAll(data16); System.out.println(" Ukurannn nya " + total.size()); // System.out.println(" Ukurannya " + data2.size()); for (HotelModel mode : total) { System.out.println(mode); } // HotelModel hotelModel = gson.fromJson(agoda, HotelModel.class); // String Data = hotelModel.getHotelTranslatedName() + ";" + hotelModel.getStarRating() + ";" + hotelModel.getAddress() + ";" + hotelModel.getIsFreeWifi(); // FilesUtil.writeToFileFromString(file2, Data); // System.out.println(hotelModel); // HSSFWorkbook workbook = new HSSFWorkbook(); HSSFSheet sheet = workbook.createSheet("Agoda Data Hotel Surabaya"); //// TreeMap<String, Object[]> datatoExel = new TreeMap<>(); int i = 1; // datatoExel.put("1", new Object[]{"Hotel Agoda Jakarta"}); datatoExel.put("1", new Object[] { "Nama Hotel", "Arena", "Alamat", "Rating", "Apakah Gratis Wifi", "Harga Mulai Dari", "Longitude", "Latitude" }); for (HotelModel mode : total) { datatoExel.put(String.valueOf(i + 1), new Object[] { mode.getHotelTranslatedName(), mode.getAreaName(), mode.getAddress(), mode.getStarRating(), mode.getIsFreeWifi(), mode.getTextPrice() + " " + mode.getCurrencyCode(), mode.getCoordinate().getLongitude(), mode.getCoordinate().getLatitude() }); i++; } // //// int i=1; //// for (HotelModel mode : data2) { //// datatoExel.put(String.valueOf(i), new Object[]{1d, "John", 1500000d}); ////// } //// //// datatoExel.put("4", new Object[]{3d, "Dean", 700000d}); //// Set<String> keyset = datatoExel.keySet(); int rownum = 0; for (String key : keyset) { Row row = sheet.createRow(rownum++); Object[] objArr = datatoExel.get(key); int cellnum = 0; for (Object obj : objArr) { Cell cell = row.createCell(cellnum++); if (obj instanceof Date) { cell.setCellValue((Date) obj); } else if (obj instanceof Boolean) { cell.setCellValue((Boolean) obj); } else if (obj instanceof String) { cell.setCellValue((String) obj); } else if (obj instanceof Double) { cell.setCellValue((Double) obj); } } } try { FileOutputStream out = new FileOutputStream(new File("C:\\Users\\deni.fahri\\Documents\\Surabaya.xls")); workbook.write(out); out.close(); System.out.println("Excel written successfully.."); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } }