Skip to content

Annotations #84

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 21 commits into from
Sep 20, 2023
Merged

Annotations #84

merged 21 commits into from
Sep 20, 2023

Conversation

ftomassetti
Copy link
Contributor

@ftomassetti ftomassetti commented Sep 8, 2023

With this PR:

  • We introduce annotations in the language (i.e., the meta-metamodel)
  • We introduce annotations in the model API. To do this we create a common ancestor for annotations and nodes as annotations can target both. We call this ancestor "Element" for lack of a better name
  • We start revising the serialization support not to explode if "annotations" is encountered
  • Wrote tests regarding the model API
  • Added support for actually exporting annotations in the serialization format

What we still need to do:

@enikao
Copy link
Contributor

enikao commented Sep 11, 2023

  • We introduce annotations in the model API. To do this we create a common ancestor for annotations and nodes as annotations can target both. We call this ancestor "Element" for lack of a better name

Isn't the common ancestor Classifier? (See https://lionweb-org.github.io/organization/metametamodel/metametamodel.html#_overview)

@ftomassetti
Copy link
Contributor Author

We introduce annotations in the model API. To do this we create a common ancestor for annotations and nodes as annotations can target both. We call this ancestor "Element" for lack of a better name

Isn't the common ancestor Classifier? (See https://lionweb-org.github.io/organization/metametamodel/metametamodel.html#_overview)

It would be the equivalent on Classifier on the model level. I.e., it would have the thing that represent an instance of a Classifier, in the same way that Node is an instance on Concept and AnnotationInstance is an instance of Annotation

@ftomassetti
Copy link
Contributor Author

I renamed Element into ClassifierInstance, because @enikao is right, is connected to Classifier

@ftomassetti
Copy link
Contributor Author

Discussion in LionWeb-io/specification#164 could affect this

@ftomassetti ftomassetti marked this pull request as ready for review September 14, 2023 15:21
@ftomassetti
Copy link
Contributor Author

This is a very big PR because a lot of code had to be changed to deal with Classifiers (and not just Concepts) and with Classifier Instances (which are either Nodes or Annotation Instances, while before we dealt only with Node).

I do not expect anyone to have the time to read this whole PR, but perhaps @enikao and/or @dslmeinte have the time to take a look at some part and provide some feedback.

Otherwise I can merge and then react to issues and inconsistencies with the TS implementation as they emerge :)

@dslmeinte
Copy link
Contributor

It's indeed a big PR. What I'm sort of missing is a persisted serialization chunk with some actual annotation instances. I only see the key-value-pair "annotations": [] having been added everywhere: that might be something to add - or likely explicitly deserialize a language + model in it that's built up in some of the tests.

@@ -160,4 +164,12 @@ public String toString() {
public void setAnnotations(List<String> annotationIDs) {
this.annotations = annotationIDs;
}

public String getAnnotated() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we have this method? This must be the same as getParent(), according to https://lionweb-org.github.io/organization/serialization/serialization.html#parent

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This came as a surprise to me. When I think about the model I imagine a tree (or a forest) which is composed by nodes, each one with their own position within the tree. Each one (besides roots) having a parent. Annotation instances are instances something else: they are not node, they are not part of the tree. They are attached to nodes. Some consumers are interested in the tree (so just the nodes), some others are interested in the tree and the attached annotation instances.

So it seems strange to me that an annotation instance has a parent, as it is not part of the tree. From may point of view it has a pointer to the node that it is attached to, which it is not its parent, as the annotation instance is not a children of the node (it is not part of any containment).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The rationale was: Every node must be contained in a Partition. We can always find the partition by moving up to the root of the containment hierarchy.
If not the annotated node, who else is the parent of an annotation instance? Which partition does it belong to?

If we wanted completely independent annotations (i.e. stored somewhere outside the annotated node), they would be provided by a processor as a derived model. This processor might have its own internal storage, or ask the repository for a "special" partition that contains all the annotations.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that the partition containing the annotation is the same partition which is containing the annotated node, on that we agree. My problem is with the term "parent" to indicate what it seems to me are two different relationship.

I think that the children of a node do not contain the annotations attached to that node. Is that right?

If it is right, then it is surprising that the annotation can have as a parent the annotated node. It means that parent is not the inverse relationship of children.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's what we decided in LionWeb-io/specification#150

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Understood, I will comply

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I hope this was our understanding, not only my understanding -- shall we raise the issue again in the next meeting?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that once @dslmeinte implements annotations for TS it could be useful to compare ideas regarding annotations at the model level, because I think we discussed annotations mostly at the metamodel level, and he may also find certain inconsistencies/weird naming. However for getAnnotated I agree and I will remove it

@@ -11,6 +11,7 @@ public class SerializedClassifierInstance {
private String id;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the difference to a SerializedNode?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In my understanding we have annotation instances and nodes, which are similar but not the same. So the common ancestor (grouping the similarities) is called Classifier Instance. Also when serializing them they are very similar but not the same. For example, an annotation instance has no concept, it has an annotation instead. It has no parent but an annotated node instead (see previous comment). For this reason also on the serialization level I find useful to distinguish them.

Annotation getAnnotationDefinition();

ClassifierInstance getAnnotated();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as getParent()

@ftomassetti
Copy link
Contributor Author

TODO: let annotations have containments

@ftomassetti
Copy link
Contributor Author

Merging to avoid conflicts with other work (lke renaming LIonWeb into LionWeb).

Some changes may be done later, to ensure adherence with the "standard"

@ftomassetti ftomassetti merged commit f41a642 into master Sep 20, 2023
@ftomassetti ftomassetti deleted the annotations branch September 20, 2023 09:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants