agave-jobs/jobs-core/src/main/java/org/iplantc/service/jobs/dao/JobDao.java
/**
	 * Returns the number of jobs in an active state for a given user 
	 * on a given system. Active states are defined by 
	 * JobStatusType.getActiveStatuses().
	 * 
	 * @param username the user for whome to count active jobs
     * @param systemId The user-defined name of the system for which to count active jobs.
	 * @return the number of active jobs for {@code username} on the {@code systemId}}
	 * @throws JobException if unable to perform the query.
	 */
Returns the number of jobs in an active state for a given user
on a given system.

@param username the user for whome to count active jobs
@param systemId The user-defined name of the system for which to count active jobs.
@return the number of active jobs for  username on the  systemId}
@throws JobException if unable to perform the query.
Returns the number of jobs in an active state for a given user on a given system . @param username the user for whome to count active jobs @param systemId The user - defined name of the system for which to count active jobs . @return the number of active jobs for username on the systemId } @throws JobException if unable to perform the query .
public static long countActiveUserJobsOnSystem(String username, String systemId) throws JobException
	{
		try
		{
			Session session = getSession();
			session.clear();
			String hql = "select count(j.id) "
					+ "from Job j "
					+ "where j.owner = :jobowner "
					+ " 	and j.visible = :visible "
					+ "		and j.system = :jobsystem "
					+ "		and j.status in "
					+ "(" + JobStatusType.getActiveStatusValues() + ") ";
			long currentUserJobCount = (Long)session.createQuery(hql)
					.setBoolean("visible", true)
					.setString("jobowner",username)
					.setString("jobsystem", systemId)
					.uniqueResult();
			session.flush();
			return currentUserJobCount;
		}
		catch (HibernateException ex) {
			throw new JobException(ex);
		}
		finally {
			try { HibernateUtil.commitTransaction();} catch (Exception ignored) {}
		}
	}
public static long countActiveUserJobsOnSystem ( String username , String systemId ) throws JobException { try { Session session = getSession ( ) ; session . clear ( ) ; String hql = "select count(j.id) " + "from Job j " + "where j.owner = :jobowner " + " 	and j.visible = :visible " + "		and j.system = :jobsystem " + "		and j.status in " + "(" + JobStatusType . getActiveStatusValues ( ) + ") " ; long currentUserJobCount = ( Long ) session . createQuery ( hql ) . setBoolean ( "visible" , true ) . setString ( "jobowner" , username ) . setString ( "jobsystem" , systemId ) . uniqueResult ( ) ; session . flush ( ) ; return currentUserJobCount ; } catch ( HibernateException ex ) { throw new JobException ( ex ) ; } finally { try { HibernateUtil . commitTransaction ( ) ; } catch ( Exception ignored ) { } } }
Returns the number of jobs in an active state for a given user
 on a given system.
Returns the number of jobs in an active state for a given user on a given system .