public static Map<String, Object> getSchemaProperties( String entityType, Map<String, Object> properties ) { Map<String, Object> sys_props = new TreeMap<String, Object>( String.CASE_INSENSITIVE_ORDER ); for ( String propName : properties.keySet() ) { if ( Schema.getDefaultSchema().hasProperty( entityType, propName ) ) { Object propValue = properties.get( propName ); sys_props.put( propName, propValue ); } } return sys_props; }
public static Map<String, Object> getDynamicProperties( String entityType, Map<String, Object> properties ) { Map<String, Object> sys_props = new TreeMap<String, Object>( String.CASE_INSENSITIVE_ORDER ); for ( String propName : properties.keySet() ) { if ( !Schema.getDefaultSchema().hasProperty( entityType, propName ) ) { Object propValue = properties.get( propName ); sys_props.put( propName, propValue ); } } return sys_props; } }
public Map<String, Object> cleanUpdatedProperties( String entityType, Map<String, Object> properties, boolean create ) { if ( properties == null ) { return null; } entityType = normalizeEntityType( entityType ); properties.remove( PROPERTY_UUID ); properties.remove( PROPERTY_TYPE ); properties.remove( PROPERTY_METADATA ); properties.remove( PROPERTY_MEMBERSHIP ); properties.remove( PROPERTY_CONNECTION ); Iterator<Entry<String, Object>> iterator = properties.entrySet().iterator(); while ( iterator.hasNext() ) { Entry<String, Object> entry = iterator.next(); if ( hasProperty( entityType, entry.getKey() ) ) { if ( !create && !isPropertyMutable( entityType, entry.getKey() ) ) { iterator.remove(); continue; } Object propertyValue = entry.getValue(); if ( ( propertyValue instanceof String ) && (propertyValue.equals("")) ) { propertyValue = null; } if ( ( propertyValue == null ) && isRequiredProperty( entityType, entry.getKey() ) ) { iterator.remove(); } } } return properties; }
while ( i.hasNext() ) { String propertyName = i.next(); if ( !hasProperty( entityType, propertyName ) ) { fieldsToRemove.add( propertyName );
public Object validateEntityPropertyValue( String entityType, String propertyName, Object propertyValue ) throws PropertyTypeConversionException { entityType = normalizeEntityType( entityType ); if ( ( propertyValue instanceof String ) && propertyValue.equals("") ) { propertyValue = null; } if ( !hasProperty( entityType, propertyName ) ) { return propertyValue; } /* * if (PROPERTY_TYPE.equals(propertyName)) { return * string(propertyValue); } else if (PROPERTY_ID.equals(propertyName)) { * return uuid(propertyValue); } */ Class<?> type = getPropertyType( entityType, propertyName ); if ( type != null ) { // propertyValue = coerce(type, propertyValue); try { propertyValue = mapper.convertValue( propertyValue, type ); } catch ( Exception e ) { throw new PropertyTypeConversionException( entityType, propertyName, propertyValue, type, e ); } } return propertyValue; }
@Test public void hasPropertyDynamic() { assertFalse( Schema.getDefaultSchema().hasProperty( "things", "" ) ); assertFalse( Schema.getDefaultSchema().hasProperty( "things", "foo" ) ); }
@Test public void hasPropertyTyped() { assertFalse( Schema.getDefaultSchema().hasProperty( "user", "" ) ); assertTrue( Schema.getDefaultSchema().hasProperty( "user", "username" ) ); }
boolean entitySchemaHasProperty = defaultSchema.hasProperty( entity.getType(), propertyName );