When adding a record in a Lotus Notes database via Lotus Notes
Connector, how do you set a Time/Date data type field?
It appears, by default the field will be set as text string and not
Time/Date data type.
I tried to use java.util.Calendar and other similar date classes like
java.util.Date, etc but when I do that the Lotus Notes connector
throws an exception.
NotesException: Unknown or unsupported object type in Vector
at lotus.domino.local.Document.NreplaceItemValue(Native Method)
at lotus.domino.local.Document.replaceItemValue(Unknown Source)
at com.ibm.di.connector.DominoConnector.modDocument(Unknown Source)
at com.ibm.di.connector.DominoConnector.putEntry(Unknown Source)
at com.ibm.di.server.AssemblyLineComponent.add1(Unknown Source)
at com.ibm.di.server.AssemblyLineComponent.add(Unknown Source)
at com.ibm.di.server.AssemblyLine.msExecuteNextConnector(Unknown
Source)
at com.ibm.di.server.AssemblyLine.executeMainStep(Unknown Source)
at com.ibm.di.server.AssemblyLine.executeMainLoop(Unknown Source)
at com.ibm.di.server.AssemblyLine.executeMainLoop(Unknown Source)
at com.ibm.di.server.AssemblyLine.executeAL(Unknown Source)
at com.ibm.di.server.AssemblyLine.run(Unknown Source)
Connector, how do you set a Time/Date data type field?
It appears, by default the field will be set as text string and not
Time/Date data type.
I tried to use java.util.Calendar and other similar date classes like
java.util.Date, etc but when I do that the Lotus Notes connector
throws an exception.
NotesException: Unknown or unsupported object type in Vector
at lotus.domino.local.Document.
at lotus.domino.local.Document.
at com.ibm.di.connector.
at com.ibm.di.connector.
at com.ibm.di.server.
at com.ibm.di.server.
at com.ibm.di.server.
Source)
at com.ibm.di.server.
at com.ibm.di.server.
at com.ibm.di.server.
at com.ibm.di.server.
at com.ibm.di.server.
Solution :
Date: Sat, May 23 2009 3:30 am
From: Eddie Hartman
This is how you catch one like this:
The Connect and Read Next buttons in Input and Output Maps is
the key. Now if you are using Local Client connection to TDI, then
you are unable to use this feature [solution to follow -ed]. When you
discover data this way, you also get the Java class returned by
the Notes library. Then you know what kind of Java object to
create for the value to make this write operation work. In your
case it's lotus.domino.cso.DateTime.
Google lead me to this link:
http://publib.boulder.ibm.com/infocenter/domhelp/v8r0/topic/com.ibm.help.domino.designer85.doc/DOC/H_JAVA_NOTES_CLASSES_JAVA.html" target="_blank" style="color: rgb(61, 84, 89); http://publib.boulder.ibm.com/infocenter/domhelp/v8r0/topic/com.ibm.help.domino.designer85.doc/DOC/H_JAVA_NOTES_CLASSES_JAVA.html
The "A-Z Reference" link takes you to the DateTime class. When you
click through you find that there's a section on creation (like for
all Domino classes):
...
Creation
To create a new DateTime object, use createDateTime in Session.
...
So all you need is the Domino session, which your Notes Connector
is holding for you. You request it using the getDominoSession()
method.
It's documented in the TDI JavaDocs (Help > Low Level API) under the
DominoConnector class. Of course, how do you know which class to look
up? For example, "system" object is the "UserFunctions" class...
The answer here is to ask TDI -- but I'll get back to that in a
moment.
First off, once you know the object and how to make one, it's simple:
JavaScript Attribute Map for "EventTime" (unabridged version :):
-----------------------------------------------------------------------------------
// Get the com.ibm.di.connector.DominoConnector object
notesConnectorInterface = thisConnector.getConnector();
// Now get the session from it.
notesSession = notesConnectorInterface.getDominoSession();
// Grab the EventTime attribute value (must be java.util.Date)
// If not, then you need to convert it. system.parseDate()
// is handy for turning formatted Strings to Dates.
eventTime = work.getObject("EventTime");
// Now create the Notes DateTime object
dEventTIme = notesSession.createDateTime(eventTIme);
// Return this for the value of the mapping rule
ret.value = dEventTime;
Easy as spittin'.
Now getting back to figuring out what classes you're dealing
with:
Have an AL (I always call mine "1_Test" so it sorts first) and drop
in a Notes Iterator, using any session type. Then start it up in
Step / Paused mode, launching the debugger. Once you get control
back, step to the After GetNext Hook (either by right-clicking and
choosing "Run and break here", clicking the Breakpoint checkbox next
to it and press the "Continue" button, or just step you way down
and watch how TDI works under the covers :)
Once you are in the After GetNext Hook, then there is data in
conn. In the JavaScript commandline (the long input field next to
the scissor button) enter the following:
conn.getObject("EventTime").getClass()
and press Enter. Each time you press Enter, the snippet of script
you typed is send to the running TDI Server (even if you connect
to a remote one) and executed in the context of your AL. You can
examine and define variables, execute functions or manipulate data.
This lets you easily drive execution along the path you want it to
take. And it lets you exercise Java api's interactively. Very sweet :)
There is a video on the Debugger here:
http://www.tdi-users.org/twiki/bin/view/Integrator/LearningTDI#DebuggerVideo
Furthermore, you can use Document Selection parameter to
filter the documents returned. For example, if you have the UNID
of a particular Document of the type you want to examine, just
enter this search formula:
UNID=xxxxxxxx
With no quotes. You do have to quote text field filter values, and
surround dates with brackets. A little experemintation taught me
this. NOTE: if anyone out there has a link to docs or examples,
_please_ share.
Hope this helps!
-Eddie
From: Eddie Hartman
This is how you catch one like this:
The Connect and Read Next buttons in Input and Output Maps is
the key. Now if you are using Local Client connection to TDI, then
you are unable to use this feature [solution to follow -ed]. When you
discover data this way, you also get the Java class returned by
the Notes library. Then you know what kind of Java object to
create for the value to make this write operation work. In your
case it's lotus.domino.cso.DateTime.
Google lead me to this link:
http://publib.boulder.ibm.com/infocenter/domhelp/v8r0/topic/com.ibm.help.domino.designer85.doc/DOC/H_JAVA_NOTES_CLASSES_JAVA.html" target="_blank" style="color: rgb(61, 84, 89); http://publib.boulder.ibm.com/
The "A-Z Reference" link takes you to the DateTime class. When you
click through you find that there's a section on creation (like for
all Domino classes):
...
Creation
To create a new DateTime object, use createDateTime in Session.
...
So all you need is the Domino session, which your Notes Connector
is holding for you. You request it using the getDominoSession()
method.
It's documented in the TDI JavaDocs (Help > Low Level API) under the
DominoConnector class. Of course, how do you know which class to look
up? For example, "system" object is the "UserFunctions" class...
The answer here is to ask TDI -- but I'll get back to that in a
moment.
First off, once you know the object and how to make one, it's simple:
JavaScript Attribute Map for "EventTime" (unabridged version :):
------------------------------
// Get the com.ibm.di.connector.
notesConnectorInterface = thisConnector.getConnector();
// Now get the session from it.
notesSession = notesConnectorInterface.
// Grab the EventTime attribute value (must be java.util.Date)
// If not, then you need to convert it. system.parseDate()
// is handy for turning formatted Strings to Dates.
eventTime = work.getObject("EventTime");
// Now create the Notes DateTime object
dEventTIme = notesSession.createDateTime(
// Return this for the value of the mapping rule
ret.value = dEventTime;
Easy as spittin'.
Now getting back to figuring out what classes you're dealing
with:
Have an AL (I always call mine "1_Test" so it sorts first) and drop
in a Notes Iterator, using any session type. Then start it up in
Step / Paused mode, launching the debugger. Once you get control
back, step to the After GetNext Hook (either by right-clicking and
choosing "Run and break here", clicking the Breakpoint checkbox next
to it and press the "Continue" button, or just step you way down
and watch how TDI works under the covers :)
Once you are in the After GetNext Hook, then there is data in
conn. In the JavaScript commandline (the long input field next to
the scissor button) enter the following:
conn.getObject("EventTime").
and press Enter. Each time you press Enter, the snippet of script
you typed is send to the running TDI Server (even if you connect
to a remote one) and executed in the context of your AL. You can
examine and define variables, execute functions or manipulate data.
This lets you easily drive execution along the path you want it to
take. And it lets you exercise Java api's interactively. Very sweet :)
There is a video on the Debugger here:
http://www.tdi-users.org/
Furthermore, you can use Document Selection parameter to
filter the documents returned. For example, if you have the UNID
of a particular Document of the type you want to examine, just
enter this search formula:
UNID=xxxxxxxx
With no quotes. You do have to quote text field filter values, and
surround dates with brackets. A little experemintation taught me
this. NOTE: if anyone out there has a link to docs or examples,
_please_ share.
Hope this helps!
-Eddie
No comments:
Post a Comment