⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 designermodeldigester.java

📁 一个java写的business process management系统
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
			else if (modelPart instanceof JoinFlowletModelPart) {
				flowletBind = createJoinFlowletBind((JoinFlowletModelPart)modelPart);
				flowModelBind.addJoinFlowlet((JoinFlowletBind)flowletBind);
				flowletIndex = new Integer(flowModelBind.getJoinFlowlets().indexOf(flowletBind));
			}
			//	call flowlets
			else if (modelPart instanceof CallFlowletModelPart) {
				flowletBind = createCallFlowletBind((CallFlowletModelPart)modelPart);
				flowModelBind.addCallFlowlet((CallFlowletBind)flowletBind);
				flowletIndex = new Integer(flowModelBind.getCallFlowlets().indexOf(flowletBind));
			}
			//	jump flowlets
			else if (modelPart instanceof JumpFlowletModelPart) {
				flowletBind = createJumpFlowletBind((JumpFlowletModelPart)modelPart);
				flowModelBind.addJumpFlowlet((JumpFlowletBind)flowletBind);
				flowletIndex = new Integer(flowModelBind.getJumpFlowlets().indexOf(flowletBind));
			}
			//	template flowlets
			else if (modelPart instanceof TemplateFlowletModelPart) {
				flowletBind = createTemplateFlowletBind((TemplateFlowletModelPart)modelPart);
				flowModelBind.addTemplateFlowlet((TemplateFlowletBind)flowletBind);
				flowletIndex = new Integer(flowModelBind.getTemplateFlowlets().indexOf(flowletBind));
			}
			//	end flowlets
			else if (modelPart instanceof EndFlowletModelPart) {
				flowletBind = createEndFlowletBind((EndFlowletModelPart)modelPart);
				flowModelBind.addEndFlowlet((EndFlowletBind)flowletBind);
				flowletIndex = new Integer(flowModelBind.getEndFlowlets().indexOf(flowletBind));
			}
			if (flowletIndex != null)
				flowletToIndexMapping.put(modelPart, flowletIndex);
		}

		//	Transitions
		for (Iterator iter = flowDiagramModelPart.getChildren().iterator(); iter.hasNext();) {
			FlowDiagramElementModelPart elem = (FlowDiagramElementModelPart)iter.next();

			if (elem instanceof DecisionFlowletModelPart)
				addBooleanTransitionBind(flowModelBind, (DecisionFlowletModelPart)elem, flowletToIndexMapping);
			else if (elem instanceof FlowletModelPart)
				addTransitionBind(flowModelBind, (FlowletModelPart)elem, flowletToIndexMapping);
		}

		return flowModelBind;
	}

	/**
	 * Creates a new binding object using the data from the model
	 * @param label
	 */
	private FlowletLabelBind createFlowletLabelBind(FlowletLabelModelPart label) {
		FlowletLabelBind labelBind = new FlowletLabelBind();
		labelBind.setX(label.getLocation().x);
		labelBind.setY(label.getLocation().y);
		labelBind.setText(label.getText());

		return labelBind;
	}

	/**
	 * Creates a new StartFlowletBind object using the data from the model
	 * @param flowlet
	 */
	private StartFlowletBind createStartFlowletBind(StartFlowletModelPart flowlet) {
		StartFlowletBind startFlowletBind = new StartFlowletBind();
		startFlowletBind.setX(flowlet.getLocation().x);
		startFlowletBind.setY(flowlet.getLocation().y);
		startFlowletBind.setLabel(createFlowletLabelBind(flowlet.getFlowletLabel()));

		//	set properties
		if (flowlet.getStartProperties() != null  &&  ! flowlet.getStartProperties().isEmpty()) {
			for (Iterator iter = flowlet.getStartProperties().entrySet().iterator(); iter.hasNext();) {
				Map.Entry propEntry = (Map.Entry)iter.next();
				PropertyBind propBind = new PropertyBind();
				propBind.setName((String)propEntry.getKey());
				propBind.setValue((String)propEntry.getValue());
				startFlowletBind.addProperty(propBind);
			}
		}

		return startFlowletBind;
	}

	/**
	 * Creates a new JavaTaskFlowletBind object using the data from the model
	 * @param flowlet
	 */
	private JavaTaskFlowletBind createJavaTaskFlowletBind(JavaTaskFlowletModelPart flowlet) {
		JavaTaskFlowletBind taskFlowletBind = new JavaTaskFlowletBind();
		taskFlowletBind.setX(flowlet.getLocation().x);
		taskFlowletBind.setY(flowlet.getLocation().y);
		taskFlowletBind.setLabel(createFlowletLabelBind(flowlet.getFlowletLabel()));
		
		//	set properties
		if (flowlet.getTaskProperties() != null  &&  ! flowlet.getTaskProperties().isEmpty()) {
			for (Iterator iter = flowlet.getTaskProperties().entrySet().iterator(); iter.hasNext();) {
				Map.Entry propEntry = (Map.Entry)iter.next();
				PropertyBind propBind = new PropertyBind();
				propBind.setName((String)propEntry.getKey());
				propBind.setValue((String)propEntry.getValue());
				taskFlowletBind.addProperty(propBind);
			}
		}

		return taskFlowletBind;
	}

	/**
	 * Creates a new ScriptTaskFlowletBind object using the data from the model
	 * @param flowlet
	 */
	private ScriptTaskFlowletBind createScriptTaskFlowletBind(ScriptTaskFlowletModelPart flowlet) {
		ScriptTaskFlowletBind taskFlowletBind = new ScriptTaskFlowletBind();
		taskFlowletBind.setX(flowlet.getLocation().x);
		taskFlowletBind.setY(flowlet.getLocation().y);
		taskFlowletBind.setLabel(createFlowletLabelBind(flowlet.getFlowletLabel()));

		return taskFlowletBind;
	}

	/**
	 * Creates a new DecisionFlowletBind object using the data from the model
	 * @param flowlet
	 */
	private DecisionFlowletBind createDecisionFlowletBind(DecisionFlowletModelPart flowlet) {
		DecisionFlowletBind decisionFlowletBind = new DecisionFlowletBind();
		decisionFlowletBind.setX(flowlet.getLocation().x);
		decisionFlowletBind.setY(flowlet.getLocation().y);
		decisionFlowletBind.setDescription(flowlet.getDescription());
		decisionFlowletBind.setLabel(createFlowletLabelBind(flowlet.getFlowletLabel()));

		return decisionFlowletBind;
	}

	/**
	 * Creates a new JoinFlowletBind object using the data from the model
	 * @param flowlet
	 */
	private JoinFlowletBind createJoinFlowletBind(JoinFlowletModelPart flowlet) {
		JoinFlowletBind joinFlowletBind = new JoinFlowletBind();
		joinFlowletBind.setX(flowlet.getLocation().x);
		joinFlowletBind.setY(flowlet.getLocation().y);

		return joinFlowletBind;
	}

	/**
	 * Creates a new CallFlowletBind object using the data from the model
	 * @param flowlet
	 */
	private CallFlowletBind createCallFlowletBind(CallFlowletModelPart flowlet) {
		CallFlowletBind callFlowletBind = new CallFlowletBind();
		callFlowletBind.setX(flowlet.getLocation().x);
		callFlowletBind.setY(flowlet.getLocation().y);
		callFlowletBind.setLabel(createFlowletLabelBind(flowlet.getFlowletLabel()));

		return callFlowletBind;
	}

	/**
	 * Creates a new JumpFlowletBind object using the data from the model
	 * @param flowlet
	 */
	private JumpFlowletBind createJumpFlowletBind(JumpFlowletModelPart flowlet) {
		JumpFlowletBind jumpFlowletBind = new JumpFlowletBind();
		jumpFlowletBind.setX(flowlet.getLocation().x);
		jumpFlowletBind.setY(flowlet.getLocation().y);
		jumpFlowletBind.setLabel(createFlowletLabelBind(flowlet.getFlowletLabel()));

		return jumpFlowletBind;
	}

	/**
	 * Creates a new TemplateFlowletBind object using the data from the model
	 * @param flowlet
	 */
	private TemplateFlowletBind createTemplateFlowletBind(TemplateFlowletModelPart flowlet) {
		TemplateFlowletBind templateFlowletBind = new TemplateFlowletBind();
		templateFlowletBind.setX(flowlet.getLocation().x);
		templateFlowletBind.setY(flowlet.getLocation().y);
		templateFlowletBind.setDescription(flowlet.getDescription());
		templateFlowletBind.setLabel(createFlowletLabelBind(flowlet.getFlowletLabel()));

		return templateFlowletBind;
	}

	/**
	 * Creates a new EndFlowletBind object using the data from the model
	 * @param flowlet
	 */
	private EndFlowletBind createEndFlowletBind(EndFlowletModelPart flowlet) {
		EndFlowletBind endFlowletBind = new EndFlowletBind();
		endFlowletBind.setX(flowlet.getLocation().x);
		endFlowletBind.setY(flowlet.getLocation().y);

		return endFlowletBind;
	}

	/**
	 * Iterates over all flowlets and stores the source connections together with the bendpoints
	 * @param transitionsGen	the container where all source transitions are added
	 * @param flowlet	source connections and bendpoints of this flowlet are added
	 * @param flowletToIndexMapping	the map where the flowlets inices are stored inside their container
	 */
	private void addTransitionBind(
		FlowModelBind FlowModelBind,
		FlowletModelPart flowlet,
		Map flowletToIndexMapping) {
		//	iterate over all flowlet's source connections
		for (Iterator transitionsIter = flowlet.getSourceTransitions().iterator(); transitionsIter.hasNext();) {
			TransitionModelPart transition = (TransitionModelPart)transitionsIter.next();
			TransitionBind transitionBind = new TransitionBind();
			setTransitionBasicContents(transitionBind, transition, flowletToIndexMapping);
			FlowModelBind.addTransition(transitionBind);
		}
	}

	/**
	 * Iterates over all flowlets and stores the source connections together with the bendpoints of 
	 * BooleanTransitions
	 * @param transitionsGen	the container where all source transitions are added
	 * @param flowlet	source connections and bendpoints of this flowlet are added
	 * @param flowletToIndexMapping	the map where the flowlets inices are stored inside their container
	 */
	private void addBooleanTransitionBind(
		FlowModelBind FlowModelBind,
		DecisionFlowletModelPart flowlet,
		Map flowletToIndexMapping) {
		//	iterate over all flowlet's source connections
		for (Iterator transitionsIter = flowlet.getSourceTransitions().iterator(); transitionsIter.hasNext();) {
			BooleanTransitionModelPart booleanTransition = (BooleanTransitionModelPart)transitionsIter.next();
			BooleanTransitionBind transitionBind = new BooleanTransitionBind();
			setTransitionBasicContents(transitionBind, booleanTransition, flowletToIndexMapping);
			//	set value
			transitionBind.setValue(booleanTransition.getBoolValue());
			FlowModelBind.addBooleanTransition(transitionBind);
		}
	}

	/**
	 * Sets the basic contents of a transition.
	 * @param transitionBind
	 * @param transition
	 * @param flowletToIndexMapping
	 */
	private void setTransitionBasicContents(
		TransitionBind transitionBind,
		TransitionModelPart transition,
		Map flowletToIndexMapping) {
		//	source
		TransitionSourceFlowletBind transitionSource = new TransitionSourceFlowletBind();
		FlowletModelPart source = transition.getSource();
		transitionBind.setSourceFlowlet(transitionSource);
		transitionSource.setType(source.getType());
		transitionSource.setIndex(((Integer)flowletToIndexMapping.get(source)).intValue());
		transitionSource.setAnchor(transition.getSourceAnchorIndex());
		//	target
		TransitionTargetFlowletBind transitionTarget = new TransitionTargetFlowletBind();
		FlowletModelPart target = transition.getTarget();
		transitionBind.setTargetFlowlet(transitionTarget);
		transitionTarget.setType(target.getType());
		transitionTarget.setIndex(((Integer)flowletToIndexMapping.get(target)).intValue());
		transitionTarget.setAnchor(transition.getTargetAnchorIndex());
		//	bendpoints
		for (Iterator bendpointsIter = transition.getBendpoints().iterator(); bendpointsIter.hasNext();) {
			TransitionBendpointModelPart bendpoint = (TransitionBendpointModelPart)bendpointsIter.next();
			BendpointBind bendpointBind = new BendpointBind();
			net.orthanc.flow4j.base.Point sourceAnchorOffsetFP =
				AnchorRegistry.getSourceAnchorOffset(source.getType(), transition.getSourceAnchorIndex());
			Point sourceAnchorOffset = new Point(sourceAnchorOffsetFP.x, sourceAnchorOffsetFP.y);
			bendpointBind.setX(
				transition.getSource().getLocation().x
					+ sourceAnchorOffset.x
					+ bendpoint.getFirstRelativeDimension().width);
			bendpointBind.setY(
				transition.getSource().getLocation().y
					+ sourceAnchorOffset.y
					+ bendpoint.getFirstRelativeDimension().height);
			transitionBind.addBendpoint(bendpointBind);
		}
	}
















}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -