on 11-13-2008 6:29 AM
Hi ALL,
I have a requirement in which i have to create a taxonomy using MDM 5.5 SP05 JAVA API.
Can anyone tell me how that functionality can be achieved?
Thanks in Advance.
Rajat.
Thanks. I was able to work using the above piece of code.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Pavel,
I got what you have written bur can you provide me the sample code for exposing the hierarchy and taxonomy lookup on the portal for the user to selects his options.
Thanks.
Rajat.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
HI, Rajat.
For exposing hierarchy in WD view you need to use node with recursive children in the context and Tree/TreeNodeType UI elements in view layout.
For load hierarchy records you have to use RetrieveLimitedHierTreeCommand. You can load whole hierarchy (as I know, SP05 API have a bug - only first 1000 record can be loaded) or load hierarchy nodes on demand (using OnLoadChildren action of TreeNodeType element).
Refer to this example of loading child records:
// Context structure:
// Tree (model node, model class built from com.sap.mdm.data.Record interface)
// |-- Children (recursive child node repeating Tree node)
// |-- DisplayValue (string value attribute, TreeNodeType's text property bound here)
// |-- HasChildren (boolean value attribute, TreeNodeType's hasChildren property bound here)
// parentElem is element of node Tree or Children for which we must load child records, null for first level of hierarchy
private void fillNodeWithChildren(IPrivateHierarchySelectView.ITreeElement parentElem) {
// Determining RecordId of parent record and context node to which child records belong
RecordId parentRecordId = null;
if (parentElem != null) parentRecordId = parentElem.modelObject().getId();
IPrivateHierarchySelectView.ITreeNode parentNode =
parentElem == null
? wdContext.nodeTree()
: parentElem.nodeChildren();
// Loading children with RetrieveLimitedHierTreeCommand
try {
RetrieveLimitedHierTreeCommand retTreeCmd = new RetrieveLimitedHierTreeCommand(...); // use suitable constructor
if (parentRecordId != null) retTreeCmd.setRootNode(parentRecordId);
retTreeCmd.setResultDefinition(...); // don't forget set ResultDefinition
retTreeCmd.execute();
HierNode subRoot = retTreeCmd.getTree()
parentNode.invalidate();
// Processing loaded child records - add elements into parentNode
if (subRoot == null) return;
IPrivateHierarchySelectView.ITreeElement childElem;
HierNode childRecord;
HierNode[] children = subRoot.getChildren();
int count = children == null ? 0 : children.length;
for (int i = 0; i < count; i++) {
childRecord = children<i>;
childElem = parentNode.createTreeElement(childRecord);
childElem.setDisplayValue(childRecord.getDisplayValue());
childElem.setHasChildren(!childRecord.isLeaf());
parentNode.addElement(childElem);
}
if (parentElem != null) parentElem.setHasChildren(count > 0);
} catch (/* Some MDM Exceptions */) {}
}
Don't forget call fillNodeWithChildren(null) in wdDoInit for load first level of hierarchy.
Hi, Rajat.
What exacly you need to know? How to create taxonomy table in repository? How to insert/updates records in taxonomy table? How to make references to taxonomy table from other table?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Pavel,
My requirement is to create, insert and update taxonomy type record in MDM through Enterprise Portal using Webdynpro Java application for which I am using the MDM 5.5 SP05 JAVA API.
For performing the same i also will require to expose the taxonomy type lookup on the portal. How can that be done?
Thanks.
Rajat
Hi, Rajat.
Create taxonomy record the same way you create any other heirarchy record - with CreateRecordCommand. Then use CreateAttributeCommand for creating new taxonomy attributes (if need). Then bind attributes to newly created taxonomy record using CreateAttributeLinkCommand.
Use DeleteAttributeCommand/DeleteAttributeLinkCommand or ModifyAttributeCommand/ModifyAttributeLink commands for deleting or modifying taxonomy attributes and its' bindings to taxonomy records.
Taxonomy records itself can be modified like any other records - with ModifyRecordCommand.
About working with taxonomy lookups:
1. when loading records of main table make sure that FieldId of your taxonomy field is in the list of select fields of ResultDefinition and not forget to call setLoadAttributes(true) on it. Therefore taxonomy record and it's attribute values will be loaded together with record
2. use containsAttribute, getAttributeValue, setAttributeValue and others methods of Record interface for manipulating values of taxonomy attributes for a record
3. save changes of taxonomy attributes for a record using ModifyRecordCommand on this record
User | Count |
---|---|
86 | |
10 | |
10 | |
9 | |
6 | |
6 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.