Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » OCL » "misplaced contructs" using second import statement
"misplaced contructs" using second import statement [message #1081506] Wed, 07 August 2013 05:58 Go to next message
Jens Reimann is currently offline Jens Reimann
Messages: 2
Registered: June 2013
Junior Member
Hello,

I struggle a bit with an issue of having two import statements. I do have some OCL validation rules that need to models for validating.

import 'platform:/plugin/org.openscada.configuration.component.model/model/component.ecore'
import 'platform:/plugin/org.openscada.configuration.infrastructure.model/model/infrastructure.ecore'

package component

context CalculationComponent
def: all_component_inputs: Set(ComponentReferenceInputDefinition) = inputs->select( i : InputDefinition | i.oclIsKindOf(ComponentReferenceInputDefinition))
def: all_masters: Set(infrastructure::MasterServer) = all_component_inputs->collect(i: ComponentReferenceInputDefinition | i.component.masterOn)
inv all_master_contained: self.masterOn->includesAll(all_masters)

...

endpackage


The editor loads and validates the file fine. But when I load them using OCL.parse(...), as suggested by the OCL validation example, I do get the following exception:

!ENTRY org.openscada.configuration.validation 4 1 2013-08-07 11:52:49.075
!MESSAGE Failed to parse OCL constraints in org.openscada.configuration.validation:constraints/comp.ocl
!STACK 0
org.eclipse.ocl.SyntaxException: 1:1:1:102 "import component: 'platform:/plugin/org.openscada.configuration.component.model/model/component.ecore'" misplaced construct(s)
	at org.eclipse.ocl.util.OCLUtil.checkForErrors(OCLUtil.java:356)
	at org.eclipse.ocl.OCL.parse(OCL.java:323)
	at org.openscada.configuration.validation.ocl.OCLConstraintProvider.parseConstraints(OCLConstraintProvider.java:168)
	at org.openscada.configuration.validation.ocl.OCLConstraintProvider.parseConstraints(OCLConstraintProvider.java:141)
	at org.openscada.configuration.validation.ocl.OCLConstraintProvider.setInitializationData(OCLConstraintProvider.java:98)
	at org.eclipse.core.internal.registry.ConfigurationElement.createExecutableExtension(ConfigurationElement.java:251)
	at org.eclipse.core.internal.registry.ConfigurationElementHandle.createExecutableExtension(ConfigurationElementHandle.java:55)
	at org.eclipse.emf.validation.internal.service.ProviderDescriptor.getProvider(ProviderDescriptor.java:268)
	at org.eclipse.emf.validation.internal.service.ConstraintCache.execute(ConstraintCache.java:285)
	at org.eclipse.emf.validation.internal.service.ConstraintCache.getBatchConstraints(ConstraintCache.java:386)


I am not sure what I am doing wrong.

Using Eclipse Kepler 4.3.

Thanks for helping.
Re: "misplaced contructs" using second import statement [message #1081628 is a reply to message #1081506] Wed, 07 August 2013 09:29 Go to previous message
Ed Willink is currently offline Ed Willink
Messages: 3446
Registered: July 2009
Senior Member
Hi

The OCL specification has no import statement, which makes Complete OCL
almost unuseable.

For a while I tried to support external metadata in a Model Registry,
which can be used by the Classic Eclipse OCL.

Eventually I had to accept that the lack of an import statement is a
language bug and so the Pivot/Xtyext-based Eclipse OCL rectifies it. (I
think Dresden OCL also has an import statement extension).

For Juno we improved the Classic OCL parser to parse but ignore import
statements, so that files developed by the new edirtor could be used. It
remains a responsibility of a Classic Eclipse OCL user to populate the
package regiustry with all relevant models.

Your error message is not consistent with your claimed imports so I'm
not confident that you are presenting the true problem.

It generally saves everyone a lot of time to attach a simple zipped project.

Regards

Ed Willink

On 07/08/2013 13:12, Jens Reimann wrote:
> Hello,
>
> I struggle a bit with an issue of having two import statements. I do
> have some OCL validation rules that need to models for validating.
>
> import
> 'platform:/plugin/org.openscada.configuration.component.model/model/component.ecore'
> import
> 'platform:/plugin/org.openscada.configuration.infrastructure.model/model/infrastructure.ecore'
>
> package component
>
> context CalculationComponent
> def: all_component_inputs: Set(ComponentReferenceInputDefinition) =
> inputs->select( i : InputDefinition |
> i.oclIsKindOf(ComponentReferenceInputDefinition))
> def: all_masters: Set(infrastructure::MasterServer) =
> all_component_inputs->collect(i: ComponentReferenceInputDefinition |
> i.component.masterOn)
> inv all_master_contained: self.masterOn->includesAll(all_masters)
>
> ...
>
> endpackage
>
> The editor loads and validates the file fine. But when I load them
> using OCL.parse(...), as suggested by the OCL validation example, I do
> get the following exception:
>
>
> !ENTRY org.openscada.configuration.validation 4 1 2013-08-07 11:52:49.075
> !MESSAGE Failed to parse OCL constraints in
> org.openscada.configuration.validation:constraints/comp.ocl
> !STACK 0
> org.eclipse.ocl.SyntaxException: 1:1:1:102 "import component:
> 'platform:/plugin/org.openscada.configuration.component.model/model/component.ecore'"
> misplaced construct(s)
> at org.eclipse.ocl.util.OCLUtil.checkForErrors(OCLUtil.java:356)
> at org.eclipse.ocl.OCL.parse(OCL.java:323)
> at
> org.openscada.configuration.validation.ocl.OCLConstraintProvider.parseConstraints(OCLConstraintProvider.java:168)
> at
> org.openscada.configuration.validation.ocl.OCLConstraintProvider.parseConstraints(OCLConstraintProvider.java:141)
> at
> org.openscada.configuration.validation.ocl.OCLConstraintProvider.setInitializationData(OCLConstraintProvider.java:98)
> at
> org.eclipse.core.internal.registry.ConfigurationElement.createExecutableExtension(ConfigurationElement.java:251)
> at
> org.eclipse.core.internal.registry.ConfigurationElementHandle.createExecutableExtension(ConfigurationElementHandle.java:55)
> at
> org.eclipse.emf.validation.internal.service.ProviderDescriptor.getProvider(ProviderDescriptor.java:268)
> at
> org.eclipse.emf.validation.internal.service.ConstraintCache.execute(ConstraintCache.java:285)
> at
> org.eclipse.emf.validation.internal.service.ConstraintCache.getBatchConstraints(ConstraintCache.java:386)
>
>
> I am not sure what I am doing wrong.
>
> Using Eclipse Kepler 4.3.
>
> Thanks for helping.
Previous Topic:Parsing an ocl file (complete OCL) to define operations in an environment
Next Topic:Visiting expression from SpecificationCS
Goto Forum:
  


Current Time: Mon Oct 07 10:12:47 EDT 2013

Powered by FUDForum. Page generated in 0.02028 seconds