On 26 April 2011 05:35, Christian Schuhegger <[email protected]>wrote:

> Hello list,
>

> Hi Christian,
good to see you here.


>
> To make a long story short: could somebody please give me a few pointers
> where I can start to investigate how Isis handles metadata?  How I can query
> the metadata?



IsisContext.getSpecificationLoader().allSpecifications() will return all the
ObjectSpecifications.  This is analagous (and wraps) java.lang.Class.  It
provides three collections: properties (of type OneToOneAssociations),
collections (of type OneToManyAssociation) and actions (ObjectAction).
These are all cf. java.lang.Method.  ObjectAction in turn has a collection
of ObjectActionParameters.

A good way to see the metadata is by running up the Restful viewer.
Alternatively the DnD viewer has a debug view (ctrl-shift-click) which lets
you see what's there.



and how I can "plug-in" another meta data provider?
>
>
I've been working on the documentation for this recently, but haven't yet
uploaded to the site.  So, to answer your question directly...

The key API you need to know about is FacetFactory, the purpose of which is
to identify "facets" of the metamodel.  An example of a Facet is noticing
the @Hidden annotation to declaratievly hide a class member, but they are
not restricted to just annotations; another one would be to notice the
hideXxx() method used to imperatively hide a class member.  In theory they
could get their information from anywhere, not just from the domain
objects.  As you can imagine, there are many, many FacetFactorys.

The main Facet API (Facet, FacetHolder, FacetFactory etc) is defined in
[oai.core:metamodel].  This also includes facets that are "well-known" by
viewers, eg the TitleFacet which is used to identify the title/label of an
object.  The implementations of the FacetFactorys live in
[oai.core:progmodel], which constitutes a library of FacetFactorys.

Not all facets are "well-known"; what makes them interesting is that they
implement HidingInteractionAdvisor, DisablingInteractionAdvisor or
ValidatingInteractionAdvisor.  Any facets that implement these interfaces
can veto any interactions ("can you see it? can you use it? can you do
it?").

There are a number of other variations of FacetFactory, such as
PropertyOrCollectionIdentifyingFacetFactory, which is called early on in
order to establish the "shape" of the domain object.  It's unlikely you
would ever provide a different implementation of these other variants.

FacetFactorys are collected together into the ProgrammingModel API, also
defined in [oai.core:metamodel].  The default implementation is
ProgrammingModelFacetsJava5, which resides in [oai.progmodels:dflt].  To
change the programming model, you can either

a) write your own implementation of this API (probably subclassing the
default) and then register in isis.properties using:
isis.reflector.facets=com.mycompany.isis.MyProgrammingModel

or

b) just register your new facets in isis.properties using:

isis.reflector.facets.include=com.mycompany.isis.MyFirstFacetFactory,com.mycompany.isis.MySecondFacetFactory

It's also possible to exclude facets using isis.reflector.facets.exclude.

~~~~~~~~~~
Here's a couple of ideas for you to get you started:
* NameFileFacetFactory - is in the trunk/examples, picks up names from a
properties file
* TitleAnnotationFacetFactory - pick up @Title as an annotation for facets
rather than the title() method
* StringLengthBetweenFacetFactory - pick up @StringLengthBetween(6,10) to
require strings are within specified length

(I intend to add these to the docs at some point as worked examples)



> Thanks,
> --
> Christian Schuhegger
> http://www.el-chef.de/
>


Cheers
Dan

Reply via email to