T - public abstract class TransactionalElementMap<T extends StrolchRootElement> extends Object implements ElementMap<T>
| Constructor and Description |
|---|
TransactionalElementMap(StrolchRealm realm) |
| 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.
|
protected abstract void |
assertIsRefParam(Parameter<?> refP) |
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
|
protected abstract StrolchDao<T> |
getDao(StrolchTransaction tx) |
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
|
protected StrolchRealm |
getRealm() |
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
|
public TransactionalElementMap(StrolchRealm realm)
protected StrolchRealm getRealm()
protected abstract StrolchDao<T> getDao(StrolchTransaction tx)
public boolean hasType(StrolchTransaction tx, String type)
ElementMaphasType in interface ElementMap<T extends StrolchRootElement>tx - the open StrolchTransactiontype - the type of element to check forpublic boolean hasElement(StrolchTransaction tx, String type, String id)
ElementMaphasElement in interface ElementMap<T extends StrolchRootElement>tx - the open StrolchTransactiontype - the type of element to check forid - the ID of the element to check forpublic long querySize(StrolchTransaction tx)
ElementMapquerySize in interface ElementMap<T extends StrolchRootElement>tx - the open StrolchTransactionpublic long querySize(StrolchTransaction tx, String type)
ElementMapquerySize in interface ElementMap<T extends StrolchRootElement>tx - the open StrolchTransactiontype - the type of element for which the number of elements is to be queriedpublic T getTemplate(StrolchTransaction tx, String type)
ElementMapgetTemplate in interface ElementMap<T extends StrolchRootElement>tx - the open StrolchTransactiontype - The template id to returnpublic T getTemplate(StrolchTransaction tx, String type, boolean assertExists) throws StrolchException
ElementMapgetTemplate in interface ElementMap<T extends StrolchRootElement>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 existpublic T getBy(StrolchTransaction tx, String type, String id)
ElementMapgetBy in interface ElementMap<T extends StrolchRootElement>tx - the open transactiontype - the type of the element to retrieveid - the id of the element to retrievepublic T getBy(StrolchTransaction tx, String type, String id, boolean assertExists) throws StrolchException
ElementMapgetBy in interface ElementMap<T extends StrolchRootElement>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 existpublic T getBy(StrolchTransaction tx, String type, String id, int version)
ElementMapgetBy in interface ElementMap<T extends StrolchRootElement>tx - the open transactiontype - the type of the element to retrieveid - the id of the element to retrieveversion - the version to getpublic T getBy(StrolchTransaction tx, String type, String id, int version, boolean assertExists) throws StrolchException
ElementMapgetBy in interface ElementMap<T extends StrolchRootElement>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 existpublic T getBy(StrolchTransaction tx, StringParameter refP, boolean assertExists) throws StrolchException
ElementMapStringParameter. 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 elementgetBy in interface ElementMap<T extends StrolchRootElement>tx - 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 parameterpublic List<T> getBy(StrolchTransaction tx, StringListParameter refP, boolean assertExists) throws StrolchException
ElementMapStringListParameter. 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 elementgetBy in interface ElementMap<T extends StrolchRootElement>tx - 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 parameterpublic List<T> getVersionsFor(StrolchTransaction tx, String type, String id)
ElementMapgetVersionsFor in interface ElementMap<T extends StrolchRootElement>tx - the StrolchTransaction instancetype - the type of the element to be queriedid - the id of the element to be queriedpublic List<T> getAllElements(StrolchTransaction tx)
ElementMapgetAllElements in interface ElementMap<T extends StrolchRootElement>tx - the StrolchTransaction instancepublic List<T> getElementsBy(StrolchTransaction tx, String type)
ElementMapgetElementsBy in interface ElementMap<T extends StrolchRootElement>tx - the StrolchTransaction instancetype - the type of the elements to retrievepublic Set<String> getTypes(StrolchTransaction tx)
ElementMapgetTypes in interface ElementMap<T extends StrolchRootElement>tx - the StrolchTransaction instancepublic Set<String> getAllKeys(StrolchTransaction tx)
ElementMapgetAllKeys in interface ElementMap<T extends StrolchRootElement>tx - the StrolchTransaction instancepublic Set<String> getKeysBy(StrolchTransaction tx, String type)
ElementMapgetKeysBy in interface ElementMap<T extends StrolchRootElement>tx - the StrolchTransaction instancetype - the type of the element to retrieve the keys forpublic void add(StrolchTransaction tx, T element)
ElementMapadd in interface ElementMap<T extends StrolchRootElement>tx - the StrolchTransaction instanceelement - the element to addpublic void addAll(StrolchTransaction tx, List<T> elements)
ElementMapaddAll in interface ElementMap<T extends StrolchRootElement>tx - the StrolchTransaction instanceelements - the elements to addpublic void update(StrolchTransaction tx, T element)
ElementMapupdate in interface ElementMap<T extends StrolchRootElement>tx - the StrolchTransaction instanceelement - the element to updatepublic void updateAll(StrolchTransaction tx, List<T> elements)
ElementMapupdateAll in interface ElementMap<T extends StrolchRootElement>tx - the StrolchTransaction instanceelements - the elements to updatepublic void remove(StrolchTransaction tx, T element)
ElementMapremove in interface ElementMap<T extends StrolchRootElement>tx - the StrolchTransaction instanceelement - the element to be removedpublic void removeAll(StrolchTransaction tx, List<T> elements)
ElementMapremoveAll in interface ElementMap<T extends StrolchRootElement>tx - the StrolchTransaction instanceelements - the elements to be removedpublic long removeAll(StrolchTransaction tx)
ElementMapRemoves all elements regardless of the type
Note: This method ignores versioning. Do NOT call this method unless you want to clear the model!
removeAll in interface ElementMap<T extends StrolchRootElement>tx - the StrolchTransaction instancepublic long removeAllBy(StrolchTransaction tx, String type)
ElementMapRemoves all elements of the given type
Note: This method ignores versioning. Do NOT call this method unless you want to clear the model!
removeAllBy in interface ElementMap<T extends StrolchRootElement>tx - the StrolchTransaction instancetype - the type of elements to removepublic T revertToVersion(StrolchTransaction tx, T element) throws StrolchException
ElementMapReverts 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.
revertToVersion in interface ElementMap<T extends StrolchRootElement>tx - the StrolchTransaction instanceelement - the version of the element to revert toStrolchException - if the version does not existpublic T revertToVersion(StrolchTransaction tx, String type, String id, int version) throws StrolchException
ElementMapReverts 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.
revertToVersion in interface ElementMap<T extends StrolchRootElement>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 existpublic void undoVersion(StrolchTransaction tx, T element) throws StrolchException
ElementMap
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
ElementMap.revertToVersion(StrolchTransaction, StrolchRootElement) method.
undoVersion in interface ElementMap<T extends StrolchRootElement>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 ariseprotected abstract void assertIsRefParam(Parameter<?> refP)
Copyright © 2011–2016 Strolch. All rights reserved.