cluster.setEmailNeeded(clusterRequest.getEmailNeeded());
return cluster;
}
public ClusterResponse convert(Cluster cluster, String clusterJson) {
ClusterResponse clusterResponse = new ClusterResponse();
clusterResponse.setCluster(jsonHelper.createJsonFromString(clusterJson));
clusterResponse.setId(cluster.getId());
clusterResponse.setStatus(cluster.getStatus().name());
if (cluster.getCreationFinished() != null) {
long now = new Date().getTime();
long createFinished = now - cluster.getCreationFinished();
int minutes = (int) ((createFinished / (MILLIS_PER_SECOND * SECONDS_PER_MINUTE)) % SECONDS_PER_MINUTE);
int hours = (int) (createFinished / (MILLIS_PER_SECOND * SECONDS_PER_MINUTE * SECONDS_PER_MINUTE));
clusterResponse.setHoursUp(hours);
clusterResponse.setMinutesUp(minutes);
} else {
clusterResponse.setHoursUp(0);
clusterResponse.setMinutesUp(0);
}
clusterResponse.setStatusReason(cluster.getStatusReason());
clusterResponse.setBlueprintId(cluster.getBlueprint().getId());
clusterResponse.setDescription(cluster.getDescription() == null ? "" : cluster.getDescription());
return clusterResponse;
}