List of usage examples for com.mongodb.util JSON parse
public static Object parse(final String jsonString)
Parses a JSON string and returns a corresponding Java object.
From source file:models.datasource.SingletonDataSource.java
public static void updateAllUserData(User user) { DBCollection collection = connectDB("mongo.usersCollection"); BasicDBObject newDocument = new BasicDBObject(); newDocument.put(Constants.USER_NAME, user.name); newDocument.put(Constants.USER_SURNAMES, user.surnames); newDocument.put(Constants.USER_EMAIL, user.email); newDocument.put(Constants.USER_PASSWORD, user.password); newDocument.put(Constants.USER_EMAIL_VERIFICATION_KEY, user.emailVerificationKey); newDocument.put(Constants.USER_CONNECTION_TIMESTAMP, user.connectionTimestamp); newDocument.put(Constants.USER_RESTORE_PASSWORD_TOKEN, user.restorePasswordToken); newDocument.put(Constants.USER_RESTORE_PASSWORD_TIMESTAMP, user.restorePasswordTimestamp); newDocument.put(Constants.USER_REGISTRATION_DATE, user.registrationDate); newDocument.put(Constants.USER_BIRTH_DATE, user.birthDate); newDocument.put(Constants.USER_RESIDENCE_CITY, user.residenceCity); newDocument.put(Constants.USER_RESIDENCE_ADDRESS, user.residenceAddress); newDocument.put(Constants.USER_RESIDENCE_NUMBER, user.residenceNumber); newDocument.put(Constants.USER_RESIDENCE_ZIP_CODE, user.residenceZipCode); newDocument.put(Constants.USER_PHONE_NUMBER, user.phoneNumber); newDocument.put(Constants.USER_STUDY_TITLE, user.studyTitle); newDocument.put(Constants.USER_STUDY_LOCATION, user.studyLocation); newDocument.put(Constants.USER_EDUCATION_LEVEL, user.educationLevel); newDocument.put(Constants.USER_DRIVING_LICENSE, user.drivingLicense); newDocument.put(Constants.USER_CERTIFICATE_OF_DISABILITY, user.certificateOfDisability); newDocument.put(Constants.USER_COURSES, JSON.parse(user.coursesToJson())); newDocument.put(Constants.USER_LANGUAGES, JSON.parse(user.languagesToJson())); newDocument.put(Constants.USER_SOFTWARE, JSON.parse(user.softwareToJson())); newDocument.put(Constants.USER_ORIENTATION_STEPS, JSON.parse(user.completedOrientationSteps.orientationStepsToJson())); newDocument.put(Constants.USER_CURRENT_SITUATION, JSON.parse(user.currentSituation.toJsonString())); newDocument.put(Constants.USER_SKILLS_LIST, JSON.parse(user.skillsToJson())); newDocument.put(Constants.USER_INTERESTS_LIST, user.interests); newDocument.put(Constants.USER_PERSONAL_CHARACTERISTICS_LIST, user.personalCharacteristics); newDocument.put(Constants.USER_PROFESSIONAL_VALUES_LIST, JSON.parse(user.professionalValuesToJson())); newDocument.put(Constants.USER_PHOTO, JSON.parse(user.photo.toJsonString())); newDocument.put(Constants.USER_NEXT_INTERVIEWS_LIST, JSON.parse(user.interviewScheduleListToJson())); collection.update(new BasicDBObject().append(Constants.USER_REGISTRATION_DATE, user.registrationDate), newDocument);// ww w . ja va 2s . com mongoClient.close(); }
From source file:models.OntoProcessor.java
License:Open Source License
protected void saveReport() { DBCollection reportColl = db.getCollection("report"); reportColl.drop();/*w w w. ja va2 s. c o m*/ BasicDBObject dbObject = (BasicDBObject) JSON.parse("{status:" + toJson(getStatus()) + ",messages:" + toJson(OntoProcessorMessageStore.getInstance()).toString() + "}"); reportColl.insert(dbObject); }
From source file:models.OntoProcessor.java
License:Open Source License
protected void saveCategories() throws JsonProcessingException { BasicDBObject dbObject;//w w w . java2s.co m CarbonOntology ontology = CarbonOntology.getInstance(); DBCollection categoriesColl = db.getCollection("categories"); categoriesColl.drop(); String serialized = mapper.writeValueAsString(ontology.getCategoryTree()); dbObject = (BasicDBObject) JSON.parse(serialized); categoriesColl.insert(dbObject); }
From source file:models.OntoProcessor.java
License:Open Source License
protected void saveImpactAndFlowTypes() throws JsonProcessingException { DBCollection impactAndFlowTypesColl = db.getCollection("impactAndFlowTypes"); impactAndFlowTypesColl.drop();//from w w w .ja va 2s . c om String impactTypesSerialized = mapper.writeValueAsString(ontology.getImpactTypes()); String elementaryFlowTypesSerialized = mapper.writeValueAsString(ontology.getElementaryFlowTypes()); BasicDBObject dbObject = (BasicDBObject) JSON.parse( "{impactTypes:" + impactTypesSerialized + ", flowTypes:" + elementaryFlowTypesSerialized + "}"); impactAndFlowTypesColl.insert(dbObject); }
From source file:models.OntoProcessor.java
License:Open Source License
protected void saveOntologyTypes() throws JsonProcessingException { DBCollection impactAndFlowTypesTreeColl = db.getCollection("ontologyTypes"); impactAndFlowTypesTreeColl.drop();/*ww w.j a v a 2 s . c o m*/ 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();//from w w w. ja v a 2 s. c om 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 w ww . ja va 2 s . 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();/*w w w . ja v a 2s . c o 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();/*from w w w . j a va2 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 www .j av a2 s . c om*/ String serializedReferences = "{references:" + mapper.writeValueAsString(ontology.getReferences().values()) + "}"; BasicDBObject dbObject = (BasicDBObject) JSON.parse(serializedReferences); refColl.insert(dbObject); }