Search in sources :

Example 1 with Tags

use of io.automatiko.engine.api.workflow.Tags in project automatiko-engine by automatiko-io.

the class AbstractProcessInstance method buildTags.

protected Tags buildTags() {
    return new Tags() {

        Collection<String> values = ((WorkflowProcessInstanceImpl) processInstance()).getTags().stream().map(t -> t.getValue()).collect(Collectors.toList());

        @Override
        public Collection<String> values() {
            return values;
        }

        @Override
        public boolean remove(String id) {
            WorkflowProcessInstanceImpl pi = (WorkflowProcessInstanceImpl) processInstance();
            boolean removed = pi.removedTag(id);
            removeOnFinish();
            return removed;
        }

        @Override
        public Tag get(String id) {
            WorkflowProcessInstanceImpl pi = (WorkflowProcessInstanceImpl) processInstance();
            return pi.getTags().stream().filter(t -> t.getId().equals(id)).findFirst().orElse(null);
        }

        @Override
        public void add(String value) {
            WorkflowProcessInstanceImpl pi = (WorkflowProcessInstanceImpl) processInstance();
            pi.addTag(value);
            removeOnFinish();
        }

        @Override
        public Collection<Tag> get() {
            WorkflowProcessInstanceImpl pi = (WorkflowProcessInstanceImpl) processInstance();
            return pi.getTags();
        }
    };
}
Also used : WorkflowProcessInstanceImpl(io.automatiko.engine.workflow.process.instance.impl.WorkflowProcessInstanceImpl) Collection(java.util.Collection) Tag(io.automatiko.engine.api.workflow.Tag) Tags(io.automatiko.engine.api.workflow.Tags)

Aggregations

Tag (io.automatiko.engine.api.workflow.Tag)1 Tags (io.automatiko.engine.api.workflow.Tags)1 WorkflowProcessInstanceImpl (io.automatiko.engine.workflow.process.instance.impl.WorkflowProcessInstanceImpl)1 Collection (java.util.Collection)1