Search in sources :

Example 1 with StringUtils

use of org.kie.workbench.common.stunner.core.util.StringUtils in project kie-wb-common by kiegroup.

the class GenericServiceTaskPropertyReader method getGenericServiceTask.

public GenericServiceTaskValue getGenericServiceTask() {
    GenericServiceTaskValue value = new GenericServiceTaskValue();
    final String implementation = Optional.ofNullable(CustomAttribute.serviceImplementation.of(task).get()).filter(StringUtils::nonEmpty).orElseGet(() -> task.getImplementation());
    value.setServiceImplementation(getServiceImplementation(implementation));
    final String operation = Optional.ofNullable(CustomAttribute.serviceOperation.of(task).get()).filter(StringUtils::nonEmpty).orElseGet(() -> Optional.ofNullable(task.getOperationRef()).map(Operation::getName).orElse(null));
    value.setServiceOperation(operation);
    value.setInMessageStructure(Optional.ofNullable(task.getOperationRef()).map(Operation::getInMessageRef).map(Message::getItemRef).map(ItemDefinition::getStructureRef).orElse(null));
    value.setOutMessagetructure(Optional.ofNullable(task.getOperationRef()).map(Operation::getOutMessageRef).map(Message::getItemRef).map(ItemDefinition::getStructureRef).orElse(null));
    final String serviceInterface = Optional.ofNullable(CustomAttribute.serviceInterface.of(task).get()).filter(StringUtils::nonEmpty).orElseGet(() -> Optional.ofNullable(task.getOperationRef()).map(Operation::eContainer).filter(container -> container instanceof Interface).map(container -> (Interface) container).map(Interface::getName).orElse(null));
    value.setServiceInterface(serviceInterface);
    return value;
}
Also used : Interface(org.eclipse.bpmn2.Interface) ItemDefinition(org.eclipse.bpmn2.ItemDefinition) CustomElement(org.kie.workbench.common.stunner.bpmn.backend.converters.customproperties.CustomElement) ServiceTask(org.eclipse.bpmn2.ServiceTask) BPMNDiagram(org.eclipse.bpmn2.di.BPMNDiagram) Message(org.eclipse.bpmn2.Message) Optional(java.util.Optional) Operation(org.eclipse.bpmn2.Operation) CustomAttribute(org.kie.workbench.common.stunner.bpmn.backend.converters.customproperties.CustomAttribute) StringUtils(org.kie.workbench.common.stunner.core.util.StringUtils) DefinitionResolver(org.kie.workbench.common.stunner.bpmn.backend.converters.tostunner.DefinitionResolver) GenericServiceTaskValue(org.kie.workbench.common.stunner.bpmn.definition.property.service.GenericServiceTaskValue) GenericServiceTaskValue(org.kie.workbench.common.stunner.bpmn.definition.property.service.GenericServiceTaskValue) ItemDefinition(org.eclipse.bpmn2.ItemDefinition) Operation(org.eclipse.bpmn2.Operation) Interface(org.eclipse.bpmn2.Interface)

Aggregations

Optional (java.util.Optional)1 Interface (org.eclipse.bpmn2.Interface)1 ItemDefinition (org.eclipse.bpmn2.ItemDefinition)1 Message (org.eclipse.bpmn2.Message)1 Operation (org.eclipse.bpmn2.Operation)1 ServiceTask (org.eclipse.bpmn2.ServiceTask)1 BPMNDiagram (org.eclipse.bpmn2.di.BPMNDiagram)1 CustomAttribute (org.kie.workbench.common.stunner.bpmn.backend.converters.customproperties.CustomAttribute)1 CustomElement (org.kie.workbench.common.stunner.bpmn.backend.converters.customproperties.CustomElement)1 DefinitionResolver (org.kie.workbench.common.stunner.bpmn.backend.converters.tostunner.DefinitionResolver)1 GenericServiceTaskValue (org.kie.workbench.common.stunner.bpmn.definition.property.service.GenericServiceTaskValue)1 StringUtils (org.kie.workbench.common.stunner.core.util.StringUtils)1