org.usergrid.persistence
Class Schema
java.lang.Object
org.usergrid.persistence.Schema
public class Schema
- extends Object
The controller class for determining Entity relationships as well as
properties types. This class loads the entity schema definition from a YAML
file called usergrid-schema.yaml at the root of the classpath.
- Author:
- edanuff
Method Summary |
void |
addEntitiesPackage(String entityPackage)
|
String |
aliasProperty(String entityType)
|
Map<String,Object> |
cleanUpdatedProperties(String entityType,
Map<String,Object> properties)
|
Map<String,Object> |
cleanUpdatedProperties(String entityType,
Map<String,Object> properties,
boolean create)
|
Object |
convertToPropertyType(Class<? extends Entity> entityClass,
String property,
Object value)
|
Object |
convertToPropertyType(String type,
String property,
Object value)
|
static String |
defaultCollectionName(String entityType)
|
static Map<String,Object> |
deserializeEntityProperties(List<me.prettyprint.hector.api.beans.HColumn<String,ByteBuffer>> columns)
|
static Map<String,Object> |
deserializeEntityProperties(List<me.prettyprint.hector.api.beans.HColumn<String,ByteBuffer>> columns,
boolean checkId,
boolean checkRequired)
|
static Map<String,Object> |
deserializeEntityProperties(Map<String,ByteBuffer> columns)
|
static Map<String,Object> |
deserializeEntityProperties(Map<String,ByteBuffer> columns,
boolean checkId,
boolean checkRequired)
|
static Map<String,Object> |
deserializeEntityProperties(me.prettyprint.hector.api.beans.Row<UUID,String,ByteBuffer> row)
|
static Object |
deserializeEntityProperty(String entityType,
String propertyName,
ByteBuffer bytes)
|
static Object |
deserializePropertyValueFromJsonBinary(ByteBuffer bytes)
|
static Object |
deserializePropertyValueFromJsonBinary(ByteBuffer bytes,
Class<?> classType)
|
Map<String,PropertyInfo> |
getAllIndexedProperties()
|
Set<String> |
getAllIndexedPropertyNames()
|
Set<String> |
getAllPropertyNames()
|
String[] |
getAllPropertyNamesAsArray()
|
static String |
getAssociatedEntityType(String entityType)
|
Set<String> |
getBasicProperties(String entityType)
|
CollectionInfo |
getCollection(String containerType,
String collectionName)
|
Set<String> |
getCollectionNames(String entityType)
|
List<String> |
getCollectionNamesAsList(String entityType)
|
Map<String,CollectionInfo> |
getCollections(String entityType)
|
String |
getCollectionSort(String containerType,
String collectionName)
|
String |
getCollectionType(String containerType,
String collectionName)
|
CollectionInfo |
getContainerCollectionLinkedToCollection(String containerType,
String collectionName)
|
Map<String,Set<CollectionInfo>> |
getContainers(String entityType)
|
Map<String,Set<CollectionInfo>> |
getContainersIndexingDictionaries(String entityType)
|
Map<String,Set<CollectionInfo>> |
getContainersIndexingDictionary(String entityType,
String dictionaryName)
|
Map<String,Set<CollectionInfo>> |
getContainersIndexingDynamicSetInfos(String entityType)
|
Map<String,Set<CollectionInfo>> |
getContainersIndexingProperties(String entityType)
|
Map<String,Set<CollectionInfo>> |
getContainersIndexingProperty(String entityType,
String propertyName)
|
Map<String,Set<CollectionInfo>> |
getContainersSubkeyedOnProperties(String entityType)
|
Map<String,Set<CollectionInfo>> |
getContainersSubkeyedOnPropertyInfo(String entityType,
String propertyName)
|
static Schema |
getDefaultSchema()
|
PropertyDescriptor |
getDescriptorForEntityProperty(Class<? extends Entity> entityClass,
String property)
|
Class<?> |
getDictionaryKeyType(String entityType,
String dictionaryName)
|
Set<String> |
getDictionaryNames(String entityType)
|
Class<?> |
getDictionaryValueType(String entityType,
String dictionaryName)
|
EntityInfo |
getDynamicEntityInfo(String entityType)
|
List<String> |
getEntitiesPackage()
|
Class<? extends Entity> |
getEntityClass(String type)
|
EntityInfo |
getEntityInfo(String entityType)
|
org.codehaus.jackson.JsonNode |
getEntityJsonSchema(String entityType)
|
Map<String,Object> |
getEntityProperties(Entity entity)
|
Object |
getEntityProperty(Entity entity,
String property)
|
String |
getEntityType(Class<? extends Entity> cls)
|
Set<String> |
getPropertiesIndexedInConnections(String entityType)
|
Set<String> |
getPropertyNames(String entityType)
|
String[] |
getPropertyNamesAsArray(String entityType)
|
Class<?> |
getPropertyType(String entityType,
String propertyName)
|
Set<String> |
getRequiredProperties(String entityType)
|
boolean |
hasCollection(String containerType,
String collectionName)
|
boolean |
hasDictionaries(String entityType)
|
boolean |
hasDictionary(String entityType,
String dictionaryName)
|
boolean |
hasProperties(String entityType)
|
boolean |
hasProperty(String entityType,
String propertyName)
|
void |
init()
|
static boolean |
isAssociatedEntityType(String entityType)
|
boolean |
isCollectionPathBased(String containerType,
String collectionName)
|
boolean |
isCollectionReversed(String containerType,
String collectionName)
|
boolean |
isDictionaryIndexedInCollection(String containerType,
String collectionName,
String dictionaryName)
|
boolean |
isDictionaryIndexedInConnections(String entityType,
String dictionaryName)
|
boolean |
isPropertyCollectionSubkey(String containerType,
String collectionName,
String propertyName)
|
boolean |
isPropertyFulltextIndexed(String entityType,
String propertyName)
|
boolean |
isPropertyIndexed(String entityType,
String propertyName)
|
boolean |
isPropertyIndexedInCollection(String containerType,
String collectionName,
String propertyName)
|
boolean |
isPropertyIndexedInConnections(String entityType,
String propertyName)
|
boolean |
isPropertyMutable(String entityType,
String propertyName)
|
boolean |
isPropertyTimestamp(String entityType,
String propertyName)
|
boolean |
isPropertyUnique(String entityType,
String propertyName)
|
boolean |
isRequiredProperty(String entityType,
String propertyName)
|
void |
mapCollector(String entityType,
String containerType,
String collectionName,
CollectionInfo collection)
|
static String |
normalizeEntityType(String entityType)
|
static String |
normalizeEntityType(String entityType,
boolean baseType)
|
void |
registerEntity(Class<? extends Entity> entityClass)
|
void |
removeEntitiesPackage(String entityPackage)
|
void |
scanEntities()
|
static ByteBuffer |
serializeEntityProperty(String entityType,
String propertyName,
Object propertyValue)
|
static ByteBuffer |
serializePropertyValueToJsonBinary(Object obj)
|
static void |
setDefaultSchema(Schema instance)
|
void |
setEntityProperty(Entity entity,
String property,
Object value)
|
Entity |
toEntity(Map<String,Object> map)
|
Map<String,Object> |
toMap(Entity entity)
|
Object |
validateEntityPropertyValue(String entityType,
String propertyName,
Object propertyValue)
|
Object |
validateEntitySetValue(String entityType,
String dictionaryName,
Object elementValue)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
DEFAULT_ENTITIES_PACKAGE
public static final String DEFAULT_ENTITIES_PACKAGE
- See Also:
- Constant Field Values
TYPE_APPLICATION
public static final String TYPE_APPLICATION
- See Also:
- Constant Field Values
TYPE_ENTITY
public static final String TYPE_ENTITY
- See Also:
- Constant Field Values
TYPE_ROLE
public static final String TYPE_ROLE
- See Also:
- Constant Field Values
TYPE_CONNECTION
public static final String TYPE_CONNECTION
- See Also:
- Constant Field Values
TYPE_MEMBER
public static final String TYPE_MEMBER
- See Also:
- Constant Field Values
PROPERTY_ACTIVATED
public static final String PROPERTY_ACTIVATED
- See Also:
- Constant Field Values
PROPERTY_COLLECTION_NAME
public static final String PROPERTY_COLLECTION_NAME
- See Also:
- Constant Field Values
PROPERTY_CREATED
public static final String PROPERTY_CREATED
- See Also:
- Constant Field Values
PROPERTY_DISABLED
public static final String PROPERTY_DISABLED
- See Also:
- Constant Field Values
PROPERTY_UUID
public static final String PROPERTY_UUID
- See Also:
- Constant Field Values
PROPERTY_EMAIL
public static final String PROPERTY_EMAIL
- See Also:
- Constant Field Values
PROPERTY_ITEM
public static final String PROPERTY_ITEM
- See Also:
- Constant Field Values
PROPERTY_ITEM_TYPE
public static final String PROPERTY_ITEM_TYPE
- See Also:
- Constant Field Values
PROPERTY_MEMBERSHIP
public static final String PROPERTY_MEMBERSHIP
- See Also:
- Constant Field Values
PROPERTY_METADATA
public static final String PROPERTY_METADATA
- See Also:
- Constant Field Values
PROPERTY_MODIFIED
public static final String PROPERTY_MODIFIED
- See Also:
- Constant Field Values
PROPERTY_NAME
public static final String PROPERTY_NAME
- See Also:
- Constant Field Values
PROPERTY_OWNER
public static final String PROPERTY_OWNER
- See Also:
- Constant Field Values
PROPERTY_OWNER_TYPE
public static final String PROPERTY_OWNER_TYPE
- See Also:
- Constant Field Values
PROPERTY_PATH
public static final String PROPERTY_PATH
- See Also:
- Constant Field Values
PROPERTY_PICTURE
public static final String PROPERTY_PICTURE
- See Also:
- Constant Field Values
PROPERTY_PUBLISHED
public static final String PROPERTY_PUBLISHED
- See Also:
- Constant Field Values
PROPERTY_SECRET
public static final String PROPERTY_SECRET
- See Also:
- Constant Field Values
PROPERTY_TIMESTAMP
public static final String PROPERTY_TIMESTAMP
- See Also:
- Constant Field Values
PROPERTY_TITLE
public static final String PROPERTY_TITLE
- See Also:
- Constant Field Values
PROPERTY_TYPE
public static final String PROPERTY_TYPE
- See Also:
- Constant Field Values
PROPERTY_URI
public static final String PROPERTY_URI
- See Also:
- Constant Field Values
PROPERTY_USERNAME
public static final String PROPERTY_USERNAME
- See Also:
- Constant Field Values
PROPERTY_INACTIVITY
public static final String PROPERTY_INACTIVITY
- See Also:
- Constant Field Values
PROPERTY_CONNECTION
public static final String PROPERTY_CONNECTION
- See Also:
- Constant Field Values
PROPERTY_ASSOCIATED
public static final String PROPERTY_ASSOCIATED
- See Also:
- Constant Field Values
PROPERTY_CURSOR
public static final String PROPERTY_CURSOR
- See Also:
- Constant Field Values
COLLECTION_ROLES
public static final String COLLECTION_ROLES
- See Also:
- Constant Field Values
COLLECTION_USERS
public static final String COLLECTION_USERS
- See Also:
- Constant Field Values
COLLECTION_GROUPS
public static final String COLLECTION_GROUPS
- See Also:
- Constant Field Values
INDEX_COLLECTIONS
public static final String INDEX_COLLECTIONS
- See Also:
- Constant Field Values
INDEX_CONNECTIONS
public static final String INDEX_CONNECTIONS
- See Also:
- Constant Field Values
DICTIONARY_PROPERTIES
public static final String DICTIONARY_PROPERTIES
- See Also:
- Constant Field Values
DICTIONARY_SETS
public static final String DICTIONARY_SETS
- See Also:
- Constant Field Values
DICTIONARY_COLLECTIONS
public static final String DICTIONARY_COLLECTIONS
- See Also:
- Constant Field Values
DICTIONARY_CONNECTIONS
public static final String DICTIONARY_CONNECTIONS
- See Also:
- Constant Field Values
DICTIONARY_INDEXES
public static final String DICTIONARY_INDEXES
- See Also:
- Constant Field Values
DICTIONARY_CONNECTING_TYPES
public static final String DICTIONARY_CONNECTING_TYPES
- See Also:
- Constant Field Values
DICTIONARY_CONNECTING_ENTITIES
public static final String DICTIONARY_CONNECTING_ENTITIES
- See Also:
- Constant Field Values
DICTIONARY_CONNECTED_TYPES
public static final String DICTIONARY_CONNECTED_TYPES
- See Also:
- Constant Field Values
DICTIONARY_CONNECTED_ENTITIES
public static final String DICTIONARY_CONNECTED_ENTITIES
- See Also:
- Constant Field Values
DICTIONARY_CONTAINER_ENTITIES
public static final String DICTIONARY_CONTAINER_ENTITIES
- See Also:
- Constant Field Values
DICTIONARY_CREDENTIALS
public static final String DICTIONARY_CREDENTIALS
- See Also:
- Constant Field Values
DICTIONARY_ROLENAMES
public static final String DICTIONARY_ROLENAMES
- See Also:
- Constant Field Values
DICTIONARY_ROLETIMES
public static final String DICTIONARY_ROLETIMES
- See Also:
- Constant Field Values
DICTIONARY_PERMISSIONS
public static final String DICTIONARY_PERMISSIONS
- See Also:
- Constant Field Values
DICTIONARY_ID_SETS
public static final String DICTIONARY_ID_SETS
- See Also:
- Constant Field Values
DICTIONARY_COUNTERS
public static final String DICTIONARY_COUNTERS
- See Also:
- Constant Field Values
DICTIONARY_GEOCELL
public static final String DICTIONARY_GEOCELL
- See Also:
- Constant Field Values
DEFAULT_DICTIONARIES
public static Map<String,Class> DEFAULT_DICTIONARIES
initLock
public static final Object initLock
Schema
public Schema()
setDefaultSchema
public static void setDefaultSchema(Schema instance)
getDefaultSchema
public static Schema getDefaultSchema()
mapCollector
public void mapCollector(String entityType,
String containerType,
String collectionName,
CollectionInfo collection)
registerEntity
public void registerEntity(Class<? extends Entity> entityClass)
init
public void init()
scanEntities
public void scanEntities()
addEntitiesPackage
public void addEntitiesPackage(String entityPackage)
removeEntitiesPackage
public void removeEntitiesPackage(String entityPackage)
getEntitiesPackage
public List<String> getEntitiesPackage()
getAllIndexedProperties
public Map<String,PropertyInfo> getAllIndexedProperties()
- Returns:
- value
getAllIndexedPropertyNames
public Set<String> getAllIndexedPropertyNames()
getAllPropertyNames
public Set<String> getAllPropertyNames()
getAllPropertyNamesAsArray
public String[] getAllPropertyNamesAsArray()
getEntityInfo
public EntityInfo getEntityInfo(String entityType)
- Parameters:
entityType
-
- Returns:
- value
getEntityJsonSchema
public org.codehaus.jackson.JsonNode getEntityJsonSchema(String entityType)
getEntityType
public String getEntityType(Class<? extends Entity> cls)
getEntityClass
public Class<? extends Entity> getEntityClass(String type)
hasProperties
public boolean hasProperties(String entityType)
- Parameters:
entityType
-
- Returns:
- value
getPropertyNames
public Set<String> getPropertyNames(String entityType)
- Parameters:
entityType
-
- Returns:
- value
getPropertyNamesAsArray
public String[] getPropertyNamesAsArray(String entityType)
- Parameters:
entityType
-
- Returns:
- value
hasProperty
public boolean hasProperty(String entityType,
String propertyName)
- Parameters:
entityType
- propertyName
-
- Returns:
- value
aliasProperty
public String aliasProperty(String entityType)
isPropertyMutable
public boolean isPropertyMutable(String entityType,
String propertyName)
- Parameters:
entityType
- propertyName
-
- Returns:
- value
isPropertyUnique
public boolean isPropertyUnique(String entityType,
String propertyName)
isPropertyIndexed
public boolean isPropertyIndexed(String entityType,
String propertyName)
isPropertyFulltextIndexed
public boolean isPropertyFulltextIndexed(String entityType,
String propertyName)
isPropertyTimestamp
public boolean isPropertyTimestamp(String entityType,
String propertyName)
getRequiredProperties
public Set<String> getRequiredProperties(String entityType)
- Parameters:
entityType
-
- Returns:
- value
isRequiredProperty
public boolean isRequiredProperty(String entityType,
String propertyName)
- Parameters:
entityType
- propertyName
-
- Returns:
- value
getPropertyType
public Class<?> getPropertyType(String entityType,
String propertyName)
- Parameters:
entityType
- propertyName
-
- Returns:
- value
getPropertiesIndexedInConnections
public Set<String> getPropertiesIndexedInConnections(String entityType)
- Parameters:
entityType
-
- Returns:
- value
isPropertyIndexedInConnections
public boolean isPropertyIndexedInConnections(String entityType,
String propertyName)
- Parameters:
entityType
- propertyName
-
- Returns:
- value
isPropertyIndexedInCollection
public boolean isPropertyIndexedInCollection(String containerType,
String collectionName,
String propertyName)
- Parameters:
containerType
- collectionName
- propertyName
-
- Returns:
- value
isPropertyCollectionSubkey
public boolean isPropertyCollectionSubkey(String containerType,
String collectionName,
String propertyName)
- Parameters:
containerType
- collectionName
- propertyName
-
- Returns:
- value
getBasicProperties
public Set<String> getBasicProperties(String entityType)
hasDictionaries
public boolean hasDictionaries(String entityType)
- Parameters:
entityType
-
- Returns:
- value
getDictionaryNames
public Set<String> getDictionaryNames(String entityType)
- Parameters:
entityType
-
- Returns:
- value
hasDictionary
public boolean hasDictionary(String entityType,
String dictionaryName)
- Parameters:
entityType
- dictionaryName
-
- Returns:
- value
getDictionaryKeyType
public Class<?> getDictionaryKeyType(String entityType,
String dictionaryName)
- Parameters:
entityType
- dictionaryName
-
- Returns:
- value
getDictionaryValueType
public Class<?> getDictionaryValueType(String entityType,
String dictionaryName)
isDictionaryIndexedInConnections
public boolean isDictionaryIndexedInConnections(String entityType,
String dictionaryName)
- Parameters:
entityType
- dictionaryName
-
- Returns:
- value
isDictionaryIndexedInCollection
public boolean isDictionaryIndexedInCollection(String containerType,
String collectionName,
String dictionaryName)
- Parameters:
containerType
- collectionName
- dictionaryName
-
- Returns:
- value
hasCollection
public boolean hasCollection(String containerType,
String collectionName)
- Parameters:
containerType
- collectionName
-
- Returns:
- value
isCollectionPathBased
public boolean isCollectionPathBased(String containerType,
String collectionName)
isCollectionReversed
public boolean isCollectionReversed(String containerType,
String collectionName)
getCollectionSort
public String getCollectionSort(String containerType,
String collectionName)
getCollection
public CollectionInfo getCollection(String containerType,
String collectionName)
- Parameters:
containerType
- collectionName
-
- Returns:
- value
getCollectionType
public String getCollectionType(String containerType,
String collectionName)
getCollections
public Map<String,CollectionInfo> getCollections(String entityType)
- Parameters:
entityType
-
- Returns:
- value
getCollectionNames
public Set<String> getCollectionNames(String entityType)
getCollectionNamesAsList
public List<String> getCollectionNamesAsList(String entityType)
getContainers
public Map<String,Set<CollectionInfo>> getContainers(String entityType)
- Parameters:
entityType
-
- Returns:
- value
getContainerCollectionLinkedToCollection
public CollectionInfo getContainerCollectionLinkedToCollection(String containerType,
String collectionName)
- Parameters:
entityType
- propertyName
-
- Returns:
- value
getContainersIndexingProperties
public Map<String,Set<CollectionInfo>> getContainersIndexingProperties(String entityType)
- Parameters:
entityType
-
- Returns:
- value
getContainersIndexingDictionaries
public Map<String,Set<CollectionInfo>> getContainersIndexingDictionaries(String entityType)
- Parameters:
entityType
-
- Returns:
- value
getContainersIndexingDynamicSetInfos
public Map<String,Set<CollectionInfo>> getContainersIndexingDynamicSetInfos(String entityType)
- Parameters:
entityType
-
- Returns:
- value
getContainersSubkeyedOnProperties
public Map<String,Set<CollectionInfo>> getContainersSubkeyedOnProperties(String entityType)
- Parameters:
entityType
-
- Returns:
- value
getContainersIndexingProperty
public Map<String,Set<CollectionInfo>> getContainersIndexingProperty(String entityType,
String propertyName)
- Parameters:
entityType
- propertyName
-
- Returns:
- value
getContainersIndexingDictionary
public Map<String,Set<CollectionInfo>> getContainersIndexingDictionary(String entityType,
String dictionaryName)
- Parameters:
entityType
- dictionaryName
-
- Returns:
- value
getContainersSubkeyedOnPropertyInfo
public Map<String,Set<CollectionInfo>> getContainersSubkeyedOnPropertyInfo(String entityType,
String propertyName)
- Parameters:
entityType
- propertyName
-
- Returns:
- value
defaultCollectionName
public static String defaultCollectionName(String entityType)
normalizeEntityType
public static String normalizeEntityType(String entityType)
getAssociatedEntityType
public static String getAssociatedEntityType(String entityType)
normalizeEntityType
public static String normalizeEntityType(String entityType,
boolean baseType)
isAssociatedEntityType
public static boolean isAssociatedEntityType(String entityType)
getDynamicEntityInfo
public EntityInfo getDynamicEntityInfo(String entityType)
- Parameters:
entityType
-
- Returns:
- value
cleanUpdatedProperties
public Map<String,Object> cleanUpdatedProperties(String entityType,
Map<String,Object> properties)
cleanUpdatedProperties
public Map<String,Object> cleanUpdatedProperties(String entityType,
Map<String,Object> properties,
boolean create)
validateEntityPropertyValue
public Object validateEntityPropertyValue(String entityType,
String propertyName,
Object propertyValue)
throws PropertyTypeConversionException
- Throws:
PropertyTypeConversionException
validateEntitySetValue
public Object validateEntitySetValue(String entityType,
String dictionaryName,
Object elementValue)
toEntity
public Entity toEntity(Map<String,Object> map)
toMap
public Map<String,Object> toMap(Entity entity)
convertToPropertyType
public Object convertToPropertyType(Class<? extends Entity> entityClass,
String property,
Object value)
convertToPropertyType
public Object convertToPropertyType(String type,
String property,
Object value)
getDescriptorForEntityProperty
public PropertyDescriptor getDescriptorForEntityProperty(Class<? extends Entity> entityClass,
String property)
setEntityProperty
public void setEntityProperty(Entity entity,
String property,
Object value)
getEntityProperty
public Object getEntityProperty(Entity entity,
String property)
getEntityProperties
public Map<String,Object> getEntityProperties(Entity entity)
deserializeEntityProperties
public static Map<String,Object> deserializeEntityProperties(me.prettyprint.hector.api.beans.Row<UUID,String,ByteBuffer> row)
deserializeEntityProperties
public static Map<String,Object> deserializeEntityProperties(List<me.prettyprint.hector.api.beans.HColumn<String,ByteBuffer>> columns)
- Parameters:
columns
-
- Returns:
- entity properties from columns as a map
deserializeEntityProperties
public static Map<String,Object> deserializeEntityProperties(Map<String,ByteBuffer> columns)
deserializeEntityProperties
public static Map<String,Object> deserializeEntityProperties(List<me.prettyprint.hector.api.beans.HColumn<String,ByteBuffer>> columns,
boolean checkId,
boolean checkRequired)
deserializeEntityProperties
public static Map<String,Object> deserializeEntityProperties(Map<String,ByteBuffer> columns,
boolean checkId,
boolean checkRequired)
- Parameters:
columns
- checkId
- checkRequired
-
- Returns:
- entity properties from columns as a map
deserializeEntityProperty
public static Object deserializeEntityProperty(String entityType,
String propertyName,
ByteBuffer bytes)
- Parameters:
entityType
- propertyName
- bytes
-
- Returns:
- object of correct type deserialize from column bytes
serializeEntityProperty
public static ByteBuffer serializeEntityProperty(String entityType,
String propertyName,
Object propertyValue)
serializePropertyValueToJsonBinary
public static ByteBuffer serializePropertyValueToJsonBinary(Object obj)
deserializePropertyValueFromJsonBinary
public static Object deserializePropertyValueFromJsonBinary(ByteBuffer bytes)
deserializePropertyValueFromJsonBinary
public static Object deserializePropertyValueFromJsonBinary(ByteBuffer bytes,
Class<?> classType)
Copyright © 2013. All Rights Reserved.