[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.State;
|
||||||
import li.strolch.model.activity.Action;
|
import li.strolch.model.activity.Action;
|
||||||
import li.strolch.model.parameter.BooleanParameter;
|
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;
|
import li.strolch.persistence.api.StrolchTransaction;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -70,8 +72,10 @@ public class ReservationExection extends DurationExecution {
|
||||||
|
|
||||||
tx().lock(getResource(action));
|
tx().lock(getResource(action));
|
||||||
|
|
||||||
// only do if reserve
|
// only do if reserve or release
|
||||||
if (!action.getType().equals(TYPE_RESERVE) && !action.getType().equals(TYPE_RELEASE)) {
|
boolean isReserve = action.getType().equals(TYPE_RESERVE);
|
||||||
|
boolean isRelease = action.getType().equals(TYPE_RELEASE);
|
||||||
|
if (!isReserve && !isRelease) {
|
||||||
// otherwise delegate to super class
|
// otherwise delegate to super class
|
||||||
super.toExecution(action);
|
super.toExecution(action);
|
||||||
|
|
||||||
|
@ -92,8 +96,10 @@ public class ReservationExection extends DurationExecution {
|
||||||
|
|
||||||
tx().lock(getResource(action));
|
tx().lock(getResource(action));
|
||||||
|
|
||||||
// only do if release
|
// only do if reserve or release
|
||||||
if (!action.getType().equals(TYPE_RESERVE) && !action.getType().equals(TYPE_RELEASE)) {
|
boolean isReserve = action.getType().equals(TYPE_RESERVE);
|
||||||
|
boolean isRelease = action.getType().equals(TYPE_RELEASE);
|
||||||
|
if (!isReserve && !isRelease) {
|
||||||
// otherwise delegate to super class
|
// otherwise delegate to super class
|
||||||
super.toExecuted(action);
|
super.toExecuted(action);
|
||||||
|
|
||||||
|
@ -102,6 +108,9 @@ public class ReservationExection extends DurationExecution {
|
||||||
|
|
||||||
setReservation(action);
|
setReservation(action);
|
||||||
setActionState(action, State.EXECUTED);
|
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) {
|
public void setReservation(Action action) {
|
||||||
|
|
|
@ -5,6 +5,8 @@ import li.strolch.handler.operationslog.LogMessage;
|
||||||
import li.strolch.handler.operationslog.OperationsLog;
|
import li.strolch.handler.operationslog.OperationsLog;
|
||||||
import li.strolch.model.State;
|
import li.strolch.model.State;
|
||||||
import li.strolch.model.activity.Action;
|
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;
|
import li.strolch.persistence.api.StrolchTransaction;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -23,6 +25,9 @@ public class SimpleExecution extends ExecutionPolicy {
|
||||||
@Override
|
@Override
|
||||||
public void toExecution(Action action) {
|
public void toExecution(Action action) {
|
||||||
setActionState(action, State.EXECUTION);
|
setActionState(action, State.EXECUTION);
|
||||||
|
|
||||||
|
FloatValue value = new FloatValue(1.0D);
|
||||||
|
action.addChange(new ValueChange<>(System.currentTimeMillis(), value, ""));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -33,18 +38,27 @@ public class SimpleExecution extends ExecutionPolicy {
|
||||||
@Override
|
@Override
|
||||||
public void toExecuted(Action action) {
|
public void toExecuted(Action action) {
|
||||||
setActionState(action, State.EXECUTED);
|
setActionState(action, State.EXECUTED);
|
||||||
|
|
||||||
|
FloatValue value = new FloatValue(0.0D);
|
||||||
|
action.addChange(new ValueChange<>(System.currentTimeMillis(), value, ""));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void toStopped(Action action) {
|
public void toStopped(Action action) {
|
||||||
getDelayedExecutionTimer().cancel(action.getLocator());
|
getDelayedExecutionTimer().cancel(action.getLocator());
|
||||||
setActionState(action, State.STOPPED);
|
setActionState(action, State.STOPPED);
|
||||||
|
|
||||||
|
FloatValue value = new FloatValue(0.0D);
|
||||||
|
action.addChange(new ValueChange<>(System.currentTimeMillis(), value, ""));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void toError(Action action) {
|
public void toError(Action action) {
|
||||||
getDelayedExecutionTimer().cancel(action.getLocator());
|
getDelayedExecutionTimer().cancel(action.getLocator());
|
||||||
setActionState(action, State.ERROR);
|
setActionState(action, State.ERROR);
|
||||||
|
|
||||||
|
FloatValue value = new FloatValue(0.0D);
|
||||||
|
action.addChange(new ValueChange<>(System.currentTimeMillis(), value, ""));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void addMessage(LogMessage message) {
|
protected void addMessage(LogMessage message) {
|
||||||
|
|
Loading…
Reference in New Issue