[gold-users] Creating a Gold Custom Object
Scott Jackson
scottmo at adaptivecomputing.com
Mon Aug 22 16:11:59 MDT 2011
Ahh, OK, so Chi Hung and Jong Su and I looked into this further and we know what the issue is now.
goldsh is a low level prompt which simply takes a name-value pair format and serializes it into the XML Request, sends it over the wire, and then displays the response. The issue is that technically, the timestamps must be passed over the wire in epoch time format. So, technically what we are sending is:
<Request action="Create" actor="scottmo"><Object>TestSchedule</Object><Set name="TestTime">1293865200</Set><Set name="TestDescription">Testing</Set></Request></Body>
To do this, you should technically be building a goldsh request as follows:
gold> TestSchedule Create TestDate=1293865200 TestDescription=Testing
Successfully created 1 TestSchedule
Since the request is built up on the client side, which does not have access to the server which knows this field to be a timestamp, the goldsh interface cannot know unless you tell it that the field is a timestamp so that it can convert it to an epoch integer. Now, many of the examples in the documentation take advantage of a little trick I put into goldsh which is that if the name of the assignment ends in the word "Time", then we will take this as a timestamp and convert it. That is why if you had created the name of the attribute as TestTime instead of TestDate, things would have worked as expected, allowing you to enter time expressions instead of epoch times:
gold> Attribute Create Object=TestSchedule Name=TestTime DataType=TimeStamp
Successfully created 1 Attribute
gold> TestSchedule Create TestTime=2011-01-01 TestDescription=Testing
Successfully created 1 TestSchedule
Now, I have started considering the possibility of allowing a string format to be legal over the wire, but this means that I will have to check it on the server side and convert it to an epoch integer in the Gold::Proxy->prepareAssignments routine.
I tested this approach and it seems to work. I would just have to think about it some more to be sure it does not cause any problems or performance issues.
Alternatively, I could provide a syntax to decode the timestamp on the goldsh line:
TestSchedule Create TestDate=Timestamp(2011-01-01) TestDescription=Testing
or I could cheat a little more and do time conversions for all attributes that end in Date or Time.
If you are interested in a small local patch that would resolve this problem for you temporarily, you could patch your Proxy.pm with:
scottmo at mana:/software/gold-2.2$ diff -Nau lib/Gold/Proxy.pm /opt/gold-2.2/lib/Gold/Proxy.pm
--- lib/Gold/Proxy.pm 2011-07-26 13:32:33.911886963 -0600
+++ /opt/gold-2.2/lib/Gold/Proxy.pm 2011-08-22 15:44:39.581992562 -0600
@ -638,6 +634,12 @@
}
}
+ my $dataType = Gold::Cache->getAttributeProperty($object, $name, "DataType");
+ if ($dataType eq 'TimeStamp' && $value !~ /^\d+$/)
+ {
+ $value = toMFT($value);
+ }
+
# Add assignment to cooked request (after appropriate checking)
$self->addAssignment($request, \@cookedAssignments, $name, $value,
$op);
Thanks,
Scott
----- Original Message -----
From: "Scott Jackson" <scottmo at adaptivecomputing.com>
To: "Gold Users Mailing List" <gold-users at supercluster.org>
Sent: Monday, August 22, 2011 12:07:31 PM
Subject: Re: [gold-users] Creating a Gold Custom Object
I think you will need to use quotes.
TestSchedule Create TestDate="2011-01-01" TestDescription=Testing
Scott
----- Original Message -----
From: "Quang Ho" <quang.ho at hp.com>
To: gold-users at supercluster.org
Sent: Tuesday, August 16, 2011 12:18:52 AM
Subject: [gold-users] Creating a Gold Custom Object
Hi,
I tried to create a custom object as below via goldsh
Object Create Name=TestSchedule Description=”Test Schedule”
Attribute Create Object =TestSchedule Name=TestDate DataType=TimeStamp
Attribute Create Object =TestSchedule Name=TestDescription DataType=String
Action Create Object=TestSchedule Name=Create Display=True Description Create
Action Create Object=TestSchedule Name=Query Display=True Description Query
When I tried to populate data into it,
TestSchedule Create TestDate=2011-01-01 TestDescription=Testing
It came back with:
TestDate TestDescription
----------- -------------------
2011 Testing
Successfully created 1 TestSchedule
The problem is it does not record a full date in database, it only stores the year in the TestDate field.
To check the usage
<Request action="Create">
<Object>TestSchedule</Object>
[<Set name="TestDate" [op="Assign (Assign)"]>YYYY-MM-DD[ hh:mm:ss]|-infinity|infinity|now</Set>]
…..
[<Option name="ShowHidden">True|False (False)</Option>]
[<Option name="ShowUsage">True|False (False)</Option>]
</Request>
Not sure what I did wrong.
Thanks in advance.
_______________________________________________
gold-users mailing list
gold-users at supercluster.org
http://www.supercluster.org/mailman/listinfo/gold-users
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.supercluster.org/pipermail/gold-users/attachments/20110822/2452cd6f/attachment.html
More information about the gold-users
mailing list