Changeset 3480


Ignore:
Timestamp:
Jun 13, 2007, 12:39:31 PM (16 years ago)
Author:
Martin Svensson
Message:

References #426 Option to flag an import/export job to be removed, when finished successfully, is now implemented.
Need to be documented too....

Location:
trunk
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/core/common-queries.xml

    r3467 r3480  
    25802580  </query>
    25812581 
     2582  <query id="SET_REMOVE_JOB_ON_JOBS" type="HQL">
     2583    <sql>
     2584      UPDATE JobData j
     2585      SET j.removeJobWhenFinished = false
     2586      WHERE j.removeJobWhenFinished IS NULL
     2587    </sql>
     2588    <description>
     2589      A HQL query that sets the deleteJobWhenFinished to false
     2590      on all jobs with a null value.
     2591    </description>
     2592  </query> 
     2593 
    25822594  <query id="GET_INTERNAL_FILES_WITH_NO_LAST_UPDATE" type="HQL">
    25832595    <sql>
  • trunk/src/core/net/sf/basedb/core/Install.java

    r3467 r3480  
    102102    method.
    103103  */
    104   public static final int NEW_SCHEMA_VERSION = 32;
     104  public static final int NEW_SCHEMA_VERSION = 33;
    105105 
    106106  public static synchronized void createTables(boolean update, final ProgressReporter progress)
  • trunk/src/core/net/sf/basedb/core/Job.java

    r2981 r3480  
    3535import net.sf.basedb.core.plugin.Request;
    3636import net.sf.basedb.core.plugin.Response;
     37import net.sf.basedb.core.plugin.Plugin.MainType;
    3738
    3839import java.util.Collection;
     
    131132    jobData.setCreated(new Date());
    132133    jobData.setSendMessage(true);
     134    jobData.setRemoveJobWhenFinished(false);
    133135    return j;
    134136  }
     
    379381    checkPermission(Permission.WRITE);
    380382    getData().setSendMessage(sendMessage);
     383  }
     384 
     385  /**
     386    If the job should be deleted after it's done successfully
     387  */
     388  public boolean getRemoveJobWhenFinished()
     389  {
     390    return getData().getRemoveJobWhenFinished();
     391  }
     392 
     393  /**
     394    Set if the job should be deleted after it has finished successfully.
     395    @throws PermissionDeniedException If the logged in user doesn't have
     396      write permission
     397  */
     398  public void setRemoveJobWhenFinished(boolean removeJobWhenFinished)
     399  {
     400    checkPermission(Permission.WRITE);
     401    getData().setRemoveJobWhenFinished(removeJobWhenFinished);
    381402  }
    382403
     
    12081229        {
    12091230          job.doneOk(response.getMessage());
     1231          PluginDefinition pd = null;
     1232          boolean isImportOrExport = false;
     1233          try
     1234          {
     1235            pd = job.getPluginDefinition();
     1236            MainType pluginMainType = pd.getMainType();
     1237            isImportOrExport = pluginMainType.equals(MainType.EXPORT) || (pluginMainType.equals(MainType.IMPORT));
     1238          }
     1239          catch(PermissionDeniedException pex)
     1240          {
     1241            isImportOrExport = false;
     1242          }
     1243          job.setRemoved(job.getRemoveJobWhenFinished() && isImportOrExport);
    12101244        }
    12111245        dc.commit();
  • trunk/src/core/net/sf/basedb/core/Update.java

    r3467 r3480  
    385385      The update sets the <code>isDefault</code> value to false for all existing
    386386      groups and roles with a null value.
     387    </td>
     388  </tr>
     389 
     390  <tr>
     391    <td>33</td>
     392    <td>
     393      <ul>
     394      <li>Added {@link net.sf.basedb.core.data.JobData#getDeleteJobWhenFinished()}.
     395      </ul>
     396      The update sets the <code>deleteJobWhenFinished</code> value to false for all existing jobs.
    387397    </td>
    388398  </tr>
     
    558568        schemaVersion = setSchemaVersionInTransaction(session, 32);
    559569      }
    560      
    561      
     570           
     571      if (schemaVersion < 33)
     572      {
     573        if (progress != null) progress.display((int)(32*progress_factor), "--Updating schema version: " + schemaVersion + " -> 33...");       
     574        schemaVersion = setSchemaVersionInTransaction(session, 33);
     575      }
    562576      /*
    563       if (schemaVersion < 33)
    564       {
    565         if (progress != null) progress.display((int)(32*progress_factor), "--Updating schema version: " + schemaVersion + " -> 33...");
    566         schemaVersion = setSchemaVersionInTransaction(session, 33);
     577      if (schemaVersion < 34)
     578      {
     579        if (progress != null) progress.display((int)(33*progress_factor), "--Updating schema version: " + schemaVersion + " -> 34...");
     580        schemaVersion = setSchemaVersionInTransaction(session, 34);
    567581        - or -
    568         schemaVersion = updateToSchemaVersion33(session);
     582        schemaVersion = updateToSchemaVersion34(session);
    569583      }
    570584      ... etc...
     
    15141528        }
    15151529       
     1530        if (schemaVersion < 33)
     1531        {
     1532          // Set delete_job to false for jobs with null value
     1533          org.hibernate.Query query = HibernateUtil.getPredefinedQuery(session,
     1534              "SET_REMOVE_JOB_ON_JOBS");
     1535          /*
     1536            UPDATE JobData j
     1537            SET j.removeJobWhenFinished = false
     1538            WHERE j.removeJobWhenFinished IS NULL
     1539          */
     1540          HibernateUtil.executeUpdate(query);
     1541        }
     1542       
    15161543        //  Commit the changes
    15171544        HibernateUtil.commit(tx);
  • trunk/src/core/net/sf/basedb/core/data/JobData.java

    r2962 r3480  
    157157  }
    158158 
     159  private boolean removeJobWhenFinished;
     160  /**
     161    If the core should delete the job when it's finished successfully.
     162    @hibernate.property column="`remove_job`" type="boolean" not-null="true"
     163  */
     164  public boolean getRemoveJobWhenFinished()
     165  {
     166    return removeJobWhenFinished;
     167  }
     168  public void setRemoveJobWhenFinished(boolean removeJobWhenFinished)
     169  {
     170    this.removeJobWhenFinished = removeJobWhenFinished;
     171  }
     172 
    159173  private int status;
    160174  /**
  • trunk/www/common/plugin/finish_job.jsp

    r2978 r3480  
    6565  PluginConfiguration pluginConfig = job.getPluginConfiguration(); // (PluginConfiguration)sc.getSessionSetting("plugin.configure.config");
    6666  boolean sendMessage = Values.getBoolean(sc.getUserClientSetting("plugins.sendmessage"), true);
     67  boolean removeJobWhenFinished = Values.getBoolean(sc.getUserClientSetting("plugins.removejob"), false);
    6768  %>
    6869  <base:page type="popup" title="Set job name and options">
     
    9394        <td class="prompt">Plugin</td>
    9495        <td><%=HTML.encodeTags(plugin.getName())%></td>
    95         </td>
    9696      </tr>
    9797      <tr valign="top" id="configurations">
     
    107107        </td>
    108108      </tr>
    109       <tr valign=top>
     109      <tr valign="top">
    110110        <td class="prompt">Job description</td>
    111111        <td nowrap>
     
    125125      </tr>
    126126     
     127      <tr>
     128        <td class="prompt">Remove job</td>
     129        <%
     130        if (plugin.getMainType().equals(Plugin.MainType.EXPORT) ||
     131            plugin.getMainType().equals(Plugin.MainType.IMPORT))
     132        {
     133          %>
     134          <td>
     135            <input type="checkbox" name="remove_job" value="1" <%=removeJobWhenFinished ? "checked" : "" %>>
     136            <a href="javascript:document.forms['plugin'].remove_job.click();">Remove job when finished</a>
     137          </td>
     138          <%
     139        }
     140        else
     141        {
     142          %>
     143          <td><i>- n/a -</i></td>
     144          <%
     145        }
     146        %>
     147      </tr>
     148           
    127149      </table>
    128150      <div align=right>&nbsp;<i><base:icon image="required.gif" /> = required information</i></div>
  • trunk/www/common/plugin/index.jsp

    r3438 r3480  
    475475    job.setDescription(Values.getStringOrNull(request.getParameter("description")));
    476476    job.setSendMessage(Values.getBoolean(request.getParameter("send_message")));
     477    job.setRemoveJobWhenFinished(Values.getBoolean(request.getParameter("remove_job")));
    477478    dc.saveItem(job);
    478479    if (pluginResponse != null) pluginResponse.saveParameters(dc);
  • trunk/www/my_base/user/preferences.jsp

    r3220 r3480  
    431431      </td>
    432432    </tr>
     433    <tr>
     434      <td class="prompt">Remove jobs</td>     
     435      <td>
     436        <%
     437        boolean removeJobWhenFinished = Values.getBoolean(sc.getUserClientSetting("plugins.removejob"), false);
     438        %>
     439        <input type="checkbox" name="removejob" value="1" <%=removeJobWhenFinished ? "checked" : "" %>>
     440        <a href="javascript:document.forms['preferences'].removejob.click();">Remove import and export jobs when they are finished.</a>
     441      </td>
     442    </tr>
    433443    </table>
    434444  </t:tab>
  • trunk/www/my_base/user/submit_user.jsp

    r3190 r3480  
    131131   
    132132    sc.setUserClientSetting("plugins.sendmessage", Values.getString(request.getParameter("sendmessage"), "0"));
     133    sc.setUserClientSetting("plugins.removejob", Values.getString(request.getParameter("removejob"), "0"));
    133134    String[] mostRecent = request.getParameterValues("enabled");
    134135    sc.setUserClientSetting("menu.mostRecent",
Note: See TracChangeset for help on using the changeset viewer.