Class TdbGraphRecord

All Implemented Interfaces:
com.tietoenator.trip.jxp.internal.utils.DOMSink

public class TdbGraphRecord extends TdbRecord
Container and manipulation logic for a record from a TRIP graph database.

THIS CLASS IS EXPERIMENTAL. METHOD SIGNATURES MAY CHANGE IN FUTURE RELEASES. USE WITH CAUTION.

Since:
TRIPjxp 3.1-0
  • Constructor Details

    • TdbGraphRecord

      public TdbGraphRecord(TdbSession session) throws TdbException
      Constructor, creates a blank graph record container.
      Parameters:
      session - Active session
      Throws:
      TdbException
    • TdbGraphRecord

      public TdbGraphRecord(TdbSession session, TdbDatabaseDesign design) throws TdbException
      Constructor, associates the graph record with the provided database design.
      Parameters:
      session - Active session
      design - Database design
      Throws:
      TdbException
    • TdbGraphRecord

      public TdbGraphRecord(TdbSession session, String name) throws TdbException
      Constructor, associates the record with the named graph database.
      Parameters:
      session - Active session
      name - Name of the graph database.
      Throws:
      TdbException
  • Method Details

    • isVertex

      public boolean isVertex()
      Returns true if this record is a vertex. A vertex record is a graph database record that either
    • isEdge

      public boolean isEdge()
      Returns true if this record is an edge.
    • setGraphRecordType

      public void setGraphRecordType(TdbGraphRecordType type) throws TdbException
      Set the type of the graph record.

      This method can only be called if the record has no assigned type and is not already committed to the graph database.

      Parameters:
      type - The type of the record to create
      Throws:
      TdbException - If assignment cannot be performed
    • getGraphRecordType

      public TdbGraphRecordType getGraphRecordType()
      Returns the type of the graph record
    • setName

      public void setName(String name) throws TdbException
      Assigns the name of the record.

      For an edge this is the name of the relation. For a vertex, this is a label that can is used to identify the vertex in illustrations, etc.

      Parameters:
      name - Name of edge or label of vertex
      Throws:
      TdbException - If assignment cannot be performed
    • getName

      public String getName() throws TdbException
      Returns the name of the graph record.

      For an edge this is the name of the relation. For a vertex, this is a label that can is used to identify the vertex in illustrations, etc.

      Throws:
      TdbException - If the value could not be retrieved
    • setReference

      public void setReference(TdbRecord rec) throws TdbException
      Set a reference to a pre-existing record.

      This assignment is only valid for vertex records. The referenced record can contain additional data about the vertex.

      Parameters:
      rec - Record to associate with the vertex record.
      Throws:
      TdbException - If assignment fails
    • setReference

      public void setReference(String databaseName, int recordId, String recordName) throws TdbException
      Set a reference to a pre-existing record.

      This assignment is only valid for vertex records. The referenced record can contain additional data about the vertex.

      Parameters:
      databaseName - Database in which the record is stored
      recordId - ID of the record
      recordName - Record name of record (pass null if none or not known)
      Throws:
      TdbException - If assignment fails
    • getReferenceRecordId

      public int getReferenceRecordId() throws TdbException
      Returns the record ID of the record referenced from this graph record.

      Only vertex records may contain a reference to another record.

      Returns:
      Record ID or 0 (zero) if no reference exists.
      Throws:
      TdbException - If the value could not be retrieved
    • getReferenceDatabase

      public String getReferenceDatabase() throws TdbException
      Returns the database name for the record referenced from this graph record.

      Only vertex records may contain a reference to another record.

      Returns:
      Database name or null if no reference exists.
      Throws:
      TdbException - If the value could not be retrieved
    • setWeight

      public void setWeight(double weight) throws TdbException
      Set the weight value for an edge record.
      Parameters:
      weight - Weight to set.
      Throws:
      TdbException - If the assignment fails
    • getWeight

      public double getWeight() throws TdbException
      Returns the weight value for an edge record.
      Throws:
      TdbException - If the record is not a graph edge
    • setSourceRecord

      public void setSourceRecord(TdbRecord rec) throws TdbException
      Set the source record for a graph edge.
      Parameters:
      rec - The record to assign as source, must have been committed prior to assignment.
      Throws:
      TdbException
    • setSourceRecord

      public void setSourceRecord(int recordId, String recordName) throws TdbException
      Set the source record for a graph edge. The source record must be a existing vertex record in the same database to which the edge is to be added.
      Parameters:
      recordId - The ID of the record
      recordName - The record name of the record
      Throws:
      TdbException
    • setSourceRecord

      public void setSourceRecord(String databaseName, int recordId) throws TdbException
      Set the source record for a graph edge. The source record must be a existing TRIP record and must not be located in a graph database.
      Parameters:
      databaseName - The name of the database in which the record resides
      recordId - The ID of the record
      Throws:
      TdbException
    • getSourceRecordId

      public int getSourceRecordId() throws TdbException
      Returns the record ID of the record used as source vertex for this graph record.

      This property is only valid for edge records.

      Returns:
      Record ID or 0 (zero) if no source was registered for this edge.
      Throws:
      TdbException - If the value could not be retrieved
    • getSourceDatabase

      public String getSourceDatabase() throws TdbException
      Returns the database name for record used as source vertex for this graph record.

      This property is only valid for edge records.

      Returns:
      Database name or null if no source was registered for this edge.
      Throws:
      TdbException - If the value could not be retrieved
    • setTargetRecord

      public void setTargetRecord(TdbRecord rec) throws TdbException
      Set the target record for a graph edge.
      Parameters:
      rec - The record to assign as target, must have been committed prior to assignment.
      Throws:
      TdbException
    • setTargetRecord

      public void setTargetRecord(int recordId, String recordName) throws TdbException
      Set the target record for a graph edge. The target record must be a existing vertex record in the same database to which the edge is to be added.
      Parameters:
      recordId - The ID of the record
      recordName - The record name of the record
      Throws:
      TdbException
    • setTargetRecord

      public void setTargetRecord(String databaseName, int recordId) throws TdbException
      Set the target record for a graph edge. The target record must be a existing TRIP record and must not be located in a graph database.
      Parameters:
      databaseName - The name of the database in which the record resides
      recordId - The ID of the record
      Throws:
      TdbException
    • getTargetRecordId

      public int getTargetRecordId() throws TdbException
      Returns the record ID of the record used as target vertex for this graph record.

      This property is only valid for edge records.

      Returns:
      Record ID or 0 (zero) if no target was registered for this edge.
      Throws:
      TdbException - If the value could not be retrieved
    • getTargetDatabase

      public String getTargetDatabase() throws TdbException
      Returns the database name for record used as target vertex for this graph record.

      This property is only valid for edge records.

      Returns:
      Database name or null if no target was registered for this edge.
      Throws:
      TdbException - If the value could not be retrieved
    • setProperty

      public void setProperty(String name, String value) throws TdbException
      Assign a property to this graph record. If the property name already exists, the previous value will be overwritten. No duplicate property names will be added.
      Parameters:
      name - Name of property
      value - Value of property
      Throws:
      TdbException
    • removeProperty

      public void removeProperty(String name) throws TdbException
      Removes a named property from this graph record.
      Parameters:
      name - Name of property to remove
      Throws:
      TdbException
    • getProperty

      public String getProperty(String name) throws TdbException
      Retrieve the value for a property.
      Parameters:
      name - Name of property whose value to retrieve.
      Returns:
      Property value or null if not found
      Throws:
      TdbException
    • getPropertyCount

      public int getPropertyCount() throws TdbException
      Returns a count of the number of properties assigned to this graph database record.
      Throws:
      TdbException
    • getPropertyName

      public String getPropertyName(int index) throws TdbException
      Returns the name of the property at the specified index.
      Parameters:
      index - Zero-based index of property whose name to retrieve
      Returns:
      Property name or null if not found
      Throws:
      TdbException
    • getPropertyValue

      public String getPropertyValue(int index) throws TdbException
      Returns the value of the property at the specified index.
      Parameters:
      index - Zero-based index of property whose value to retrieve
      Returns:
      Property value or null if not found
      Throws:
      TdbException
    • addKeyword

      public void addKeyword(String keyword) throws TdbException
      Add a keyword to this graph record. If the keyword already exists, no action will be taken.
      Parameters:
      keyword - Keyword to add
      Throws:
      TdbException
    • getKeywords

      public List<String> getKeywords() throws TdbException
      Return a list of all keywords assigned to this graph record.
      Throws:
      TdbException
    • removeKeyword

      public void removeKeyword(String keyword) throws TdbException
      Remove a keyword from this graph record.
      Parameters:
      keyword - Keyword to remove
      Throws:
      TdbException
    • removeKeyword

      public void removeKeyword(int index) throws TdbException
      Remove a keyword from this graph record.
      Parameters:
      index - Zero based index of keyword to remove
      Throws:
      TdbException