[New] Adding value changes to actions on execution
This commit is contained in:
parent
b05c3db748
commit
93e099f101
|
@ -7,6 +7,8 @@ import li.strolch.model.Resource;
|
|||
import li.strolch.model.State;
|
||||
import li.strolch.model.activity.Action;
|
||||
import li.strolch.model.parameter.BooleanParameter;
|
||||
import li.strolch.model.timevalue.impl.FloatValue;
|
||||
import li.strolch.model.timevalue.impl.ValueChange;
|
||||
import li.strolch.persistence.api.StrolchTransaction;
|
||||
|
||||
/**
|
||||
|
@ -70,8 +72,10 @@ public class ReservationExection extends DurationExecution {
|
|||
|
||||
tx().lock(getResource(action));
|
||||
|
||||
// only do if reserve
|
||||
if (!action.getType().equals(TYPE_RESERVE) && !action.getType().equals(TYPE_RELEASE)) {
|
||||
// only do if reserve or release
|
||||
boolean isReserve = action.getType().equals(TYPE_RESERVE);
|
||||
boolean isRelease = action.getType().equals(TYPE_RELEASE);
|
||||
if (!isReserve && !isRelease) {
|
||||
// otherwise delegate to super class
|
||||
super.toExecution(action);
|
||||
|
||||
|
@ -92,8 +96,10 @@ public class ReservationExection extends DurationExecution {
|
|||
|
||||
tx().lock(getResource(action));
|
||||
|
||||
// only do if release
|
||||
if (!action.getType().equals(TYPE_RESERVE) && !action.getType().equals(TYPE_RELEASE)) {
|
||||
// only do if reserve or release
|
||||
boolean isReserve = action.getType().equals(TYPE_RESERVE);
|
||||
boolean isRelease = action.getType().equals(TYPE_RELEASE);
|
||||
if (!isReserve && !isRelease) {
|
||||
// otherwise delegate to super class
|
||||
super.toExecuted(action);
|
||||
|
||||
|
@ -102,6 +108,9 @@ public class ReservationExection extends DurationExecution {
|
|||
|
||||
setReservation(action);
|
||||
setActionState(action, State.EXECUTED);
|
||||
|
||||
FloatValue value = new FloatValue(isReserve ? 1.0D : 0.0D);
|
||||
action.addChange(new ValueChange<>(System.currentTimeMillis(), value, ""));
|
||||
}
|
||||
|
||||
public void setReservation(Action action) {
|
||||
|
|
|
@ -5,13 +5,15 @@ import li.strolch.handler.operationslog.LogMessage;
|
|||
import li.strolch.handler.operationslog.OperationsLog;
|
||||
import li.strolch.model.State;
|
||||
import li.strolch.model.activity.Action;
|
||||
import li.strolch.model.timevalue.impl.FloatValue;
|
||||
import li.strolch.model.timevalue.impl.ValueChange;
|
||||
import li.strolch.persistence.api.StrolchTransaction;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Simple Execution Policy which sets the state of the action depending on the method called.
|
||||
* </p>
|
||||
*
|
||||
*
|
||||
* @author Robert von Burg <eitch@eitchnet.ch>
|
||||
*/
|
||||
public class SimpleExecution extends ExecutionPolicy {
|
||||
|
@ -23,6 +25,9 @@ public class SimpleExecution extends ExecutionPolicy {
|
|||
@Override
|
||||
public void toExecution(Action action) {
|
||||
setActionState(action, State.EXECUTION);
|
||||
|
||||
FloatValue value = new FloatValue(1.0D);
|
||||
action.addChange(new ValueChange<>(System.currentTimeMillis(), value, ""));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -33,18 +38,27 @@ public class SimpleExecution extends ExecutionPolicy {
|
|||
@Override
|
||||
public void toExecuted(Action action) {
|
||||
setActionState(action, State.EXECUTED);
|
||||
|
||||
FloatValue value = new FloatValue(0.0D);
|
||||
action.addChange(new ValueChange<>(System.currentTimeMillis(), value, ""));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toStopped(Action action) {
|
||||
getDelayedExecutionTimer().cancel(action.getLocator());
|
||||
setActionState(action, State.STOPPED);
|
||||
|
||||
FloatValue value = new FloatValue(0.0D);
|
||||
action.addChange(new ValueChange<>(System.currentTimeMillis(), value, ""));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toError(Action action) {
|
||||
getDelayedExecutionTimer().cancel(action.getLocator());
|
||||
setActionState(action, State.ERROR);
|
||||
|
||||
FloatValue value = new FloatValue(0.0D);
|
||||
action.addChange(new ValueChange<>(System.currentTimeMillis(), value, ""));
|
||||
}
|
||||
|
||||
protected void addMessage(LogMessage message) {
|
||||
|
|
Loading…
Reference in New Issue