Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » XPandfacade and Check
XPandfacade and Check [message #732211] Tue, 04 October 2011 09:08 Go to next message
st oehm is currently offline st oehmFriend
Messages: 79
Registered: October 2009
Member
hi to all
i have some problemens using check in XPand
for now i have done this:

Resource resource;
//...load resource

OutputImpl output = new OutputImpl();
//...

ProtectedRegionResolverImpl prs = new ProtectedRegionResolverImpl();
//...

UML2MetaModel mm = new UML2MetaModel();

Map<String,Variable> globalVarsMap = new HashMap<String,Variable>();
//...
XpandExecutionContextImpl execCtx = new XpandExecutionContextImpl(output, prs,
globalVarsMap, null, null);
execCtx.registerMetaModel(mm);

//checkcomponents
CheckComponent c = new CheckComponent();
c.addMetaModel(mm);
c.addCheckFile("templateMiddle::javacheck");
WorkflowContextImpl ctx = new WorkflowContextImpl();
ctx.put("", resource.getContents().get(0));
c.invoke(ctx);

//für primtive Types etc...
new Setup().setStandardUML2Setup(true);

XpandFacade facade = XpandFacade.create(execCtx);
facade.evaluate("templateMiddle::Template::main", resource.getContents().get(0));

i have added to the checkcomponent the metamodel and the checkFile. because i found no possibility to set the checkcomponent in the executionContext, i guess i have to use the invoke method of the checkcomponent. but this method expects a WorkFlowContext Object. but i'm not sure what i have put in this workFlowObject. Maybe someone knows it?

greetings
stoehm
Re: XPandfacade and Check [message #732217 is a reply to message #732211] Tue, 04 October 2011 09:21 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi,

you are right. it is impossible to get the XpandFacade running Checks.
the thing is called XpandFacade and not WorkflowFacade. Thus it facades Xpand and not a Workflow nor Check or Xtend.
But (what a miracle) there are also a CheckFacade, a XtendFacade and a WorkflowRunner

~Christian


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: XPandfacade and Check [message #732235 is a reply to message #732217] Tue, 04 October 2011 09:53 Go to previous messageGo to next message
st oehm is currently offline st oehmFriend
Messages: 79
Registered: October 2009
Member
hi christian
thanks for your reply. sorry, i have not think of that, because the name xpand is often use for the whole framework, instead only for the templates
greetings stoehm
Re: XPandfacade and Check [message #734891 is a reply to message #732235] Mon, 10 October 2011 10:06 Go to previous messageGo to next message
st oehm is currently offline st oehmFriend
Messages: 79
Registered: October 2009
Member
hi
trying to use CheckFacade to check the model, i have some problems:
i used

CheckFacade.checkAll(String checkFile, Collection<?> toCheck, ExecutionContext ctx, Issues issues)

the execution context and the checkFile is no problem, but i'am not sure what the toCheck Collection is needed. null is not allowed and debugging does not really help. i just figure out, that for each object of the collection a type check is done.
so a hint what the parameters exactly means is very helpfull for me
(btw: i wonder how the actual model is announced to the CheckFacade )

greetings stoehm
Re: XPandfacade and Check [message #734898 is a reply to message #734891] Mon, 10 October 2011 10:31 Go to previous messageGo to next message
Karsten Thoms is currently offline Karsten ThomsFriend
Messages: 762
Registered: July 2009
Location: Dortmund, Germany
Senior Member

The toCheck collection is the collection of objects to perform the validation on.
I have added javadocs now.

/**
* Invokes Check validation on a set of objects.
* @param checkFile Qualified name of the check file (qualified with '::')
* @param in The InputStream to use to load checkFile
* @param toCheck A collection of objects to perform the validation on
* @param ctx Execution context to use for evaluating the Check rules
* @param issues Issues instance to collect detected problems in
* @param warnIfNothingChecked When set a warning will be raised if no validation rule was executed
*/


Need professional support for Xtext, EMF, Eclipse IDE?
Go to: http://devhub.karakun.com
Twitter : @kthoms
Blog : www.karsten-thoms.de
Re: XPandfacade and Check [message #734914 is a reply to message #734898] Mon, 10 October 2011 11:36 Go to previous messageGo to next message
st oehm is currently offline st oehmFriend
Messages: 79
Registered: October 2009
Member
hi karsten
thanks for your reply!
i'm sorry, i'm still not sure about the toCheck Parameter! Is this a collection where i can put my models into? normally i have only one model!

i set in the parameter the root of my model like i did in xpandfacade but it does not work!

this it what i tried:

...//put the uml-model in a resource

ArrayList<Object> al= new ArrayList<Object>();
//put the root of the model in the arraylist
al.add(resource.getContents().get(0));
CheckFacade.checkAll("templateMiddle::javacheck", al, execCtx, null,false);

//here i put also the root in the parameterlist; and here it does work
XpandFacade facade = XpandFacade.create(execCtx);
facade.evaluate("templateMiddle::Template::main", resource.getContents().get(0));


so i'm still doing something wrong, any idea?

Re: XPandfacade and Check [message #734919 is a reply to message #734914] Mon, 10 October 2011 12:06 Go to previous messageGo to next message
Karsten Thoms is currently offline Karsten ThomsFriend
Messages: 762
Registered: July 2009
Location: Dortmund, Germany
Senior Member

The collection should contain all the elements to check, so most likely the model itself and all of its contents, i.e. eAllContents

Need professional support for Xtext, EMF, Eclipse IDE?
Go to: http://devhub.karakun.com
Twitter : @kthoms
Blog : www.karsten-thoms.de
Re: XPandfacade and Check [message #734959 is a reply to message #734919] Mon, 10 October 2011 14:24 Go to previous message
st oehm is currently offline st oehmFriend
Messages: 79
Registered: October 2009
Member
thanks a lot, now it works fine!
for everbody who is interested, the code is below

//...put the model in a resource

LinkedList<Object> ll = new LinkedList<Object>();
//copy the treeIterator from eAllContents into a linkedList
for(TreeIterator<EObject> iterator = resource.getContents().get(0).eAllContents(); iterator.hasNext();){
ll.add(iterator.next());
}

IssuesImpl issues =new IssuesImpl();
CheckFacade.checkAll("templateMiddle::javacheck",ll , execCtx, issues);

//print out all Errors that are detected
MWEDiagnostic[] errors = issues.getErrors();
for(int i=0;i<errors.length;i++){
System.out.println(errors[i].toString());
}

//print out all Warnings that are detected
MWEDiagnostic[] warnings = issues.getWarnings();
for(int i=0;i<warnings.length;i++){
System.out.println(warnings[i].toString());
}

//only evalute the xpandfacade when there are no errors
if(!issues.hasErrors()){
XpandFacade facade = XpandFacade.create(execCtx);
facade.evaluate("templateMiddle::Template::main", resource.getContents().get(0));
}

Previous Topic:[Acceleo] possible to use a genmodel with acceleo?
Next Topic:[Acceleo] Project jar dependencies in standalone compilation
Goto Forum:
  


Current Time: Thu Apr 25 19:27:52 GMT 2024

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

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

Back to the top