Hi Ram�n !

thanks a lot for your patience !

there is a lot of what I want to discuss in detail,

but the very urgent - and may be simplest - questens are:

>  Method ObjectTypeSet ( Arg As ObjectType) As %Status
> {
>         set ..ObjectType = Arg
>         // here
>         // set ..TypeTree = Arg.TypeTree.Insert(Arg)
>         For i = 1:1:Arg.TypeTree.Count { Do ..TypeTree.Insert(
> Arg.TypeTree.GetAt( i ) ) }
>         Quit $$$OK
> }

how can I reset or initialize the Property "TypeTree" ?

I think I have to do this when .Insert adds Items -
but "set ..TypeTree = null" do not work - is not accepted by the compiler
as I would have done in other programming languages ?

And the second urgent question is:

I have 2 Classes with this Method - in the first one, the line
>         set i%ObjectType = Arg
works fine

in the second one the column in the table is still empty ?

Do I need to call ..%Save in the overloaded PropertySet Method ?
I hope not - because if there is an other triggered method ... !

So I can not imagine the difference ?

there is the code snippet:

        set new = ..%New()
        set new.DOCID = docid
        set new.Name = name
        set descr = r.GetDataByName("ATTROBJ_DESCRIPTION")
        set new.Description = descr
        &SQL(SELECT ID, DOCID INTO :tid, :tdocid FROM
GAS.ObjectReferenceType WHERE DOCID = :typeid)
        write !,"tid/tdocid: ", tid , "/", tdocid,!
        set newtype = ..%OpenId(tid)
        write "new type : ", newtype, !
        set new.ObjectReferenceType = newtype
        do new.%Save()
        write "new type : ", new.ObjectReferenceType, !
=> here it is still empty ?

        set new = ..%New()
        set new.DOCID = docid
        set new.Name = name
        set new.Description = descr
        &SQL(SELECT ID, DOCID INTO :tid, :tdocid FROM GAS.DocumentType WHERE
DOCID = :typeid)
        set newtype = ..%OpenId(tid)
        write " type : ", newtype, !
        set new.DocumentType = newtype
        do new.%Save()
=> this one works ???

thanks a lot - and I hope we can discuss the other features of cache also
later on ... !

brg
werne

