Xtext assign object in xtext file - eclipse

Trying to make a meta model for Mongoose and MondoDb, using metamodeling concepts, eclipse and xtext.
I am trying to assign object that i created in my test.mydsl file to another object in the same file, but i get error in my test.mydsl file.
I am trying to assign created Schema(sc1) object to Collection(col) object, but currently getting an error
error message
the feature 'validate' of
'paket.impl.NCollectionImpl#67d76e14{platform:/resource/test/classes/test.mydsl#//#collections.0}'
contains an unresolved proxy
'paket.impl.SchemaImpl#361d8284{platform:/resource/test/classes/test.mydsl#|0}'
my grammar for Schema and Collection
Schema returns Schema:
{Schema}
('Schema' '<' Name=EString) '>'
'{'
(schemaExpression+=Expression ( "," schemaExpression+=Expression)*)?
(verificationDocumentElement+=VerDocElement ( "," verificationDocumentElement+=VerDocElement)*)?
'}';
NCollection returns NCollection:
{NCollection}
('Collection' '<' Name=EString) ',' (validate=[Schema|EString])? '>'
'{'
(document+=Document ( "," document+=Document)*)?
'}';
my test.mydsl
Database<db1>{
Schema<sc1>{
var ja=lp
ime:{
type:String,
min:123.0
}
}
Collection<col, sc1>
{
}
}
I tried all, but unsuccessful.
Any ideas what to do?
Thanks
EDIT:
Maybe I was not clear enough. The major problem is with "validate" attribute in NCollection rule.
When I create my Schema object(sc1 in test.mydsl) and then try to pass it to Collection(col in test.mydsl) as a "sc1", the "validate" attribute cannot accept it like string, and I don't know how to pass it like Schema object.
I hope this explanation helps.

Please try to use name=EStringinstead of Name=EString as Xtext imposes a special default semantics for the attribute name. Also I recommend to look into the documentation.

The code
validate=[Schema|EString]
says: I want a schema reference via a String, i.e. "sc1" instead of the name. Xtext doesn't know how to convert a string into a reference. Use this instead:
validate=[Schema]
which is short for
validate=[Schema|ID]
That will use the name of the Schema as reference. Note that you have to write
('Schema' '<' name=EString) '>'
i.e. lower case name to make it work. Xtext has special handling for properties called name.

Related

Data factory lookup (dot) in the item() name

I am having lookup wherein salesforce query is there. I am using elements (item()) in subsequent activities. Till now i had item().name or item().email but now i have item().NVMStatsSF__Related_Lead__r.FirstName which has (dot) in the field name.
How should i parse it through body tag so that it reads it correctly?
So I have the following data in item()
{
"NVMStatsSF__Related_Lead__c": "00QE000egrtgrAK",
"NVMStatsSF__Agent__r.Name": "ABC",
"NVMStatsSF__Related_Lead__r.Email": "geggegg#gmail.com",
"NVMStatsSF__Related_Lead__r.FirstName": "ABC",
"NVMStatsSF__Related_Lead__r.OwnerId": "0025434535IIAW"
}
now when i use item().NVMStatsSF__Agent__r.Name it will not parse because of (dot) after NVMStatsSF__Agent__r. And it is giving me the following error.
'item().NVMStatsSF__Related_Lead__r.Email' cannot be evaluated because property 'NVMStatsSF__Related_Lead__r' doesn't exist, available properties are 'NVMStatsSF__Related_Lead__c, NVMStatsSF__Agent__r.Name, NVMStatsSF__Related_Lead__r.Email, NVMStatsSF__Related_Lead__r.FirstName, NVMStatsSF__Related_Lead__r.OwnerId'.",
"failureType": "UserError",
"target": "WebActivityToAddPerson"
this is because ADF uses '.' for object reading.
Could you find a way to rename the field name which contains '.'?
Seems like you need a built-in function to get the value of an object according to the key. Like getValue(item(), 'key.nestkey'). But unfortunately, seems there isn't such a function. You may need handle your key first.
Finally, it worked. I was being silly.
Instead of taking the value from the child table with the help of (dot) operator I just used subquery. Silly see.
And it worked.

Insert field name with dot in mongo document

