ID/Key definitions in EMF (Meta) Models - eclipse-emf

I'm stuck with a very basic problem regarding EMF, here's what i've got.
EClass A:
aID : EInteger (Key: true)
EClass B:
bID : EInteger (Key: true)
EClass C:
Reference refA: to elements of A, containment: true, EKeys: aID, 0 .. n
Reference refB: to elements of B, containment: true, EKeys: bID, 0 .. n
Now here's the problem. In both my a and b list I'd like to have IDs from 0 to n. However, when I do this, I get the message:
The ID '1' of 'A' collides with that of 'B'
I hope my problem is described clearly. Does anyone know what I'm doing wrong? Thanks!

An EAttribute which is set as "ID" should be unique resource-wide. If you want to reference elements using a myReference[name="SomeName"] construction then you should use eKeys, then the eKeyed attribute should have a unique value within a reference.
I am under the impression you defined "aID" and "bID" as "ID's whereas that's not what you really want here.

That could be resolved using OO hierachy. You just need to extend A and B from a common Abstract class that contains the id attribute and it setted as ID in emf properties.
regards

Related

Dart/Flutter: Method 'foldIndexed' isn't defined for the type 'List'

I am trying to use the foldIndexed() method on a List in Flutter/Dart, like so:
// should only compute the combined character length of the first two fruits
['apple', 'banana', 'cherry'].foldIndexed(
0,
(index, previousElement, element) =>
index < 2 ? previousElement + element.length : previousElement);
For some reason it shows the following syntax error: The method 'foldIndexed' isn't defined for the type 'List'.
From this documentation I understand that foldIndexed() is part of Flutter and that it should be possible to use it on a List as List is an implementation of the Iterable abstract class.
Any ideas why Flutter casts the above mentioned error or won't let me use it? Or is there another way of getting access to the iteration index when using the fold() method on a List?
My problem was that I had forgotten to import collection.dart as pointed out by #pskink.

How to convert an array of data to a list of widgets with expand or fold in flutter/dart?

