List of usage examples for com.mongodb DBCollection insert
public WriteResult insert(final List<? extends DBObject> documents)
From source file:models.OntoProcessor.java
License:Open Source License
protected void saveOntologyTypes() throws JsonProcessingException { DBCollection impactAndFlowTypesTreeColl = db.getCollection("ontologyTypes"); impactAndFlowTypesTreeColl.drop();/* w ww . ja v a 2 s . c om*/ String impactTypesTreeSerialized = mapper.writeValueAsString(ontology.getImpactTypesTree()); String elementaryFlowTypesTreeSerialized = mapper.writeValueAsString(ontology.getElementaryFlowTypesTree()); BasicDBObject dbObject = (BasicDBObject) JSON.parse("{impactTypesTree:" + impactTypesTreeSerialized + ", flowTypesTree:" + elementaryFlowTypesTreeSerialized + "}"); impactAndFlowTypesTreeColl.insert(dbObject); }
From source file:models.OntoProcessor.java
License:Open Source License
protected void saveRelationTypes() throws JsonProcessingException { DBCollection relationTypesColl = db.getCollection("relationTypes"); relationTypesColl.drop();// ww w. jav a 2s.co m String relationTypesTreeSerialized = mapper.writeValueAsString(ontology.getRelationTypes()); BasicDBObject dbObject = (BasicDBObject) JSON.parse("{relationTypes: " + relationTypesTreeSerialized + "}"); relationTypesColl.insert(dbObject); }
From source file:models.OntoProcessor.java
License:Open Source License
protected void saveGroups() throws JsonProcessingException { DBCollection groupsColl = db.getCollection("groups"); groupsColl.drop();//from ww w . j a va 2s . c o m for (Group group : ontology.getGroups().values()) { String serializedGroup = mapper.writeValueAsString(group); BasicDBObject dbObject = (BasicDBObject) JSON.parse(serializedGroup); dbObject.append("_id", group.getId()); groupsColl.insert(dbObject); if (group.getType() == com.mycsense.carbondb.domain.group.Type.PROCESS) { HashMap<String, String> node = new HashMap<>(); node.put("id", group.getId()); node.put("label", group.getLabel()); nodes.add(node); processGroupsId.add(group.getId()); } } }
From source file:models.OntoProcessor.java
License:Open Source License
protected void saveProcesses() throws JsonProcessingException { DBCollection processesColl = db.getCollection("processes"); processesColl.drop();/*from ww w.j av a 2 s .co m*/ for (Process process : ontology.getProcesses()) { String serializedProcess = mapper.writeValueAsString(process); BasicDBObject dbObject = (BasicDBObject) JSON.parse(serializedProcess); dbObject.append("_id", process.getId()); processesColl.insert(dbObject); processesId.add(process.getId()); HashMap<String, String> node = new HashMap<>(); node.put("id", process.getId()); String label = ""; for (Keyword keyword : process.getKeywords()) { label += keyword.getLabel() + " - "; } label = label.substring(0, label.length() - 3); label += " [" + process.getUnit().getSymbol() + "]"; node.put("label", label); derivedNodes.add(node); } }
From source file:models.OntoProcessor.java
License:Open Source License
protected void saveCoefficients() throws JsonProcessingException { DBCollection coefficientsColl = db.getCollection("coefficients"); coefficientsColl.drop();// w ww.j a v a2 s .c o m for (Coefficient coeff : ontology.getCoefficients()) { String serializedCoeff = mapper.writeValueAsString(coeff); BasicDBObject dbObject = (BasicDBObject) JSON.parse(serializedCoeff); dbObject.append("_id", coeff.getId()); coefficientsColl.insert(dbObject); } }
From source file:models.OntoProcessor.java
License:Open Source License
protected void saveReferences() throws JsonProcessingException { DBCollection refColl = db.getCollection("references"); refColl.drop();/*from w w w . j av a 2 s .c o m*/ String serializedReferences = "{references:" + mapper.writeValueAsString(ontology.getReferences().values()) + "}"; BasicDBObject dbObject = (BasicDBObject) JSON.parse(serializedReferences); refColl.insert(dbObject); }
From source file:models.OntoProcessor.java
License:Open Source License
protected void saveGraph() { DBCollection graphColl = db.getCollection("graph"); graphColl.drop();//from w ww. j a va2s . c o m for (SourceRelation sourceRelation : ontology.getSourceRelations().values()) { String sourceId = sourceRelation.getSource().getId(); String destinationId = sourceRelation.getDestination().getId(); HashMap<String, Object> link = new HashMap<>(); link.put("id", sourceRelation.getId()); link.put("source", processGroupsId.indexOf(sourceId)); link.put("target", processGroupsId.indexOf(destinationId)); if (sourceRelation.getType() != null) link.put("type", sourceRelation.getType().getId()); else link.put("type", "#none"); links.add(link); } BasicDBObject dbObject = (BasicDBObject) JSON .parse("{nodes:" + toJson(nodes).toString() + ",links:" + toJson(links).toString() + "}"); graphColl.insert(dbObject); }
From source file:models.OntoProcessor.java
License:Open Source License
protected void saveDerivedGraph() { DBCollection derivedGraphColl = db.getCollection("derivedGraph"); derivedGraphColl.drop();//from ww w . jav a2 s .c o m for (DerivedRelation relation : ontology.getDerivedRelations()) { String sourceId = relation.getSource().getId(); String destinationId = relation.getDestination().getId(); HashMap<String, Object> link = new HashMap<>(); link.put("source", processesId.indexOf(sourceId)); link.put("target", processesId.indexOf(destinationId)); if (relation.getType() != null) link.put("type", relation.getType().getId()); else link.put("type", "#none"); derivedLinks.add(link); } BasicDBObject dbObject = (BasicDBObject) JSON.parse( "{nodes:" + toJson(derivedNodes).toString() + ",links:" + toJson(derivedLinks).toString() + "}"); derivedGraphColl.insert(dbObject); }
From source file:models.OntoProcessor.java
License:Open Source License
protected void saveStats() throws JsonProcessingException { DBCollection statsColl = db.getCollection("ontologyStats"); statsColl.drop();//from w w w . j av a 2 s .c o m HashMap<String, Integer> stats = new HashMap<>(); stats.put("coefficientGroups", ontology.getCoefficientGroups().size()); stats.put("processGroups", ontology.getProcessGroups().size()); stats.put("coefficients", ontology.getCoefficients().size()); stats.put("processes", ontology.getProcesses().size()); Integer numberOfInputElementaryFlow = 0; Integer numberOfCalculatedElementaryFlow = 0; Integer numberOfImpact = 0; for (Process process : ontology.getProcesses()) { numberOfInputElementaryFlow += process.getInputFlows().size(); numberOfCalculatedElementaryFlow += process.getCalculatedFlows().size(); numberOfImpact += process.getImpacts().size(); } stats.put("inputFlows", numberOfInputElementaryFlow); stats.put("calculatedFlows", numberOfCalculatedElementaryFlow); stats.put("impacts", numberOfImpact); stats.put("sourceRelations", ontology.getSourceRelations().size()); stats.put("derivedRelations", ontology.getDerivedRelations().size()); stats.put("references", ontology.getReferences().size()); BasicDBObject dbObject = (BasicDBObject) JSON.parse(mapper.writeValueAsString(stats)); statsColl.insert(dbObject); }
From source file:Modules.Client.Model.DAO.DAO_Mongo_client.java
public static void insert_Client(Client_class c) { DBCollection table = Singleton_app.collection; table.insert(c.Client_to_DB()); }