A Meteor server code tries to insert an object into a Mongo collection. The value of one of the property is a string which contains a dot i.e. ".".
Meteor terminal is complaining :-
Error: key Food 1.1 and drinks must not contain '.'
What does this mean and how to fix it?
let obj = {
food: group,
rest: rule,
item: item[0],
key: i
};
FoodCol.insert(obj);
edit
The suggested answer by Kishor for replacing the "." with "\uff0E" will produce a space after the dot which is not what a user expects.
From this link, How to use dot in field name?
You can replace dot symbols of your field name to Unicode equivalent
"\uff0E":
Update: As Fred suggested, please use "\u002E" for "."
We solved this issue by encoding (Base64) the key before insertion and decode after taking out from the db. Since we consume the document as it is and query fields are different and their keys are not encoded.
But if u want to make query using this key or the key should be readable to the user, this solution will be not be suitable.

FindBy property in TYPO3 Extbase MVC is not working

I'm unable to run the FindBy magic function property in Extbase MVC
$title=array(0 =>'Books Day');
$each_event=$this->eventRepository->findByTitle($title);
$each_event is returning an object of type TYPO3\CMS\Extbase\Persistence\Generic\QueryResult .
How do I make this work?
I also tried passing in a string to findByTitle and findByOne. Both don;t work! :(
I'm using TYPO3 6.1 and extension builder.
The last part of those magic functions always needs to be a field in the database. So "title" must be in your model. You might have a field "one" for your object, but I guess you meant findOneByTitle?
The object type QueryResult is correct. You can turn it into an array for debugging purpose for example:
$foo = $query->execute()->toArray();
By the way: check wether your eventRepository is null or not and you could try this to see if it works at all:
$result = $this->myRepository->findAll();
Try
$each_event=$this->eventRepository->findByTitle($title)->toArray();
Reference to the QueryResult.
As said in the documentation, it returns a QueryResultInterface|array.
As a consequence you have to loop over the result like this:
foreach($each_event as $single_event) {
$single_event->getProperty();
}
If you are sure that it returns only one single value you could also access it by the index 0:
$each_event[0]->getProperty();

Replacing contents of xml attribute in xml column in DB2

I have an xml document saved in a DB2 Table with XML datatype and I want to update the value of a node. I tried this:
XQUERY replace value of node db2-fn:sqlquery('select my_xml_column from myTable where someId = someValue)/some/xpath/with/#attribute with "foobar"
(and I tried several variants, everything that google hinted that it could do the job).
But unfortunatelly I am just getting error messages. Here:
SQL16002N An XQuery expression has an unexpected token "value" following "replace ". Expected tokens may include: "
What am I doing wrong?
update myTable SET myXmlColumn = XMLQUERY('
transform copy $copy := $original
modify do replace value of $copy/some/xpath/with/#attribute with "FOOBAR"
return $copy
'
PASSING myXmlColumn AS "original"
) WHERE someId = someValue
This works and has the desired effect. It hoped for somebody to come up with a pure XQuery solution, but the problem is solved...

How to deal with list return values in ANTLR

What is the correct way to solve this problem in ANTLR:
I have a simple grammar rule, say for a list with an arbitrary number of elements.
list
: '[]'
| '[' value (COMMA value)* ']'
If I wanted to assign a return value for list, and have that value be the actual list of returned values from the production, what is the proper way to do it? The alternatives I'm entertaining are:
create my own stack in the global scope to keep track of these lists
Try to inspect the tree nodes below me and extract information that way
Access it in some slick and cool way that I'm hoping to find out about in which I can get easy access to such a list from within the action associated with the rule.
I guess the question is: How do the cool kids do it?
(FYI I'm using the python API for ANTLR, but if you hit me with another language, I can handle that)
In C# it might look like this:
list returns [ List<string> ValueList ]
#init
{
$ValueList = new List<string>();
}
: '[]'
| '[' value {$ValueList.Add(value);} (COMMA value {$ValueList.Add(value);})* ']'
;
I guess a more straightforward way could be
list returns [ List values ]
: '[]'
| '[' vs+=value (COMMA vs+=value)* ']' {
$values = $vs;
}