use of org.wso2.siddhi.core.stream.input.source.Source in project carbon-business-process by wso2.
the class ActivityImpl method processSubActivities.
/**
* Get the subactivites in the bpel process
* Processes the subActivities each one separately, if the activity name matches any of the element tags
* then the constructor of that activity implementation is invoked
*
* @param omElement process definition of the bpel process
* @return activity
*/
public ActivityInterface processSubActivities(OMElement omElement) {
ActivityInterface endActivity = null;
// Checks whether omElement contains a value
if (omElement != null) {
ActivityInterface activity = null;
Iterator iterator = omElement.getChildElements();
// Iterates through the subActivities
while (iterator.hasNext()) {
OMElement tmpElement = (OMElement) iterator.next();
if (tmpElement.getLocalName().equals(BPEL2SVGFactory.ASSIGN_START_TAG) && isIncludeAssigns()) {
activity = new AssignImpl(tmpElement, this);
} else if (tmpElement.getLocalName().equals(BPEL2SVGFactory.EMPTY_START_TAG)) {
activity = new EmptyImpl(tmpElement, this);
} else if (tmpElement.getLocalName().equals(BPEL2SVGFactory.CATCHALL_START_TAG)) {
activity = new CatchAllImpl(tmpElement, this);
} else if (tmpElement.getLocalName().equals(BPEL2SVGFactory.CATCH_START_TAG)) {
activity = new CatchImpl(tmpElement, this);
} else if (tmpElement.getLocalName().equals(BPEL2SVGFactory.COMPENSATESCOPE_START_TAG)) {
activity = new CompensateScopeImpl(tmpElement, this);
} else if (tmpElement.getLocalName().equals(BPEL2SVGFactory.COMPENSATE_START_TAG)) {
activity = new CompensateImpl(tmpElement, this);
} else if (tmpElement.getLocalName().equals(BPEL2SVGFactory.COMPENSATIONHANDLER_START_TAG)) {
activity = new CompensationHandlerImpl(tmpElement, this);
} else if (tmpElement.getLocalName().equals(BPEL2SVGFactory.ELSEIF_START_TAG)) {
activity = new ElseIfImpl(tmpElement, this);
} else if (tmpElement.getLocalName().equals(BPEL2SVGFactory.ELSE_START_TAG)) {
activity = new ElseImpl(tmpElement, this);
} else if (tmpElement.getLocalName().equals(BPEL2SVGFactory.EVENTHANDLER_START_TAG)) {
activity = new EventHandlerImpl(tmpElement, this);
} else if (tmpElement.getLocalName().equals(BPEL2SVGFactory.EXIT_START_TAG)) {
activity = new ExitImpl(tmpElement, this);
} else if (tmpElement.getLocalName().equals(BPEL2SVGFactory.FAULTHANDLER_START_TAG)) {
activity = new FaultHandlerImpl(tmpElement, this);
} else if (tmpElement.getLocalName().equals(BPEL2SVGFactory.FLOW_START_TAG)) {
activity = new FlowImpl(tmpElement, this);
} else if (tmpElement.getLocalName().equals(BPEL2SVGFactory.FOREACH_START_TAG)) {
activity = new ForEachImpl(tmpElement, this);
} else if (tmpElement.getLocalName().equals(BPEL2SVGFactory.IF_START_TAG)) {
activity = new IfImpl(tmpElement, this);
} else if (tmpElement.getLocalName().equals(BPEL2SVGFactory.INVOKE_START_TAG)) {
activity = new InvokeImpl(tmpElement, this);
} else if (tmpElement.getLocalName().equals(BPEL2SVGFactory.ONALARM_START_TAG)) {
activity = new OnAlarmImpl(tmpElement, this);
} else if (tmpElement.getLocalName().equals(BPEL2SVGFactory.ONEVENT_START_TAG)) {
activity = new OnEventImpl(tmpElement, this);
} else if (tmpElement.getLocalName().equals(BPEL2SVGFactory.ONMESSAGE_START_TAG)) {
activity = new OnMessageImpl(tmpElement, this);
} else if (tmpElement.getLocalName().equals(BPEL2SVGFactory.PICK_START_TAG)) {
activity = new PickImpl(tmpElement, this);
} else if (tmpElement.getLocalName().equals(BPEL2SVGFactory.PROCESS_START_TAG)) {
activity = new ProcessImpl(tmpElement, this);
} else if (tmpElement.getLocalName().equals(BPEL2SVGFactory.RECEIVE_START_TAG)) {
activity = new ReceiveImpl(tmpElement, this);
} else if (tmpElement.getLocalName().equals(BPEL2SVGFactory.REPEATUNTIL_START_TAG)) {
activity = new RepeatUntilImpl(tmpElement, this);
} else if (tmpElement.getLocalName().equals(BPEL2SVGFactory.REPLY_START_TAG)) {
activity = new ReplyImpl(tmpElement, this);
} else if (tmpElement.getLocalName().equals(BPEL2SVGFactory.RETHROW_START_TAG)) {
activity = new ReThrowImpl(tmpElement, this);
} else if (tmpElement.getLocalName().equals(BPEL2SVGFactory.SCOPE_START_TAG)) {
activity = new ScopeImpl(tmpElement, this);
} else if (tmpElement.getLocalName().equals(BPEL2SVGFactory.SEQUENCE_START_TAG)) {
activity = new SequenceImpl(tmpElement, this);
} else if (tmpElement.getLocalName().equals(BPEL2SVGFactory.SOURCE_START_TAG)) {
// source
activity = new SourceImpl(tmpElement, this);
if (activity.getAttributes().get(0).getAttribute().equals("linkName")) {
if (links.containsKey(activity.getAttributes().get(0).getValue())) {
// if a entry for the particular link name already exists
links.get(activity.getAttributes().get(0).getValue()).setSource(this.parent);
} else {
// if the link name doesnot exist i.e. if the link is a new link
// Create a new Link object
Link link = new Link();
// Set the source(Start activity) as the parent activity
link.setSource(this.parent);
links.put(activity.getAttributes().get(0).getValue(), link);
}
// Add the parent activity of the activity to the source-list
sources.add(this.parent);
}
} else if (tmpElement.getLocalName().equals(BPEL2SVGFactory.SOURCES_START_TAG)) {
activity = new SourcesImpl(tmpElement, this);
} else if (tmpElement.getLocalName().equals(BPEL2SVGFactory.TARGET_START_TAG)) {
// target;
activity = new TargetImpl(tmpElement, this);
if (activity.getAttributes().get(0).getAttribute().equals("linkName")) {
if (links.containsKey(activity.getAttributes().get(0).getValue())) {
// if a entry for the particular link name already exists
links.get(activity.getAttributes().get(0).getValue()).setTarget(this.parent);
} else {
// if the link name doesnot exist i.e. if the link is a new link
// Create a new Link object
Link link = new Link();
// Set the target(End activity) as the parent activity
link.setTarget(this.parent);
links.put(activity.getAttributes().get(0).getValue(), link);
}
// Add the parent activity of the activity to the target-list
targets.add(this.parent);
}
} else if (tmpElement.getLocalName().equals(BPEL2SVGFactory.TARGETS_START_TAG)) {
activity = new TargetsImpl(tmpElement, this);
} else if (tmpElement.getLocalName().equals(BPEL2SVGFactory.TERMINATIONHANDLER_START_TAG)) {
activity = new TerminationHandlerImpl(tmpElement, this);
} else if (tmpElement.getLocalName().equals(BPEL2SVGFactory.THROW_START_TAG)) {
activity = new ThrowImpl(tmpElement, this);
} else if (tmpElement.getLocalName().equals(BPEL2SVGFactory.WAIT_START_TAG)) {
activity = new WaitImpl(tmpElement, this);
} else if (tmpElement.getLocalName().equals(BPEL2SVGFactory.WHILE_START_TAG)) {
activity = new WhileImpl(tmpElement, this);
} else if (tmpElement.getLocalName().equals(getEndTag())) {
break;
} else {
continue;
}
// Set the link properties i.e. the link name, source of the link and the target of the link
activity.setLinkProperties(links, sources, targets);
// Add the activity to the subActivities list
subActivities.add(activity);
// Checks if the activity has any child activities
if (tmpElement.getChildElements().hasNext()) {
// The child activities are processed again by invoking the same method recursively
ActivityInterface replyActivity = activity.processSubActivities(tmpElement);
if (replyActivity != null) {
subActivities.add(replyActivity);
}
}
if (tmpElement.getLocalName().equals(BPEL2SVGFactory.PROCESS_START_TAG)) {
break;
}
}
}
return endActivity;
}
use of org.wso2.siddhi.core.stream.input.source.Source in project carbon-business-process by wso2.
the class IfImpl method getArrows.
/**
* Get the arrow coordinates of the activities
*
* @param doc SVG document which defines the components including shapes, gradients etc. of the activity
* @return An element which contains the arrow coordinates of the If activity and its subActivities
*/
protected Element getArrows(SVGDocument doc) {
if (subActivities != null) {
ActivityInterface prevActivity = null;
ActivityInterface prevElseActivity = null;
ActivityInterface activity = null;
ActivityInterface seqActivity = null;
boolean throwOrNot = true;
String id = null;
// Coordinates of the start icon exit arrow
SVGCoordinates myStartCoords = getStartIconExitArrowCoords();
// Coordinates of the end icon entry arrow
SVGCoordinates myExitCoords = getEndIconEntryArrowCoords();
// Coordinates of the Else activity start icon entry arrow
SVGCoordinates myStartElseCoords = getStartIconElseArrowCoords();
SVGCoordinates exitCoords = null;
SVGCoordinates activityEntryCoords = null;
SVGCoordinates activityExitCoords = null;
Iterator<ActivityInterface> itr = subActivities.iterator();
Element subGroup = doc.createElementNS(SVGNamespace.SVG_NAMESPACE, "g");
// Iterates through all the subActivities
while (itr.hasNext()) {
activity = itr.next();
// Gets the entry and exit coordinates of the iterated activity
activityEntryCoords = activity.getEntryArrowCoords();
activityExitCoords = activity.getExitArrowCoords();
// Checks if the iterated activity is an instance of ElseIf or Else activity
if (activity instanceof ElseIfImpl || activity instanceof ElseImpl) {
// Checks whether there is a previous activity and if so whether that activity is an ElseIf
if (prevActivity != null && prevActivity instanceof ElseIfImpl) {
// Get the exit arrow coordinates of the ElseIf activity
exitCoords = ((ElseIfInterface) prevActivity).getNextElseExitArrowCoords();
// id is assigned with the id of the previous activity + id of the current activity
id = prevActivity.getId() + "-" + activity.getId();
// Checks whether the activity is an instance of Else
if (activity instanceof ElseImpl) {
// Gets the boolean value assigned inside ElseImpl when a throw activity is in Else
boolean check = ((ElseImpl) activity).throwOrNot;
// Define the entry arrow flow coordinates for the activity
subGroup.appendChild(getArrowDefinition(doc, exitCoords.getXLeft(), exitCoords.getYTop(), activityEntryCoords.getXLeft() - getEndIconWidth() / 2, exitCoords.getYTop(), id));
// If there is a Throw activity inside Else, no exit arrow from Throw activity
if (check != true) {
subGroup.appendChild(getArrowDefinition(doc, activityExitCoords.getXLeft(), activityExitCoords.getYTop(), myExitCoords.getXLeft(), myExitCoords.getYTop(), id));
}
} else if (activity instanceof ElseIfImpl) {
// Checks whether the activity is an instance of ElseIf
// Gets the boolean value assigned inside ElseIfImpl when a throw activity is in ElseIf
boolean check = ((ElseIfImpl) activity).throwOrNot;
// Define the entry arrow flow coordinates for the activity
subGroup.appendChild(getArrowDefinition(doc, exitCoords.getXLeft(), exitCoords.getYTop(), activityEntryCoords.getXLeft(), activityEntryCoords.getYTop(), id));
// If there is a Throw activity inside ElseIf, no exit arrow from Throw activity
if (check != true) {
subGroup.appendChild(getArrowDefinition(doc, activityExitCoords.getXLeft(), activityExitCoords.getYTop(), myExitCoords.getXLeft(), myExitCoords.getYTop(), id));
}
} else {
// Entry and exit arrow flows defined for other activities except for instances of Elseif and
// Else
subGroup.appendChild(getArrowDefinition(doc, exitCoords.getXLeft(), exitCoords.getYTop(), activityEntryCoords.getXLeft(), activityEntryCoords.getYTop(), id));
subGroup.appendChild(getArrowDefinition(doc, activityExitCoords.getXLeft(), activityExitCoords.getYTop(), myExitCoords.getXLeft(), myExitCoords.getYTop(), id));
}
} else if (prevActivity instanceof ThrowImpl && activity instanceof ElseImpl) {
// IF conditon fifnished --> ELSE IF ( previous activity is null and its is not an instance of
// ElseIf)
/*Checks if the previous activity is a Throw and if the current activity an Else, if so no exit
arrow flows only entry arrow flows.
*/
subGroup.appendChild(getArrowDefinition(doc, myStartElseCoords.getXLeft(), myStartElseCoords.getYTop(), activityEntryCoords.getXLeft(), activityEntryCoords.getYTop(), id));
} else if (activity instanceof ElseIfImpl) {
// Checks whether the activity is an instance of ElseIf
// Gets the boolean value assigned inside ElseIfImpl when a throw activity is in ElseIf
boolean check = ((ElseIfImpl) activity).throwOrNot;
// Define the entry arrow flow coordinates for the activity
subGroup.appendChild(getArrowDefinition(doc, myStartElseCoords.getXLeft(), myStartElseCoords.getYTop(), activityEntryCoords.getXLeft(), activityEntryCoords.getYTop(), id));
// If there is a Throw activity inside ElseIf, no exit arrow from Throw activity
if (check != true) {
subGroup.appendChild(getArrowDefinition(doc, activityExitCoords.getXLeft(), activityExitCoords.getYTop(), myExitCoords.getXLeft(), myExitCoords.getYTop(), id));
}
} else if (activity instanceof ElseImpl) {
// Checks whether the activity is an instance of Else
// Gets the boolean value assigned inside ElseIfImpl when a throw activity is in Else
boolean check = ((ElseImpl) activity).throwOrNot;
// Define the entry arrow flow coordinates for the activity
subGroup.appendChild(getArrowDefinition(doc, myStartElseCoords.getXLeft(), myStartElseCoords.getYTop(), activityEntryCoords.getXLeft(), activityEntryCoords.getYTop(), id));
// If there is a Throw activity inside Else, no exit arrow from Throw activity
if (check != true) {
subGroup.appendChild(getArrowDefinition(doc, activityExitCoords.getXLeft(), activityExitCoords.getYTop(), myExitCoords.getXLeft(), myExitCoords.getYTop(), id));
}
} else {
id = prevActivity.getId() + "-" + activity.getId();
// flows
if (activity instanceof ThrowImpl) {
subGroup.appendChild(getArrowDefinition(doc, myStartElseCoords.getXLeft(), myStartElseCoords.getYTop(), activityEntryCoords.getXLeft(), activityEntryCoords.getYTop(), id));
} else {
// Define both the entry and the exit arrow flows to the activity
subGroup.appendChild(getArrowDefinition(doc, myStartElseCoords.getXLeft(), myStartElseCoords.getYTop(), activityEntryCoords.getXLeft(), activityEntryCoords.getYTop(), id));
subGroup.appendChild(getArrowDefinition(doc, activityExitCoords.getXLeft(), activityExitCoords.getYTop(), myExitCoords.getXLeft(), myExitCoords.getYTop(), id));
}
}
} else if (activity instanceof ThrowImpl) {
// Checks if the current activity a Throw activity, if so no exit arrow flows only entry arrow flows
subGroup.appendChild(getArrowDefinition(doc, myStartCoords.getXLeft(), myStartCoords.getYTop(), activityEntryCoords.getXLeft(), activityEntryCoords.getYTop(), id));
} else if (activity instanceof SourceImpl || activity instanceof TargetImpl || activity instanceof SourcesImpl || activity instanceof TargetsImpl) {
// Checks if the current activity a Source/s or Target/s activity, if so no exit or entry arrow flows
// as no icons are defined
// No arrow flows for Sources or Targets..
} else {
if (prevActivity != null) {
// Gets the coordinates of the exit arrows of the previous activity
exitCoords = prevActivity.getExitArrowCoords();
id = prevActivity.getId() + "-" + activity.getId();
// arrow flows as no icons are defined
if (prevActivity instanceof SourceImpl || prevActivity instanceof TargetImpl || prevActivity instanceof SourcesImpl || prevActivity instanceof TargetsImpl) {
// No arrow flows for Sources or Targets..
} else {
subGroup.appendChild(getArrowDefinition(doc, exitCoords.getXLeft(), exitCoords.getYTop(), activityEntryCoords.getXLeft(), activityEntryCoords.getYTop(), id));
}
} else {
// Checks whether the activity is a Sequence
if (activity instanceof SequenceImpl) {
List<ActivityInterface> sub = activity.getSubActivities();
// Iterates through the subActivities
Iterator<ActivityInterface> as = sub.iterator();
while (as.hasNext()) {
seqActivity = as.next();
// Checks if the subActivity is a Throw activity
if (seqActivity instanceof ThrowImpl) {
throwOrNot = true;
// if condition breaks if the subActivity is a Throw activity
break;
} else {
throwOrNot = false;
}
}
// If its a Throw activity , no exit arrow flow only entry arrow flow to the activity
if (throwOrNot == true) {
subGroup.appendChild(getArrowDefinition(doc, myStartCoords.getXLeft(), myStartCoords.getYTop(), activityEntryCoords.getXLeft(), activityEntryCoords.getYTop(), id));
} else {
// If not, define both the entry and the exit arrow flows to the activity
subGroup.appendChild(getArrowDefinition(doc, myStartCoords.getXLeft(), myStartCoords.getYTop(), activityEntryCoords.getXLeft(), activityEntryCoords.getYTop(), id));
subGroup.appendChild(getArrowDefinition(doc, activityExitCoords.getXLeft(), activityExitCoords.getYTop(), myExitCoords.getXLeft(), myExitCoords.getYTop(), id));
}
} else {
// Define both the entry and the exit arrow flows to the activity
subGroup.appendChild(getArrowDefinition(doc, myStartCoords.getXLeft(), myStartCoords.getYTop(), activityEntryCoords.getXLeft(), activityEntryCoords.getYTop(), id));
subGroup.appendChild(getArrowDefinition(doc, activityExitCoords.getXLeft(), activityExitCoords.getYTop(), myExitCoords.getXLeft(), myExitCoords.getYTop(), id));
}
}
}
// current activity is assigned to the previous activity
prevActivity = activity;
}
return subGroup;
}
return null;
}
use of org.wso2.siddhi.core.stream.input.source.Source in project carbon-business-process by wso2.
the class HTRenderingApiImpl method getRenderingInputElements.
/**
* @param taskIdentifier : interested task identifier
* @return set of input renderings wrapped within InputType
* @throws IllegalArgumentFault : error occured while retrieving renderings from task definition
* @throws IOException If an error occurred while reading from the input source
* @throws SAXException If the content in the input source is invalid
*/
private InputType getRenderingInputElements(URI taskIdentifier) throws IllegalArgumentFault, IOException, SAXException, IllegalOperationFault, IllegalAccessFault, IllegalStateFault, XPathExpressionException {
// TODO Chaching : check cache against task id for input renderings
QName renderingType = new QName(htRenderingNS, "input", "wso2");
String inputRenderings = (String) taskOps.getRendering(taskIdentifier, renderingType);
// Create input element
InputType renderingInputs = null;
// check availability of input renderings
if (inputRenderings != null && inputRenderings.length() > 0) {
// parse input renderings
Element inputRenderingsElement = DOMUtils.stringToDOM(inputRenderings);
// retrieve input elements
NodeList inputElementList = inputRenderingsElement.getElementsByTagNameNS(htRenderingNS, "element");
Element taskInputMsgElement = DOMUtils.stringToDOM((String) taskOps.getInput(taskIdentifier, null));
if (inputElementList != null && inputElementList.getLength() > 0) {
// hold number of input element
int inputElementNum = inputElementList.getLength();
InputElementType[] inputElements = new InputElementType[inputElementNum];
for (int i = 0; i < inputElementNum; i++) {
Element tempElement = (Element) inputElementList.item(i);
String label = tempElement.getElementsByTagNameNS(htRenderingNS, "label").item(0).getTextContent();
String value = tempElement.getElementsByTagNameNS(htRenderingNS, "value").item(0).getTextContent();
// if the value starts with '/' then considered as an xpath and evaluate over received Input Message
if (value.startsWith("/") && taskInputMsgElement != null) {
// value represents xpath. evaluate against the input message
String xpathValue = evaluateXPath(value, taskInputMsgElement, inputRenderingsElement.getOwnerDocument());
if (xpathValue != null) {
value = xpathValue;
}
}
inputElements[i] = new InputElementType();
inputElements[i].setLabel(label);
inputElements[i].setValue(value);
}
renderingInputs = new InputType();
renderingInputs.setElement(inputElements);
// TODO cache renderingInputs against task instance id
}
}
return renderingInputs;
}
use of org.wso2.siddhi.core.stream.input.source.Source in project carbon-business-process by wso2.
the class ArchiveBasedHumanTaskDeploymentUnitBuilder method readInTheWSDLFile.
/**
* Read the WSDL file given the input stream for the WSDL source
*
* @param in WSDL input stream
* @param entryName ZIP file entry name
* @param fromRegistry whether the wsdl is read from registry
* @return WSDL Definition
* @throws javax.wsdl.WSDLException at parser error
*/
public static Definition readInTheWSDLFile(InputStream in, String entryName, boolean fromRegistry) throws WSDLException {
WSDLReader reader = WSDLFactory.newInstance().newWSDLReader();
// switch off the verbose mode for all usecases
reader.setFeature(HumanTaskConstants.JAVAX_WSDL_VERBOSE_MODE_KEY, false);
reader.setFeature("javax.wsdl.importDocuments", true);
Definition def;
Document doc;
try {
doc = XMLUtils.newDocument(in);
} catch (ParserConfigurationException e) {
throw new WSDLException(WSDLException.PARSER_ERROR, "Parser Configuration Error", e);
} catch (SAXException e) {
throw new WSDLException(WSDLException.PARSER_ERROR, "Parser SAX Error", e);
} catch (IOException e) {
throw new WSDLException(WSDLException.INVALID_WSDL, "IO Error", e);
}
// Log when and from where the WSDL is loaded.
if (log.isDebugEnabled()) {
log.debug("Reading 1.1 WSDL with base uri = " + entryName);
log.debug(" the document base uri = " + entryName);
}
if (fromRegistry) {
throw new UnsupportedOperationException("This operation is not currently " + "supported in this version of WSO2 BPS.");
} else {
def = reader.readWSDL(entryName, doc.getDocumentElement());
}
def.setDocumentBaseURI(entryName);
return def;
}
use of org.wso2.siddhi.core.stream.input.source.Source in project product-iots by wso2.
the class DeviceTypeServiceImpl method downloadSketch.
/**
* To download device type agent source code as zip file.
*
* @param deviceName name for the device type instance
* @param sketchType folder name where device type agent was installed into server
* @return Agent source code as zip file
*/
@Path("/device/download")
@GET
@Produces("application/zip")
public Response downloadSketch(@QueryParam("deviceName") String deviceName, @QueryParam("sketchType") String sketchType) {
try {
ZipArchive zipFile = createDownloadFile(APIUtil.getAuthenticatedUser(), deviceName, sketchType);
Response.ResponseBuilder response = Response.ok(FileUtils.readFileToByteArray(zipFile.getZipFile()));
response.status(Response.Status.OK);
response.type("application/zip");
response.header("Content-Disposition", "attachment; filename=\"" + zipFile.getFileName() + "\"");
Response resp = response.build();
zipFile.getZipFile().delete();
return resp;
} catch (IllegalArgumentException ex) {
// bad request
return Response.status(400).entity(ex.getMessage()).build();
} catch (DeviceManagementException ex) {
log.error(ex.getMessage(), ex);
return Response.status(500).entity(ex.getMessage()).build();
} catch (JWTClientException ex) {
log.error(ex.getMessage(), ex);
return Response.status(500).entity(ex.getMessage()).build();
} catch (APIManagerException ex) {
log.error(ex.getMessage(), ex);
return Response.status(500).entity(ex.getMessage()).build();
} catch (IOException ex) {
log.error(ex.getMessage(), ex);
return Response.status(500).entity(ex.getMessage()).build();
} catch (UserStoreException ex) {
log.error(ex.getMessage(), ex);
return Response.status(500).entity(ex.getMessage()).build();
}
}
Aggregations