public static GrantObject fromEntity(Entity entity) { String grantObject = entity.getValue(Constants.GRANT_OBJECT).toString(); Map<String, Grant> userGrants = new ConcurrentHashMap<>(); Property grantsProperty = entity.getProperty(Constants.GRANTS); for(Value grantValue : grantsProperty.getValues()) { EntityValue entityValue = (EntityValue) grantValue; String grantUser = entityValue.toEntity().getValue(Constants.GRANT_USER).toString(); String grantMode = entityValue.toEntity().getValue(Constants.GRANT_MODE).toString(); userGrants.put(grantUser, new GrantMeta(grantUser, AccessMode.fromMode(grantMode))); } return new GrantObjectMeta(grantObject, userGrants); }
/** * Adds an embedded entity to the current entity with the given property name * @param propertyName The name to add the embedded entity on * @param entity The entity to embed * @return The entity onto which the entity was embedded */ @Override public SimpleEntity addEntity(String propertyName, Entity entity) { addValueToProperty(propertyName, new EntityValue(entity)); return this; }
@Override public Object mapFromProperty(PropertyMetadata propertyMetadata, Property property) { EntityValue entityValue = (EntityValue) property.getFirstValue(); Entity embeddedEntity = entityValue.getValue(); List<Property> embeddedProperties = embeddedEntity.getProperties(); Map<String, Object> properties = new HashMap<>(); embeddedProperties.forEach(p -> { properties.put(p.getPropertyName(), p.getFirstValue().getValue()); }); return properties; } }
generator.writeBoolean(((BooleanValue)value).toBoolean()); } else if(value instanceof EntityValue) { serializeEntity(((EntityValue) value).toEntity(), generator); } else { generator.writeString(value.toString());
@Override public Property mapToProperty(String propertyName, Object value) { Property property = new MultivalueProperty(propertyName, true); EmbeddedEntity entity = new EmbeddedEntity(); Map<String, ?> rawValueMap = mapToRawType(value); rawValueMap.forEach((k, v) -> { try { TypeMapper typeMapper = getTypeMapper(v.getClass()); entity.addProperty(typeMapper.mapToProperty(k, v)); } catch (JasDBStorageException e) { LOG.error("", e); } }); property.addValue(new EntityValue(entity)); return property; }
Entity embedEntity = value.toEntity();
Entity embedEntity = value.toEntity();