java.lang.Object
com.orientechnologies.orient.core.metadata.schema.OClassImpl
All Implemented Interfaces:
OClass, Comparable<OClass>
Direct Known Subclasses:
OClassEmbedded, OClassRemote, OViewImpl

public abstract class OClassImpl extends Object implements OClass
Schema Class implementation.
Author:
Luca Garulli (l.garulli--(at)--orientdb.com)
  • Field Details

    • NOT_EXISTENT_CLUSTER_ID

      protected static final int NOT_EXISTENT_CLUSTER_ID
      See Also:
    • owner

      protected final OSchemaShared owner
    • properties

      protected final Map<String,OProperty> properties
    • defaultClusterId

      protected int defaultClusterId
    • name

      protected String name
    • description

      protected String description
    • clusterIds

      protected int[] clusterIds
    • superClasses

      protected List<OClassImpl> superClasses
    • polymorphicClusterIds

      protected int[] polymorphicClusterIds
    • subclasses

      protected List<OClass> subclasses
    • overSize

      protected float overSize
    • shortName

      protected String shortName
    • strictMode

      protected boolean strictMode
    • abstractClass

      protected boolean abstractClass
    • customFields

      protected Map<String,String> customFields
    • clusterSelection

      protected volatile OClusterSelectionStrategy clusterSelection
    • allocation

      protected OClassAllocationImpl allocation
    • hashCode

      protected volatile int hashCode
  • Constructor Details

    • OClassImpl

      protected OClassImpl(OSchemaShared iOwner, String iName, int[] iClusterIds)
    • OClassImpl

      protected OClassImpl(OSchemaShared iOwner, String iName)
      Constructor used in unmarshalling.
  • Method Details

    • readableClusters

      public static int[] readableClusters(ODatabaseDocument db, int[] iClusterIds, String className)
    • getClusterSelection

      public OClusterSelectionStrategy getClusterSelection()
      Specified by:
      getClusterSelection in interface OClass
    • setClusterSelection

      public OClass setClusterSelection(OClusterSelectionStrategy clusterSelection)
      Specified by:
      setClusterSelection in interface OClass
    • getCustom

      public String getCustom(String iName)
      Specified by:
      getCustom in interface OClass
    • getCustomInternal

      public Map<String,String> getCustomInternal()
    • removeCustom

      public void removeCustom(String name)
      Specified by:
      removeCustom in interface OClass
    • getCustomKeys

      public Set<String> getCustomKeys()
      Specified by:
      getCustomKeys in interface OClass
    • hasClusterId

      public boolean hasClusterId(int clusterId)
      Specified by:
      hasClusterId in interface OClass
    • hasPolymorphicClusterId

      public boolean hasPolymorphicClusterId(int clusterId)
      Specified by:
      hasPolymorphicClusterId in interface OClass
    • getSuperClass

      @Deprecated public OClass getSuperClass()
      Deprecated.
      Specified by:
      getSuperClass in interface OClass
    • setSuperClass

      @Deprecated public OClass setSuperClass(OClass iSuperClass)
      Deprecated.
      Specified by:
      setSuperClass in interface OClass
    • getName

      public String getName()
      Specified by:
      getName in interface OClass
    • getSuperClasses

      public List<OClass> getSuperClasses()
      Specified by:
      getSuperClasses in interface OClass
    • hasSuperClasses

      public boolean hasSuperClasses()
      Specified by:
      hasSuperClasses in interface OClass
    • getSuperClassesNames

      public List<String> getSuperClassesNames()
      Specified by:
      getSuperClassesNames in interface OClass
    • setSuperClassesByNames

      public OClass setSuperClassesByNames(List<String> classNames)
    • setSuperClassesInternal

      protected abstract void setSuperClassesInternal(List<? extends OClass> classes)
    • getSize

      public long getSize()
      Specified by:
      getSize in interface OClass
    • getShortName

      public String getShortName()
      Specified by:
      getShortName in interface OClass
    • getDescription

      public String getDescription()
      Specified by:
      getDescription in interface OClass
    • getStreamableName

      public String getStreamableName()
      Specified by:
      getStreamableName in interface OClass
    • declaredProperties

      public Collection<OProperty> declaredProperties()
      Specified by:
      declaredProperties in interface OClass
    • propertiesMap

      public Map<String,OProperty> propertiesMap()
      Specified by:
      propertiesMap in interface OClass
    • properties

      public Collection<OProperty> properties()
      Specified by:
      properties in interface OClass
    • getIndexedProperties

      public void getIndexedProperties(Collection<OProperty> indexedProperties)
    • getIndexedProperties

      public Collection<OProperty> getIndexedProperties()
      Specified by:
      getIndexedProperties in interface OClass
    • getProperty

      public OProperty getProperty(String propertyName)
      Specified by:
      getProperty in interface OClass
    • createProperty

      public OProperty createProperty(String iPropertyName, OType iType)
      Specified by:
      createProperty in interface OClass
    • createProperty

      public OProperty createProperty(String iPropertyName, OType iType, OClass iLinkedClass)
      Specified by:
      createProperty in interface OClass
    • createProperty

      public OProperty createProperty(String iPropertyName, OType iType, OClass iLinkedClass, boolean unsafe)
      Description copied from interface: OClass
      Create a property in the class with the specified options.
      Specified by:
      createProperty in interface OClass
      Parameters:
      iPropertyName - the name of the property.
      iType - the type of the property.
      iLinkedClass - in case of property of type LINK,LINKLIST,LINKSET,LINKMAP,EMBEDDED,EMBEDDEDLIST,EMBEDDEDSET,EMBEDDEDMAP can be specified a linked class in all the other cases should be null
      unsafe - if true avoid to check the persistent data for compatibility, should be used only if all persistent data is compatible with the property
      Returns:
      the created property.
    • createProperty

      public OProperty createProperty(String iPropertyName, OType iType, OType iLinkedType)
      Specified by:
      createProperty in interface OClass
    • createProperty

      public OProperty createProperty(String iPropertyName, OType iType, OType iLinkedType, boolean unsafe)
      Description copied from interface: OClass
      Create a property in the class with the specified options.
      Specified by:
      createProperty in interface OClass
      Parameters:
      iPropertyName - the name of the property.
      iType - the type of the property.
      iLinkedType - in case of property of type EMBEDDEDLIST,EMBEDDEDSET,EMBEDDEDMAP can be specified a linked type in all the other cases should be null
      unsafe - if true avoid to check the persistent data for compatibility, should be used only if all persistent data is compatible with the property
      Returns:
      the created property.
    • existsProperty

      public boolean existsProperty(String propertyName)
      Specified by:
      existsProperty in interface OClass
    • fromStream

      public void fromStream(ODocument document)
    • createPropertyInstance

      protected abstract OPropertyImpl createPropertyInstance()
    • toStream

      public ODocument toStream()
    • getClusterForNewInstance

      public int getClusterForNewInstance(ODocument doc)
      Specified by:
      getClusterForNewInstance in interface OClass
    • getDefaultClusterId

      public int getDefaultClusterId()
      Specified by:
      getDefaultClusterId in interface OClass
    • getClusterIds

      public int[] getClusterIds()
      Specified by:
      getClusterIds in interface OClass
    • getPolymorphicClusterIds

      public int[] getPolymorphicClusterIds()
      Specified by:
      getPolymorphicClusterIds in interface OClass
    • renameProperty

      public void renameProperty(String iOldName, String iNewName)
    • addClusters

      public static OClass addClusters(OClass cls, int iClusters)
    • truncateClusterInternal

      protected void truncateClusterInternal(String clusterName, ODatabaseDocumentInternal database)
    • getSubclasses

      public Collection<OClass> getSubclasses()
      Specified by:
      getSubclasses in interface OClass
      Returns:
      all the subclasses (one level hierarchy only)
    • getAllSubclasses

      public Collection<OClass> getAllSubclasses()
      Specified by:
      getAllSubclasses in interface OClass
      Returns:
      all the subclass hierarchy
    • getBaseClasses

      @Deprecated public Collection<OClass> getBaseClasses()
      Deprecated.
      Specified by:
      getBaseClasses in interface OClass
    • getAllBaseClasses

      @Deprecated public Collection<OClass> getAllBaseClasses()
      Deprecated.
      Specified by:
      getAllBaseClasses in interface OClass
    • getAllSuperClasses

      public Collection<OClass> getAllSuperClasses()
      Specified by:
      getAllSuperClasses in interface OClass
      Returns:
      all recursively collected super classes
    • removeBaseClassInternal

      public abstract OClass removeBaseClassInternal(OClass baseClass)
    • getOverSize

      public float getOverSize()
      Description copied from interface: OClass
      Returns the oversize factor. Oversize is used to extend the record size by a factor to avoid defragmentation upon updates. 0 or 1.0 means no oversize.
      Specified by:
      getOverSize in interface OClass
      Returns:
      Oversize factor
      See Also:
    • getClassOverSize

      public float getClassOverSize()
      Specified by:
      getClassOverSize in interface OClass
    • isAbstract

      public boolean isAbstract()
      Specified by:
      isAbstract in interface OClass
    • isStrictMode

      public boolean isStrictMode()
      Specified by:
      isStrictMode in interface OClass
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • compareTo

      public int compareTo(OClass o)
      Specified by:
      compareTo in interface Comparable<OClass>
    • count

      public long count()
      Description copied from interface: OClass
      Returns the number of the records of this class considering also subclasses (polymorphic).
      Specified by:
      count in interface OClass
    • count

      public long count(boolean isPolymorphic)
      Description copied from interface: OClass
      Returns the number of the records of this class and based on polymorphic parameter it consider or not the subclasses.
      Specified by:
      count in interface OClass
    • truncate

      public void truncate()
      Truncates all the clusters the class uses.
      Specified by:
      truncate in interface OClass
    • isSubClassOf

      public boolean isSubClassOf(String iClassName)
      Check if the current instance extends specified schema class.
      Specified by:
      isSubClassOf in interface OClass
      Parameters:
      iClassName - of class that should be checked
      Returns:
      Returns true if the current instance extends the passed schema class (iClass)
      See Also:
    • isSubClassOf

      public boolean isSubClassOf(OClass clazz)
      Check if the current instance extends specified schema class.
      Specified by:
      isSubClassOf in interface OClass
      Parameters:
      clazz - to check
      Returns:
      true if the current instance extends the passed schema class (iClass)
      See Also:
    • isSuperClassOf

      public boolean isSuperClassOf(OClass clazz)
      Returns true if the passed schema class (iClass) extends the current instance.
      Specified by:
      isSuperClassOf in interface OClass
      Parameters:
      clazz - to check
      Returns:
      Returns true if the passed schema class extends the current instance
      See Also:
    • get

      public Object get(OClass.ATTRIBUTES iAttribute)
      Specified by:
      get in interface OClass
    • set

      public OClass set(OClass.ATTRIBUTES attribute, Object iValue)
      Specified by:
      set in interface OClass
    • setEncryption

      public abstract OClassImpl setEncryption(String iValue)
    • createIndex

      public OIndex createIndex(String iName, OClass.INDEX_TYPE iType, String... fields)
      Description copied from interface: OClass
      Creates database index that is based on passed in field names. Given index will be added into class instance and associated with database index.
      Specified by:
      createIndex in interface OClass
      Parameters:
      iName - Database index name
      iType - Index type.
      fields - Field names from which index will be created.
      Returns:
      Class index registered inside of given class ans associated with database index.
    • createIndex

      public OIndex createIndex(String iName, String iType, String... fields)
      Description copied from interface: OClass
      Creates database index that is based on passed in field names. Given index will be added into class instance and associated with database index.
      Specified by:
      createIndex in interface OClass
      Parameters:
      iName - Database index name
      iType - Index type.
      fields - Field names from which index will be created.
      Returns:
      Class index registered inside of given class ans associated with database index.
    • createIndex

      public OIndex createIndex(String iName, OClass.INDEX_TYPE iType, OProgressListener iProgressListener, String... fields)
      Description copied from interface: OClass
      Creates database index that is based on passed in field names. Given index will be added into class instance.
      Specified by:
      createIndex in interface OClass
      Parameters:
      iName - Database index name.
      iType - Index type.
      iProgressListener - Progress listener.
      fields - Field names from which index will be created.
      Returns:
      Class index registered inside of given class ans associated with database index.
    • createIndex

      public OIndex createIndex(String iName, String iType, OProgressListener iProgressListener, ODocument metadata, String... fields)
      Description copied from interface: OClass
      Creates database index that is based on passed in field names. Given index will be added into class instance.
      Specified by:
      createIndex in interface OClass
      Parameters:
      iName - Database index name.
      iType - Index type.
      iProgressListener - Progress listener.
      metadata - Additional parameters which will be added in index configuration document as "metadata" field.
      fields - Field names from which index will be created. @return Class index registered inside of given class ans associated with database index.
    • createIndex

      public OIndex createIndex(String name, String type, OProgressListener progressListener, ODocument metadata, String algorithm, String... fields)
      Description copied from interface: OClass
      Creates database index that is based on passed in field names. Given index will be added into class instance.
      Specified by:
      createIndex in interface OClass
      Parameters:
      name - Database index name.
      type - Index type.
      progressListener - Progress listener.
      metadata - Additional parameters which will be added in index configuration document as "metadata" field.
      algorithm - Algorithm to use for indexing.
      fields - Field names from which index will be created. @return Class index registered inside of given class ans associated with database index.
    • areIndexed

      public boolean areIndexed(String... fields)
      Specified by:
      areIndexed in interface OClass
      Parameters:
      fields - Field names.
      Returns:
      true if given fields are contained as first key fields in class indexes.
      See Also:
    • areIndexed

      public boolean areIndexed(Collection<String> fields)
      Description copied from interface: OClass
      Indicates whether given fields are contained as first key fields in class indexes. Order of fields does not matter. If there are indexes for the given set of fields in super class they will be taken into account.
      Specified by:
      areIndexed in interface OClass
      Parameters:
      fields - Field names.
      Returns:
      true if given fields are contained as first key fields in class indexes.
    • getInvolvedIndexes

      public Set<OIndex> getInvolvedIndexes(String... fields)
      Description copied from interface: OClass
      Returns list of indexes that contain passed in fields names as their first keys. Order of fields does not matter.

      All indexes sorted by their count of parameters in ascending order. If there are indexes for the given set of fields in super class they will be taken into account.

      Specified by:
      getInvolvedIndexes in interface OClass
      Parameters:
      fields - Field names.
      Returns:
      list of indexes that contain passed in fields names as their first keys.
      See Also:
    • getInvolvedIndexes

      public Set<OIndex> getInvolvedIndexes(Collection<String> fields)
      Description copied from interface: OClass
      Returns list of indexes that contain passed in fields names as their first keys. Order of fields does not matter.

      All indexes sorted by their count of parameters in ascending order. If there are indexes for the given set of fields in super class they will be taken into account.

      Specified by:
      getInvolvedIndexes in interface OClass
      Parameters:
      fields - Field names.
      Returns:
      list of indexes that contain passed in fields names as their first keys.
      See Also:
    • getClassInvolvedIndexes

      public Set<OIndex> getClassInvolvedIndexes(Collection<String> fields)
      Description copied from interface: OClass
      Returns list of indexes that contain passed in fields names as their first keys. Order of fields does not matter.

      Indexes that related only to the given class will be returned.

      Specified by:
      getClassInvolvedIndexes in interface OClass
      Parameters:
      fields - Field names.
      Returns:
      list of indexes that contain passed in fields names as their first keys.
      See Also:
    • getClassInvolvedIndexes

      public Set<OIndex> getClassInvolvedIndexes(String... fields)
      Specified by:
      getClassInvolvedIndexes in interface OClass
      Parameters:
      fields - Field names.
      Returns:
      list of indexes that contain passed in fields names as their first keys.
      See Also:
    • getClassIndex

      public OIndex getClassIndex(String name)
      Description copied from interface: OClass
      Returns index instance by database index name.
      Specified by:
      getClassIndex in interface OClass
      Parameters:
      name - Database index name.
      Returns:
      Index instance.
    • getClassIndexes

      public Set<OIndex> getClassIndexes()
      Specified by:
      getClassIndexes in interface OClass
      Returns:
      All indexes for given class, not the inherited ones.
    • getClassIndexes

      public void getClassIndexes(Collection<OIndex> indexes)
      Description copied from interface: OClass
      Internal. Copy all the indexes for given class, not the inherited ones, in the collection received as argument.
      Specified by:
      getClassIndexes in interface OClass
    • getAutoShardingIndex

      public OIndex getAutoShardingIndex()
      Description copied from interface: OClass
      Returns the auto sharding index configured for the class if any.
      Specified by:
      getAutoShardingIndex in interface OClass
    • isEdgeType

      public boolean isEdgeType()
      Specified by:
      isEdgeType in interface OClass
      Returns:
      true if this class represents a subclass of an edge class (E)
    • isVertexType

      public boolean isVertexType()
      Specified by:
      isVertexType in interface OClass
      Returns:
      true if this class represents a subclass of a vertex class (V)
    • onPostIndexManagement

      public void onPostIndexManagement()
    • getIndexes

      public void getIndexes(Collection<OIndex> indexes)
      Description copied from interface: OClass
      Internal. All indexes for given class and its super classes.
      Specified by:
      getIndexes in interface OClass
    • getIndexes

      public Set<OIndex> getIndexes()
      Specified by:
      getIndexes in interface OClass
      Returns:
      All indexes for given class and its super classes.
    • acquireSchemaReadLock

      public void acquireSchemaReadLock()
    • releaseSchemaReadLock

      public void releaseSchemaReadLock()
    • acquireSchemaWriteLock

      public void acquireSchemaWriteLock()
    • acquireSchemaWriteLock

      public void acquireSchemaWriteLock(ODatabaseDocumentInternal database)
    • releaseSchemaWriteLock

      public void releaseSchemaWriteLock()
    • releaseSchemaWriteLock

      public void releaseSchemaWriteLock(boolean iSave)
    • releaseSchemaWriteLock

      public void releaseSchemaWriteLock(ODatabaseDocumentInternal database, boolean iSave)
    • checkEmbedded

      public void checkEmbedded()
    • setClusterSelectionInternal

      public void setClusterSelectionInternal(OClusterSelectionStrategy iClusterSelection)
    • fireDatabaseMigration

      public void fireDatabaseMigration(ODatabaseDocument database, String propertyName, OType type)
    • firePropertyNameMigration

      public void firePropertyNameMigration(ODatabaseDocument database, String propertyName, String newPropertyName, OType type)
    • checkPersistentPropertyType

      public void checkPersistentPropertyType(ODatabaseInternal<ORecord> database, String propertyName, OType type, OClass linkedClass)
    • checkAllLikedObjects

      protected void checkAllLikedObjects(ODatabaseInternal<ORecord> database, String propertyName, OType type, OClass linkedClass)
    • matchesType

      protected boolean matchesType(Object x, OClass linkedClass)
    • getEscapedName

      protected String getEscapedName(String iName, boolean iStrictSQL)
    • getOwner

      public OSchemaShared getOwner()
    • renameCluster

      protected void renameCluster(String oldName, String newName)
    • onlyAddPolymorphicClusterId

      protected void onlyAddPolymorphicClusterId(int clusterId)
    • addProperty

      protected abstract OProperty addProperty(String propertyName, OType type, OType linkedType, OClass linkedClass, boolean unsafe)
    • validatePropertyName

      protected void validatePropertyName(String propertyName)
    • addClusterIdToIndexes

      protected abstract void addClusterIdToIndexes(int iId)
    • addBaseClass

      public OClass addBaseClass(OClassImpl iBaseClass)
      Adds a base class to the current one. It adds also the base class cluster ids to the polymorphic cluster ids array.
      Parameters:
      iBaseClass - The base class to add.
    • checkParametersConflict

      protected void checkParametersConflict(OClass baseClass)
    • checkParametersConflict

      public static void checkParametersConflict(List<OClass> classes)
    • removePolymorphicClusterIds

      protected void removePolymorphicClusterIds(OClassImpl iBaseClass)
    • onlyRemovePolymorphicClusterId

      protected void onlyRemovePolymorphicClusterId(int clusterId)
    • removePolymorphicClusterId

      protected void removePolymorphicClusterId(int clusterId)
    • getDatabase

      protected ODatabaseDocumentInternal getDatabase()
    • addPolymorphicClusterIds

      protected void addPolymorphicClusterIds(OClassImpl iBaseClass)
      Add different cluster id to the "polymorphic cluster ids" array.
    • extractFieldTypes

      public List<OType> extractFieldTypes(String[] fieldNames)
    • setClusterIds

      protected OClass setClusterIds(int[] iClusterIds)
    • decodeClassName

      public static String decodeClassName(String s)
    • toNetworkStream

      public ODocument toNetworkStream()
    • getAllocation

      public OClassAllocationImpl getAllocation()
      Specified by:
      getAllocation in interface OClass