agave-jobs/jobs-api/src/main/java/org/iplantc/service/jobs/resources/JobListAttributeResource.java
/**
	 * Returns a json array of jobs matching the key value pairs.
	 */
Returns a json array of jobs matching the key value pairs.
Returns a json array of jobs matching the key value pairs .
@Override
	public Representation represent(Variant variant) throws ResourceException
	{
		try {
			if (attribute == null) {
				getResponse().setStatus(Status.CLIENT_ERROR_BAD_REQUEST);
				return new IplantErrorRepresentation("Unknown job attribute");
			}
			try {
				JSONArray json = new JSONArray();
				List<Job> jobs = JobDao.getByUsername(getAuthenticatedUsername(), offset, limit, getSortOrder(AgaveResourceResultOrdering.ASC), getSortOrderSearchTerm());
				for (Job job : jobs) {
					JSONObject jsonJob = new JSONObject();
					jsonJob.put("id", job.getUuid());
					jsonJob.put(attribute, job.getValueForAttributeName(attribute));
					jsonJob.put("_links",
							new JSONObject().put("self",
									new JSONObject().put("href",
											TenancyHelper.resolveURLToCurrentTenant(Settings.IPLANT_JOB_SERVICE) + job.getUuid())));
					json.put(jsonJob);
				}
				return new IplantSuccessRepresentation(json.toString());
			} catch (Exception e) {
				log.error("Failed to search jobs by attribute " + attribute + " for user " + getAuthenticatedUsername(), e);
				getResponse().setStatus(Status.SERVER_ERROR_INTERNAL);
				return new IplantErrorRepresentation(e.getMessage());
			}
		}
		finally {
			try { HibernateUtil.closeSession(); } catch (Throwable ignored) {}
		}
	}
@ Override public Representation represent ( Variant variant ) throws ResourceException { try { if ( attribute == null ) { getResponse ( ) . setStatus ( Status . CLIENT_ERROR_BAD_REQUEST ) ; return new IplantErrorRepresentation ( "Unknown job attribute" ) ; } try { JSONArray json = new JSONArray ( ) ; List < Job > jobs = JobDao . getByUsername ( getAuthenticatedUsername ( ) , offset , limit , getSortOrder ( AgaveResourceResultOrdering . ASC ) , getSortOrderSearchTerm ( ) ) ; for ( Job job : jobs ) { JSONObject jsonJob = new JSONObject ( ) ; jsonJob . put ( "id" , job . getUuid ( ) ) ; jsonJob . put ( attribute , job . getValueForAttributeName ( attribute ) ) ; jsonJob . put ( "_links" , new JSONObject ( ) . put ( "self" , new JSONObject ( ) . put ( "href" , TenancyHelper . resolveURLToCurrentTenant ( Settings . IPLANT_JOB_SERVICE ) + job . getUuid ( ) ) ) ) ; json . put ( jsonJob ) ; } return new IplantSuccessRepresentation ( json . toString ( ) ) ; } catch ( Exception e ) { log . error ( "Failed to search jobs by attribute " + attribute + " for user " + getAuthenticatedUsername ( ) , e ) ; getResponse ( ) . setStatus ( Status . SERVER_ERROR_INTERNAL ) ; return new IplantErrorRepresentation ( e . getMessage ( ) ) ; } } finally { try { HibernateUtil . closeSession ( ) ; } catch ( Throwable ignored ) { } } }
Returns a json array of jobs matching the key value pairs.
Returns a json array of jobs matching the key value pairs .
//String json = "";