}
else {
status = history.getStatus().getDisplayName();
}
OperationHistoryRest hist = new OperationHistoryRest();
hist.setStatus(status);
if (history.getResource()!=null) {
hist.setResourceName(history.getResource().getName());
}
hist.setOperationName(history.getOperationDefinition().getName());
hist.lastModified(history.getModifiedTime());
if (history.getErrorMessage()!=null) {
hist.setErrorMessage(history.getErrorMessage());
}
if (history.getResults()!=null) {
Configuration results = history.getResults();
for (Property p : results.getProperties()) {
String val;
if (p instanceof PropertySimple) {
val = ((PropertySimple)p).getStringValue();
}
else {
val = p.toString();
}
hist.getResult().put(p.getName(),val);
}
}
String jobName = history.getJobName();
String jobGroup = history.getJobGroup();
JobId jobId = new JobId(jobName, jobGroup);
hist.setJobId(jobId.toString());
UriBuilder uriBuilder = uriInfo.getBaseUriBuilder();
uriBuilder.path("/operation/history/{id}");
URI url = uriBuilder.build(jobId);
Link self = new Link("self",url.toString());
hist.getLinks().add(self);
return hist;
}