简体   繁体   English

在Java中使用OCL验证XMI模型

[英]Validate xmi model using OCL in Java

I am trying to create a stand alone Java application that accepts an xmi model and an OCL file containing constraints applied to the model's meta-model. 我正在尝试创建一个独立的Java应用程序,该应用程序接受一个xmi模型和一个OCL文件,其中包含应用于该模型的元模型的约束。 The application then validates the model against the ocl. 然后,应用程序根据ocl验证模型。

I have managed to do this inside eclipse using the EMF. 我设法使用EMF在eclipse中做到这一点。 However when I start to create the java app, many libraries are missing. 但是,当我开始创建Java应用程序时,缺少许多库。 Some of which I was able to locate in the plugins directory but some seem to be missing. 其中一些我可以在plugins目录中找到,但有些似乎丢失了。

For example 例如

org.eclipse.ocl.examples.library.oclstdlib.OCLstdlib;

cannot be found. 找不到。

Is there a straight forward way, using the EMF to accomplish what I am trying to do. 有没有一种直接的方法,可以使用EMF来完成我尝试做的事情。 I have been trying to create something very much like the following: 我一直在尝试创建类似于以下内容的内容:

http://subversion.assembla.com/svn/da_sw_tf/trunk/OCL/src/ocl/OCLEvaluator.java http://subversion.assembla.com/svn/da_sw_tf/trunk/OCL/src/ocl/OCLEvaluator.java

Something missing, usually means something bad configured. 缺少某些东西通常意味着配置错误。 Without more information I can only point you out to the OCL Help , where it explains why and how you need to do some manual registrations in order to execute OCL code in standalone mode. 没有更多信息,我只能向您指出OCL帮助 ,它在其中解释了为什么以及如何需要进行一些手动注册才能在独立模式下执行OCL代码。

Taken from the help: 来自帮助:

"If you use Eclipse OCL within Eclipse you should find that the appropriate registrations are provided for you automatically by the plugin registration mechanisms. “如果您在Eclipse中使用Eclipse OCL,则应该发现插件注册机制会自动为您提供适当的注册。

However if you use Eclipse OCL outside Eclipse, for instance in JUnit tests, you must provide the corresponding registrations in your code." 但是,如果您在Eclipse之外(例如在JUnit测试中)使用Eclipse OCL,则必须在代码中提供相应的注册。”

The eclipse plugins were located in my personal folder under .eclipse. eclipse插件位于我的.eclipse下的个人文件夹中。 I had completely forgotten about the personal instances of the plugins. 我完全忘记了插件的个人实例。 Instead I re-installed everything only to realise the the libraries were not in the install directory plugins folder. 相反,我重新安装了所有内容,只是意识到这些库不在安装目录的plugins文件夹中。

Installing the EMF and OCL plugins from the following link were correct. 通过以下链接安装EMF和OCL插件是正确的。

http://download.eclipse.org/releases/kepler http://download.eclipse.org/releases/kepler

note: you may have to change the above url to suit your particular eclipse version. 注意:您可能必须更改上述url以适合您特定的eclipse版本。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM