java.lang.Object
org.gcube.informationsystem.resourceregistry.persistence.orientdb.base.SchemaIndexManagement

public class SchemaIndexManagement extends Object
Creates the indexes the service's lookups rely on, idempotently: bootstrap creates them on a new database, the migration on an existing one. Schema changes, so run outside any transaction, with the admin users.

OrientDB only indexes declared properties, so each field is declared first when it is not. An index on a class covers the records of its subclasses too.

Author:
Luca Frosini (ISTI - CNR)
  • Constructor Summary

    Constructors
    Constructor
    Description
    SchemaIndexManagement(com.orientechnologies.orient.core.db.document.ODatabaseDocument db)
    Creates a new instance over the given session.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Indexes the fields a Context is resolved by, its current path and its previousPaths, not unique: a deleted Context stays in the same class, and a new Context may reuse its path.
    void
    Indexes the UUID of every entity and of every relation, unique: id on EntityElement and on RelationElement, which every vertex and edge the service manages descends from.
    void
    Indexes the name of every Query Template, unique: the registry holds at most one Query Template for each exact, case-sensitive name, under concurrent requests too.
    Returns the UUIDs held by more than one record of the class, subclasses included.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • SchemaIndexManagement

      public SchemaIndexManagement(com.orientechnologies.orient.core.db.document.ODatabaseDocument db)
      Creates a new instance over the given session.
      Parameters:
      db - an admin session, outside any transaction
  • Method Details

    • ensureContextPathIndexes

      public void ensureContextPathIndexes()
      Indexes the fields a Context is resolved by, its current path and its previousPaths, not unique: a deleted Context stays in the same class, and a new Context may reuse its path. Then ContextManagement.OWNED_PATHS, the paths of a live Context, unique: no other live Context may hold any of them, under concurrent requests too.
      Throws:
      IllegalStateException - if the Context class does not exist, or some path is already owned by more than one live Context, listed in the message
    • ensureIdentifierIndexes

      public void ensureIdentifierIndexes()
      Indexes the UUID of every entity and of every relation, unique: id on EntityElement and on RelationElement, which every vertex and edge the service manages descends from. A vertex and an edge are two families and two indexes: the UUID-reuse guard of the code covers the case across them. Records with no id are not indexed.
      Throws:
      IllegalStateException - if either class does not exist, or some UUID is already held by more than one record, listed in the message
    • ensureQueryTemplateNameIndex

      public void ensureQueryTemplateNameIndex()
      Indexes the name of every Query Template, unique: the registry holds at most one Query Template for each exact, case-sensitive name, under concurrent requests too.
      Throws:
      IllegalStateException - if the QueryTemplate class does not exist, or some name is already held by more than one Query Template, listed in the message
    • findDuplicateIdentifiers

      public Map<String,Long> findDuplicateIdentifiers(String className)
      Returns the UUIDs held by more than one record of the class, subclasses included.
      Parameters:
      className - the class to check
      Returns:
      how many records hold each duplicated UUID