Skip to Content

MDM JAVA API: which is way for reads parend id

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???

Add a comment
10|10000 characters needed characters exceeded

Related questions

1 Answer

  • Best Answer
    Posted on Jan 15, 2009 at 04:13 PM

    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

    Add a comment
    10|10000 characters needed characters exceeded

    • 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.");

      }

      }

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.