Harvest

 View Only
  • 1.  Harvest CA SCM Get Package Group details using JHSDK

    Posted Dec 02, 2016 06:38 AM

    For automation, i need to list the package group details using the jhsdk, is there any native library available to get the details.

    I am able to get the package details using jhsdk but not able to list the package groups. Kindly suggest a way to achieve it.



  • 2.  Re: Harvest CA SCM Get Package Group details using JHSDK

    Posted Dec 02, 2016 11:08 AM

    There is a method GetBindPackageGroupObjId on a package which returns the object id of the associated package group, but I suspect this will only work for bound package groups, of which a package may only belong to one.  For unbound package groups, of which a package may belong to many, you are going to have to use a SQL query.  Depending upon what you want to achieve, the following two queries should help you get the package group names:

     

          SELECT g.pkggrpname FROM harpackagegroup g WHERE g.pkggrpobjid=123;

     

          SELECT g.pkggrpname FROM harpackagegroup g, harpkgsinpkggrp pig WHERE g.pkggrpobjid=pig.pkggrpobjid AND pig.packageobjid=456;

     

    Best regards,

     

          Robert



  • 3.  Re: Harvest CA SCM Get Package Group details using JHSDK

    Posted Dec 05, 2016 05:32 AM

    Thanks Robert. I am not able to get package group id(GetBindPackageGroupObjId) from the package details of JCaPackage. I can fetch the package group name using the query with hardcoded package group ID details.

     

    Is there any way to view the table structure of the database ? I need a query to retrieve all the package group and their associated packages for each state.



  • 4.  Re: Harvest CA SCM Get Package Group details using JHSDK
    Best Answer

    Posted Dec 05, 2016 06:35 AM

    The table structure used to be documented in the Administrator guide, but it now only contains a list of tables.  There is a KB article that details them here: Knowledge Base Articles  Unfortunately it lacks an entity relationship diagram to show which tables join to which tables.

     

    You need to be careful with package groups, as unbound package groups can span multiple states, and as I said previously, a package can belong to multiple unbound package groups.

     

    To get what you want, you need to start with the packages.  Each package is associated with one (and only one) state.  You can therefore get all the packages in a state quite easily by pinning down the STATEOBJID in the HARPACKAGE table.  You probably won't want to use ids, so you'll also need to use HARSTATE and HARENVIRONMENT to lookup the state and project respectively.  I gave you the other tables you need in the other two queries.  I'm not quite sure what you need, but the following query will print every package name and package group name combination for all the packages in a state (I'll let you figure out the GROUP BY etc).

     

         SELECT p.packagename, g.pkggrpname
         FROM harpackage p, harpackagegroup g, harpkgsinpkggrp pig,
         harstate s, harenvironment e
         WHERE p.stateobjid=s.stateobjid AND s.envobjid=e.envobjid
         AND g.pkggrpobjid=pig.pkggrpobjid AND pig.packageobjid=p.packageobjid
         AND s.statename='MyState' AND e.environmentname='MyProject'

     

    Best regards,

     

          Robert



  • 5.  Re: Harvest CA SCM Get Package Group details using JHSDK

    Posted Dec 07, 2016 03:56 AM

    Thanks Robert. I am able to get necessary details from the query. Also the db doc is very useful.