[New] added tx.get*()-methods with assertExists boolean
- now a user can always use that flag to guarantee the element exists
This commit is contained in:
parent
120ff0ace9
commit
be6f1d170f
|
@ -65,7 +65,7 @@ public interface ElementMap<T extends StrolchRootElement> {
|
||||||
public T getBy(StrolchTransaction tx, String type, String id);
|
public T getBy(StrolchTransaction tx, String type, String id);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the Element which is referenced by the given {@link StringParameter}. A reference {@link Parameter} must
|
* Returns the element which is referenced by the given {@link StringParameter}. A reference {@link Parameter} must
|
||||||
* have its interpretation set to the element type being referenced e.g. s
|
* have its interpretation set to the element type being referenced e.g. s
|
||||||
* {@link StrolchConstants#INTERPRETATION_ORDER_REF} and the UOM must be set to the element's type and the value is
|
* {@link StrolchConstants#INTERPRETATION_ORDER_REF} and the UOM must be set to the element's type and the value is
|
||||||
* the id of the element
|
* the id of the element
|
||||||
|
@ -74,12 +74,15 @@ public interface ElementMap<T extends StrolchRootElement> {
|
||||||
* the {@link StrolchTransaction} instance
|
* the {@link StrolchTransaction} instance
|
||||||
* @param refP
|
* @param refP
|
||||||
* the {@link StringParameter} which references an element
|
* the {@link StringParameter} which references an element
|
||||||
|
* @param assertExists
|
||||||
|
* if true, and element does not exist, then a {@link StrolchException} is thrown
|
||||||
|
*
|
||||||
* @return the element found, or null if it does not exist
|
* @return the element found, or null if it does not exist
|
||||||
*
|
*
|
||||||
* @throws StrolchException
|
* @throws StrolchException
|
||||||
* if the {@link StringParameter} is not a properly configured as a reference parameter
|
* if the {@link StringParameter} is not a properly configured as a reference parameter
|
||||||
*/
|
*/
|
||||||
public T getBy(StrolchTransaction tx, StringParameter refP) throws StrolchException;
|
public T getBy(StrolchTransaction tx, StringParameter refP, boolean assertExists) throws StrolchException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns all elements which are referenced by the given {@link StringListParameter}. A reference {@link Parameter}
|
* Returns all elements which are referenced by the given {@link StringListParameter}. A reference {@link Parameter}
|
||||||
|
@ -91,6 +94,8 @@ public interface ElementMap<T extends StrolchRootElement> {
|
||||||
* the {@link StrolchTransaction} instance
|
* the {@link StrolchTransaction} instance
|
||||||
* @param refP
|
* @param refP
|
||||||
* the {@link StringListParameter} which references an element
|
* the {@link StringListParameter} which references an element
|
||||||
|
* @param assertExists
|
||||||
|
* if true, and element does not exist, then a {@link StrolchException} is thrown
|
||||||
*
|
*
|
||||||
* @return the list of elements found, or the empty list if they do not exist. <b>Note:</b> Any missing elements are
|
* @return the list of elements found, or the empty list if they do not exist. <b>Note:</b> Any missing elements are
|
||||||
* not returned!
|
* not returned!
|
||||||
|
@ -98,7 +103,7 @@ public interface ElementMap<T extends StrolchRootElement> {
|
||||||
* @throws StrolchException
|
* @throws StrolchException
|
||||||
* if the {@link StringParameter} is not a properly configured as a reference parameter
|
* if the {@link StringParameter} is not a properly configured as a reference parameter
|
||||||
*/
|
*/
|
||||||
public List<T> getBy(StrolchTransaction tx, StringListParameter refP) throws StrolchException;
|
public List<T> getBy(StrolchTransaction tx, StringListParameter refP, boolean assertExists) throws StrolchException;
|
||||||
|
|
||||||
public List<T> getAllElements(StrolchTransaction tx);
|
public List<T> getAllElements(StrolchTransaction tx);
|
||||||
|
|
||||||
|
|
|
@ -105,57 +105,26 @@ public class AuditingElementMapFacade<T extends StrolchRootElement> implements E
|
||||||
return this.deletedAllByType;
|
return this.deletedAllByType;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param tx
|
|
||||||
* @param type
|
|
||||||
* @return
|
|
||||||
* @see li.strolch.agent.api.ElementMap#hasType(li.strolch.persistence.api.StrolchTransaction, java.lang.String)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasType(StrolchTransaction tx, String type) {
|
public boolean hasType(StrolchTransaction tx, String type) {
|
||||||
return this.elementMap.hasType(tx, type);
|
return this.elementMap.hasType(tx, type);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param tx
|
|
||||||
* @param type
|
|
||||||
* @param id
|
|
||||||
* @return
|
|
||||||
* @see li.strolch.agent.api.ElementMap#hasElement(li.strolch.persistence.api.StrolchTransaction, java.lang.String,
|
|
||||||
* java.lang.String)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasElement(StrolchTransaction tx, String type, String id) {
|
public boolean hasElement(StrolchTransaction tx, String type, String id) {
|
||||||
return this.elementMap.hasElement(tx, type, id);
|
return this.elementMap.hasElement(tx, type, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param tx
|
|
||||||
* @return
|
|
||||||
* @see li.strolch.agent.api.ElementMap#querySize(li.strolch.persistence.api.StrolchTransaction)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public long querySize(StrolchTransaction tx) {
|
public long querySize(StrolchTransaction tx) {
|
||||||
return this.elementMap.querySize(tx);
|
return this.elementMap.querySize(tx);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param tx
|
|
||||||
* @param type
|
|
||||||
* @return
|
|
||||||
* @see li.strolch.agent.api.ElementMap#querySize(li.strolch.persistence.api.StrolchTransaction, java.lang.String)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public long querySize(StrolchTransaction tx, String type) {
|
public long querySize(StrolchTransaction tx, String type) {
|
||||||
return this.elementMap.querySize(tx, type);
|
return this.elementMap.querySize(tx, type);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param tx
|
|
||||||
* @param type
|
|
||||||
* @return
|
|
||||||
* @see li.strolch.agent.api.ElementMap#getTemplate(li.strolch.persistence.api.StrolchTransaction, java.lang.String)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public T getTemplate(StrolchTransaction tx, String type) {
|
public T getTemplate(StrolchTransaction tx, String type) {
|
||||||
T template = this.elementMap.getTemplate(tx, type);
|
T template = this.elementMap.getTemplate(tx, type);
|
||||||
|
@ -164,14 +133,6 @@ public class AuditingElementMapFacade<T extends StrolchRootElement> implements E
|
||||||
return template;
|
return template;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param tx
|
|
||||||
* @param type
|
|
||||||
* @param id
|
|
||||||
* @return
|
|
||||||
* @see li.strolch.agent.api.ElementMap#getBy(li.strolch.persistence.api.StrolchTransaction, java.lang.String,
|
|
||||||
* java.lang.String)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public T getBy(StrolchTransaction tx, String type, String id) {
|
public T getBy(StrolchTransaction tx, String type, String id) {
|
||||||
T element = this.elementMap.getBy(tx, type, id);
|
T element = this.elementMap.getBy(tx, type, id);
|
||||||
|
@ -180,35 +141,22 @@ public class AuditingElementMapFacade<T extends StrolchRootElement> implements E
|
||||||
return element;
|
return element;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param tx
|
|
||||||
* @param refP
|
|
||||||
* @return
|
|
||||||
* @throws StrolchException
|
|
||||||
* @see li.strolch.agent.api.ElementMap#getBy(li.strolch.persistence.api.StrolchTransaction,
|
|
||||||
* li.strolch.model.parameter.StringParameter)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public T getBy(StrolchTransaction tx, StringParameter refP) throws StrolchException {
|
public T getBy(StrolchTransaction tx, StringParameter refP, boolean assertExists) throws StrolchException {
|
||||||
T element = this.elementMap.getBy(tx, refP);
|
T element = this.elementMap.getBy(tx, refP, assertExists);
|
||||||
if (this.observeAccessReads)
|
if (this.observeAccessReads)
|
||||||
this.read.add(element);
|
this.read.add(element);
|
||||||
return element;
|
return element;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<T> getBy(StrolchTransaction tx, StringListParameter refP) throws StrolchException {
|
public List<T> getBy(StrolchTransaction tx, StringListParameter refP, boolean assertExists) throws StrolchException {
|
||||||
List<T> elements = this.elementMap.getBy(tx, refP);
|
List<T> elements = this.elementMap.getBy(tx, refP, assertExists);
|
||||||
if (this.observeAccessReads)
|
if (this.observeAccessReads)
|
||||||
this.read.addAll(elements);
|
this.read.addAll(elements);
|
||||||
return elements;
|
return elements;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param tx
|
|
||||||
* @return
|
|
||||||
* @see li.strolch.agent.api.ElementMap#getAllElements(li.strolch.persistence.api.StrolchTransaction)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public List<T> getAllElements(StrolchTransaction tx) {
|
public List<T> getAllElements(StrolchTransaction tx) {
|
||||||
List<T> elements = this.elementMap.getAllElements(tx);
|
List<T> elements = this.elementMap.getAllElements(tx);
|
||||||
|
@ -217,13 +165,6 @@ public class AuditingElementMapFacade<T extends StrolchRootElement> implements E
|
||||||
return elements;
|
return elements;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param tx
|
|
||||||
* @param type
|
|
||||||
* @return
|
|
||||||
* @see li.strolch.agent.api.ElementMap#getElementsBy(li.strolch.persistence.api.StrolchTransaction,
|
|
||||||
* java.lang.String)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public List<T> getElementsBy(StrolchTransaction tx, String type) {
|
public List<T> getElementsBy(StrolchTransaction tx, String type) {
|
||||||
List<T> elements = this.elementMap.getElementsBy(tx, type);
|
List<T> elements = this.elementMap.getElementsBy(tx, type);
|
||||||
|
@ -232,67 +173,33 @@ public class AuditingElementMapFacade<T extends StrolchRootElement> implements E
|
||||||
return elements;
|
return elements;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param tx
|
|
||||||
* @return
|
|
||||||
* @see li.strolch.agent.api.ElementMap#getTypes(li.strolch.persistence.api.StrolchTransaction)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public Set<String> getTypes(StrolchTransaction tx) {
|
public Set<String> getTypes(StrolchTransaction tx) {
|
||||||
return this.elementMap.getTypes(tx);
|
return this.elementMap.getTypes(tx);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param tx
|
|
||||||
* @return
|
|
||||||
* @see li.strolch.agent.api.ElementMap#getAllKeys(li.strolch.persistence.api.StrolchTransaction)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public Set<String> getAllKeys(StrolchTransaction tx) {
|
public Set<String> getAllKeys(StrolchTransaction tx) {
|
||||||
return this.elementMap.getAllKeys(tx);
|
return this.elementMap.getAllKeys(tx);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param tx
|
|
||||||
* @param type
|
|
||||||
* @return
|
|
||||||
* @see li.strolch.agent.api.ElementMap#getKeysBy(li.strolch.persistence.api.StrolchTransaction, java.lang.String)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public Set<String> getKeysBy(StrolchTransaction tx, String type) {
|
public Set<String> getKeysBy(StrolchTransaction tx, String type) {
|
||||||
return this.elementMap.getKeysBy(tx, type);
|
return this.elementMap.getKeysBy(tx, type);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param tx
|
|
||||||
* @param element
|
|
||||||
* @see li.strolch.agent.api.ElementMap#add(li.strolch.persistence.api.StrolchTransaction,
|
|
||||||
* li.strolch.model.StrolchRootElement)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public void add(StrolchTransaction tx, T element) {
|
public void add(StrolchTransaction tx, T element) {
|
||||||
this.elementMap.add(tx, element);
|
this.elementMap.add(tx, element);
|
||||||
this.created.add(element);
|
this.created.add(element);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param tx
|
|
||||||
* @param elements
|
|
||||||
* @see li.strolch.agent.api.ElementMap#addAll(li.strolch.persistence.api.StrolchTransaction, java.util.List)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public void addAll(StrolchTransaction tx, List<T> elements) {
|
public void addAll(StrolchTransaction tx, List<T> elements) {
|
||||||
this.elementMap.addAll(tx, elements);
|
this.elementMap.addAll(tx, elements);
|
||||||
this.created.addAll(elements);
|
this.created.addAll(elements);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param tx
|
|
||||||
* @param element
|
|
||||||
* @return
|
|
||||||
* @see li.strolch.agent.api.ElementMap#update(li.strolch.persistence.api.StrolchTransaction,
|
|
||||||
* li.strolch.model.StrolchRootElement)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public T update(StrolchTransaction tx, T element) {
|
public T update(StrolchTransaction tx, T element) {
|
||||||
T replaced = this.elementMap.update(tx, element);
|
T replaced = this.elementMap.update(tx, element);
|
||||||
|
@ -301,12 +208,6 @@ public class AuditingElementMapFacade<T extends StrolchRootElement> implements E
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param tx
|
|
||||||
* @param elements
|
|
||||||
* @return
|
|
||||||
* @see li.strolch.agent.api.ElementMap#updateAll(li.strolch.persistence.api.StrolchTransaction, java.util.List)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public List<T> updateAll(StrolchTransaction tx, List<T> elements) {
|
public List<T> updateAll(StrolchTransaction tx, List<T> elements) {
|
||||||
List<T> replaced = this.elementMap.updateAll(tx, elements);
|
List<T> replaced = this.elementMap.updateAll(tx, elements);
|
||||||
|
@ -314,34 +215,18 @@ public class AuditingElementMapFacade<T extends StrolchRootElement> implements E
|
||||||
return replaced;
|
return replaced;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param tx
|
|
||||||
* @param element
|
|
||||||
* @see li.strolch.agent.api.ElementMap#remove(li.strolch.persistence.api.StrolchTransaction,
|
|
||||||
* li.strolch.model.StrolchRootElement)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public void remove(StrolchTransaction tx, T element) {
|
public void remove(StrolchTransaction tx, T element) {
|
||||||
this.elementMap.remove(tx, element);
|
this.elementMap.remove(tx, element);
|
||||||
this.deleted.add(element);
|
this.deleted.add(element);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param tx
|
|
||||||
* @param elements
|
|
||||||
* @see li.strolch.agent.api.ElementMap#removeAll(li.strolch.persistence.api.StrolchTransaction, java.util.List)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public void removeAll(StrolchTransaction tx, List<T> elements) {
|
public void removeAll(StrolchTransaction tx, List<T> elements) {
|
||||||
this.elementMap.removeAll(tx, elements);
|
this.elementMap.removeAll(tx, elements);
|
||||||
this.deleted.addAll(elements);
|
this.deleted.addAll(elements);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param tx
|
|
||||||
* @return
|
|
||||||
* @see li.strolch.agent.api.ElementMap#removeAll(li.strolch.persistence.api.StrolchTransaction)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public long removeAll(StrolchTransaction tx) {
|
public long removeAll(StrolchTransaction tx) {
|
||||||
long removed = this.elementMap.removeAll(tx);
|
long removed = this.elementMap.removeAll(tx);
|
||||||
|
@ -349,12 +234,6 @@ public class AuditingElementMapFacade<T extends StrolchRootElement> implements E
|
||||||
return removed;
|
return removed;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param tx
|
|
||||||
* @param type
|
|
||||||
* @return
|
|
||||||
* @see li.strolch.agent.api.ElementMap#removeAllBy(li.strolch.persistence.api.StrolchTransaction, java.lang.String)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public long removeAllBy(StrolchTransaction tx, String type) {
|
public long removeAllBy(StrolchTransaction tx, String type) {
|
||||||
long removed = this.elementMap.removeAllBy(tx, type);
|
long removed = this.elementMap.removeAllBy(tx, type);
|
||||||
|
|
|
@ -107,15 +107,21 @@ public abstract class CachedElementMap<T extends StrolchRootElement> implements
|
||||||
protected abstract void assertIsRefParam(Parameter<?> refP);
|
protected abstract void assertIsRefParam(Parameter<?> refP);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public T getBy(StrolchTransaction tx, StringParameter refP) throws StrolchException {
|
public T getBy(StrolchTransaction tx, StringParameter refP, boolean assertExists) throws StrolchException {
|
||||||
assertIsRefParam(refP);
|
assertIsRefParam(refP);
|
||||||
String type = refP.getUom();
|
String type = refP.getUom();
|
||||||
String id = refP.getValue();
|
String id = refP.getValue();
|
||||||
return getBy(tx, type, id);
|
T element = getBy(tx, type, id);
|
||||||
|
if (assertExists && element == null) {
|
||||||
|
String msg = "The element for refP {0} with id {1} does not exist!"; //$NON-NLS-1$
|
||||||
|
msg = MessageFormat.format(msg, refP.getLocator(), id);
|
||||||
|
throw new StrolchException(msg);
|
||||||
|
}
|
||||||
|
return element;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<T> getBy(StrolchTransaction tx, StringListParameter refP) throws StrolchException {
|
public List<T> getBy(StrolchTransaction tx, StringListParameter refP, boolean assertExists) throws StrolchException {
|
||||||
assertIsRefParam(refP);
|
assertIsRefParam(refP);
|
||||||
|
|
||||||
List<T> elements = new ArrayList<>();
|
List<T> elements = new ArrayList<>();
|
||||||
|
@ -124,8 +130,15 @@ public abstract class CachedElementMap<T extends StrolchRootElement> implements
|
||||||
|
|
||||||
for (String id : ids) {
|
for (String id : ids) {
|
||||||
T element = getBy(tx, type, id);
|
T element = getBy(tx, type, id);
|
||||||
if (element != null)
|
if (element != null) {
|
||||||
elements.add(element);
|
elements.add(element);
|
||||||
|
} else if (assertExists) {
|
||||||
|
if (assertExists && element == null) {
|
||||||
|
String msg = "The element for refP {0} with id {1} does not exist!"; //$NON-NLS-1$
|
||||||
|
msg = MessageFormat.format(msg, refP.getLocator(), id);
|
||||||
|
throw new StrolchException(msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return elements;
|
return elements;
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package li.strolch.agent.impl;
|
package li.strolch.agent.impl;
|
||||||
|
|
||||||
|
import java.text.MessageFormat;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
@ -56,15 +57,21 @@ public abstract class TransactionalElementMap<T extends StrolchRootElement> impl
|
||||||
protected abstract void assertIsRefParam(Parameter<?> refP);
|
protected abstract void assertIsRefParam(Parameter<?> refP);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public T getBy(StrolchTransaction tx, StringParameter refP) throws StrolchException {
|
public T getBy(StrolchTransaction tx, StringParameter refP, boolean assertExists) throws StrolchException {
|
||||||
assertIsRefParam(refP);
|
assertIsRefParam(refP);
|
||||||
String type = refP.getUom();
|
String type = refP.getUom();
|
||||||
String id = refP.getValue();
|
String id = refP.getValue();
|
||||||
return getBy(tx, type, id);
|
T element = getBy(tx, type, id);
|
||||||
|
if (assertExists && element == null) {
|
||||||
|
String msg = "The element for refP {0} with id {1} does not exist!"; //$NON-NLS-1$
|
||||||
|
msg = MessageFormat.format(msg, refP.getLocator(), id);
|
||||||
|
throw new StrolchException(msg);
|
||||||
|
}
|
||||||
|
return element;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<T> getBy(StrolchTransaction tx, StringListParameter refP) throws StrolchException {
|
public List<T> getBy(StrolchTransaction tx, StringListParameter refP, boolean assertExists) throws StrolchException {
|
||||||
assertIsRefParam(refP);
|
assertIsRefParam(refP);
|
||||||
|
|
||||||
List<T> elements = new ArrayList<>();
|
List<T> elements = new ArrayList<>();
|
||||||
|
@ -73,8 +80,15 @@ public abstract class TransactionalElementMap<T extends StrolchRootElement> impl
|
||||||
|
|
||||||
for (String id : ids) {
|
for (String id : ids) {
|
||||||
T element = getBy(tx, type, id);
|
T element = getBy(tx, type, id);
|
||||||
if (element != null)
|
if (element != null) {
|
||||||
elements.add(element);
|
elements.add(element);
|
||||||
|
} else if (assertExists) {
|
||||||
|
if (assertExists && element == null) {
|
||||||
|
String msg = "The element for refP {0} with id {1} does not exist!"; //$NON-NLS-1$
|
||||||
|
msg = MessageFormat.format(msg, refP.getLocator(), id);
|
||||||
|
throw new StrolchException(msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return elements;
|
return elements;
|
||||||
|
|
|
@ -395,17 +395,17 @@ public abstract class AbstractTransaction implements StrolchTransaction {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Order getOrderBy(StringParameter refP, boolean assertExists) throws StrolchException {
|
public Order getOrderBy(StringParameter refP, boolean assertExists) throws StrolchException {
|
||||||
Order order = getOrderMap().getBy(this, refP);
|
return getOrderMap().getBy(this, refP, assertExists);
|
||||||
if (assertExists && order == null) {
|
|
||||||
String msg = "No Order exists with the id {0} with type {1} for refP {2}";
|
|
||||||
throw new StrolchException(MessageFormat.format(msg, refP.getValue(), refP.getUom(), refP.getLocator()));
|
|
||||||
}
|
|
||||||
return order;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Order> getOrdersBy(StringListParameter refP) throws StrolchException {
|
public List<Order> getOrdersBy(StringListParameter refP) throws StrolchException {
|
||||||
return getOrderMap().getBy(this, refP);
|
return getOrderMap().getBy(this, refP, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Order> getOrdersBy(StringListParameter refP, boolean assertExists) throws StrolchException {
|
||||||
|
return getOrderMap().getBy(this, refP, assertExists);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -430,17 +430,17 @@ public abstract class AbstractTransaction implements StrolchTransaction {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Resource getResourceBy(StringParameter refP, boolean assertExists) throws StrolchException {
|
public Resource getResourceBy(StringParameter refP, boolean assertExists) throws StrolchException {
|
||||||
Resource resource = getResourceMap().getBy(this, refP);
|
return getResourceMap().getBy(this, refP, assertExists);
|
||||||
if (assertExists && resource == null) {
|
|
||||||
String msg = "No Resource exists with the id {0} with type {1} for refP {2}";
|
|
||||||
throw new StrolchException(MessageFormat.format(msg, refP.getValue(), refP.getUom(), refP.getLocator()));
|
|
||||||
}
|
|
||||||
return resource;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Resource> getResourcesBy(StringListParameter refP) throws StrolchException {
|
public List<Resource> getResourcesBy(StringListParameter refP) throws StrolchException {
|
||||||
return getResourceMap().getBy(this, refP);
|
return getResourceMap().getBy(this, refP, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Resource> getResourcesBy(StringListParameter refP, boolean assertExists) throws StrolchException {
|
||||||
|
return getResourceMap().getBy(this, refP, assertExists);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -580,6 +580,24 @@ public interface StrolchTransaction extends AutoCloseable {
|
||||||
*/
|
*/
|
||||||
public List<Resource> getResourcesBy(StringListParameter refP) throws StrolchException;
|
public List<Resource> getResourcesBy(StringListParameter refP) throws StrolchException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns all {@link Resource Resources} which are referenced by the given {@link StringListParameter}. A reference
|
||||||
|
* {@link Parameter} must have its interpretation set to {@link StrolchConstants#INTERPRETATION_RESOURCE_REF} and
|
||||||
|
* the UOM must be set to the resource's type and the value is the id of the resource
|
||||||
|
*
|
||||||
|
* @param refP
|
||||||
|
* the {@link StringListParameter} which references a list of {@link Resource Resources}
|
||||||
|
* @param assertExists
|
||||||
|
* if true, and resource does not exist, then a {@link StrolchException} is thrown
|
||||||
|
*
|
||||||
|
* @return the resources referenced by the parameter, or the empty list if they do not exist. <b>Note:</b> Any
|
||||||
|
* missing resources are not returned!
|
||||||
|
*
|
||||||
|
* @throws StrolchException
|
||||||
|
* if the {@link StringListParameter} is not a properly configured as a reference parameter
|
||||||
|
*/
|
||||||
|
public List<Resource> getResourcesBy(StringListParameter refP, boolean assertExists) throws StrolchException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the {@link Order} with the given type and id, or null if it does not exist
|
* Returns the {@link Order} with the given type and id, or null if it does not exist
|
||||||
*
|
*
|
||||||
|
@ -657,4 +675,22 @@ public interface StrolchTransaction extends AutoCloseable {
|
||||||
* if the {@link StringListParameter} is not a properly configured as a reference parameter
|
* if the {@link StringListParameter} is not a properly configured as a reference parameter
|
||||||
*/
|
*/
|
||||||
public List<Order> getOrdersBy(StringListParameter refP) throws StrolchException;
|
public List<Order> getOrdersBy(StringListParameter refP) throws StrolchException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns all {@link Order Orders} which are referenced by the given {@link StringListParameter}. A reference
|
||||||
|
* {@link Parameter} must have its interpretation set to {@link StrolchConstants#INTERPRETATION_ORDER_REF} and the
|
||||||
|
* UOM must be set to the order's type and the value is the id of the order
|
||||||
|
*
|
||||||
|
* @param refP
|
||||||
|
* the {@link StringListParameter} which references a list of {@link Order Orders}
|
||||||
|
* @param assertExists
|
||||||
|
* if true, and order does not exist, then a {@link StrolchException} is thrown
|
||||||
|
*
|
||||||
|
* @return the orders referenced by the parameter, or the empty list if they do not exist. <b>Note:</b> Any missing
|
||||||
|
* orders are not returned!
|
||||||
|
*
|
||||||
|
* @throws StrolchException
|
||||||
|
* if the {@link StringListParameter} is not a properly configured as a reference parameter
|
||||||
|
*/
|
||||||
|
public List<Order> getOrdersBy(StringListParameter refP, boolean assertExists) throws StrolchException;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue