[New] Added StrolchTransaction.addOrUpdate() methods
This commit is contained in:
parent
8e0c2e6412
commit
a85fa26b5e
|
@ -947,6 +947,33 @@ public abstract class AbstractTransaction implements StrolchTransaction {
|
||||||
getPrivilegeContext().assertHasAnyRole(roleNames);
|
getPrivilegeContext().assertHasAnyRole(roleNames);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addOrUpdate(Resource resource) throws StrolchModelException {
|
||||||
|
DBC.PRE.assertNotNull("resource must not be null", resource);
|
||||||
|
if (hasResource(resource.getType(), resource.getId()))
|
||||||
|
getObjectFilter().update(Tags.RESOURCE, resource.getLocator(), resource);
|
||||||
|
else
|
||||||
|
getObjectFilter().add(Tags.RESOURCE, resource.getLocator(), resource);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addOrUpdate(Order order) throws StrolchModelException {
|
||||||
|
DBC.PRE.assertNotNull("order must not be null", order);
|
||||||
|
if (hasOrder(order.getType(), order.getId()))
|
||||||
|
getObjectFilter().update(Tags.ORDER, order.getLocator(), order);
|
||||||
|
else
|
||||||
|
getObjectFilter().add(Tags.ORDER, order.getLocator(), order);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addOrUpdate(Activity activity) throws StrolchModelException {
|
||||||
|
DBC.PRE.assertNotNull("activity must not be null", activity);
|
||||||
|
if (hasActivity(activity.getType(), activity.getId()))
|
||||||
|
getObjectFilter().update(Tags.ACTIVITY, activity.getLocator(), activity);
|
||||||
|
else
|
||||||
|
getObjectFilter().add(Tags.ACTIVITY, activity.getLocator(), activity);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void add(Resource resource) throws StrolchModelException {
|
public void add(Resource resource) throws StrolchModelException {
|
||||||
DBC.PRE.assertNotNull("resource must not be null", resource);
|
DBC.PRE.assertNotNull("resource must not be null", resource);
|
||||||
|
|
|
@ -1125,6 +1125,39 @@ public interface StrolchTransaction extends AutoCloseable {
|
||||||
*/
|
*/
|
||||||
boolean hasActivity(String type, String id);
|
boolean hasActivity(String type, String id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add or update and thus persist the given {@link Resource} by calling the relevant {@link Command}
|
||||||
|
*
|
||||||
|
* @param resource
|
||||||
|
* the resource to add or update
|
||||||
|
*
|
||||||
|
* @throws StrolchModelException
|
||||||
|
* if the resource is null
|
||||||
|
*/
|
||||||
|
void addOrUpdate(Resource resource) throws StrolchModelException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add or update and thus persist the given {@link Order} by calling the relevant {@link Command}
|
||||||
|
*
|
||||||
|
* @param order
|
||||||
|
* the order to add or update
|
||||||
|
*
|
||||||
|
* @throws StrolchModelException
|
||||||
|
* if the order is null
|
||||||
|
*/
|
||||||
|
void addOrUpdate(Order order) throws StrolchModelException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add or update and thus persist the given {@link Activity} by calling the relevant {@link Command}
|
||||||
|
*
|
||||||
|
* @param activity
|
||||||
|
* the activity to add or update
|
||||||
|
*
|
||||||
|
* @throws StrolchModelException
|
||||||
|
* if the resource is null
|
||||||
|
*/
|
||||||
|
void addOrUpdate(Activity activity) throws StrolchModelException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds and thus persists the given {@link Resource} by calling the relevant {@link Command}
|
* Adds and thus persists the given {@link Resource} by calling the relevant {@link Command}
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in New Issue