org.gcube.contentmanagement.baselayer
Interface RelationshipAndPropertyManager

All Known Implementing Classes:
GenericJDBCDatabase

public interface RelationshipAndPropertyManager

Manager for relationships and properties.

Author:
michaelspringmann

Method Summary
 void addLinkContentLocation(java.lang.String oid, RawContentLocation location)
          Registers a location for the content of the information object
 void addReference(java.lang.String sourceoid, java.lang.String targetoid, java.lang.String role, java.lang.String secondaryRole, long position, java.lang.String propagationRule)
          Adds a new reference between two information objects.
 long countReferences(java.lang.String oid, boolean isSource, java.lang.String role, java.lang.String secondaryRole)
          Counts the references of an object
 java.lang.String createInfoObject(java.lang.String name, java.lang.String type, BasicStorageHints hints)
          Creates a new information object
 boolean existsInfoObject(java.lang.String oid)
          Checks, whether an information object with the given ID exists.
 boolean existsReference(java.lang.String sourceoid, java.lang.String targetoid, java.lang.String role, java.lang.String secondaryRole)
          Check if a reference exists
 BasicInfoObjectDescription getInfoObjectDescription(java.lang.String oid)
          Retrieves an existing information object with all available information
 BasicInfoObjectDescription getInfoObjectDescription(java.lang.String oid, boolean includeProperties, boolean includeReferences, boolean includeReferred)
          Retrieves an existing information object with some tuning parameters, to remove un-required information
 BasicPropertyDescription getProperty(java.lang.String oid, java.lang.String name)
          Retrieves a particular property of an information object
 BasicReferenceDescription getReference(java.lang.String sourceoid, java.lang.String targetoid)
          Retrieves a single references which point from this source object to the target object.
 boolean hasProperty(java.lang.String oid, java.lang.String name)
          Returns whether an information object has a particular property set
 boolean hasRawContent(java.lang.String oid)
          Returns whether there exists raw content associated with an information object
 boolean removeAllRawContentOf(java.lang.String oid, BasicStorageHints hints)
          Unregisters all locations for the content of the information object and deletes the content physically.
 boolean removeInfoObject(java.lang.String oid)
          Deletes an information object.
 boolean removeLinkContentLocation(RawContentLocation location)
          Unregisters a location for the content of the information object
 boolean removeReference(java.lang.String sourceoid, java.lang.String targetoid, java.lang.String role, java.lang.String secondaryRole)
          Deletes any reference with having the given parameters.
CAUTION: This propagates deletion events as defined in the propagation rule of the reference.
 java.util.List<RawContentLocation> retrieveObjectContentLocations(java.lang.String oid)
          Retrieves all locations where the content can be accessed
 java.util.Map<java.lang.String,BasicPropertyDescription> retrieveObjectProperties(java.lang.String oid)
          Retrieves all properties of an information object
 java.util.List<java.lang.String> retrieveOIDByProperty(java.lang.String name, java.lang.String value)
          Retrieves all object IDs of information object for which a particular property value has been set
 java.util.List<BasicReferenceDescription> retrieveReferences(java.lang.String sourceoid, java.lang.String role, java.lang.String secondaryRole)
          Retrieves all references which point from this source object to some other object.
 java.util.List<BasicReferenceDescription> retrieveReferencesOrderedByPosition(java.lang.String sourceoid, java.lang.String role, java.lang.String secondaryRole)
          Retrieves all references which point from this source object and order those based on the position.
 java.util.List<BasicReferenceDescription> retrieveReferred(java.lang.String targetoid, java.lang.String role, java.lang.String secondaryRole)
          Retrieves all references which point to this target object.
 java.util.List<java.lang.String> retrieveReferredSourceOIDs(java.lang.String targetoid, java.lang.String role, java.lang.String secondaryRole)
          Retrieves all object OIDs of information object, which have a reference to this target object.
 java.util.List<java.lang.String> retrieveReferredTargetOIDs(java.lang.String sourceoid, java.lang.String role, java.lang.String secondaryRole)
          Retrieves all object OIDs of information object, which have a reference from this source object.
 void setProperty(java.lang.String oid, java.lang.String name, java.lang.String type, java.lang.String value)
          Sets the storage property of a given name for a particular information object.
 boolean unsetProperty(java.lang.String oid, java.lang.String name)
          Removes a property (or all properties) of an information object
 void updateLinkContentLocations(java.lang.String oid, RawContentLocation newestLocation)
          Updates the locations for the content of the information object
 

Method Detail

createInfoObject

java.lang.String createInfoObject(java.lang.String name,
                                  java.lang.String type,
                                  BasicStorageHints hints)
                                  throws BaseLayerException
Creates a new information object

Parameters:
name - a human readable name (does not need to be unique, can also be null)
type - the type of the information object
hints - hints that should be taken into account, e.g. BasicStorageHints#HINT_NAME_PREDEFINED_ID.
Returns:
the object ID of the new information object
Throws:
BaseLayerException - if something goes wrong

getInfoObjectDescription

BasicInfoObjectDescription getInfoObjectDescription(java.lang.String oid)
                                                    throws BaseLayerException
Retrieves an existing information object with all available information

Parameters:
oid - the object ID of the object
Returns:
the description
Throws:
BaseLayerException - if something goes wrong

existsInfoObject

boolean existsInfoObject(java.lang.String oid)
                         throws BaseLayerException
Checks, whether an information object with the given ID exists. Since the ID is supposed to be UUID, the main purpose is to ensure that some other operation, e.g. removal of an object finished correctly.

Parameters:
oid - the object ID of the object
Returns:
true, if object exists; false otherwise.
Throws:
BaseLayerException - if something goes wrong

getInfoObjectDescription

BasicInfoObjectDescription getInfoObjectDescription(java.lang.String oid,
                                                    boolean includeProperties,
                                                    boolean includeReferences,
                                                    boolean includeReferred)
                                                    throws BaseLayerException
Retrieves an existing information object with some tuning parameters, to remove un-required information

Parameters:
oid - the object ID of the object
includeProperties - if set to true, properties will be retrieved; otherwise properties will not be retrieved
includeReferences - if set to true, references to other info objects will be retrieved; otherwise references will not be retrieved
includeReferred - if set to true, references from other info objects will be retrieved; otherwise those references will not be retrieved
Returns:
the description
Throws:
BaseLayerException - if something goes wrong

removeInfoObject

boolean removeInfoObject(java.lang.String oid)
                         throws BaseLayerException
Deletes an information object. This will trigger propagation of deletions if corresponding relations exist.

Parameters:
oid - the object ID of the object that should be deleted
Returns:
true, if object has been deleted successfully; false if the object did not exist and therefore the operation had no effect.
Throws:
BaseLayerException - if something goes wrong

addReference

void addReference(java.lang.String sourceoid,
                  java.lang.String targetoid,
                  java.lang.String role,
                  java.lang.String secondaryRole,
                  long position,
                  java.lang.String propagationRule)
                  throws BaseLayerException
Adds a new reference between two information objects. A reference is always directed and can define propagation rules for deletion of items.

Parameters:
sourceoid - the object ID of the starting information object of the relation
targetoid - the object Id of the referenced information object
role - the role of the information object (sourceoid) with respect to this reference
secondaryRole - similar to role, but for the secondary role used by Metadata Catalog
position - an attribute to allow for position preserving representation, set to ReferenceDescription.UNDEFINED_POSITION if not in use.
propagationRule - rule for propagation of deletion.
Throws:
BaseLayerException - if something goes wrong
See Also:
org.gcube.contentmanagement.layerindependent.descriptions.BasicReferenceDescription

removeReference

boolean removeReference(java.lang.String sourceoid,
                        java.lang.String targetoid,
                        java.lang.String role,
                        java.lang.String secondaryRole)
                        throws BaseLayerException
Deletes any reference with having the given parameters.
CAUTION: This propagates deletion events as defined in the propagation rule of the reference.

Parameters:
sourceoid - the object ID of the starting information object of the relation
targetoid - the object Id of the referenced information object
role - the role of the information object (sourceoid) with respect this reference. Can be set to ReferenceDescription.ANY_ROLE to match all possible values of role.
secondaryRole - similar to role, but for the secondary role used by Metadata Catalog
Returns:
true, if reference has been deleted successfully; false if no such reference existed and therefore the operation had no effect.
Throws:
BaseLayerException - if something goes wrong

getReference

BasicReferenceDescription getReference(java.lang.String sourceoid,
                                       java.lang.String targetoid)
                                       throws BaseLayerException
Retrieves a single references which point from this source object to the target object.

Parameters:
sourceoid - the object ID of the starting information object of the relation
targetoid - the object Id of the referenced information object
Returns:
the BasicReferenceDescription
Throws:
BaseLayerException - if something goes wrong

existsReference

boolean existsReference(java.lang.String sourceoid,
                        java.lang.String targetoid,
                        java.lang.String role,
                        java.lang.String secondaryRole)
                        throws BaseLayerException
Check if a reference exists

Parameters:
sourceoid - the object ID of the starting information object of the relation
targetoid - the object Id of the referenced information object
role - the role of the information object (sourceoid) with respect to this reference
secondaryRole - similar to role, but for the secondary role used by Metadata Catalog
Returns:
true if the reference has been found, false otherwise.
Throws:
BaseLayerException - if something goes wrong
See Also:
org.gcube.contentmanagement.layerindependent.descriptions.BasicReferenceDescription

retrieveReferences

java.util.List<BasicReferenceDescription> retrieveReferences(java.lang.String sourceoid,
                                                             java.lang.String role,
                                                             java.lang.String secondaryRole)
                                                             throws BaseLayerException
Retrieves all references which point from this source object to some other object.

Parameters:
sourceoid - the object ID of the starting information object of the relation
role - the role of the information object (sourceoid) with respect this reference. Can be set to BasicReferenceDescription.ANY_ROLE to match all possible values of role.
secondaryRole - similar to role, but for the secondary role used by Metadata Catalog
refDescriptions - a collection to which elements of type BasicReferenceDescription will be added
Throws:
BaseLayerException - if something goes wrong

retrieveReferencesOrderedByPosition

java.util.List<BasicReferenceDescription> retrieveReferencesOrderedByPosition(java.lang.String sourceoid,
                                                                              java.lang.String role,
                                                                              java.lang.String secondaryRole)
                                                                              throws BaseLayerException
Retrieves all references which point from this source object and order those based on the position.

Parameters:
sourceoid - the object ID of the starting information object of the relation
role - the role of the information object (sourceoid) with respect this reference. Can be set to BasicReferenceDescription.ANY_ROLE to match all possible values of role.
secondaryRole - similar to role, but for the secondary role used by Metadata Catalog
Returns:
the retrieved references list
Throws:
BaseLayerException - if something goes wrong

countReferences

long countReferences(java.lang.String oid,
                     boolean isSource,
                     java.lang.String role,
                     java.lang.String secondaryRole)
                     throws BaseLayerException
Counts the references of an object

Parameters:
oid - the oid of the known object
isSource - true, if oid is the object ID of the source object, false if oid is the target oid
role - the role, or ReferenceDescription.ANY_ROLE
secondaryRole - similar to role, but for the secondary role used by Metadata Catalog
Returns:
the number of references that the object has
Throws:
BaseLayerException - if something goes wrong

retrieveReferredSourceOIDs

java.util.List<java.lang.String> retrieveReferredSourceOIDs(java.lang.String targetoid,
                                                            java.lang.String role,
                                                            java.lang.String secondaryRole)
                                                            throws BaseLayerException
Retrieves all object OIDs of information object, which have a reference to this target object.

Parameters:
targetoid - the object Id of the referenced information object
role - the role of the information object (sourceoid) with respect this reference. Can be set to BasicReferenceDescription.ANY_ROLE to match all possible values of role.
secondaryRole - similar to role, but for the secondary role used by Metadata Catalog
Returns:
the OID list.
Throws:
BaseLayerException - if something goes wrong

retrieveReferredTargetOIDs

java.util.List<java.lang.String> retrieveReferredTargetOIDs(java.lang.String sourceoid,
                                                            java.lang.String role,
                                                            java.lang.String secondaryRole)
                                                            throws BaseLayerException
Retrieves all object OIDs of information object, which have a reference from this source object.

Parameters:
sourceoid - the object Id of the referenced information object
role - the role of the information object (sourceoid) with respect this reference. Can be set to BasicReferenceDescription.ANY_ROLE to match all possible values of role.
secondaryRole - similar to role, but for the secondary role used by Metadata Catalog
Returns:
the oid list.
Throws:
BaseLayerException - if something goes wrong

retrieveReferred

java.util.List<BasicReferenceDescription> retrieveReferred(java.lang.String targetoid,
                                                           java.lang.String role,
                                                           java.lang.String secondaryRole)
                                                           throws BaseLayerException
Retrieves all references which point to this target object.

Parameters:
targetoid - the object Id of the referenced information object
role - the role of the information object (sourceoid) with respect this reference. Can be set to BasicReferenceDescription.ANY_ROLE to match all possible values of role.
secondaryRole - similar to role, but for the secondary role used by Metadata Catalog
Returns:
a list of elements of type BasicReferenceDescription
Throws:
BaseLayerException - if something goes wrong

setProperty

