The _JPO element runs custom code to retrieve metadata and objects from the repository.
Using the _JPO element constructs a Java Program Object (JPO) and calls a method of the new object. For more information about Java Program Objects, refer to the Enovia documentation.
The method takes a matrix.db.Context object and a String array. The String array can be unpacked using the method matrix.db.JPO.unpackArgs, which returns a java.util.Map.
The unpacked map contains the following keys and values:
| Key | Type | Value |
|---|---|---|
connector_task
|
String | The name of the connector task. |
document_name
|
String | The document_name as specified by the DOCUMENT element. |
top_level_object_id
|
String | The ID of the current object being processed from the initial query. |
include_map
|
java.util.Map | The replacement values from previous _INCLUDE, _INCLUDE_CHILDREN or _JPO elements in the DocumentsXML hierarchy. |
relationship_id
|
String | The relationship ID if the current object is a relationship. |
object_id
|
String | The object ID if the current object is a business object. |
element_attributes
|
java.util.Map | Any additional attributes of the _JPO element. |
The method must return a java.util.Map. The map can define the following keys and values:
| Key | Type | Value |
|---|---|---|
metadata
|
java.util.Map
|
The field names and values. The map entry value is either a String or a java.util.List of String (for multi-value fields). |
object_ids
|
A |
The objects to process when child elements are added following the _JPO element in the DocumentsXML hierarchy. |
relationship_ids
|
A |
The relationships to process when child elements are added following the _JPO element in the DocumentsXML hierarchy. |
include_map
|
java.util.Map
|
New replacement values to override those from previous _INCLUDE, _INCLUDE_CHILDREN or _JPO elements in the DocumentsXML hierarchy. |
include_xpath
|
String
|
An XPath expression to include an XML fragment. The XML fragment replaces the child elements in the DocumentsXML hierarchy. |
| Attribute | Description |
|---|---|
node_name
|
The name of the metadata field created to contain the metadata retrieved by your custom code. If When If |
name_attr
|
The name of the XML metadata attribute to contain the name of metadata fields retrieved from the repository. |
jpo_name
|
The name of the Java Program Object (JPO) that is instantiated. The constructor of the JPO takes a |
jpo_method
|
The name of the method to call. The method must return a |
The following code could be used in the Java Program Object:
import matrix.db.*;
import java.util.*;
public class ${CLASSNAME}
{
// JPO constructor.
// The String[] argument will always be called by the
// connector with an empty array.
public ${CLASSNAME} (Context context, String[] args)
{
}
// JPO method.
// The String[] argument contains a java.util.Map
// Use matrix.db.JPO.unpackArgs to extract the Map.
// Return java.util.Map containing any metadata
// and IDs in the required structure.
public Map doSomething(Context context, String[] args)
{
Map input = (Map)JPO.unpackArgs(args);
Map output = new HashMap();
// This example just passes the input object or relationship
// ID straight through. As a result the method has no effect
// and the connector will continue processing the
// child elements of _JPO.
if (input.containsKey("object_id"))
output.put("object_ids", input.get("object_id"));
if (input.containsKey("relationship_id"))
output.put("relationship_ids", input.get("relationship_id"));
return output;
}
}
|
|