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]));
}
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]));
}
Aggregations