Difference between revisions of "Higgins/ModelAPIs"
(→The model for attribute models) |
m (logo, category, left menu) |
||
Line 1: | Line 1: | ||
+ | {{#eclipseproject:technology.higgins}} | ||
+ | [[Image:Higgins_logo_76Wx100H.jpg|right]] | ||
=Problem= | =Problem= | ||
Today, IdAS defines a set of special interfaces for accessing a context's model elements. There are a number of problems with these interfaces: | Today, IdAS defines a set of special interfaces for accessing a context's model elements. There are a number of problems with these interfaces: | ||
Line 93: | Line 95: | ||
<TODO need to be able to specify min/max cardinality on each attributeType associated with a specific node model so we can preserve the ability to say "person nodes must have at least one surname attribute value, and may have a telephone number" without causing all instances of surname to be min=1 | <TODO need to be able to specify min/max cardinality on each attributeType associated with a specific node model so we can preserve the ability to say "person nodes must have at least one surname attribute value, and may have a telephone number" without causing all instances of surname to be min=1 | ||
+ | |||
+ | [[Category:Higgins IdAS]] |
Revision as of 14:59, 18 March 2008
{{#eclipseproject:technology.higgins}}
Contents
Problem
Today, IdAS defines a set of special interfaces for accessing a context's model elements. There are a number of problems with these interfaces:
- They are 'fixed' in nature. The only way to represent extra information about the model of context elements is to revise these interfaces. For example, say there's a need to associate an image with the attribute called “http://example.com/some/name/space#telephoneNumber” (this image might be used by a management UI). To make that association we need a new method like IAttributeModel.getManagementImage().
- Even if we felt like it's ok to revise the current I*Model interfaces, we do not know what kinds of information will need to be associated with the models of elements in a context. It may be the case that some people will have needs that we think are unworthy of revising the interfaces for. For example, say someone wants to associate an astrological symbol to each different attribute model. Does that mean we should add a new IAttributeModel.getAstrologicalSymbol()?
- There is no way to update a context's model. We have a need to be able to add models for new node types, attribute types and so-on. We also need to be able to change existing models (such as changing the cardinality of an attribute). Also, we may need to remove models.
- We cannot look up a model with partial information. For example, say I know there's an attribute with the word "telephoneNumber" in its ID, but I don't know the entire ID. It would be nice to be able to have a way to find what I need without enumerating through the entire set of attribute models.
Proposal
It may be better to move away from the existing special interfaces for the purpose of defining the model of elements, but instead simply re-use the existing interfaces that are used to access normal information within a Context (nodes and their attributes).
Following is a proposal which shows how these model nodes might look. To illustrate the proposal, we start by showing how an instance of a person looks (nothing new) and then examining the model nodes that govern instances of nodes and attributes:
A person
Example of an instance of a person node.
- Java type: some impl of INode. The context provider implements this class
- getNodeID() returns: the contextually unique ID for this person
- getAttributes() returns: typical attributes about this person (things like a homeAddress and phoneNumber)
- getType() returns: an identifier for this person's model node. assume it's called “http://example.com/some/name/space#Person”
- getTypeNode() returns: some impl of INode, assume it returns a PersonModel.class
A person's model
Now, say we look at the “person model” node we saw above (we got this either by calling INode.getTypeNode(), or INode.getType() followed by IContext.getNode(NodeID)), we see (NOTE: this node is a model element):
- Java type: some impl of INode – This is implemented by the context provider. We can assume it's a PersonModel.class.
- getNodeID() returns: the contextually unique ID for this node. This is the same value we got when calling INode.getType() on the person instance above, so in this case it would be “http://example.com/some/name/space#Person”.
- getAttributes() returns: the following and other attributes:
- http://www.eclipse.org/higgins/ontologies/2006/higgins#attributeTypes: This attribute has values which are pointers to various attribute model nodes. For example, a value might point at the “http://example.com/some/name/space#telephoneNumber” attribute model node, and another one might point at the “http://example.com/some/name/space#homeAddress” attribute model node.
- Note that the full list of valid attributes for this type of node must be discovered by looking at this list as well as the list of all this node model's supertypes. We can talk about possible shortcuts to get them all at once.
- http://www.eclipse.org/higgins/ontologies/2006/higgins#supertype: This attribute would point at another node model node. If person is derived from something like “http://example.com/some/name/space#Mammal” it would point at that. If person is at the top of it's node type hierarchy in this context, this attribute would point at a well-known node model node that defines INode in general (that would be called “http://www.eclipse.org/higgins/ontologies/2006/higgins#Node”)
- http://www.eclipse.org/higgins/ontologies/2006/higgins#attributeTypes: This attribute has values which are pointers to various attribute model nodes. For example, a value might point at the “http://example.com/some/name/space#telephoneNumber” attribute model node, and another one might point at the “http://example.com/some/name/space#homeAddress” attribute model node.
- getType() returns: the well-known identifier “http://www.eclipse.org/higgins/ontologies/2006/higgins#NodeModel”
- getTypeNode() returns: an implementation of “http://www.eclipse.org/higgins/ontologies/2006/higgins#NodeModel”. This object would be implemented by Higgins and thus would be the same for all context providers.
The "top" node model
Ok, now let's look at the instance of the node called “http://www.eclipse.org/higgins/ontologies/2006/higgins#Node”. This is simply the top-level model definition for all node model hierarchies. Thus it contains model definitions for things common to all nodes:
- Java type: an impl of INode (maybe we'll call it Node.class). This is implemented by Higgins and is always the same
- getNodeID() returns: the unique ID for this node. This is “http://www.eclipse.org/higgins/ontologies/2006/higgins#Node”
- getAttributes() returns: the following attributes:
- http://www.eclipse.org/higgins/ontologies/2006/higgins#attributeTypes: Only one value exists at this point, and that is “http://www.eclipse.org/higgins/ontologies/2006/higgins#NodeID”
- getType() returns: the well-known identifier “http://www.eclipse.org/higgins/ontologies/2006/higgins#NodeModel”
- getTypeNode() returns: an implementation of “http://www.eclipse.org/higgins/ontologies/2006/higgins#NodeModel”. This object would be implemented by Higgins and thus would be the same for all context providers.
The model for node models
What defines a node model node? This does:
- Java type: an impl of INode. Higgins will provide a default class called NodeModel.class, but a context provider is free to return its own (which may or may not be a subclass of the Higgins NodeModel.class), as long as it contains the “http://www.eclipse.org/higgins/ontologies/2006/higgins#attributeTypes” and its values mentioned below. A context provider is free to add more values to the “http://www.eclipse.org/higgins/ontologies/2006/higgins#attributeTypes” attribute.
- getNodeID() returns: the unique ID for this node. This is “http://www.eclipse.org/higgins/ontologies/2006/higgins#NodeModel”
- getAttributes() returns: the following attributes:
- http://www.eclipse.org/higgins/ontologies/2006/higgins#attributeTypes: These values exists here (note that a context provider may add to this set of values):
- “http://www.eclipse.org/higgins/ontologies/2006/higgins#attributeTypes”
- Note there's a subtlety here that may look confusing. The attribute is called attributeTypes and this value is also called attributeTypes. What we're saying is that this model (which defines what it means to be a node model – really a node model model to be precise) specifies that instances (like the model for person, or organization) can have an attribute called attributeTypes. We could rename this value to something like “http://www.eclipse.org/higgins/ontologies/2006/higgins#nodeAttributeTypes” if that would make it more clear.
- “http://www.eclipse.org/higgins/ontologies/2006/higgins#supertype”
- This says that instances (like the model for person, or organization) can have an attribute called supertype.
- “http://www.eclipse.org/higgins/ontologies/2006/higgins#attributeTypes”
- http://www.eclipse.org/higgins/ontologies/2006/higgins#attributeTypes: These values exists here (note that a context provider may add to this set of values):
- getType() returns: the well-known identifier “http://www.eclipse.org/higgins/ontologies/2006/higgins#ModelModel”
- getTypeNode() returns: an implementation of “http://www.eclipse.org/higgins/ontologies/2006/higgins#ModelModel”. This object would be implemented by Higgins and thus would be the same for all context providers.
- alternately, this could be null if we just tell people there is no such thing and teach them conceptually what it is.
The model for model elements
Finally, here's the model for model elements:
- Java type: an impl of INode called ModelModel. This is implemented by Higgins and is always the same.
- getNodeID() returns: the unique ID for this node. This is “http://www.eclipse.org/higgins/ontologies/2006/higgins#ModelModel”
- getAttributes() returns: the following attributes:
- http://www.eclipse.org/higgins/ontologies/2006/higgins#attributeTypes: This only has:
- “http://www.eclipse.org/higgins/ontologies/2006/higgins#attributeTypes”
- This says that instances (the nodes for NodeModel, attributeModel, and valueModel) have an attribute called attributeTypes
- “http://www.eclipse.org/higgins/ontologies/2006/higgins#attributeTypes”
- http://www.eclipse.org/higgins/ontologies/2006/higgins#attributeTypes: This only has:
- getType() returns: the well-known identifier “http://www.eclipse.org/higgins/ontologies/2006/higgins#ModelModel”
- getTypeNode() returns: an implementation of “http://www.eclipse.org/higgins/ontologies/2006/higgins#ModelModel”. This object would be implemented by Higgins and thus would be the same for all context providers.
Note the recursive nature of getType and getTypeNode above. We could instead return null or throw some well-known exception.
An attribute model
Now for fun, let's look at an attribute's model, and follow that. We'll take the example of “http://example.com/some/name/space#homeAddress”:
- Java type: an impl of INode. This is created by the context provider.
- getNodeID() returns: the unique ID for this node. In this case it's “http://example.com/some/name/space#homeAddress”
- getAttributes() returns: the following attributes:
- http://www.eclipse.org/higgins/ontologies/2006/higgins#valueTypes: Each value would be the identifier of a model node which represents a permitted data type for the value(s) of attribute instances that this attribute model defines. An example might be ** ** “http://www.w3.org/2001/XMLSchema#string ”, but could also point at any other value model.
- http://www.eclipse.org/higgins/ontologies/2006/higgins#maxCardinality: holds a value which represents the maximum values that can be placed on instances of attributes that this attribute model defines.
- http://www.eclipse.org/higgins/ontologies/2006/higgins#minCardinality: holds a value which represents the minimum values that can be placed on instances of attributes that this attribute model defines.
- http://www.eclipse.org/higgins/ontologies/2006/higgins#supertype: This attribute would point at another attribute model node. If homeAddress is derived from something like “http://example.com/some/name/space#postalAddress” it would point at that. If homeAddress is at the top of it's node type hierarchy in this context, this attribute would point at a well-known attribute model node that defines IAttributes in general (assume that would be called “http://www.eclipse.org/higgins/ontologies/2006/higgins#TopAttribute”)
- getType() returns: the well-known identifier “http://www.eclipse.org/higgins/ontologies/2006/higgins#AttributeModel”
- getTypeNode() returns: an implementation of “http://www.eclipse.org/higgins/ontologies/2006/higgins#AttributeModel”. This object would be implemented by Higgins and thus would be the same for all context providers.
The model for attribute models
And here's that the node identified by “http://www.eclipse.org/higgins/ontologies/2006/higgins#AttributeModel” looks like:
- Java type: an impl of INode. Higgins will provide a default class called AttributeModel.class, but a context provider is free to return its own (which may or may not be a subclass of the Higgins AttributeModel.class), as long as it contains the “http://www.eclipse.org/higgins/ontologies/2006/higgins#attributeTypes” and its values mentioned below. A context provider is free to add more values to the “http://www.eclipse.org/higgins/ontologies/2006/higgins#attributeTypes” attribute.
- getNodeID() returns: the unique ID for this node. This is http://www.eclipse.org/higgins/ontologies/2006/higgins#AttributeModel”
- getAttributes() returns: the following attributes:
- “http://www.eclipse.org/higgins/ontologies/2006/higgins#attributeTypes”: These values represent the types of attributes allowed on an attribute model node (note that a context provider may add to this set of values):
- getType() returns: the well-known identifier “http://www.eclipse.org/higgins/ontologies/2006/higgins#ModelModel”
- getTypeNode() returns: an implementation of “http://www.eclipse.org/higgins/ontologies/2006/higgins#ModelModel”. This object would be implemented by Higgins and thus would be the same for all context providers.
Then of course we have value models. Again from the bottom-up, here's a node that describes a value type called <TODO: finish this>
<TODO need to be able to specify min/max cardinality on each attributeType associated with a specific node model so we can preserve the ability to say "person nodes must have at least one surname attribute value, and may have a telephone number" without causing all instances of surname to be min=1