Topic
  • 7 replies
  • Latest Post - ‏2013-10-25T13:07:29Z by mahesh12345
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
    69 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
    69 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
    69 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.