agave-jobs/jobs-core/src/main/java/org/iplantc/service/jobs/model/Job.java
/**
	 * Serializes to json with notifications embedded in hypermedia response.
	 * @param notifications
	 * @return
	 * @throws IOException 
	 */
Serializes to json with notifications embedded in hypermedia response.
@param notifications
@return
@throws IOException
Serializes to json with notifications embedded in hypermedia response . @param notifications @return @throws IOException
public String toJsonWithNotifications(List<Notification> notifications)
	throws IOException
	{
		ObjectMapper mapper = new ObjectMapper();
		ArrayNode notifArray = mapper.createArrayNode();
		if (notifications != null) {
			String baseNotificationUrl = TenancyHelper.resolveURLToCurrentTenant(Settings.IPLANT_NOTIFICATION_SERVICE);
			for(Notification n: notifications) {
				notifArray.add(mapper.createObjectNode()
						.put("href", baseNotificationUrl + n.getUuid())
						.put("title", n.getEvent()));
			}
		}
		ObjectNode hypermedia = getHypermedia();
		hypermedia.put("notification", notifArray);
		ObjectNode json = mapper.createObjectNode()
			.put("id", uuid)
			.put("name", name)
			.put("owner", owner)
			.put("appId", softwareName)
			.put("executionSystem", system)
			.put("batchQueue", batchQueue)
			.put("nodeCount", nodeCount)
			.put("processorsPerNode", processorsPerNode)
			.put("memoryPerNode", memoryPerNode)
			.put("maxRunTime", maxRunTime)
			.put("archive", archiveOutput)
			.put("retries", retries)
			.put("localId", localJobId)
			.put("executionType", executionType.name())
			.put("schedulerType", schedulerType.name())
			.put("created", new DateTime(created).toString())
			.put("lastModified", new DateTime(lastUpdated).toString());
		if (archiveOutput)
		{
			json.put("archivePath", getArchivePath());
			json.put("archiveSystem", getArchiveSystem().getSystemId());
		}
		json.put("outputPath", getWorkPath());
		json.put("status", status.name());
		if (status.equals(JobStatusType.FAILED))
		{
			json.put("message", getErrorMessage());
		}
		json.put("submitTime", submitTime == null ? null : new DateTime(getSubmitTime()).toString());
		json.put("startTime", startTime == null ? null : new DateTime(getStartTime()).toString());
		json.put("endTime", endTime == null ? null : new DateTime(getEndTime()).toString());
		try {
			json.set("inputs", getInputsAsJsonObject());
			json.set("parameters", getParametersAsJsonObject());
		} catch (JobException e) {
			throw new IOException(e.getMessage(), e);
		}
		json.set("_links", hypermedia);
		return json.toString();
	}
public String toJsonWithNotifications ( List < Notification > notifications ) throws IOException { ObjectMapper mapper = new ObjectMapper ( ) ; ArrayNode notifArray = mapper . createArrayNode ( ) ; if ( notifications != null ) { String baseNotificationUrl = TenancyHelper . resolveURLToCurrentTenant ( Settings . IPLANT_NOTIFICATION_SERVICE ) ; for ( Notification n : notifications ) { notifArray . add ( mapper . createObjectNode ( ) . put ( "href" , baseNotificationUrl + n . getUuid ( ) ) . put ( "title" , n . getEvent ( ) ) ) ; } } ObjectNode hypermedia = getHypermedia ( ) ; hypermedia . put ( "notification" , notifArray ) ; ObjectNode json = mapper . createObjectNode ( ) . put ( "id" , uuid ) . put ( "name" , name ) . put ( "owner" , owner ) . put ( "appId" , softwareName ) . put ( "executionSystem" , system ) . put ( "batchQueue" , batchQueue ) . put ( "nodeCount" , nodeCount ) . put ( "processorsPerNode" , processorsPerNode ) . put ( "memoryPerNode" , memoryPerNode ) . put ( "maxRunTime" , maxRunTime ) . put ( "archive" , archiveOutput ) . put ( "retries" , retries ) . put ( "localId" , localJobId ) . put ( "executionType" , executionType . name ( ) ) . put ( "schedulerType" , schedulerType . name ( ) ) . put ( "created" , new DateTime ( created ) . toString ( ) ) . put ( "lastModified" , new DateTime ( lastUpdated ) . toString ( ) ) ; if ( archiveOutput ) { json . put ( "archivePath" , getArchivePath ( ) ) ; json . put ( "archiveSystem" , getArchiveSystem ( ) . getSystemId ( ) ) ; } json . put ( "outputPath" , getWorkPath ( ) ) ; json . put ( "status" , status . name ( ) ) ; if ( status . equals ( JobStatusType . FAILED ) ) { json . put ( "message" , getErrorMessage ( ) ) ; } json . put ( "submitTime" , submitTime == null ? null : new DateTime ( getSubmitTime ( ) ) . toString ( ) ) ; json . put ( "startTime" , startTime == null ? null : new DateTime ( getStartTime ( ) ) . toString ( ) ) ; json . put ( "endTime" , endTime == null ? null : new DateTime ( getEndTime ( ) ) . toString ( ) ) ; try { json . set ( "inputs" , getInputsAsJsonObject ( ) ) ; json . set ( "parameters" , getParametersAsJsonObject ( ) ) ; } catch ( JobException e ) { throw new IOException ( e . getMessage ( ) , e ) ; } json . set ( "_links" , hypermedia ) ; return json . toString ( ) ; }
Serializes to json with notifications embedded in hypermedia response.
Serializes to json with notifications embedded in hypermedia response .
//			json.put("workPath", getWorkPath());