Discussion:
How to return empty attribute created in AttributeMap Component panel (i.e. with no values)
(too old to reply)
Mihir Shah
2018-10-12 11:54:01 UTC
Permalink
Hi Eddie,

I have couple of questions on very basics of TDI. Would be glad if you help me understand.

In an AttributeMap component panel when a new attribute is created its default assgnement value is
work.test (assuming attribute created is test)

On dumping work entry --> task.dumpEntry(work);
I could not see test attribute in work entry.

On changing the assignment value of test attribute in AttributeMap component panel like
ret.value = system.newAttribute("test") and then running the AL

I could notice blank attribute test. However it doesn't matter as to what we pass as parameter for newAttribute method.
even if I would have returned like
ret.value = system.newAtribute("objectClass");

and then run the AL, I still see work entry with test attribute and with no values.

The newAttribute(String name) API will create an attribute with no values.

So to return an empty test attribute you first need to create a new attribute (that is not in work entry) And when you return this newAttribute its empty values
are merged with test attribute. Hence we get the test attribute with no values.

Is this the only way to get work attribute from AttributeMap component panel without any values and use it at later stage (in same AL)

I even tries something like
var oc = system.newAttribute("objectClass");
oc.addValue("top");

ret.value = oc;

On dumping work entry I see 'top' is value of test attribute and not of objectclass attribute. I also tried printing before dumping the entry like
task.logmsg(oc);

out still shows like

