# See the License for the specific language governing permissions and
# limitations under the License.
-# Save and load `Model` from/to Neo4j base.
+# Save and load a `Model` to/from a Neo4j graph.
#
# Nit models are composed by MEntities.
# This module creates NeoNode for each MEntity found in a `Model` and save them
# into Neo4j database.
#
-# see `Neo4jClient`.
+# SEE: `Neo4jClient`
#
# NeoNodes can also be translated back to MEntities to rebuild a Nit `Model`.
#
-# Structure of the nit `Model` in base:
+# Structure of the nit `Model` in the graph:
#
# Note : Any null or empty attribute will not be saved in the database.
#
#
# * labels: `MClass`, `model_name` and `MEntity`.
# * `full_name`: fully qualified name.
-# * `arity`: number of generic formal parameters. 0 if the class is not generic.
# * `kind`: kind of the class (`interface`, `abstract class`, etc.)
# * `visibility`: visibility of the class.
+# * `parameter_names`: JSON array listing the name of each formal generic
+# parameter (in order of declaration).
# * `(:MClass)-[:CLASSTYPE]->(:MClassType)`: SEE: `MClass.mclass_type`
#
# Arguments in the `CLASSTYPE` are named following the `parameter_names`
# `MClassDef`
#
# * labels: `MClassDef`, `model_name` and `MEntity`.
-# * `is_intro`: Does this definition introduce the class?
# * `location`: origin of the definition. SEE: `Location.to_s`
-# * `parameter_names`: JSON array listing the name of each formal generic
-# parameter (in order of declaration).
# * `(:MClassDef)-[:BOUNDTYPE]->(:MClassType)`: bounded type associated to the
# classdef.
# * `(:MClassDef)-[:MCLASS]->(:MClass)`: associated `MClass`.
# * labels: `MPropDef`, `model_name` and `MEntity`. Must also have `MMethodDef`,
# `MAttributeDef` or `MVirtualTypeDef`, depending on the class of the
# represented entity.
-# * `is_intro`: Does this definition introduce the property?
# * `location`: origin of the definition. SEE: `Location.to_s`.
# * `(:MPropDef)-[:DEFINES]->(:MProperty)`: associated property.
#
# * `(:MClassType)-[:ARGUMENT]->(:MType)`: type arguments.
#
# Arguments are named following the `parameter_names` attribute of the
-# `MClassDef` that introduces the class referred by `CLASS`.
+# `MClass` referred by `CLASS`.
#
# Additional relationship for `MVirtualType`:
#
private fun mclassdef_node(mclassdef: MClassDef): NeoNode do
var node = make_node(mclassdef)
node.labels.add "MClassDef"
- node["is_intro"] = mclassdef.is_intro
node["location"] = mclassdef.location.to_s
node.out_edges.add(new NeoEdge(node, "BOUNDTYPE", to_node(mclassdef.bound_mtype)))
node.out_edges.add(new NeoEdge(node, "MCLASS", to_node(mclassdef.mclass)))
end
mentities[node] = mprop
set_doc(node, mprop)
- for npropdef in node.in_nodes("DEFINES") do
- var mpropdef = to_mpropdef(model, npropdef)
- if npropdef["is_intro"].as(Bool) then
- mprop.mpropdefs.unshift mpropdef
- else
- mprop.mpropdefs.add mpropdef
- end
- end
return mprop
end
private fun mpropdef_node(mpropdef: MPropDef): NeoNode do
var node = make_node(mpropdef)
node.labels.add "MPropDef"
- node["is_intro"] = mpropdef.is_intro
node["location"] = mpropdef.location.to_s
node.out_edges.add(new NeoEdge(node, "DEFINES", to_node(mpropdef.mproperty)))
if mpropdef isa MMethodDef then