Highlighted
Rohan001 Respected Contributor.
Respected Contributor.
477 views

Finding complete Treasurus Term tree attached to a record

Jump to solution

Hi All,

Apologies if the question sounds a bit noob but I donn't see to find a solution.


I'm using HP RM 8.3 and trying to extract the complete Treasuras Term tree for a record using .NET SDK
I have used the 'broader' relation to move from leaf to parent of Keywords.


But as many leaf terms have multiple parents its difficult to get the exact parent which was used during attaching the record.

Is there any way to find this ? Or does the record manager does not support such implimentation ?

The following has been my code so far:

public static void GetTreeFromRecord(string uri)

{
     Database hpConnect = new Database();

     hpConnect.WorkgroupServerName = "SVR";
     hpConnect.Id = "DD";
     hpConnect.Connect();

     TrimMainObjectSearch objTrimSearch = new TrimMainObjectSearch(hpConnect, BaseObjectTypes.Record);
     TrimSearchClause objTrimClause = new TrimSearchClause(hpConnect, BaseObjectTypes.Record, SearchClauseIds.Uri);
     objTrimClause.SetCriteriaFromString(uri);
     objTrimSearch.AddFilterClause(objTrimClause);

     // Get Record
     foreach (Record record in objTrimSearch)
     {
          //Get Keywords
          foreach (RecordKeyword item in record.ChildKeywords)
          {
               //Get Parent Tree of Keyword
               TrimMainObjectSearch recKeyword = new TrimMainObjectSearch(hpConnect, BaseObjectTypes.Keyword);
               recKeyword.SetSearchString("broader:" + item.Keyword.Uri.UriAsString);

               string treeString = item.NameString;

               foreach (Keyword ite in recKeyword)
               {
                    GetParent(hpConnect, ite,ref treeString);
               }

               Console.WriteLine(treeString);

          }
     }
}

public static void GetParent(Database db,Keyword kWord, ref string kwTree)
{
     kwTree = kWord.NameString + " < " + kwTree;

     TrimMainObjectSearch recKeyword = new TrimMainObjectSearch(db, BaseObjectTypes.Keyword);
     recKeyword.SetSearchString("broader:" + kWord.Uri.UriAsString);

     if (recKeyword.Count > 0)
     {
          int count = 0;
          foreach (Keyword ite in recKeyword)
          {
               GetParent(db, ite, ref kwTree);
          }
     }

}

0 Likes
1 Solution

Accepted Solutions
JanMartin Outstanding Contributor.
Outstanding Contributor.

Re: Finding complete Treasurus Term tree attached to a record

Jump to solution

I've had a look at your implementation and I think I understand what you're trying to do.

Looking through the SDK, there is no way to tell which traversal was used to apply a term. Thesaurus terms are stored in the SQL table TSRECTERM, and the lack of data relating terms to their hierarchy seems to support this conclusion.

I think the only way you could get it working as you expect is to have a policy of creating new child keywords for each hierarchy.

1 Reply
JanMartin Outstanding Contributor.
Outstanding Contributor.

Re: Finding complete Treasurus Term tree attached to a record

Jump to solution

I've had a look at your implementation and I think I understand what you're trying to do.

Looking through the SDK, there is no way to tell which traversal was used to apply a term. Thesaurus terms are stored in the SQL table TSRECTERM, and the lack of data relating terms to their hierarchy seems to support this conclusion.

I think the only way you could get it working as you expect is to have a policy of creating new child keywords for each hierarchy.

The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.