Acceleo java wrapping service doesn't take complex parameter - Invalid result for expression self.invoke - acceleo

I can't call a java wrapping service in Acceleo because it doesn't recognize parameters type. This is my simple test code: the main calls a query stored in Services.mtl, that calls the java service that just return the name of an object "Send"
Main.mtl
[file ('system.P', false, 'UTF-8')]
[for (t : Send | aSystemBehavior.transitions)) ]
[getName(t)/]
[/for]
[/file]
Services.mtl
[query public getName(arg0 : Send) : String
= invoke('myPackage.Services', 'getName(myPackage.Send)', Sequence{arg0})
/]
Services.java
public class Services
{
public String getName(Send t)
{return t.getName();}
}
The Error Log shows:
Invalid result for expression
self.invoke('myPakage.Services',
'getName(myPakage.Send)', Sequence {arg0}) at line 0 in
Module services for query getName(Send). Last recorded value of self
was org.eclipse.emf.ecore.impl.DynamicEObjectImpl#1f00eb36 (eClass:
org.eclipse.emf.ecore.impl.EClassImpl#2c2aade3 (name: Send)
(instanceClassName: null) (abstract: false, interface: false)).
Problem found while generating the file system.P'.
If I use a String as parameter type instead of Send, everything works fine.

Does the package containing the service "Services" has been exported? If not, open the file MANIFEST.MF, go in the runtime tab and add its package to the list of exported packages. Are you sure that your "Send" object has a name? This message only indicates that null was returned by the query getName.

I don't have anymore this problem... I created a new Acceleo project from scratch, and it works. I am not sure what was the problem... maybe it's something about che choice of metamodels to import during the creation of the Module (I have to choose between run-tim and develop-time metamodel).

Related

drf_yasg doesn't take TYPE_ARRAY as a valid type

the drf_yasg swagger generator doesnt take TYPE_ARRAY as a valid parameter type.
the implementation is as follows
from drf_yasg import openapi
param1 = openapi.Parameter('param_name',
in_=openapi.IN_QUERY,
description='description of param',
type=openapi.TYPE_ARRAY,
required=True
)
whereas the documentation of drf_yasg suggests that it takes openapi.TYPE_ARRAY as valid type.
the error that the generators throws is
File "/usr/local/lib/python3.6/dist-packages/drf_yasg/codecs.py", line 73, in encode
raise SwaggerValidationError("spec validation failed", errors, spec, self)
drf_yasg.errors.SwaggerValidationError: spec validation failed
is there some configuration that i am missing or something because TYPE_STRING,TYPE_NUMBER works perfectly fine.
A Parameter of TYPE_ARRAY requires the items key:
param1 = openapi.Parameter('param_name',
in_=openapi.IN_QUERY,
description='description of param',
type=openapi.TYPE_ARRAY,
items=openapi.Items(type=openapi.TYPE_STRING) # <------
required=True
)
See the OpenAPI 2.0 specification for more details.

Fali to use getAppliedStereotype to get id and name of requirement

In Eclipse, Using Papyrus neon and Acceleo 3.7 for SysML 1.4 diagram, the getAppliedStereotype()returns null.
The modules are
[module generate('http://www.eclipse.org/uml2/5.0.0/UML',
'http://www.eclipse.org/papyrus/sysml/1.4/SysML',
'http://www.eclipse.org/papyrus/sysml/1.4/SysML/Blocks',
'http://www.eclipse.org/papyrus/sysml/1.4/SysML/Activities',
'http://www.eclipse.org/papyrus/sysml/1.4/SysML/Requirements',
'http://www.eclipse.org/papyrus/sysml/1.4/SysML/ModelElements')]
I have added the following code in the generate.java but still cannot work
Map<URI, URI> uriMap = resourceSet.getURIConverter().getURIMap();
// UML2 profiles
URI uri = URI.createURI("platform:/plugin/org.eclipse.uml2.uml.resources");
uriMap.put(URI.createURI(UMLResource.LIBRARIES_PATHMAP), uri.appendSegment("libraries").appendSegment(""));
uriMap.put(URI.createURI(UMLResource.METAMODELS_PATHMAP), uri.appendSegment("metamodels").appendSegment(""));
uriMap.put(URI.createURI(UMLResource.PROFILES_PATHMAP), uri.appendSegment("profiles").appendSegment(""));
// SysML profiles
uri = URI.createURI("platform:/plugin/org.eclipse.papyrus.sysml14");
uriMap.put(URI.createURI(SysMLResource.LIBRARIES_PATHMAP), uri.appendSegment("librairies").appendSegment(""));
uriMap.put(URI.createURI("pathmap://SysML14_PROFILES/"), uri.appendSegment("model").appendSegment(""));
The code like c.getAppliedStereotypes() returns null. I want to get the information of a requirement like the following code which returns nothing because of the getAppliedStereotype operation:
[for (re : uml::Class | uml::Class.allInstances()->select(cl : uml::Class | cl.getAppliedStereotype('SysML::Requirements::Requirement') <> null))]
--[re.name/]
Modellpfad : [re.qualifiedName/]
Id : [re.getValue(re.getAppliedStereotype('SysML::Requirements::Requirement'), 'id')/]
Text : [re.getValue(re.getAppliedStereotype('SysML::Requirements::Requirement'), 'text')/]
[/for]
Well, if none of your model elements have an applied stereotype, you will find no classes or objects. Thus, when you try to print the applied stereotype of all elements with an applied stereotype without first ensuring that the list is itself not null, you will fail.

