From 3fce19a3d35a557845a8a50cfb7987501b6967f4 Mon Sep 17 00:00:00 2001 From: grammarware Date: Thu, 11 Oct 2012 11:10:37 +0200 Subject: [PATCH] more systematic approach to organising the megamodel examples --- topics/mega/lib/ox/.gitignore | 3 +++ topics/mega/lib/ox/Makefile | 7 +++++++ topics/mega/lib/ox/README.txt | 8 ++++++++ topics/mega/lib/ox/annotation.megal | 14 ++++++++++++++ topics/mega/lib/ox/configuration.megal | 12 ++++++++++++ topics/mega/lib/ox/deserialization.megal | 16 ++++++++++++++++ topics/mega/lib/ox/generation.megal | 10 ++++++++++ topics/mega/lib/ox/read.megal | 12 ++++++++++++ topics/mega/lib/ox/serialization.megal | 16 ++++++++++++++++ topics/mega/lib/ox/technology.megal | 19 +++++++++++++++++++ topics/mega/lib/ox/types.megal | 13 +++++++++++++ topics/mega/lib/ox/write.megal | 12 ++++++++++++ .../mega/{examples => lib/slps}/guided.megal | 0 topics/mega/src/MegaParser.rsc | 2 +- 14 files changed, 143 insertions(+), 1 deletion(-) create mode 100644 topics/mega/lib/ox/.gitignore create mode 100644 topics/mega/lib/ox/Makefile create mode 100644 topics/mega/lib/ox/README.txt create mode 100644 topics/mega/lib/ox/annotation.megal create mode 100644 topics/mega/lib/ox/configuration.megal create mode 100644 topics/mega/lib/ox/deserialization.megal create mode 100644 topics/mega/lib/ox/generation.megal create mode 100644 topics/mega/lib/ox/read.megal create mode 100644 topics/mega/lib/ox/serialization.megal create mode 100644 topics/mega/lib/ox/technology.megal create mode 100644 topics/mega/lib/ox/types.megal create mode 100644 topics/mega/lib/ox/write.megal rename topics/mega/{examples => lib/slps}/guided.megal (100%) diff --git a/topics/mega/lib/ox/.gitignore b/topics/mega/lib/ox/.gitignore new file mode 100644 index 00000000..6a9a615b --- /dev/null +++ b/topics/mega/lib/ox/.gitignore @@ -0,0 +1,3 @@ +*.back.megal +*.dot +*.pdf diff --git a/topics/mega/lib/ox/Makefile b/topics/mega/lib/ox/Makefile new file mode 100644 index 00000000..74b56ad4 --- /dev/null +++ b/topics/mega/lib/ox/Makefile @@ -0,0 +1,7 @@ +all: + +build: + cp ../../../../../101repo/capabilities/Object_XML_mapping/MegaL/*.megal . + +clean: + rm -f *.dot *.pdf diff --git a/topics/mega/lib/ox/README.txt b/topics/mega/lib/ox/README.txt new file mode 100644 index 00000000..57ba0700 --- /dev/null +++ b/topics/mega/lib/ox/README.txt @@ -0,0 +1,8 @@ +These megamodels are taken directly from the 101companies repository. +They were available at this address: + https://github.com/101companies/101repo/tree/master/capabilities/Object_XML_mapping/MegaL + +For more information on the project, look for: + http://101companies.org/ + +Re-run 'make build' if you want to refresh the files — requires a cloned copy of the 101companies repository. diff --git a/topics/mega/lib/ox/annotation.megal b/topics/mega/lib/ox/annotation.megal new file mode 100644 index 00000000..f8876223 --- /dev/null +++ b/topics/mega/lib/ox/annotation.megal @@ -0,0 +1,14 @@ +{- Object/XML mapping may be customized by some annotation mechanism such that schema-derived or authored OO types and their members are annotated with hints regarding de-/serialization. -} + +megamodel capabilities/Object_XML_mapping/annotation . + +include capabilities/Object_XML_mapping/serialization . +include capabilities/Object_XML_mapping/deserialization . + +variable Language Annotation partOf OoLanguage . +variable Language OxAnnotation subsetOf Annotation . +variable Fragment+ anno partOf ooTypes . + +OxAnnotation partOf OxMapper . +deserialize dependsOn anno . +serialize dependsOn anno . diff --git a/topics/mega/lib/ox/configuration.megal b/topics/mega/lib/ox/configuration.megal new file mode 100644 index 00000000..8eb15e62 --- /dev/null +++ b/topics/mega/lib/ox/configuration.megal @@ -0,0 +1,12 @@ +{- Configuration of Object/XML mapping may be achieved by designated configuration files. An additional or alternative form of configuration may be achieved by annotations, as discussed elsewhere. -} + +megamodel capabilities/Object_XML_mapping/configuration . + +include capabilities/Object_XML_mapping/values . + +variable Language OxConfiguration . +variable File config elementOf OxConfiguration . + +OxConfiguration partOf OxMapper . +deserialize dependsOn config . +serialize dependsOn config . diff --git a/topics/mega/lib/ox/deserialization.megal b/topics/mega/lib/ox/deserialization.megal new file mode 100644 index 00000000..9038cb74 --- /dev/null +++ b/topics/mega/lib/ox/deserialization.megal @@ -0,0 +1,16 @@ +{- This module describes the value-level aspect of specifically de-serialization. (There is a related module for specifically serialization. At the heart of this description is a function deserialize, which is somehow derived by the mapper from the XML types (or the corresponding OO types) such that deserialization may map an XML document to an object graph with the suitable correspondence and conformance relationships. -} + +megamodel capabilities/Object_XML_mapping/deserialization . + +include capabilities/Object_XML_mapping/values . + +local Function deserialize : XML -> ObjectGraphs . +variable File xmlInputDoc elementOf XML . +variable ObjectGraph intialObj elementOf ObjectGraphs . + +deserialize dependsOn OxMapper . +deserialize dependsOn xmlTypes . +xmlInputDoc conformsTo xmlTypes . +finalObj conformsTo ooTypes . +finalObj correspondsTo xmlInputDoc . +deserialize(xmlInputDoc) |-> intialObj . diff --git a/topics/mega/lib/ox/generation.megal b/topics/mega/lib/ox/generation.megal new file mode 100644 index 00000000..f56b36d6 --- /dev/null +++ b/topics/mega/lib/ox/generation.megal @@ -0,0 +1,10 @@ +{- Arguably, the typical Object/XML mapping technology comes with a code generation component to derive OO types from XML types. Conceptually, though, this component is optional, which is why it is only introduced now. -} + +megamodel capabilities/Object_XML_mapping/generation . + +include capabilities/Object_XML_mapping/types . + +local Function generator : XmlSchemas -> MappableOo . + +generator partOf OxMapper. +generator(xmlTypes) |-> ooTypes . diff --git a/topics/mega/lib/ox/read.megal b/topics/mega/lib/ox/read.megal new file mode 100644 index 00000000..7b8e6212 --- /dev/null +++ b/topics/mega/lib/ox/read.megal @@ -0,0 +1,12 @@ +{- De-serialization was already discussed in a designated module, but the derivation of the corresponding function for de-serialization was not yet explained. To this end, we need to assume actual program code which makes use of appropriate library functionality to issue de-serialization. (There is a similar module for serialization.) -} + +megamodel capabilities/Object_XML_mapping/read . + +include capabilities/Object_XML_mapping/deserialization . + +variable File problemProgram elementOf OoLanguage . +variable Fragment deserialization partOf problemProgram . + +problemProgram dependsOn ooTypes . +deserialization realizationOf deserialize . +deserialization dependsOn OxLibrary . diff --git a/topics/mega/lib/ox/serialization.megal b/topics/mega/lib/ox/serialization.megal new file mode 100644 index 00000000..634f26df --- /dev/null +++ b/topics/mega/lib/ox/serialization.megal @@ -0,0 +1,16 @@ +{- This module describes the value-level aspect of specifically serialization. (There is a related module for specifically de-serialization. At the heart of this description is a function serialize, which is somehow derived by the mapper from the XML types (or the corresponding OO types) such that serialization may map an object graph to an XML document with the suitable correspondence and conformance relationships. -} + +megamodel capabilities/Object_XML_mapping/serialization . + +include capabilities/Object_XML_mapping/values . + +local Function serialize : ObjectGraphs -> XML . +variable File xmlOutputDoc elementOf XML . +variable ObjectGraph finalObj elementOf ObjectGraphs . + +serialize dependsOn OxMapper . +serialize dependsOn xmlTypes . +xmlOutputDoc conformsTo xmlTypes . +finalObj conformsTo ooTypes . +finalObj correspondsTo xmlOutputDoc . +serialize(finalObj) |-> xmlOutputDoc . diff --git a/topics/mega/lib/ox/technology.megal b/topics/mega/lib/ox/technology.megal new file mode 100644 index 00000000..866be49f --- /dev/null +++ b/topics/mega/lib/ox/technology.megal @@ -0,0 +1,19 @@ +{- This is the basic module explaining the component structure and inter-language and technology dependencies for an Object/XML mapping technology. -} + +megamodel capabilities/Object_XML_mapping/technology . + +variable Technology OxMapper . -- the name for the technology +variable Library OxLibrary . -- the assumed support library +variable Language XmlSchemas . -- the targeted XML type system, e.g., XSD +variable Language OoLanguage . -- the targeted OO language +variable Language MappableOo . -- the OO subset used in mapping +Language XML . -- XML as serialization format +variable Language ObjectGraphs . -- object graphs in memory + +OxLibrary partOf OxMapper . +OxMapper dependsOn XmlSchemas . +OxMapper dependsOn OoLanguage . +MappableOo subsetOf OoLanguage . +MappableOo partOf OxMapper . +OxMapper dependsOn XML . +OxMapper dependsOn ObjectGraphs . diff --git a/topics/mega/lib/ox/types.megal b/topics/mega/lib/ox/types.megal new file mode 100644 index 00000000..ef149e4b --- /dev/null +++ b/topics/mega/lib/ox/types.megal @@ -0,0 +1,13 @@ +{- This module covers the essential type-level aspects of Object/XML mapping. In particular, the types in the spaces XMLware and the objectware are pointed as they correspond to each other. We also make explicit the existence of a problem-specific language underlying the involved type-level artifacts. We think of this language as being abstract in the sense of not fixing it here as being a set of XML trees or object graphs. -} + +megamodel capabilities/Object_XML_mapping/types . + +include capabilities/Object_XML_mapping/technology . + +variable File+ xmlTypes elementOf XmlSchemas . +variable File+ ooTypes elementOf MappableOo . +local Language problemLanguage . + +xmlTypes correspondsTo ooTypes . +xmlTypes definitionOf problemLanguage . +ooTypes definitionOf problemLanguage . diff --git a/topics/mega/lib/ox/write.megal b/topics/mega/lib/ox/write.megal new file mode 100644 index 00000000..cdb365bc --- /dev/null +++ b/topics/mega/lib/ox/write.megal @@ -0,0 +1,12 @@ +{- Serialization was already discussed in a designated module, but the derivation of the corresponding function for serialization was not yet explained. To this end, we need to assume actual program code which makes use of appropriate library functionality to issue serialization. (There is a similar module for de-serialization.) -} + +megamodel capabilities/Object_XML_mapping/write . + +include capabilities/Object_XML_mapping/serialization . + +variable File problemProgram elementOf OoLanguage . +variable Fragment serialization partOf problemProgram . + +problemProgram dependsOn ooTypes . +serialization realizationOf serialize . +serialization dependsOn OxLibrary . diff --git a/topics/mega/examples/guided.megal b/topics/mega/lib/slps/guided.megal similarity index 100% rename from topics/mega/examples/guided.megal rename to topics/mega/lib/slps/guided.megal diff --git a/topics/mega/src/MegaParser.rsc b/topics/mega/src/MegaParser.rsc index 4a4ecc17..9e0c9da0 100644 --- a/topics/mega/src/MegaParser.rsc +++ b/topics/mega/src/MegaParser.rsc @@ -11,7 +11,7 @@ import IO; public void main(list[str] args) { - loc base = |cwd:///../tests|; + loc base = |cwd:///../lib/ox|; for (f <- listEntries(base), endsWith(f,".megal")) { println("Getting a parse tree of ...");