[Neo] meta meta classes

Niels Hoogeveen pd_aficionado at hotmail.com
Tue Apr 13 00:29:23 CEST 2010


Before adding the features described so far, let's discuss the issue of a MetaModelMetaClass.

This entire discussion started with an example of an HTML tag library, where the need arose to add properties to classes. At the time I suggested, and described, a reification method, that created a MetaModelClass in a different namespace, that allowed for the modeling of a particular MetaModelClass. 

That solution is more or less correct, except, the reify method shouldn't return a MetaModelClass, whose single instance is the node of another MetaModelClass. The proper solution to that issue, requires a MetaModelMetaClass, whose instance is a MetaModelClass.

Adding a MetaModelMetaClass to the meta model makes sense, what is a meta model, without having meta classes? UML/MOF recognizes instances, classes and meta classes as well.

Having meta classes also makes it possible to model the meta model itself. Instead of having "magic" properties and "special" relationships, used in the meta model component, these entities can become ordinary citizens of the meta model. 

Introducing meta classes creates one "magic" property "meta_name" and one "special" relationships of its own "META_META_IS_SUBCLASS_OF" (from MetaModelMetaClass to MetaModelMetaClass), so the question may arise, why treat those three entities as special? 

The answer to that is quite simple. If we would want to treat that "magic" property and "special" relationship as ordinary citizens, we'd have to create a MetaModelMetaMetaClass, but that meta meta class would be strikingly uninteresting, since it would be the sole entity on that meta level, only stating that MetaModelMetaClasses has a "meta_name" and can have subclasses.

So while theoretically a meta model class consists of 4 layers, for all practical purposes we need 3: instance, class, meta class.

Instances are described by classes, while classes are described by meta classes.

Assuming a split between MetaModelProperties and MetaModelRelationship 
as proposed before, I will use the following abbreviations from now on:

PP = MetaModelProperty
RS = MetaModelRelationship
CL = MetaModelClass
MC = MetaModelMetaClass
PR = MetaModePropertyRestriction
RR = MetaModelRelationshipRestriction
NS = MetaModelNamespace

The meta model would have the following default entities:

PP:

name - (applies to all entities except the global namespace, and the MetaModelMetaClassRoot)
range_implementation_class - (applies to PP, RS, PR and RR)
range_specification - (applies to PP and PR)
data_range - (applies to PP and PR)

RS:

META_META_IS_INSTANCE_OF (CL --> MC)
META_META_IS_SUBCLASS_OF (MC --> MC)

META_CLASS  (NS --> CL)
META_CLASS_HAS_PROPERTY (CL --> PP)
META_HAS_INSTANCE (CL --> Node)  //Reversed the relationship, because node is not part of the meta model
META_IS_INVERSE_OF (PP --> PP)
META_IS_SUBCLASS_OF (CL --> CL)
META_IS_SUBPROPERTY_OF (PP --> PP)
META_NAMESPACE (GlobalNamespace --> NameableNamespace)
META_PROPERTY (NS --> PP)
META_RELATIONSHIP_HAS_RANGE (PP --> CL)
META_RESTRICTION_TO_CLASS (PR or RR --> CL)
META_RESTRICTION_TO_PROPERTY (PR --> PP)
META_RESTRICTION_TO_RELATIONSHIP (RR --> RS)
META_SUBREF_TO_REF(GlobalNamespace --> Reference node) //Reversed the relationship, because reference node is not part of the meta model

MC:

MetaModelMetaClassRoot (takes no direct instances and is the root of all MC's)
Nameable (takes no direct instances, and is the root of all nameable meta object, is subclass of MetaModelMetaClassRoot)
NS (takes no direct instances, and is the root of all namespaces, is subclass of MetaModelMetaClassRoot)

GlobalNamespace (has one instance, denoting the global namespace, is subclass of Namespace)
NameableNamespace (is subclass of Namespace and is subclass of Nameable)

MC (is subclass of Nameable)
PP (is subclass of Nameable)
RS (is subclass of Nameable)
PR (is subclass of Nameable)
RR (is subclass of Nameable)

MC's live in the global namespace, since we only want to have one meta layer in the database. 

With all this in place, it becomes trivial to implement a "taggable" class, like the HTML tag library example.

Create PP "tagname" with datatype "String"
Create MC "taggable"
Make PP "tagname" a property of MC "taggable"
Create CL "taggable"
Make CL "taggable" a direct instance of MC "taggable"


Now each CL "taggable" will have a PP "tagname", which can be set for each CL "taggable", and which can be seen as a constant for each instance of a subclass of CL "taggable". E.g.  CL "div" is a subclass of CL "taggable" with "tagname" = "div" and PP's "id", "class", "dir", "lang", "style". Each instance of "div" can have different values for "id", "class", "dir", "lang" and "style", but the tagname will be "div" for each instance, since that is defined at the class level.

Kind regards,
Niels Hoogeveen

> Date: Mon, 12 Apr 2010 09:28:53 +0200
> From: mattias at neotechnology.com
> To: user at lists.neo4j.org
> Subject: Re: [Neo] meta meta classes
> 
> Your thoughts and finding makes a lot of sense and I too would be happy to
> see those features in the meta model.
> 
> 2010/4/11 Niels Hoogeveen <pd_aficionado at hotmail.com>
> 
> >
> >
> >
> >
> >
> >
> > I would be very happy when this functionally is implemented. Let's see who
> > gets to this first. At the moment I am working on implementing meta model
> > path expressions that can be used in a traverser, so it may take a couple of
> > days for me to take a stab at building the instance restriction
> > functionality.
> >
> > I do have another issue with the current implementation. I don't think it's
> > a good idea to treat relationships and properties on the same footing. There
> > may be common functionality, but that doesn't make a property the same as a
> > relationship.
> >
> > I think it would be better to have interfaces PropertyRange and
> > RelationshipRange, and having classes MetaModelProperty and
> > MetaModelRelationship. Treating properties and relationships as equal,
> > restricts the modelability of a Neo4J graph.
> >
> > As it stands, it is impossible to model the properties of a Relationship.
> > Within the current design it is not possible to add that functionality,
> > because it would mean the ability to set MetaModelProperties for
> >  MetaModelProperties. This would be correct for MetaModelProperties that
> > denote relationships, but not for MetaModelProperties that denote
> > properties.
> >
> > For my own project, I also run into problems that MetaModelProperty is not
> > specific enough. I'd like to describe paths by means of their meta model
> > entities. A path would take a form like this:
> >
> > MetaModelClass("some class name") --> RelationshipType("some relationship
> > type name") --> MetaModelClass("some other class name") -->
> > MetaModelProperty("some property name")
> >
> > There are two problems here. First of all, I need to use RelationshipType
> > as a means to denote a relation. RelationshipType is not part of the meta
> > model, and as a result has no cardinality information. Without unique names
> > for PropertyTypes it is impossible to look up the MetaModelProperty a
> > RelationshipType is related to, since there can be several
> > MetaModelProperties with the same name. Even if such a lookup were possible,
> > it is still a clumsy solution. It would be much nicer to be able to have a
> > class MetaModelRelationship which denotes a relationship, and which has
> > cardinality and range methods.
> >
> > Another issue is that I'd like to be able to state that the final element
> > in a path is a property of some type. In the end, programs interact with
> > users and other programs through values, not through objects. So most of the
> > paths I would like to describe, will end with something that denotes a
> > property value. Using MetaModelProperty for this purpose, doesn't work,
> > because MetaModelProperty can denote both a property and a relationship.
> >
> > So I think we need three main types of ranges:
> >
> > InstanceRange
> > ClassRanges
> > PropertyRanges
> >
> > Each MetaModelRestrictable now takes a combination of the last two ranges,
> > and, in my opinion, those should be separated:
> >
> > MetaModelProperty (takes PropertyRange and has cardinality methods)
> > MetaModelRelationship (takes ClassRange or InstanceRange* and has
> > cardinality methods)
> > MetaModelClass (takes InstanceRange and has cardinality methods)
> >
> > *An InstanceRange on MetaModelRelationship means that each instance of a
> > class can only have a particular relationship with certain instances. A
> > class range on MetaModelRelationship means that each instance of a class can
> > only have a particular relationship with instances of a certain classes.
> >
> >
> > MetaModelClass will additionally have:
> >
> > getAllInstances()
> > getDirectInstances()
> > getAllPropertyTypes()
> > getDirectPropertyTypes()
> > getAllRelationshipsTypes()
> > getDirectRelationshipsTypes()
> > getPropertyRestriction(MetaModelProperty, boolean) returns
> > MetaModelPropertyRestriction
> > getRelationshipRestriction(MetaModelRelationship, boolean) returns
> > MetaModelRelationshipRestriction
> >
> > MetaModelRelationship will additionally have:
> >
> > getAllPropertyTypes()
> >
> > getDirectPropertyTypes()
> > getPropertyRestriction(MetaModelProperty, boolean) returns
> > MetaModelPropertyRestriction
> >
> >
> > MetaModelProperty needs no additional methods not already covered in the
> > current implementation.
> >
> > Kind regards,
> > Niels Hoogeveen
> >
> > P.S. I think it should be smart to introduce one more entity
> > MetaModelMetaClass, which I will write about later.
> >
> >
> >
> > > Date: Fri, 9 Apr 2010 13:36:12 +0200
> > > From: mattias at neotechnology.com
> > > To: user at lists.neo4j.org
> > > Subject: Re: [Neo] meta meta classes
> > >
> > > Now we're getting somewhere... I like this solution a lot, thanks for the
> > > great idea. Let me see if I get time to try and implement it soon! Or if
> > you
> > > get to if before me and supply a patch. It's nice either way :)
> > >
> > > 2010/4/9 Niels Hoogeveen <pd_aficionado at hotmail.com>
> > >
> > > >
> > > > Having thought about implementation a little bit more, it would be neat
> > to
> > > > have MetaModelClass implement an interface similar to
> > MetaModelRestrictable,
> > > > with one difference, the setRange and getRange don't refer to a
> > > > PropertyRange but to an InstanceRange.
> > > >
> > > > Like PropertyRange, InstanceRange should be an abstract class so
> > several
> > > > different different implementations of InstanceRanges can be provided:
> > > >
> > > > * InstanceEnumerationRange (enumerates the n instances the class
> > contains
> > > > and sets minCardinality = maxCardinality = n )
> > > > * IndexedInstanceRange (indexes the n instances it contains and sets
> > > > minCardinality = maxCardinality = n, making the class into an Instance
> > > > array)
> > > > * NullInstanceRange (set minCardinality = maxCardinality = 0, making
> > the
> > > > class abstract)
> > > > * InstanceClassesRange (states that the instances of a class have to be
> > > > instances of one of a given set of classes)
> > > >
> > > > The first three range types restrict the MetaModelClass to having no
> > > > getDirectInstances.add functionality, and also the setting of
> > cardinality
> > > > should be disabled, which makes me wonder if we need a class
> > > > FixedMetaModelClass, which simply doesn't provide these methods, or if
> > we
> > > > should throw exceptions when methods are inappropriately called, or if
> > we
> > > > allow inconsistent data like the rest of the meta model does.
> > > >
> > > >
> > > > > From: pd_aficionado at hotmail.com
> > > > > To: user at lists.neo4j.org
> > > > > Date: Thu, 8 Apr 2010 23:52:02 +0200
> > > > > Subject: Re: [Neo] meta meta classes
> > > > >
> > > > >
> > > > > I think the best solution here is to have an instance enumeration on
> > > > MetaModelClass. Singletons are special case of an enumeration.
> > > > >
> > > > > See:
> > > > > http://www.w3.org/TR/2002/WD-owl-ref-20021112/#Enumerated
> > > > >
> > > >
> > http://owl.cs.manchester.ac.uk/2007/05/api/javadoc/org/semanticweb/owl/model/OWLObjectOneOf.html
> > > > >
> > > > >
> > > > >
> > > > > > Date: Thu, 8 Apr 2010 22:33:11 +0200
> > > > > > From: mattias at neotechnology.com
> > > > > > To: user at lists.neo4j.org
> > > > > > Subject: Re: [Neo] meta meta classes
> > > > > >
> > > > > > Ok now I get your point! Thank you for clarifying.
> > > > > >
> > > > > > Your singleton proposal could be a good idea then. Could it
> > > > > > potentially be a hindrance in some scenario? I mean should we have
> > a
> > > > > > MetaModelClass#setSingleton(boolean) or something so that this
> > > > > > behaviour can be controlled?
> > > > > >
> > > > > > 2010/4/8, Niels Hoogeveen <pd_aficionado at hotmail.com>:
> > > > > > >
> > > > > > > Each country needs to be modeled as classes, because I want to
> > set
> > > > the
> > > > > > > restriction that French regions (which can have different
> > properties
> > > > from
> > > > > > > Canadian provinces) can only have a relationship with the country
> > > > France,
> > > > > > > and Canadian provinces can only have a relationship with the
> > country
> > > > Canada.
> > > > > > > The domain and the range of a PropertyType are classes not
> > instances.
> > > > If
> > > > > > > countries were simply instances of the  "country" class, it would
> > be
> > > > > > > possible to say that an instance of a Canadian province is a
> > > > subdivision of
> > > > > > > France.
> > > > > > >
> > > > > > > I'd like to be able to iterate over the subdivision of France and
> > > > have
> > > > > > > guaranteed that each instance has the property "region code", a
> > > > property
> > > > > > > unknown to Canadian provinces. Without having a restriction
> > stating
> > > > that a
> > > > > > > specific sub-division belongs to a specific country, any
> > sub-division
> > > > can be
> > > > > > > related to any country, so a user may erroneously say that
> > Alberta is
> > > > a
> > > > > > > French region. Not only is this factually incorrect, but
> > structurally
> > > > too.
> > > > > > > Alberta, being a Canadian province, doesn't have the "region
> > code"
> > > > property,
> > > > > > > which I want French regions to have.
> > > > > > >
> > > > > > >
> > > > > > >> Date: Thu, 8 Apr 2010 20:06:32 +0200
> > > > > > >> From: mattias at neotechnology.com
> > > > > > >> To: user at lists.neo4j.org
> > > > > > >> Subject: Re: [Neo] meta meta classes
> > > > > > >>
> > > > > > >> 2010/4/8 Niels Hoogeveen <pd_aficionado at hotmail.com>
> > > > > > >>
> > > > > > >> >
> > > > > > >> > Your point about the cardinality restriction is a correct
> > > > observation.
> > > > > > >> >
> > > > > > >> > In fact it would be better to create a "is-subdivision-of"
> > > > PropertyType
> > > > > > >> > on
> > > > > > >> > "sub-division" and give that a range "country" with a
> > cardinality
> > > > of 1.
> > > > > > >> > Then
> > > > > > >> > for each subclass of "sub-division" a restriction should be
> > set,
> > > > naming
> > > > > > >> > the
> > > > > > >> > "country" class this specific "sub-division" class applies to.
> > > > > > >> >
> > > > > > >> > Still, it requires  each country to be defined as both a class
> > and
> > > > an
> > > > > > >> > instance.
> > > > > > >> >
> > > > > > >> Why just countries as classes? why not each subdivision as
> > classes
> > > > as
> > > > > > >> well?
> > > > > > >> Why countries as classes at all?
> > > > > > >>
> > > > > > >> >
> > > > > > >> > > Date: Thu, 8 Apr 2010 19:15:30 +0200
> > > > > > >> > > From: mattias at neotechnology.com
> > > > > > >> > > To: user at lists.neo4j.org
> > > > > > >> > > Subject: Re: [Neo] meta meta classes
> > > > > > >> > >
> > > > > > >> > > So, you describe the model (with "country", "sub-division"
> > and
> > > > > > >> > > "has-sub-division") which is OK! Then you not just want to
> > add
> > > > data
> > > > > > >> > > which
> > > > > > >> > > would conform to it, you also describe the highest level of
> > that
> > > > data
> > > > > > >> > > in
> > > > > > >> > the
> > > > > > >> > > meta model itself with cardinality for how many
> > sub-divisions
> > > > each
> > > > > > >> > > such
> > > > > > >> > > level must contain.
> > > > > > >> > >
> > > > > > >> > > My first though here is: why put actual data into the meta
> > model
> > > > (the
> > > > > > >> > design
> > > > > > >> > > isn't intended for that)?
> > > > > > >> > > The second is: why (since you put actual data into the meta
> > > > model)
> > > > > > >> > > would
> > > > > > >> > you
> > > > > > >> > > stop there? why only say that "France" have 10 subdivisions?
> > You
> > > > don't
> > > > > > >> > say
> > > > > > >> > > exactly which subdivisions or how many/which subdivisions
> > each
> > > > > > >> > subdivision
> > > > > > >> > > has, a.s.o. Which benefits would modeling only the highest
> > level
> > > > of
> > > > > > >> > > data
> > > > > > >> > get
> > > > > > >> > > you? And if you could describe the entire data in the meta
> > > > model, you
> > > > > > >> > > end
> > > > > > >> > up
> > > > > > >> > > with a meta model which describes the entire data and then,
> > in
> > > > > > >> > > addition,
> > > > > > >> > the
> > > > > > >> > > data which is exactly the same as the meta model... what
> > > > benefits does
> > > > > > >> > that
> > > > > > >> > > give you?
> > > > > > >> > >
> > > > > > >> > > I'm just confused about the fact that you want to have the
> > meta
> > > > model
> > > > > > >> > > (classes, properties, restrictions) and (some of) the actual
> > > > data
> > > > > > >> > > modeled
> > > > > > >> > in
> > > > > > >> > > the meta model, whereas the meta model was intended to model
> > the
> > > > meta
> > > > > > >> > model
> > > > > > >> > > (the UML diagram, so to speak) and not the actual data it
> > would
> > > > have
> > > > > > >> > conform
> > > > > > >> > > to it.
> > > > > > >> > >
> > > > > > >> > > Help me understand which benefits you're after by modeling
> > the
> > > > "top
> > > > > > >> > level"
> > > > > > >> > > of your actual data into the meta model itself.
> > > > > > >> > >
> > > > > > >> > >
> > > > > > >> > > Best,
> > > > > > >> > > Mattias
> > > > > > >> > >
> > > > > > >> > > 2010/4/8 Niels Hoogeveen <pd_aficionado at hotmail.com>
> > > > > > >> > >
> > > > > > >> > > >
> > > > > > >> > > > The example of the tag library and countries/sub-divisions
> > are
> > > > not
> > > > > > >> > > > necessarily similar. The first shows the need to model the
> > > > > > >> > > > properties
> > > > > > >> > of a
> > > > > > >> > > > class.
> > > > > > >> > > >
> > > > > > >> > > > The second example shows the need to have singleton
> > classes,
> > > > which
> > > > > > >> > > > is a
> > > > > > >> > > > different concept, and something that cannot be done out
> > of
> > > > the box,
> > > > > > >> > but I
> > > > > > >> > > > will show a solution that requires minimal modifications
> > to
> > > > the
> > > > > > >> > > > current
> > > > > > >> > > > software.
> > > > > > >> > > >
> > > > > > >> > > > Suppose we want to model "countries" and their
> > > > "sub-divisions".
> > > > > > >> > > >
> > > > > > >> > > > We do the following:
> > > > > > >> > > >
> > > > > > >> > > > create class "country"
> > > > > > >> > > > create class "sub-division"
> > > > > > >> > > > create property "has-sub-division"
> > > > > > >> > > > make "has-subdivision" a property of "country"
> > > > > > >> > > >
> > > > > > >> > > > Now we like to populate the database, since all countries
> > have
> > > > > > >> > different
> > > > > > >> > > > types of sub-divisions we need to create those:
> > > > > > >> > > >
> > > > > > >> > > > create class "french_region"
> > > > > > >> > > > create class "canadian_province"
> > > > > > >> > > > create class "canadian_territory"
> > > > > > >> > > > create class "US_state"
> > > > > > >> > > > etc.
> > > > > > >> > > >
> > > > > > >> > > > Populate the various classes with instances:
> > > > > > >> > > >
> > > > > > >> > > > create node for "Alsace" and make it an instance of
> > > > "french_region"
> > > > > > >> > > > create node for "Aquitaine" and make it an instance of
> > > > > > >> > > > "french_region"
> > > > > > >> > > > create node for "Alberta" and make it an instance of
> > > > > > >> > > > "Canadian_province"
> > > > > > >> > > > create node for "Nanavut" and make it an instance of
> > > > > > >> > > > "Canadian_territory"
> > > > > > >> > > > create node for "British Columbia" and make it an instance
> > of
> > > > > > >> > > > "Canadian_province"
> > > > > > >> > > > create node for "Alabama" and make it an instance of
> > > > > > >> > > > "US_State"
> > > > > > >> > > > create node for "Alaska" and make it an instance of
> > > > > > >> > > > "US_State"
> > > > > > >> > > > etc.
> > > > > > >> > > >
> > > > > > >> > > > We'd like to state that each country has its own
> > restriction
> > > > on the
> > > > > > >> > type of
> > > > > > >> > > > subdivision. To do that we need to create classes for each
> > > > country.
> > > > > > >> > > >
> > > > > > >> > > > create class "France"
> > > > > > >> > > > create class "Canada"
> > > > > > >> > > > create class "United_States_of_America"
> > > > > > >> > > > etc.
> > > > > > >> > > >
> > > > > > >> > > > make class "France" a subclass of "Country"
> > > > > > >> > > > make class "Canada" a subclass of "Country"
> > > > > > >> > > > make class "United_States_of_America" a subclass of
> > "Country"
> > > > > > >> > > > etc.
> > > > > > >> > > >
> > > > > > >> > > > create restriction for "France" on "has-sub-division" with
> > > > range
> > > > > > >> > > > "french_province" and cardinality = 26
> > > > > > >> > > > create restriction for "Canada" on "has-sub-division" with
> > > > range
> > > > > > >> > > > "canadian_province" and cardinality = 10
> > > > > > >> > > > create restriction for "Canada" on "has-sub-division" with
> > > > range
> > > > > > >> > > > "canadian_territory" and cardinality = 3
> > > > > > >> > > > create restriction for "United_States_of_America" on
> > > > > > >> > > > "has-sub-division"
> > > > > > >> > > > with range "US_State" and cardinality = 50
> > > > > > >> > > > etc.
> > > > > > >> > > >
> > > > > > >> > > > Now we have classes for each country, but no instances.
> > > > > > >> > > > Unfortunately
> > > > > > >> > we
> > > > > > >> > > > cannot say that a class is an instance of itself, that
> > would
> > > > require
> > > > > > >> > > > a
> > > > > > >> > > > relationsship where the endnode equals the startnode,
> > which
> > > > Neo4J
> > > > > > >> > doesn't
> > > > > > >> > > > allow. So we have to create separate instances for each
> > > > country.
> > > > > > >> > > >
> > > > > > >> > > > create node for "France"
> > > > > > >> > > > create node for "Canada"
> > > > > > >> > > > create node for "United_States_Of_America"
> > > > > > >> > > > etc.
> > > > > > >> > > >
> > > > > > >> > > > make node "France" an instance of class "France"
> > > > > > >> > > > make node "Canada" an instance of class "Canada"
> > > > > > >> > > > make node "United_States_of_America" an instance of class
> > > > > > >> > > > "United_States_of_America"
> > > > > > >> > > >
> > > > > > >> > > > And finally link the subdivisions to their countries:
> > > > > > >> > > >
> > > > > > >> > > >  "France" "has-sub-division" "Alsace"
> > > > > > >> > > > "France" "has-sub-division" "Aquitaine"
> > > > > > >> > > > "Canada" "has-sub-division-of" "Alberta"
> > > > > > >> > > > "Canada" "has-subdivision" "British Columbia"
> > > > > > >> > > > "Canada" "has-subdivision" "Nanavut"
> > > > > > >> > > > "United_States_of_America" "has-sub-division" "Alabama"
> > > > > > >> > > > "United_States_of_America" "has-sub-division" "Alaska"
> > > > > > >> > > >
> > > > > > >> > > > So we end up having a class for each country and an
> > instance
> > > > for
> > > > > > >> > > > each
> > > > > > >> > > > country.
> > > > > > >> > > >
> > > > > > >> > > > Writing this down, I realize the patch I sent you a few
> > days
> > > > ago,
> > > > > > >> > contains
> > > > > > >> > > > a minor flaw, that needs to be fixed. In that patch I
> > added an
> > > > > > >> > > > indexed
> > > > > > >> > > > property "uri" to the meta model, to bring it in line with
> > > > what is
> > > > > > >> > being
> > > > > > >> > > > done in the RDF module, and to make certain that the same
> > URI
> > > > is not
> > > > > > >> > used
> > > > > > >> > > > for two different properties. Without unicity a class can
> > have
> > > > > > >> > > > several
> > > > > > >> > > > different ProperyTypes with the same name. In that
> > situation
> > > > the
> > > > > > >> > > > lookup
> > > > > > >> > of
> > > > > > >> > > > the PropertyType of a property or relationship becomes
> > > > impossible.
> > > > > > >> > > >
> > > > > > >> > > > The flaw in my patch is the name of the "uri" property,
> > which
> > > > should
> > > > > > >> > > > be
> > > > > > >> > > > something like "class_uri". That way the class of each
> > country
> > > > can
> > > > > > >> > > > be
> > > > > > >> > given
> > > > > > >> > > > the same URI as the instance of each country, because they
> > > > live in
> > > > > > >> > different
> > > > > > >> > > > name spaces.
> > > > > > >> > > >
> > > > > > >> > > > This same technique is used in OWL to provide "punning".
> > An
> > > > instance
> > > > > > >> > and a
> > > > > > >> > > > class can have the same URI, because instances in OWL live
> > in
> > > > a
> > > > > > >> > different
> > > > > > >> > > > namespaces from classes.
> > > > > > >> > > >
> > > > > > >> > > > Through the use of the "uri" property and the "class_uri"
> > > > property
> > > > > > >> > > > we
> > > > > > >> > can
> > > > > > >> > > > also distill that each country class is a singleton class,
> > > > because
> > > > > > >> > there
> > > > > > >> > > > exists an instance with the same URI. That way we can work
> > > > around
> > > > > > >> > > > the
> > > > > > >> > > > limitation that relationships cannot have the same start
> > and
> > > > end
> > > > > > >> > > > node.
> > > > > > >> > > >
> > > > > > >> > > > Furthermore, it allows for some extra restrictions to
> > > > MetaModelClass
> > > > > > >> > with
> > > > > > >> > > > the following logic: If a class has exactly one instance
> > where
> > > > the
> > > > > > >> > "uri" of
> > > > > > >> > > > that instance equals the "class_uri" of the class, no more
> > > > instances
> > > > > > >> > can be
> > > > > > >> > > > added And if there is an instance of a class without a
> > "uri"
> > > > that
> > > > > > >> > equals the
> > > > > > >> > > > "class_uri", no instances can be added where the "uri" of
> > the
> > > > > > >> > > > instance
> > > > > > >> > > > equals the "class_uri" of the class. With that logic, we
> > have
> > > > proper
> > > > > > >> > > > singleton classes in the meta model of Neo4J.
> > > > > > >> > > >
> > > > > > >> > > > Kind regards,
> > > > > > >> > > > Niels Hoogeveen
> > > > > > >> > > >
> > > > > > >> > > > > Date: Thu, 8 Apr 2010 11:37:37 +0200
> > > > > > >> > > > > From: mattias at neotechnology.com
> > > > > > >> > > > > To: user at lists.neo4j.org
> > > > > > >> > > > > Subject: Re: [Neo] meta meta classes
> > > > > > >> > > > >
> > > > > > >> > > > > 2010/3/30 Niels Hoogeveen <pd_aficionado at hotmail.com>
> > > > > > >> > > > >
> > > > > > >> > > > > >
> > > > > > >> > > > > > MetaModelObject already has a getter (without using
> > the
> > > > word
> > > > > > >> > > > > > "get")
> > > > > > >> > to
> > > > > > >> > > > > > access the node.
> > > > > > >> > > > > >
> > > > > > >> > > > > > Wrapping MetaModelObject to give it a Node-interface
> > makes
> > > > it
> > > > > > >> > possible
> > > > > > >> > > > to
> > > > > > >> > > > > > directly write:
> > > > > > >> > > > > >
> > > > > > >> > > > > > metalObject.setProperty("a", b)
> > > > > > >> > > > > >
> > > > > > >> > > > > > instead of
> > > > > > >> > > > > >
> > > > > > >> > > > > > metaobject.node.setPropert("a", b)
> > > > > > >> > > > > >
> > > > > > >> > > > > > If that were all, I wouldn't make a post about it. The
> > > > more
> > > > > > >> > interesting
> > > > > > >> > > > > > part is the meta modeling of the node gotten from a
> > > > > > >> > MetaModelObject.
> > > > > > >> > > > This
> > > > > > >> > > > > > node represents the class, but it is not an instance
> > of
> > > > any
> > > > > > >> > > > > > class
> > > > > > >> > > > itself.
> > > > > > >> > > > > > That's where the reify method comes into play, which
> > takes
> > > > the
> > > > > > >> > > > > > node
> > > > > > >> > > > from a
> > > > > > >> > > > > > MetaModelObject and creates a class with the same
> > name,
> > > > but in a
> > > > > > >> > > > different
> > > > > > >> > > > > > namespace, and makes the node an instance of this new
> > > > class.
> > > > > > >> > > > > >
> > > > > > >> > > > > > With that construction it becomes possible to model
> > the
> > > > > > >> > > > > > relationships/properties of a class.
> > > > > > >> > > > > >
> > > > > > >> > > > > > There are many examples where this can be handy.
> > > > > > >> > > > > >
> > > > > > >> > > > > > I already gave the example of HTML tags, where the
> > > > attributes
> > > > > > >> > > > > > can
> > > > > > >> > be
> > > > > > >> > > > > > modeled as properties and the tagname as a property of
> > the
> > > > meta
> > > > > > >> > class.
> > > > > > >> > > > > >
> > > > > > >> > > > > > Another example is:
> > > > > > >> > > > > >
> > > > > > >> > > > > > All countries have subdivision. Countries and their
> > > > subdivisions
> > > > > > >> > all
> > > > > > >> > > > are
> > > > > > >> > > > > > instances of a certain class. There is one class for
> > > > country,
> > > > > > >> > > > > > but
> > > > > > >> > there
> > > > > > >> > > > is a
> > > > > > >> > > > > > set of classes for subdivisions. In some countries, a
> > > > > > >> > > > > > subdivision
> > > > > > >> > is
> > > > > > >> > > > called
> > > > > > >> > > > > > "province", in others it's a "state" or a "district".
> > > > > > >> > > > > > Subdivision
> > > > > > >> > of
> > > > > > >> > > > various
> > > > > > >> > > > > > countries can have different sets of properties and
> > > > relations.
> > > > > > >> > > > > >
> > > > > > >> > > > > > How to model the fact that the instance "United States
> > of
> > > > > > >> > > > > > America"
> > > > > > >> > has
> > > > > > >> > > > > > subdivisions of the class "State_(US)"? Using the
> > reify
> > > > method
> > > > > > >> > > > > > we
> > > > > > >> > can
> > > > > > >> > > > make a
> > > > > > >> > > > > > class "United States of America", where we can model
> > that
> > > > the
> > > > > > >> > > > ClassRange of
> > > > > > >> > > > > > "State_(US)" is "United States of America". Or if we
> > want
> > > > the
> > > > > > >> > > > relationship
> > > > > > >> > > > > > to point the other way, that the "United States of
> > > > America" has
> > > > > > >> > > > > > 50
> > > > > > >> > (use
> > > > > > >> > > > of
> > > > > > >> > > > > > cardinality) subdivisions of the class "State_(US)".
> > > > > > >> > > > > >
> > > > > > >> > > > > Here you take a step into modeling the actual data into
> > the
> > > > meta
> > > > > > >> > model
> > > > > > >> > > > which
> > > > > > >> > > > > describes the data. Is it desirable to first model
> > exactly
> > > > how the
> > > > > > >> > data
> > > > > > >> > > > will
> > > > > > >> > > > > look, and then add data so that it looks like that? I
> > get a
> > > > > > >> > > > > feeling
> > > > > > >> > that
> > > > > > >> > > > the
> > > > > > >> > > > > data is described twice here...
> > > > > > >> > > > >
> > > > > > >> > > > > >
> > > > > > >> > > > > > Of course all this can directly be expressed with
> > nodes
> > > > and
> > > > > > >> > > > relationships,
> > > > > > >> > > > > > but that's what the meta model does anyway.
> > > > > > >> > > > > >
> > > > > > >> > > > > > I do have one peeve with the meta model API. The class
> > > > DataRange
> > > > > > >> > has a
> > > > > > >> > > > > > constructor:
> > > > > > >> > > > > >
> > > > > > >> > > > > > DataRange(String datatype, Object... values)
> > > > > > >> > > > > >
> > > > > > >> > > > > > I'd much rather see a new Restrictable class
> > Datavalue,
> > > > and see
> > > > > > >> > > > > > a
> > > > > > >> > > > > > constructor:
> > > > > > >> > > > > >
> > > > > > >> > > > > > DataRange(String datatype, Datavalue... values)
> > > > > > >> > > > > >
> > > > > > >> > > > > > That way the possible values a property can have
> > > > additional
> > > > > > >> > properties
> > > > > > >> > > > and
> > > > > > >> > > > > > relationships (eg. link to Wordnet definition or
> > Wikipedia
> > > > > > >> > > > > > entry).
> > > > > > >> > > > > >
> > > > > > >> > > > > > Kind regards,
> > > > > > >> > > > > > Niels Hoogeveen
> > > > > > >> > > > > >
> > > > > > >> > > > > >
> > > > > > >> > > > > >
> > > > > > >> > > > > >
> > > > > > >> > > > > >
> > > > > > >> > > > > >
> > > > > > >> > > > > > > Date: Tue, 30 Mar 2010 09:30:10 +0200
> > > > > > >> > > > > > > From: mattias at neotechnology.com
> > > > > > >> > > > > > > To: user at lists.neo4j.org
> > > > > > >> > > > > > > Subject: Re: [Neo] meta meta classes
> > > > > > >> > > > > > >
> > > > > > >> > > > > > > Would making the underlying Node publically
> > available
> > > > (via a
> > > > > > >> > getter)
> > > > > > >> > > > be
> > > > > > >> > > > > > > virtually the same thing? In that case the meta
> > model
> > > > classes
> > > > > > >> > could
> > > > > > >> > > > have
> > > > > > >> > > > > > > such a getter.
> > > > > > >> > > > > > >
> > > > > > >> > > > > > > 2010/3/26 Niels Hoogeveen <
> > pd_aficionado at hotmail.com>
> > > > > > >> > > > > > >
> > > > > > >> > > > > > > >
> > > > > > >> > > > > > > > Hi Peter,
> > > > > > >> > > > > > > >
> > > > > > >> > > > > > > > I added a Wiki entry in my github repo called
> > > > "Reification
> > > > > > >> > > > > > > > of
> > > > > > >> > meta
> > > > > > >> > > > > > classes
> > > > > > >> > > > > > > > and meta properties":
> > > > > > >> > > > > > > >
> > > > > > >> > > > > > > >
> > > > > > >> > > > > > > >
> > > > > > >> > > > > >
> > > > > > >> > > >
> > > > > > >> >
> > > >
> > http://wiki.github.com/NielsHoogeveen/Scala-Neo4j-utils/reification-of-meta-classes-and-meta-properties
> > > > > > >> > > > > > > >
> > > > > > >> > > > > > > > The source code for the Scala wrappers can be
> > found
> > > > found in
> > > > > > >> > > > > > > > my
> > > > > > >> > > > repo:
> > > > > > >> > > > > > > >
> > > > > > >> > > > > > > >
> > http://github.com/NielsHoogeveen/Scala-Neo4j-utils
> > > > > > >> > > > > > > >
> > > > > > >> > > > > > > > Kind regards,
> > > > > > >> > > > > > > > Niels Hoogeveen
> > > > > > >> > > > > > > >
> > > > > > >> > > > > > > > > From: neubauer.peter at gmail.com
> > > > > > >> > > > > > > > > Date: Fri, 26 Mar 2010 17:25:01 +0100
> > > > > > >> > > > > > > > > To: user at lists.neo4j.org
> > > > > > >> > > > > > > > > Subject: Re: [Neo] meta meta classes
> > > > > > >> > > > > > > > >
> > > > > > >> > > > > > > > > Awesome Niels!
> > > > > > >> > > > > > > > >
> > > > > > >> > > > > > > > > maybe you could blog or document some cool
> > example
> > > > on
> > > > > > >> > > > > > > > > this?
> > > > > > >> > > > > > > > >
> > > > > > >> > > > > > > > > Cheers,
> > > > > > >> > > > > > > > >
> > > > > > >> > > > > > > > > /peter neubauer
> > > > > > >> > > > > > > > >
> > > > > > >> > > > > > > > > COO and Sales, Neo Technology
> > > > > > >> > > > > > > > >
> > > > > > >> > > > > > > > > GTalk:      neubauer.peter
> > > > > > >> > > > > > > > > Skype       peter.neubauer
> > > > > > >> > > > > > > > > Phone       +46 704 106975
> > > > > > >> > > > > > > > > LinkedIn   http://www.linkedin.com/in/neubauer
> > > > > > >> > > > > > > > > Twitter      http://twitter.com/peterneubauer
> > > > > > >> > > > > > > > >
> > > > > > >> > > > > > > > > http://www.neo4j.org             - Your high
> > > > performance
> > > > > > >> > graph
> > > > > > >> > > > > > database.
> > > > > > >> > > > > > > > > http://www.tinkerpop.com      - Processing for
> > > > > > >> > Internet-scale
> > > > > > >> > > > > > graphs.
> > > > > > >> > > > > > > > > http://www.thoughtmade.com - Scandinavias
> > coolest
> > > > > > >> > Bring-a-Thing
> > > > > > >> > > > > > party.
> > > > > > >> > > > > > > > >
> > > > > > >> > > > > > > > >
> > > > > > >> > > > > > > > >
> > > > > > >> > > > > > > > > On Fri, Mar 26, 2010 at 5:22 PM, Niels Hoogeveen
> > > > > > >> > > > > > > > > <pd_aficionado at hotmail.com> wrote:
> > > > > > >> > > > > > > > > >
> > > > > > >> > > > > > > > > > Using Scala, I was actually able to extend
> > > > > > >> > > > > > > > > > MetaModelThing
> > > > > > >> > to
> > > > > > >> > > > act as
> > > > > > >> > > > > > a
> > > > > > >> > > > > > > > Node and MetaModelClass to have shadowing
> > > > functionality for
> > > > > > >> > both
> > > > > > >> > > > > > > > MetaModelClasses and for MetaModelProperties,
> > without
> > > > > > >> > > > > > > > touching
> > > > > > >> > the
> > > > > > >> > > > > > original
> > > > > > >> > > > > > > > source code.
> > > > > > >> > > > > > > > > >
> > > > > > >> > > > > > > > > >> To: user at lists.neo4j.org
> > > > > > >> > > > > > > > > >> From: rick.bullotta at burningskysoftware.com
> > > > > > >> > > > > > > > > >> Date: Fri, 26 Mar 2010 14:29:03 +0000
> > > > > > >> > > > > > > > > >> Subject: Re: [Neo] meta meta classes
> > > > > > >> > > > > > > > > >>
> > > > > > >> > > > > > > > > >> Such are the joys and challenges of
> > frameworks
> > > > and
> > > > > > >> > > > abstractions.
> > > > > > >> > > > > > > >  Sometimes you do need to get "close to the metal"
> > > > though,
> > > > > > >> > > > > > > > to
> > > > > > >> > > > achieve
> > > > > > >> > > > > > > > specific functional and performance requirements.
> > > >  Thus the
> > > > > > >> > reason
> > > > > > >> > > > open
> > > > > > >> > > > > > > > source frameworks are awesome.  At least we can
> > change
> > > > and
> > > > > > >> > extend
> > > > > > >> > > > them
> > > > > > >> > > > > > more
> > > > > > >> > > > > > > > easily!
> > > > > > >> > > > > > > > > >>
> > > > > > >> > > > > > > > > >>
> > > > > > >> > > > > > > > > >>
> > > > > > >> > > > > > > > > >> -----Original Message-----
> > > > > > >> > > > > > > > > >> From: Niels Hoogeveen <
> > pd_aficionado at hotmail.com
> > > > >
> > > > > > >> > > > > > > > > >> Date: Fri, 26 Mar 2010 15:20:15
> > > > > > >> > > > > > > > > >> To: <user at lists.neo4j.org>
> > > > > > >> > > > > > > > > >> Subject: Re: [Neo] meta meta classes
> > > > > > >> > > > > > > > > >>
> > > > > > >> > > > > > > > > >>
> > > > > > >> > > > > > > > > >> Making MetaModelThing implement the Node
> > > > interface is
> > > > > > >> > actually
> > > > > > >> > > > > > > > orthogonal to the creation of Shadow objects.
> > Though
> > > > it does
> > > > > > >> > make
> > > > > > >> > > > code
> > > > > > >> > > > > > using
> > > > > > >> > > > > > > > classes as objects cleaner, and allows the node
> > > > property of
> > > > > > >> > > > > > MetaModelThing
> > > > > > >> > > > > > > > to become private.
> > > > > > >> > > > > > > > > >>
> > > > > > >> > > > > > > > > >> > From: pd_aficionado at hotmail.com
> > > > > > >> > > > > > > > > >> > To: user at lists.neo4j.org
> > > > > > >> > > > > > > > > >> > Date: Fri, 26 Mar 2010 14:38:08 +0100
> > > > > > >> > > > > > > > > >> > Subject: Re: [Neo] meta meta classes
> > > > > > >> > > > > > > > > >> >
> > > > > > >> > > > > > > > > >> >
> > > > > > >> > > > > > > > > >> > Or, and this probably the simplest
> > solution.
> > > > Let a
> > > > > > >> > > > > > MetaModelThing
> > > > > > >> > > > > > > > implement the Node interface. This allows a class
> > to
> > > > be an
> > > > > > >> > instance
> > > > > > >> > > > of
> > > > > > >> > > > > > > > another class and/or a SubType of another class.
> > > > > > >> > > > > > > > > >> >
> > > > > > >> > > > > > > > > >> >
> > > > > > >> > > > > > > > > >> > > From: pd_aficionado at hotmail.com
> > > > > > >> > > > > > > > > >> > > To: user at lists.neo4j.org
> > > > > > >> > > > > > > > > >> > > Date: Fri, 26 Mar 2010 14:20:07 +0100
> > > > > > >> > > > > > > > > >> > > Subject: Re: [Neo] meta meta classes
> > > > > > >> > > > > > > > > >> > >
> > > > > > >> > > > > > > > > >> > >
> > > > > > >> > > > > > > > > >> > > The class as object phenomenon is
> > actually
> > > > quite
> > > > > > >> > > > pervasive,
> > > > > > >> > > > > > and I
> > > > > > >> > > > > > > > think it is possible to have a generalized
> > solution
> > > > for it.
> > > > > > >> > > > > > > > > >> > >
> > > > > > >> > > > > > > > > >> > > After sending this email yesterday, I
> > came up
> > > > with
> > > > > > >> > > > > > > > > >> > > a
> > > > > > >> > > > slightly
> > > > > > >> > > > > > > > different solution.
> > > > > > >> > > > > > > > > >> > >
> > > > > > >> > > > > > > > > >> > > val taggable =
> > > > namespace.getMetaClass("taggable",
> > > > > > >> > true)
> > > > > > >> > > > > > > > > >> > >
> > > > > > >> > > > > > > > > >> > > val tagName =
> > > > > > >> > > > metaModelNamespace.getMetaProperty("tagname",
> > > > > > >> > > > > > true)
> > > > > > >> > > > > > > > > >> > > tagName.setCardinality(1)
> > > > > > >> > > > > > > > > >> > >
> > > > > > >> > > > > > > > > >> > > val metaTaggable =
> > > > > > >> > > > metaModelNamespace.getMetaClass("taggable",
> > > > > > >> > > > > > > > true)
> > > > > > >> > > > > > > > > >> > >
> > metaTaggable.getDirectProperties.add(tagName)
> > > > > > >> > > > > > > > > >> > >
> > > > metaTaggable.getDirectInstances.add(taggable.node)
> > > > > > >> > > > > > > > > >> > >
> > > > > > >> > > > > > > > > >> > > val body = namespace.getMetaClass("body",
> > > > true)
> > > > > > >> > > > > > > > > >> > > taggable.getDirectSubs.add(body)
> > > > > > >> > > > > > > > > >> > >
> > > > > > >> > > > > > > > > >> > > Instead of directly relating the class
> > "body"
> > > > to
> > > > > > >> > > > > > > > > >> > > the
> > > > > > >> > meta
> > > > > > >> > > > > > class
> > > > > > >> > > > > > > > "taggable", I create a shadow of the meta class
> > > > "taggable"
> > > > > > >> > > > > > > > with
> > > > > > >> > the
> > > > > > >> > > > > > same
> > > > > > >> > > > > > > > name in the namespace of the class "body", and
> > make
> > > > "body" a
> > > > > > >> > > > subclass
> > > > > > >> > > > > > of
> > > > > > >> > > > > > > > this shadow. That way the sub classing
> > relationship
> > > > remains
> > > > > > >> > nicely
> > > > > > >> > > > in
> > > > > > >> > > > > > one
> > > > > > >> > > > > > > > name space, while the instance relationship
> > transcends
> > > > name
> > > > > > >> > spaces,
> > > > > > >> > > > as
> > > > > > >> > > > > > it
> > > > > > >> > > > > > > > should.
> > > > > > >> > > > > > > > > >> > >
> > > > > > >> > > > > > > > > >> > > This could in principle be generalized by
> > > > adding a
> > > > > > >> > methods
> > > > > > >> > > > to
> > > > > > >> > > > > > > > MetaModelClass:
> > > > > > >> > > > > > > > > >> > >
> > > > > > >> > > > > > > > > >> > > public MetaModelClass
> > > > createShadowClass(NameSpace
> > > > > > >> > > > > > > > > >> > > ns){
> > > > > > >> > > > > > > > > >> > >
> > > > > > >> > > > > > > > > >> > >     MetaModelClass mc =
> > > > > > >> > ns.getMetaClass(this.getName(),
> > > > > > >> > > > true);
> > > > > > >> > > > > > > > > >> > >     this.getDirectInstances.add(mc.node);
> > > > > > >> > > > > > > > > >> > >     return mc;
> > > > > > >> > > > > > > > > >> > > }
> > > > > > >> > > > > > > > > >> > >
> > > > > > >> > > > > > > > > >> > > This returns a shadow of a given
> > > > MetaModelClass in
> > > > > > >> > > > > > > > > >> > > a
> > > > > > >> > given
> > > > > > >> > > > > > > > namespace and adds it as a an instance of this.
> > > > > > >> > > > > > > > > >> > >
> > > > > > >> > > > > > > > > >> > > It would of course be nicer to have a
> > method
> > > > with
> > > > > > >> > > > > > > > > >> > > the
> > > > > > >> > > > > > signature:
> > > > > > >> > > > > > > > > >> > >
> > > > > > >> > > > > > > > > >> > > public MetaModelClass getShadow(NameSpace
> > ns,
> > > > > > >> > > > > > > > > >> > > Boolean
> > > > > > >> > > > create)
> > > > > > >> > > > > > > > > >> > >
> > > > > > >> > > > > > > > > >> > > This is much more in line with the rest
> > of
> > > > the API,
> > > > > > >> > but
> > > > > > >> > > > > > requires a
> > > > > > >> > > > > > > > way to find out the namespace a given
> > MetaModelClass
> > > > is
> > > > > > >> > > > > > > > defined
> > > > > > >> > in.
> > > > > > >> > > > I
> > > > > > >> > > > > > didn't
> > > > > > >> > > > > > > > see a method getNamespace() for a given class, and
> > > > didn't
> > > > > > >> > > > > > > > delve
> > > > > > >> > > > deeply
> > > > > > >> > > > > > > > enough in the source code to figure out how to do
> > > > that.
> > > > > > >> > > > > > > > > >> > >
> > > > > > >> > > > > > > > > >> > > A similar approach can of course also be
> > > > applied to
> > > > > > >> > > > > > > > MetaModelProperties, by adding the following
> > method to
> > > > > > >> > > > MetaModelClass:
> > > > > > >> > > > > > > > > >> > >
> > > > > > >> > > > > > > > > >> > > public MetaModelProperty
> > > > > > >> > > > > > > > > >> > > createShadowProperty(NameSpace ns){
> > > > > > >> > > > > > > > > >> > >
> > > > > > >> > > > > > > > > >> > >
> > > > > > >> > > > > > > > > >> > >
> > > > > > >> > > > > > > > > >> > >     MetaModelProperty mp =
> > > > > > >> > > > > > > > > >> > > ns.getMetaProperty(this.getName(), true);
> > > > > > >> > > > > > > > > >> > >
> > > > > > >> > > > > > > > > >> > >
> > > > > > >> > > > > > > > > >> > > this.getDirectInstances.add(mp.node);
> > > > > > >> > > > > > > > > >> > >
> > > > > > >> > > > > > > > > >> > >     return mp;
> > > > > > >> > > > > > > > > >> > >
> > > > > > >> > > > > > > > > >> > > }
> > > > > > >> > > > > > > > > >> > >
> > > > > > >> > > > > > > > > >> > >
> > > > > > >> > > > > > > > > >> > > This way the underlying node of a
> > > > MetaModelProperty
> > > > > > >> > can
> > > > > > >> > > > > > properly
> > > > > > >> > > > > > > > be used as a class of its own and have properties,
> > > > > > >> > relationships,
> > > > > > >> > > > that
> > > > > > >> > > > > > can
> > > > > > >> > > > > > > > be further modeled in the meta layer. This e.q.
> > allows
> > > > to
> > > > > > >> > > > > > > > set a
> > > > > > >> > > > default
> > > > > > >> > > > > > > > rendering format for a given property class.
> > > > > > >> > > > > > > > > >> > >
> > > > > > >> > > > > > > > > >> > > I don't see a MetaModelRelationships,
> > which
> > > > is
> > > > > > >> > > > unfortunate,
> > > > > > >> > > > > > since
> > > > > > >> > > > > > > > that would allow the modeling of the properties of
> > a
> > > > > > >> > Relationship.
> > > > > > >> > > > > > > > > >> > >
> > > > > > >> > > > > > > > > >> > >
> > > > > > >> > > > > > > > > >> > > Kind regards,
> > > > > > >> > > > > > > > > >> > > Niels Hoogeveen
> > > > > > >> > > > > > > > > >> > >
> > > > > > >> > > > > > > > > >> > >
> > > > > > >> > > > > > > > > >> > > > Date: Fri, 26 Mar 2010 11:26:29 +0100
> > > > > > >> > > > > > > > > >> > > > From: mattias at neotechnology.com
> > > > > > >> > > > > > > > > >> > > > To: user at lists.neo4j.org
> > > > > > >> > > > > > > > > >> > > > Subject: Re: [Neo] meta meta classes
> > > > > > >> > > > > > > > > >> > > >
> > > > > > >> > > > > > > > > >> > > > That's an interresting case you've got
> > here
> > > > and
> > > > > > >> > > > > > > > > >> > > > it
> > > > > > >> > looks
> > > > > > >> > > > to
> > > > > > >> > > > > > me
> > > > > > >> > > > > > > > like it's
> > > > > > >> > > > > > > > > >> > > > probably the best way to model it in
> > the
> > > > meta
> > > > > > >> > > > > > > > > >> > > > model.
> > > > > > >> > > > > > > > > >> > > >
> > > > > > >> > > > > > > > > >> > > > 2010/3/25 Niels Hoogeveen <
> > > > > > >> > pd_aficionado at hotmail.com>
> > > > > > >> > > > > > > > > >> > > >
> > > > > > >> > > > > > > > > >> > > > >
> > > > > > >> > > > > > > > > >> > > > > For my application, I want to model
> > an
> > > > HTML
> > > > > > >> > template
> > > > > > >> > > > in
> > > > > > >> > > > > > Neo4J,
> > > > > > >> > > > > > > > using the
> > > > > > >> > > > > > > > > >> > > > > MetaModel api.
> > > > > > >> > > > > > > > > >> > > > >
> > > > > > >> > > > > > > > > >> > > > > So I started setting up
> > MetaModelClasses
> > > > for
> > > > > > >> > > > > > > > > >> > > > > the
> > > > > > >> > > > various
> > > > > > >> > > > > > HTML
> > > > > > >> > > > > > > > entities.
> > > > > > >> > > > > > > > > >> > > > >
> > > > > > >> > > > > > > > > >> > > > > e.g. (code in Scala)
> > > > > > >> > > > > > > > > >> > > > >
> > > > > > >> > > > > > > > > >> > > > > val classProp =
> > > > > > >> > > > > > > > > >> > > > > namespace.getMetaProperty("class",
> > > > > > >> > > > true)
> > > > > > >> > > > > > > > > >> > > > > val idProp =
> > > > > > >> > > > > > > > > >> > > > > namespace.getMetaProperty("id", true)
> > > > > > >> > > > > > > > > >> > > > > idProp.setCardinality(1)
> > > > > > >> > > > > > > > > >> > > > >
> > > > > > >> > > > > > > > > >> > > > >
> > > > > > >> > > > > > > > > >> > > > > val body =
> > namespace.getMetaClass("body",
> > > > true)
> > > > > > >> > > > > > > > > >> > > > > body.getDirectProperties(classProp)
> > > > > > >> > > > > > > > > >> > > > > body.getDirectProperties(idProp)
> > > > > > >> > > > > > > > > >> > > > >
> > > > > > >> > > > > > > > > >> > > > >
> > > > > > >> > > > > > > > > >> > > > > Which creates a class named "body"
> > which
> > > > has a
> > > > > > >> > > > property
> > > > > > >> > > > > > named
> > > > > > >> > > > > > > > "class"
> > > > > > >> > > > > > > > > >> > > > > without a cardinality restriction and
> > a
> > > > > > >> > > > > > > > > >> > > > > property
> > > > > > >> > named
> > > > > > >> > > > > > "id"
> > > > > > >> > > > > > > > with a
> > > > > > >> > > > > > > > > >> > > > > cardinality restriction of 1.
> > > > > > >> > > > > > > > > >> > > > >
> > > > > > >> > > > > > > > > >> > > > > Now I can create nodes of class
> > "body"
> > > > with
> > > > > > >> > various
> > > > > > >> > > > values
> > > > > > >> > > > > > for
> > > > > > >> > > > > > > > "class" and
> > > > > > >> > > > > > > > > >> > > > > for "id".
> > > > > > >> > > > > > > > > >> > > > >
> > > > > > >> > > > > > > > > >> > > > > So far so good, but now I want to say
> > > > that the
> > > > > > >> > class
> > > > > > >> > > > body
> > > > > > >> > > > > > has
> > > > > > >> > > > > > > > a property
> > > > > > >> > > > > > > > > >> > > > > "tagname" which should get the value
> > > > "body".
> > > > > > >> > > > > > > > > >> > > > >
> > > > > > >> > > > > > > > > >> > > > > The meta model itself doesn't allow
> > > > classes to
> > > > > > >> > have
> > > > > > >> > > > > > > > properties, but it
> > > > > > >> > > > > > > > > >> > > > > allows access to the underlying node
> > of
> > > > the
> > > > > > >> > > > > > > > > >> > > > > class.
> > > > > > >> > > > > > > > > >> > > > >
> > > > > > >> > > > > > > > > >> > > > > So I created a separate namespace for
> > the
> > > > meta
> > > > > > >> > meta
> > > > > > >> > > > > > classes
> > > > > > >> > > > > > > > and added the
> > > > > > >> > > > > > > > > >> > > > > following three definitions:
> > > > > > >> > > > > > > > > >> > > > >
> > > > > > >> > > > > > > > > >> > > > > val tagName =
> > > > > > >> > metaNamespace.getMetaProperty("tagname",
> > > > > > >> > > > > > true)
> > > > > > >> > > > > > > > > >> > > > > tagName.setCardinality(1)
> > > > > > >> > > > > > > > > >> > > > > val taggable =
> > > > > > >> > metaNamespace.getMetaClass("taggable",
> > > > > > >> > > > > > true)
> > > > > > >> > > > > > > > > >> > > > >
> > > > > > >> > > > > > > > > >> > > > > body.node.setProperty("tagname",
> > "body")
> > > > > > >> > > > > > > > > >> > > > >
> > > > > > >> > > > > > > > > >> > > > > This creates a property "tagname"
> > with
> > > > the
> > > > > > >> > > > > > > > > >> > > > > value
> > > > > > >> > > > "body"
> > > > > > >> > > > > > for
> > > > > > >> > > > > > > > the class named
> > > > > > >> > > > > > > > > >> > > > > "body".
> > > > > > >> > > > > > > > > >> > > > >
> > > > > > >> > > > > > > > > >> > > > > Now comes the more ambiguous part,
> > how to
> > > > link
> > > > > > >> > "body"
> > > > > > >> > > > to
> > > > > > >> > > > > > > > "taggable".
> > > > > > >> > > > > > > > > >> > > > >
> > > > > > >> > > > > > > > > >> > > > > I can make body.node an instance of
> > > > taggable.
> > > > > > >> > > > > > > > > >> > > > > Once
> > > > > > >> > > > there
> > > > > > >> > > > > > is a
> > > > > > >> > > > > > > > validator,
> > > > > > >> > > > > > > > > >> > > > > the existence of a "tagname" property
> > > > with
> > > > > > >> > cardinality
> > > > > > >> > > > 1
> > > > > > >> > > > > > > > should be checked,
> > > > > > >> > > > > > > > > >> > > > > so it is reasonable to make body.node
> > an
> > > > > > >> > > > > > > > > >> > > > > instance
> > > > > > >> > of
> > > > > > >> > > > > > taggable.
> > > > > > >> > > > > > > > > >> > > > >
> > > > > > >> > > > > > > > > >> > > > > At the same time the class body is
> > > > actually a
> > > > > > >> > subclass
> > > > > > >> > > > of
> > > > > > >> > > > > > > > taggable, so I am
> > > > > > >> > > > > > > > > >> > > > > inclined to define that as well.
> > > > > > >> > > > > > > > > >> > > > >
> > > > > > >> > > > > > > > > >> > > > > So I end up doing the following:
> > > > > > >> > > > > > > > > >> > > > >
> > > > > > >> > > > > > > > > >> > > > >
> > > > taggable.getDirectInstances.add(body.node)
> > > > > > >> > > > > > > > > >> > > > > taggable.getDirectSubs.add(body)
> > > > > > >> > > > > > > > > >> > > > >
> > > > > > >> > > > > > > > > >> > > > > I would like to know if this is the
> > > > correct
> > > > > > >> > approach
> > > > > > >> > > > to
> > > > > > >> > > > > > this
> > > > > > >> > > > > > > > situation, or
> > > > > > >> > > > > > > > > >> > > > > whether there are better
> > alternatives.
> > > > > > >> > > > > > > > > >> > > > >
> > > > > > >> > > > > > > > > >> > > > > Kind regards,
> > > > > > >> > > > > > > > > >> > > > > Niels Hoogeveen
> > > > > > >> > > > > > > > > >> > > > >
> > > > > > >> > > > > > > > > >> > > > >
> > > > > > >> > > > > > > > > >> > > > >
> > > > > > >> > > > > > > >
> > > > > > >> >
> > _________________________________________________________________
> > > > > > >> > > > > > > > > >> > > > > New Windows 7: Find the right PC for
> > you.
> > > > Learn
> > > > > > >> > more.
> > > > > > >> > > > > > > > > >> > > > > http://windows.microsoft.com/shop
> > > > > > >> > > > > > > > > >> > > > >
> > > > _______________________________________________
> > > > > > >> > > > > > > > > >> > > > > Neo mailing list
> > > > > > >> > > > > > > > > >> > > > > User at lists.neo4j.org
> > > > > > >> > > > > > > > > >> > > > >
> > > > https://lists.neo4j.org/mailman/listinfo/user
> > > > > > >> > > > > > > > > >> > > > >
> > > > > > >> > > > > > > > > >> > > >
> > > > > > >> > > > > > > > > >> > > >
> > > > > > >> > > > > > > > > >> > > >
> > > > > > >> > > > > > > > > >> > > > --
> > > > > > >> > > > > > > > > >> > > > Mattias Persson, [
> > > > mattias at neotechnology.com]
> > > > > > >> > > > > > > > > >> > > > Neo Technology, www.neotechnology.com
> > > > > > >> > > > > > > > > >> > > >
> > > > _______________________________________________
> > > > > > >> > > > > > > > > >> > > > Neo mailing list
> > > > > > >> > > > > > > > > >> > > > User at lists.neo4j.org
> > > > > > >> > > > > > > > > >> > > >
> > > > https://lists.neo4j.org/mailman/listinfo/user
> > > > > > >> > > > > > > > > >> > >
> > > > > > >> > > > > > > > > >> > >
> > > > > > >> > > > > >
> > > > _________________________________________________________________
> > > > > > >> > > > > > > > > >> > > Express yourself instantly with MSN
> > > > Messenger!
> > > > > > >> > Download
> > > > > > >> > > > today
> > > > > > >> > > > > > it's
> > > > > > >> > > > > > > > FREE!
> > > > > > >> > > > > > > > > >> > >
> > > > > > >> > > > > >
> > > > http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/
> > > > > > >> > > > > > > > > >> > >
> > > > _______________________________________________
> > > > > > >> > > > > > > > > >> > > Neo mailing list
> > > > > > >> > > > > > > > > >> > > User at lists.neo4j.org
> > > > > > >> > > > > > > > > >> > >
> > > > https://lists.neo4j.org/mailman/listinfo/user
> > > > > > >> > > > > > > > > >> >
> > > > > > >> > > > > > > > > >> >
> > > > > > >> > > > > >
> > > > _________________________________________________________________
> > > > > > >> > > > > > > > > >> > New Windows 7: Find the right PC for you.
> > Learn
> > > > more.
> > > > > > >> > > > > > > > > >> > http://windows.microsoft.com/shop
> > > > > > >> > > > > > > > > >> >
> > _______________________________________________
> > > > > > >> > > > > > > > > >> > Neo mailing list
> > > > > > >> > > > > > > > > >> > User at lists.neo4j.org
> > > > > > >> > > > > > > > > >> >
> > https://lists.neo4j.org/mailman/listinfo/user
> > > > > > >> > > > > > > > > >>
> > > > > > >> > > > > > > > > >>
> > > > > > >> > > >
> > > > _________________________________________________________________
> > > > > > >> > > > > > > > > >> New Windows 7: Find the right PC for you.
> > Learn
> > > > more.
> > > > > > >> > > > > > > > > >> http://windows.microsoft.com/shop
> > > > > > >> > > > > > > > > >>
> > _______________________________________________
> > > > > > >> > > > > > > > > >> Neo mailing list
> > > > > > >> > > > > > > > > >> User at lists.neo4j.org
> > > > > > >> > > > > > > > > >>
> > https://lists.neo4j.org/mailman/listinfo/user
> > > > > > >> > > > > > > > > >>
> > _______________________________________________
> > > > > > >> > > > > > > > > >> Neo mailing list
> > > > > > >> > > > > > > > > >> User at lists.neo4j.org
> > > > > > >> > > > > > > > > >>
> > https://lists.neo4j.org/mailman/listinfo/user
> > > > > > >> > > > > > > > > >
> > > > > > >> > > > > > > > > >
> > > > > > >> > > >
> > > > _________________________________________________________________
> > > > > > >> > > > > > > > > > New Windows 7: Find the right PC for you.
> > Learn
> > > > more.
> > > > > > >> > > > > > > > > > http://windows.microsoft.com/shop
> > > > > > >> > > > > > > > > >
> > _______________________________________________
> > > > > > >> > > > > > > > > > Neo mailing list
> > > > > > >> > > > > > > > > > User at lists.neo4j.org
> > > > > > >> > > > > > > > > > https://lists.neo4j.org/mailman/listinfo/user
> > > > > > >> > > > > > > > > >
> > > > > > >> > > > > > > > > _______________________________________________
> > > > > > >> > > > > > > > > Neo mailing list
> > > > > > >> > > > > > > > > User at lists.neo4j.org
> > > > > > >> > > > > > > > > https://lists.neo4j.org/mailman/listinfo/user
> > > > > > >> > > > > > > >
> > > > > > >> > > > > > > >
> > > > > > >> >
> > _________________________________________________________________
> > > > > > >> > > > > > > > Express yourself instantly with MSN Messenger!
> > > > Download
> > > > > > >> > > > > > > > today
> > > > > > >> > it's
> > > > > > >> > > > > > FREE!
> > > > > > >> > > > > > > >
> > > > > > >> >
> > http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/
> > > > > > >> > > > > > > > _______________________________________________
> > > > > > >> > > > > > > > Neo mailing list
> > > > > > >> > > > > > > > User at lists.neo4j.org
> > > > > > >> > > > > > > > https://lists.neo4j.org/mailman/listinfo/user
> > > > > > >> > > > > > > >
> > > > > > >> > > > > > >
> > > > > > >> > > > > > >
> > > > > > >> > > > > > >
> > > > > > >> > > > > > > --
> > > > > > >> > > > > > > Mattias Persson, [mattias at neotechnology.com]
> > > > > > >> > > > > > > Neo Technology, www.neotechnology.com
> > > > > > >> > > > > > > _______________________________________________
> > > > > > >> > > > > > > Neo mailing list
> > > > > > >> > > > > > > User at lists.neo4j.org
> > > > > > >> > > > > > > https://lists.neo4j.org/mailman/listinfo/user
> > > > > > >> > > > > >
> > > > > > >> > > > > >
> > > > _________________________________________________________________
> > > > > > >> > > > > > Express yourself instantly with MSN Messenger!
> > Download
> > > > today
> > > > > > >> > > > > > it's
> > > > > > >> > > > FREE!
> > > > > > >> > > > > >
> > > > http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/
> > > > > > >> > > > > > _______________________________________________
> > > > > > >> > > > > > Neo mailing list
> > > > > > >> > > > > > User at lists.neo4j.org
> > > > > > >> > > > > > https://lists.neo4j.org/mailman/listinfo/user
> > > > > > >> > > > > >
> > > > > > >> > > > >
> > > > > > >> > > > >
> > > > > > >> > > > >
> > > > > > >> > > > > --
> > > > > > >> > > > > Mattias Persson, [mattias at neotechnology.com]
> > > > > > >> > > > > Hacker, Neo Technology
> > > > > > >> > > > > www.neotechnology.com
> > > > > > >> > > > > _______________________________________________
> > > > > > >> > > > > Neo mailing list
> > > > > > >> > > > > User at lists.neo4j.org
> > > > > > >> > > > > https://lists.neo4j.org/mailman/listinfo/user
> > > > > > >> > > >
> > > > > > >> > > >
> > > > _________________________________________________________________
> > > > > > >> > > > Express yourself instantly with MSN Messenger! Download
> > today
> > > > it's
> > > > > > >> > FREE!
> > > > > > >> > > >
> > > > http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/
> > > > > > >> > > > _______________________________________________
> > > > > > >> > > > Neo mailing list
> > > > > > >> > > > User at lists.neo4j.org
> > > > > > >> > > > https://lists.neo4j.org/mailman/listinfo/user
> > > > > > >> > > >
> > > > > > >> > >
> > > > > > >> > >
> > > > > > >> > >
> > > > > > >> > > --
> > > > > > >> > > Mattias Persson, [mattias at neotechnology.com]
> > > > > > >> > > Hacker, Neo Technology
> > > > > > >> > > www.neotechnology.com
> > > > > > >> > > _______________________________________________
> > > > > > >> > > Neo mailing list
> > > > > > >> > > User at lists.neo4j.org
> > > > > > >> > > https://lists.neo4j.org/mailman/listinfo/user
> > > > > > >> >
> > > > > > >> >
> > _________________________________________________________________
> > > > > > >> > New Windows 7: Find the right PC for you. Learn more.
> > > > > > >> > http://windows.microsoft.com/shop
> > > > > > >> > _______________________________________________
> > > > > > >> > Neo mailing list
> > > > > > >> > User at lists.neo4j.org
> > > > > > >> > https://lists.neo4j.org/mailman/listinfo/user
> > > > > > >> >
> > > > > > >>
> > > > > > >>
> > > > > > >>
> > > > > > >> --
> > > > > > >> Mattias Persson, [mattias at neotechnology.com]
> > > > > > >> Hacker, Neo Technology
> > > > > > >> www.neotechnology.com
> > > > > > >> _______________________________________________
> > > > > > >> Neo mailing list
> > > > > > >> User at lists.neo4j.org
> > > > > > >> https://lists.neo4j.org/mailman/listinfo/user
> > > > > > >
> > > > > > > _________________________________________________________________
> > > > > > > Express yourself instantly with MSN Messenger! Download today
> > it's
> > > > FREE!
> > > > > > > http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/
> > > > > > > _______________________________________________
> > > > > > > Neo mailing list
> > > > > > > User at lists.neo4j.org
> > > > > > > https://lists.neo4j.org/mailman/listinfo/user
> > > > > > >
> > > > > >
> > > > > >
> > > > > > --
> > > > > > Mattias Persson, [mattias at neotechnology.com]
> > > > > > Hacker, Neo Technology
> > > > > > www.neotechnology.com
> > > > > > _______________________________________________
> > > > > > Neo mailing list
> > > > > > User at lists.neo4j.org
> > > > > > https://lists.neo4j.org/mailman/listinfo/user
> > > > >
> > > > > _________________________________________________________________
> > > > > Express yourself instantly with MSN Messenger! Download today it's
> > FREE!
> > > > > http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/
> > > > > _______________________________________________
> > > > > Neo mailing list
> > > > > User at lists.neo4j.org
> > > > > https://lists.neo4j.org/mailman/listinfo/user
> > > >
> > > > _________________________________________________________________
> > > > Express yourself instantly with MSN Messenger! Download today it's
> > FREE!
> > > > http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/
> > > > _______________________________________________
> > > > Neo mailing list
> > > > User at lists.neo4j.org
> > > > https://lists.neo4j.org/mailman/listinfo/user
> > > >
> > >
> > >
> > >
> > > --
> > > Mattias Persson, [mattias at neotechnology.com]
> > > Hacker, Neo Technology
> > > www.neotechnology.com
> > > _______________________________________________
> > > Neo mailing list
> > > User at lists.neo4j.org
> > > https://lists.neo4j.org/mailman/listinfo/user
> >
> > _________________________________________________________________
> > New Windows 7: Simplify what you do everyday. Find the right PC for you.
> > http://windows.microsoft.com/shop
> > _______________________________________________
> > Neo mailing list
> > User at lists.neo4j.org
> > https://lists.neo4j.org/mailman/listinfo/user
> >
> 
> 
> 
> -- 
> Mattias Persson, [mattias at neotechnology.com]
> Hacker, Neo Technology
> www.neotechnology.com
> _______________________________________________
> Neo mailing list
> User at lists.neo4j.org
> https://lists.neo4j.org/mailman/listinfo/user
 		 	   		  
_________________________________________________________________
New Windows 7: Find the right PC for you. Learn more.
http://windows.microsoft.com/shop


More information about the User mailing list