我们正在使用 Modelio 创建实体图并将其导出为 XMI 文件。
一旦我们有了 XMI,我们就可以使用 jhipster uml 工具来生成源代码。
由于我们在某些实体中需要一个日期字段,因此我们在 Modelio 中添加了一个名为 DateTime 的数据类型。目的是在 Java 类中生成 org.joda.time.DateTime。
运行 jhipster url.jhipster-uml test.xmi 时出现以下错误
Parser detected: MODELIO.
The type 'DateTime' isn't supported by JHipster, exiting now.
Error
at Object.<anonymous> (/usr/local/lib/node_modules/jhipster-uml/lib/exceptions/invalid_type_exception.js:7:34)
at Module._compile (module.js:435:26)
at Object.Module._extensions..js (module.js:442:10)
我们在这里缺少什么?我认为我们需要以某种方式告诉 Modelio 在哪里/如何将 DateTime 类型映射到 joda 类。
下面是通过 Modelio 3.4.1 导出的完整 XMI 文件
<?xml version="1.0" encoding="UTF-8"?>
<xmi:XMI xmi:version="2.1" xmlns:xmi="http://schema.omg.org/spec/XMI/2.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:JavaExtensions="http:///schemas/JavaExtensions/_UVePsJdXEeWrwNWyJ1cDng/0" xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" xmlns:uml="http://www.eclipse.org/uml2/3.0.0/UML" xsi:schemaLocation="http:///schemas/JavaExtensions/_UVePsJdXEeWrwNWyJ1cDng/0 JavaExtensions.profile.xmi#_UVnZp5dXEeWrwNWyJ1cDng">
<uml:Model xmi:id="_UVGcQJdXEeWrwNWyJ1cDng" name="test">
<eAnnotations xmi:id="_UVGcQZdXEeWrwNWyJ1cDng" source="Objing">
<contents xmi:type="uml:Property" xmi:id="_UVGcQpdXEeWrwNWyJ1cDng" name="exporterVersion">
<defaultValue xmi:type="uml:LiteralString" xmi:id="_UVGcQ5dXEeWrwNWyJ1cDng" value="3.0.0"/>
</contents>
</eAnnotations>
<packagedElement xmi:type="uml:Class" xmi:id="_UVGcRJdXEeWrwNWyJ1cDng" name="TestClass">
<ownedComment xmi:id="_UVGcRZdXEeWrwNWyJ1cDng">
<body><Enter note text here></body>
</ownedComment>
<ownedAttribute xmi:id="_UVGcRpdXEeWrwNWyJ1cDng" name="testAtt" visibility="public" type="_UVGcR5dXEeWrwNWyJ1cDng" isUnique="false"/>
</packagedElement>
<packagedElement xmi:type="uml:PrimitiveType" xmi:id="_UVGcR5dXEeWrwNWyJ1cDng" name="DateTime"/>
<profileApplication xmi:id="_UWtl0JdXEeWrwNWyJ1cDng">
<eAnnotations xmi:id="_UWvbAJdXEeWrwNWyJ1cDng" source="http://www.eclipse.org/uml2/2.0.0/UML">
<references xmi:type="ecore:EPackage" href="JavaExtensions.profile.xmi#_UVnZp5dXEeWrwNWyJ1cDng"/>
</eAnnotations>
<appliedProfile href="JavaExtensions.profile.xmi#_UVnZoJdXEeWrwNWyJ1cDng"/>
</profileApplication>
</uml:Model>
<JavaExtensions:JavaDataType xmi:id="_UW1hoJdXEeWrwNWyJ1cDng" base_DataType="_UVGcR5dXEeWrwNWyJ1cDng" base_PrimitiveType="_UVGcR5dXEeWrwNWyJ1cDng"/>
</xmi:XMI>