Changeset 4311


Ignore:
Timestamp:
May 23, 2008, 2:24:56 PM (15 years ago)
Author:
Nicklas Nordborg
Message:

Fixes #1024: Allow users to select a specific job-agent when creating a new job

Location:
trunk
Files:
20 edited

Legend:

Unmodified
Added
Removed
  • trunk/doc/src/docbook/admindoc/user_administration.xml

    r3944 r4311  
    848848              </listitem>
    849849            </varlistentry>
     850
     851            <varlistentry>
     852              <term>
     853                <guilabel>Select job agent for jobs</guilabel>
     854              </term>
     855              <listitem>
     856                <para>
     857                Allows the user to select a specific job agent when running jobs.
     858                Users without this permission will always have a randomly selected
     859                job agent.
     860                </para>
     861              </listitem>
     862            </varlistentry>
     863
    850864            <varlistentry>
    851865              <term>
  • trunk/doc/src/docbook/userdoc/jobs.xml

    r4309 r4311  
    245245          <varlistentry>
    246246            <term>
     247              <guilabel>Job agent</guilabel>
     248            </term>
     249            <listitem>
     250              <para>
     251                The job agent the job is/was running on. It is also
     252                possible to set this value before a job is executed. If that
     253                has been done only the selected job agent will accept the job.
     254                This options is normally only given to powers users and
     255                needs the <emphasis>Select job agent</emphasis> permission.
     256                See <xref linkend="user_administration.roles.edit" />.
     257              </para>
     258            </listitem>
     259          </varlistentry>
     260          <varlistentry>
     261            <term>
    247262              <guilabel>User/Owner</guilabel>
    248263            </term>
  • trunk/src/clients/jobagent/net/sf/basedb/clients/jobagent/JobRunner.java

    r3857 r4311  
    108108     
    109109      // Change the status to Job.Status.PREPARED
    110       j.setPrepared(agent.getServerName());
     110      j.setPrepared(agent.getServerName(), agent.getJobAgent(dc));
    111111      try
    112112      {
  • trunk/src/clients/jobagent/net/sf/basedb/clients/jobagent/executors/DummyJobExecutor.java

    r4093 r4311  
    9999      dc = sc.newDbControl();
    100100      job = Job.getById(dc, job.getId());
    101       job.start("Not really, but used for testing the job agent", agent.getServerName());
     101      job.start("Not really, but used for testing the job agent",
     102        agent.getServerName(), agent.getJobAgent(dc));
    102103      if (wait > 0)
    103104      {
  • trunk/src/core/common-queries.xml

    r4299 r4311  
    14241424    <description>
    14251425      A Hibernate query that loads plugin jobs in the job queue waiting to be
    1426       executed sorted by priority and waiting type.
     1426      executed sorted by priority and waiting type. The query should return all
     1427      jobs, ignoring all settings specifying that the internal job queue should
     1428      not be used.
    14271429    </description>
    14281430  </query>
     
    14351437      AND job.type = :type
    14361438      AND job.pluginDefinition.useInternalJobQueue = true
     1439      AND job.jobAgentId IS NULL
    14371440      ORDER BY job.priority ASC, job.created ASC
    14381441    </sql>
     
    14401443      A Hibernate query that loads plugin jobs in the job queue waiting to be
    14411444      executed sorted by priority and waiting type. It should only return
    1442       jobs where the plug-in setting useInternalJobQueue=true
     1445      jobs where the plug-in setting useInternalJobQueue=true and no
     1446      specific job agent has been selected for the job.
    14431447    </description>
    14441448  </query>
  • trunk/src/core/net/sf/basedb/core/Install.java

    r4299 r4311  
    107107    method.
    108108  */
    109   public static final int NEW_SCHEMA_VERSION = Integer.valueOf(56).intValue();
     109  public static final int NEW_SCHEMA_VERSION = Integer.valueOf(57).intValue();
    110110 
    111111  public static synchronized void createTables(boolean update, final ProgressReporter progress)
     
    302302     
    303303      HashMap<RoleData, Integer> systemPermissions = new HashMap<RoleData, Integer>();
    304       systemPermissions.put(roleAdmin, Permission.grant(Permission.SHARE_TO_EVERYONE));
    305       systemPermissions.put(rolePower, Permission.grant(Permission.SHARE_TO_EVERYONE));
     304      systemPermissions.put(roleAdmin, Permission.grant(Permission.SHARE_TO_EVERYONE, Permission.SELECT_JOBAGENT));
     305      systemPermissions.put(rolePower, Permission.grant(Permission.SHARE_TO_EVERYONE, Permission.SELECT_JOBAGENT));
    306306     
    307307      // System permissions
     
    392392        agentPermissions.put(Item.JOBAGENT, PERMISSION_READ | PERMISSION_CREATE);
    393393        agentPermissions.put(Item.MESSAGE, PERMISSION_CREATE);
    394         agentPermissions.put(Item.SYSTEM, Permission.grant(Permission.ACT_AS_ANOTHER_USER));
     394        agentPermissions.put(Item.SYSTEM, Permission.grant(Permission.ACT_AS_ANOTHER_USER, Permission.SELECT_JOBAGENT));
    395395        addRolePermissions(roleJobAgent, agentPermissions);
    396396      }
     
    17991799    }
    18001800  }
    1801 
     1801 
    18021802  /**
    18031803    Create an {@link ItemKey}.
  • trunk/src/core/net/sf/basedb/core/InternalJobQueue.java

    r4265 r4311  
    452452       
    453453        // Change the status to Job.Status.PREPARED
    454         job.setPrepared(Application.getHostName());
     454        job.setPrepared(Application.getHostName(), null);
    455455        try
    456456        {
  • trunk/src/core/net/sf/basedb/core/Job.java

    r4257 r4311  
    672672 
    673673  /**
     674    Get the job agent this job should run on, is running on or
     675    was running on.
     676    @return A job agent or null if not known
     677    @since 2.8
     678  */
     679  public JobAgent getJobAgent()
     680  {
     681    Integer id = getData().getJobAgentId();
     682    JobAgent agent = null;
     683    if (id != null)
     684    {
     685      try
     686      {
     687        agent = JobAgent.getById(getDbControl(), id);
     688      }
     689      catch (ItemNotFoundException ex)
     690      {}
     691    }
     692    return agent;
     693  }
     694 
     695  /**
     696    Set the job agent this job should run on. If the job is already
     697    running or has ended, this call is ignored.
     698    <p>
     699    NOTE! This method doesn't check that the specified job agent
     700    has actually been configured to run the plug-in used by this job.
     701    Setting this parameter to an incorrect value may result in the
     702    job never being executed.
     703   
     704    @param agent The job agent, or null to let any job agent run
     705      the job
     706    @throws PermissionDeniedException If the logged in user doesn't
     707      have write permission on this job, or use permission on the
     708      job agent or is lacking the {@link Permission#SELECT_JOBAGENT}
     709      permission
     710    @since 2.8
     711  */
     712  public void setJobAgent(JobAgent agent)
     713  {
     714    Job.Status status = getStatus();
     715    if (status != Job.Status.WAITING) return;
     716    checkPermission(Permission.WRITE);
     717    if (agent != null)
     718    {
     719      if (!getSessionControl().hasSystemPermission(Permission.SELECT_JOBAGENT))
     720      {
     721        throw new PermissionDeniedException(Permission.SELECT_JOBAGENT);
     722      }
     723      agent.checkPermission(Permission.USE);
     724    }
     725    getData().setJobAgentId(agent == null ? null : agent.getId());
     726  }
     727 
     728  /**
    674729    Set information needed to create a signal transporter object that can be used
    675730    to send signals to the plug-in that is currently executing this job.
     
    759814
    760815  /**
     816    @deprecated Use {@link #setPrepared(String, JobAgent)} instead
     817  */
     818  public void setPrepared(String server)
     819    throws PermissionDeniedException
     820  {
     821    setPrepared(server, null);
     822  }
     823 
     824  /**
    761825    Set the job's status to {@link Status#PREPARED}. This status is
    762     used to signal that a job is about to be executed, but the actual exception
     826    used to signal that a job is about to be executed, but the actual excecution
    763827    hasn't started yet. This status prevents two job agents from trying to
    764828    start the same job twice.
    765     @param server Name of the server which this job will executed on.
     829   
     830    @param server Name of the server which this job will executed on
     831    @param agent The job agent that is going to execute the
     832      job or null if it is executed by something else, eg. the
     833      internal job queue
    766834    @throws PermissionDeniedException If the logged in user doesn't have write permission.
    767   */
    768   public void setPrepared(String server)
     835    @since 2.8
     836  */
     837  public void setPrepared(String server, JobAgent agent)
    769838    throws PermissionDeniedException
    770839  {
     
    778847    data.setStatus(Status.PREPARED.getValue());
    779848    data.setServer(StringUtil.setNullableString(server, "server", MAX_SERVER_LENGTH));
    780   }
    781  
    782   /**
    783     Register the job as started. Note! This method doesn't start the actual
     849    getData().setJobAgentId(agent == null ? null : agent.getId());
     850  }
     851
     852  /**
     853    @deprecated Use {@link #start(String, String, JobAgent)} instead
     854  */
     855  public void start(String statusMessage, String server)
     856    throws PermissionDeniedException, InvalidDataException
     857  {
     858    start(statusMessage, server, null);
     859  }
     860 
     861  /**
     862    Register the job as started. Note! This method doesn't start the actual
    784863    execution of the job. This method should be called by an job runner application
    785864    to tell the core that the job runner has started to execute the job.
     
    788867    @param statusMessage A message
    789868    @param server The name of the server where the job is started
     869    @param agent The job agent that is going to execute the
     870      job or null if it is executed by something else, eg. the
     871      internal job queue
    790872    @throws PermissionDeniedException If the logged in user doesn't have
    791873      write permission
    792874    @throws InvalidDataException If the status message is too long
    793   */
    794   public void start(String statusMessage, String server)
     875    @since 2.8
     876   */
     877  public void start(String statusMessage, String server, JobAgent agent)
    795878    throws PermissionDeniedException, InvalidDataException
    796879  {
     
    802885    data.setStarted(new Date());
    803886    data.setPercentComplete(0);
    804   }
    805  
     887    data.setJobAgentId(agent == null ? null : agent.getId());
     888  }
     889
    806890  /**
    807891    Get a progress reporter that reports progress by updating the information
     
    815899  public ProgressReporter getProgressReporter(ProgressReporter chained)
    816900  {
    817     return new ProgressReporterImpl(this, null, chained);
     901    return new ProgressReporterImpl(this, null, null, chained);
    818902  }
    819903 
     
    9411025    data.setStackTrace(null);
    9421026    data.setServer(null);
     1027    data.setJobAgentId(null);
    9431028    if (useLatestConfiguration)
    9441029    {
     
    9921077        this, parameters, context, pd, pd.getAllowImmediateExecution()
    9931078      );
    994     request.setProgressReporter(new ProgressReporterImpl(this, null, null));
     1079    request.setProgressReporter(new ProgressReporterImpl(this, null, null, null));
    9951080    return request;
    9961081  }
     
    10521137    PluginConfiguration config = getPluginConfiguration();
    10531138    Plugin plugin = pd.newInstance(settings == null ? null : settings.getJarPath());
     1139    JobAgent agent = settings == null ? null : settings.getJobAgent();
    10541140    SessionControl sc = getSessionControl();
    10551141    ParameterValuesImpl parameters = new ParameterValuesImpl(this, true);
    1056     ProgressReporterImpl jobProgress = new ProgressReporterImpl(this, server, progress);
     1142    ProgressReporterImpl jobProgress =
     1143      new ProgressReporterImpl(this, server, agent, progress);
    10571144   
    10581145    PluginExecutionRequest request =
     
    13731460    private final String server;
    13741461    private final Job job;
     1462    private final JobAgent agent;
    13751463    private final ProgressReporter chained;
    13761464    private long lastUpdate;
     
    13791467    private int offset;
    13801468   
    1381     ProgressReporterImpl(Job job, String server, ProgressReporter chained)
     1469    ProgressReporterImpl(Job job, String server, JobAgent agent, ProgressReporter chained)
    13821470      throws BaseException
    13831471    {
     
    13861474      this.jobId = job.getId();
    13871475      this.server = server;
     1476      this.agent = agent;
    13881477      this.chained = chained;
    13891478      this.lastUpdate = 0;
     
    15011590          job.setSignalTransporter(signalTransporter, signalId);
    15021591        }
    1503         job.start("Starting...", server);
     1592        job.start("Starting...", server, agent);
    15041593        dc.commit();
    15051594      }
  • trunk/src/core/net/sf/basedb/core/JobAgent.java

    r4034 r4311  
    391391      AND (job.owner IN (:sharedToUsers) OR job.activeProjectId IN (:sharedToProjects)
    392392      AND job.status = Job.Status.WAITING
     393      AND job.jobAgentId IS NULL OR job.jobAgentId = this.id
    393394      ORDER BY job.priority - jas.priorityBoost ASC, job.created ASC
    394395    */
     
    483484        Hql.property("status"),
    484485        Expressions.integer(Job.Status.WAITING.getValue())
     486      )
     487    );
     488   
     489    // Filter out jobs that have been marked for other job agents
     490    // jobAgentId = this.id OR jobAgentId IS NULL
     491    query.restrictPermanent(
     492      Restrictions.or(
     493        Restrictions.eq(
     494          Hql.property("jobAgentId"),
     495          Expressions.integer(getId())
     496        ),
     497        Restrictions.eq(Hql.property("jobAgentId"), null)
    485498      )
    486499    );
  • trunk/src/core/net/sf/basedb/core/Permission.java

    r3679 r4311  
    126126    item.
    127127  */
    128   ACT_AS_ANOTHER_USER(1024, 1024, "act as another user");
     128  ACT_AS_ANOTHER_USER(1024, 1024, "act as another user"),
     129
     130  /**
     131    This permission allows a user to specify which job agent
     132    a job should be executed on using {@link Job#setJobAgent(JobAgent)}.
     133    This is a system permission and is only meaningful for the role key
     134    for the {@link Item#SYSTEM} item.
     135    @since 2.8
     136  */
     137  SELECT_JOBAGENT(2048, 2048, "select job agent");
    129138
    130139  private final int grantValue;
     
    299308  }
    300309
     310  /**
     311    Merges a list of integer permission values.
     312    @param permissions The permission values, null values are ignored
     313    @return The combined permissions
     314    @since 2.8
     315  */
     316  static int merge(Integer... permissions)
     317  {
     318    int perm = 0;
     319    for (Integer i : permissions)
     320    {
     321      if (i != null) perm |= i;
     322    }
     323    return perm;
     324  }
     325 
    301326}
    302327
  • trunk/src/core/net/sf/basedb/core/PluginResponse.java

    r4040 r4311  
    126126      throw new PermissionDeniedException("Can't execute immediately since response status is: " + getStatus());
    127127    }
    128     ProgressReporterImpl jobProgress = new ProgressReporterImpl(request.getJob(), Application.getHostName(), progress);
     128    ProgressReporterImpl jobProgress = new ProgressReporterImpl(request.getJob(), Application.getHostName(), null, progress);
    129129    PluginExecutionRequest executionRequest = new PluginExecutionRequest(request, Request.COMMAND_EXECUTE);
    130130    executionRequest.setProgressReporter(jobProgress);
  • trunk/src/core/net/sf/basedb/core/Update.java

    r4299 r4311  
    5353import net.sf.basedb.core.data.ProjectData;
    5454import net.sf.basedb.core.data.RawBioAssayData;
     55import net.sf.basedb.core.data.RoleData;
     56import net.sf.basedb.core.data.RoleKeyData;
    5557import net.sf.basedb.core.data.SchemaVersionData;
    5658import net.sf.basedb.core.data.TransformationData;
     
    642644      The update needs to calculate the number of reporters in existing
    643645      lists.
     646    </td>
     647  </tr>
     648 
     649  <tr>
     650    <td>57</td>
     651    <td>
     652      <ul>
     653      <li>Added {@link net.sf.basedb.core.data.JobData#getJobAgentId()}.
     654      </ul>
     655      The update grants {@link Permission#SELECT_JOBAGENT} to the
     656      administrators, power users and job agent roles.
    644657    </td>
    645658  </tr>
     
    906919        if (progress != null) progress.display((int)(55*progress_factor), "--Updating schema version: " + schemaVersion + " -> 56...");
    907920        schemaVersion = updateToSchemaVersion56(session);
     921      }
     922     
     923      if (schemaVersion < 57)
     924      {
     925        if (progress != null) progress.display((int)(56*progress_factor), "--Updating schema version: " + schemaVersion + " -> 57...");
     926        schemaVersion = updateToSchemaVersion57(session);
    908927      }
    909928     
     
    22322251    return schemaVersion;
    22332252  }
     2253 
     2254  /**
     2255    Grant {@link Permission#SELECT_JOBAGENT} permission to
     2256    administrators, power users and job agent roles.
     2257   
     2258    @return The new schema version (=57)
     2259  */
     2260  private static int updateToSchemaVersion57(org.hibernate.Session session)
     2261    throws BaseException
     2262  {
     2263    final int schemaVersion = 57;
     2264    org.hibernate.Transaction tx = null;
     2265    try
     2266    {
     2267      tx = HibernateUtil.newTransaction(session);
     2268     
     2269      int selectPermission = Permission.SELECT_JOBAGENT.grantValue();
     2270     
     2271      RoleData admin = HibernateUtil.loadData(session, RoleData.class, SystemItems.getId(Role.ADMINISTRATOR));
     2272      RoleData power = HibernateUtil.loadData(session, RoleData.class, SystemItems.getId(Role.POWER_USER));
     2273      RoleData agent = HibernateUtil.loadData(session, RoleData.class, SystemItems.getId(Role.JOBAGENT));
     2274      RoleKeyData systemKey = HibernateUtil.loadData(session, RoleKeyData.class,
     2275          SystemItems.getRoleKeyId(Item.SYSTEM));
     2276     
     2277      Map<RoleData, Integer> rolePermissions = systemKey.getRoles();
     2278      rolePermissions.put(admin, Permission.merge(selectPermission, rolePermissions.get(admin)));
     2279      rolePermissions.put(power, Permission.merge(selectPermission, rolePermissions.get(power)));
     2280      rolePermissions.put(agent, Permission.merge(selectPermission, rolePermissions.get(agent)));
     2281
     2282      // Update the schema version number
     2283      setSchemaVersion(session, schemaVersion);
     2284 
     2285      // Commit the changes
     2286      HibernateUtil.commit(tx);
     2287      log.info("updateToSchemaVersion57: OK");
     2288    }
     2289    catch (BaseException ex)
     2290    {
     2291      if (tx != null) HibernateUtil.rollback(tx);
     2292      log.error("updateToSchemaVersion57: FAILED", ex);
     2293      throw ex;
     2294    }
     2295    return schemaVersion;
     2296  }
     2297 
    22342298  /**
    22352299    Adjust the existing items in the database to be compatible with the latest mappings.
  • trunk/src/core/net/sf/basedb/core/data/JobData.java

    r4074 r4311  
    378378  }
    379379 
     380  private Integer jobAgentId;
     381  /**
     382    The ID of the job agent this job should run/is running/was running on.
     383    We store this as an ID value only and not a reference to {@link JobAgentData}
     384    since it would then be impossible to delete a job agent without also deleting
     385    all jobs that has been running on it.
     386    @since 2.8
     387    @hibernate.property column="`jobagent_id`" type="int" not-null="false"
     388  */
     389  public Integer getJobAgentId()
     390  {
     391    return jobAgentId;
     392  }
     393  public void setJobAgentId(Integer jobAgentId)
     394  {
     395    this.jobAgentId = jobAgentId;
     396  }
     397 
    380398  private Map<String, ParameterValueData<?>> parameters;
    381399  /**
  • trunk/www/admin/roles/edit_role.jsp

    r3890 r4311  
    137137  final boolean hasShareToEveryone = role == null ? false : system.getPermissions(role).contains(Permission.SHARE_TO_EVERYONE);
    138138  final boolean hasActAsAnotherUser = role == null ? false : system.getPermissions(role).contains(Permission.ACT_AS_ANOTHER_USER);
     139  final boolean hasSelectJobagent = role == null ? false : system.getPermissions(role).contains(Permission.SELECT_JOBAGENT);
    139140 
    140141  // Query to retrieve role keys
     
    187188        if (frm.share_to_everyone.checked) systemPermission += <%=PermissionUtil.getPermissionCode(EnumSet.of(Permission.SHARE_TO_EVERYONE))%>;
    188189        if (frm.act_as_another_user.checked) systemPermission += <%=PermissionUtil.getPermissionCode(EnumSet.of(Permission.ACT_AS_ANOTHER_USER))%>;
     190        if (frm.select_jobagent.checked) systemPermission += <%=PermissionUtil.getPermissionCode(EnumSet.of(Permission.SELECT_JOBAGENT))%>;
    189191        frm['<%=Item.SYSTEM.name()%>'].value = systemPermission;
    190192        frm.submit();
     
    366368          <input type="checkbox" value="1" name="act_as_another_user"
    367369            <%=hasActAsAnotherUser ? "checked" : ""%>
    368             >Act as another user
     370            >Act as another user<br>
     371          <input type="checkbox" value="1" name="select_jobagent"
     372            <%=hasSelectJobagent ? "checked" : ""%>
     373            >Select job agent for jobs<br>
    369374        </td>
    370375      </tr>
  • trunk/www/admin/roles/view_role.jsp

    r4003 r4311  
    9292  final boolean hasShareToEveryone = system.getPermissions(role).contains(Permission.SHARE_TO_EVERYONE);
    9393  final boolean hasActAsAnotherUser = system.getPermissions(role).contains(Permission.ACT_AS_ANOTHER_USER);
     94  final boolean hasSelectJobagent = system.getPermissions(role).contains(Permission.SELECT_JOBAGENT);
    9495 
    9596  final boolean writePermission = role.hasPermission(Permission.WRITE);
     
    252253          <td class="prompt">Share to everyone</td>
    253254          <td><%=hasShareToEveryone ? "yes" : "no"%></td>
     255          <td class="prompt">Select job agent</td>
     256          <td><%=hasSelectJobagent ? "yes" : "no"%></td>
    254257        </tr>
    255258        <tr>
  • trunk/www/common/plugin/finish_job.jsp

    r3675 r4311  
    3636  import="net.sf.basedb.core.ItemResultList"
    3737  import="net.sf.basedb.core.Include"
     38  import="net.sf.basedb.core.Permission"
    3839  import="net.sf.basedb.core.Job"
     40  import="net.sf.basedb.core.JobAgent"
     41  import="net.sf.basedb.core.PluginResponse"
    3942  import="net.sf.basedb.core.query.Hql"
    4043  import="net.sf.basedb.core.query.Expressions"
     
    4346  import="net.sf.basedb.core.plugin.GuiContext"
    4447  import="net.sf.basedb.core.plugin.Plugin"
     48  import="net.sf.basedb.core.plugin.Response"
    4549  import="net.sf.basedb.core.plugin.InteractivePlugin"
    4650  import="net.sf.basedb.core.plugin.AutoDetectingImporter"
     
    6367  Job job = (Job)sc.getSessionSetting("plugin.configure.job");
    6468  dc.reattachItem(job);
    65   PluginDefinition plugin = job.getPluginDefinition(); //(PluginDefinition)sc.getSessionSetting("plugin.configure.plugin");
    66   PluginConfiguration pluginConfig = job.getPluginConfiguration(); // (PluginConfiguration)sc.getSessionSetting("plugin.configure.config");
     69  PluginDefinition plugin = job.getPluginDefinition();
     70  PluginConfiguration pluginConfig = job.getPluginConfiguration();
    6771  boolean sendMessage = Values.getBoolean(sc.getUserClientSetting("plugins.sendmessage"), true);
    6872  boolean removeJobWhenFinished = Values.getBoolean(sc.getUserClientSetting("plugins.removejob"), false);
     73
     74  PluginResponse pluginResponse = (PluginResponse)sc.getSessionSetting("plugin.configure.response");
     75  boolean executeImmediately =
     76    pluginResponse != null && pluginResponse.getStatus() == Response.Status.EXECUTE_IMMEDIATELY;
     77
     78  List<JobAgent> agents = null;
     79  if (!executeImmediately && sc.hasSystemPermission(Permission.SELECT_JOBAGENT))
     80  {
     81    ItemQuery<JobAgent> agentQuery = JobAgent.getQuery();
     82    agentQuery.join(Hql.innerJoin("plugins", "plg"));
     83    agentQuery.restrict(Restrictions.eq(Hql.index("plg", null), Hql.entity(plugin)));
     84    agentQuery.include(Include.ALL);
     85    agentQuery.order(Orders.asc(Hql.property("name")));
     86    agents = agentQuery.list(dc);
     87  }
    6988  %>
    7089  <base:page type="popup" title="Set job name and options">
     
    112131        </td>
    113132      </tr>
     133     
     134      <%
     135      if (agents != null && agents.size() > 0)
     136      {
     137        %>
     138        <tr valign="top">
     139          <td class="prompt">Use job agent</td>
     140          <td>
     141            <select name="agent_id">
     142            <option value="">- automatic -
     143            <%
     144            for (JobAgent agent : agents)
     145            {
     146              %>
     147              <option value="<%=agent.getId()%>"><%=HTML.encodeTags(agent.getName())%>
     148              <%
     149            }
     150            %>
     151            </select>
     152          </td>
     153        </tr>
     154        <%
     155      }
     156      %>
     157     
    114158      <tr valign="top">
    115159        <td class="prompt">Job description</td>
  • trunk/www/common/plugin/index.jsp

    r4265 r4311  
    5151  import="net.sf.basedb.core.Path"
    5252  import="net.sf.basedb.core.Job"
     53  import="net.sf.basedb.core.JobAgent"
    5354  import="net.sf.basedb.core.Type"
    5455  import="net.sf.basedb.core.Experiment"
     
    517518    Job job = (Job)sc.getSessionSetting("plugin.configure.job");
    518519    PluginResponse pluginResponse = (PluginResponse)sc.getSessionSetting("plugin.configure.response");
     520    boolean executeImmediately =
     521      pluginResponse != null && pluginResponse.getStatus() == Response.Status.EXECUTE_IMMEDIATELY;
    519522
    520523    job.setName(Values.getStringOrNull(request.getParameter("name")));
     
    523526    job.setRemoveJobWhenFinished(Values.getBoolean(request.getParameter("remove_job")));
    524527    dc.saveItem(job);
     528   
     529    if (!executeImmediately)
     530    {
     531      int agentId = Values.getInt(request.getParameter("agent_id"), -1);
     532      if (agentId >= 0)
     533      {
     534        job.setJobAgent(agentId == 0 ? null : JobAgent.getById(dc, agentId));
     535      }
     536    }
     537   
    525538    if (pluginResponse != null) pluginResponse.saveParameters(dc);
    526539    dc.commit();
     
    532545    sc.setSessionSetting("plugin.configure.config", null);
    533546    sc.setSessionSetting("plugin.configure.currentContext", null);
    534     if (pluginResponse != null && pluginResponse.getStatus() == Response.Status.EXECUTE_IMMEDIATELY)
     547    if (executeImmediately)
    535548    {
    536549      PluginExecutionRequest executionRequest = pluginResponse.getExecutionRequest(null);
  • trunk/www/include/scripts/main.js

    r4302 r4311  
    398398    this.controllers['BIOASSAYSET'] = { url:'views/experiments/bioassaysets/index.jsp', width:800, height:500 };
    399399    this.controllers['TRANSFORMATION'] = { url:'views/experiments/transformations/index.jsp', width:500, height:300 };
    400     this.controllers['JOB'] = { url:'views/jobs/index.jsp', width:600, height:440, popup:true, edit:false };
     400    this.controllers['JOB'] = { url:'views/jobs/index.jsp', width:640, height:480, popup:true, edit:false };
    401401    this.controllers['FORMULA'] = { url:'views/formulas/index.jsp', width:740, height:500 };
    402402    this.controllers['HYBRIDIZATION'] = { url:'views/hybridizations/index.jsp', width:800, height:500 };
  • trunk/www/views/jobs/list_jobs.jsp

    r4003 r4311  
    3131  import="net.sf.basedb.core.Item"
    3232  import="net.sf.basedb.core.Job"
     33  import="net.sf.basedb.core.JobAgent"
    3334  import="net.sf.basedb.core.ItemQuery"
    3435  import="net.sf.basedb.core.Include"
     
    4041  import="net.sf.basedb.core.PermissionDeniedException"
    4142  import="net.sf.basedb.core.query.Hql"
     43  import="net.sf.basedb.core.query.Orders"
    4244  import="net.sf.basedb.core.query.Restrictions"
    4345  import="net.sf.basedb.core.query.Expressions"
     
    9496try
    9597{
     98 
     99  // Get all job agents
     100  final ItemQuery<JobAgent> agentQuery = JobAgent.getQuery();
     101  agentQuery.include(Include.ALL);
     102  agentQuery.order(Orders.asc(Hql.property("name")));
     103  agentQuery.setCacheResult(true);
     104  Enumeration<String, String> agents = new Enumeration<String, String>();
     105  for (JobAgent a : agentQuery.list(dc))
     106  {
     107    agents.add(Integer.toString(a.getId()), a.getName());
     108  }
     109 
    96110  Map<Plugin.MainType, Integer> pluginCount = PluginDefinition.countPlugins(dc, guiContext);
    97111  try
     
    277291        filterable="true"
    278292        exportable="true"
     293      />
     294      <tbl:columndef
     295        id="jobagent"
     296        property="jobAgentId"
     297        datatype="int"
     298        title="Job agent"
     299        filterable="true"
     300        enumeration="<%=agents%>"
    279301      />
    280302      <tbl:columndef
     
    497519                readPlugin = false;
    498520              }
     521              JobAgent agent = null;
     522              boolean readAgent = true;
     523              try
     524              {
     525                agent = item.getJobAgent();
     526              }
     527              catch (PermissionDeniedException ex)
     528              {
     529                readAgent = false;
     530              }
    499531              %>
    500532              <tbl:row>
     
    545577                <tbl:cell column="stackTrace"><%=HTML.encodeTags(item.getStackTrace())%></tbl:cell>
    546578                <tbl:cell column="server"><%=HTML.encodeTags(item.getServer())%></tbl:cell>
     579                <tbl:cell column="jobagent"><%=Base.getLinkedName(ID, agent, !readAgent, true)%></tbl:cell>
    547580                <tbl:cell column="estimatedExecutionTime"><%=item.getEstimatedExecutionTime()%></tbl:cell>
    548581                <tbl:cell column="percentComplete">
  • trunk/www/views/jobs/view_job.jsp

    r4127 r4311  
    3535  import="net.sf.basedb.core.Permission"
    3636  import="net.sf.basedb.core.Job"
     37  import="net.sf.basedb.core.JobAgent"
    3738  import="net.sf.basedb.core.BasicItem"
    3839  import="net.sf.basedb.core.Nameable"
     
    9798    readCurrentConfig = false;
    9899  }
     100  boolean readAgent = true;
     101  JobAgent agent = null;
     102  try
     103  {
     104    agent = job.getJobAgent();
     105  }
     106  catch (PermissionDeniedException ex)
     107  {
     108    readAgent = false;
     109  }
    99110
    100111  int parameterVersion = job.getParameterVersion();
     
    174185  <base:body onload="autoUpdate()">
    175186    <h3 class="docked"><%=title%> <base:help tabcontrol="main" /></h3>
    176     <t:tabcontrol id="main" active="<%=tab%>" position="bottom" contentstyle="<%="height: "+(int)(scale*320)+"px;"%>">
     187    <t:tabcontrol id="main" active="<%=tab%>" position="bottom" contentstyle="<%="height: "+(int)(scale*350)+"px;"%>">
    177188    <t:tab id="properties" title="Properties" helpid="job.view.properties">
    178189
     
    287298          <%=HTML.encodeTags(job.getServer())%>
    288299        </td>
     300      </tr>
     301      <tr valign="top">
     302        <td class="prompt">Job agent</td>
     303        <td><%=Base.getEncodedName(agent, !readAgent)%></td>
    289304      </tr>
    290305      <tr valign="top">
Note: See TracChangeset for help on using the changeset viewer.