use of io.automatiko.engine.workflow.base.instance.impl.humantask.HumanTaskWorkItemImpl in project automatiko-engine by automatiko-io.
the class AbstractProtobufProcessInstanceMarshaller method readHumanTaskWorkItem.
public static HumanTaskWorkItem readHumanTaskWorkItem(WorkflowProcessInstance processInstance, MarshallerReaderContext context, AutomatikoMessages.HumanTaskWorkItem _workItem) throws IOException {
HumanTaskWorkItemImpl workItem = new HumanTaskWorkItemImpl();
workItem.setId(_workItem.getId());
workItem.setProcessInstanceId(_workItem.getProcessInstancesId());
workItem.setName(_workItem.getName());
workItem.setState(_workItem.getState());
workItem.setDeploymentId(_workItem.getDeploymentId());
workItem.setNodeId(_workItem.getNodeId());
workItem.setNodeInstanceId(_workItem.getNodeInstanceId());
workItem.setPhaseId(_workItem.getPhaseId());
workItem.setPhaseStatus(_workItem.getPhaseStatus());
workItem.setStartDate(new Date(_workItem.getStartDate()));
workItem.setProcessInstance(processInstance);
if (_workItem.getCompleteDate() > 0) {
workItem.setCompleteDate(new Date(_workItem.getCompleteDate()));
}
if (_workItem.getTaskName() != null) {
workItem.setTaskName(_workItem.getTaskName());
}
if (_workItem.getTaskDescription() != null) {
workItem.setTaskDescription(_workItem.getTaskDescription());
}
if (_workItem.getTaskPriority() != null) {
workItem.setTaskPriority(_workItem.getTaskPriority());
}
if (_workItem.getTaskReferenceName() != null) {
workItem.setReferenceName(_workItem.getTaskReferenceName());
}
if (_workItem.getActualOwner() != null) {
workItem.setActualOwner(_workItem.getActualOwner());
}
for (String item : _workItem.getAdminGroupsList()) {
workItem.getAdminGroups().add(item);
}
for (String item : _workItem.getAdminUsersList()) {
workItem.getAdminUsers().add(item);
}
for (String item : _workItem.getPotGroupsList()) {
workItem.getPotentialGroups().add(item);
}
for (String item : _workItem.getPotUsersList()) {
workItem.getPotentialUsers().add(item);
}
for (String item : _workItem.getExcludedUsersList()) {
workItem.getExcludedUsers().add(item);
}
for (AutomatikoMessages.Variable _variable : _workItem.getVariableList()) {
try {
Object value = ProtobufProcessMarshaller.unmarshallVariableValue(context, _variable);
workItem.setParameter(_variable.getName(), value);
} catch (ClassNotFoundException e) {
throw new IllegalArgumentException(e);
}
}
return workItem;
}
use of io.automatiko.engine.workflow.base.instance.impl.humantask.HumanTaskWorkItemImpl in project automatiko-engine by automatiko-io.
the class TestWorkItemHandler method executeWorkItem.
public void executeWorkItem(WorkItem workItem, WorkItemManager manager) {
workItems.add(workItem);
if (workItem instanceof HumanTaskWorkItem) {
HumanTaskWorkItemImpl humanTaskWorkItem = (HumanTaskWorkItemImpl) workItem;
humanTaskWorkItem.setPhaseId(Active.ID);
humanTaskWorkItem.setPhaseStatus(Active.STATUS);
}
}
use of io.automatiko.engine.workflow.base.instance.impl.humantask.HumanTaskWorkItemImpl in project automatiko-engine by automatiko-io.
the class HumanTaskNodeInstance method createWorkItem.
protected WorkItem createWorkItem(WorkItemNode workItemNode) {
HumanTaskWorkItemImpl workItem = (HumanTaskWorkItemImpl) super.createWorkItem(workItemNode);
String actorId = assignWorkItem(workItem);
if (actorId != null) {
workItem.setParameter(ACTOR_ID, actorId);
}
workItem.setTaskName((String) workItem.getParameter("NodeName"));
workItem.setTaskDescription((String) workItem.getParameter("Description"));
workItem.setTaskPriority(String.valueOf(workItem.getParameter("Priority")));
workItem.setReferenceName((String) workItem.getParameter("TaskName"));
workItem.setReferenceId(buildReferenceId());
workItem.setReferenceId(buildReferenceId());
return workItem;
}
use of io.automatiko.engine.workflow.base.instance.impl.humantask.HumanTaskWorkItemImpl in project automatiko-engine by automatiko-io.
the class HumanTaskNodeInstance method assignWorkItem.
protected String assignWorkItem(WorkItem workItem) {
String actorId = null;
// if this human task node is part of a swimlane, check whether an actor
// has already been assigned to this swimlane
String swimlaneName = getHumanTaskNode().getSwimlane();
SwimlaneContextInstance swimlaneContextInstance = getSwimlaneContextInstance(swimlaneName);
if (swimlaneContextInstance != null) {
actorId = swimlaneContextInstance.getActorId(swimlaneName);
((WorkItemImpl) workItem).setParameter("SwimlaneActorId", actorId);
}
// actor is specified for this human task
if (actorId == null) {
actorId = (String) workItem.getParameter(ACTOR_ID);
if (actorId != null && swimlaneContextInstance != null && actorId.split(separator).length == 1) {
swimlaneContextInstance.setActorId(swimlaneName, actorId);
((WorkItemImpl) workItem).setParameter("SwimlaneActorId", actorId);
}
}
processAssigment(ACTOR_ID, workItem, ((HumanTaskWorkItemImpl) workItem).getPotentialUsers());
processAssigment(GROUP_ID, workItem, ((HumanTaskWorkItemImpl) workItem).getPotentialGroups());
processAssigment(GROUPS, workItem, ((HumanTaskWorkItemImpl) workItem).getPotentialGroups());
processAssigment(EXCLUDED_OWNER_ID, workItem, ((HumanTaskWorkItemImpl) workItem).getExcludedUsers());
processAssigment(BUSINESSADMINISTRATOR_ID, workItem, ((HumanTaskWorkItemImpl) workItem).getAdminUsers());
processAssigment(BUSINESSADMINISTRATOR_GROUP_ID, workItem, ((HumanTaskWorkItemImpl) workItem).getAdminGroups());
// parameter
return (String) workItem.getParameter(ACTOR_ID);
}
use of io.automatiko.engine.workflow.base.instance.impl.humantask.HumanTaskWorkItemImpl in project automatiko-engine by automatiko-io.
the class PredictionAwareHumanTaskLifeCycle method transitionTo.
@Override
public Map<String, Object> transitionTo(WorkItem workItem, WorkItemManager manager, Transition<Map<String, Object>> transition) {
LifeCyclePhase targetPhase = phaseById(transition.phase());
if (targetPhase == null) {
logger.debug("Target life cycle phase '{}' does not exist in {}", transition.phase(), this.getClass().getSimpleName());
throw new InvalidLifeCyclePhaseException(transition.phase());
}
HumanTaskWorkItemImpl humanTaskWorkItem = (HumanTaskWorkItemImpl) workItem;
if (targetPhase.id().equals(Active.ID)) {
PredictionOutcome outcome = predictionService.predict(workItem, workItem.getParameters());
logger.debug("Prediction service returned confidence level {} for work item {}", outcome.getConfidenceLevel(), humanTaskWorkItem.getId());
if (outcome.isCertain()) {
humanTaskWorkItem.getResults().putAll(outcome.getData());
logger.debug("Prediction service is certain (confidence level {}) on the outputs, completing work item {}", outcome.getConfidenceLevel(), humanTaskWorkItem.getId());
((DefaultWorkItemManager) manager).internalCompleteWorkItem(humanTaskWorkItem);
return outcome.getData();
} else if (outcome.isPresent()) {
logger.debug("Prediction service is NOT certain (confidence level {}) on the outputs, setting recommended outputs on work item {}", outcome.getConfidenceLevel(), humanTaskWorkItem.getId());
humanTaskWorkItem.getResults().putAll(outcome.getData());
}
}
// prediction service does work only on activating tasks
Map<String, Object> data = super.transitionTo(workItem, manager, transition);
if (targetPhase.id().equals(Complete.ID)) {
// upon actual transition train the data if it's completion phase
predictionService.train(humanTaskWorkItem, workItem.getParameters(), data);
}
return data;
}
Aggregations