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

📄 designermodeldigester.java

📁 一个java写的business process management系统
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
	 * @see net.orthanc.flow4j.model.AbstractModelDigester#digestJumpFlowlet(net.orthanc.flow4j.model.bind.JumpFlowletBind, net.orthanc.flow4j.model.bind.FlowModelBind)
	 */
	protected void digestJumpFlowlet(
		JumpFlowletBind flowletBind,
		FlowModelBind flowModelBind) {
			CreateRequest request = new CreateRequest();
			request.setFactory(new SimpleFactory(JumpFlowletModelPart.class));

			Rectangle flowletRect = new Rectangle(flowletBind.getX(), flowletBind.getY(), 0, 0);
			Rectangle labelRect =
				new Rectangle(flowletBind.getLabel().getX(), flowletBind.getLabel().getY(), 0, 0);

			CompoundCommand command =
				Flow4XYLayoutEditPolicy.getCreateFlowletWithLabelCommand(
					request,
					flowDiagramModelPart,
					flowletRect,
					labelRect,
					flowletBind.getLabel().getText());
			FlowDiagramElementModelPart flowletModelpart = ((CreateCommand)command.getChildren()[0]).getChild();
			flowletToFlowletBindMapping.put(flowletModelpart, flowletBind);
			flowletIdToFlowletMapping.put(flowletBind.getId(flowModelBind), flowletModelpart);

			createCommand.add(command);
	}

	/* (non-Javadoc)
	 * @see net.orthanc.flow4j.model.AbstractModelDigester#digestScriptTaskFlowlet(net.orthanc.flow4j.model.bind.ScriptTaskFlowletBind, net.orthanc.flow4j.model.bind.FlowModelBind)
	 */
	protected void digestScriptTaskFlowlet(
		ScriptTaskFlowletBind flowletBind,
		FlowModelBind flowModelBind) {
			CreateRequest request = new CreateRequest();
			request.setFactory(new SimpleFactory(ScriptTaskFlowletModelPart.class));

			Rectangle flowletRect = new Rectangle(flowletBind.getX(), flowletBind.getY(), 0, 0);
			Rectangle labelRect =
				new Rectangle(flowletBind.getLabel().getX(), flowletBind.getLabel().getY(), 0, 0);

			CompoundCommand command =
				Flow4XYLayoutEditPolicy.getCreateFlowletWithLabelCommand(
					request,
					flowDiagramModelPart,
					flowletRect,
					labelRect,
					flowletBind.getLabel().getText());
			ScriptTaskFlowletModelPart taskFlowletModelpart = (ScriptTaskFlowletModelPart)((CreateCommand)command.getChildren()[0]).getChild();
		
			//System.out.println(flowletBind.getScript());
			//	set the task's properties
	/*		Map taskProperties = new HashMap();
			if (flowletBind.getPropertiesGen() != null) {
				for (Enumeration enum = flowletBind.getPropertiesGen().enumeratePropertyGen(); enum.hasMoreElements(); ) {
					PropertyBind taskPropBind = (PropertyBind)enum.nextElement();
					taskProperties.put(taskPropBind.getName(), taskPropBind.getValue());
				}			
			}
			taskFlowletModelpart.setTaskProperties(taskProperties);
	*/		
			flowletToFlowletBindMapping.put(taskFlowletModelpart, flowletBind);
			flowletIdToFlowletMapping.put(flowletBind.getId(flowModelBind), taskFlowletModelpart);

			createCommand.add(command);
	}

	/* (non-Javadoc)
	 * @see net.orthanc.flow4j.model.AbstractModelDigester#digestTemplateFlowlet(net.orthanc.flow4j.model.bind.TemplateFlowletBind, net.orthanc.flow4j.model.bind.FlowModelBind)
	 */
	protected void digestTemplateFlowlet(
		TemplateFlowletBind flowletBind,
		FlowModelBind flowModelBind) {
			CreateRequest request = new CreateRequest();
			request.setFactory(new SimpleFactory(TemplateFlowletModelPart.class));

			Rectangle flowletRect = new Rectangle(flowletBind.getX(), flowletBind.getY(), 0, 0);
			Rectangle labelRect =
				new Rectangle(flowletBind.getLabel().getX(), flowletBind.getLabel().getY(), 0, 0);

			CompoundCommand command =
				Flow4XYLayoutEditPolicy.getCreateFlowletWithLabelCommand(
					request,
					flowDiagramModelPart,
					flowletRect,
					labelRect,
					flowletBind.getLabel().getText());
			TemplateFlowletModelPart templateFlowletModelpart = (TemplateFlowletModelPart)((CreateCommand)command.getChildren()[0]).getChild();
			templateFlowletModelpart.setDescription(flowletBind.getDescription());
			flowletToFlowletBindMapping.put(templateFlowletModelpart, flowletBind);
			flowletIdToFlowletMapping.put(flowletBind.getId(flowModelBind), templateFlowletModelpart);

			createCommand.add(command);
	}



















	
	
	/**
	 * Performs the basic ConnectionCommand creation
	 * @param transitionBind
	 * @param transitionModelPart
	 */
	private void digestTransition(
		TransitionBind transitionBind,
		IFlowletBind sourceFlowletBind,
		IFlowletBind targetFlowletBind,
		FlowModelBind flowModelBind,
		TransitionModelPart transitionModelPart) {
		ConnectionCommand command = new ConnectionCommand();
		command.setTransition(transitionModelPart);

		command.setSource((FlowletModelPart)flowletIdToFlowletMapping.get(sourceFlowletBind.getId(flowModelBind)));
		command.setSourceAnchorIndex(transitionBind.getSourceFlowlet().getAnchor());

		command.setTarget((FlowletModelPart)flowletIdToFlowletMapping.get(targetFlowletBind.getId(flowModelBind)));
		command.setTargetAnchorIndex(transitionBind.getTargetFlowlet().getAnchor());



//		IFlowletBind source = transitionBind.getSourceFlowlet();
//		TransitionTargetFlowletGen target = transitionBind.getTransitionTargetFlowletGen();
//
//		String flowletRef = source.getType() + "_" + source.getIndex();
//		FlowletModelPart flowletModelPart = (FlowletModelPart)flowletIdToFlowletMapping.get(flowletRef);
//		command.setSource((FlowletModelPart)flowletIdToFlowletMapping.get(flowletRef));
//		command.setSourceAnchorIndex(transitionBind.getTransitionSourceFlowletGen().getAnchor());
//		transitionBind.setSourceFlowletBind((IFlowletBind)flowletToFlowletBindMapping.get(flowletModelPart));
//
//		flowletRef = target.getType() + "_" + target.getIndex();
//		flowletModelPart = (FlowletModelPart)flowletIdToFlowletMapping.get(flowletRef);
//		command.setTarget(flowletModelPart);
//		command.setTargetAnchorIndex(transitionBind.getTransitionTargetFlowletGen().getAnchor());
//		transitionBind.setTargetFlowletBind((IFlowletBind)flowletToFlowletBindMapping.get(flowletModelPart));

		transitionBindToTransitionMapping.put(transitionBind, transitionModelPart);

		createCommand.add(command);

	}













	/* (non-Javadoc)
	 * @see net.orthanc.flow4j.model.AbstractModelDigester#digestTransition(net.orthanc.flow4j.model.bind.TransitionBind, net.orthanc.flow4j.model.bind.IFlowletBind, net.orthanc.flow4j.model.bind.IFlowletBind, net.orthanc.flow4j.model.bind.FlowModelBind)
	 */
	protected void digestTransition(
		TransitionBind transitionBind,
		IFlowletBind sourceFlowletBind,
		IFlowletBind targetFlowletBind,
		FlowModelBind flowModelBind) {
		
		digestTransition(transitionBind, sourceFlowletBind, targetFlowletBind, flowModelBind, new TransitionModelPart());
			//	digest the bendpoints
		super.digestTransition(
			transitionBind,
			sourceFlowletBind,
			targetFlowletBind,
			flowModelBind);
	}


	/* (non-Javadoc)
	 * @see net.orthanc.flow4j.model.AbstractModelDigester#digestBooleanTransition(net.orthanc.flow4j.model.bind.BooleanTransitionBind, net.orthanc.flow4j.model.bind.IFlowletBind, net.orthanc.flow4j.model.bind.IFlowletBind, net.orthanc.flow4j.model.bind.FlowModelBind)
	 */
	protected void digestBooleanTransition(
		BooleanTransitionBind transitionBind,
		IFlowletBind sourceFlowletBind,
		IFlowletBind targetFlowletBind,
		FlowModelBind flowModelBind) {

		digestTransition(
			transitionBind,
			sourceFlowletBind,
			targetFlowletBind,
			flowModelBind,
			new BooleanTransitionModelPart());
		//	digest the bendpoints
		super.digestBooleanTransition(
			transitionBind,
			sourceFlowletBind,
			targetFlowletBind,
			flowModelBind);
	}



	/**
	 * Adds a CreateBendpointCommand to the global CompoundCommand.
	 * Calculates the relative dimensions
	 */
	protected void digestBendpoint(
		TransitionBind transitionBind,
		IFlowletBind sourceFlowletBind,
		IFlowletBind targetFlowletBind,
		BendpointBind bendpointBind,
		FlowModelBind flowModelBind) {
			TransitionModelPart transition = (TransitionModelPart)transitionBindToTransitionMapping.get(transitionBind);

			//	create the command
			CreateBendpointCommand command = new CreateBendpointCommand();
			command.setTransition(transition);

			Point bendpointLocation = new Point(bendpointBind.getX(), bendpointBind.getY());
			Point sourceFlowletBindLoc = new Point(((ILocationHolder)sourceFlowletBind).getX(), ((ILocationHolder)sourceFlowletBind).getY());
			Point targetFlowletBindLoc = new Point(((ILocationHolder)targetFlowletBind).getX(), ((ILocationHolder)targetFlowletBind).getY());
			net.orthanc.flow4j.base.Point sourceOffsetFP =
				AnchorRegistry.getSourceAnchorOffset(
					sourceFlowletBind.getType(),
					transitionBind.getSourceFlowlet().getAnchor());
			Point sourceOffset = new Point(sourceOffsetFP.x, sourceOffsetFP.y);
			Dimension dim1 = bendpointLocation.getDifference(sourceFlowletBindLoc.getTranslated(sourceOffset));

			net.orthanc.flow4j.base.Point targetOffsetFP =
				AnchorRegistry.getTargetAnchorOffset(
					targetFlowletBind.getType(),
					transitionBind.getTargetFlowlet().getAnchor());
			Point targetOffset = new Point(targetOffsetFP.x, targetOffsetFP.y);
			Dimension dim2 = bendpointLocation.getDifference(targetFlowletBindLoc.getTranslated(targetOffset));

			command.setRelativeDimensions(dim1, dim2);
			command.setIndex(transitionBind.getBendpoints().indexOf(bendpointBind));

			createCommand.add(command);
	}



