Search in sources :

Example 1 with Task

use of io.lumeer.core.task.Task in project engine by Lumeer.

the class TaskProcessingFacade method onCreateLink.

public void onCreateLink(@Observes final CreateLinkInstance createLinkEvent) {
    List<Task> tasks = linkCreatedTasks(new LinkInstance(createLinkEvent.getLinkInstance()));
    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) CreateLinkInstance(io.lumeer.engine.api.event.CreateLinkInstance) LinkInstance(io.lumeer.api.model.LinkInstance) RemoveLinkInstance(io.lumeer.engine.api.event.RemoveLinkInstance) UpdateLinkInstance(io.lumeer.engine.api.event.UpdateLinkInstance)

Example 2 with Task

use of io.lumeer.core.task.Task in project engine by Lumeer.

the class TaskProcessingFacade method setParentForLatestTask.

private void setParentForLatestTask(Task task, Task newParent) {
    Task currentTask = task;
    while (currentTask.getParent() != null) {
        currentTask = currentTask.getParent();
    }
    currentTask.setParent(newParent);
}
Also used : FunctionTask(io.lumeer.core.task.FunctionTask) Task(io.lumeer.core.task.Task) RuleTask(io.lumeer.core.task.RuleTask)

Example 3 with Task

use of io.lumeer.core.task.Task 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 4 with Task

use of io.lumeer.core.task.Task in project engine by Lumeer.

the class TaskProcessingFacade method runRule.

public void runRule(final Collection collection, final String ruleName, final Document document, final String actionName) {
    if (collection != null && document != null) {
        Optional<RuleTask> task = createRuleTask(collection, ruleName, null, document);
        Task t = task.orElse(null);
        while (t != null) {
            if (t instanceof RuleTask) {
                ((RuleTask) t).setActionName(actionName);
            }
            t = t.getParent();
        }
        task.ifPresent(this::processTasks);
    }
}
Also used : FunctionTask(io.lumeer.core.task.FunctionTask) Task(io.lumeer.core.task.Task) RuleTask(io.lumeer.core.task.RuleTask) RuleTask(io.lumeer.core.task.RuleTask)

Example 5 with Task

use of io.lumeer.core.task.Task in project engine by Lumeer.

the class TaskProcessingFacade method onCreateDocument.

public void onCreateDocument(@Observes final CreateDocument createDocument) {
    List<Task> tasks = documentCreatedTasks(new Document(createDocument.getDocument()));
    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) Document(io.lumeer.api.model.Document) RemoveDocument(io.lumeer.engine.api.event.RemoveDocument) CreateDocument(io.lumeer.engine.api.event.CreateDocument) UpdateDocument(io.lumeer.engine.api.event.UpdateDocument)

Aggregations

FunctionTask (io.lumeer.core.task.FunctionTask)7 RuleTask (io.lumeer.core.task.RuleTask)7 Task (io.lumeer.core.task.Task)7 AttributeUtil.checkAttributesDiff (io.lumeer.api.util.AttributeUtil.checkAttributesDiff)2 AttributesDiff (io.lumeer.api.util.AttributesDiff)2 ArrayList (java.util.ArrayList)2 Collection (io.lumeer.api.model.Collection)1 Document (io.lumeer.api.model.Document)1 LinkInstance (io.lumeer.api.model.LinkInstance)1 CreateDocument (io.lumeer.engine.api.event.CreateDocument)1 CreateLinkInstance (io.lumeer.engine.api.event.CreateLinkInstance)1 RemoveDocument (io.lumeer.engine.api.event.RemoveDocument)1 RemoveLinkInstance (io.lumeer.engine.api.event.RemoveLinkInstance)1 UpdateDocument (io.lumeer.engine.api.event.UpdateDocument)1 UpdateLinkInstance (io.lumeer.engine.api.event.UpdateLinkInstance)1