During the lifetime of the AssemblyLine, the TDI Server makes available a number of component Properties, related to the execution environment of the AssemblyLine, that we can query in your scripts: either from Script Components or Component Hooks. One property (lastCallStatus) can even be set.
You access the properties by using an AssemblyLine object, for example, a Connector and call its method get(property_name) to extract the property_name value; alternatively, use the put(property_name, property_value) method to set the property to the desired value. When setting properties, the property name or property value cannot be null; if one of them is null an Exception with an appropriate message will be thrown.
The set of properties available is as follows:
Property | Usage |
---|---|
numErrors | The number of errors occurred. |
numAdd | Total number of entries the AssemblyLine has added (performed by Connectors in AddOnly mode). |
numModify | Total number of entries the AssemblyLine has modified (performed by Connectors in Update mode). |
numDelete | Total number of entries the AssemblyLine has deleted (performed by Connectors in Delete mode). |
numGet | Total number of entries the AssemblyLine has retrieved (performed by Connectors in Iterator mode). |
numGetTries | Total number of times the AssemblyLine has attempted to retrieve an entry (performed by Connectors in Iterator mode). |
numGetClient | Total number of accepted Clients (available for Connectors in Server mode). |
numGetClientTries | Total number of times the AssemblyLine has attempted to get the next connected client (performed by Connectors in Server mode). |
numCallreply | Total number of Call/Reply operations the AssemblyLine has executed (performed by Connectors in CallReply mode). |
numLookup | Total number of Lookup operations the AssemblyLine has executed (performed by Connectors in Update/Delete/Lookup mode). |
numNoChange | Total number of entries the AssemblyLine processed but left unchanged. |
numSkipped | Total number of entries the AssemblyLine has skipped. |
numIgnored | Total number of entries the AssemblyLine has ignored (performed by Connectors in Update/Delta mode). |
lastCallStatus | Contains the status for the AssemblyLine execution. It is not just a read-only property and can be modified by you. The value of this property is “fail” or “success” dependant on the AssemblyLine execution. |
lastConn | The Conn entry from the last Connector operation. Before the first Connector operation, lastConn has a value of null. |
lastError | The last error as a Java object. |
hooksInvoked | A java.util.List of the names of the hooks invoked the last time the Component was invoked. The names are internal names. |
success | This property is set to true if the last operation was a success, and false otherwise. |
endOfData | True when the Iterator Component has reached End of Data, false otherwise. Changing this property has no effect. |
If an attempt is made to change a read-only property then an Exception with appropriate message will be thrown.
To illustrate the use of these Component Properties, let's assume we have a FileSystem Connector called FS, and some Script Components. The following JavaScript Code is in the "GetNext Successful" hook of FS:
if(work.getString("ID") == null) throw new java.lang.Exception("Missing ID"); //for the AssemblyLine Cycle to execute properly I need an ID, so throw an Exception
And this JavaScript Code is in the "DefaultOnError" hook of FS:
if(FS.get("lastError").getMessage().equals(“Missing ID”)) { //I could fix this by adding an ID which would help AssemblyLine execution work.setAttribute(“ID”, “SomeID”); //add the ID if(FS.get("fixErrors") == null) { var vector = new java.util.Vector(); vector.add(FS.get("lastError")); FS.put("fixErrors", vector);//save all fixed errors in my custom property } else {//I have previously fixed similar error var vector = FS.get("fixErrors"); vector.add(FS.get("lastError")); FS.put("fixErrors", vector); //save all fixed errors in my custom property } FS.put("lastCallStatus", "success"); } else {//I could not fix this error if(FS.get("notFixErrors") == null) { var vector = new java.util.Vector(); vector.add(FS.get("lastError")); FS.put("notFixErrors", vector); //save all not fixed errors in my custom property } else { var vector = FS.get("notFixErrors"); vector.add(FS.get("lastError")); FS.put("notFixErrors", vector); //save all not fixed errors in my custom property } FS.put("lastCallStatus", "fail"); }
Finally, in a Script Component, consider the following code:
main.logmsg("AL Cycle status: " + FS.get("lastCallStatus")); //print the AssemblyLine status for this AssemblyLine Cycle //I can also report all errors which have occurred // during the AssemblyLine Execution through my custom property, "vector"
Parent topic: Control execution with scripting