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; }
@Override @JsonIgnore public Map<String, Object> getProperties() { return Schema.getDefaultSchema().getEntityProperties( this ); }
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; } }
@Override public final Object getProperty( String propertyName ) { return Schema.getDefaultSchema().getEntityProperty(this, propertyName); }
@Override public final void setProperty( String propertyName, Object propertyValue ) { Schema.getDefaultSchema().setEntityProperty( this, propertyName, propertyValue ); }
public Set<String> getCollectionSet( EntityRef ref ) { Set<String> set = Schema.getDefaultSchema().getCollectionNames(ref.getType()); set = new LinkedHashSet<String>( set ); if ( declaredCollections != null ) { set.addAll( declaredCollections ); } if ( privateCollections != null ) { set.removeAll( privateCollections ); } if ( set.size() > 0 ) { return set; } return null; }
@Override @EntityProperty(required = true, mutable = false, basic = true, indexed = false) public String getType() { return Schema.getDefaultSchema().getEntityType( this.getClass() ); }
public static Entity fromMap( Entity entity, Map<String, Object> map, String entityType, boolean topLevel ) { if ( entity == null ) { entity = new Entity(); } SchemaManager schemaManager = Schema.getDefaultSchema(); return mapConverter.fromMap(entity,map, schemaManager, entityType,topLevel); }
public Set<String> getPropertiesIndexed() { if ( propertiesIndexed != null ) { return propertiesIndexed; } return Schema.getDefaultSchema().getEntityInfo( getType() ).getIndexedProperties(); }
public boolean isCollectionReversed( ServiceContext context ) { if ( info == null ) { return false; } if ( "application".equals( context.getOwner().getType() ) ) { return Schema.getDefaultSchema().isCollectionReversed("application", pluralize(info.getItemType())); } return Schema.getDefaultSchema().isCollectionReversed(info.getContainerType(), info.getCollectionName()); }
public String getCollectionSort( ServiceContext context ) { if ( info == null ) { return null; } if ( "application".equals( context.getOwner().getType() ) ) { return Schema.getDefaultSchema().getCollectionSort("application", pluralize(info.getItemType())); } return Schema.getDefaultSchema().getCollectionSort(info.getContainerType(), info.getCollectionName()); }
@Test public void testTypes() throws Exception { logger.info( "" + Schema.getDefaultSchema().getEntityClass( "sample_entity" ) ); logger.info( "" + Schema.getDefaultSchema().getEntityType( SampleEntity.class ) ); SampleEntity entity = new SampleEntity(); logger.info( entity.getType() ); }
@Test public void testJsonSchema() throws Exception { logger.info( mapToFormattedJsonString( Schema.getDefaultSchema().getEntityJsonSchema( "user" ) ) ); logger.info( mapToFormattedJsonString( Schema.getDefaultSchema().getEntityJsonSchema( "test" ) ) ); }
@Test public void hasPropertyTyped() { assertFalse( Schema.getDefaultSchema().hasProperty( "user", "" ) ); assertTrue( Schema.getDefaultSchema().hasProperty( "user", "username" ) ); }
@Test public void hasPropertyDynamic() { assertFalse( Schema.getDefaultSchema().hasProperty( "things", "" ) ); assertFalse( Schema.getDefaultSchema().hasProperty( "things", "foo" ) ); }
/** Should always return true */ @Test public void indexedTyped() { assertTrue( Schema.getDefaultSchema().isPropertyIndexed( "user", "" ) ); assertTrue( Schema.getDefaultSchema().isPropertyIndexed( "user", "username" ) ); }
@Override public void setProperty( EntityRef entityRef, String propertyName, Object propertyValue, boolean override ) throws Exception { if ( ( propertyValue instanceof String ) && ( ( String ) propertyValue ).equals( "" ) ) { propertyValue = null; } Entity entity = get( entityRef ); propertyValue = Schema.getDefaultSchema().validateEntityPropertyValue( entity.getType(), propertyName, propertyValue ); entity.setProperty( propertyName, propertyValue ); entity.setProperty( PROPERTY_MODIFIED, UUIDUtils.getTimestampInMillis( UUIDUtils.newTimeUUID() ) ); update(entity); }
/** Should always return true for dynamic types */ @Test public void indexedUnTyped() { assertTrue( Schema.getDefaultSchema().isPropertyIndexed( "things", "" ) ); assertTrue( Schema.getDefaultSchema().isPropertyIndexed( "things", "foo" ) ); } }
@Override public Results queryJobData( Query query ) throws Exception { if ( query == null ) { query = new Query(); } String jobDataType = Schema.getDefaultSchema().getEntityType(JobData.class); return getEm().searchCollection( getEm().getApplicationRef(), Schema.defaultCollectionName(jobDataType), query ); }
public Entity convertMvccEntityToEntity( org.apache.usergrid.persistence.model.entity.Entity entity){ if(entity == null) { return null; } Class clazz = Schema.getDefaultSchema().getEntityClass(entity.getId().getType()); Entity oldFormatEntity = EntityFactory.newEntity(entity.getId().getUuid(), entity.getId().getType(), clazz); oldFormatEntity.setProperties(CpEntityMapUtils.toMap(entity)); return oldFormatEntity; }