Cannot invoke <function> with an argument list of type Dictionary<Generic, Generic>

I have a function with the following signature:
static func dictionaryToJSON<K : ToJSON,V : ToJSON> ( dictionary : Dictionary<K,V>) -> JValue
You can find it here.
When I attempt to call this function, I get the error Cannot invoke 'dictionaryToJSON' with an argument list of type '(Dictionary<Domain, Account>)'. Here is the call:
let accounts : JValue = Aeson.dictionaryToJSON( self.accounts)
self.accounts has type Dictionary<Domain,Account>, and Domain and Account both implement the protocol ToJSON. Is there any reason why this doesn't type check? This is for Swift 2 (XCode 7 beta 6), so maybe there is a compiler bug?
It looks like I commented out Domain's implementation of ToJSON to debug and forgot. It's working now.

XML Parsing Error : AJAX Chat

I am just trying to plant AJAX Chat for my website users. I have successfully completed the installation process with database configuration. But when I am trying to brows the domain.com/ajaxchat/index.php its returning this error given below:
XML Parsing Error: junk after document element Location: http://futurenext.esy.es/inc/chat/ Line Number 2, Column 1:
I think that the problem is in AJAXChatTemplate.php , and here the code is:
function getContent() {
if(!$this->_content) {
$this->_content = AJAXChatFileSystem::getFileContents($this->_templateFile);
}
return $this->_content;
And the error message is like:
" Non-static method AJAXChatFileSystem::getFileContents() should not be called statically, assuming $this from incompatible context in line 37"
Now please any one can help me to fix the problem. What is the problem here I can't really understand. Thanks.

"Cannot extract single value from Iterable" with custom query result object

I'm using SpringDataNeo4J 3.0.0-M1 with Neo4J 2.00-M0.6.
I have BetDAO nodes, linked to a collection of BetAnswerDAO nodes with BET_ANSWER relationship.
I'm trying to retrieve a bet and all its answers on the same request. I have a BetRepository with the following request :
#Query("start bet=node:BetDAO(id = {betId}) "
+ "match (bet)-[:BET_ANSWER]->(betAnswer) "
+ "return bet, collect(betAnswer) as betAnswers")
BetWithInfo getByIdWithInfo(#Param("betId") String id);
My BetWithInfo object :
import org.springframework.data.neo4j.annotation.QueryResult;
import org.springframework.data.neo4j.annotation.ResultColumn;
import fr.project.commons.data.graph.neo4j.beans.nodes.BetAnswerDAO;
import fr.project.commons.data.graph.neo4j.beans.nodes.BetDAO;
#QueryResult
public interface BetWithInfo {
#ResultColumn("bet")
BetDAO getBet();
#ResultColumn("betAnswers")
Iterable<BetAnswerDAO> getBetAnswers();
}
The request is executed without errors, but when I try to access the bet answers collections, I get the following error :
Caused by: java.lang.RuntimeException: Cannot extract single value from Iterable with more than one elements.
at org.springframework.data.neo4j.conversion.DefaultConverter.extractSingle(DefaultConverter.java:60)
at org.springframework.data.neo4j.conversion.DefaultConverter.extractValue(DefaultConverter.java:51)
at org.springframework.data.neo4j.conversion.DefaultConverter.convert(DefaultConverter.java:40)
at org.springframework.data.neo4j.support.conversion.EntityResultConverter.convert(EntityResultConverter.java:165)
at org.springframework.data.neo4j.conversion.QueryResultBuilder$1.convert(QueryResultBuilder.java:103)
at org.springframework.data.neo4j.conversion.QueryResultBuilder$1.access$300(QueryResultBuilder.java:81)
at org.springframework.data.neo4j.conversion.QueryResultBuilder$1$1.underlyingObjectToObject(QueryResultBuilder.java:121)
at org.neo4j.helpers.collection.IteratorWrapper.next(IteratorWrapper.java:47)
at org.neo4j.helpers.collection.IteratorUtil.addToCollection(IteratorUtil.java:403)
at org.neo4j.helpers.collection.IteratorUtil.addToCollection(IteratorUtil.java:482)
at org.neo4j.helpers.collection.IteratorUtil.asCollection(IteratorUtil.java:581)
at org.springframework.data.neo4j.support.conversion.EntityResultConverter.extractAndSetValueOfField(EntityResultConverter.java:129)
at org.springframework.data.neo4j.support.conversion.EntityResultConverter.extractPOJOResult(EntityResultConverter.java:102)
at org.springframework.data.neo4j.support.conversion.EntityResultConverter.convert(EntityResultConverter.java:163)
at org.springframework.data.neo4j.conversion.DefaultConverter.convert(DefaultConverter.java:36)
at org.springframework.data.neo4j.rest.SpringRestGraphDatabase$SpringResultConverter.convert(SpringRestGraphDatabase.java:148)
at org.neo4j.rest.graphdb.util.QueryResultBuilder$1$1.underlyingObjectToObject(QueryResultBuilder.java:98)
at org.neo4j.helpers.collection.IteratorWrapper.next(IteratorWrapper.java:47)
at org.neo4j.helpers.collection.IteratorUtil.single(IteratorUtil.java:334)
at org.neo4j.helpers.collection.IteratorUtil.singleOrNull(IteratorUtil.java:130)
at org.neo4j.helpers.collection.IteratorUtil.singleOrNull(IteratorUtil.java:287)
at org.springframework.data.neo4j.rest.SpringEndResult.singleOrNull(SpringEndResult.java:39)
at org.springframework.data.neo4j.repository.query.GraphRepositoryQuery.dispatchQuery(GraphRepositoryQuery.java:115)
at org.springframework.data.neo4j.repository.query.GraphRepositoryQuery$1.doWithGraph(GraphRepositoryQuery.java:86)
at org.springframework.data.neo4j.support.Neo4jTemplate.doExecute(Neo4jTemplate.java:408)
at org.springframework.data.neo4j.support.Neo4jTemplate.access$000(Neo4jTemplate.java:85)
at org.springframework.data.neo4j.support.Neo4jTemplate$2.doInTransaction(Neo4jTemplate.java:422)
at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:130)
at org.springframework.data.neo4j.support.Neo4jTemplate.exec(Neo4jTemplate.java:419)
at org.springframework.data.neo4j.repository.query.GraphRepositoryQuery.execute(GraphRepositoryQuery.java:80)
at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.invoke(RepositoryFactorySupport.java:337)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:110)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:155)
... 59 more
It seems to me that what I've done is really close from the example in spring-data documentation. What am I doing wrong ?
EDIT :
I made a mistake in my code. I get this error when the getBetAnswers() function returns an Iterable. With a Collection, I get the following error :
java.lang.ClassCastException: org.springframework.data.neo4j.conversion.QueryResultBuilder$1 cannot be cast to java.util.Collection
Are you sure
#Query("start bet=node:BetDAO(id = {betId}) "
+ "match (bet)-[:BET_ANSWER]->(betAnswer) "
+ "return bet, collect(betAnswer) as betAnswers")
BetWithInfo getByIdWithInfo(#Param("betId") String id);
returns only 1 result?
From what I understand, this query returns several rows at runtime but Spring Data is told to return only 1 BetWithInfo.
Either double-check your query thus making sure it returns only 1 row, or migrate your method return type from BetWithInfo to Iterable<BetWithInfo> (or Collection<BetWithInfo>).
In the BetWithInfo interface, try changing
Collection<BetAnswerDAO> getBetAnswers();
to
Iterable<BetAnswerDAO> getBetAnswers();
I looks like it is a bug as described here google forum. that will be fixed on the next spring-data-neo4j release.
It is still present in spring-data-neo4j 3.3.0.RELEASE.

Resources