ucCloneGenAltId

Purpose

This can be used to generate the ALT_ID value to store an issue when cloning an issue.

Applies To

Edit screen buttons

Signature

public HashMap ucCloneGenAltId( 
      ProblemFormParam values,    // contains values of form params
      FormParameters fp,          // contains values of form params
      HashMap msg,                // contains msg that goes into COMMENTS field
      Connection con,             // the database connection
      SesameSession session)  	  // the session object

Notes

It can also be used to manipulate the cloning message that goes into the inbuilt COMMENTS field. For example, if you want to insert a message that is different from the standard “Issue # xxxxx cloned from Issue # yyyyy”, then use this method to overwrite the value for the COMMENTS parameter.

Example

This method shows how a cloning message can be changed from the standard. Instead, it overwrites the value for the comments parameter, and returns the modified message.

public HashMap ucCloneGenAltId( 
      ProblemFormParam values,    // contains values of form params
      FormParameters fp,          // contains values of form params
      HashMap msg,                // contains msg that goes into COMMENTS field
      Connection con,             // the database connection
      SesameSession session) throws Exception  // the session object
{
    String project_prefix = null;
    String area = null;
    String project = null;
    String new_alt_id = null;
    ProblemFormParam npfp = (ProblemFormParam) session.getAttribute("CLONEE_PFP");
    
    if (npfp == null) {
       project = (String) fp.get("p_project");
    } else {
       project = (String) npfp.get("PROJECT_ID");
    }
    
    int index1 = project.indexOf("|");
    if (index1 > -1) {
    	area = project.substring(0, index1);
        project = project.substring(index1 + 1, project.length());
    }

    // Get current issue's ALT_ID
    String alt_id = (String) values.get("ALT_ID");
    if (alt_id == null) {
    	Problem p = Problem.getReference(con, (String) values.get("ID"));
        alt_id = p.getAltId();
    }
    
    if (area == null) { area = "AREA"; }
    if (project == null) { project = "PROJECT"; }
    
    project_prefix = area + "_" + project;
    
    String preAltId = null;
    String seq = (String) values.get("ID");

    int len = seq.length();
    // fill with preceeding zeros if length is less than 5 digits
    while (len