Search in sources :

Example 1 with AttributesDiff

use of io.lumeer.api.util.AttributesDiff in project engine by Lumeer.

the class TaskProcessingFacade method onUpdateLinkType.

public void onUpdateLinkType(@Observes final UpdateLinkType updateLinkType) {
    if (updateLinkType.getOriginalLinkType() == null || updateLinkType.getLinkType() == null) {
        return;
    }
    List<Task> tasks = new ArrayList<>();
    AttributesDiff attributesDiff = checkAttributesDiff(updateLinkType.getOriginalLinkType().getAttributes(), updateLinkType.getLinkType().getAttributes());
    String linkTypeId = updateLinkType.getOriginalLinkType().getId();
    attributesDiff.getRemovedIds().forEach(removedAttributeId -> functionFacade.onDeleteLinkAttribute(linkTypeId, removedAttributeId));
    attributesDiff.getRemovedFunction().forEach(removedAttributeId -> functionFacade.onDeleteLinkTypeFunction(linkTypeId, removedAttributeId));
    attributesDiff.getCreatedFunction().forEach(attribute -> tasks.add(functionFacade.createTaskForCreatedLinkFunction(updateLinkType.getLinkType(), attribute)));
    attributesDiff.getUpdatedFunction().forEach(attribute -> tasks.add(functionFacade.createTaskForUpdatedLinkFunction(updateLinkType.getLinkType(), attribute)));
    processTasks(tasks.toArray(new Task[0]));
}
Also used : FunctionTask(io.lumeer.core.task.FunctionTask) Task(io.lumeer.core.task.Task) RuleTask(io.lumeer.core.task.RuleTask) ArrayList(java.util.ArrayList) AttributeUtil.checkAttributesDiff(io.lumeer.api.util.AttributeUtil.checkAttributesDiff) AttributesDiff(io.lumeer.api.util.AttributesDiff)

Example 2 with AttributesDiff

use of io.lumeer.api.util.AttributesDiff in project engine by Lumeer.

the class TaskProcessingFacade method onUpdateCollection.

public void onUpdateCollection(@Observes final UpdateResource updateResource) {
    if (updateResource.getResource() == null || updateResource.getOriginalResource() == null || !(updateResource.getResource() instanceof Collection)) {
        return;
    }
    List<Task> tasks = new ArrayList<>();
    Collection original = (Collection) updateResource.getOriginalResource();
    Collection current = (Collection) updateResource.getResource();
    AttributesDiff attributesDiff = checkAttributesDiff(original.getAttributes(), current.getAttributes());
    attributesDiff.getRemovedIds().forEach(removedAttributeId -> functionFacade.onDeleteCollectionAttribute(original.getId(), removedAttributeId));
    attributesDiff.getRemovedFunction().forEach(removedAttributeId -> functionFacade.onDeleteCollectionFunction(original.getId(), removedAttributeId));
    attributesDiff.getCreatedFunction().forEach(attribute -> tasks.add(functionFacade.createTaskForCreatedFunction(current, attribute)));
    attributesDiff.getUpdatedFunction().forEach(attribute -> tasks.add(functionFacade.createTaskForUpdatedFunction(current, attribute)));
    processTasks(tasks.toArray(new Task[0]));
}
Also used : FunctionTask(io.lumeer.core.task.FunctionTask) Task(io.lumeer.core.task.Task) RuleTask(io.lumeer.core.task.RuleTask) ArrayList(java.util.ArrayList) Collection(io.lumeer.api.model.Collection) AttributeUtil.checkAttributesDiff(io.lumeer.api.util.AttributeUtil.checkAttributesDiff) AttributesDiff(io.lumeer.api.util.AttributesDiff)

Aggregations

AttributeUtil.checkAttributesDiff (io.lumeer.api.util.AttributeUtil.checkAttributesDiff)2 AttributesDiff (io.lumeer.api.util.AttributesDiff)2 FunctionTask (io.lumeer.core.task.FunctionTask)2 RuleTask (io.lumeer.core.task.RuleTask)2 Task (io.lumeer.core.task.Task)2 ArrayList (java.util.ArrayList)2 Collection (io.lumeer.api.model.Collection)1