use of org.vcell.api.common.events.DataJobEventRepresentation in project vcell by virtualcell.
the class DataJobEvent method toJsonRep.
public DataJobEventRepresentation toJsonRep() {
int eventType = this.eventType;
Double progress = this.progress;
String username = this.vcDataJobID.getJobOwner().getName();
String userkey = this.vcDataJobID.getJobOwner().getID().toString();
long jobid = this.vcDataJobID.getJobID();
boolean isBackgroundTask = this.vcDataJobID.isBackgroundTask();
String dataIdString = this.dataIdString;
String dataKey = this.dataKey.toString();
DataJobEventRepresentation rep = new DataJobEventRepresentation(eventType, progress, username, userkey, jobid, isBackgroundTask, dataIdString, dataKey);
return rep;
}
use of org.vcell.api.common.events.DataJobEventRepresentation in project vcell by virtualcell.
the class RestEventService method newEventMessage.
private void newEventMessage(MessageEvent event) {
System.out.println(getClass().getName() + ".newEventMessage(" + event.getClass().getSimpleName() + ": " + event);
if (event instanceof ExportEvent) {
ExportEvent exportEvent = (ExportEvent) event;
try {
ExportEventRepresentation exportEventRep = exportEvent.toJsonRep();
ExportEvent event2 = ExportEvent.fromJsonRep(this, exportEventRep);
if (!Compare.isEqual(event2.getFormat(), exportEvent.getFormat())) {
throw new RuntimeException("Export event round-trip failed");
}
if (!Compare.isEqual(event2.getJobID(), exportEvent.getJobID())) {
throw new RuntimeException("Export event round-trip failed");
}
Gson gson = new Gson();
String eventJSON = gson.toJson(exportEventRep);
insert(exportEventRep.username, EventType.ExportEvent, eventJSON);
} catch (Exception e) {
e.printStackTrace();
}
} else if (event instanceof SimulationJobStatusEvent) {
SimulationJobStatusEvent simJobEvent = (SimulationJobStatusEvent) event;
try {
SimulationJobStatusEventRepresentation simJobEventRep = simJobEvent.toJsonRep();
SimulationJobStatusEvent event2 = SimulationJobStatusEvent.fromJsonRep(this, simJobEventRep);
if (!Compare.isEqual(event2.getJobStatus(), simJobEvent.getJobStatus())) {
throw new RuntimeException("SimulationJobStatus event round-trip failed");
}
if (!Compare.isEqual(event2.getProgress(), simJobEvent.getProgress())) {
throw new RuntimeException("SimulationJobStatus <PROGRESS> event round-trip failed");
}
Gson gson = new Gson();
String eventJSON = gson.toJson(simJobEventRep);
insert(simJobEventRep.username, EventType.SimJob, eventJSON);
} catch (Exception e) {
e.printStackTrace();
}
} else if (event instanceof VCellMessageEvent) {
VCellMessageEvent vcellMessageEvent = (VCellMessageEvent) event;
lg.error("event of type VCellMessageEvent not supported");
} else if (event instanceof WorkerEvent) {
lg.error("event of type WorkerEvent not supported");
WorkerEvent workerEvent = (WorkerEvent) event;
} else if (event instanceof PerformanceMonitorEvent) {
lg.error("event of type PerformanceMonitorEvent not supported");
PerformanceMonitorEvent performanceMonitorEvent = (PerformanceMonitorEvent) event;
} else if (event instanceof DataJobEvent) {
lg.error("event of type DataJobEvent not supported");
DataJobEvent dataJobEvent = (DataJobEvent) event;
try {
DataJobEventRepresentation dataJobEventRep = dataJobEvent.toJsonRep();
DataJobEvent event2 = DataJobEvent.fromJsonRep(this, dataJobEventRep);
if (!Compare.isEqual(event2.getDataIdString(), dataJobEvent.getDataIdString())) {
throw new RuntimeException("DataJob event round-trip failed");
}
if (!Compare.isEqual(event2.getProgress(), dataJobEvent.getProgress())) {
throw new RuntimeException("DataJob <PROGRESS> event round-trip failed");
}
Gson gson = new Gson();
String eventJSON = gson.toJson(dataJobEventRep);
insert(dataJobEventRep.username, EventType.DataJob, eventJSON);
} catch (Exception e) {
e.printStackTrace();
}
}
}
Aggregations