17:18:46,505 INFO - CTGDIS087I Iterating.
17:18:46,508 INFO - CTGDIS086I No iterator in AssemblyLine, will run single pass only.
17:18:46,509 INFO - CTGDIS092I Using runtime provided entry as working entry (first pass only).
17:18:46,510 INFO - "test": "person"
17:18:46,510 INFO - CTGDIS003I *** Start dumping Entry
17:18:46,516 INFO - Operation: generic
17:18:46,517 INFO - Entry attributes:
17:18:46,517 INFO - test (replace): 'person'
17:18:46,517 INFO - CTGDIS004I *** Finished dumping Entry
17:18:46,517 INFO - CTGDIS088I Finished iterating.
17:18:46,520 INFO - CTGDIS100I Printing the Connector statistics.
17:18:46,521 INFO - [AttributeMap] CTGDIS103I No statistics.
17:18:46,521 INFO - [EmptyScript] Calls: 1
17:18:46,521 INFO - [DumpWorkEntry] Calls: 1
17:18:46,521 INFO - CTGDIS104I Total: Not used.
17:18:46,521 INFO - CTGDIS101I Finished printing the Connector statistics.
17:18:46,522 INFO - CTGDIS080I Terminated successfully (0 errors).
Jason Williams
2018-10-12 17:30:17 UTC
Permalink
Post by Mihir Shah
Hi Eddie,
I have couple of questions on very basics of TDI. Would be glad if you help me understand.
In an AttributeMap component panel when a new attribute is created its default assgnement value is
work.test (assuming attribute created is test)
On dumping work entry --> task.dumpEntry(work);
I could not see test attribute in work entry.
On changing the assignment value of test attribute in AttributeMap component panel like
ret.value = system.newAttribute("test") and then running the AL
I could notice blank attribute test. However it doesn't matter as to what we pass as parameter for newAttribute method.
even if I would have returned like
ret.value = system.newAtribute("objectClass");
and then run the AL, I still see work entry with test attribute and with no values.
The newAttribute(String name) API will create an attribute with no values.
So to return an empty test attribute you first need to create a new attribute (that is not in work entry) And when you return this newAttribute its empty values
are merged with test attribute. Hence we get the test attribute with no values.
Is this the only way to get work attribute from AttributeMap component panel without any values and use it at later stage (in same AL)
I even tries something like
var oc = system.newAttribute("objectClass");
oc.addValue("top");
ret.value = oc;
On dumping work entry I see 'top' is value of test attribute and not of objectclass attribute. I also tried printing before dumping the entry like
task.logmsg(oc);
out still shows like
17:18:46,505 INFO - CTGDIS087I Iterating.
17:18:46,508 INFO - CTGDIS086I No iterator in AssemblyLine, will run single pass only.
17:18:46,509 INFO - CTGDIS092I Using runtime provided entry as working entry (first pass only).
17:18:46,510 INFO - "test": "person"
17:18:46,510 INFO - CTGDIS003I *** Start dumping Entry
17:18:46,516 INFO - Operation: generic
17:18:46,517 INFO - test (replace): 'person'
17:18:46,517 INFO - CTGDIS004I *** Finished dumping Entry
17:18:46,517 INFO - CTGDIS088I Finished iterating.
17:18:46,520 INFO - CTGDIS100I Printing the Connector statistics.
17:18:46,521 INFO - [AttributeMap] CTGDIS103I No statistics.
17:18:46,521 INFO - [EmptyScript] Calls: 1
17:18:46,521 INFO - [DumpWorkEntry] Calls: 1
17:18:46,521 INFO - CTGDIS104I Total: Not used.
17:18:46,521 INFO - CTGDIS101I Finished printing the Connector statistics.
17:18:46,522 INFO - CTGDIS080I Terminated successfully (0 errors).
Mihir,
Try changing the 'Null Behavior' of this 'Attribute Map' to 'Return Null Value'. You should then see 'test' when WORK is dumped.
17:29:47,274 INFO - Entry attributes:
17:29:47,275 INFO - test (replace):
Mihir Shah
2018-10-12 18:50:34 UTC
Permalink
Post by Jason Williams
Post by Mihir Shah
Hi Eddie,
I have couple of questions on very basics of TDI. Would be glad if you help me understand.
In an AttributeMap component panel when a new attribute is created its default assgnement value is
work.test (assuming attribute created is test)
On dumping work entry --> task.dumpEntry(work);
I could not see test attribute in work entry.
On changing the assignment value of test attribute in AttributeMap component panel like
ret.value = system.newAttribute("test") and then running the AL
I could notice blank attribute test. However it doesn't matter as to what we pass as parameter for newAttribute method.
even if I would have returned like
ret.value = system.newAtribute("objectClass");
and then run the AL, I still see work entry with test attribute and with no values.
The newAttribute(String name) API will create an attribute with no values.
So to return an empty test attribute you first need to create a new attribute (that is not in work entry) And when you return this newAttribute its empty values
are merged with test attribute. Hence we get the test attribute with no values.
Is this the only way to get work attribute from AttributeMap component panel without any values and use it at later stage (in same AL)
I even tries something like
var oc = system.newAttribute("objectClass");
oc.addValue("top");
ret.value = oc;
On dumping work entry I see 'top' is value of test attribute and not of objectclass attribute. I also tried printing before dumping the entry like
task.logmsg(oc);
out still shows like
17:18:46,505 INFO - CTGDIS087I Iterating.
17:18:46,508 INFO - CTGDIS086I No iterator in AssemblyLine, will run single pass only.
17:18:46,509 INFO - CTGDIS092I Using runtime provided entry as working entry (first pass only).
17:18:46,510 INFO - "test": "person"
17:18:46,510 INFO - CTGDIS003I *** Start dumping Entry
17:18:46,516 INFO - Operation: generic
17:18:46,517 INFO - test (replace): 'person'
17:18:46,517 INFO - CTGDIS004I *** Finished dumping Entry
17:18:46,517 INFO - CTGDIS088I Finished iterating.
17:18:46,520 INFO - CTGDIS100I Printing the Connector statistics.
17:18:46,521 INFO - [AttributeMap] CTGDIS103I No statistics.
17:18:46,521 INFO - [EmptyScript] Calls: 1
17:18:46,521 INFO - [DumpWorkEntry] Calls: 1
17:18:46,521 INFO - CTGDIS104I Total: Not used.
17:18:46,521 INFO - CTGDIS101I Finished printing the Connector statistics.
17:18:46,522 INFO - CTGDIS080I Terminated successfully (0 errors).
Mihir,
Try changing the 'Null Behavior' of this 'Attribute Map' to 'Return Null Value'. You should then see 'test' when WORK is dumped.
Thanks Jason it worked. I have one more query

When I try like (in assignment value)

var oc = system.newAttribute("objectClass");
oc.addValue("top");

ret.value = oc;

This merges the value 'top' to test attribute. Which means test attribute now has single value = 'top'

Is it possible to add attribute object 'objectClass' as value to work.test ?

