use of org.wso2.siddhi.query.api.annotation.Element in project carbon-business-process by wso2.
the class ProcessImpl method getLinkArrows.
/**
* Gets the Link arrow coordinates when there is a FLOW activity in the process
*
* @param doc SVG document which defines the components including shapes, gradients etc. of the process
* @return An element which contains the link arrow coordinates of the Process
*/
private Element getLinkArrows(SVGDocument doc) {
Element group = doc.createElementNS(SVGNamespace.SVG_NAMESPACE, "g");
// Checks whether the any links exist
if (links != null && !links.isEmpty()) {
// Returns a collection-view of the map with the link names, sources(starting activity) and the target
// (ending activity)
Set linksSet = links.entrySet();
Iterator linksIterator = linksSet.iterator();
// Iterates through the links
while (linksIterator.hasNext()) {
Map.Entry<String, Link> link = (Map.Entry<String, Link>) linksIterator.next();
// Gets the source/start activity of the link
ActivityInterface startActivity = link.getValue().getSource();
// Gets the target/end activity of the link
ActivityInterface endActivity = link.getValue().getTarget();
// Get the link name
String linkName = link.getKey();
// Check if the source and the target of the link contains a value
if (endActivity != null && startActivity != null) {
// Define the link flow/path by giving the coordinates of the start and end activity
group.appendChild(drawLink(doc, startActivity.getExitArrowCoords().getXLeft(), startActivity.getExitArrowCoords().getYTop(), endActivity.getEntryArrowCoords().getXLeft(), endActivity.getEntryArrowCoords().getYTop(), startActivity.getStartIconWidth(), link.getKey(), linkName));
}
}
}
return group;
}
use of org.wso2.siddhi.query.api.annotation.Element 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.query.api.annotation.Element in project carbon-business-process by wso2.
the class ActivityImpl method getSubActivitiesSVGString.
/**
* @param doc SVG document which defines the components including shapes, gradients etc. of the subActivities
* @return Element(represents an element in a XML/HTML document) which contains the components of the subActivities
*/
public Element getSubActivitiesSVGString(SVGDocument doc) {
Iterator<ActivityInterface> itr = subActivities.iterator();
ActivityInterface activity = null;
Element subElement = doc.createElementNS(SVGNamespace.SVG_NAMESPACE, "g");
// Iterates through the subActivities
while (itr.hasNext()) {
activity = itr.next();
// Embeds the Element returned by each subActivity(which contains the components of the subActivities)
// into the SVG container <g>
subElement.appendChild(activity.getSVGString(doc));
// Get the name of the activity
name = activity.getId();
}
return subElement;
}
use of org.wso2.siddhi.query.api.annotation.Element in project carbon-business-process by wso2.
the class NotificationScheduler method publishEmailNotifications.
/**
* Publish Email notifications by extracting the information from the incoming message rendering tags
* <htd:renderings>
* <htd:rendering type="wso2:email" xmlns:wso2="http://wso2.org/ht/schema/renderings/">
* <wso2:to name="to" type="xsd:string">wso2bpsemail@wso2.com</wso2:to>
* <wso2:subject name="subject" type="xsd:string">email subject to user</wso2:subject>
* <wso2:body name="body" type="xsd:string">Hi email notifications</wso2:body>
* </htd:rendering>
* <htd:rendering type="wso2:sms" xmlns:wso2="http://wso2.org/ht/schema/renderings/">
* <wso2:receiver name="receiver" type="xsd:string">94777459299</wso2:receiver>
* <wso2:body name="body" type="xsd:string">Hi $firstname$</wso2:body>
* </htd:rendering>
*</htd:renderings>
*
* @param task TaskDAO object for this notification task instance
* @param taskConfiguration task configuration instance for this notification task definition
*/
public void publishEmailNotifications(TaskDAO task, HumanTaskBaseConfiguration taskConfiguration) throws IOException, SAXException, ParserConfigurationException {
String rendering = CommonTaskUtil.getRendering(task, taskConfiguration, new QName(HumanTaskConstants.RENDERING_NAMESPACE, HumanTaskConstants.RENDERING_TYPE_EMAIL));
if (rendering != null) {
Map<String, String> dynamicPropertiesForEmail = new HashMap<String, String>();
Element root = DOMUtils.stringToDOM(rendering);
if (root != null) {
String emailBody = null;
String mailSubject = null;
String mailTo = null;
String contentType = null;
NodeList mailToList = root.getElementsByTagNameNS(HumanTaskConstants.RENDERING_NAMESPACE, HumanTaskConstants.EMAIL_TO_TAG);
if (log.isDebugEnabled()) {
log.debug("Parsing Email notification rendering element to for notification id " + task.getId());
}
if (mailToList != null && mailToList.getLength() > 0) {
mailTo = mailToList.item(0).getTextContent();
} else {
log.warn("Email to address not specified for email notification with notification id " + task.getId());
}
NodeList mailSubjectList = root.getElementsByTagNameNS(HumanTaskConstants.RENDERING_NAMESPACE, HumanTaskConstants.EMAIL_SUBJECT_TAG);
if (log.isDebugEnabled()) {
log.debug("Paring Email notification rendering element subject " + task.getId());
}
if (mailSubjectList != null && mailSubjectList.getLength() > 0) {
mailSubject = mailSubjectList.item(0).getTextContent();
} else {
log.warn("Email subject not specified for email notification with notification id " + task.getId());
}
NodeList mailContentType = root.getElementsByTagNameNS(HumanTaskConstants.RENDERING_NAMESPACE, HumanTaskConstants.EMAIL_CONTENT_TYPE_TAG);
if (log.isDebugEnabled()) {
log.debug("Paring Email notification rendering element contentType " + task.getId());
}
if (mailContentType != null && mailContentType.getLength() > 0) {
contentType = mailContentType.item(0).getTextContent();
} else {
contentType = HumanTaskConstants.CONTENT_TYPE_TEXT_PLAIN;
log.warn("Email contentType not specified for email notification with notification id " + task.getId() + ". Using text/plain.");
}
if (log.isDebugEnabled()) {
log.debug("Parsing Email notification rendering element body tag for notification id " + task.getId());
}
NodeList emailBodyList = root.getElementsByTagNameNS(HumanTaskConstants.RENDERING_NAMESPACE, HumanTaskConstants.EMAIL_OR_SMS_BODY_TAG);
if (emailBodyList != null && emailBodyList.getLength() > 0) {
emailBody = emailBodyList.item(0).getTextContent();
} else {
log.warn("Email notification message body not specified for notification with id " + task.getId());
}
dynamicPropertiesForEmail.put(HumanTaskConstants.ARRAY_EMAIL_ADDRESS, mailTo);
dynamicPropertiesForEmail.put(HumanTaskConstants.ARRAY_EMAIL_SUBJECT, mailSubject);
dynamicPropertiesForEmail.put(HumanTaskConstants.ARRAY_EMAIL_TYPE, contentType);
String adaptorName = getAdaptorName(task.getName(), HumanTaskConstants.RENDERING_TYPE_EMAIL);
if (!emailAdapterNames.contains(adaptorName)) {
OutputEventAdapterConfiguration outputEventAdapterConfiguration = createOutputEventAdapterConfiguration(adaptorName, HumanTaskConstants.RENDERING_TYPE_EMAIL, HumanTaskConstants.EMAIL_MESSAGE_FORMAT);
try {
HumanTaskServiceComponent.getOutputEventAdapterService().create(outputEventAdapterConfiguration);
emailAdapterNames.add(adaptorName);
} catch (OutputEventAdapterException e) {
log.error("Unable to create Output Event Adapter : " + adaptorName, e);
}
}
HumanTaskServiceComponent.getOutputEventAdapterService().publish(adaptorName, dynamicPropertiesForEmail, emailBody);
// emailAdapter.publish(emailBody, dynamicPropertiesForEmail);
}
} else {
log.warn("Email Rendering type not found for task definition with task id " + task.getId());
}
}
use of org.wso2.siddhi.query.api.annotation.Element in project carbon-business-process by wso2.
the class NotificationScheduler method publishSMSNotifications.
/**
* Publish SMS notifications by extracting the information from the incoming message rendering tags
* <htd:renderings>
* <htd:rendering type="wso2:email" xmlns:wso2="http://wso2.org/ht/schema/renderings/">
* <wso2:to name="to" type="xsd:string">wso2bpsemail@wso2.com</wso2:to>
* <wso2:subject name="subject" type="xsd:string">email subject to user</wso2:subject>
* <wso2:body name="body" type="xsd:string">Hi email notifications</wso2:body>
* </htd:rendering>
* <htd:rendering type="wso2:sms" xmlns:wso2="http://wso2.org/ht/schema/renderings/">
* <wso2:receiver name="receiver" type="xsd:string">94777459299</wso2:receiver>
* <wso2:body name="body" type="xsd:string">Hi $firstname$</wso2:body>
* </htd:rendering>
* </htd:renderings>
* @param task Task Dao Object for this notification task
* @param taskConfiguration task Configuration for this notification task instance
*/
public void publishSMSNotifications(TaskDAO task, HumanTaskBaseConfiguration taskConfiguration) throws IOException, SAXException, ParserConfigurationException {
String renderingSMS = CommonTaskUtil.getRendering(task, taskConfiguration, new QName(HumanTaskConstants.RENDERING_NAMESPACE, HumanTaskConstants.RENDERING_TYPE_SMS));
if (renderingSMS != null) {
Map<String, String> dynamicPropertiesForSms = new HashMap<String, String>();
Element rootSMS = DOMUtils.stringToDOM(renderingSMS);
if (rootSMS != null) {
String smsReceiver = null;
String smsBody = null;
if (log.isDebugEnabled()) {
log.debug("Parsing SMS notification rendering element 'receiver' for notification id " + task.getId());
}
NodeList smsReceiverList = rootSMS.getElementsByTagNameNS(HumanTaskConstants.RENDERING_NAMESPACE, HumanTaskConstants.SMS_RECEIVER_TAG);
if (smsReceiverList != null && smsReceiverList.getLength() > 0) {
smsReceiver = smsReceiverList.item(0).getTextContent();
} else {
log.warn("SMS notification rendering element 'receiver' not specified for notification with id " + task.getId());
}
NodeList smsBodyList = rootSMS.getElementsByTagNameNS(HumanTaskConstants.RENDERING_NAMESPACE, HumanTaskConstants.EMAIL_OR_SMS_BODY_TAG);
if (log.isDebugEnabled()) {
log.debug("Parsing SMS notification rendering element 'body' for notification id " + task.getId());
}
if (smsBodyList != null && smsBodyList.getLength() > 0) {
smsBody = smsBodyList.item(0).getTextContent();
} else {
log.warn("SMS notification rendering element 'body' not specified for notification with id " + task.getId());
}
dynamicPropertiesForSms.put(HumanTaskConstants.ARRAY_SMS_NO, smsReceiver);
String adaptorName = getAdaptorName(task.getName(), HumanTaskConstants.RENDERING_TYPE_SMS);
if (!smsAdapterNames.contains(adaptorName)) {
OutputEventAdapterConfiguration outputEventAdapterConfiguration = createOutputEventAdapterConfiguration(adaptorName, HumanTaskConstants.RENDERING_TYPE_SMS, HumanTaskConstants.SMS_MESSAGE_FORMAT);
try {
HumanTaskServiceComponent.getOutputEventAdapterService().create(outputEventAdapterConfiguration);
smsAdapterNames.add(adaptorName);
} catch (OutputEventAdapterException e) {
log.error("Unable to create Output Event Adapter : " + adaptorName, e);
}
}
HumanTaskServiceComponent.getOutputEventAdapterService().publish(adaptorName, dynamicPropertiesForSms, smsBody);
// smsAdapter.publish(smsBody, dynamicPropertiesForSms);
}
} else {
log.warn("SMS Rendering type not found for task definition with task id " + task.getId());
}
}
Aggregations