protected ActionDescription.Builder updateActionDescription(final ActionDescription.Builder actionDescription) throws CouldNotPerformException { ServiceStateDescription.Builder serviceStateDescription = actionDescription.getServiceStateDescriptionBuilder(); serviceStateDescription.setUnitId(getId()); actionDescription.setDescription(actionDescription.getDescription().replace(ActionDescriptionProcessor.LABEL_KEY, getLabel())); //TODO: update USER key with authentication, should not be needed anymore in release 2.0 because the location remote // should use the applyAction method of the AbstractUnitRemote which does it. actionDescription.setLabel(actionDescription.getLabel().replace(ActionDescriptionProcessor.LABEL_KEY, getLabel())); return actionDescription; }
ResourceAllocation.Builder resourceAllocation = actionDescription.getResourceAllocationBuilder(); serviceStateDescription.setUnitId(getId()); resourceAllocation.addResourceIds(ScopeGenerator.generateStringRep(getScope()));
serviceStateDescription.setUnitId(unitRemote.getId().toString()); serviceStateDescription.setUnitType(unitType);
for (ServiceDescription serviceDescription : getUnitTemplate().getServiceDescriptionList()) { try { ServiceStateDescription.Builder serviceStateDescription = ServiceStateDescription.newBuilder().setServiceType(serviceDescription.getType()).setUnitId(getId()); serviceStateDescription.setUnitId(getId()); serviceStateDescription.setUnitType(getUnitTemplate().getType()); serviceStateDescription.setServiceType(serviceDescription.getType());
public Consumer(final UnitController<?,?> unitController) { this.active = false; this.serviceStateObserver = (Observer) (final Observable source, final Object data) -> { try { ActionDescription responsibleAction = Services.getResponsibleAction(((GeneratedMessage) data)); // build consumer action out of responsible action ActionDescription.Builder consumerActionBuilder = responsibleAction.toBuilder(); consumerActionBuilder.getServiceStateDescriptionBuilder().setUnitId(unitController.getId()); consumerActionBuilder.getServiceStateDescriptionBuilder().setUnitType(unitController.getUnitType()); // apply new action unitController.applyAction(consumerActionBuilder.build()); } catch (CouldNotPerformException ex) { ExceptionPrinter.printHistory("Could not consume update!", ex, LOGGER); } }; }
private ActionDescription updateActionDescriptionForUnit(ActionDescription actionDescription, UnitRemote unitRemote) throws CouldNotPerformException { // create new builder and copy fields ActionDescription.Builder unitActionDescription = ActionDescription.newBuilder(actionDescription); // get a new resource allocation id ActionDescriptionProcessor.updateResourceAllocationId(unitActionDescription); // update the action chain ActionDescriptionProcessor.updateActionChain(unitActionDescription, actionDescription); // resource ids should only contain that unit ResourceAllocation.Builder unitResourceAllocation = unitActionDescription.getResourceAllocationBuilder(); unitResourceAllocation.clearResourceIds(); unitResourceAllocation.addResourceIds(ScopeGenerator.generateStringRep(unitRemote.getScope())); // update the id in the serviceStateDescription to that of the unit ServiceStateDescription.Builder serviceStateDescription = unitActionDescription.getServiceStateDescriptionBuilder(); serviceStateDescription.setUnitId((String) unitRemote.getId()); return unitActionDescription.build(); }