Search in sources :

Example 6 with HumanTaskWorkItem

use of io.automatiko.engine.api.runtime.process.HumanTaskWorkItem in project automatiko-engine by automatiko-io.

the class HumanTaskNodeInstance method triggerCompleted.

public void triggerCompleted(WorkItem workItem) {
    String swimlaneName = getHumanTaskNode().getSwimlane();
    SwimlaneContextInstance swimlaneContextInstance = getSwimlaneContextInstance(swimlaneName);
    if (swimlaneContextInstance != null) {
        String newActorId = (workItem instanceof HumanTaskWorkItem) ? ((HumanTaskWorkItem) workItem).getActualOwner() : (String) workItem.getParameter(ACTOR_ID);
        if (newActorId != null) {
            swimlaneContextInstance.setActorId(swimlaneName, newActorId);
        }
    }
    super.triggerCompleted(workItem);
}
Also used : HumanTaskWorkItem(io.automatiko.engine.api.runtime.process.HumanTaskWorkItem) SwimlaneContextInstance(io.automatiko.engine.workflow.base.instance.context.swimlane.SwimlaneContextInstance)

Example 7 with HumanTaskWorkItem

use of io.automatiko.engine.api.runtime.process.HumanTaskWorkItem in project automatiko-engine by automatiko-io.

the class WebSocketEventPublisher method publish.

@Override
public void publish(DataEvent<?> event) {
    if (event instanceof ProcessInstanceDataEvent && !config.instance().orElse(true)) {
        LOGGER.debug("Skipping process instance event as the publisher should not deal with instances");
        return;
    } else if (event instanceof UserTaskInstanceDataEvent && !config.tasks().orElse(true)) {
        LOGGER.debug("Skipping user task event as the publisher should not deal with tasks");
        return;
    }
    String text;
    try {
        text = json.writeValueAsString(event);
        for (Session session : sessions.values()) {
            String filter = (String) session.getUserProperties().get("atk_filter");
            if (filter != null && !filter.matches(event.getType())) {
                continue;
            }
            boolean allowed = true;
            IdentityProvider identityProvider = (IdentityProvider) session.getUserProperties().get("atk_identity");
            if (event instanceof ProcessInstanceDataEvent) {
                List<String> visibleTo = ((ProcessInstanceDataEvent) event).getData().getVisibleTo();
                allowed = visibleTo.isEmpty() || visibleTo.contains(identityProvider.getName()) || visibleTo.stream().anyMatch(item -> identityProvider.getRoles().contains(item));
            } else if (event instanceof UserTaskInstanceDataEvent) {
                HumanTaskWorkItem workItem = ((UserTaskInstanceDataEvent) event).getData().sourceInstance();
                allowed = workItem.enforce(SecurityPolicy.of(identityProvider));
            }
            if (allowed) {
                session.getAsyncRemote().sendText(text);
            }
        }
    } catch (Exception e) {
        LOGGER.error("Unexpected error when publishing websocket event", e);
    }
}
Also used : HumanTaskWorkItem(io.automatiko.engine.api.runtime.process.HumanTaskWorkItem) IdentityProvider(io.automatiko.engine.api.auth.IdentityProvider) UserTaskInstanceDataEvent(io.automatiko.engine.services.event.UserTaskInstanceDataEvent) ProcessInstanceDataEvent(io.automatiko.engine.services.event.ProcessInstanceDataEvent) Session(javax.websocket.Session)

Aggregations

HumanTaskWorkItem (io.automatiko.engine.api.runtime.process.HumanTaskWorkItem)7 IdentityProvider (io.automatiko.engine.api.auth.IdentityProvider)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 AccessPolicy (io.automatiko.engine.api.auth.AccessPolicy)1 SecurityPolicy (io.automatiko.engine.api.auth.SecurityPolicy)1 WorkflowProcessInstance (io.automatiko.engine.api.runtime.process.WorkflowProcessInstance)1 GroupedNamedDataType (io.automatiko.engine.api.workflow.GroupedNamedDataType)1 IOEventDescription (io.automatiko.engine.api.workflow.IOEventDescription)1 NamedDataType (io.automatiko.engine.api.workflow.NamedDataType)1 ProcessInstance (io.automatiko.engine.api.workflow.ProcessInstance)1 ProcessInstanceDataEvent (io.automatiko.engine.services.event.ProcessInstanceDataEvent)1 UserTaskInstanceDataEvent (io.automatiko.engine.services.event.UserTaskInstanceDataEvent)1 AbstractProcessInstance (io.automatiko.engine.workflow.AbstractProcessInstance)1 ParameterDefinition (io.automatiko.engine.workflow.base.core.ParameterDefinition)1 SwimlaneContextInstance (io.automatiko.engine.workflow.base.instance.context.swimlane.SwimlaneContextInstance)1 HumanTaskWorkItemImpl (io.automatiko.engine.workflow.base.instance.impl.humantask.HumanTaskWorkItemImpl)1 WorkflowProcessInstance (io.automatiko.engine.workflow.process.instance.WorkflowProcessInstance)1 WorkflowProcessInstanceImpl (io.automatiko.engine.workflow.process.instance.impl.WorkflowProcessInstanceImpl)1 HumanTaskNodeInstance (io.automatiko.engine.workflow.process.instance.node.HumanTaskNodeInstance)1