使用Acceleo

时间:2018-07-19 08:54:50

标签: acceleo

我开始使用AcceleoBPMN model生成文本。

我正在使用BPMN2Modeler生成的BPMN模型作为输入,并且我已经安装了Acceleo 3.7.3。

输入模型为:

<?xml version="1.0" encoding="UTF-8"?>
<!-- origin at X=0.0 Y=0.0 -->
<bpmn2:definitions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
  xmlns:bpmn2="http://www.omg.org/spec/BPMN/20100524/MODEL" 
  xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" 
  xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" 
  xmlns:di="http://www.omg.org/spec/DD/20100524/DI" 
  xmlns:ext="http://org.eclipse.bpmn2/ext" 
  xmlns:xs="http://www.w3.org/2001/XMLSchema" 
  id="Definitions_1" 
  exporter="org.eclipse.bpmn2.modeler.core" 
  exporterVersion="1.4.2.Final-v20171109-1930-B1" 
  targetNamespace="http://org.eclipse.bpmn2/default/process">
  <bpmn2:process id="base" name="Default Process" isExecutable="false">
    <bpmn2:startEvent id="StartEvent_1" name="Start Event 1">
      <bpmn2:outgoing>SequenceFlow_2</bpmn2:outgoing>
    </bpmn2:startEvent>
    <bpmn2:endEvent id="EndEvent_1" name="End Event 1">
      <bpmn2:incoming>SequenceFlow_5</bpmn2:incoming>
    </bpmn2:endEvent>
    <bpmn2:task id="Task_1" name="tarea1">
      <bpmn2:incoming>SequenceFlow_2</bpmn2:incoming>
      <bpmn2:outgoing>SequenceFlow_3</bpmn2:outgoing>
    </bpmn2:task>
    <bpmn2:sequenceFlow id="SequenceFlow_2" sourceRef="StartEvent_1" targetRef="Task_1"/>
    <bpmn2:task id="Task_2" name="tarea2">
      <bpmn2:incoming>SequenceFlow_3</bpmn2:incoming>
      <bpmn2:outgoing>SequenceFlow_4</bpmn2:outgoing>
    </bpmn2:task>
    <bpmn2:sequenceFlow id="SequenceFlow_3" sourceRef="Task_1" targetRef="Task_2"/>
    <bpmn2:task id="Task_3" name="tarea3">
      <bpmn2:incoming>SequenceFlow_4</bpmn2:incoming>
      <bpmn2:outgoing>SequenceFlow_5</bpmn2:outgoing>
    </bpmn2:task>
    <bpmn2:sequenceFlow id="SequenceFlow_4" sourceRef="Task_2" targetRef="Task_3"/>
    <bpmn2:sequenceFlow id="SequenceFlow_5" sourceRef="Task_3" targetRef="EndEvent_1"/>
  </bpmn2:process>
</bpmn2:definitions>

我创建了一个Acceleo项目并创建了一个模块文件,为此我尝试选择我认为必要的元模型。即我可以选择:

http://www.omg.org/spec/BPMN/20100524/DI
http://www.omg.org/spec/BPMN/20100524/DI-XMI
http://www.omg.org/spec/BPMN/20100524/MODEL
http://www.omg.org/spec/BPMN/20100524/MODEL-XMI
http://www.omg.org/spec/DD/20100524/DC-XMI
http://www.omg.org/spec/DD/20100524/DI
http://www.omg.org/spec/DD/20100524/DI-XMI

它们是在安装BPMN2Modeler时注册的。

如果我尝试选择不以-XMI结尾的元模型,则图形界面将不包含它们,但不会产生任何错误消息。如果我选择以-XMI结尾的元模型,则可以将它们正确添加到模块文件中。

[comment encoding = UTF-8 /]
[module generate('http:// www.omg.org/spec/BPMN/20100524/MODEL-XMI', 'http://www.omg.org/spec/BPMN/20100524/DI-XMI', 'http://www.omg.org/spec/DD/20100524/DI-XMI', 'http://www.omg.org/spec/DD/20100524/DC-XMI')]

[template public generateElement(aDefinitions : Definitions)]
[comment @main/]
[file (aDefinitions.name.concat('.java'), false)]
[/file]

[/template]

当我尝试运行它时,将其配置为作为Acceleo插件应用程序运行时会失败:

  

