@Override public void convertModelToXML(Element element, BaseElement baseElement) { SequenceFlow sequenceFlow = (SequenceFlow) baseElement; element.addAttribute(BpmnXMLConstants.ATTRIBUTE_SOURCEREF, sequenceFlow.getSourceRefId()); element.addAttribute(BpmnXMLConstants.ATTRIBUTE_TARGETREF, sequenceFlow.getTargetRefId()); if (null != sequenceFlow.getFlowCondition()) { String condition = sequenceFlow.getFlowCondition(); Element childElem = element.addElement(BpmnXMLConstants.BPMN2_PREFIX + ':' + BpmnXMLConstants.ELEMENT_CONDITIONEXPRESSION); childElem.addAttribute(BpmnXMLConstants.XSI_PREFIX + ':' + BpmnXMLConstants.TYPE, BpmnXMLConstants.BPMN2_PREFIX + ':' + BpmnXMLConstants.TYPE_FORMALEXPRESSION); childElem.addAttribute(BpmnXMLConstants.ATTRIBUTE_ID, UniqueIDUtil.getInstance().generateElementID(BpmnXMLConstants.TYPE_FORMALEXPRESSION)); childElem.addAttribute(BpmnXMLConstants.FOXBPM_PREFIX + ':' + BpmnXMLConstants.ATTRIBUTE_NAME, BpmnXMLUtil.interceptStr(condition)); childElem.add(new DOMCDATA(condition)); } super.convertModelToXML(element, baseElement); }
private static void createStarterElement(Element parentElement, List<PotentialStarter> potentialStarters) { if (null != potentialStarters) { PotentialStarter potentialStarter = null; Element potentialStarterEle = null; Element childElem = null; String id = null; for (Iterator<PotentialStarter> iterator = potentialStarters.iterator(); iterator.hasNext();) { potentialStarter = iterator.next(); potentialStarterEle = parentElement.addElement(BpmnXMLConstants.FOXBPM_PREFIX + ':' + BpmnXMLConstants.ELEMENT_POTENTIAL_STARTER); potentialStarterEle.addAttribute(BpmnXMLConstants.ATTRIBUTE_RESOURCETYPE, potentialStarter.getResourceType()); potentialStarterEle.addAttribute(BpmnXMLConstants.ATTRIBUTE_DESCRIPTION, potentialStarter.getDocumentation()); childElem = potentialStarterEle.addElement(BpmnXMLConstants.FOXBPM_PREFIX + ':' + BpmnXMLConstants.ELEMENT_EXPRESSION); childElem.addAttribute(BpmnXMLConstants.XSI_PREFIX + ':' + BpmnXMLConstants.TYPE, BpmnXMLConstants.FOXBPM_PREFIX + ':' + BpmnXMLConstants.TYPE_EXPRESSION); id = UniqueIDUtil.getInstance().generateElementID(null); childElem.addAttribute(BpmnXMLConstants.ATTRIBUTE_ID, BpmnXMLConstants.ELEMENT_EXPRESSION + '_' + id); childElem.addAttribute(BpmnXMLConstants.ATTRIBUTE_NAME, id); childElem.add(new DOMCDATA(potentialStarter.getExpression())); } } }
@Override public void export(ExportHelper helper) throws IOException { String s = helper.getParameter("script"); if (s == null) throw new IllegalArgumentException("No script provided, please set the script parameter."); Script script = ScriptDAO.getInstance().get(Long.valueOf(s)); if (script == null) throw new IllegalArgumentException("Stript " + s + " does not exist."); helper.getSessionContext().checkPermission(Right.ScriptEdit); helper.setup("text/xml", script.getName().replace('/', '-').replace('\\', '-').replace(':', '-') + ".xml", false); Document document = DocumentHelper.createDocument(); Element scriptEl = document.addElement("script"); scriptEl.addAttribute("name", script.getName()); if (script.getPermission() != null) scriptEl.addAttribute("permission", script.getPermission()); scriptEl.addAttribute("engine", script.getEngine()); if (script.getDescription() != null) scriptEl.addElement("description").add(new DOMCDATA(script.getDescription())); for (ScriptParameter parameter: script.getParameters()) { Element paramEl = scriptEl.addElement("parameter"); paramEl.addAttribute("name", parameter.getName()); if (parameter.getLabel() != null) paramEl.addAttribute("label", parameter.getLabel()); paramEl.addAttribute("type", parameter.getType()); if (parameter.getDefaultValue() != null) paramEl.addAttribute("default", parameter.getDefaultValue()); } if (script.getScript() != null) scriptEl.addElement("body").add(new DOMCDATA(script.getScript())); scriptEl.addAttribute("created", new Date().toString()); OutputStream out = helper.getOutputStream(); new XMLWriter(out, OutputFormat.createPrettyPrint()).write(document); }
@Override public void export(ExportHelper helper) throws IOException { String s = helper.getParameter("id"); if (s == null) throw new IllegalArgumentException("No report provided, please set the id parameter."); SavedHQL report = SavedHQLDAO.getInstance().get(Long.valueOf(s)); if (report == null) throw new IllegalArgumentException("Report " + s + " does not exist."); helper.getSessionContext().checkPermission(report, Right.HQLReportEdit); helper.setup("text/xml", report.getName().replace('/', '-').replace('\\', '-').replace(':', '-') + ".xml", false); Document document = DocumentHelper.createDocument(); document.addDocType("report", "-//UniTime//UniTime HQL Reports DTD/EN", "http://www.unitime.org/interface/Reports.dtd"); Element reportEl = document.addElement("report"); reportEl.addAttribute("name", report.getName()); for (SavedHQL.Flag flag : SavedHQL.Flag.values()) { if (report.isSet(flag)) reportEl.addElement("flag").setText(flag.name()); } if (report.getDescription() != null) reportEl.addElement("description").add(new DOMCDATA(report.getDescription())); if (report.getQuery() != null) reportEl.addElement("query").add(new DOMCDATA(report.getQuery())); reportEl.addAttribute("created", new Date().toString()); OutputStream out = helper.getOutputStream(); new XMLWriter(out, OutputFormat.createPrettyPrint()).write(document); }
/** * foxbpm:expression 给xml元素添加属性 * * @param element * foxbpm:expression * @param obj */ public static void createExpressionElement(Element element, Object obj) { String expression = obj.toString(); element.addAttribute(BpmnXMLConstants.XSI_PREFIX + ':' + BpmnXMLConstants.TYPE, BpmnXMLConstants.FOXBPM_PREFIX + ':' + BpmnXMLConstants.TYPE_EXPRESSION); element.addAttribute(BpmnXMLConstants.ATTRIBUTE_ID, UniqueIDUtil.getInstance().generateElementID(BpmnXMLConstants.TYPE_EXPRESSION)); element.addAttribute(BpmnXMLConstants.ATTRIBUTE_NAME, BpmnXMLUtil.interceptStr(expression)); element.add(new DOMCDATA(expression)); }
/** * 创建foxbpm:expression 节点 * * @param element * @param obj */ public static void createExpressionElementByParent(Element element, Object obj) { Element expressionElement = element.addElement(BpmnXMLConstants.FOXBPM_PREFIX + ':' + BpmnXMLConstants.ELEMENT_EXPRESSION, BpmnXMLConstants.FOXBPM_NAMESPACE); String expression = obj.toString(); expressionElement.addAttribute(BpmnXMLConstants.XSI_PREFIX + ':' + BpmnXMLConstants.TYPE, BpmnXMLConstants.FOXBPM_PREFIX + ':' + BpmnXMLConstants.TYPE_EXPRESSION); expressionElement.addAttribute(BpmnXMLConstants.ATTRIBUTE_ID, UniqueIDUtil.getInstance().generateElementID(BpmnXMLConstants.TYPE_EXPRESSION)); expressionElement.addAttribute(BpmnXMLConstants.ATTRIBUTE_NAME, BpmnXMLUtil.interceptStr(expression)); expressionElement.add(new DOMCDATA(expression)); }
private static void createInputsParam(Element parentElement, List<InputParam> inputsParam) { if (null != inputsParam && !inputsParam.isEmpty()) { InputParam inputParam = null; Element childElem = null; Element expressionElem = null; for (Iterator<InputParam> iterator = inputsParam.iterator(); iterator.hasNext();) { inputParam = iterator.next(); childElem = parentElement.addElement(BpmnXMLConstants.FOXBPM_PREFIX + ':' + BpmnXMLConstants.ELEMENT_CONNECTORPARAMETER_INPUTS); childElem.addAttribute(BpmnXMLConstants.XSI_PREFIX + ':' + BpmnXMLConstants.TYPE, BpmnXMLConstants.FOXBPM_PREFIX + ':' + BpmnXMLConstants.TYPE_CONNECTORPARAMETERINPUT); BpmnXMLUtil.addElemAttribute(childElem, BpmnXMLConstants.ATTRIBUTE_ID, inputParam.getId()); BpmnXMLUtil.addElemAttribute(childElem, BpmnXMLConstants.ATTRIBUTE_NAME, inputParam.getName()); BpmnXMLUtil.addElemAttribute(childElem, BpmnXMLConstants.ATTRIBUTE_DATATYPE, inputParam.getDataType()); BpmnXMLUtil.addElemAttribute(childElem, BpmnXMLConstants.ATTRIBUTE_ISEXECUTE, String.valueOf(inputParam.isExecute())); if (null != inputParam.getExpression()) { expressionElem = childElem.addElement(BpmnXMLConstants.FOXBPM_PREFIX + ':' + BpmnXMLConstants.ELEMENT_EXPRESSION); expressionElem.addAttribute(BpmnXMLConstants.XSI_PREFIX + ':' + BpmnXMLConstants.TYPE, BpmnXMLConstants.FOXBPM_PREFIX + ':' + BpmnXMLConstants.TYPE_EXPRESSION); expressionElem.addAttribute(BpmnXMLConstants.ATTRIBUTE_NAME, BpmnXMLUtil.interceptStr(inputParam.getExpression())); expressionElem.add(new DOMCDATA(inputParam.getExpression())); } } } }
private static void createDataVariableElement(Element parentElement, List<DataVariableDefinition> dataVariables) { if (null != dataVariables) { DataVariableDefinition dataVariableDefinition = null; Element dataVariableEle = null; Element childElem = null; for (Iterator<DataVariableDefinition> iterator = dataVariables.iterator(); iterator.hasNext();) { dataVariableDefinition = iterator.next(); dataVariableEle = parentElement.addElement(BpmnXMLConstants.FOXBPM_PREFIX + ':' + BpmnXMLConstants.ELEMENT_DATAVARIABLE); dataVariableEle.addAttribute(BpmnXMLConstants.ATTRIBUTE_ID, dataVariableDefinition.getId()); dataVariableEle.addAttribute(BpmnXMLConstants.ATTRIBUTE_DATATYPE, dataVariableDefinition.getDataType()); dataVariableEle.addAttribute(BpmnXMLConstants.ATTRIBUTE_BIZTYPE, dataVariableDefinition.getBizType()); dataVariableEle.addAttribute(BpmnXMLConstants.ATTRIBUTE_FIELDNAME, dataVariableDefinition.getFieldName()); if (dataVariableDefinition.isPersistence()) { dataVariableEle.addAttribute(BpmnXMLConstants.ATTRIBUTE_ISPERSISTENCE, String.valueOf(dataVariableDefinition.isPersistence())); } // 描述 if (null != dataVariableDefinition.getDocumentation()) { childElem = dataVariableEle.addElement(BpmnXMLConstants.FOXBPM_PREFIX + ':' + BpmnXMLConstants.ELEMENT_DOCUMENTATION); childElem.addAttribute(BpmnXMLConstants.XSI_PREFIX + ':' + BpmnXMLConstants.TYPE, BpmnXMLConstants.FOXBPM_PREFIX + ':' + BpmnXMLConstants.TYPE_DOCUMENTATION); childElem.setText(dataVariableDefinition.getDocumentation()); } if (null != dataVariableDefinition.getExpression()) { // 表达式 childElem = dataVariableEle.addElement(BpmnXMLConstants.FOXBPM_PREFIX + ':' + BpmnXMLConstants.ELEMENT_EXPRESSION); childElem.addAttribute(BpmnXMLConstants.XSI_PREFIX + ':' + BpmnXMLConstants.TYPE, BpmnXMLConstants.FOXBPM_PREFIX + ':' + BpmnXMLConstants.TYPE_EXPRESSION); childElem.addAttribute(BpmnXMLConstants.ATTRIBUTE_ID, UniqueIDUtil.getInstance().generateElementID(BpmnXMLConstants.ELEMENT_EXPRESSION)); childElem.addAttribute(BpmnXMLConstants.ATTRIBUTE_NAME, BpmnXMLUtil.interceptStr(dataVariableDefinition.getExpression())); childElem.add(new DOMCDATA(dataVariableDefinition.getExpression())); } } } }
/** * Generates XML document containing brief representation of records matching the query * @param hits - Array of records matching the query * @return Returns XML (payload) document to be inserted into SOAP message */ private Document prepareResult(Record []hits){ Element content=new DOMElement("content"); BriefFormatter rf=(BriefFormatter)RecordFormatterFactory.getFormatter(RecordFormatterFactory.FORMAT_BRIEF); content.addAttribute("count",""+0); int counter=0; UnimarcConverter conv=new UnimarcConverter(); if(hits!=null){ for (int i=0;i<hits.length;i++){ Record oneHit = hits[i]; if(oneHit!=null){ Element recBrief=new DOMElement("record_brief"); recBrief.addAttribute("recId",""+oneHit.getRecordID()); //add author element Element author = new DOMElement("author"); author.add(new DOMCDATA(getElementContent(rf.getAuthor(oneHit, "sr").toString(),conv))); recBrief.add(author); //add title element Element title = new DOMElement("title"); title.add(new DOMCDATA(getElementContent(rf.getTitle(oneHit),conv))); recBrief.add(title); //add publisher element Element publisher = new DOMElement("publisher"); publisher.add(new DOMCDATA(getElementContent(rf.getTitle(oneHit),conv))); recBrief.add(publisher); //add publication year element Element pubYear = new DOMElement("publication_year"); pubYear.add(new DOMCDATA(rf.getYear(oneHit))); recBrief.add(pubYear); //add language year element Element language = new DOMElement("language"); language.add(new DOMCDATA(rf.getLanguageOfOriginal(oneHit))); recBrief.add(language); //add language year element Element country = new DOMElement("country"); country.add(new DOMCDATA(rf.getCountry(oneHit))); recBrief.add(country); content.add(recBrief); counter++; }else{ if(MessagingEnvironment.DEBUG==1) System.out.println("Null objekat za record"); } } content.addAttribute("count",""+counter); } Document newDoc = MessageUtil.messageSetup("bisis_response","http://www.w3.org/2001/XMLSchema-instance",respSchemaURL,"PerformSearchResponse",content); return newDoc; }
@Override public void convertModelToXML(Element element, BaseElement baseElement) { Event event = (Event) baseElement; if (null != event.getEventDefinitions()) { EventDefinition eventDefinition = null; TimerEventDefinition timerEventDefinition = null; TerminateEventDefinition terminateEventDefinition = null; Element childElem = null; Element nodeElem = null; for (Iterator<EventDefinition> iterator = event.getEventDefinitions().iterator(); iterator.hasNext();) { eventDefinition = iterator.next(); // 处理时间 if (eventDefinition instanceof TimerEventDefinition) { timerEventDefinition = (TimerEventDefinition) eventDefinition; childElem = element.addElement(BpmnXMLConstants.BPMN2_PREFIX + ':' + BpmnXMLConstants.ELEMENT_TIMEREVENTDEFINITION); childElem.addAttribute(BpmnXMLConstants.ATTRIBUTE_ID, timerEventDefinition.getId()); if (null != timerEventDefinition.getTimeCycle()) { nodeElem = childElem.addElement(BpmnXMLConstants.BPMN2_PREFIX + ':' + BpmnXMLConstants.ELEMENT_TIMECYCLE); nodeElem.addAttribute(BpmnXMLConstants.XSI_PREFIX + ':' + BpmnXMLConstants.TYPE, BpmnXMLConstants.BPMN2_PREFIX + ':' + BpmnXMLConstants.TYPE_FORMALEXPRESSION); nodeElem.addAttribute(BpmnXMLConstants.ATTRIBUTE_ID, UniqueIDUtil.getInstance().generateElementID(BpmnXMLConstants.FORMALEXPRESSION)); nodeElem.addAttribute(BpmnXMLConstants.FOXBPM_PREFIX + ':' + BpmnXMLConstants.ATTRIBUTE_NAME, BpmnXMLUtil.interceptStr(timerEventDefinition.getTimeCycle())); nodeElem.add(new DOMCDATA(timerEventDefinition.getTimeCycle())); } if (null != timerEventDefinition.getTimeDuration()) { nodeElem = childElem.addElement(BpmnXMLConstants.BPMN2_PREFIX + ':' + BpmnXMLConstants.ELEMENT_TIMEDURATION); nodeElem.addAttribute(BpmnXMLConstants.XSI_PREFIX + ':' + BpmnXMLConstants.TYPE, BpmnXMLConstants.BPMN2_PREFIX + ':' + BpmnXMLConstants.TYPE_FORMALEXPRESSION); nodeElem.addAttribute(BpmnXMLConstants.ATTRIBUTE_ID, UniqueIDUtil.getInstance().generateElementID(BpmnXMLConstants.FORMALEXPRESSION)); nodeElem.addAttribute(BpmnXMLConstants.FOXBPM_PREFIX + ':' + BpmnXMLConstants.ATTRIBUTE_NAME, BpmnXMLUtil.interceptStr(timerEventDefinition.getTimeDuration())); nodeElem.add(new DOMCDATA(timerEventDefinition.getTimeDuration())); } if (null != timerEventDefinition.getTimeDate()) { nodeElem = childElem.addElement(BpmnXMLConstants.BPMN2_PREFIX + ':' + BpmnXMLConstants.ELEMENT_TIMEDATE); nodeElem.addAttribute(BpmnXMLConstants.XSI_PREFIX + ':' + BpmnXMLConstants.TYPE, BpmnXMLConstants.BPMN2_PREFIX + ':' + BpmnXMLConstants.TYPE_FORMALEXPRESSION); nodeElem.addAttribute(BpmnXMLConstants.ATTRIBUTE_ID, UniqueIDUtil.getInstance().generateElementID(BpmnXMLConstants.FORMALEXPRESSION)); nodeElem.addAttribute(BpmnXMLConstants.FOXBPM_PREFIX + ':' + BpmnXMLConstants.ATTRIBUTE_NAME, BpmnXMLUtil.interceptStr(timerEventDefinition.getTimeDate())); nodeElem.add(new DOMCDATA(timerEventDefinition.getTimeDate())); } } else if (eventDefinition instanceof TerminateEventDefinition) { terminateEventDefinition = (TerminateEventDefinition) eventDefinition; childElem = element.addElement(BpmnXMLConstants.BPMN2_PREFIX + ':' + BpmnXMLConstants.ELEMENT_TERMINATEEVENTDEFINITION); childElem.addAttribute(BpmnXMLConstants.ATTRIBUTE_ID, terminateEventDefinition.getId()); } } } super.convertModelToXML(element, baseElement); }
private static void createExtensionElement(Element processEle, Process process) { // 基本属性设置 Element extensionElements = processEle.addElement(BpmnXMLConstants.BPMN2_PREFIX + ':' + BpmnXMLConstants.ELEMENT_EXTENSION_ELEMENTS); Element childElem = null; Element expression = null; // 表单url if (null != process.getFormUri()) { childElem = extensionElements.addElement(BpmnXMLConstants.FOXBPM_PREFIX + ':' + BpmnXMLConstants.ELEMENT_FORMURI); expression = childElem.addElement(BpmnXMLConstants.FOXBPM_PREFIX + ':' + BpmnXMLConstants.ELEMENT_EXPRESSION); expression.addAttribute(BpmnXMLConstants.XSI_PREFIX + ':' + BpmnXMLConstants.TYPE, BpmnXMLConstants.FOXBPM_PREFIX + ':' + BpmnXMLConstants.TYPE_EXPRESSION); expression.addAttribute(BpmnXMLConstants.ATTRIBUTE_ID, UniqueIDUtil.getInstance().generateElementID(BpmnXMLConstants.ELEMENT_EXPRESSION)); expression.addAttribute(BpmnXMLConstants.ATTRIBUTE_NAME, BpmnXMLUtil.interceptStr(process.getFormUri())); expression.add(new DOMCDATA(process.getFormUri())); } // taskSubject if (null != process.getSubject()) { childElem = extensionElements.addElement(BpmnXMLConstants.FOXBPM_PREFIX + ':' + BpmnXMLConstants.ELEMENT_TASKSUBJECT); childElem.addAttribute(BpmnXMLConstants.ATTRIBUTE_ID, UniqueIDUtil.getInstance().generateElementID(BpmnXMLConstants.ELEMENT_TASKSUBJECT)); expression = childElem.addElement(BpmnXMLConstants.FOXBPM_PREFIX + ':' + BpmnXMLConstants.ELEMENT_EXPRESSION); expression.addAttribute(BpmnXMLConstants.XSI_PREFIX + ':' + BpmnXMLConstants.TYPE, BpmnXMLConstants.FOXBPM_PREFIX + ':' + BpmnXMLConstants.TYPE_EXPRESSION); expression.addAttribute(BpmnXMLConstants.ATTRIBUTE_ID, UniqueIDUtil.getInstance().generateElementID(BpmnXMLConstants.ELEMENT_EXPRESSION)); expression.addAttribute(BpmnXMLConstants.ATTRIBUTE_NAME, BpmnXMLUtil.interceptStr(process.getSubject())); expression.add(new DOMCDATA(process.getSubject())); } // formUriView if (null != process.getFormUriView()) { childElem = extensionElements.addElement(BpmnXMLConstants.FOXBPM_PREFIX + ':' + BpmnXMLConstants.ELEMENT_FORMURIVIEW); expression = childElem.addElement(BpmnXMLConstants.FOXBPM_PREFIX + ':' + BpmnXMLConstants.ELEMENT_EXPRESSION); expression.addAttribute(BpmnXMLConstants.XSI_PREFIX + ':' + BpmnXMLConstants.TYPE, BpmnXMLConstants.FOXBPM_PREFIX + ':' + BpmnXMLConstants.TYPE_EXPRESSION); expression.addAttribute(BpmnXMLConstants.ATTRIBUTE_ID, UniqueIDUtil.getInstance().generateElementID(BpmnXMLConstants.ELEMENT_EXPRESSION)); expression.addAttribute(BpmnXMLConstants.ATTRIBUTE_NAME, BpmnXMLUtil.interceptStr(process.getFormUriView())); expression.add(new DOMCDATA(process.getFormUriView())); } // 数据变量 createDataVariableElement(extensionElements, process.getDataVariables()); // 启动人 createStarterElement(extensionElements, process.getPotentialStarters()); // 连接器 BpmnXMLUtil.createConectorElement(extensionElements, BpmnXMLConstants.TYPE_FLOWCONNECTOR, process.getConnector()); }