ability to add another custom attribute to a property

146 views
Skip to first unread message

kevin furze

unread,
Jun 14, 2010, 6:09:42 AM6/14/10
to Caché, Ensemble, DeepSee
I have 2000+ properties that i must work with, each one is exposed
through XML etc but I need to have access to a custom attribute
associated with each property

example
Property revisionDate as %Date
( customLookupID="CatalogueItemSpecificationUpdate.RevisionDate" );

I then want to be able to access the customLookUpID of any property to
go to a help file to tell the user what this property means

Hopefully this makes sense,

can I do this within cache (currently v2009, but prepared to go to
v2010 if need be) and if so how do I access the attribute late at
programming time

kev

Sungung

unread,
Jun 15, 2010, 1:28:15 AM6/15/10
to Caché, Ensemble, DeepSee
Hi Kevin,

It seems to be property attribute belongs to datatype class itself. So
only way you can achieve is to create new datatype class which is
inherited from generic cache datatype, then define customs attribute.
Please see the below sample code with class method which can get
attribute value.

Class User.String Extends %Library.String
{
Parameter customId;
}

Class User.MySuper Extends %Persistent
{

Property sample As User.String(customId="sample.data");

ClassMethod getCustomId(prop As %String) As %String
{
set custId = ""
set dic = ##class(%Dictionary.ClassDefinition).%OpenId(..
%ClassName(1))
for i=1:1:dic.Properties.Count() {
if (dic.Properties.GetAt(i).Name = prop) {
set custId = dic.Properties.GetAt(i).Parameters.GetAt("customId")
quit
}
}
quit custId

}

}

Thanks, Sungung

kevin furze

unread,
Jun 15, 2010, 4:32:04 AM6/15/10
to Caché, Ensemble, DeepSee
thanks, will try this tonight and see how I get on.

kev

Eric

unread,
Jun 15, 2010, 11:57:34 AM6/15/10
to Caché, Ensemble, DeepSee

Kevin,

Another way is to define a PropertyClass. To see an example look at
%ZEN.Component.abstractPage which uses %ZEN.pageParameters as a
PropertyClass to make the ZENURL parameter available to all
properties.

The choice between defining a datatype or using a property class is a
design choice depending on on what you are trying to do. Both
approaches are valid.


Eric

kevin furze

unread,
Jun 15, 2010, 4:18:16 PM6/15/10
to Caché, Ensemble, DeepSee
Sungung
I've played tonight with the code, but its producing an error.

I've created two custom classes, 1st one is the extension to %String
to add the parameter customId

Class Custom.String Extends %Library.String
{
Parameter customId;
}

next I've extended %Persistant to automatically include the
getCustomId method to every class that inherits it

Class Custom.MySuper Extends %Persistent
{

ClassMethod getCustomId(prop As %String) As %String
{
set custId = ""
w !,..%ClassName(1) // tmp - prove its in the right class
set dic = ##class(%Dictionary.ClassDefinition).%OpenId(..
%ClassName(1))
for i=1:1:dic.Properties.Count() {
w !,dic.Properties.GetAt(i).Name // tmp - prove each name
is being checked
if dic.Properties.GetAt(i).Name = prop {
set custId =
dic.Properties.GetAt(i).Parameters.GetAt("customId")
quit
}
}
quit custId
}
}

finally, I created a new User.test with a few properties, each with a
different customId

Class User.test Extends Custom.MySuper
{
Property name As %String;
Property dateAdd As Custom.String(customId =
"productAddDate");
Property dateSend As Custom.String(customId =
"productSendDate");
Property dateReceived As Custom.String(customId =
"productReceiveDate");

ClassMethod insert()
{
&sql(insert into sqluser.test set
name='kevin',dateAdd='20-08-2009',dateSend='23-08-2009',dateReceived='29-08-2009')
}
}

I've successfully inserted data, so its clearly inheriting %Persistent
when I then call the getCustomId, it hesitates a long time before
giving up with an error

w ##class(User.test).getCustomId("sample")

