@Override public List<WidgetPosition> getPositions() { final BasicDBObject positions = (BasicDBObject) fields.get(DashboardImpl.EMBEDDED_POSITIONS); if (positions == null) { return Collections.emptyList(); } final List<WidgetPosition> result = new ArrayList<>(positions.size()); for ( String positionId : positions.keySet() ) { final BasicDBObject position = (BasicDBObject) positions.get(positionId); final int width = parseInt(position.get("width").toString()); final int height = parseInt(position.get("height").toString()); final int col = parseInt(position.get("col").toString()); final int row = parseInt(position.get("row").toString()); final WidgetPosition widgetPosition = WidgetPosition.builder() .id(positionId) .width(width) .height(height) .col(col) .row(row) .build(); result.add(widgetPosition); } return result; }
@Override public boolean equals(final Object o) { if (o == this) { return true; } if (!(o instanceof BSONObject)) { return false; } BSONObject other = (BSONObject) o; if (!keySet().equals(other.keySet())) { return false; } return Arrays.equals(toBson(canonicalizeBSONObject(this)), toBson(canonicalizeBSONObject(other))); }
/** * Creates a new instance which is a copy of this BasicDBObject. * * @return a BasicDBObject with exactly the same values as this instance. */ public Object copy() { // copy field values into new object BasicDBObject newCopy = new BasicDBObject(this.toMap()); // need to clone the sub obj for (final String field : keySet()) { Object val = get(field); if (val instanceof BasicDBObject) { newCopy.put(field, ((BasicDBObject) val).copy()); } else if (val instanceof BasicDBList) { newCopy.put(field, ((BasicDBList) val).copy()); } } return newCopy; }
private void addLookupAndMatchToPipeline(BasicDBList lookup, BasicDBObject mongoQuery, List<DBObject> pipeline) { BasicDBObject matchBeforeLookup = new BasicDBObject(); BasicDBObject matchAfterLookup = new BasicDBObject(); for (String key : mongoQuery.keySet()) { if (key.contains(".")) { matchAfterLookup.append(key, mongoQuery.get(key)); } else { matchBeforeLookup.append(key, mongoQuery.get(key)); } } if (matchBeforeLookup.size() > 0) { pipeline.add(new BasicDBObject("$match", matchBeforeLookup)); } for (Object lookupItem : lookup) { pipeline.add((DBObject) lookupItem); } if (matchAfterLookup.size() > 0) { pipeline.add(new BasicDBObject("$match", matchAfterLookup)); } }
Set<String> set = obj.keySet(); // Set containing index name which
for (String key : orderBy.keySet())
private String getKey(BasicDBObject dbo) { for (String key : dbo.keySet()) { if (!key.equals("_id")) { return key; } } return null; } }
@Override public String toString() { StringBuilder builder = new StringBuilder(this.errorCode.toString()); for(String propKey : properties.keySet()){ builder.append("\n\t"); builder.append(propKey); builder.append(" : "); builder.append(properties.get(propKey)); } return builder.toString(); } }
@Override public String toString() { StringBuilder builder = new StringBuilder(this.errorCode.toString()); if(this.getMessage() != null){ builder.append(" : "); builder.append(this.getMessage()); } for(String propKey : properties.keySet()){ builder.append("\n\t"); builder.append(propKey); builder.append(" : "); builder.append(properties.get(propKey)); } return builder.toString(); } }
@Override public Collection<String> getFieldNames(){ Collection<String> fielNames = new ArrayList<String>(bsonObject.size() * 2); for(String dbName : bsonObject.keySet()){ MetaField metaField = getMetaClass().getFieldByDbName(dbName); if (metaField != null) { String fieldName = metaField.getName(); fielNames.add(fieldName); } } return fielNames; }
@Override public Collection<String> getFieldNames(){ Collection<String> fielNames = new HashSet<String>(bsonObject.size() * 2); for(String dbName : bsonObject.keySet()){ MetaField metaField = getMetaClass().getFieldByFlattenValueDbName(dbName); if (metaField != null) { String fieldName = metaField.getName(); fielNames.add(fieldName); } } return fielNames; }
/** * Reads database fields (that do not have Java fields) and copies them to workflow instance properties. * This makes it possible to write non-standard fields to the database and read them from properties. */ private void copyProperties(BasicDBObject dbWorkflowInstance, WorkflowInstanceImpl workflowInstance) { if (dbWorkflowInstance == null || workflowInstance == null) { return; } Set<String> invalidPropertyKeys = Extensible.getInvalidPropertyKeys(WorkflowInstance.class); // Map<String,?> mappedBeanFields = mongoMapper.write(workflowInstance.toWorkflowInstance()); for (String fieldName : dbWorkflowInstance.keySet()) { boolean property = !invalidPropertyKeys.contains(fieldName); if (property) { workflowInstance.setProperty(fieldName, dbWorkflowInstance.get(fieldName)); } } }
/** * Reads database fields (that do not have Java fields) and copies them to workflow instance properties. * This makes it possible to write non-standard fields to the database and read them from properties. */ private void copyProperties(BasicDBObject dbWorkflowInstance, WorkflowInstanceImpl workflowInstance) { if (dbWorkflowInstance == null || workflowInstance == null) { return; } Set<String> invalidPropertyKeys = Extensible.getInvalidPropertyKeys(WorkflowInstance.class); // Map<String,?> mappedBeanFields = mongoMapper.write(workflowInstance.toWorkflowInstance()); for (String fieldName : dbWorkflowInstance.keySet()) { boolean property = !invalidPropertyKeys.contains(fieldName); if (property) { workflowInstance.setProperty(fieldName, dbWorkflowInstance.get(fieldName)); } } }
@Override public boolean equals(final Object o) { if (o == this) { return true; } if (!(o instanceof BSONObject)) { return false; } BSONObject other = (BSONObject) o; if (!keySet().equals(other.keySet())) { return false; } return Arrays.equals(toBson(canonicalizeBSONObject(this)), toBson(canonicalizeBSONObject(other))); }
public List<YAttribute> convert(BasicDBObject source) { List<YAttribute> attributes = new ArrayList<>(); for (String key : source.keySet()) { if(getConverter().getTypeMapper().isTypeKey(key)){ continue; } Object value = source.get(key); key = getConverter().potentiallyUnescapeMapKey(key); attributes.addAll(processAttributes(key, value)); } return attributes; }
/** * Creates a new instance which is a copy of this BasicDBObject. * * @return a BasicDBObject with exactly the same values as this instance. */ public Object copy() { // copy field values into new object BasicDBObject newCopy = new BasicDBObject(this.toMap()); // need to clone the sub obj for (final String field : keySet()) { Object val = get(field); if (val instanceof BasicDBObject) { newCopy.put(field, ((BasicDBObject) val).copy()); } else if (val instanceof BasicDBList) { newCopy.put(field, ((BasicDBList) val).copy()); } } return newCopy; }
@Override public Collection<String> getFieldNames(){ Collection<String> fielNames = new ArrayList<String>(bsonObject.size() * 2); for(String dbName : bsonObject.keySet()){ MetaField metaField = getMetaClass().getFieldByDbName(dbName); if (metaField != null) { String fieldName = metaField.getName(); fielNames.add(fieldName); } } return fielNames; }
public void loadProperties(InputStream is) { DBCollection propertiesCollection = mongo.getDB(CMSConsts.SYS_DB).getCollection(CMSConsts.PROPERTIES_COLLECTION); //load properties collection BasicDBObject cmsProperties = (BasicDBObject)loadBasonFromFile(is); for (String key : cmsProperties.keySet()) { DBObject obj = new BasicDBObject().append(key, cmsProperties.get(key)); propertiesCollection.insert(obj); } }
static Event convertEvent(BasicDBObject o) { Event event = new Event(); event.setTime(o.getLong("time")); event.setType(EventType.valueOf(o.getString("type"))); event.setRealmId(o.getString("realmId")); event.setClientId(o.getString("clientId")); event.setUserId(o.getString("userId")); event.setSessionId(o.getString("sessionId")); event.setIpAddress(o.getString("ipAddress")); event.setError(o.getString("error")); BasicDBObject d = (BasicDBObject) o.get("details"); if (d != null) { Map<String, String> details = new HashMap<String, String>(); for (Object k : d.keySet()) { details.put((String) k, d.getString((String) k)); } event.setDetails(details); } return event; }
private void buildJsonBody(DBObject modifyBody) { BasicDBObject set = (BasicDBObject) modifyBody.get("$set"); MetaField field = getField(); BasicDBObject enityObject = (BasicDBObject) getEntity().getNode(); BasicDBObject fieldObject = (BasicDBObject) enityObject.get(field.getFlattenValueDbName()); if (fieldObject != null) { BasicDBObject givenValue = fieldObject; if (givenValue != null) { for (String key : givenValue.keySet()) { set.put(field.getFlattenValueDbName() + DOT + key, givenValue.get(key)); } // field properties // no length here set.put(field.getFlattenPropertyValueDbName(FieldProperty.TIMESTAMP), getEntity().getFieldTimestamp(field.getName())); } } }