Complex data for dimension based on collection.

6 views
Skip to first unread message

Andre Luis - Shift

unread,
Dec 10, 2009, 7:13:40 AM12/10/09
to InterSystems: DeepSee Community
Hi all,

I read on the documentation about the use of complex code to show a
dimension of a collection property.

In according of the documentation, we need to convert the collection
property to a space-separated list.

I have a case which it is not possible to convert the collection
property to a space-separated list, because the content of each part
of the list is name of person.

Is there a way to define other character to separate the list, instead
of space?

Lexi Hayden

unread,
Dec 10, 2009, 10:40:49 AM12/10/09
to InterSystems: DeepSee Community
You are referring to using the Words dimension type. The doc. suggests
this as one way to use a collection property; you can also use the
M.C.B. feature, which is documented in the same place.

The trick to using the Words approach is this: you define a custom
type that is based on Words but that uses the words separator that you
choose. Then in your Complex Code, iterate through your list and build
a string of the form list-item separator list-item separator etc.

The Words type (or your subtype) will pick apart this string and
convert each list item into a member of the dimension.

Beware limitations: Words strips out all non-alphanumeric characters.
Also there is of course the usual long-string limit.

Andre Luis - Shift

unread,
Dec 11, 2009, 5:28:55 AM12/11/09
to InterSystems: DeepSee Community
Thanks Lexi,
I have tried to use the M.C.B, also. In our case, the content in the
list is “Id” of other class and we want to show a property of that
class.
We had some doubts about what I should do to open the class and show
the property.
The samples on the documentation show the accessing of the content
direct in the list.
In our case, we would like to show the content of other class. So, do
you know if get the information of the list and open a table to show a
property is possible in the Each Fetch of the M.C.B?
> > of space?- Hide quoted text -
>
> - Show quoted text -

Lexi Hayden

unread,
Dec 11, 2009, 10:58:32 AM12/11/09
to InterSystems: DeepSee Community
You're welcome. ... The short answer is that we are talking about ways
to access one class from another, in Cache ObjectScript, and that
depends on what the classes really look like.

I'm afraid that I don't quite understand the details of your question.
Without disclosing anything proprietary, can you tell us about these
classes?

Class A is your base class, and class B is the other class.

What property in A refers to the other class? What is the definition
of this property?

What properties does class B have and how do you want to use them?

Andre Luis - Shift

unread,
Dec 14, 2009, 2:38:37 PM12/14/09
to InterSystems: DeepSee Community
Following your example, I have class A and class B.
Class A is a base class.
Class A has a collection property like the follow example:
Class A {
Property abc As list of %String;
}

Class B {
Property desc As %String;
}

The property abc of the A class has “Ids” which allow to access the
class B.

In this case, to access this information through cache I will use this
code
Set y = ##Class(A).%Open(“any value”)
For c=1:1:y.abc.Count(){
Set x = ##Class(B).%OpenId(y.abc.GetAt(c))
If $IsObject(x) {
Set desc = desc _ “ “_ x.Description
}Else{
Set desc = desc _ “ “ _“there is no value”
}
Quit desc
}
However, I don’t know how to do the same thing using M.C.B.
Now, did you get it?
> > > - Show quoted text -- Hide quoted text -

Lexi Hayden

unread,
Dec 14, 2009, 3:17:29 PM12/14/09
to InterSystems: DeepSee Community
Yes, thank you, the detail is perfect.

In your case, I think you can use this for Loop Coding:
For c=1:1:y.abc.Count() do

And use this for Each Fetch:
Set val=##(utilityclass).GetDesc(c)

Then the utility method returns a single Desc value each time it is
called:
Method GetDesc(I as %Integer) as %String
{
//open the object that has the given ID
//use 0 for 2nd arg of %OpenId to avoid concurrency locking
//also runs faster
Set x = ##Class(B).%OpenId(y.abc.GetAt(i),0)
If $IsObject(x) {
Set desc = x.Description
}Else{
Set desc = “there is no value”
}
Quit desc
}

TIP: Look at the generated INT to see where your M.C.B. settings get
placed. The doc. doesn't show this but I think it's helpful.

Andre Luis - Shift

unread,
Dec 15, 2009, 6:54:04 AM12/15/09
to InterSystems: DeepSee Community
Ok. Thank you
Reply all
Reply to author
Forward
0 new messages