use of org.eclipse.bpmn2.Operation in project ddf by codice.
the class AbstractCswSource method canRetrieveResourceById.
/**
* Determine if the resource should be retrieved using a ResourceReader or by calling
* GetRecordById.
*/
private boolean canRetrieveResourceById() {
OperationsMetadata operationsMetadata = capabilities.getOperationsMetadata();
Operation getRecordByIdOp = getOperation(operationsMetadata, CswConstants.GET_RECORD_BY_ID);
if (getRecordByIdOp != null) {
DomainType getRecordByIdOutputSchemas = getParameter(getRecordByIdOp, CswConstants.OUTPUT_SCHEMA_PARAMETER);
if (getRecordByIdOutputSchemas != null && getRecordByIdOutputSchemas.getValue() != null && getRecordByIdOutputSchemas.getValue().contains(OCTET_STREAM_OUTPUT_SCHEMA)) {
return true;
}
}
return false;
}
use of org.eclipse.bpmn2.Operation in project ddf by codice.
the class TestCswSourceBase method configureMockCsw.
protected void configureMockCsw(int numRecordsReturned, long numRecordsMatched, String cswVersion) throws CswException {
ServiceIdentification mockServiceIdentification = mock(ServiceIdentification.class);
when(mockServiceIdentification.getAbstract()).thenReturn("myDescription");
CapabilitiesType mockCapabilities = mock(CapabilitiesType.class);
when(mockCapabilities.getVersion()).thenReturn(cswVersion);
when(mockCapabilities.getServiceIdentification()).thenReturn(mockServiceIdentification);
when(mockCapabilities.getServiceIdentification()).thenReturn(mockServiceIdentification);
when(mockCsw.getCapabilities(any(GetCapabilitiesRequest.class))).thenReturn(mockCapabilities);
FilterCapabilities mockFilterCapabilities = mock(FilterCapabilities.class);
when(mockCapabilities.getFilterCapabilities()).thenReturn(mockFilterCapabilities);
List<ComparisonOperatorType> comparisonOpsList = new ArrayList<>();
comparisonOpsList.add(ComparisonOperatorType.EQUAL_TO);
comparisonOpsList.add(ComparisonOperatorType.LIKE);
comparisonOpsList.add(ComparisonOperatorType.NOT_EQUAL_TO);
comparisonOpsList.add(ComparisonOperatorType.GREATER_THAN);
comparisonOpsList.add(ComparisonOperatorType.GREATER_THAN_EQUAL_TO);
comparisonOpsList.add(ComparisonOperatorType.LESS_THAN);
comparisonOpsList.add(ComparisonOperatorType.LESS_THAN_EQUAL_TO);
comparisonOpsList.add(ComparisonOperatorType.BETWEEN);
comparisonOpsList.add(ComparisonOperatorType.NULL_CHECK);
ComparisonOperatorsType comparisonOps = new ComparisonOperatorsType();
comparisonOps.setComparisonOperator(comparisonOpsList);
ScalarCapabilitiesType mockScalarCapabilities = mock(ScalarCapabilitiesType.class);
when(mockScalarCapabilities.getLogicalOperators()).thenReturn(mock(LogicalOperators.class));
mockScalarCapabilities.setComparisonOperators(comparisonOps);
when(mockScalarCapabilities.getComparisonOperators()).thenReturn(comparisonOps);
when(mockFilterCapabilities.getScalarCapabilities()).thenReturn(mockScalarCapabilities);
List<DomainType> getRecordsParameters = new ArrayList<>();
DomainType typeName = new DomainType();
typeName.setName(CswConstants.TYPE_NAME_PARAMETER);
typeName.setValue(Collections.singletonList("csw:Record"));
getRecordsParameters.add(typeName);
DomainType typeNames = new DomainType();
typeNames.setName(CswConstants.TYPE_NAMES_PARAMETER);
getRecordsParameters.add(typeNames);
DomainType getRecordsOutputSchema = new DomainType();
getRecordsOutputSchema.setName(CswConstants.OUTPUT_SCHEMA_PARAMETER);
getRecordsOutputSchema.getValue().add(CswConstants.CSW_OUTPUT_SCHEMA);
getRecordsParameters.add(getRecordsOutputSchema);
DomainType constraintLang = new DomainType();
constraintLang.setName(CswConstants.CONSTRAINT_LANGUAGE_PARAMETER);
constraintLang.setValue(Collections.singletonList(CswConstants.CONSTRAINT_LANGUAGE_FILTER));
getRecordsParameters.add(constraintLang);
DomainType outputFormat = new DomainType();
outputFormat.setName(CswConstants.OUTPUT_FORMAT_PARAMETER);
getRecordsParameters.add(outputFormat);
DomainType resultType = new DomainType();
resultType.setName(CswConstants.RESULT_TYPE_PARAMETER);
getRecordsParameters.add(resultType);
DomainType elementSetName = new DomainType();
elementSetName.setName(CswConstants.ELEMENT_SET_NAME_PARAMETER);
getRecordsParameters.add(elementSetName);
List<DomainType> getRecordByIdParameters = new ArrayList<>();
DomainType getRecordByIdOutputSchema = new DomainType();
getRecordByIdOutputSchema.setName(CswConstants.OUTPUT_SCHEMA_PARAMETER);
List<String> outputSchemas = new ArrayList<>();
outputSchemas.add(CswConstants.CSW_OUTPUT_SCHEMA);
getRecordByIdOutputSchema.setValue(outputSchemas);
getRecordByIdParameters.add(getRecordByIdOutputSchema);
Operation getRecords = new Operation();
getRecords.setName(CswConstants.GET_RECORDS);
getRecords.setParameter(getRecordsParameters);
Operation getRecordById = new Operation();
getRecordById.setName(CswConstants.GET_RECORD_BY_ID);
getRecordById.setParameter(getRecordByIdParameters);
List<Operation> operations = new ArrayList<>(2);
operations.add(getRecords);
operations.add(getRecordById);
OperationsMetadata mockOperationsMetadata = mock(OperationsMetadata.class);
mockOperationsMetadata.setOperation(operations);
when(mockCapabilities.getOperationsMetadata()).thenReturn(mockOperationsMetadata);
when(mockOperationsMetadata.getOperation()).thenReturn(operations);
if (numRecordsReturned > 0) {
List<Metacard> metacards = new ArrayList<>(numRecordsReturned);
for (int i = 1; i <= numRecordsReturned; i++) {
String id = "ID_" + String.valueOf(i);
MetacardImpl metacard = new MetacardImpl();
metacard.setId(id);
metacard.setContentTypeName("myContentType");
metacards.add(metacard);
}
SearchResultsType searchResults = mock(SearchResultsType.class);
when(searchResults.getNumberOfRecordsMatched()).thenReturn(BigInteger.valueOf(numRecordsMatched));
when(searchResults.getNumberOfRecordsReturned()).thenReturn(BigInteger.valueOf(numRecordsReturned));
CswRecordCollection mockCswRecordCollection = mock(CswRecordCollection.class);
when(mockCswRecordCollection.getCswRecords()).thenReturn(metacards);
when(mockCswRecordCollection.getNumberOfRecordsMatched()).thenReturn(numRecordsMatched);
when(mockCswRecordCollection.getNumberOfRecordsReturned()).thenReturn((long) numRecordsReturned);
when(mockCsw.getRecords(any(GetRecordsType.class))).thenReturn(mockCswRecordCollection);
}
}
use of org.eclipse.bpmn2.Operation in project kie-wb-common by kiegroup.
the class Bpmn2JsonUnmarshaller method revisitServiceTasksExecuteForLanes.
private void revisitServiceTasksExecuteForLanes(Lane lane, Definitions def, List<RootElement> rootElements, List<Interface> toAddInterfaces, List<Message> toAddMessages, List<ItemDefinition> toAddDefinitions) {
List<FlowNode> laneFlowNodes = lane.getFlowNodeRefs();
for (FlowElement fe : laneFlowNodes) {
if (fe instanceof ServiceTask) {
Iterator<FeatureMap.Entry> iter = fe.getAnyAttribute().iterator();
String serviceImplementation = null;
String serviceInterface = null;
String serviceOperation = null;
EStructuralFeature serviceInterfaceFeature = null;
EStructuralFeature serviceOperationFeature = null;
while (iter.hasNext()) {
FeatureMap.Entry entry = iter.next();
if (entry.getEStructuralFeature().getName().equals("serviceimplementation")) {
serviceImplementation = (String) entry.getValue();
}
if (entry.getEStructuralFeature().getName().equals("serviceoperation")) {
serviceOperation = (String) entry.getValue();
serviceOperationFeature = entry.getEStructuralFeature();
}
if (entry.getEStructuralFeature().getName().equals("serviceinterface")) {
serviceInterface = (String) entry.getValue();
serviceInterfaceFeature = entry.getEStructuralFeature();
}
}
boolean foundInterface = false;
Interface touseInterface = null;
if (serviceImplementation != null && serviceImplementation.equals("Java")) {
for (RootElement iroot : rootElements) {
if (iroot instanceof Interface && ((Interface) iroot).getName().equals(serviceInterface)) {
foundInterface = true;
touseInterface = (Interface) iroot;
break;
}
}
if (!foundInterface) {
for (Interface toadd : toAddInterfaces) {
if (toadd.getName() != null && toadd.getName().equals(serviceInterface)) {
foundInterface = true;
touseInterface = toadd;
break;
}
}
}
} else if (serviceImplementation != null && serviceImplementation.equals("##WebService")) {
for (RootElement iroot : rootElements) {
if (iroot instanceof Interface && ((Interface) iroot).getImplementationRef().equals(serviceInterface)) {
foundInterface = true;
touseInterface = (Interface) iroot;
break;
}
}
if (!foundInterface) {
for (Interface toadd : toAddInterfaces) {
if (toadd.getImplementationRef().equals(serviceInterface)) {
foundInterface = true;
touseInterface = toadd;
break;
}
}
}
}
if (!foundInterface) {
touseInterface = Bpmn2Factory.eINSTANCE.createInterface();
if (serviceInterface == null || serviceInterface.length() == 0) {
serviceInterface = fe.getId() + "_ServiceInterface";
if (serviceInterfaceFeature != null) {
fe.getAnyAttribute().set(serviceInterfaceFeature, serviceInterface);
}
}
touseInterface.setName(serviceInterface);
touseInterface.setImplementationRef(serviceInterface);
touseInterface.setId(fe.getId() + "_ServiceInterface");
toAddInterfaces.add(touseInterface);
}
if (serviceOperation != null) {
boolean foundOperation = false;
for (Operation oper : touseInterface.getOperations()) {
if (serviceImplementation != null && serviceImplementation.equals("Java")) {
if (oper.getName().equals(serviceOperation)) {
foundOperation = true;
break;
}
} else if (serviceImplementation != null && serviceImplementation.equals("##WebService")) {
if (oper.getImplementationRef().equals(serviceOperation)) {
foundOperation = true;
break;
}
}
}
if (!foundOperation) {
Operation touseOperation = Bpmn2Factory.eINSTANCE.createOperation();
if (serviceOperation == null || serviceOperation.length() == 0) {
serviceOperation = fe.getId() + "_ServiceOperation";
if (serviceOperationFeature != null) {
fe.getAnyAttribute().set(serviceOperationFeature, serviceOperation);
}
}
touseOperation.setId(fe.getId() + "_ServiceOperation");
touseOperation.setName(serviceOperation);
touseOperation.setImplementationRef(serviceOperation);
Message message = Bpmn2Factory.eINSTANCE.createMessage();
message.setId(fe.getId() + "_InMessage");
ItemDefinition itemdef = Bpmn2Factory.eINSTANCE.createItemDefinition();
itemdef.setId(message.getId() + "Type");
message.setItemRef(itemdef);
toAddDefinitions.add(itemdef);
toAddMessages.add(message);
touseOperation.setInMessageRef(message);
touseInterface.getOperations().add(touseOperation);
((ServiceTask) fe).setOperationRef(touseOperation);
}
}
} else if (fe instanceof FlowElementsContainer) {
revisitServiceTasksExecute((FlowElementsContainer) fe, rootElements, toAddInterfaces, toAddMessages, toAddDefinitions);
}
}
}
use of org.eclipse.bpmn2.Operation in project kie-wb-common by kiegroup.
the class Bpmn2JsonUnmarshaller method revisitServiceTasksExecute.
private void revisitServiceTasksExecute(FlowElementsContainer container, List<RootElement> rootElements, List<Interface> toAddInterfaces, List<Message> toAddMessages, List<ItemDefinition> toAddDefinitions) {
List<FlowElement> flowElements = container.getFlowElements();
for (FlowElement fe : flowElements) {
if (fe instanceof ServiceTask) {
Iterator<FeatureMap.Entry> iter = fe.getAnyAttribute().iterator();
String serviceImplementation = null;
String serviceInterface = null;
String serviceOperation = null;
EStructuralFeature serviceInterfaceFeature = null;
EStructuralFeature serviceOperationFeature = null;
while (iter.hasNext()) {
FeatureMap.Entry entry = iter.next();
if (entry.getEStructuralFeature().getName().equals("serviceimplementation")) {
serviceImplementation = (String) entry.getValue();
}
if (entry.getEStructuralFeature().getName().equals("serviceoperation")) {
serviceOperation = (String) entry.getValue();
serviceOperationFeature = entry.getEStructuralFeature();
}
if (entry.getEStructuralFeature().getName().equals("serviceinterface")) {
serviceInterface = (String) entry.getValue();
serviceInterfaceFeature = entry.getEStructuralFeature();
}
}
boolean foundInterface = false;
Interface touseInterface = null;
if (serviceImplementation != null && serviceImplementation.equals("Java")) {
for (RootElement iroot : rootElements) {
if (iroot instanceof Interface && ((Interface) iroot).getName().equals(serviceInterface)) {
foundInterface = true;
touseInterface = (Interface) iroot;
break;
}
}
if (!foundInterface) {
for (Interface toadd : toAddInterfaces) {
if (toadd.getName() != null && toadd.getName().equals(serviceInterface)) {
foundInterface = true;
touseInterface = toadd;
break;
}
}
}
} else if (serviceImplementation != null && serviceImplementation.equals("##WebService")) {
for (RootElement iroot : rootElements) {
if (iroot instanceof Interface && ((Interface) iroot).getImplementationRef().equals(serviceInterface)) {
foundInterface = true;
touseInterface = (Interface) iroot;
break;
}
}
if (!foundInterface) {
for (Interface toadd : toAddInterfaces) {
if (toadd.getImplementationRef().equals(serviceInterface)) {
foundInterface = true;
touseInterface = toadd;
break;
}
}
}
}
if (!foundInterface) {
touseInterface = Bpmn2Factory.eINSTANCE.createInterface();
if (serviceInterface == null || serviceInterface.length() == 0) {
serviceInterface = fe.getId() + "_ServiceInterface";
if (serviceInterfaceFeature != null) {
fe.getAnyAttribute().set(serviceInterfaceFeature, serviceInterface);
}
}
touseInterface.setName(serviceInterface);
touseInterface.setImplementationRef(serviceInterface);
touseInterface.setId(fe.getId() + "_ServiceInterface");
toAddInterfaces.add(touseInterface);
}
if (serviceOperation != null) {
boolean foundOperation = false;
for (Operation oper : touseInterface.getOperations()) {
if (serviceImplementation != null && serviceImplementation.equals("Java")) {
if (oper.getName().equals(serviceOperation)) {
foundOperation = true;
break;
}
} else if (serviceImplementation != null && serviceImplementation.equals("##WebService")) {
if (oper.getImplementationRef().equals(serviceOperation)) {
foundOperation = true;
break;
}
}
}
if (!foundOperation) {
Operation touseOperation = Bpmn2Factory.eINSTANCE.createOperation();
if (serviceOperation == null || serviceOperation.length() == 0) {
serviceOperation = fe.getId() + "_ServiceOperation";
if (serviceOperationFeature != null) {
fe.getAnyAttribute().set(serviceOperationFeature, serviceOperation);
}
}
touseOperation.setId(fe.getId() + "_ServiceOperation");
touseOperation.setName(serviceOperation);
touseOperation.setImplementationRef(serviceOperation);
Message message = Bpmn2Factory.eINSTANCE.createMessage();
message.setId(fe.getId() + "_InMessage");
ItemDefinition itemdef = Bpmn2Factory.eINSTANCE.createItemDefinition();
itemdef.setId(message.getId() + "Type");
message.setItemRef(itemdef);
toAddDefinitions.add(itemdef);
toAddMessages.add(message);
touseOperation.setInMessageRef(message);
touseInterface.getOperations().add(touseOperation);
((ServiceTask) fe).setOperationRef(touseOperation);
}
}
} else if (fe instanceof FlowElementsContainer) {
revisitServiceTasksExecute((FlowElementsContainer) fe, rootElements, toAddInterfaces, toAddMessages, toAddDefinitions);
}
}
}
Aggregations