T - the object instance being managedpublic interface ElementMap<T extends StrolchRootElement>
The ElementMap is the entry point to the Strolch model. Any access to Strolch objects is done using the
ElementMap. A concrete ElementMap instance uses the given StrolchTransaction to access the a
StrolchDao and perform the relevant operation.
Note:
| Modifier and Type | Method and Description |
|---|---|
void |
add(StrolchTransaction tx,
T element)
Adds the given element to the underlying persistence layer.
|
void |
addAll(StrolchTransaction tx,
List<T> elements)
Adds the given elements to the underlying persistence layer.
|
List<T> |
getAllElements(StrolchTransaction tx)
Returns all elements in the underlying persistence layer regardless of type
|
Set<String> |
getAllKeys(StrolchTransaction tx)
Returns all keys/IDs of all elements in the underlying persistence layer, regardless of type
|
List<T> |
getBy(StrolchTransaction tx,
StringListParameter refP,
boolean assertExists)
Returns all elements which are referenced by the given
StringListParameter. |
T |
getBy(StrolchTransaction tx,
StringParameter refP,
boolean assertExists)
Returns the element which is referenced by the given
StringParameter. |
T |
getBy(StrolchTransaction tx,
String type,
String id)
Retrieves the element with the given type and id, or null if it does not exist
|
T |
getBy(StrolchTransaction tx,
String type,
String id,
boolean assertExists)
Retrieves the element with the given type and id, or null if it does not exist
|
T |
getBy(StrolchTransaction tx,
String type,
String id,
int version)
Retrieves the specific version of the element with the given type and id, or null if it does not exist
|
T |
getBy(StrolchTransaction tx,
String type,
String id,
int version,
boolean assertExists)
Retrieves the specific version of the element with the given type and id, or null if it does not exist
|
List<T> |
getElementsBy(StrolchTransaction tx,
String type)
Returns all elements in the underlying persistence layer of the given type
|
Set<String> |
getKeysBy(StrolchTransaction tx,
String type)
Returns all keys/IDs of all elements in the underlying persistence layer, of the given type
|
T |
getTemplate(StrolchTransaction tx,
String type)
Returns a copy of the element with the type "Template" and the id = type
|
T |
getTemplate(StrolchTransaction tx,
String type,
boolean assertExists)
Returns a copy of the element with the type "Template" and the id = type
|
Set<String> |
getTypes(StrolchTransaction tx)
Returns all the types known in the underlying persistence layer
|
List<T> |
getVersionsFor(StrolchTransaction tx,
String type,
String id)
Queries and returns all the versions of the element with the given type and ID
|
boolean |
hasElement(StrolchTransaction tx,
String type,
String id)
Returns true if the underlying persistence layer has an element with the given type and ID
|
boolean |
hasType(StrolchTransaction tx,
String type)
Returns true if the underlying persistence layer has elements with the given type
|
long |
querySize(StrolchTransaction tx)
Returns the number of elements regardless of type in the underlying persistence layer
|
long |
querySize(StrolchTransaction tx,
String type)
Returns the number of elements of the given type in the underlying persistence layer
|
void |
remove(StrolchTransaction tx,
T element)
Removes the given element
|
long |
removeAll(StrolchTransaction tx)
Removes all elements regardless of the type
|
void |
removeAll(StrolchTransaction tx,
List<T> elements)
Removes the given elements
|
long |
removeAllBy(StrolchTransaction tx,
String type)
Removes all elements of the given type
|
T |
revertToVersion(StrolchTransaction tx,
String type,
String id,
int version)
Reverts to the given version of the specified element.
|
T |
revertToVersion(StrolchTransaction tx,
T element)
Reverts to the given version of the specified element.
|
void |
undoVersion(StrolchTransaction tx,
T element)
Undoes the given version by reverting to the previous version of the element given.
|
void |
update(StrolchTransaction tx,
T element)
Updates the existing element
|
void |
updateAll(StrolchTransaction tx,
List<T> elements)
Updates all the existing elements
|
boolean hasType(StrolchTransaction tx, String type)
tx - the open StrolchTransactiontype - the type of element to check forboolean hasElement(StrolchTransaction tx, String type, String id)
tx - the open StrolchTransactiontype - the type of element to check forid - the ID of the element to check forlong querySize(StrolchTransaction tx)
tx - the open StrolchTransactionlong querySize(StrolchTransaction tx, String type)
tx - the open StrolchTransactiontype - the type of element for which the number of elements is to be queriedT getTemplate(StrolchTransaction tx, String type)
tx - the open StrolchTransactiontype - The template id to returnT getTemplate(StrolchTransaction tx, String type, boolean assertExists) throws StrolchException
tx - the open StrolchTransactiontype - The template id to returnassertExists - if true, and element does not exist, then a StrolchException is thrownStrolchException - if the template does not existT getBy(StrolchTransaction tx, String type, String id)
tx - the open transactiontype - the type of the element to retrieveid - the id of the element to retrieveT getBy(StrolchTransaction tx, String type, String id, boolean assertExists) throws StrolchException
tx - the open transactiontype - the type of the element to retrieveid - the id of the element to retrieveassertExists - if true, and element does not exist, then a StrolchException is thrownStrolchException - if the element does not existT getBy(StrolchTransaction tx, String type, String id, int version)
tx - the open transactiontype - the type of the element to retrieveid - the id of the element to retrieveversion - the version to getT getBy(StrolchTransaction tx, String type, String id, int version, boolean assertExists) throws StrolchException
tx - the open transactiontype - the type of the element to retrieveid - the id of the element to retrieveversion - the version to getassertExists - if true, and element does not exist, then a StrolchException is thrownStrolchException - if the element does not existT getBy(StrolchTransaction tx, StringParameter refP, boolean assertExists) throws StrolchException
StringParameter. A reference Parameter must
have its interpretation set to the element type being referenced e.g. s
StrolchConstants.INTERPRETATION_ORDER_REF and the UOM must be set to the element's type and the value is
the id of the elementtx - the StrolchTransaction instancerefP - the StringParameter which references an elementassertExists - if true, and element does not exist, then a StrolchException is thrownStrolchException - if the StringParameter is not a properly configured as a reference parameterList<T> getBy(StrolchTransaction tx, StringListParameter refP, boolean assertExists) throws StrolchException
StringListParameter. A reference Parameter
must have its interpretation set to the element type being referenced e.g. s
StrolchConstants.INTERPRETATION_ORDER_REF and the UOM must be set to the element's type and the value is
the id of the elementtx - the StrolchTransaction instancerefP - the StringListParameter which references an elementassertExists - if true, and element does not exist, then a StrolchException is thrownStrolchException - if the StringParameter is not a properly configured as a reference parameterList<T> getVersionsFor(StrolchTransaction tx, String type, String id)
tx - the StrolchTransaction instancetype - the type of the element to be queriedid - the id of the element to be queriedList<T> getAllElements(StrolchTransaction tx)
tx - the StrolchTransaction instanceList<T> getElementsBy(StrolchTransaction tx, String type)
tx - the StrolchTransaction instancetype - the type of the elements to retrieveSet<String> getTypes(StrolchTransaction tx)
tx - the StrolchTransaction instanceSet<String> getAllKeys(StrolchTransaction tx)
tx - the StrolchTransaction instanceSet<String> getKeysBy(StrolchTransaction tx, String type)
tx - the StrolchTransaction instancetype - the type of the element to retrieve the keys forvoid add(StrolchTransaction tx, T element) throws StrolchPersistenceException
tx - the StrolchTransaction instanceelement - the element to addStrolchPersistenceException - if an element already exists with the same IDvoid addAll(StrolchTransaction tx, List<T> elements) throws StrolchPersistenceException
tx - the StrolchTransaction instanceelements - the elements to addStrolchPersistenceException - if an element already exists with the same IDvoid update(StrolchTransaction tx, T element) throws StrolchPersistenceException
tx - the StrolchTransaction instanceelement - the element to updateStrolchPersistenceException - if the element does not existvoid updateAll(StrolchTransaction tx, List<T> elements) throws StrolchPersistenceException
tx - the StrolchTransaction instanceelements - the elements to updateStrolchPersistenceException - if any of the elements don't yet existvoid remove(StrolchTransaction tx, T element) throws StrolchPersistenceException
tx - the StrolchTransaction instanceelement - the element to be removedStrolchPersistenceException - if the element does not existvoid removeAll(StrolchTransaction tx, List<T> elements) throws StrolchPersistenceException
tx - the StrolchTransaction instanceelements - the elements to be removedStrolchPersistenceException - if any of the elements don't yet existlong removeAll(StrolchTransaction tx)
Removes all elements regardless of the type
Note: This method ignores versioning. Do NOT call this method unless you want to clear the model!
tx - the StrolchTransaction instancelong removeAllBy(StrolchTransaction tx, String type)
Removes all elements of the given type
Note: This method ignores versioning. Do NOT call this method unless you want to clear the model!
tx - the StrolchTransaction instancetype - the type of elements to removevoid undoVersion(StrolchTransaction tx, T element) throws StrolchException
Undoes the given version by reverting to the previous version of the element given. If the element given is the
first version, then the element is removed. If the previous version exists, then it is reverted to it. If the
given element does not exist, nor it's previous version, then a StrolchPersistenceException is thrown
Note: This method should only be used in the same transaction where the element was created to undo a
change in the same transaction. If there is a requirement to revert to a previous version, then the
revertToVersion(StrolchTransaction, StrolchRootElement) method.
tx - the StrolchTransaction instanceelement - the element which is to be reverted to a previous versionStrolchException - if the version does not exist, if this version is not the latest version, if the previous version is
missing or other problems ariseT revertToVersion(StrolchTransaction tx, T element) throws StrolchException
Reverts to the given version of the specified element. This method will retrieve the given version of the specified element, then set a new version on that element which is an increment of the current latest version and store this new version. The new element is then returned for convenience.
Note: This is the method which should be called when a change should be reverted. This method gurantees that the history is not changed and that a new version is saved but with the version of the element specified.
tx - the StrolchTransaction instanceelement - the version of the element to revert toStrolchException - if the version does not existT revertToVersion(StrolchTransaction tx, String type, String id, int version) throws StrolchException
Reverts to the given version of the specified element. This method will retrieve the given version of the specified element, then set a new version on that element which is an increment of the current latest version and store this new version. The new element is then returned for convenience.
Note: This is the method which should be called when a change should be reverted. This method gurantees that the history is not changed and that a new version is saved but with the version of the element specified.
tx - the StrolchTransaction instancetype - the type of the element to revert toid - the id of the element to revert toversion - the version of the specified element to revert toStrolchException - if the version does not existCopyright © 2011–2016 Strolch. All rights reserved.