agave-jobs/jobs-api/src/main/java/org/iplantc/service/jobs/resources/JobSearchResource.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
		{
			List<JobDTO> jobs = JobDao.findMatching(getAuthenticatedUsername(), new JobSearchFilter().filterCriteria(queryParameters), offset, limit);
			ObjectMapper mapper = new ObjectMapper();
			if (hasJsonPathFilters()) {
				return new IplantSuccessRepresentation(mapper.writeValueAsString(jobs));
			}
			else {
				JSONWriter writer = new JSONStringer();
				writer.array();
				for(JobDTO job: jobs)
				{
					writer.object()
						.key("id").value(job.getUuid())
						.key("name").value(job.getName())
						.key("owner").value(job.getOwner())
						.key("executionSystem").value(job.getExecution_system())
						.key("appId").value(job.getSoftware_name())
						.key("created").value(new DateTime(job.getCreated()).toString())
						.key("status").value(job.getStatus())
						.key("startTime").value(job.getStart_time() == null ? null : new DateTime(job.getStart_time()).toString())
						.key("endTime").value(job.getEnd_time() == null ? null : new DateTime(job.getEnd_time()).toString())
						.key("_links").object()
				        	.key("self").object()
				        		.key("href").value(TenancyHelper.resolveURLToCurrentTenant(Settings.IPLANT_JOB_SERVICE) + job.getUuid())
					        .endObject()
					        .key("archiveData").object()
			        			.key("href").value(TenancyHelper.resolveURLToCurrentTenant(job.getArchiveUrl()))
					        .endObject()
				       .endObject()
			        .endObject();
				}
				writer.endArray();
				return new IplantSuccessRepresentation(writer.toString());
			}
		}
		catch (Exception e)
		{
			log.error("Failed to perform search for jobs", 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 { List < JobDTO > jobs = JobDao . findMatching ( getAuthenticatedUsername ( ) , new JobSearchFilter ( ) . filterCriteria ( queryParameters ) , offset , limit ) ; ObjectMapper mapper = new ObjectMapper ( ) ; if ( hasJsonPathFilters ( ) ) { return new IplantSuccessRepresentation ( mapper . writeValueAsString ( jobs ) ) ; } else { JSONWriter writer = new JSONStringer ( ) ; writer . array ( ) ; for ( JobDTO job : jobs ) { writer . object ( ) . key ( "id" ) . value ( job . getUuid ( ) ) . key ( "name" ) . value ( job . getName ( ) ) . key ( "owner" ) . value ( job . getOwner ( ) ) . key ( "executionSystem" ) . value ( job . getExecution_system ( ) ) . key ( "appId" ) . value ( job . getSoftware_name ( ) ) . key ( "created" ) . value ( new DateTime ( job . getCreated ( ) ) . toString ( ) ) . key ( "status" ) . value ( job . getStatus ( ) ) . key ( "startTime" ) . value ( job . getStart_time ( ) == null ? null : new DateTime ( job . getStart_time ( ) ) . toString ( ) ) . key ( "endTime" ) . value ( job . getEnd_time ( ) == null ? null : new DateTime ( job . getEnd_time ( ) ) . toString ( ) ) . key ( "_links" ) . object ( ) . key ( "self" ) . object ( ) . key ( "href" ) . value ( TenancyHelper . resolveURLToCurrentTenant ( Settings . IPLANT_JOB_SERVICE ) + job . getUuid ( ) ) . endObject ( ) . key ( "archiveData" ) . object ( ) . key ( "href" ) . value ( TenancyHelper . resolveURLToCurrentTenant ( job . getArchiveUrl ( ) ) ) . endObject ( ) . endObject ( ) . endObject ( ) ; } writer . endArray ( ) ; return new IplantSuccessRepresentation ( writer . toString ( ) ) ; } } catch ( Exception e ) { log . error ( "Failed to perform search for jobs" , 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 .
//				Job job = jobs.get(i);