Topic
  • 4 replies
  • Latest Post - ‏2014-04-25T16:06:02Z by jkrause
DevM
DevM
9 Posts

Pinned topic How do I get the latest CRID from Rational Change?

‏2014-04-08T15:35:06Z |

I am working on a PERL script to cycle through all the records, or a chunk of them, in the database when necessary. Is there a way to query for the highest (or next) CRID?

A query or ccm command would help.

 

Thanks,

  DevM

Updated on 2014-04-08T15:35:19Z at 2014-04-08T15:35:19Z by DevM
  • Mike.Scharnow
    Mike.Scharnow
    67 Posts

    Re: How do I get the latest CRID from Rational Change?

    ‏2014-04-08T21:03:21Z  
    ccm query -name probtrac_seed -type admin -u -f %next_problem
    

    should help here...

    BR,
    Mike

    

     

  • DevM
    DevM
    9 Posts

    Re: How do I get the latest CRID from Rational Change?

    ‏2014-04-23T19:09:37Z  
    <pre class="javascript dw" data-editor-lang="js" data-pbcklang="javascript" dir="ltr">ccm query -name probtrac_seed -type admin -u -f %next_problem </pre>

    should help here...

    BR,
    Mike

    

     

    Mike,

       I need a little more guidance. I use the following code to sign in to the database:

           $csapi->setUpConnection($http);

             $user = $csapi->Login($username, $password, $role, $db);

     The ccm query does not seem to recognize that I'm logged in. Role is set to User. The rest are self explanatory.  I tried giving myself the ccm_admin role as well but that didn't help. I'm sure I'm just missing something but I haven't figured out what yet. Maybe another ccm to log in on the Unix side. It seems excessive, but...

     

    Thanks,

      Paul

     

     

  • Mike.Scharnow
    Mike.Scharnow
    67 Posts

    Re: How do I get the latest CRID from Rational Change?

    ‏2014-04-24T10:23:35Z  
    • DevM
    • ‏2014-04-23T19:09:37Z

    Mike,

       I need a little more guidance. I use the following code to sign in to the database:

           $csapi->setUpConnection($http);

             $user = $csapi->Login($username, $password, $role, $db);

     The ccm query does not seem to recognize that I'm logged in. Role is set to User. The rest are self explanatory.  I tried giving myself the ccm_admin role as well but that didn't help. I'm sure I'm just missing something but I haven't figured out what yet. Maybe another ccm to log in on the Unix side. It seems excessive, but...

     

    Thanks,

      Paul

     

     

    Hi Paul,

    I think I need a little bit more of your code to see what went wrong.

    In the code you provided, you opened a connection to Change, not directly to Synergy.

    Thus you need to use the Change API for posing the query. "ccm query" will not work.

    Perhaps something like the following will help you  ($queryString would be "type='admin' and name='probtrac_seed'")

    $queryResults = $self->QueryData($user, "Basic Summary", "$queryString", undef, undef, undef, "attr1|attr2|attr3");
    if( $queryResults->getDataSize() eq 0 ) {
        # error
    }
    if( $queryResults->getDataSize() >1 ) {
        # error ?? depends on the query
    }
    
    my $attr1 = $queryResults->getDataObject(0)->getDataObjectByName("attr1")->getValue();
    

    BR,
    Mike

    Updated on 2014-04-24T10:35:32Z at 2014-04-24T10:35:32Z by Mike.Scharnow
  • jkrause
    jkrause
    12 Posts

    Re: How do I get the latest CRID from Rational Change?

    ‏2014-04-25T16:06:02Z  
    • DevM
    • ‏2014-04-23T19:09:37Z

    Mike,

       I need a little more guidance. I use the following code to sign in to the database:

           $csapi->setUpConnection($http);

             $user = $csapi->Login($username, $password, $role, $db);

     The ccm query does not seem to recognize that I'm logged in. Role is set to User. The rest are self explanatory.  I tried giving myself the ccm_admin role as well but that didn't help. I'm sure I'm just missing something but I haven't figured out what yet. Maybe another ccm to log in on the Unix side. It seems excessive, but...

     

    Thanks,

      Paul

     

     

    Hi Mike, 

    I'd like to add a demonstration of how to get the same information directly from Synergy using a perl script. This can be modified to execute most any Synergy CLI commands. 

    Given that you have $username, $password, $cmrole, $db, and the $synergy_server_url set in your perl script, you can use the following code to start and connect directly to a Synergy CLI session, run a query, and (very important) stop the Synergy session.  You don't want to leave unused sessions hanging around.
     
    Note that $cmrole is the Synergy role (developer, build_mgr, ccm_admin etc) which is different than the Change login role (User, Admin, ReportBuilder)
    # This example is for Windows.  For UNIX, change $CCM_HOME accordingly and change \\ to /
    
    use Env;      # imports all possible Environment variables
    
    my $CCM_HOME='C:\\Program Files\\IBM\\Rational\\Synergy\\7.2';
    $ENV{"PATH"} = $CCM_HOME."\\bin;".$PATH; 
    
    my $start_cmd = "ccm start -d $db -m -q -nogui -n $username -pw $password -s $synergy_server_url -r $cmrole";
     
    my $ccm_addr = `$start_cmd` || die "Could not start session on $db!\n";
    $ENV{'CCM_ADDR'} = $ccm_addr;
      
    my $next_CRID = `ccm query -name probtrac_seed -type admin -u -f %next_problem`;
    print "Next CR number:$next_CRID\n";
     
    $exit_msg=`ccm stop`;
    print "$exit_msg\n";
    

    Also, I'd like to point out that the 'next_problem' attribute on the probtrac_seed object holds the next CR number to be used.  And, because this attribute may have potentially been modified - set to a higher number for instance - this attribute may not represent an accurate count of the CRs in the database.  

    An alternative approach to get and process all CRs is to get their CR id or 4-part name directly from Synergy:

    # This creates an array of CR ids (A#1, A#2, etc)
    my @cr_list =  `ccm query -t problem -u -f %displayname`;
    
    # This creates an array of CR 4-part names (problem1-1:probtrac:A, problem2-1:probtrac:A, etc)
    # my @cr_list =  `ccm query -t problem -u -f %displayname`;
    
    foreach $cr (@cr_list) {
        chomp $cr;
        # Add commands to process the CR
            print "$cr\n";
    }
    

    This must be done between the 'ccm start' and 'ccm stop' commands.

    I hope you find this useful.

    Jeff