It's all about the answers!

Ask a question

References between different models


Inna Skarbovsky (1621) | asked Mar 11 '08, 3:39 a.m.
Hello all,
I was wondering if it is possible via some kind of API to store references between instances of elements in the logical model?

For example I have a logical model with EClass A with an attribute which references EClass B.
But this dependencies are the metadata dependencies.
Lets assume I have instances A1, A2 of EClass A in the repository - I would like A1 to have references to B1, B2 and A2 to have references to B2,B3 , and to be able to query those references.
Basically I need some kind of mechanism to query dependencies between instances of elements specified in the logical model , if such thing is possible.

3 answers



permanent link
Chris Daly (61651) | answered Mar 12 '08, 2:05 a.m.
JAZZ DEVELOPER
ishkin wrote:
Hello all,
I was wondering if it is possible via some kind of API to store
references between instances of elements in the logical model?

For example I have a logical model with EClass A with an attribute
which references EClass B.
But this dependencies are the metadata dependencies.
Lets assume I have instances A1, A2 of EClass A in the repository - I
would like A1 to have references to B1, B2 and A2 to have references
to B2,B3 , and to be able to query those references.
Basically I need some kind of mechanism to query dependencies between
instances of elements specified in the logical model , if such thing
is possible.


I'm not sure I fully understand your question, but here's a stab at it.
When you generate your storage model you also get query model classes.
These can be used with the IQueryService to construct queries. You
can definitely construct queries like "select all A instances where
reference A.b points to B1".

To make your references (or attributes) queryable you need to use the
"queryableProperty" annotation on them. The JazzBot tutorial has some
examples of constructing queries and using IQueryService. The wiki also
discusses the "queryableProperty" annotation:

https://jazz.net/wiki/bin/view/Main/JazzBotWalkthrough

--
Chris Daly
Jazz Component Development Team

permanent link
Inna Skarbovsky (1621) | answered Mar 13 '08, 4:56 a.m.
Hello Chris and thanks for replying!
Is is possible to create references and then query them for two different storage models?
For example storage model EClass A with attribute AttributeA referencing an EClass B from another storage model?
I know each component can have only one storage model, but it probably can extend another storage model, right?

Thanks again!

permanent link
Chris Daly (61651) | answered Mar 13 '08, 1:08 p.m.
JAZZ DEVELOPER
ishkin wrote:
Hello Chris and thanks for replying!
Is is possible to create references and then query them for two
different storage models?
For example storage model EClass A with attribute AttributeA
referencing an EClass B from another storage model?

Yes this is possible. In your query you can use one of the _eq methods
in ISingleItemQueryModel to get a predicate for this. So the query code
might look something like this:

AQueryModel aQueryModel = BaseAQueryModel.AQueryModel.ROOT;
IItemQuery aQuery = IItemQuery.FACTORY.newInstance(aQueryModel);

aQuery.filter(aQueryModel.b()._eq(bItemHandle));

Where bItemHandle is an IItemHandle for a B item. Note the comments in
the _eq() methods that a more efficient way of doing this is to use an
IItemHandleInputArg. In that case you would do something like this
instead of the previous line:

IItemHandleInputArg bArg = aQuery.newItemHandleArg();
aQuery.filter(aQueryModel.b()._eq(bArg));

At this point you would call IQueryService.queryItems(...) with aQuery.
If you are directly using bItemHandle then the second parameter to
queryItems would be IQueryService.EMPTY_PARAMETERS. If you are using
the IItemHandleInputArg then you would construct an array with bArg to
pass for that parameter.

I know each component can have only one storage model, but it probably
can extend another storage model, right?


I think by "extend" here what you mean is that you are referencing a
type from another model (not extending classes). You can do this, but
the current recommendation (discussed in the JazzBot tutorial) is to
reference the super-type in the Repository model (SimpleItem or
Auditable) from your model instead of directly referencing the other
model type. In any case, you will not have a problem constructing this
type of query because you essentially need an IItemHandle.
SimpleItem/Auditable are IItemHandles as are all of your concrete types
that extend them.

--
Chris Daly
Jazz Component Development Team

Your answer


Register or to post your answer.


Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.