User.test

for i=1:1:dic.Properties.Count() {
^
<INVALID OREF>zgetCustomId+5^User.test.1

if I zw, I get

%0CacheLock("User.test")=1
%ROWCOUNT=1
%ROWID=3
%objlasterror="0 > ¬ 0%LoadData+4^%Dictionary.ClassDefinition.
1:USER"
<Private variables>
prop="sample"
custId=""
dic=""
USER 3f2>

can you hlp and let me know where I'm going wrong
kev

Thomas Springer

unread,
Jun 15, 2010, 6:18:11 PM6/15/10
to intersystems...@googlegroups.com
Hi,

you should check the status after retrieving dic:

set dic =
##class(%Dictionary.ClassDefinition).%OpenId(..%ClassName(1),,.status)
write:($$$ISERR(status)) ##class(%SYSTEM.Status).GetErrorText(status),!

What is the error message?

If you see Error #5804 then User.test is locked and %OpenId() times out.
Check that the class isn't open in Cach� Studio with unsaved changes.

Hth,
Thomas

kevin furze schrieb:

Anil Mathew

unread,
Jun 16, 2010, 10:05:22 AM6/16/10
to an...@fiestahms.com, intersystems...@googlegroups.com
Hi All,
Found the answer to my problem, connecting using Vism.

Anil
Anil Mathew wrote:
> Hi All,
>
> Is there any way of accessing Routines written in Cache Object Script
> from C# directly?
>
> Thanks a bunch.
> Anil
>
>

Anil Mathew

unread,
Jun 16, 2010, 8:04:57 AM6/16/10
to intersystems...@googlegroups.com

Anil Mathew

unread,
Jun 20, 2010, 6:44:22 AM6/20/10
to Victor França, intersystems...@googlegroups.com
Hi Victor,
Try this out.
Steps to add VISM to C#.net(asp.net/C#.net) project.
 
step 1:Right click on Solution explorer of the project and select "Add Reference". It will display add reference window.
step 2 : Select "COM" Tab
step 3:  "COM" Tab  shows list of available controls in the system.
step 4: Select "VISM Active Control Module" then click OK Button.(After this step it will be available in your project reference).Now you can use in your code.
 
To available VISM Methods & Properties in your code.Fallow below steps.
step 1: open C#.net(.cs) page in which page you want to add
step 2 : Go to Top of the page
step 3 : import dll into your page.Example in C# using VISMLib; (where VISMLib is the corresponding reference class name for the VISM Active Control
Step4: After the 3rd step all VISM Methods & Properties available in C# Code.
 
Steps to Declare object  access functions & propertes of the VISM control

VisMClass

vsm = new VisMClass();// vsm is the object for VISM control.

vsm.MServer =

"";

vsm.MServer =

"CN_IPTCP:127.0.0.1[1972]:Your name space";//your server path & name space

vsm.NameSpace =

"your name space"; // your name space

vsm.PLIST =

"";

vsm.PDELIM =

"*";

vsm.VALUE =

""; string VBDATA = ""

vsm.P0 = VBDATA;

vsm.Code ="$$SUBROUTINE^MYROUTINE(P0)";

vsm.ExecFlag = 1;

 Regards
Anil


Victor França wrote:
Hi, Anil,
Can you send to me this Vism, to connect whtin CACHÉ



2010/6/16 Anil Mathew <an...@fiestahms.com>
--
InterSystems: Advanced software technologies for breakthrough applications

Caché 2010.1.2 released on May 29, 2010



--
Victor França

Victor França

unread,
Jun 19, 2010, 1:47:58 PM6/19/10
to intersystems...@googlegroups.com, an...@fiestahms.com
Hi, Anil,
Can you send to me this Vism, to connect whtin CACHÉ



2010/6/16 Anil Mathew <an...@fiestahms.com>
Hi All,
--
InterSystems: Advanced software technologies for breakthrough applications

Caché 2010.1.2 released on May 29, 2010



--
Victor França
Reply all
Reply to author
Forward
0 new messages