//	############################################################
//	########     FlowModelBind Creation      ###################
//	############################################################
	


	/**
	 * Fills a new FlowModelBind object with the model data, ready for marshalling
	 * @see net.orthanc.flow4j.model.IModelDigester#createFlowDiagramBind()
	 * @return	retruns the filled FlowDiargamBind object
	 */
	public FlowModelBind createFlowModelBind() {
		FlowModelBind flowModelBind = new FlowModelBind(flowDiagramModelPart.getFlowName());

		Map flowletToIndexMapping = new HashMap();

		//	iterate over all flowlets
		for (Iterator iter = flowDiagramModelPart.getChildren().iterator(); iter.hasNext();) {
			FlowDiagramElementModelPart modelPart = (FlowDiagramElementModelPart)iter.next();
			IFlowletBind flowletBind = null;
			Integer flowletIndex = null;
			//	start flowlets
			if (modelPart instanceof StartFlowletModelPart) {
				flowletBind = createStartFlowletBind((StartFlowletModelPart)modelPart);
				flowModelBind.addStartFlowlet((StartFlowletBind)flowletBind);
				flowletIndex = new Integer(flowModelBind.getStartFlowlets().indexOf(flowletBind));
			}
			//	java task flowlets
			else if (modelPart instanceof JavaTaskFlowletModelPart) {
				flowletBind = createJavaTaskFlowletBind((JavaTaskFlowletModelPart)modelPart);
				flowModelBind.addJavaTaskFlowlet((JavaTaskFlowletBind)flowletBind);
				flowletIndex = new Integer(flowModelBind.getJavaTaskFlowlets().indexOf(flowletBind));
			}
			//	script task flowlets
			else if (modelPart instanceof ScriptTaskFlowletModelPart) {
				flowletBind = createScriptTaskFlowletBind((ScriptTaskFlowletModelPart)modelPart);
				flowModelBind.addScriptTaskFlowlet((ScriptTaskFlowletBind)flowletBind);
				flowletIndex = new Integer(flowModelBind.getScriptTaskFlowlets().indexOf(flowletBind));
			}
			//	decision flowlets
			else if (modelPart instanceof DecisionFlowletModelPart) {
				flowletBind = createDecisionFlowletBind((DecisionFlowletModelPart)modelPart);
				flowModelBind.addDecisionFlowlet((DecisionFlowletBind)flowletBind);
				flowletIndex = new Integer(flowModelBind.getDecisionFlowlets().indexOf(flowletBind));
			}
			//	join flowlets

⌨️ 快捷键说明

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