Interface IDataService
-
Field Summary
-
Method Summary
Modifier and TypeMethodDescriptionAdapts the givenIPObject
to the instance of the given target class.void
Clear all object and document caches in the system.void
clearCaches
(String nodeId) For a given node in a cluster, clear all object and document caches in the system.void
clearCaches
(Collection<SubterraURI> uris) For given uris, clear all object and document caches in the system.void
clearCaches
(Collection<SubterraURI> uris, boolean globalOnly) For given uris, clear all object and document caches in the system.createCollectionForKey
(IPObject pobject, String key, List data) Creates an instance of a collection object, corresponding to the model definition.createCollectionForTypeId
(IPObject pobject, String listTypeId, List data) Creates the instance of the list object, that corresponds to the model definition.createInstance
(String prototypeName) Creates the new instance of the given prototype.createStructureForKey
(IPObject pobject, String key, Map data) Creates the instance of the structure object, that corresponds to the model definition.createStructureForTypeId
(IPObject pobject, String structureId, Map data) Creates the instance of a structure object, that corresponds to the model definition.void
void
delete
(IPObjectList instances) <T> T
doInBaseline
(String baselineRevision, RunnableWEx<T> r) Executes code in the given runnable, inside the baseline context.<T> T
doOutsideBaseline
(RunnableWEx<T> r) Returns a set of constant enumeration IDs.getEnumerationForEnumId
(IEnumType type, IContextId contextId) Returns the enumeration for a given enumeration type.getEnumerationForKey
(String prototypeName, String key, IContextId contextId) Returns the instance of the enum factory, that handles the enumeration for a given key.Returns a map of all enumeration object factoriesgetInstance
(IObjectId id) Returns an instance of the correct type for the object id.getInstance
(SubterraURI uri) Returns an instance of the correct type for the given URI.getInstances
(List<SubterraURI> uris) int
getInstancesCount
(IPrototype proto, String query) Returns the instances count for a query.int
getInstancesCount
(String proto, String query) Returns the count of instances for a query.int
getInstancesCountInBaseline
(String index, String query, String revision) Searches the count of objects in the given index from a given revision.This method should be used instead ofIRepositoryReadOnlyConnection.getCurrentRepositoryState()
in use cases related to the model objects (i.e.getObjectEnumerationForEnumId
(IEnumType type, IContextId contextId) Returns the instance of the object enum factory, that handles the enumeration with a given ID.getObjectEnumerationForKey
(String prototypeName, String key, IContextId contextId) Returns the instance of the object enum factory, that handles the enumeration for a given key.getObjectFromEnumOption
(IEnumOption enumOption) Returns the IPObject instance from the given IEnumOption if it exists.<T extends IPObject>
IPObjectList<T>getObjectHistory
(T object) Returns the whole history of the a given object, in the form of its versioned objects.Reverse method togetSubterraURIForObjectId(IObjectId)
getPreviousStorageRevision
(String revision) This method should be used instead ofIRepositoryReadOnlyConnection.getPreviousState(String)
in use cases related to the model objects (i.e.getPrototype
(String name) This is a shortcut for calling the prototype service.Returns the prototype that the uri of the given object belongs to.getRevision
(IContextId contextId, String revisionId) Same asgetRevision(String, String)
, but the repository name is determined from the context.getRevision
(String repositoryName, String revisionId) Same asgetRevision(IContextId, String)
, but the revision.Shortcut method to get the platform security service.getStorageRevisionAt
(Date timePoint) This method should be used instead ofIRepositoryReadOnlyConnection.getRepositoryState(Date)
in use cases related to the model objects (i.e.Return SubterraURI for given object id.Class[]
getSupportedTargetClasses
(String protoName) Even if the adaptation is possible for the given prototype in general, it can still be impossible for a particular instance.getValidRevisionInBaseline
(String revision) getVersionedInstance
(IObjectId objectId, String revision) Returns a versioned object for the given uri and revision.getVersionedInstance
(SubterraURI uri, String revision) Returns a versioned object for the given uri and revision.boolean
Test if a given string is a valid ID (primary key) for the PObject.void
objectsChanged
(Collection uris) Causes the objects with the given uris being refreshed in the cache and index.void
refreshEnumerations
(IContextId contextId) Refreshes enumerations (stored in the database) in a given project.void
Resolves theIPObject
with data from the server.void
resolve
(IPObjectList instances) A more efficient way for resolving more objects at once, than to resolve each one individually.void
void
save
(IPObjectList instances) Only the instances withIPObject.isModified()
== true are saved.search()
Returns an instance ofIObjectsSearch
that allows for the search and count of the persistent objects in various secondary data sources.searchInstances
(IPrototype proto, String query, String sort) Searches for objects of the given type matching the query.searchInstances
(IPrototype proto, String query, String sort, int resultLimit) Searches for objects of the given type matching the query.searchInstances
(String index, String query, String sort) Searches the objects in the given index.searchInstances
(String index, String query, String sort, int resultLimit) Searches the objects in the given index.searchInstancesInBaseline
(String index, String query, String sort, int resultLimit, String revision) Searches the objects in the given index from a given revision.searchInstancesInBaseline
(String index, String query, String sort, String revision) Searches the objects in the given index from a given revision.<T extends IPObject>
IPObjectList<T>Searches the persistent objects by executing the specified SQL-query in the database for the current revision.<T extends IPObject>
IPObjectList<T>sqlSearchInBaseline
(String sqlQuery, String revision) Searches the persistent objects by executing the specified SQL-query in the database for the specified revision.
-
Field Details
-
ID_INVALID_CHARS
- See Also:
-
-
Method Details
-
isValidId
Test if a given string is a valid ID (primary key) for the PObject. Must not have leading or trailing white spaces or containID_INVALID_CHARS
characters.- Parameters:
id
-- Returns:
- true if the ID is valid.
-
getPrototype
This is a shortcut for calling the prototype service.- Parameters:
name
-- Returns:
- the
IPrototype
with the specifiedname
,null
if no such prototype exists. - See Also:
-
getCustomFieldsService
ICustomFieldsService getCustomFieldsService()- Returns:
- The custom features service used by this data service. Not null.
-
getCalculatedFieldsService
ICalculatedFieldsService getCalculatedFieldsService()- Returns:
- the derived fields service, not
null
- Since:
- 3.3.0
-
getObjectHierarchyProvider
IObjectHierarchyProvider getObjectHierarchyProvider()- Returns:
- the object hierarchy provider, not
null
- Since:
- 3.3.0
-
getQueryHelper
IQueryHelper getQueryHelper()- Returns:
- Returns the tool for manipulating queries (e.g. composing complex ones from simple ones).
-
getEventManager
IEventManager getEventManager()- Returns:
- The event manager instance, where it's possible to listen to events on objects stored in the persistence.
-
searchInstances
Searches for objects of the given type matching the query. A shortcut forsearchInstances(proto.getName(), query, sort);
Note: In general, the searching does not preserve inheritance. In other words, if
Proto2 extends Proto1
, then searching forProto1
does not return the instances ofProto2
.- Parameters:
proto
-query
-sort
- The format is same as forIIndexSearch.sort(String)
.- Returns:
- a
IPObjectList
containing the result of the query.
-
searchInstances
Searches for objects of the given type matching the query. A shortcut forsearchInstances(proto.getName(), query, sort, resultLimit);
Note: In general, the searching does not preserve inheritance. In other words, if
Proto2 extends Proto1
, then searching forProto1
does not return the instances ofProto2
.- Parameters:
proto
-query
-sort
- The format is same as forIIndexSearch.sort(String)
.resultLimit
- The maximum size of the returned list. A negative number means it's unlimited.- Returns:
- a
IPObjectList
containing the result of the query.
-
searchInstances
Searches the objects in the given index. In a typical case, the index name corresponds to the prototype name, however, there can be some additional indices defined, that don't correspond to a particular prototype.- Parameters:
index
-query
-sort
- The format is same as forIIndexSearch.sort(String)
.- Returns:
- a
IPObjectList
containing the result of the query
-
searchInstancesInBaseline
Searches the objects in the given index from a given revision. In a typical case, the index name corresponds to the prototype name, however, there can be some additional indices defined, that don't correspond to a particular prototype.- Parameters:
index
-query
-sort
- The format is same as forIIndexSearch.sort(String)
revision
-- Returns:
- a
IPObjectList
containing the result of the query - Since:
- 3.6.0
-
searchInstances
Searches the objects in the given index. Only firstresultLimit
items are returned if there are more objects found.In a typical case, the index name corresponds to the prototype name, however, there can be some additional indices defined, that don't correspond to a particular prototype.
- Parameters:
index
-query
-sort
- The format is same as forIIndexSearch.sort(String)
.resultLimit
- maximal size of returned list, negative number means no limit- Returns:
- a
IPObjectList
containing the result of the query
-
searchInstancesInBaseline
IPObjectList searchInstancesInBaseline(String index, String query, String sort, int resultLimit, String revision) Searches the objects in the given index from a given revision. Only firstresultLimit
items are returned if there are more objects found.In a typical case, the index name corresponds to the prototype name, however, there can be some additional indices defined, that don't correspond to a particular prototype.
- Parameters:
index
-query
-sort
- The format is same as forIIndexSearch.sort(String)
.resultLimit
- The maximum size of the returned list. A negative number means it's unlimited.revision
- baseline revision, ornull
not to search in a baseline.- Returns:
- a
IPObjectList
containing the result of the query. - Since:
- 3.6.0
-
sqlSearch
Searches the persistent objects by executing the specified SQL-query in the database for the current revision.You can also use
search()
.database()
.instances(String)
for the same purpose. SQL searches should only be used for advanced querying/counting when joins and the other SQL-capabilities, that cannot be achieved using Lucene queries, are needed. In other cases theIDataService
's search/count methods that work with Lucene queries are preferred. For example,searchInstances(String, String, String)
,getInstancesCount(String, String)
, etc.- Parameters:
sqlQuery
-- Returns:
- a
IPObjectList
containing the objects found as a result of the query execution. - Since:
- 3.6.0
-
sqlSearchInBaseline
@NotNull <T extends IPObject> IPObjectList<T> sqlSearchInBaseline(@NotNull String sqlQuery, @Nullable String revision) Searches the persistent objects by executing the specified SQL-query in the database for the specified revision. *You can also use
search()
.database()
.instancesInBaseline(String, String)
for the same purpose. SQL searches should only be used for advanced querying/counting when joins and the other SQL-capabilities, that cannot be achieved using Lucene queries, are needed. In other cases theIDataService
's search/count methods that work with Lucene queries are preferred. For example,searchInstances(String, String, String)
,getInstancesCount(String, String)
, etc.- Parameters:
sqlQuery
-revision
- A Baseline revision in which to search. Ifnull
, search in the current revision.- Returns:
- a
IPObjectList
containing the objects found as a result of the query execution. - Since:
- 3.6.1
-
search
Returns an instance ofIObjectsSearch
that allows for the search and count of the persistent objects in various secondary data sources.- Returns:
- An instance of
IObjectsSearch
. - Since:
- 3.19.3
-
getInstancesCount
Returns the count of instances for a query.- Parameters:
proto
-query
-- Returns:
- the number instances with a specified prototype for the query.
- See Also:
-
getInstancesCount
Returns the instances count for a query.- Parameters:
proto
-query
-- Returns:
- the number instances for the query.
- See Also:
-
getInstance
Returns an instance of the correct type for the given URI. The object is unresolved and it is not guaranteed that it exists.- Parameters:
uri
- The URI of an object. Can't be anull
- Returns:
- the IPObject implementing the model-specific interface (if registered)
or just a generic
IPObject
if none is specified
-
getInstance
Returns an instance of the correct type for the object id.- Parameters:
id
- - ObjectId of a retrieved object. Can't be anull
- Returns:
- The IPObject implementing the model-specific interface (if registered)
or just a generic
IPObject
if none is specified.
-
getInstances
- Parameters:
uris
- The list ofSubterraURI
s- Returns:
- The list with these objects. The objects in the list are not resolved. This operation does not contact the back-end.
-
createInstance
Creates the new instance of the given prototype. The object is not yet persistent and an attempt to read its ID or to link it to other objects (e.g.otherObject.setXXX(created)
will result in an exception. Performing the save operation on the object will create the object persistently and makes its ID readable.- Parameters:
prototypeName
-- Returns:
- a new
IPObject
instance for the givenprototypeName
- Throws:
ReadOnlyException
- If the prototype is read only.- See Also:
-
save
- Throws:
ReadOnlyException
-
save
Only the instances withIPObject.isModified()
== true are saved. Instances that are not resolved are ignored. Instances, that did not exist before, are created.- Parameters:
instances
-- Throws:
ReadOnlyException
-
resolve
Resolves theIPObject
with data from the server. If the object is already resolved, it does nothing.- Parameters:
instance
-
-
resolve
A more efficient way for resolving more objects at once, than to resolve each one individually.- Parameters:
instances
- List ofIPObject
-
delete
- Throws:
ReadOnlyException
-
delete
- Throws:
ReadOnlyException
-
createCollectionForKey
Creates an instance of a collection object, corresponding to the model definition. Use the dot notation, if the collection is under another structure or collection (e.g. mystructure.substructure).- Parameters:
pobject
- object (notnull
)key
-data
- This is the low-level data, that will be wrapped by the structure. An emptyArrayList
should be passed in when the low level data is not available.- Returns:
- the
ITypedList
instance created for the specifiedkey
- Since:
- 3.1.2
- See Also:
-
createCollectionForTypeId
Creates the instance of the list object, that corresponds to the model definition.- Parameters:
pobject
- object (notnull
)listTypeId
-data
-- Returns:
- the
ITypedList
instance created for the specifiedlistTypeId
- Since:
- 3.1.2
-
createStructureForKey
Creates the instance of the structure object, that corresponds to the model definition. Use the dot notation, if the structure is under another structure or collection (e.g. mystructure.substructure).- Parameters:
pobject
- object (notnull
)key
-data
- This is low-level data, that will be wrapped by the structure. An emptyHashMap
should be passed on when the low level data is not available.- Returns:
- the
IStructure
instance created for the specifiedkey
- Since:
- 3.1.2
- See Also:
-
createStructureForTypeId
Creates the instance of a structure object, that corresponds to the model definition.- Parameters:
pobject
- object (notnull
)structureId
-data
-- Returns:
- the
IStructure
instance created for the specifiedstructureId
- Since:
- 3.1.2
-
getEnumerationForKey
Returns the instance of the enum factory, that handles the enumeration for a given key.Use the dot notation, if the enum is under a structure or collection (e.g. mystructure.substructure).
This is a shortcut for determining the enum ID and then calling
getEnumerationForEnumId(IEnumType, IContextId)
- Parameters:
key
-prototypeName
-- Returns:
- the
IEnumeration
instance created for the specifiedkey
- See Also:
-
getObjectEnumerationForKey
IObjectEnumeration getObjectEnumerationForKey(String prototypeName, String key, IContextId contextId) Returns the instance of the object enum factory, that handles the enumeration for a given key.Use the dot notation, if the enum is under a structure or collection (e.g. mystructure.substructure).
This is a shortcut for determining the enum ID and then calling
getObjectEnumerationForEnumId(IEnumType, IContextId)
- Parameters:
key
-prototypeName
-- Returns:
- the
IObjectEnumeration
instance created for the specifiedkey
- Since:
- 3.6.3
- See Also:
-
getEnumerationForEnumId
@NotNull IEnumeration getEnumerationForEnumId(@NotNull IEnumType type, @NotNull IContextId contextId) Returns the enumeration for a given enumeration type. -
getObjectEnumerationForEnumId
Returns the instance of the object enum factory, that handles the enumeration with a given ID.- Parameters:
type
-contextId
- - context for factory- Returns:
- the
IObjectEnumeration
instance created for the specifiedenumId
- Since:
- 3.6.3
-
getEnumerationObjectFactories
Map<String,IEnumObjectFactory> getEnumerationObjectFactories()Returns a map of all enumeration object factories- Since:
- 3.6.3
-
getConstantEnumerationIds
Returns a set of constant enumeration IDs. It does NOT contain enumerations that can be modified in Administration.- Since:
- 3.9.0
-
getObjectFromEnumOption
Returns the IPObject instance from the given IEnumOption if it exists.- Returns:
- the
IPObject
instance returned for the givenenumOption
- Since:
- 3.6.3
-
getObjectHistory
Returns the whole history of the a given object, in the form of its versioned objects. The objects in the returned collection are not resolved and the client should be able to handle the situation, when not all objects in the history are resolvable.The history list is sorted from the oldest (first) to the newest (last).
An empty list is returned if the object does not support history retrieval.
- Parameters:
object
-- Returns:
- a
IPObjectList
containing all versions of the specifiedIPObject
- See Also:
-
getVersionedInstance
Returns a versioned object for the given uri and revision.The object may be unresolvable.
- Parameters:
uri
- The URI of a object. Cannot benull
.revision
- Ifnull
, then the object without a specific revision will be returned.- Returns:
- The versioned IPObject implementing the model-specific interface (if
registered) or just a generic
IPObject
if none is specified.
-
getVersionedInstance
Returns a versioned object for the given uri and revision.The object may be unresolvable.
- Parameters:
objectId
- IObjectId of a object. Ifnull
, then an instance without a version will be returned (even if the source objectId has a revision).revision
- Ifnull
, then an object without a specific revision will be returned.- Returns:
- The versioned IPObject implementing the model-specific interface (if
registered) or just a generic
IPObject
if none is specified.
-
getPrototypeFromObjectURI
Returns the prototype that the uri of the given object belongs to. For example if its a passed uri of some work item, then it returns the WorkItem prototype.- Parameters:
uri
-- Returns:
- the
IPrototype
of the object at the specifieduri
-
getSubterraURIForObjectId
Return SubterraURI for given object id. Reverse method togetObjectIdForSubterraURI(SubterraURI)
- Parameters:
id
- object id- Returns:
- SubterraURI
- Throws:
IllegalArgumentException
- if id is null
-
getObjectIdForSubterraURI
Reverse method togetSubterraURIForObjectId(IObjectId)
- Parameters:
uri
-- Returns:
- the
IObjectId
for the passeduri
-
adapt
Adapts the givenIPObject
to the instance of the given target class. Returnsnull
if such an adaptation is not supported.- Parameters:
adaptable
-targetClass
-- Returns:
adaptable
adapted to be an instance oftargetClass
-
getSupportedTargetClasses
Even if the adaptation is possible for the given prototype in general, it can still be impossible for a particular instance.- Parameters:
protoName
-- Returns:
- An array of types that the instances of the given prototype can be adapted for.
- See Also:
-
getDiffManager
IDiffManager getDiffManager() -
getPersistencePolicy
IPersistencePolicy getPersistencePolicy() -
getSecurityService
ISecurityService getSecurityService()Shortcut method to get the platform security service.- Returns:
- the platform security service.
-
getRevision
Same asgetRevision(String, String)
, but the repository name is determined from the context. -
getRevision
Same asgetRevision(IContextId, String)
, but the revision.- Parameters:
repositoryName
- The repository that the revision comes from (must NOT benull
).revisionId
- The revision ID (must NOT benull
)..- Returns:
- The unresolved IRevision with a given ID. The operation is
performed only with the IDs, so it is not guaranteed that such a
revision actually exists and will be resolvable. Never returns
null
.
-
getLastStorageRevision
This method should be used instead ofIRepositoryReadOnlyConnection.getCurrentRepositoryState()
in use cases related to the model objects (i.e. the ones returned bygetInstance(IObjectId)
)- Returns:
- from the primary storage (i.e. the
IRepositoryService.DEFAULT
repository) of the model objects the last revision. Ignores the baseline set bydoInBaseline(String, RunnableWEx)
- Since:
- 3.19.2
-
getStorageRevisionAt
This method should be used instead ofIRepositoryReadOnlyConnection.getRepositoryState(Date)
in use cases related to the model objects (i.e. the ones returned bygetInstance(IObjectId)
)- Returns:
- from the primary storage of the model objects (i.e. the
IRepositoryService.DEFAULT
repository) the last revision that was created before or at the given time point. - Since:
- 3.19.2
-
getValidRevisionInBaseline
- Returns:
- the given revision if the
getCurrentBaselineRevision()
is null or higher than the given revision, otherwise returns thegetCurrentBaselineRevision()
, in both cases wrapped as anIRevision
. - Throws:
NumberFormatException
- when the given revision cannot be parsed as long number.- Since:
- 3.19.2
-
getPreviousStorageRevision
This method should be used instead ofIRepositoryReadOnlyConnection.getPreviousState(String)
in use cases related to the model objects (i.e. the ones returned bygetInstance(IObjectId)
)- Returns:
- from the primary storage (i.e. the
IRepositoryService.DEFAULT
repository) of the model objects the revision before the given one. Returns0
when the given one isnull
or lower than1
. - Throws:
NumberFormatException
- when the given revision cannot be parsed as long number.- Since:
- 3.19.2
-
objectsChanged
Causes the objects with the given uris being refreshed in the cache and index. This method is especially meant for derived fields providers, who should call this method whenever the derived fields change (because of external events) to notify persistence about this change.The clients should be aware, that the method is likely to take a long time (depending on the number of
uris
to process).- Parameters:
uris
-
-
clearCaches
void clearCaches()Clear all object and document caches in the system. (Works for the whole cluster in cluster setup.) -
clearCaches
For given uris, clear all object and document caches in the system.- Since:
- 3.2.0
-
clearCaches
For given uris, clear all object and document caches in the system.- Parameters:
globalOnly
- If true then only the global data object cache is cleared- Since:
- 3.7.0
-
clearCaches
For a given node in a cluster, clear all object and document caches in the system.- Parameters:
nodeId
- - The node ID of the node to clear its caches.- Since:
- 3.8.0
-
getExternalRepositoryProviderRegistry
IExternalRepositoryProviderRegistry getExternalRepositoryProviderRegistry()- Since:
- 3.5.1
-
doInBaseline
Executes code in the given runnable, inside the baseline context.- Parameters:
baselineRevision
- can not be null or an empty string.- Throws:
UserFriendlyRuntimeException
- if baselineRevision is not a valid number.- Since:
- 3.6.0
-
doOutsideBaseline
- Since:
- 3.6.0
-
getCurrentBaselineRevision
String getCurrentBaselineRevision()- Since:
- 3.6.0
-
getLastRevisionCommitedByCurrentThread
String getLastRevisionCommitedByCurrentThread()- Since:
- 3.6.0
-
refreshEnumerations
Refreshes enumerations (stored in the database) in a given project. IfcontextId
isnull
, refreshes enumerations in all projects.- Since:
- 3.8.0
-
getInstancesCountInBaseline
int getInstancesCountInBaseline(@NotNull String index, @NotNull String query, @Nullable String revision) Searches the count of objects in the given index from a given revision. In a typical case, the index name corresponds to the prototype name, however, there can be some additional indices defined, that don't correspond to a particular prototype.- Parameters:
index
-query
-revision
- baseline revision, ornull
not to search in a baseline- Returns:
- An objects count by a specified query.
- Since:
- 3.17.2
-