Changeset 5480


Ignore:
Timestamp:
Nov 8, 2010, 10:56:02 AM (12 years ago)
Author:
Nicklas Nordborg
Message:

References #1542: Plug-ins should be able to suggest a better job name

Fixed in the core API. Plug-ins can now call Response.setSuggestedJobName() to suggest a job name. The reporter importer was used as a test case. I will fix this in the remaining core plug-ins.

Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/core/net/sf/basedb/core/PluginResponse.java

    r5405 r5480  
    5858  private String message;
    5959  private boolean dryRun;
     60  private String suggestedJobName;
    6061  private List<? extends Throwable> errorList;
    6162  private String nextCommand;
     
    9293 
    9394  /**
     95    Get the job name that was suggested by the job.
     96 
     97    @return A job name or null if no name has been suggested
     98    @since 2.17
     99  */
     100  public String getSuggestedJobName()
     101  {
     102    return suggestedJobName;
     103  }
     104 
     105  /**
    94106    Get the return message from the plugin.
    95107  */
     
    312324      PluginResponse.this.dryRun = dryRun;
    313325    }
     326   
     327    @Override
     328    public void setSuggestedJobName(String jobName)
     329    {
     330      PluginResponse.this.suggestedJobName = jobName;
     331    }
    314332    // -------------------------------------------
    315333  }
  • trunk/src/core/net/sf/basedb/core/plugin/Response.java

    r5405 r5480  
    143143 
    144144  /**
     145    A plug-in may call this method on it's job configuration phase
     146    to suggest a name for the job. Otherwise a default name will be
     147    generated by the core.
     148    @param jobName
     149    @since 2.17
     150  */
     151  public void setSuggestedJobName(String jobName);
     152 
     153  /**
    145154    This will end the job execution or configuration and report it as a
    146155    failure. If in a configuration sequence the client application may try
  • trunk/src/plugins/core/net/sf/basedb/plugins/ReporterFlatFileImporter.java

    r5451 r5480  
    388388        storeValue(job, request, reporterIsUsedErrorParameter);
    389389       
     390        File importFile = (File)job.getValue(fileParameter.getName());
     391        if (reporterListContext)
     392        {
     393          ReporterList reporterList = (ReporterList)job.getValue("reporterList");
     394          response.setSuggestedJobName("Import reporters to list '" + reporterList.getName()
     395              + "' from '" + importFile.getName() + "'");
     396        }
     397        else
     398        {
     399          response.setSuggestedJobName("Import reporters from '" + importFile.getName() + "'");
     400        }
    390401        response.setDone("Job configuration complete", Job.ExecutionTime.SHORT);
    391402      }
  • trunk/src/plugins/core/net/sf/basedb/plugins/executor/ExternalProgramExecutor.java

    r5405 r5480  
    13721372    {}
    13731373
     1374   
     1375    @Override
     1376    public void setSuggestedJobName(String jobName)
     1377    {}
     1378   
    13741379    @Override
    13751380    public void setError(String message, List<? extends Throwable> errorList)
  • trunk/www/common/plugin/index.jsp

    r5437 r5480  
    6161  import="net.sf.basedb.core.Include"
    6262  import="net.sf.basedb.core.SimpleProgressReporter"
     63  import="net.sf.basedb.core.StringUtil"
    6364  import="net.sf.basedb.core.query.Hql"
    6465  import="net.sf.basedb.core.query.Expressions"
     
    484485      if (job != null)
    485486      {
     487        String suggestedJobName = pluginResponse.getSuggestedJobName();
     488        if (suggestedJobName != null) job.setName(StringUtil.trimString(suggestedJobName, Job.MAX_NAME_LENGTH));
    486489        sc.setSessionSetting("plugin.configure.response", pluginResponse);
    487490        forward = "finish_job.jsp";
Note: See TracChangeset for help on using the changeset viewer.