This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

How to get the last created release ?

Hi all,

I want to know if there is a command that i can get the last created release by PCMS api ?

i try this code as below but i don't know how to continue to get result faster:

PcmsObjStruct obj = { 0 };
obj.objType = PCMS_BASELINE;
int noUids = 0;
int *uids = NULL;

string product = "COH12";


if (PcmsQuery(conId, &obj, 0, &noUids, &uids) == PCMS_OK && noUids)
{
          for (int i = 0; i < noUids; i )
          {
               if (PcmsInitUid(conId, uids[i], PCMS_BASELINE, &obj) != PCMS_OK)
                continue;

                if (product.compare((_TCHAR*)obj.productId) == 0)
                {

                       printf( "%s:%s\n", (_TCHAR*)obj.objId, (_TCHAR*)obj.dateTime);

                }
          }

}

Please help.

Tags:

Parents
  • 0

    Hi,

    The first thing to try could be initial filter by the product value (as input to PcmsQuery), so you get only UIDs from interesting you product.

    Looking at docs (Developer’s API Reference PDF) that should be something like:

    obj.noAttrs = 1; obj.attrs = (PcmsObjAttrStruct *)PcmsEvntCalloc(sizeof(PcmsObjAttrStruct)); obj.attrs[0].attr = PCMS_ATTR_PRODUCT_ID; PcmsSvaSetVal(obj.attrs[0].value,"COH12",0); // then call PcmsQuery and you should not get other than baselines from COH12 ... // At the very end do not forget to free memory PcmsObjFree(&obj); PcmsEvntFree(uids);

    Theoretically the latest baseline should have the maximum UID, but that's not really guaranteed, so not reliable.

    One other thing you may try - using PcmsFullQuery instead of PcmsQuery, which should query object data in bulk, so faster than per each one in a loop. I see that docs state "The objType field in the PcmsObjStruct can currently only be PCMS_CHDOC", but I am not certain that is correct. So, it's worth trying.

    --
    Regards,
    Alex

    --
    Alex Shevchenko
    Sr Development Manager
    Although I work for OpenText, I am speaking for myself and not for OpenText.
    If you found this post useful, give it a “Like” or click on "Verify Answer" under the "More" button.

Reply
  • 0

    Hi,

    The first thing to try could be initial filter by the product value (as input to PcmsQuery), so you get only UIDs from interesting you product.

    Looking at docs (Developer’s API Reference PDF) that should be something like:

    obj.noAttrs = 1; obj.attrs = (PcmsObjAttrStruct *)PcmsEvntCalloc(sizeof(PcmsObjAttrStruct)); obj.attrs[0].attr = PCMS_ATTR_PRODUCT_ID; PcmsSvaSetVal(obj.attrs[0].value,"COH12",0); // then call PcmsQuery and you should not get other than baselines from COH12 ... // At the very end do not forget to free memory PcmsObjFree(&obj); PcmsEvntFree(uids);

    Theoretically the latest baseline should have the maximum UID, but that's not really guaranteed, so not reliable.

    One other thing you may try - using PcmsFullQuery instead of PcmsQuery, which should query object data in bulk, so faster than per each one in a loop. I see that docs state "The objType field in the PcmsObjStruct can currently only be PCMS_CHDOC", but I am not certain that is correct. So, it's worth trying.

    --
    Regards,
    Alex

    --
    Alex Shevchenko
    Sr Development Manager
    Although I work for OpenText, I am speaking for myself and not for OpenText.
    If you found this post useful, give it a “Like” or click on "Verify Answer" under the "More" button.

Children
  • 0 in reply to 

    Hi Alex

    Thank's for your answer.

    Your code help me a bit to get a minimum all releases about the product COH12.

    I will try to convert datetime for each release item and to be sorted in the end.

    I think it's can help.