Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » VIATRA » Tutorial Issue: createRule.precondition errors(What needs to be done to solve the Xtend editor errors?)
Tutorial Issue: createRule.precondition errors [message #1745171] Wed, 05 October 2016 23:46 Go to next message
Jon Passki is currently offline Jon PasskiFriend
Messages: 31
Registered: November 2015
Member

Hello,

I'm walking through the VIATRA tutorial using Neon.1 installed via Eclipse Installer: Eclipse Modeling Tools, VIATRA Core (1.4-maintenance), VIATRA Tooling. I upgrade VIATRA to 1.4 after the install (1.3 was installed for whatever reason) and additionally installed Xtext SDK 2.10.0.

The following code below, from the "Specify which action to run when the rule fires." step in Section 4.1: Batch Transformations, has a couple error markers shown in the Xtend editor:

val hostRule = createRule.precondition(HostInstanceMatcher.querySpecification) [
    val cpsHostInstance = it.hostInstance
    val nodeIp = cpsHostInstance.nodeIp
    println('''Mapping host with IP: «nodeIp»''')

    /** Create & initialize DeploymentHost in output model **/
    val depHost = cps2dep.deployment.createChild(deployment_Hosts, deploymentHost) => [
        set(deploymentHost_Ip, nodeIp)
    ]

    /** Create trace element in trace model **/
    cps2dep.createChild(CPSToDeployment_Traces, CPS2DeploymentTrace) => [
        addTo(CPS2DeploymentTrace_CpsElements, cpsHostInstance)
        addTo(CPS2DeploymentTrace_DeploymentElements, depHost)
    ]

    println('''Mapped with IP: «nodeIp»''')
]


The first is on the createRule.precondition line:

Invalid number of arguments. The method precondition(IQuerySpecification<Matcher>) is not applicable for the arguments (IQuerySpecification<HostInstanceMatcher>,(ViatraQueryEngine)=>String)


The next error is with cpsHostInstance.nodeIp:

The method or field nodeIp is undefined for the type HostInstanceMatcher
.

The same type of errors occur also for the val applicationRule = createRule.precondition.

Additionally, the execute method shows two errors for the following lines:

        /* Fire transformation rules**/
        hostRule.fireAllCurrent
        applicationRule.fireAllCurrent


hostRule.fireAllCurrent error:

Type mismatch: cannot convert from BatchTransformationRuleFactory.BatchTransformationRuleBuilder<HostInstanceMatch, HostInstanceMatcher> to BatchTransformationRule<IPatternMatch, ?>


applicationRule.fireAllCurrent error:

Type mismatch: cannot convert from BatchTransformationRuleFactory.BatchTransformationRuleBuilder<ApplicationInstanceMatch, ApplicationInstanceMatcher> to BatchTransformationRule<IPatternMatch, ?>



What needs to be done to solve these errors?
Re: Tutorial Issue: createRule.precondition errors [message #1745181 is a reply to message #1745171] Thu, 06 October 2016 07:00 Go to previous messageGo to next message
Abel Hegedus is currently offline Abel HegedusFriend
Messages: 197
Registered: September 2015
Senior Member
Quote:
installed via Eclipse Installer: Eclipse Modeling Tools, VIATRA Core (1.4-maintenance), VIATRA Tooling.


The VIATRA setup in the Eclipse Installer is for VIATRA Developers, not users. The tutorial explains what you need to try it: http://static.incquerylabs.com/projects/viatra/viatra-docs/ViatraDocs.html#environment

Please install VIATRA from the update site into an Eclipse instead of using the developer Oomph setup.
Re: Tutorial Issue: createRule.precondition errors [message #1745182 is a reply to message #1745181] Thu, 06 October 2016 07:20 Go to previous messageGo to next message
Abel Hegedus is currently offline Abel HegedusFriend
Messages: 197
Registered: September 2015
Senior Member
Also, thanks for spotting the outdated API usage in the example, I have updated the docs: https://github.com/viatra/viatra-docs/commit/6c871b0056fca7a0a88728fe588ea5c46abd64be

In short, transformation rules are created with a Builder API, so you need to specfy that the lambda is an action and finally call build to prepare the rule.

val hostRule = createRule.precondition(HostInstanceMatcher.querySpecification).action[/*Action part*/].build
Re: Tutorial Issue: createRule.precondition errors [message #1745216 is a reply to message #1745182] Thu, 06 October 2016 15:28 Go to previous message
Jon Passki is currently offline Jon PasskiFriend
Messages: 31
Registered: November 2015
Member

Abel Hegedus wrote on Thu, 06 October 2016 00:20
Also, thanks for spotting the outdated API usage in the example, I have updated the docs: https://github.com/viatra/viatra-docs/commit/6c871b0056fca7a0a88728fe588ea5c46abd64be

In short, transformation rules are created with a Builder API, so you need to specfy that the lambda is an action and finally call build to prepare the rule.

val hostRule = createRule.precondition(HostInstanceMatcher.querySpecification).action[/*Action part*/].build


Thanks, this worked!
Previous Topic:Alternative for RunOnce engine in v1.0.0
Next Topic:Checking the EClass of an EObject in a pattern
Goto Forum:
  


Current Time: Fri Apr 26 01:18:31 GMT 2024

Powered by FUDForum. Page generated in 0.03223 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top