"Ram�n Jim�nez" <rjimenez@@@cicla..com...do> schrieb im Newsbeitrag
news:[EMAIL PROTECTED]
> Werner :)
>
> > In cache I tried this:
> > Class XXX.ObjectType Extends ...
> > {
> >     Property ObjectType As ObjectType;
> >
> >     Property TypeTree As ObjectType [Collection = list];
> >
> >     Method ObjectTypeSet ( Arg As ObjectType) As %Status
> >     {
> >         set ..ObjectType = Arg
> >         set ..TypeTree = Arg.TypeTree.Insert(Arg)
> >         Quit $$$OK
> >     }
> > }
>
> Where I assume ObjectType is an object's single parent and TypeTree are
its
> children...
>
> Now the line "Set ..TypeTree = Arg.TypeTree.Insert(Arg)" won't precisely
do
> what you want - .Insert() doesn't return another list (but it would be
nice
> wouldn't it? So we could do chained inserts :)) I'll explain further below
> how to do this. But I still quite don't get "Arg.TypeTree.Insert(Arg)"
> According to my assumption above it reads like "Add an object to its own
> list of children". Surely I'm getting something wrong :(
>
> Something I *did* definitely do wrong is the following:
>
> > Do argParent.Parents.Insert( %this ) ... would be helpful if I had to
> > rebuild the tree bottom up I guess ?
>
> Yes - sorry - I misunderstood and thought you wanted multiple parents for
a
> child in this bit - I was wrong.
>
> > I want to buil it top down - and for this I take the "tree information"
> > stored in the parent propperty and add the parent at the end.
>
> So it is indeed as I assume above! Or is it? ...
>
> > But - sorry - I still do not know how to get the whole list from the
> parent
> > property into my TypeTree property,
> > .Insert will do it before or after copy.
>
> It seems you rather want to say "add all of the parent's children to my
> children", which in code would be
>
>  Method ObjectTypeSet ( Arg As ObjectType) As %Status
> {
>         set ..ObjectType = Arg
>         // here
>         // set ..TypeTree = Arg.TypeTree.Insert(Arg)
>         For i = 1:1:Arg.TypeTree.Count { Do ..TypeTree.Insert(
> Arg.TypeTree.GetAt( i ) ) }
>         Quit $$$OK
> }
>
> This copies all entries in Arg.TypeTree to the current object's TypeTree
> (the object to which Arg is being assigned as parent).
>
> If this is not exactly what you need (in terms of semantics), at least I
> hope it shows you how to do it right.
>
> > Pointer to same List or copy of List: I do not want to modify the
parent's
> > TreeList, only this one of the current object.
> > .%Save() does the rest - stores hopefully the list content for
persistent
> > objects and not only the pointer ?
>
> Yep - my mistake again. What I meant is you need to do as above, i.e. you
> can't just say
>
> Set ..TypeTree  = Arg..TypeTree
>
> not sure Cach� will handle that as we expect.
>
> > May be relations will be a solution, I need them for Object Relations
> anyway
> > (isn't "Property ObjectType As ObjectType;" also a kind of relation ?),
>
> It is, but it is not managed. Which is to say, you have to enforce
> referential integrity yourself. Using Cach�'s parent/children
relationship,
> it won't allow insertion of a child without a parent, and deleting a
parent
> deletes all children. It's like object composition. On the other hand,
> one/many is less stringent, more akin to aggregation. But in both cases
you
> get the advantage that by only setting one direction of the relationship
> Cach� sets the inverse between both objects.
>
> > but for the class tree itself I think its still a good idea to have the
> > "tree information" with each object...
>
> You would :) Cach� relationships project with an interface highly similar
to
> that of a list collection.
>
> > There is also an other design - or just understanding problem? - for me:
> > In Oracle I did a table for every Object with an entry for each Language
> > (NLSName) and an ID (outer join) back to the ObjectTable.
> > When I search in this table - I have a unique namespace - and I can
access
> > the right Object with its Type, the ClassTree  and so on...
>
> [snip]
>
> If I get it right...
>
> In Oracle you have a table for each value of ObjectType and you have a row
> for each language in each of these tables, so you get (languages)x(types)
> rows, right?
>
> Now in Cach� you have a class hierarchy for this and you redefine
properties
> in the subclasses to match expected types, .e.g.
>
> > Class ObjectType Extents NLSObject...
> > {
> >     Property ObjectType as ObjectType; // parent
>
> [snip]
>
> > Class Object Extents NLSOBject...
> > {
> >     Property ObjectType as ObjectType; // flat
> > }
>
> [snip]
>
> > // derived classes:
> > Class MyObjectType Extents NLSObject...
> > {
> >     Property ObjectType as MyObjectType; // parent
>
> [snip]
>
> > Class MyObject Extents NLSOBject...
> > {
> >     Property ObjectType as MyObjectType; // flat
> > }
>
> [snip]
>
> > But when I search for an Object by a name in a certain language,
> > who do I know what derived Type this Object is ???
>
> Well I reckon polymorphism takes care of this. Whenever you open a
specific
> Object its ObjectType reference will point to an instance of the
appropriate
> class. And in fact this happens even if you don't override properties; you
> can leave them to be of the superclass type and if you assign them an
> instance of a specific subclass then Cach� will just "know" when it opens
it
> back :) This is very cool because you don't have to perform conditionals
in
> the code, i.e. instead of
>
> Open object
> If object.ObjectType = Type1 Do This
> If object.ObjectType = Type2 Do That
>
> you have
>
> Open object
> Do object.ObjectType.Something()
>
> and Something() will have different implementations in each subclass, and
> depending on the instance you assigned to object.ObjectType on saving it
> will execute the correct implementation. Such is the beauty of objects :)
>
> (Of course, maybe the ObjectType class itself is not the right place to
> define this behavior, but I hope you get the idea)
>
> I hope this is all clear to you. The parent/child stuff has been discussed
> many times before and you can see past discussions at
> http://xiscsp.co.uk/ngp. Many of the newsgroup's *real* gurus are all gone
> to a conference this week, but many good people are left and then there's
me
> :) I'll keep trying my best, so please be patient if I mix up too many
> things!
>
> HTH,
>
> Ram�n
>
>



Reply via email to