Also I tried doing something like (in a script component placed below)
var tempAttr = oc.getAttribute("objectClass");
tempAttr.addValue("SomeValue");
task.logmsg(tempAttr);

(Please note variables used in above code is in continuation to code written just few lines above this)


I get error like
00:13:36,760 ERROR - [EmptyScript] CTGDIS809E handleException - cannot handle exception , script
com.ibm.jscript.InterpretException: Script interpreter error, line=9, col=10: Unknown member 'addValue' in Java class 'java.lang.String'
at com.ibm.jscript.types.JavaAccessObject.get(JavaAccessObject.java:756)
at com.ibm.jscript.types.FBSReferenceByName.getValue(FBSReferenceByName.java:93)
at com.ibm.jscript.ASTTree.InterpretResult.getFBSValue(InterpretResult.java:70)
at com.ibm.jscript.ASTTree.ASTCall.interpret(ASTCall.java:91)
at com.ibm.jscript.ASTTree.ASTProgram.interpret(ASTProgram.java:119)
at com.ibm.jscript.ASTTree.ASTProgram.interpretEx(ASTProgram.java:139)
at com.ibm.jscript.JSExpression._interpretExpression(JSExpression.java:435)
at com.ibm.jscript.JSExpression.interpretExpression(JSExpression.java:421)
at com.ibm.jscript.JSExpression.evaluateValue(JSExpression.java:251)
at com.ibm.jscript.JSExpression.evaluateValue(JSExpression.java:238)
at com.ibm.jscript.JSExpression.evaluateValue(JSExpression.java:241)
at com.ibm.jscript.JSInterpreter.interpret(JSInterpreter.java:57)
at com.ibm.di.script.ScriptEngine.interpret(ScriptEngine.java:940)
at com.ibm.di.script.ScriptEngine.interpret(ScriptEngine.java:925)
at com.ibm.di.server.ScriptComponent.add1(ScriptComponent.java:244)
at com.ibm.di.server.ScriptComponent.add(ScriptComponent.java:210)
at com.ibm.di.server.AssemblyLine.msExecuteNextConnector(AssemblyLine.java:3731)
at com.ibm.di.server.AssemblyLine.executeMainStep(AssemblyLine.java:3351)
at com.ibm.di.server.AssemblyLine.executeMainLoop(AssemblyLine.java:2960)
at com.ibm.di.server.AssemblyLine.executeMainLoop(AssemblyLine.java:2943)
at com.ibm.di.server.AssemblyLine.executeAL(AssemblyLine.java:2912)
at com.ibm.di.server.AssemblyLine.run(AssemblyLine.java:1311)
00:13:36,760 ERROR - CTGDIS266E Error in NextConnectorOperation. Exception occurred: com.ibm.jscript.InterpretException: Script interpreter error, line=9, col=10: Unknown member 'addValue' in Java class 'java.lang.String'
com.ibm.jscript.InterpretException: Script interpreter error, line=9, col=10: Unknown member 'addValue' in Java class 'java.lang.String'
at com.ibm.jscript.types.JavaAccessObject.get(JavaAccessObject.java:756)
at com.ibm.jscript.types.FBSReferenceByName.getValue(FBSReferenceByName.java:93)
at com.ibm.jscript.ASTTree.InterpretResult.getFBSValue(InterpretResult.java:70)
at com.ibm.jscript.ASTTree.ASTCall.interpret(ASTCall.java:91)
at com.ibm.jscript.ASTTree.ASTProgram.interpret(ASTProgram.java:119)
at com.ibm.jscript.ASTTree.ASTProgram.interpretEx(ASTProgram.java:139)
at com.ibm.jscript.JSExpression._interpretExpression(JSExpression.java:435)
at com.ibm.jscript.JSExpression.interpretExpression(JSExpression.java:421)
at com.ibm.jscript.JSExpression.evaluateValue(JSExpression.java:251)
at com.ibm.jscript.JSExpression.evaluateValue(JSExpression.java:238)
at com.ibm.jscript.JSExpression.evaluateValue(JSExpression.java:241)
at com.ibm.jscript.JSInterpreter.interpret(JSInterpreter.java:57)
at com.ibm.di.script.ScriptEngine.interpret(ScriptEngine.java:940)
at com.ibm.di.script.ScriptEngine.interpret(ScriptEngine.java:925)
at com.ibm.di.server.ScriptComponent.add1(ScriptComponent.java:244)
at com.ibm.di.server.ScriptComponent.add(ScriptComponent.java:210)
at com.ibm.di.server.AssemblyLine.msExecuteNextConnector(AssemblyLine.java:3731)
at com.ibm.di.server.AssemblyLine.executeMainStep(AssemblyLine.java:3351)
at com.ibm.di.server.AssemblyLine.executeMainLoop(AssemblyLine.java:2960)
at com.ibm.di.server.AssemblyLine.executeMainLoop(AssemblyLine.java:2943)
at com.ibm.di.server.AssemblyLine.executeAL(AssemblyLine.java:2912)
at com.ibm.di.server.AssemblyLine.run(AssemblyLine.java:1311)