null org.eclipse.acceleo.ide.ui错误2018年7月18日星期三13:35:47   无法加载课程   org.eclipse.acceleo.gonzalo.lopez.sample.common。从项目生成   org.eclipse.acceleo.gonzalo.lopez.sample null   org.eclipse.acceleo.common警告星期三2018年7月18日13:35:46   无法加载org.eclipse.acceleo类。   gonzalo.lopez.sample.common.Generate。检查其是否包含   包已导出。

但是,组织。日食。 acceleo.gonzalo.lopez.sample.common软件包在导出的软件包列表中。 [Acceleo文档中提供的UML示例也会发生相同的错误。]

如果我将其作为Java应用程序运行,则生成失败,并声称找不到“ definitions”类(模型的最外部元素)或该类是抽象的。

我认为该错误是由元模型的选择引起的,但是我对如何解决它一无所知。任何帮助将不胜感激。

    Exception in thread "main" org.eclipse.emf.ecore.resource.impl.ResourceSetImpl$1DiagnosticWrappedException: org.eclipse.emf.ecore.xmi.ClassNotFoundException: Class 'definitions' is not found or is abstract. (file:/Users/jmalvarez/workspaces/photon-mod-dsl-workspace/org.eclipse.acceleo.gonzalo.lopez.sample/models/base.bpmn, 3, 541)
    at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.handleDemandLoadException(ResourceSetImpl.java:319)
    at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLoadHelper(ResourceSetImpl.java:278)
    at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.getResource(ResourceSetImpl.java:406)
    at org.eclipse.acceleo.common.utils.ModelUtils.load(ModelUtils.java:391)
    at org.eclipse.acceleo.common.utils.ModelUtils.load(ModelUtils.java:356)
    at org.eclipse.acceleo.engine.service.AbstractAcceleoGenerator.initialize(AbstractAcceleoGenerator.java:488)
    at org.eclipse.acceleo.gonzalo.lopez.sample.common.Generate.<init>(Generate.java:90)
    at org.eclipse.acceleo.gonzalo.lopez.sample.common.Generate.main(Generate.java:144)
Caused by: org.eclipse.emf.ecore.xmi.ClassNotFoundException: Class 'definitions' is not found or is abstract. (file:/Users/jmalvarez/workspaces/photon-mod-dsl-workspace/org.eclipse.acceleo.gonzalo.lopez.sample/models/base.bpmn, 3, 541)
    at org.eclipse.emf.ecore.xmi.impl.XMLHandler.validateCreateObjectFromFactory(XMLHandler.java:2298)
    at org.eclipse.emf.ecore.xmi.impl.XMLHandler.validateCreateObjectFromFactory(XMLHandler.java:2289)
    at org.eclipse.emf.ecore.xmi.impl.XMLHandler.createObjectByType(XMLHandler.java:1386)
    at org.eclipse.emf.ecore.xmi.impl.XMLHandler.createTopObject(XMLHandler.java:1522)
    at org.eclipse.emf.ecore.xmi.impl.XMLHandler.processElement(XMLHandler.java:1044)
    at org.eclipse.emf.ecore.xmi.impl.XMIHandler.processElement(XMIHandler.java:78)
    at org.eclipse.emf.ecore.xmi.impl.XMLHandler.startElement(XMLHandler.java:1026)
    at org.eclipse.emf.ecore.xmi.impl.XMLHandler.startElement(XMLHandler.java:720)
    at org.eclipse.emf.ecore.xmi.impl.XMIHandler.startElement(XMIHandler.java:190)
    at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.startElement(AbstractSAXParser.java:509)
    at com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDValidator.startElement(XMLDTDValidator.java:745)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanStartElement(XMLDocumentFragmentScannerImpl.java:1364)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$ContentDriver.scanRootElementHook(XMLDocumentScannerImpl.java:1295)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:3135)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$PrologDriver.next(XMLDocumentScannerImpl.java:880)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:606)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:510)
    at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:848)
    at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:777)
    at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:141)
    at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1213)
    at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:643)
    at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl.parse(SAXParserImpl.java:327)
    at org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl.load(XMLLoadImpl.java:175)
    at org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl.doLoad(XMLResourceImpl.java:261)
    at org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(ResourceImpl.java:1563)
    at org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(ResourceImpl.java:1342)
    at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLoad(ResourceSetImpl.java:259)
    at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLoadHelper(ResourceSetImpl.java:274)
    ... 6 more

0 个答案:

没有答案