on 01-15-2009 4:05 PM
Hi MDM guru,
I work with Hierarchy table and use MDM Java Api.
Question:
For each node Which is the way for reads parent id???
In the RetrieveLimitedHierTreeCommand when you execute the getTree() method you get a HierNode object. This object is the entire tree returned. You can use the getParent() method to get the HierNode object of the parent, then you can use the getId() method.
-Greg
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Greg,
thanks for you help.
The problem is:
I use RetrieveLimitedHierTreeCommand in follow mode:
RetrieveLimitedHierTreeCommand cmd = new RetrieveLimitedHierTreeCommand(cntrl.getConnection());
cmd.setSession(cntrl.getUserSession());
cmd.setSearch(search);
cmd.setResultDefinition(resultDefinition);
if(rootNodeRecordID != null) {
cmd.setRootNode(rootNodeRecordID);
}
try {
cmd.execute();
} catch (CommandException e) {
throw new IllegalArgumentException(e.getMessage());
}
return cmd.getTree().getParent();
I have a node (cmd.getTree) but getParent is NULL.
This for me is clear.
But if i have this tree:
root
|-----A
| __ |---A1
| __ |---A2
| _____ |---A21
|-----B
| __ |---B1
| __ |---B2
|_____ |---B21
If I use RetrieveLimitedHierTreeCommand for search B2 I have this result:
cmd.getTree()= B2 [HierNode object]
cmd.getTree().getParent() = [NULL]
I think about the correct result is B or no?
This is a API error or no? I
Thanks Greg,
I resolve with this class:
static public MdmObjectKey getParentMdmKey(MdmPlugIntf plug, RepositorySchema schema, Search search, ResultDefinition resultDefinition, RecordId child) {
MdmPlug plugInst = (MdmPlug)plug;
ControlIntf cntrl = plugInst.getControl();
TableProperties table = schema.getTable(resultDefinition.getTable());
switch(table.getType()) {
case TableProperties.HIERARCHY:
case TableProperties.TAXONOMY:
RetrieveHierAncestorsCommand cmd = new RetrieveHierAncestorsCommand(cntrl.getConnection());
cmd.setSession(cntrl.getUserSession());
cmd.setChildNode(child);
cmd.setResultDefinition(resultDefinition);
try {
cmd.execute();
} catch (CommandException e) {
throw new IllegalArgumentException(e.getMessage());
}
Record[] item=cmd.getAncestors().getRecords();
MdmObjectKey mdmKey = new MdmObjectKey();
if (item!=null && item.length>0){
RecordId resultValue=new RecordId(item[0].getId());
for (int j=0;j<item.length-1;j++){
resultValue=item[j].getId();
}
mdmKey.setRecordId(new Integer(resultValue.getIdValue()));
}
return mdmKey;
default:
throw new IllegalArgumentException("This method only works with Taxonomy and Hierarchy tables.");
}
}
User | Count |
---|---|
94 | |
11 | |
11 | |
10 | |
9 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.