So is it true that if we create a new attribute using system.newAttribute("someName"),
we cannot add values to it from other component placed down in AL ?
Eddie Hartman
2018-10-14 12:34:50 UTC
Permalink
Post by Mihir Shah
Hi Eddie,
I have couple of questions on very basics of TDI. Would be glad if you help me understand.
In an AttributeMap component panel when a new attribute is created its default assgnement value is
work.test (assuming attribute created is test)
On dumping work entry --> task.dumpEntry(work);
I could not see test attribute in work entry.
On changing the assignment value of test attribute in AttributeMap component panel like
ret.value = system.newAttribute("test") and then running the AL
I could notice blank attribute test. However it doesn't matter as to what we pass as parameter for newAttribute method.
even if I would have returned like
ret.value = system.newAtribute("objectClass");
and then run the AL, I still see work entry with test attribute and with no values.
The newAttribute(String name) API will create an attribute with no values.
So to return an empty test attribute you first need to create a new attribute (that is not in work entry) And when you return this newAttribute its empty values
are merged with test attribute. Hence we get the test attribute with no values.
Is this the only way to get work attribute from AttributeMap component panel without any values and use it at later stage (in same AL)
I even tries something like
var oc = system.newAttribute("objectClass");
oc.addValue("top");
ret.value = oc;
On dumping work entry I see 'top' is value of test attribute and not of objectclass attribute. I also tried printing before dumping the entry like
task.logmsg(oc);
out still shows like
17:18:46,505 INFO - CTGDIS087I Iterating.
17:18:46,508 INFO - CTGDIS086I No iterator in AssemblyLine, will run single pass only.
17:18:46,509 INFO - CTGDIS092I Using runtime provided entry as working entry (first pass only).
17:18:46,510 INFO - "test": "person"
17:18:46,510 INFO - CTGDIS003I *** Start dumping Entry
17:18:46,516 INFO - Operation: generic
17:18:46,517 INFO - test (replace): 'person'
17:18:46,517 INFO - CTGDIS004I *** Finished dumping Entry
17:18:46,517 INFO - CTGDIS088I Finished iterating.
17:18:46,520 INFO - CTGDIS100I Printing the Connector statistics.
17:18:46,521 INFO - [AttributeMap] CTGDIS103I No statistics.
17:18:46,521 INFO - [EmptyScript] Calls: 1
17:18:46,521 INFO - [DumpWorkEntry] Calls: 1
17:18:46,521 INFO - CTGDIS104I Total: Not used.
17:18:46,521 INFO - CTGDIS101I Finished printing the Connector statistics.
17:18:46,522 INFO - CTGDIS080I Terminated successfully (0 errors).
Let me chime in here :) If you want to add a value to a pre-existing work Attribute you can do that in the map assignment like this:

work.test.addValue("top"); // and value 'top' to existing attribute in work

or, in case you are unsure if 'test' exists already:

work.addAttributeValue("test", "top"); // creates 'test' if it's not already there

But it seems to me that want to add a new attribute to the work Entry with a name that is different from the one you specify in your map (i.e. 'test'). This you will have to do this explicity:

work.objectClass = "top"; // create (overwrite) 'objectClass' att and set value to "top"

Hope this helps!
/Eddie
Eddie Hartman
2018-10-14 20:40:11 UTC
Permalink
And to answer your question: yes you can add value to an Attribute you create elsewhere in the AL. The error you are getting is that add value() is undefined for a String object, so it looks like you have variables mixed up.

/Eddie

Loading...