Really frustrated about not solving it myself but finally gave up.
I have an array of fields, each being a map with title and value. I want to iterate through it and create a list of text widgets along with some padding between them. I tried the following:
fields.expand((field)=>
[ Text(field['title']),
Padding(padding: const EdgeInsets.only(bottom: 4.0))
]
).toList()
But this gives the following error:
type 'List<dynamic>' is not a subtype of type 'List<Widget>'
I tried adding <Widget> after expand but then I get:
type 'MappedListIterable<Map<String, String>, dynamic>' is not a subtype of type 'List<Widget>'
I also tried adding <Widget> after expand( but then I get:
type '<Widget>(dynamic) => List<Widget>' is not a subtype of type '(Map<String, String>) => Iterable<dynamic>' of 'f'
Not sure what else to do. How the heck can I force it to realize this is a list of widgets?
I also tried using fold but got similar typing issues.
I think what you're looking for is .map(), but there's a cleaner way to do it :
items: [
for(var field in fields)
...[
Text(field['title']),
Padding(padding: const EdgeInsets.only(bottom: 4.0)),
]
]
Make sure your minimum SDK version is 2.6.0 or above in the pubspec.yaml
As #christopher-moore noted, adding <Widget> after expand does work. The reason I thought it was not working was that I kept getting the error, but for a different place where I still had the same statement but without that addition.
As I said in my comment, one of your solutions appears to should have work, but since it didn't I'm providing an alternate solution.
You can use a for-each loop to "manually" create an output List that you can pass to your Column widget. Ex.
List<Widget> columnList = List();
for(Map field in fields) {
columnList.add(Text(field['title']);
columnList.add(Padding(padding: const EdgeInsets.only(bottom: 4.0)));
}

Get Taxonomy Term ID by Node in Drupal 8

I'm trying to get Taxonomy data by particular node.
How can I get Taxonomy Term Id by using Node object ?
Drupal ver. 8.3.6
You could do something like that:
$termId = $node->get('field_yourfield')->target_id;
Then you can load the term with
Term::load($termId);
Hope this helps.
If you want to get Taxonomy Term data you can use this code:
$node->get('field_yourfield')->referencedEntities();
Hope it will be useful for you.
PS: If you need just Term's id you can use this:
$node->get('field_yourfield')->getValue();
You will get something like this:
[0 => ['target_id' => 23], 1 => ['target_id'] => 25]
In example my field has 2 referenced taxonomy terms.
Thanks!
#Kevin Wenger's comment helped me. I'm totally basing this answer on his comment.
In your code, when you have access to a fully loaded \Drupal\node\Entity\Node you can access all the (deeply) nested properties.
In this example, I've got a node which has a taxonomy term field "field_site". The "field_site" term itself has a plain text field "field_site_url_base". In order to get the value of the "field_site_url_base", I can use the following:
$site_base_url = $node->get('field_site')->entity->field_site_url_base->value;
How to extract multiple term IDs easily if you know a little Laravel (specifically Collections):
Setup: composer require tightenco/collect to make Collections available in Drupal.
// see #Wau's answer for this first bit...
// remember: if you want the whole Term object, use ->referencedEntities()
$field_value = $node->get('field_yourfield')->getValue();
// then use collections to avoid loops etc.
$targets = collect($field_value)->pluck('target_id')->toArray();
// $targets = [1,2,3...]
or maybe you'd like the term IDs comma-separated? (I used this for programmatically passing contextual filter arguments to a view, which requires , (OR) or + (AND) to specify multiple values.)
$targets = collect($field_value)->implode('target_id', ',');
// $targets = "1,2,3"

Django - how to make this query

I have the following model which is populated with something like this:
Property
concept_id name value
1 definition blablabla
1 prefLabel prefferedLabel
1 scope Scopeee
1 NOT_NEEDED a not needed value
2 definition another definition
2 prefLabel another label
2 scope another scope
.........................
I want to obtain this result in query(under the form of a list, dictionary, queryset, it doesn't matter which form):
concept_id definition prefLabel scope
1 blablabla prefferedLabel Scopeee
2 another definition another label another scope
How can I achieve this? Thanks
EDIT: I am using MySQL.
My ugly solution is this one
for concept_id in Concept.objects.all().values_list('id', flat=True):
Property.objects.filter(concept_id=concept_id, name__in=['prefLabel', 'scope', 'definition'])
.....
But is realy ugly, I want something different
THE SOLUTIONS OF pcoronel:
table = []
for concept in Concept.objects.all():
row = {'code': concept.id}
result=concept.property_set.filter(
name__in=['prefLabel', 'scope', 'definition'],
)
for r in result:
row.update({
r.name: r.value,
})
table.append(row)
Not sure if this is the best solution
Assuming your Property model has a field: models.ForeignKey('Concept', ...), you can simply follow that relationship backwards:
# iterate through Concepts and get desired related Properties using their name
for concept in Concept.objects.all():
concept.property_set.filter(name__in=['prefLabel', 'scope', 'definition'])

Check if value of Cell is in another Sheet2.CellRange if yes, take the value of Sheet2.CellD position

OBS: im using OpenOffice, i cant use the "OpenOffice" tag, =|
i have this Sheet2:
and I'm planning to type the value of B4:B12 inside another Sheet
for example, i type in A1 the value 4, so it will fill the B with D4 and C with E4(from sourceSheet position)
Sheet1 that will get the value of D or E from Row where Sheet2.B is equal Sheet1.A
--A--B--C
1|4-D4--E4
2|
3|7-D7--E7
4|1-D1--E1
and i tried this:
LOOKUP(A1;Sheet2.B1:Sheet2.B12;Sheet2.D4:Sheet2.D12);
but its not getting the value, just return sometimes #NAME
I believe your ranges are written incorrectly.
First, Sheet2.B1:Sheet2.B12 should be Sheet2.B1:B12
Second, for the Lookup function, the searchtable and result table must be the same size (take a look at the online documentation for details).
Try this instead:
LOOKUP(A1;Sheet2.B1:B12;Sheet2.D1:D12);
Please try in B1 and copied across to C1, then both down to suit:
=IF(ISERROR(LOOKUP($A1;Sheet2.$B$4:$B$12;Sheet2.D$4:D$12));"";LOOKUP($A1;Sheet2.$B$4:$B$12;Sheet2.D$4:D$12))