Changeset 4379


Ignore:
Timestamp:
Aug 5, 2008, 2:22:52 PM (14 years ago)
Author:
Nicklas Nordborg
Message:

References #1082: Make it possible to re-enter parameters for a failed job

Major changes are now in place. Need more testing to find non-working plug-ins and to cover all possible paths for a job.

Location:
trunk
Files:
8 edited

Legend:

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

    r4372 r4379  
    107107    method.
    108108  */
    109   public static final int NEW_SCHEMA_VERSION = Integer.valueOf(61).intValue();
     109  public static final int NEW_SCHEMA_VERSION = Integer.valueOf(62).intValue();
    110110 
    111111  public static synchronized void createTables(boolean update, final ProgressReporter progress)
  • trunk/src/core/net/sf/basedb/core/Job.java

    r4355 r4379  
    683683    return getData().getServer();
    684684  }
     685 
     686  /**
     687    Checks if this job has saved information about the context that was active
     688    when this job was created. If context information is available it is possible
     689    to re-configure a failed job.
     690    @see #configure(GuiContext)
     691    @see #getLastGuiContext()
     692    @return TRUE if context information is available, FALSE otherwise
     693    @since 2.8
     694  */
     695  public boolean hasContext()
     696  {
     697    return getData().getContextItem() != null && getData().getContextType() != null;
     698  }
     699 
     700  /**
     701    Get the gui-context that was active when this job was created.
     702    @return The active context, or null if not known
     703    @since 2.8
     704  */
     705  public GuiContext getLastGuiContext()
     706  {
     707    GuiContext context = null;
     708    if (hasContext())
     709    {
     710      context = new GuiContext(Item.fromValue(getData().getContextItem()),
     711          GuiContext.Type.fromValue(getData().getContextType()), getData().getSubContext());
     712    }
     713    return context;
     714  }
     715 
    685716 
    686717  /**
     
    15901621    {
    15911622      JobData data = job.getData();
    1592       data.setStatus(Status.WAITING.getValue());
     1623      data.setStatus(Job.Status.WAITING.getValue());
     1624      data.setPercentComplete(0);
     1625      data.setStarted(null);
     1626      data.setEnded(null);
     1627      data.setStatusMessage(null);
     1628      data.setStackTrace(null);
     1629      data.setServer(null);
     1630      data.setJobAgentId(null);
    15931631      data.setEstimatedExecutionTime(response.getEstimatedExecutionTime().getValue());
    15941632    }
     
    17861824
    17871825    /**
     1826      The job is beeing prepared for execution.
     1827    */
     1828    PREPARED(5, "Preparing", true),
     1829
     1830   
     1831    /**
    17881832      The job is executing.
    17891833    */
    17901834    EXECUTING(2, "Executing", false),
    1791    
    1792     /**
    1793       The job has finished successfully.
    1794     */
    1795     DONE(3, "Done", false),
    1796 
    1797     /**
    1798       The job has finished with an error.
    1799     */
    1800     ERROR(4, "Error", false),
    1801    
    1802     /**
    1803       The job is beeing prepared for execution.
    1804     */
    1805     PREPARED(5, "Preparing", true),
    1806    
     1835
    18071836    /**
    18081837      The {@link Signal#ABORT} signal has been sent to the
    18091838      job, but it has not yet responded.
    18101839    */
    1811     ABORTING(6, "Aborting", false);
    1812 
     1840    ABORTING(6, "Aborting", false),
     1841   
     1842    /**
     1843      The job has finished successfully.
     1844    */
     1845    DONE(3, "Done", false),
     1846
     1847    /**
     1848      The job has finished with an error.
     1849    */
     1850    ERROR(4, "Error", false);
     1851   
    18131852    /**
    18141853      Maps the integer that is stored in the database.
  • trunk/src/core/net/sf/basedb/core/PluginRequest.java

    r4105 r4379  
    2626package net.sf.basedb.core;
    2727
     28import net.sf.basedb.core.data.JobData;
    2829import net.sf.basedb.core.plugin.GuiContext;
    2930import net.sf.basedb.core.plugin.Plugin;
     
    246247    Save all parameters that have got values in this request/response session.
    247248  */
    248   void saveParameters(DbControl dc)
     249  void saveParameters(DbControl dc, GuiContext context)
    249250  {
    250251    if (jobParameters != null && !jobParameters.isWriteProtected() && job != null)
    251252    {
    252253      Job theJob = job.isInDatabase() ? Job.getById(dc, job.getId()) : job;
     254      JobData jobData = theJob.getData();
     255      if (pluginConfiguration != null)
     256      {
     257        jobData.setParameterVersion(pluginConfiguration.getParameterVersion());
     258      }
     259      if (context != null)
     260      {
     261        jobData.setContextItem(context.getItem().getValue());
     262        jobData.setContextType(context.getType().getValue());
     263        jobData.setSubContext(context.getSubContext());
     264       
     265      }
     266      else
     267      {
     268        jobData.setContextItem(null);
     269        jobData.setContextType(null);
     270        jobData.setSubContext(null);
     271      }
    253272      jobParameters.saveParameters(theJob, parameterInfo);
    254273    }
  • trunk/src/core/net/sf/basedb/core/PluginResponse.java

    r4330 r4379  
    146146      throw new PermissionDeniedException("Can't save parameters since response status is: " + getStatus());
    147147    }
    148     request.saveParameters(dc);
     148    request.saveParameters(dc, request.getGuiContext());
    149149  }
    150150 
  • trunk/src/core/net/sf/basedb/core/Update.java

    r4355 r4379  
    699699    </td>
    700700  </tr>
     701  <tr>
     702    <td>62</td>
     703    <td>
     704      Added:
     705      <ul>
     706      <li>{@link net.sf.basedb.core.data.JobData#getContextItem()}.
     707      <li>{@link net.sf.basedb.core.data.JobData#getContextType()}.
     708      <li>{@link net.sf.basedb.core.data.JobData#getSubContext()}.
     709      </ul>
     710      No special database update is needed. Only increase the schema version.
     711    </td>
     712  </tr>
    701713 
    702714  </table>
     
    982994      }
    983995     
    984       if (schemaVersion < 61)
    985       {
    986         if (progress != null) progress.display((int)(60*progress_factor), "--Updating schema version: " + schemaVersion + " -> 61...");
    987         schemaVersion = setSchemaVersionInTransaction(session, 61);
     996      if (schemaVersion < 62)
     997      {
     998        if (progress != null) progress.display((int)(61*progress_factor), "--Updating schema version: " + schemaVersion + " -> 62...");
     999        schemaVersion = setSchemaVersionInTransaction(session, 62);
    9881000      }
    9891001     
  • trunk/src/core/net/sf/basedb/core/data/JobData.java

    r4355 r4379  
    383383  }
    384384
     385  private Integer contextItem;
     386  /**
     387    The item type of the context that was active when configuring
     388    this job. null = no context was known
     389    @hibernate.property column="`context_item`" type="int"
     390    @since 2.8
     391  */
     392  public Integer getContextItem()
     393  {
     394    return contextItem;
     395  }
     396  /**
     397    @since 2.8
     398  */
     399  public void setContextItem(Integer contextItem)
     400  {
     401    this.contextItem = contextItem;
     402  }
     403 
     404  private Integer contextType;
     405  /**
     406    The context type that was active when configuring
     407    this job. 0 = single item, 1 = list
     408    @hibernate.property column="`context_type`" type="int"
     409    @since 2.8
     410  */
     411  public Integer getContextType()
     412  {
     413    return contextType;
     414  }
     415  /**
     416    @since 2.8
     417  */
     418  public void setContextType(Integer contextType)
     419  {
     420    this.contextType = contextType;
     421  }
     422 
     423  /**
     424    The maximum allowed length of the subcontext name.
     425    @since 2.8
     426  */
     427  public static final int MAX_SUBCONTEXT_LENGTH = 255;
     428  private String subContext;
     429  /**
     430    The name of the subcontext that was active whjen configuring
     431    this job.
     432    @hibernate.property column="`subcontext`" type="string" length="255" not-null="false"
     433    @since 2.8
     434  */
     435  public String getSubContext()
     436  {
     437    return subContext;
     438  }
     439  /**
     440    @since 2.8
     441  */
     442  public void setSubContext(String subContext)
     443  {
     444    this.subContext = subContext;
     445  }
     446 
    385447  /**
    386448    The maximum allowed length of the signal transporter string.
  • trunk/www/common/plugin/index.jsp

    r4343 r4379  
    326326    Job job = Job.getById(dc, jobId);
    327327   
    328     // TODO - This is not meaningful unless we can get a context
    329     //int pluginDefinitionId = Values.getInt(request.getParameter("plugindefinition_id"));
    330     //int pluginConfigurationId = Values.getInt(request.getParameter("pluginconfiguration_id"));
    331    
    332328    //Item itemType = Item.valueOf(request.getParameter("item_type"));
    333329    //String subContext = Values.getString(request.getParameter("subcontext"), "");
    334330    //GuiContext.Type contextType = GuiContext.Type.valueOf(request.getParameter("context_type"));
    335     //GuiContext context = new GuiContext(itemType, contextType, subContext);
     331    GuiContext context = job.getLastGuiContext();
    336332   
    337333    PluginDefinition plugin = job.getPluginDefinition();
    338334    PluginConfiguration pluginConfig = job.getPluginConfiguration();
    339335   
    340     PluginConfigurationRequest pcRequest = job.configure(null);
     336    PluginConfigurationRequest pcRequest = job.configure(context);
    341337    sc.setSessionSetting("plugin.configure.request", pcRequest);
    342338    sc.setSessionSetting("plugin.configure.job", job);
     
    522518    dc = sc.newDbControl();
    523519    Job job = (Job)sc.getSessionSetting("plugin.configure.job");
     520    if (job.isInDatabase())
     521    {
     522      dc.reattachItem(job);
     523    }
     524    else
     525    {
     526      dc.saveItem(job);
     527    }
     528   
    524529    PluginResponse pluginResponse = (PluginResponse)sc.getSessionSetting("plugin.configure.response");
    525530    boolean executeImmediately =
     
    530535    job.setSendMessage(Values.getBoolean(request.getParameter("send_message")));
    531536    job.setRemoveJobWhenFinished(Values.getBoolean(request.getParameter("remove_job")));
    532     dc.saveItem(job);
    533537   
    534538    if (!executeImmediately)
  • trunk/www/views/jobs/view_job.jsp

    r4355 r4379  
    169169    location.href = 'index.jsp?ID=<%=ID%>&cmd=RestartJob&item_id=<%=itemId%>&useLatestConfiguration='+useLatestConfiguration;
    170170  }
     171  function reconfigureJob()
     172  {
     173    location.href = '../../common/plugin/index.jsp?ID=<%=ID%>&cmd=ConfigureJob&job_id=<%=itemId%>';
     174  }
     175 
    171176    function deleteItemPermanently()
    172177    {
     
    526531      {
    527532        %>
    528         <base:button onclick="restartJob()" title="Restart job" image="refresh.gif" />
     533        <base:button onclick="restartJob()" title="Restart job"
     534          image="refresh.gif"
     535          tooltip="Try to run this job again with the same parameters"
     536        />
     537        <base:button onclick="reconfigureJob()" title="Re-configure job"
     538          image="runplugin.gif"
     539          tooltip="Change the parameters for this job and try again"
     540          visible="<%=job.hasContext()%>"
     541        />
    529542        <%
    530543      }
Note: See TracChangeset for help on using the changeset viewer.