List of usage examples for com.mongodb BasicDBObject toString
@SuppressWarnings("deprecation") public String toString()
Returns a JSON serialization of this object
The output will look like: {"a":1, "b":["x","y","z"]} }
From source file:eu.eubrazilcc.lvl.storage.dao.WorkflowRunDAO.java
License:EUPL
private WorkflowRunEntity map(final BasicDBObject obj) { WorkflowRunEntity entity = null;/*ww w . j av a 2s.co m*/ try { entity = JSON_MAPPER.readValue(obj.toString(), WorkflowRunEntity.class); } catch (IOException e) { LOGGER.error("Failed to read workflow run from DB object", e); } return entity; }
From source file:eu.eubrazilcc.lvl.storage.oauth2.dao.AuthCodeDAO.java
License:EUPL
private AuthCodeEntity map(final BasicDBObject obj) { AuthCodeEntity entity = null;/* www. ja va 2 s. c o m*/ try { entity = JSON_MAPPER.readValue(obj.toString(), AuthCodeEntity.class); } catch (IOException e) { LOGGER.error("Failed to read authN code from DB object", e); } return entity; }
From source file:eu.eubrazilcc.lvl.storage.oauth2.dao.ClientAppDAO.java
License:EUPL
private ClientAppEntity map(final BasicDBObject obj) { ClientAppEntity entity = null;// w w w .ja v a 2s. c om try { entity = JSON_MAPPER.readValue(obj.toString(), ClientAppEntity.class); } catch (IOException e) { LOGGER.error("Failed to read client app from DB object", e); } return entity; }
From source file:eu.eubrazilcc.lvl.storage.oauth2.dao.LinkedInStateDAO.java
License:EUPL
private LinkedInStateEntity map(final BasicDBObject obj) { LinkedInStateEntity entity = null;//from w ww . j av a 2 s . c o m try { entity = JSON_MAPPER.readValue(obj.toString(), LinkedInStateEntity.class); } catch (IOException e) { LOGGER.error("Failed to read access state from DB object", e); } return entity; }
From source file:eu.eubrazilcc.lvl.storage.oauth2.dao.PendingUserDAO.java
License:EUPL
private PendingUserEntity map(final BasicDBObject obj) { PendingUserEntity entity = null;/*from w w w . j av a 2 s.co m*/ try { entity = JSON_MAPPER.readValue(obj.toString(), PendingUserEntity.class); } catch (IOException e) { LOGGER.error("Failed to read pending user from DB object", e); } return entity; }
From source file:eu.eubrazilcc.lvl.storage.oauth2.dao.ResourceOwnerDAO.java
License:EUPL
private ResourceOwnerEntity map(final BasicDBObject obj) { ResourceOwnerEntity entity = null;/*from w ww . java 2 s . c o m*/ try { entity = JSON_MAPPER.readValue(obj.toString(), ResourceOwnerEntity.class); } catch (IOException e) { LOGGER.error("Failed to read resource owner from DB object", e); } return entity; }
From source file:eu.eubrazilcc.lvl.storage.oauth2.dao.TokenDAO.java
License:EUPL
private AccessTokenEntity map(final BasicDBObject obj) { AccessTokenEntity entity = null;//from w ww. j a v a 2s .c o m try { entity = JSON_MAPPER.readValue(obj.toString(), AccessTokenEntity.class); } catch (IOException e) { LOGGER.error("Failed to read access token from DB object", e); } return entity; }
From source file:eu.operando.core.pdb.mongo.OSPPrivacyPolicyMongo.java
/** * * @param filter//w ww. jav a 2 s . com * @return */ public String getOSPByFilter(String filter) { String result = null; BasicDBObject query = new BasicDBObject(); System.out.println("filter expression: " + filter); try { JSONObject obj = new JSONObject(filter); Iterator<String> keys = obj.keys(); while (keys.hasNext()) { String key = keys.next(); System.out.println("found key " + key); System.out.println("converting key " + toCamelCase(key)); String cKey = toCamelCase(key); if (!isAValidFieldName(cKey)) { System.out.println("Not a valid key name found: " + cKey); return null; } System.out.println("value " + obj.getString(key)); query.put(cKey, java.util.regex.Pattern.compile(obj.getString(key))); } } catch (JSONException e) { e.printStackTrace(); } System.out.println("Query: " + query.toString()); List<OSPPrivacyPolicy> arrPRObj = new ArrayList<OSPPrivacyPolicy>(); List<Document> documents = ospCollection.find(query).into(new ArrayList<Document>()); //System.out.println("FOUND " + documents.size()); for (Document document : documents) { //System.out.println("DOCUMENT ++:" + document.toString()); OSPPrivacyPolicy ospObj = null; try { ObjectMapper mapper = new ObjectMapper(); mapper.configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES, false); ospObj = mapper.readValue(document.toJson(), OSPPrivacyPolicy.class); //add policy id ospObj.setOspPolicyId(document.get("_id").toString()); arrPRObj.add(ospObj); } catch (JsonGenerationException e) { e.printStackTrace(); } catch (JsonMappingException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } } try { ObjectMapper mapper = new ObjectMapper(); mapper.getSerializationConfig().enable(SerializationConfig.Feature.WRITE_ENUMS_USING_TO_STRING); mapper.setPropertyNamingStrategy(PropertyNamingStrategy.CAMEL_CASE_TO_LOWER_CASE_WITH_UNDERSCORES); result = mapper.writeValueAsString(arrPRObj); } catch (JsonMappingException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } System.out.println("GET OSP by filter RESULT (list): " + result); return result; }
From source file:eu.operando.core.pdb.mongo.RegulationsMongo.java
public String getRegulationByFilter(String filter) { String result = null;//from w ww. j a v a2 s. com BasicDBObject query = new BasicDBObject(); System.out.println("filter expression: " + filter); try { JSONObject obj = new JSONObject(filter); Iterator<String> keys = obj.keys(); while (keys.hasNext()) { String key = keys.next(); System.out.println("found key " + key); System.out.println("converting key " + toCamelCase(key)); String cKey = toCamelCase(key); if (!isAValidFieldName(cKey)) { System.out.println("Not a valid key name found: " + cKey); return null; } System.out.println("value " + obj.getString(key)); query.put(cKey, java.util.regex.Pattern.compile(obj.getString(key))); } } catch (JSONException e) { e.printStackTrace(); } System.out.println("Query: " + query.toString()); List<PrivacyRegulation> arrPRObj = new ArrayList<PrivacyRegulation>(); List<Document> documents = regCollection.find(query).into(new ArrayList<Document>()); //System.out.println("FOUND " + documents.size()); for (Document document : documents) { //System.out.println("DOCUMENT ++:" + document.toString()); PrivacyRegulation ospObj = null; try { ObjectMapper mapper = new ObjectMapper(); mapper.configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES, false); ospObj = mapper.readValue(document.toJson(), PrivacyRegulation.class); //add policy id ospObj.setRegId(document.get("_id").toString()); arrPRObj.add(ospObj); } catch (JsonGenerationException e) { e.printStackTrace(); } catch (JsonMappingException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } } try { ObjectMapper mapper = new ObjectMapper(); mapper.getSerializationConfig().enable(SerializationConfig.Feature.WRITE_ENUMS_USING_TO_STRING); mapper.setPropertyNamingStrategy(PropertyNamingStrategy.CAMEL_CASE_TO_LOWER_CASE_WITH_UNDERSCORES); result = mapper.writeValueAsString(arrPRObj); } catch (JsonMappingException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } System.out.println("GET Regulations by filter RESULT (list): " + result); return result; }
From source file:eu.operando.core.pdb.mongo.UPPMongo.java
public String getUPPByFilter(String filter) { String result = null;//from w w w . j av a2s . c o m BasicDBObject query = new BasicDBObject(); if (filter == null) { return "Input error: No UPP ID provided"; } System.out.println("filter expression: " + filter); try { JSONObject obj = new JSONObject(filter); Iterator<String> keys = obj.keys(); while (keys.hasNext()) { String key = keys.next(); System.out.println("found key " + key); System.out.println("converting key " + toCamelCase(key)); String cKey = toCamelCase(key); if (!isAValidFieldName(cKey)) { System.out.println("Not a valid key name found: " + cKey); return null; } System.out.println("value " + obj.getString(key)); query.put(cKey, java.util.regex.Pattern.compile(obj.getString(key))); } } catch (JSONException e) { e.printStackTrace(); } System.out.println("Query: " + query.toString()); List<UserPrivacyPolicy> arrUPPObj = new ArrayList<UserPrivacyPolicy>(); DBCursor cursor = this.uppTable.find(query); while (cursor.hasNext()) { BasicDBObject regObj = (BasicDBObject) cursor.next(); System.out.println("Adding result " + regObj.toString()); arrUPPObj.add(getUPP(regObj)); } try { ObjectMapper mapper = new ObjectMapper(); mapper.getSerializationConfig().enable(SerializationConfig.Feature.WRITE_ENUMS_USING_TO_STRING); mapper.setPropertyNamingStrategy(PropertyNamingStrategy.CAMEL_CASE_TO_LOWER_CASE_WITH_UNDERSCORES); result = mapper.writeValueAsString(arrUPPObj); } catch (JsonMappingException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } System.out.println("getUPPByFilter RESULT (list): " + result); return result; }