Topic
  • 20 replies
  • Latest Post - ‏2017-04-26T09:05:23Z by Mike.Scharnow
sreenivasj
sreenivasj
8 Posts

Pinned topic Change synergy Query command for extracting attachment content

‏2013-10-11T07:19:34Z |

Hi,

Could any one help me with, letting me know on how to use the change synergy command in linux shell environment, for getting the content of the attachment of a CR. This is required as part of automating the build process, I have in my organization.

The scenario is that, when ever a CR is in 'Implemented' state the build should get initiated. Few of the inputs needed by the build_automation shell script is in one of the CR field named: 'attachment' which has a readme file attached to it. This field has DB type= child, and Web Type=CCM_RELATION. I have seen the normal attributes of type: string, popup the value when used in a query. In this case, how can I get the attachments' content (readme file) and save it? Normally I start a synergy session and set CCM_ADDR to the right address, and use commands such as:   ccm query "cvtype='problem' and crstatus='Implemented' " to get see all Implemented CRs. I am expecting a similar command, for getting the value of the attachment too.

 

Thanks,

Sreenivas J.

  • Mike.Scharnow
    Mike.Scharnow
    81 Posts

    Re: Change synergy Query command for extracting attachment content

    ‏2013-10-11T08:07:57Z  

    Hi Sreenivas J.

    Attachments are stored in Synergy object versions which are related to the "problem" object versions.

    provided you already have the concerned problem_number, e.g. 12345, you can get these object versions using the query:

    ccm query "is_attachment_of(cr('12345')) and attachment_name='readme.txt'"

    If this query returns at least one attachment, you can query for the "content" of the first found attachment using the statement

    source_value=`ccm attr -s source @1`

    Now, attachments are usually, but as far as I know not always, stored in object versions of type binary. This gives you 2 possibilities: Either the result of the previous command gives you the direct content of the attachment, but for binary objects you will get a result that looks like the following

    <path to synergy database>/st_root/cache/source/#<number>/<number>

    In this case, this result is the full path of a filename which contains the content of the attachment. To be sure, you can write a statement that checks whether the content represents a filename, e.g. with

    if (-f $source_value) then...

    So, with this filename you can use a command like

    head -1 $source_value

    to get the first line of the readme file (or use cat or grep or whatever you need)

    If there is no such file, the content is already stored in $source_value.

    Hope this helps,

    Mike

  • sreenivasj
    sreenivasj
    8 Posts

    Re: Change synergy Query command for extracting attachment content

    ‏2013-10-22T14:49:16Z  

    Hi Mike,

    Thank you. This helps.

    I would need your assistance in one more area:

    In the customised CR life cycle dialog, I have an attribute named: 'ChildCR' (Label == Child CR, DB type == child, Web Type == CCM_RELATION), with the option: 'Allow creation of associated Objects and Association/Discaasociation of Objects'.  This attricute is created with and intention to initiate a child CR from existing CR (from existing dialog).

    Can I kow, how we can use the query command to initaite creation of a child CR, while working on an existing CR ? This query needs to be used as part of the automation (shell script) which will avoid, adding manual entries in the child  CR).

    Thanks and regards,

    Sreenivas.

     

     

  • Mike.Scharnow
    Mike.Scharnow
    81 Posts

    Re: Change synergy Query command for extracting attachment content

    ‏2013-10-22T15:07:49Z  

    Hi Mike,

    Thank you. This helps.

    I would need your assistance in one more area:

    In the customised CR life cycle dialog, I have an attribute named: 'ChildCR' (Label == Child CR, DB type == child, Web Type == CCM_RELATION), with the option: 'Allow creation of associated Objects and Association/Discaasociation of Objects'.  This attricute is created with and intention to initiate a child CR from existing CR (from existing dialog).

    Can I kow, how we can use the query command to initaite creation of a child CR, while working on an existing CR ? This query needs to be used as part of the automation (shell script) which will avoid, adding manual entries in the child  CR).

    Thanks and regards,

    Sreenivas.

     

     

    I'm sorry, I did not understand your goal. What shall the user do, what shall the shell script do, what shall the user not do, what shall the script prevent and why?

     

    The "query" command is for querying, i.e. getting information from the system, not for creating stuff. There are "create" and "relate" command, though. And the "relate" function has a "-show" mode as well (check the CLI help or ask, if you have questions)

  • sreenivasj
    sreenivasj
    8 Posts

    Re: Change synergy Query command for extracting attachment content

    ‏2013-10-22T15:33:21Z  

    I'm sorry, I did not understand your goal. What shall the user do, what shall the shell script do, what shall the user not do, what shall the script prevent and why?

     

    The "query" command is for querying, i.e. getting information from the system, not for creating stuff. There are "create" and "relate" command, though. And the "relate" function has a "-show" mode as well (check the CLI help or ask, if you have questions)

    Sorry for the confusion.

    I would like to know, whether I can give values to the attribute of the above type (DB type == child, Web Type == CCM_RELATION, with the option: 'Allow creation of associated Objects and Association/Discaasociation of Objects'), using the CLI commands available for Change? So that, I can get a new Child patch creation window.

    I have attached the screenshots of the manual process of using this attribute. As per the screenshot, my aim is: I would like initiate the dialog (Create Child patch) second screenshot, in the file, without clicking on: 'Create Child patch' - as seen in the first screenshot. 

    Please let me know, if this makes bit more clear.

    Regards,
    Sreenivas.

  • Mike.Scharnow
    Mike.Scharnow
    81 Posts

    Re: Change synergy Query command for extracting attachment content

    ‏2013-10-22T16:08:28Z  

    Sorry for the confusion.

    I would like to know, whether I can give values to the attribute of the above type (DB type == child, Web Type == CCM_RELATION, with the option: 'Allow creation of associated Objects and Association/Discaasociation of Objects'), using the CLI commands available for Change? So that, I can get a new Child patch creation window.

    I have attached the screenshots of the manual process of using this attribute. As per the screenshot, my aim is: I would like initiate the dialog (Create Child patch) second screenshot, in the file, without clicking on: 'Create Child patch' - as seen in the first screenshot. 

    Please let me know, if this makes bit more clear.

    Regards,
    Sreenivas.

    Well, yes, that's possible. The question would be how to do it in the most effective way.

    First question is "when should the child patch be created?" If it is e.g. directly after the parent cr has been created, you might want to write a post submit trigger (1). If it is when the user pushes a button (perhaps with the label "Create a child patch"), you could create some html code and post it onto your "show" form (2). If you want it to be done in the background, perhaps periodically all 5 minutes, you would write a cron job (3).

    Next question is "how do you want to program this?"

    For (1) refer to the example triggers which have been provided with the Change installation. Triggers can be programmed in Perl, Rhino or Jython. I usually use Perl. The Trigger and Perl APIs can be seen on the help pages of the admin interface of Change

    For (2) I personally would also write a perl script as a CGI script and change the jetty webserver so that CGI requests are handled by the perl interpreter. There is some information on some IBM technical bulletins (google should help you here). There is the Perl API and the Web Services API

    For (3) you can write a sh script and are free which API you use. You could use the Synergy API, (using the commands ccm create, ccm attr -create, ccm relate) but people rarely do this, because it is rather "low level" and you would have to ensure yourself that you create all needed attributes, give them the correct types, deal with the correct filling of the transition log and so on. Rather you should use a Change API which is a defined interface for manipulating and creating Change requests.

  • sreenivasj
    sreenivasj
    8 Posts

    Re: Change synergy Query command for extracting attachment content

    ‏2013-10-23T06:59:12Z  

    Well, yes, that's possible. The question would be how to do it in the most effective way.

    First question is "when should the child patch be created?" If it is e.g. directly after the parent cr has been created, you might want to write a post submit trigger (1). If it is when the user pushes a button (perhaps with the label "Create a child patch"), you could create some html code and post it onto your "show" form (2). If you want it to be done in the background, perhaps periodically all 5 minutes, you would write a cron job (3).

    Next question is "how do you want to program this?"

    For (1) refer to the example triggers which have been provided with the Change installation. Triggers can be programmed in Perl, Rhino or Jython. I usually use Perl. The Trigger and Perl APIs can be seen on the help pages of the admin interface of Change

    For (2) I personally would also write a perl script as a CGI script and change the jetty webserver so that CGI requests are handled by the perl interpreter. There is some information on some IBM technical bulletins (google should help you here). There is the Perl API and the Web Services API

    For (3) you can write a sh script and are free which API you use. You could use the Synergy API, (using the commands ccm create, ccm attr -create, ccm relate) but people rarely do this, because it is rather "low level" and you would have to ensure yourself that you create all needed attributes, give them the correct types, deal with the correct filling of the transition log and so on. Rather you should use a Change API which is a defined interface for manipulating and creating Change requests.

    Thank you, Mike.

    This helps in proceeding further on what I need to do.

    Sreenivas.

  • mahesh12345
    mahesh12345
    8 Posts

    Re: Change synergy Query command for extracting attachment content

    ‏2013-10-25T13:07:29Z  

    Thank you, Mike.

    This helps in proceeding further on what I need to do.

    Sreenivas.

    Hi Mike,

    Could you please provide an example of point3 (can write a sh script and are free which API you use).

    Say i want to create a Child CR, (using commands ccm create or relevat command).

     

    Regards,

    Sreenivas.

  • yuvraj_mane
    yuvraj_mane
    7 Posts

    Re: Change synergy Query command for extracting attachment content

    ‏2017-04-11T13:25:02Z  

    How to add document file to CR using CLI

  • Mike.Scharnow
    Mike.Scharnow
    81 Posts

    Re: Change synergy Query command for extracting attachment content

    ‏2017-04-11T14:03:32Z  

    How to add document file to CR using CLI

    There is no CLI for Change, only for Synergy. For Change, you would usually create a short Perl script that calls the function CreateAttachmentObject (see Perl API help file for details and examples).

     

    If you really need to use the CLI of Synergy and cannot use Perl, you have to mimic the behaviour of the Change function. But that's not so easy and not documented, so you have to reverse engineer it. You could examine an existing problem and attachment object and use the commands "ccm relate -show", "ccm attr -list" and "ccm attr -show" to find out which relations have to be created, how the attachment objects are to be named and how to enter the content of the existing file into the database.

  • yuvraj_mane
    yuvraj_mane
    7 Posts

    Re: Change synergy Query command for extracting attachment content

    ‏2017-04-12T15:04:34Z  

    There is no CLI for Change, only for Synergy. For Change, you would usually create a short Perl script that calls the function CreateAttachmentObject (see Perl API help file for details and examples).

     

    If you really need to use the CLI of Synergy and cannot use Perl, you have to mimic the behaviour of the Change function. But that's not so easy and not documented, so you have to reverse engineer it. You could examine an existing problem and attachment object and use the commands "ccm relate -show", "ccm attr -list" and "ccm attr -show" to find out which relations have to be created, how the attachment objects are to be named and how to enter the content of the existing file into the database.

    Thank you for reply,

      I am using the following  sample Perl script which will download an attachment using cvid.

    I am new in using perl script I downloaded the Activeperl package while I am running the following perl script getting error of csapi module not found.

    basically i have questions from where i have to download perl csapi module  so i can keep that in lib folder of perl and how to run the following script 

    or is it required to run following using Run the script with ratlperl

    i used this link for reference    http://www-01.ibm.com/support/docview.wss?uid=swg21663076

     Please help in run following perl script with also provide the details of environment i need to run and step to follow

     

    use ChangeSynergy::csapi; 
    my $csapi = new ChangeSynergy::csapi(); 
    eval 

    $csapi->setUpConnection("http://GBCHMLP201UDAT.railad.com:8400" );
     my $aUser = $csapi->Login("yuvraj11", "abc@21", "developer", "/data/V71/ATSS");
     my $data = $csapi->DatabaseGetObject($aUser, "167931"); open(OUTPUT, ">Dummy.txt"); 
    print(OUTPUT $data->getResponseByteData()); 
    close(OUTPUT); }; 
    if ($@) { 
    print $@; } 

  • Mike.Scharnow
    Mike.Scharnow
    81 Posts

    Re: Change synergy Query command for extracting attachment content

    ‏2017-04-12T15:25:12Z  

    Thank you for reply,

      I am using the following  sample Perl script which will download an attachment using cvid.

    I am new in using perl script I downloaded the Activeperl package while I am running the following perl script getting error of csapi module not found.

    basically i have questions from where i have to download perl csapi module  so i can keep that in lib folder of perl and how to run the following script 

    or is it required to run following using Run the script with ratlperl

    i used this link for reference    http://www-01.ibm.com/support/docview.wss?uid=swg21663076

     Please help in run following perl script with also provide the details of environment i need to run and step to follow

     

    use ChangeSynergy::csapi; 
    my $csapi = new ChangeSynergy::csapi(); 
    eval 

    $csapi->setUpConnection("http://GBCHMLP201UDAT.railad.com:8400" );
     my $aUser = $csapi->Login("yuvraj11", "abc@21", "developer", "/data/V71/ATSS");
     my $data = $csapi->DatabaseGetObject($aUser, "167931"); open(OUTPUT, ">Dummy.txt"); 
    print(OUTPUT $data->getResponseByteData()); 
    close(OUTPUT); }; 
    if ($@) { 
    print $@; } 

    The api is part of the Change installation.

    Assuming that your script runs on the server GBCHMLP201UDAT and assuming that Change is installed in let's say /opt/cs53/atss, you would add a first line in your script

    use lib "/opt/cs53/atss/jetty/webapps/change/WEB-INF/perl/lib/perl5/site_perl/5.8.6";
    

    If your script runs on a different server or on a PC, copy the directory /opt/cs53/atss/jetty/webapps/change/WEB-INF/perl/lib/perl5/site_perl/5.8.6/ChangeSynergy to any location you desire and adopt your "use lib" command accordingly.

  • yuvraj_mane
    yuvraj_mane
    7 Posts

    Re: Change synergy Query command for extracting attachment content

    ‏2017-04-13T05:53:31Z  

    The api is part of the Change installation.

    Assuming that your script runs on the server GBCHMLP201UDAT and assuming that Change is installed in let's say /opt/cs53/atss, you would add a first line in your script

    <pre class="php dw" data-editor-lang="js" data-pbcklang="php" dir="ltr">use lib "/opt/cs53/atss/jetty/webapps/change/WEB-INF/perl/lib/perl5/site_perl/5.8.6"; </pre>

    If your script runs on a different server or on a PC, copy the directory /opt/cs53/atss/jetty/webapps/change/WEB-INF/perl/lib/perl5/site_perl/5.8.6/ChangeSynergy to any location you desire and adopt your "use lib" command accordingly.

    Thank you Mike

    I have installed ibm rational synergy 7.1 client setup on my machine I do not have synergy change installed on my machine so i do not have synergy perl

    Using ibm rational synergy 7.1 client  I am able to connect the synergy server.

    right now i am connecting ibm rational change using web url link http://139.10.162.15:8600/change/user

    actually i am confuse is there any synergy change client

    Can you please tell me which version synergy change i have to installed on my machine

     

     

     

  • Mike.Scharnow
    Mike.Scharnow
    81 Posts

    Re: Change synergy Query command for extracting attachment content

    ‏2017-04-13T20:16:25Z  

    Thank you Mike

    I have installed ibm rational synergy 7.1 client setup on my machine I do not have synergy change installed on my machine so i do not have synergy perl

    Using ibm rational synergy 7.1 client  I am able to connect the synergy server.

    right now i am connecting ibm rational change using web url link http://139.10.162.15:8600/change/user

    actually i am confuse is there any synergy change client

    Can you please tell me which version synergy change i have to installed on my machine

     

     

     

    No, there is no IBM Rational Change client, Change is a web application. Only for Perl programs you need the .pm files from the Change server. So, if you have direct access to the server, use any file transfer program (ftp, sftp, scp, ...) to copy all the .pm files located inside the directory <jetty directory>/webapps/change/WEB-INF/perl/lib/perl5/site_perl/5.8.6/ChangeSynergy to your PC. Otherwise ask the Server administrators to give you the files.

     

    And, yes, it is totally OK to use ActivePerl, you don't need ratlperl.

  • yuvraj_mane
    yuvraj_mane
    7 Posts

    Re: Change synergy Query command for extracting attachment content

    ‏2017-04-20T12:58:54Z  

    No, there is no IBM Rational Change client, Change is a web application. Only for Perl programs you need the .pm files from the Change server. So, if you have direct access to the server, use any file transfer program (ftp, sftp, scp, ...) to copy all the .pm files located inside the directory <jetty directory>/webapps/change/WEB-INF/perl/lib/perl5/site_perl/5.8.6/ChangeSynergy to your PC. Otherwise ask the Server administrators to give you the files.

     

    And, yes, it is totally OK to use ActivePerl, you don't need ratlperl.

    Thank you Mike for reply

    I wrote the following code for upload the attachment to CR after executing following perl script i am receiving following error 

    UNIVERSAL->import is deprecated and will be removed in a future perl at C:/Perl/
    lib/XML/Lite.pm line 23.
    The fault code: 2
    The fault string: The authentication server is not available. Contact your admin
    istrator.

    even though i put correct username and password receiving above error 

    after changing change server password (remove @ from password) and set this password Admin!23  getting following error

    UNIVERSAL->import is deprecated and will be removed in a future perl at C:/Perl/
    lib/XML/Lite.pm line 23.
    The fault code: 2
    The fault string: You do not have access to log in.

    use ChangeSynergy::csapi; 
    my $csapi  = new ChangeSynergy::csapi();
        my $buf    = "";
        my $buffer = "";
        my $size   = "";
        eval
        {
            $csapi->setUpConnection("http://139.10.162.18:8608/change");
            my $aUser = $csapi->Login("yuvraj", "Admin!23", "developer", "/data/V71/ATWW");
            open(INPUTFILE, "d:\\output.doc") or die "Could not open up the file";
            binmode(INPUTFILE);
            while($buf = readline *INPUTFILE)
            {
                $buffer .= $buf;
            }
            close(INPUTFILE);    
            $size = -s "output.doc";        
            my $data = $csapi->CreateAttachmentObject($aUser, "1460", "attachment", "output",
                                                   "BINARY", "The output", "", "true", $buffer, $size);
            print $data->getResponseData();
        };    
        if ($@)
        {
            print $@;
        }

    if i mentioned database name in following format it gives error invalid role or database

    my $aUser = $csapi->Login("yuvraj", "Admin!23", "developer", "\\\\data\\V71\\ATWW");

     

    Updated on 2017-04-20T17:13:18Z at 2017-04-20T17:13:18Z by yuvraj_mane
  • Mike.Scharnow
    Mike.Scharnow
    81 Posts

    Re: Change synergy Query command for extracting attachment content

    ‏2017-04-20T19:13:32Z  

    Thank you Mike for reply

    I wrote the following code for upload the attachment to CR after executing following perl script i am receiving following error 

    UNIVERSAL->import is deprecated and will be removed in a future perl at C:/Perl/
    lib/XML/Lite.pm line 23.
    The fault code: 2
    The fault string: The authentication server is not available. Contact your admin
    istrator.

    even though i put correct username and password receiving above error 

    after changing change server password (remove @ from password) and set this password Admin!23  getting following error

    UNIVERSAL->import is deprecated and will be removed in a future perl at C:/Perl/
    lib/XML/Lite.pm line 23.
    The fault code: 2
    The fault string: You do not have access to log in.

    use ChangeSynergy::csapi; 
    my $csapi  = new ChangeSynergy::csapi();
        my $buf    = "";
        my $buffer = "";
        my $size   = "";
        eval
        {
            $csapi->setUpConnection("http://139.10.162.18:8608/change");
            my $aUser = $csapi->Login("yuvraj", "Admin!23", "developer", "/data/V71/ATWW");
            open(INPUTFILE, "d:\\output.doc") or die "Could not open up the file";
            binmode(INPUTFILE);
            while($buf = readline *INPUTFILE)
            {
                $buffer .= $buf;
            }
            close(INPUTFILE);    
            $size = -s "output.doc";        
            my $data = $csapi->CreateAttachmentObject($aUser, "1460", "attachment", "output",
                                                   "BINARY", "The output", "", "true", $buffer, $size);
            print $data->getResponseData();
        };    
        if ($@)
        {
            print $@;
        }

    if i mentioned database name in following format it gives error invalid role or database

    my $aUser = $csapi->Login("yuvraj", "Admin!23", "developer", "\\\\data\\V71\\ATWW");

     

    Hello Yuvraj.

    • It is good practice to have a line 'use warnings;' somewhere at the beginning of the script. It should tell you e.g. when variables are not written correctly.
    • @ in password: In Perl, it is better to put the password in single quotes 'hello@yuvraj' instead of double quotes "hello@yuvraj". With double quotes, Perl tries to interpolate variable names.
    • UNIVERSAL->import is deprecated: Well, this is just a warning and should not disturb your program, but it might be possible though unlikely that a module somehow reacts on this warning. Perhaps there will be an updated version of XML::Lite available some time. In the meantime, you can suppress this warning, see https://www.effectiveperlprogramming.com/2010/07/turn-off-perl-5-12-deprecation-warnings-if-you-dare/
    • Path to database: Is your server 139.10.162.18 a Unix/Linux server or a Windows server? If Unix/Linux, you must use the syntax "/data/V71/ATWW", if Windows, use "\\\\data\\V71\\ATWW". Note that not the client computer but the server computer is important here.
    • "You do not have access to log in" could be a problem of the account. Perhaps you get more information in the event.log (Admin interface, Home page, Log). It might be that when you tested your script multiple times that your account has been locked. If your RDS is a standalone server, you can unlock it with the RDA, if the RDS has a connection to a corporate directory server, you might have to ask your admins. Are you sure that you changed the RDS password (using the link "Forgot my password" or the Synergy set-password-page) and not the OS user password? So, can you use your new password to log into the Change user interface? 
    • Update: Oh, wait: generally, there is no "developer" interface in Change, unless your lifecycle contains one. Normally, you should write
      my $aUser = $csapi->Login("yuvraj", 'Admin!23', "User", "/data/V71/ATWW");

    Hope this helps,
    Mike

     

  • yuvraj_mane
    yuvraj_mane
    7 Posts

    Re: Change synergy Query command for extracting attachment content

    ‏2017-04-22T06:30:57Z  

    Hello Yuvraj.

    • It is good practice to have a line 'use warnings;' somewhere at the beginning of the script. It should tell you e.g. when variables are not written correctly.
    • @ in password: In Perl, it is better to put the password in single quotes 'hello@yuvraj' instead of double quotes "hello@yuvraj". With double quotes, Perl tries to interpolate variable names.
    • UNIVERSAL->import is deprecated: Well, this is just a warning and should not disturb your program, but it might be possible though unlikely that a module somehow reacts on this warning. Perhaps there will be an updated version of XML::Lite available some time. In the meantime, you can suppress this warning, see https://www.effectiveperlprogramming.com/2010/07/turn-off-perl-5-12-deprecation-warnings-if-you-dare/
    • Path to database: Is your server 139.10.162.18 a Unix/Linux server or a Windows server? If Unix/Linux, you must use the syntax "/data/V71/ATWW", if Windows, use "\\\\data\\V71\\ATWW". Note that not the client computer but the server computer is important here.
    • "You do not have access to log in" could be a problem of the account. Perhaps you get more information in the event.log (Admin interface, Home page, Log). It might be that when you tested your script multiple times that your account has been locked. If your RDS is a standalone server, you can unlock it with the RDA, if the RDS has a connection to a corporate directory server, you might have to ask your admins. Are you sure that you changed the RDS password (using the link "Forgot my password" or the Synergy set-password-page) and not the OS user password? So, can you use your new password to log into the Change user interface? 
    • Update: Oh, wait: generally, there is no "developer" interface in Change, unless your lifecycle contains one. Normally, you should write
      my $aUser = $csapi->Login("yuvraj", 'Admin!23', "User", "/data/V71/ATWW");

    Hope this helps,
    Mike

     

    Thank you mike. after made above changes It is working for me :)

  • yuvraj_mane
    yuvraj_mane
    7 Posts

    Re: Change synergy Query command for extracting attachment content

    ‏2017-04-25T09:45:34Z  

    Thank you mike. after made above changes It is working for me :)

    How to get change request associated to task using perl script?

  • Mike.Scharnow
    Mike.Scharnow
    81 Posts

    Re: Change synergy Query command for extracting attachment content

    ‏2017-04-25T15:40:31Z  

    How to get change request associated to task using perl script?

    this can be done using a "relation query".

    Objects in Synergy can be related, Relations have a name (e.g. "task", "associated_cv", "child", ...) and a direction, i.e. "is_..._of" and "has_...".

    Currently, I do not have a change installation with tasks available, so, I'm not sure, what exactly the name for relations between problems and task is. You can find it out by

    • finding an existing task that is related to a problem, e.g. Task #23
    • starting a CLI session
    • do a query command to find this task, e.g. ccm query -t "task_number='23'"
    • find the relation:
      ccm relate -show -to @  
      (or was it ccm relate -show -from @ ???)
    • the result gives you : from-object, name, to-object, creation date. You need the name.
    • if the name is e.g. "associated_task", the query you asked for is:
      ​has_associated_task(task_number='23')

     

  • yuvraj_mane
    yuvraj_mane
    7 Posts

    Re: Change synergy Query command for extracting attachment content

    ‏2017-04-25T17:31:58Z  

    this can be done using a "relation query".

    Objects in Synergy can be related, Relations have a name (e.g. "task", "associated_cv", "child", ...) and a direction, i.e. "is_..._of" and "has_...".

    Currently, I do not have a change installation with tasks available, so, I'm not sure, what exactly the name for relations between problems and task is. You can find it out by

    • finding an existing task that is related to a problem, e.g. Task #23
    • starting a CLI session
    • do a query command to find this task, e.g. ccm query -t "task_number='23'"
    • find the relation:
      ccm relate -show -to @  
      (or was it ccm relate -show -from @ ???)
    • the result gives you : from-object, name, to-object, creation date. You need the name.
    • if the name is e.g. "associated_task", the query you asked for is:
      ​has_associated_task(task_number='23')

     

    Hi Mike ,

    ccm relate -show -to @   this command is working fine for me using synergy CLI but 

    I want to get the  change request associated to task using perl script API (IBM Rational change)   Instead of Synergy CLI

    Is it possible?

     

     

     

  • Mike.Scharnow
    Mike.Scharnow
    81 Posts

    Re: Change synergy Query command for extracting attachment content

    ‏2017-04-26T09:05:23Z  

    Hi Mike ,

    ccm relate -show -to @   this command is working fine for me using synergy CLI but 

    I want to get the  change request associated to task using perl script API (IBM Rational change)   Instead of Synergy CLI

    Is it possible?

     

     

     

    Well, you do this with a query. So, the first step is to get the information on how to formulate the query. Once you used the mechanism above to determine the name of the relation you will be able to do a command like

    ccm query "is...of(...task...)" -format %problem_number
    

    You now need to convert the query string and the format to be used with the Change API. There are several possibilities to do queries with the API, I'd suggest to use the function "QueryStringData".

     

    One example:

    eval{
        $related_crs = $csapi->QueryStringData($aUser, "Basic Summary", $query, "problem_number");
    };
    if ($@) {
        die "internal error while querying for related problem: ".$@;
    }
    if ($related_crs->getDataSize()) {
        my @crs;
        eval{
            for(my $relPos=0; $relPos < $related_crs->getDataSize(); $relPos++) {
                push @crs, $related_crs->getDataObject($relPos)->getDataObjectByName("problem_number")->getValue();
            }
        };
        if ($@) {
            die "internal error when accessing retrieved values: $@";
        }
    }
    

    Edit: removed blanks, reformatted, added semicolon and bracket

    Updated on 2017-04-26T09:27:29Z at 2017-04-26T09:27:29Z by Mike.Scharnow