void setProperty(java.lang.String oid,
                 java.lang.String name,
                 java.lang.String type,
                 java.lang.String value)
                 throws BaseLayerException
Sets the storage property of a given name for a particular information object.

If this property already exists, it will be updated. If not, it will be added with the given values.

Parameters:
oid - the object ID of the information object
name - the name of the property (use prefixes, e.g. namespace prefixes to disambiguate)
type - the type of the value of this property
value - the value of the property
Throws:
BaseLayerException - if something goes wrong

unsetProperty

boolean unsetProperty(java.lang.String oid,
                      java.lang.String name)
                      throws BaseLayerException
Removes a property (or all properties) of an information object

Parameters:
oid - the object ID of the information object
name - the name of the property, or PropertyDescription.ANY_NAME for all
Returns:
false, If the object didn't have such a property; otherwise true
Throws:
BaseLayerException - if something goes wrong

getProperty

BasicPropertyDescription getProperty(java.lang.String oid,
                                     java.lang.String name)
                                     throws BaseLayerException
Retrieves a particular property of an information object

Parameters:
oid - the object ID of the information object
name - the name of the property
Returns:
a PropertyDescription of the defined property
Throws:
ObjectNotFoundException - if either the OID is invalid or there is no property with this name defined for this information object
BaseLayerException - if something goes wrong

hasProperty

boolean hasProperty(java.lang.String oid,
                    java.lang.String name)
                    throws BaseLayerException
Returns whether an information object has a particular property set

Parameters:
oid - the object ID of the information object
name - the name of the property
Returns:
true, if the property is set
Throws:
ObjectNotFoundException - if the OID is invalid
BaseLayerException - if something goes wrong

retrieveObjectProperties

java.util.Map<java.lang.String,BasicPropertyDescription> retrieveObjectProperties(java.lang.String oid)
                                                                                  throws BaseLayerException
Retrieves all properties of an information object

Parameters:
oid - the object ID of the information object
Returns:
the retrieved properties in a map, to which the PropertyDescription will be added, key is the name of the property
Throws:
BaseLayerException - if something goes wrong

retrieveOIDByProperty

java.util.List<java.lang.String> retrieveOIDByProperty(java.lang.String name,
                                                       java.lang.String value)
                                                       throws BaseLayerException
Retrieves all object IDs of information object for which a particular property value has been set

Parameters:
name - the name of the property
value - the value of the property
oids - a collection to which elements of type String will be added
Throws:
BaseLayerException - if something goes wrong

addLinkContentLocation

void addLinkContentLocation(java.lang.String oid,
                            RawContentLocation location)
                            throws BaseLayerException
Registers a location for the content of the information object

Parameters:
oid - the object ID of the information object
location - the location where the content resides
Throws:
BaseLayerException - if something goes wrong

removeLinkContentLocation

boolean removeLinkContentLocation(RawContentLocation location)
                                  throws BaseLayerException
Unregisters a location for the content of the information object

Parameters:
location - the location where the content no longer resides
Returns:
true, if location has been deleted successfully; false if the location did not exist and therefore the operation had no effect.
Throws:
BaseLayerException - if something goes wrong

removeAllRawContentOf

boolean removeAllRawContentOf(java.lang.String oid,
                              BasicStorageHints hints)
                              throws BaseLayerException
Unregisters all locations for the content of the information object and deletes the content physically.

Parameters:
oid - the object ID of the object who's raw content should be deleted
Returns:
true, if raw content of object has been deleted successfully; false if the object did not have any raw content and therefore the operation had no effect.
Throws:
BaseLayerException - if something goes wrong

retrieveObjectContentLocations

java.util.List<RawContentLocation> retrieveObjectContentLocations(java.lang.String oid)
                                                                  throws BaseLayerException
Retrieves all locations where the content can be accessed

Parameters:
oid - the object ID of the information object
Returns:
a list of RawContentLocation
Throws:
BaseLayerException - if something goes wrong

updateLinkContentLocations

void updateLinkContentLocations(java.lang.String oid,
                                RawContentLocation newestLocation)
                                throws BaseLayerException
Updates the locations for the content of the information object

Parameters:
oid - the object ID of the information object
newestLocation - the location where most recent version of the content resides
Throws:
BaseLayerException - if something goes wrong

hasRawContent

boolean hasRawContent(java.lang.String oid)
                      throws BaseLayerException
Returns whether there exists raw content associated with an information object

Parameters:
oid - the object ID of the information object
Returns:
true, if there is raw content; false otherwise
Throws:
BaseLayerException - if something goes wrong