* @param stateChangeMsg the state change message
*/
public void handleAutomationCompositionStateChange(AutomationCompositionStateChange stateChangeMsg) {
- if (stateChangeMsg.getAutomationCompositionId() == null) {
- return;
- }
-
var automationComposition = cacheProvider.getAutomationComposition(stateChangeMsg.getAutomationCompositionId());
if (automationComposition == null) {
* @param migrationMsg the AutomationCompositionMigration
*/
public void handleAutomationCompositionMigration(AutomationCompositionMigration migrationMsg) {
- if (migrationMsg.getAutomationCompositionId() == null || migrationMsg.getCompositionTargetId() == null) {
- return;
- }
-
var automationComposition = cacheProvider.getAutomationComposition(migrationMsg.getAutomationCompositionId());
if (automationComposition == null) {
LOGGER.debug("Automation composition {} does not use this participant",
}
if (!SubState.NONE.equals(element.getSubState())) {
- handleSubState(automationComposition, element, stateChangeResult);
+ if (!StateChangeResult.FAILED.equals(stateChangeResult)) {
+ element.setSubState(SubState.NONE);
+ }
} else if (deployState != null) {
- handleDeployState(automationComposition, element, deployState, stateChangeResult);
+ element.setDeployState(deployState);
+ element.setLockState(
+ DeployState.DEPLOYED.equals(element.getDeployState()) ? LockState.LOCKED : LockState.NONE);
}
if (lockState != null) {
- handleLockState(automationComposition, element, lockState, stateChangeResult);
+ element.setLockState(lockState);
}
var acStateChangeAck = createAutomationCompositionDeployAck();
return acStateChangeAck;
}
- private void handleDeployState(AutomationComposition automationComposition, AutomationCompositionElement element,
- DeployState deployState, StateChangeResult stateChangeResult) {
- element.setDeployState(deployState);
- element.setLockState(DeployState.DEPLOYED.equals(element.getDeployState()) ? LockState.LOCKED : LockState.NONE);
- if (StateChangeResult.FAILED.equals(stateChangeResult)) {
- return;
- }
- var checkOpt = automationComposition.getElements().values().stream()
- .filter(acElement -> !deployState.equals(acElement.getDeployState())).findAny();
- if (checkOpt.isEmpty()) {
- if (DeployState.DEPLOYED.equals(automationComposition.getDeployState())
- && automationComposition.getCompositionTargetId() != null) {
- // migration scenario
- automationComposition.setCompositionId(automationComposition.getCompositionTargetId());
- automationComposition.setCompositionTargetId(null);
- }
- automationComposition.setDeployState(deployState);
- automationComposition.setLockState(element.getLockState());
- automationComposition.setSubState(SubState.NONE);
-
- if (DeployState.DELETED.equals(deployState)) {
- cacheProvider.removeAutomationComposition(automationComposition.getInstanceId());
- }
- }
- }
-
- private void handleLockState(AutomationComposition automationComposition, AutomationCompositionElement element,
- LockState lockState, StateChangeResult stateChangeResult) {
- element.setLockState(lockState);
- if (StateChangeResult.FAILED.equals(stateChangeResult)) {
- return;
- }
- var checkOpt = automationComposition.getElements().values().stream()
- .filter(acElement -> !lockState.equals(acElement.getLockState())).findAny();
- if (checkOpt.isEmpty()) {
- automationComposition.setLockState(lockState);
- automationComposition.setSubState(SubState.NONE);
- }
- }
-
- private void handleSubState(AutomationComposition automationComposition, AutomationCompositionElement element,
- StateChangeResult stateChangeResult) {
- if (StateChangeResult.FAILED.equals(stateChangeResult)) {
- return;
- }
- element.setSubState(SubState.NONE);
- var checkOpt = automationComposition.getElements().values().stream()
- .filter(acElement -> !SubState.NONE.equals(acElement.getSubState())).findAny();
- if (checkOpt.isEmpty()) {
- automationComposition.setSubState(SubState.NONE);
- }
- }
-
/**
* Send Ac Element Info.
*