
org.yaoqiang.graph.io.graphml.GraphMLGenericNode Maven / Gradle / Ivy
package org.yaoqiang.graph.io.graphml;
import java.awt.Rectangle;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import org.w3c.dom.Element;
/**
* GraphMLGenericNode
*
* @author Shi Yaoqiang([email protected])
*/
public class GraphMLGenericNode {
private String configuration = "";
private Rectangle geometry = new Rectangle();
private String nodeLabel = "";
private Map properties = new HashMap();
private String bpmnType;
private String activityType;
private String taskType;
private String dataObjectType;
private String conversationType;
private List markers = new ArrayList();
private String eventCharacteristic;
public GraphMLGenericNode(Element genericNodeElement) {
this.configuration = genericNodeElement.getAttribute(GraphMLConstants.CONFIGURATION);
Element geometryElement = GraphMLUtils.childsTag(genericNodeElement, GraphMLConstants.YWORKS + GraphMLConstants.GEOMETRY);
Double x = Double.valueOf(geometryElement.getAttribute(GraphMLConstants.X));
Double y = Double.valueOf(geometryElement.getAttribute(GraphMLConstants.Y));
Double w = Double.valueOf(geometryElement.getAttribute(GraphMLConstants.WIDTH));
Double h = Double.valueOf(geometryElement.getAttribute(GraphMLConstants.HEIGHT));
geometry.setRect(x, y, w, h);
Element labelElement = GraphMLUtils.childsTag(genericNodeElement, GraphMLConstants.YWORKS + GraphMLConstants.NODE_LABEL);
if (labelElement != null) {
this.nodeLabel = labelElement.getTextContent();
}
Element stylePropertiesElement = GraphMLUtils.childsTag(genericNodeElement, GraphMLConstants.YWORKS + GraphMLConstants.STYLE_PROPERTIES);
if (stylePropertiesElement != null) {
List propertyElements = GraphMLUtils.childsTags(stylePropertiesElement, GraphMLConstants.YWORKS + GraphMLConstants.PROPERTY);
for (Element el : propertyElements) {
properties.put(el.getAttribute(GraphMLConstants.NAME), el.getAttribute(GraphMLConstants.VALUE));
}
this.bpmnType = properties.get(GraphMLConstants.BPMN_TYPE);
this.activityType = properties.get(GraphMLConstants.ACTIVITY_TYPE);
this.taskType = properties.get(GraphMLConstants.TASK_TYPE);
this.dataObjectType = properties.get(GraphMLConstants.DATA_OBJECT_TYPE);
this.conversationType = properties.get(GraphMLConstants.CONVERSATION_TYPE);
for (Entry entry : properties.entrySet()) {
if (entry.getKey().startsWith(GraphMLConstants.MARKER_TYPE)) {
markers.add(entry.getValue());
}
}
this.eventCharacteristic = properties.get(GraphMLConstants.EVENT_CHARACTERISTIC);
}
}
public boolean isEvent() {
if (getConfiguration().equals(GraphMLConstants.EVENT)) {
return true;
}
return false;
}
public boolean isStartEvent() {
if (isEvent() && getEventCharacteristic().equals("EVENT_CHARACTERISTIC_START")) {
return true;
}
return false;
}
public boolean isEventStartEvent() {
if (isEvent() && getEventCharacteristic().equals("EVENT_CHARACTERISTIC_START_EVENT_SUB_PROCESS_INTERRUPTING")) {
return true;
}
return false;
}
public boolean isNonInterruptingEventStartEvent() {
if (isEvent() && getEventCharacteristic().equals("EVENT_CHARACTERISTIC_START_EVENT_SUB_PROCESS_NON_INTERRUPTING")) {
return true;
}
return false;
}
public boolean isEntEvent() {
if (isEvent() && getEventCharacteristic().equals("EVENT_CHARACTERISTIC_END")) {
return true;
}
return false;
}
public boolean isIntermediateCatchEvent() {
if (isEvent() && getEventCharacteristic().equals("EVENT_CHARACTERISTIC_INTERMEDIATE_CATCHING")) {
return true;
}
return false;
}
public boolean isIntermediateThrowEvent() {
if (isEvent() && getEventCharacteristic().equals("EVENT_CHARACTERISTIC_INTERMEDIATE_THROWING")) {
return true;
}
return false;
}
public boolean isBoundaryEvent() {
if (isEvent() && getEventCharacteristic().equals("EVENT_CHARACTERISTIC_INTERMEDIATE_BOUNDARY_INTERRUPTING")) {
return true;
}
return false;
}
public boolean isNonInterruptingBoundaryEvent() {
if (isEvent() && getEventCharacteristic().equals("EVENT_CHARACTERISTIC_INTERMEDIATE_BOUNDARY_NON_INTERRUPTING")) {
return true;
}
return false;
}
public boolean isNoneEvent() {
if (isEvent() && getBpmnType().equals("EVENT_TYPE_PLAIN")) {
return true;
}
return false;
}
public boolean isMessageEvent() {
if (isEvent() && getBpmnType().equals("EVENT_TYPE_MESSAGE")) {
return true;
}
return false;
}
public boolean isTimerEvent() {
if (isEvent() && getBpmnType().equals("EVENT_TYPE_TIMER")) {
return true;
}
return false;
}
public boolean isErrorEvent() {
if (isEvent() && getBpmnType().equals("EVENT_TYPE_ERROR")) {
return true;
}
return false;
}
public boolean isCancelEvent() {
if (isEvent() && getBpmnType().equals("EVENT_TYPE_CANCEL")) {
return true;
}
return false;
}
public boolean isCompensationEvent() {
if (isEvent() && getBpmnType().equals("EVENT_TYPE_COMPENSATION")) {
return true;
}
return false;
}
public boolean isConditionalEvent() {
if (isEvent() && getBpmnType().equals("EVENT_TYPE_CONDITIONAL")) {
return true;
}
return false;
}
public boolean isSignalEvent() {
if (isEvent() && getBpmnType().equals("EVENT_TYPE_SIGNAL")) {
return true;
}
return false;
}
public boolean isMultipleEvent() {
if (isEvent() && getBpmnType().equals("EVENT_TYPE_MULTIPLE")) {
return true;
}
return false;
}
public boolean isParallelMultipleEvent() {
if (isEvent() && getBpmnType().equals("EVENT_TYPE_PARALLEL_MULTIPLE")) {
return true;
}
return false;
}
public boolean isLinkEvent() {
if (isEvent() && getBpmnType().equals("EVENT_TYPE_LINK")) {
return true;
}
return false;
}
public boolean isTerminateEvent() {
if (isEvent() && getBpmnType().equals("EVENT_TYPE_TERMINATE")) {
return true;
}
return false;
}
public boolean isGateway() {
if (getConfiguration().equals(GraphMLConstants.GATEWAY)) {
return true;
}
return false;
}
public boolean isGatewayWithoutMarker() {
if (isGateway() && getBpmnType().equals("GATEWAY_TYPE_PLAIN")) {
return true;
}
return false;
}
public boolean isExclusiveGateway() {
if (isGateway() && getBpmnType().equals("GATEWAY_TYPE_DATA_BASED_EXCLUSIVE")) {
return true;
}
return false;
}
public boolean isEventGateway() {
if (isGateway() && getBpmnType().equals("GATEWAY_TYPE_EVENT_BASED_EXCLUSIVE")) {
return true;
}
return false;
}
public boolean isInstantiateEventGateway() {
if (isGateway() && getBpmnType().equals("GATEWAY_TYPE_EVENT_BASED_EXCLUSIVE_START_PROCESS")) {
return true;
}
return false;
}
public boolean isParallelEventGateway() {
if (isGateway() && getBpmnType().equals("GATEWAY_TYPE_PARALLEL_EVENT_BASED_EXCLUSIVE_START_PROCESS")) {
return true;
}
return false;
}
public boolean isParallelGateway() {
if (isGateway() && getBpmnType().equals("GATEWAY_TYPE_PARALLEL")) {
return true;
}
return false;
}
public boolean isInclusiveGateway() {
if (isGateway() && getBpmnType().equals("GATEWAY_TYPE_INCLUSIVE")) {
return true;
}
return false;
}
public boolean isComplexGateway() {
if (isGateway() && getBpmnType().equals("GATEWAY_TYPE_COMPLEX")) {
return true;
}
return false;
}
public boolean isActivity() {
if (getBpmnType().equals("ACTIVITY_TYPE")) {
return true;
}
return false;
}
public boolean isCallActivity() {
if (isActivity() && getActivityType().equals("ACTIVITY_TYPE_CALL_ACTIVITY")) {
return true;
}
return false;
}
public boolean isCallSubProcess() {
if (isCallActivity() && getMarkers().contains("BPMN_MARKER_CLOSED")) {
return true;
}
return false;
}
public boolean isEventSubProcess() {
if (isActivity() && getActivityType().equals("ACTIVITY_TYPE_EVENT_SUB_PROCESS")) {
return true;
}
return false;
}
public boolean isTransaction() {
if (isActivity() && getActivityType().equals("ACTIVITY_TYPE_TRANSACTION")) {
return true;
}
return false;
}
public boolean isTask() {
if (isActivity() && getActivityType().equals("ACTIVITY_TYPE_TASK") && !isSubProcess()) {
return true;
}
return false;
}
public boolean isSubProcess() {
if (isActivity() && (getMarkers().contains("BPMN_MARKER_OPEN") || getMarkers().contains("BPMN_MARKER_CLOSED"))) {
return true;
}
return false;
}
public boolean isAbstractTask() {
if (getTaskType().equals("TASK_TYPE_ABSTRACT")) {
return true;
}
return false;
}
public boolean isSendTask() {
if (getTaskType().equals("TASK_TYPE_SEND")) {
return true;
}
return false;
}
public boolean isReceiveTask() {
if (getTaskType().equals("TASK_TYPE_RECEIVE")) {
return true;
}
return false;
}
public boolean isUserTask() {
if (getTaskType().equals("TASK_TYPE_USER")) {
return true;
}
return false;
}
public boolean isManualTask() {
if (getTaskType().equals("TASK_TYPE_MANUAL")) {
return true;
}
return false;
}
public boolean isBusinessRuleTask() {
if (getTaskType().equals("TASK_TYPE_BUSINESS_RULE")) {
return true;
}
return false;
}
public boolean isServiceTask() {
if (getTaskType().equals("TASK_TYPE_SERVICE")) {
return true;
}
return false;
}
public boolean isScriptTask() {
if (getTaskType().equals("TASK_TYPE_SCRIPT")) {
return true;
}
return false;
}
public boolean isLoopActivity() {
if (isActivity() && getMarkers().contains("BPMN_MARKER_LOOP")) {
return true;
}
return false;
}
public boolean isAdHocActivity() {
if (isActivity() && getMarkers().contains("BPMN_MARKER_AD_HOC")) {
return true;
}
return false;
}
public boolean isCompensationActivity() {
if (isActivity() && getMarkers().contains("BPMN_MARKER_COMPENSATION")) {
return true;
}
return false;
}
public boolean isMultiInstanceParallelActivity() {
if (isActivity() && getMarkers().contains("BPMN_MARKER_PARALLEL")) {
return true;
}
return false;
}
public boolean isMultiInstanceSequentialActivity() {
if (isActivity() && getMarkers().contains("BPMN_MARKER_SEQUENTIAL")) {
return true;
}
return false;
}
public boolean isConversation() {
if (getBpmnType().equals("CONVERSATION_TYPE")) {
return true;
}
return false;
}
public boolean isCallConversation() {
if (getConversationType().equals("CONVERSATION_TYPE_CALL_CONVERSATION")) {
return true;
}
return false;
}
public boolean isSubConversation() {
if (isConversation() && getMarkers().contains("BPMN_MARKER_CLOSED")) {
return true;
}
return false;
}
public boolean isArtifact() {
if (getConfiguration().equals(GraphMLConstants.ARTIFACT)) {
return true;
}
return false;
}
public boolean isDataObject() {
if (isArtifact() && getBpmnType().equals("ARTIFACT_TYPE_DATA_OBJECT")) {
return true;
}
return false;
}
public boolean isDataInput() {
if (isDataObject() && getDataObjectType().equals("DATA_OBJECT_TYPE_INPUT")) {
return true;
}
return false;
}
public boolean isDataOutput() {
if (isDataObject() && getDataObjectType().equals("DATA_OBJECT_TYPE_OUTPUT")) {
return true;
}
return false;
}
public boolean isCollectionDataObject() {
if (isDataObject() && getMarkers().contains("BPMN_MARKER_PARALLEL")) {
return true;
}
return false;
}
public boolean isDataStore() {
if (isArtifact() && getBpmnType().equals("ARTIFACT_TYPE_DATA_STORE")) {
return true;
}
return false;
}
public boolean isAnnotation() {
if (isArtifact() && getBpmnType().equals("ARTIFACT_TYPE_ANNOTATION")) {
return true;
}
return false;
}
public boolean isGroup() {
if (isArtifact() && getBpmnType().equals("ARTIFACT_TYPE_GROUP")) {
return true;
}
return false;
}
public boolean isInitiatingMessage() {
if (isArtifact() && getBpmnType().equals("ARTIFACT_TYPE_REQUEST_MESSAGE")) {
return true;
}
return false;
}
public boolean isMessage() {
if (isArtifact() && getBpmnType().equals("ARTIFACT_TYPE_REPLY_MESSAGE")) {
return true;
}
return false;
}
public String getConfiguration() {
return configuration;
}
public String getEventCharacteristic() {
return eventCharacteristic;
}
public Rectangle getGeometry() {
return geometry;
}
public String getNodeLabel() {
return nodeLabel == null ? "" : nodeLabel;
}
public String getBpmnType() {
return bpmnType;
}
public String getActivityType() {
return activityType;
}
public String getTaskType() {
return taskType;
}
public String getDataObjectType() {
return dataObjectType;
}
public String getConversationType() {
return conversationType;
}
public List getMarkers() {
return markers;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy