From b699cc27e85a8f8234502c0853ec5ad6a6d4f440 Mon Sep 17 00:00:00 2001 From: Giancarlo Panichi Date: Fri, 13 Mar 2015 15:50:42 +0000 Subject: [PATCH] Added JobClassifier git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-gwt-service@113601 82a268e6-3cf1-43bd-a215-b396298e98cf --- .../gwtservice/server/TDGWTServiceImpl.java | 12 +++- .../server/trservice/JobClassifierMap.java | 32 +++++++++ .../BackgroundOperationMonitorCreator.java | 8 ++- .../monitor/OperationMonitorCreator.java | 7 +- .../user/td/gwtservice/shared/task/JobS.java | 49 ++++++++----- .../shared/task/JobSClassifier.java | 58 +++++++++++++++ .../shared/tr/table/Validations.java | 71 +++++++++++-------- 7 files changed, 185 insertions(+), 52 deletions(-) create mode 100644 src/main/java/org/gcube/portlets/user/td/gwtservice/server/trservice/JobClassifierMap.java create mode 100644 src/main/java/org/gcube/portlets/user/td/gwtservice/shared/task/JobSClassifier.java diff --git a/src/main/java/org/gcube/portlets/user/td/gwtservice/server/TDGWTServiceImpl.java b/src/main/java/org/gcube/portlets/user/td/gwtservice/server/TDGWTServiceImpl.java index 3a6e3cc..6e89911 100644 --- a/src/main/java/org/gcube/portlets/user/td/gwtservice/server/TDGWTServiceImpl.java +++ b/src/main/java/org/gcube/portlets/user/td/gwtservice/server/TDGWTServiceImpl.java @@ -151,6 +151,7 @@ import org.gcube.portlets.user.td.gwtservice.server.resource.ResourceTypeMap; import org.gcube.portlets.user.td.gwtservice.server.storage.FilesStorage; import org.gcube.portlets.user.td.gwtservice.server.trservice.ColumnDataTypeMap; import org.gcube.portlets.user.td.gwtservice.server.trservice.ExtractReferences; +import org.gcube.portlets.user.td.gwtservice.server.trservice.JobClassifierMap; import org.gcube.portlets.user.td.gwtservice.server.trservice.LicenceMap; import org.gcube.portlets.user.td.gwtservice.server.trservice.OperationDefinitionMap; import org.gcube.portlets.user.td.gwtservice.server.trservice.PeriodTypeMap; @@ -200,6 +201,7 @@ import org.gcube.portlets.user.td.gwtservice.shared.source.SourceType; import org.gcube.portlets.user.td.gwtservice.shared.statistical.StatisticalOperationSession; import org.gcube.portlets.user.td.gwtservice.shared.task.InvocationS; import org.gcube.portlets.user.td.gwtservice.shared.task.JobS; +import org.gcube.portlets.user.td.gwtservice.shared.task.JobSClassifier; import org.gcube.portlets.user.td.gwtservice.shared.task.State; import org.gcube.portlets.user.td.gwtservice.shared.task.TaskResubmitSession; import org.gcube.portlets.user.td.gwtservice.shared.task.TaskResumeSession; @@ -4333,7 +4335,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements ArrayList vList = new ArrayList(); int i = 0; for (Validation v : vals) { - valid = new Validations(String.valueOf(i), + valid = new Validations(String.valueOf(i),"", v.getDescription(), v.isValid(), null, null); vList.add(valid); i++; @@ -6863,11 +6865,12 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements ArrayList validations = new ArrayList(); for (ValidationDescriptor val : job.getValidations()) { Validations validation = new Validations( - String.valueOf(i), val.getDescription(), + String.valueOf(i),val.getTitle(), val.getDescription(), val.isValid(), ConditionCodeMap.mapConditionCode(val .getConditionCode()), val.getValidationColumn()); + validations.add(validation); i++; } @@ -6896,8 +6899,11 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements operationExecution.getOperationId(), mapSent, task.getId().getValue(), refColumn); } + + JobSClassifier jobClassifier=JobClassifierMap.map(job.getJobClassifier()); + JobS jobS = new JobS(String.valueOf(j), job.getProgress(), - job.getHumaReadableStatus(), job.getDescription(), + job.getHumaReadableStatus(), jobClassifier, job.getDescription(), validations, invocationS); jobSList.add(jobS); j++; diff --git a/src/main/java/org/gcube/portlets/user/td/gwtservice/server/trservice/JobClassifierMap.java b/src/main/java/org/gcube/portlets/user/td/gwtservice/server/trservice/JobClassifierMap.java new file mode 100644 index 0000000..880a8a9 --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/td/gwtservice/server/trservice/JobClassifierMap.java @@ -0,0 +1,32 @@ +package org.gcube.portlets.user.td.gwtservice.server.trservice; + +import org.gcube.data.analysis.tabulardata.service.operation.JobClassifier; +import org.gcube.portlets.user.td.gwtservice.shared.task.JobSClassifier; + +/** + * + * @author "Giancarlo Panichi" g.panichi@isti.cnr.it + * + */ +public class JobClassifierMap { + public static JobSClassifier map(JobClassifier jobClassifier) { + if (jobClassifier == null) { + return JobSClassifier.UNKNOWN; + } + + switch (jobClassifier) { + case DATAVALIDATION: + return JobSClassifier.DATAVALIDATION; + case POSTPROCESSING: + return JobSClassifier.POSTPROCESSING; + case PREPROCESSING: + return JobSClassifier.PREPROCESSING; + case PROCESSING: + return JobSClassifier.PROCESSING; + default: + return JobSClassifier.UNKNOWN; + + } + } +} diff --git a/src/main/java/org/gcube/portlets/user/td/gwtservice/shared/monitor/BackgroundOperationMonitorCreator.java b/src/main/java/org/gcube/portlets/user/td/gwtservice/shared/monitor/BackgroundOperationMonitorCreator.java index fdf0e6c..6d6a53b 100644 --- a/src/main/java/org/gcube/portlets/user/td/gwtservice/shared/monitor/BackgroundOperationMonitorCreator.java +++ b/src/main/java/org/gcube/portlets/user/td/gwtservice/shared/monitor/BackgroundOperationMonitorCreator.java @@ -26,6 +26,7 @@ import org.gcube.data.analysis.tabulardata.service.tabular.TabularResourceId; import org.gcube.data.analysis.tabulardata.service.tabular.metadata.NameMetadata; import org.gcube.portlets.user.td.gwtservice.server.SessionUtil; import org.gcube.portlets.user.td.gwtservice.server.storage.FilesStorage; +import org.gcube.portlets.user.td.gwtservice.server.trservice.JobClassifierMap; import org.gcube.portlets.user.td.gwtservice.server.trservice.TabularResourceTypeMap; import org.gcube.portlets.user.td.gwtservice.server.trservice.TaskStateMap; import org.gcube.portlets.user.td.gwtservice.server.trservice.WorkerStateMap; @@ -34,6 +35,7 @@ import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTServiceExcept import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTSessionExpiredException; import org.gcube.portlets.user.td.gwtservice.shared.json.JSONExportSession; import org.gcube.portlets.user.td.gwtservice.shared.task.JobS; +import org.gcube.portlets.user.td.gwtservice.shared.task.JobSClassifier; import org.gcube.portlets.user.td.gwtservice.shared.task.TaskS; import org.gcube.portlets.user.td.gwtservice.shared.task.TaskWrapper; import org.gcube.portlets.user.td.gwtservice.shared.task.ValidationsJobS; @@ -168,9 +170,11 @@ public class BackgroundOperationMonitorCreator { validationsJobS.add(validationJ); j++; } - + + JobSClassifier jobClassifier=JobClassifierMap.map(job.getJobClassifier()); + JobS jobS = new JobS(String.valueOf(i), job.getProgress(), - job.getHumaReadableStatus(), job.getDescription(), + job.getHumaReadableStatus(), jobClassifier, job.getDescription(), WorkerStateMap.map(job.getStatus()), job.getErrorMessage(), validationsJobS); diff --git a/src/main/java/org/gcube/portlets/user/td/gwtservice/shared/monitor/OperationMonitorCreator.java b/src/main/java/org/gcube/portlets/user/td/gwtservice/shared/monitor/OperationMonitorCreator.java index d203599..797cad3 100644 --- a/src/main/java/org/gcube/portlets/user/td/gwtservice/shared/monitor/OperationMonitorCreator.java +++ b/src/main/java/org/gcube/portlets/user/td/gwtservice/shared/monitor/OperationMonitorCreator.java @@ -25,6 +25,7 @@ import org.gcube.data.analysis.tabulardata.service.tabular.TabularResource; import org.gcube.data.analysis.tabulardata.service.tabular.TabularResourceId; import org.gcube.portlets.user.td.gwtservice.server.SessionUtil; import org.gcube.portlets.user.td.gwtservice.server.storage.FilesStorage; +import org.gcube.portlets.user.td.gwtservice.server.trservice.JobClassifierMap; import org.gcube.portlets.user.td.gwtservice.server.trservice.TabularResourceTypeMap; import org.gcube.portlets.user.td.gwtservice.server.trservice.TaskStateMap; import org.gcube.portlets.user.td.gwtservice.server.trservice.WorkerStateMap; @@ -33,6 +34,7 @@ import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTServiceExcept import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTSessionExpiredException; import org.gcube.portlets.user.td.gwtservice.shared.json.JSONExportSession; import org.gcube.portlets.user.td.gwtservice.shared.task.JobS; +import org.gcube.portlets.user.td.gwtservice.shared.task.JobSClassifier; import org.gcube.portlets.user.td.gwtservice.shared.task.TaskS; import org.gcube.portlets.user.td.gwtservice.shared.task.TaskWrapper; import org.gcube.portlets.user.td.gwtservice.shared.task.ValidationsJobS; @@ -166,9 +168,12 @@ public class OperationMonitorCreator { validationsJobS.add(validationJ); j++; } + + JobSClassifier jobClassifier=JobClassifierMap.map(job.getJobClassifier()); + JobS jobS = new JobS(String.valueOf(i), job.getProgress(), - job.getHumaReadableStatus(), job.getDescription(), + job.getHumaReadableStatus(), jobClassifier, job.getDescription(), WorkerStateMap.map(job.getStatus()), job.getErrorMessage(), validationsJobS); diff --git a/src/main/java/org/gcube/portlets/user/td/gwtservice/shared/task/JobS.java b/src/main/java/org/gcube/portlets/user/td/gwtservice/shared/task/JobS.java index 30c3012..9c9bf47 100644 --- a/src/main/java/org/gcube/portlets/user/td/gwtservice/shared/task/JobS.java +++ b/src/main/java/org/gcube/portlets/user/td/gwtservice/shared/task/JobS.java @@ -7,22 +7,24 @@ import org.gcube.portlets.user.td.gwtservice.shared.tr.table.Validations; /** * - * @author "Giancarlo Panichi" - * + * @author giancarlo + * email: g.panichi@isti.cnr.it + * */ public class JobS implements Serializable { private static final long serialVersionUID = 4502877601374000292L; - protected String id; // For grid only - protected float progress; - protected String humaReadableStatus; - protected String description; - protected InvocationS invocation; - protected ArrayList validations; - protected Throwable errorMessage; - protected WorkerState workerState; - protected ArrayList validationsJobS; + private String id; // For grid only + private float progress; + private String humaReadableStatus; + private JobSClassifier jobClassifier; + private String description; + private InvocationS invocation; + private ArrayList validations; + private Throwable errorMessage; + private WorkerState workerState; + private ArrayList validationsJobS; public JobS() { @@ -39,11 +41,12 @@ public class JobS implements Serializable { * @param invocation */ public JobS(String id, float progress, String humaReadableStatus, - String description, ArrayList validations, + JobSClassifier jobClassifier, String description, ArrayList validations, InvocationS invocation) { this.id = id; this.progress = progress; this.humaReadableStatus = humaReadableStatus; + this.jobClassifier=jobClassifier; this.description = description; this.validations = validations; this.invocation = invocation; @@ -64,11 +67,12 @@ public class JobS implements Serializable { * @param validationsJobs */ public JobS(String id, float progress, String humaReadableStatus, - String description, WorkerState workerState, + JobSClassifier jobClassifier,String description, WorkerState workerState, Throwable errorMessage, ArrayList validationsJobs) { this.id = id; this.progress = progress; this.humaReadableStatus = humaReadableStatus; + this.jobClassifier=jobClassifier; this.description = description; this.validationsJobS = validationsJobs; this.errorMessage = errorMessage; @@ -101,6 +105,14 @@ public class JobS implements Serializable { this.humaReadableStatus = humaReadableStatus; } + public JobSClassifier getJobClassifier() { + return jobClassifier; + } + + public void setJobClassifier(JobSClassifier jobClassifier) { + this.jobClassifier = jobClassifier; + } + public String getDescription() { return description; } @@ -153,10 +165,13 @@ public class JobS implements Serializable { public String toString() { return "JobS [id=" + id + ", progress=" + progress + ", humaReadableStatus=" + humaReadableStatus - + ", description=" + description + ", invocation=" + invocation - + ", validations=" + validations + ", errorMessage=" - + errorMessage + ", workerState=" + workerState - + ", validationsJobS=" + validationsJobS + "]"; + + ", jobClassifier=" + jobClassifier + ", description=" + + description + ", invocation=" + invocation + ", validations=" + + validations + ", errorMessage=" + errorMessage + + ", workerState=" + workerState + ", validationsJobS=" + + validationsJobS + "]"; } + + } diff --git a/src/main/java/org/gcube/portlets/user/td/gwtservice/shared/task/JobSClassifier.java b/src/main/java/org/gcube/portlets/user/td/gwtservice/shared/task/JobSClassifier.java new file mode 100644 index 0000000..0d64eb2 --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/td/gwtservice/shared/task/JobSClassifier.java @@ -0,0 +1,58 @@ +package org.gcube.portlets.user.td.gwtservice.shared.task; + +import java.io.Serializable; +import java.util.Arrays; +import java.util.List; + +/** + * + * @author giancarlo + * email: g.panichi@isti.cnr.it + * + */ +public enum JobSClassifier implements Serializable{ + PREPROCESSING("Preprocessing"), + PROCESSING("Processing"), + POSTPROCESSING("Postprocessing"), + DATAVALIDATION("Data Validation"), + UNKNOWN("Unknown"); + + + /** + * @param text + */ + private JobSClassifier(final String id) { + this.id = id; + } + + private final String id; + + @Override + public String toString() { + return id; + } + + + public static List getList(){ + return Arrays.asList(values()); + + } + + + public static JobSClassifier getJobClassifierFromId( + String id) { + for(JobSClassifier jobClassifier:values()){ + if (id.compareTo(jobClassifier.id) == 0) { + return jobClassifier; + } + } + return null; + } + + public String getLabel(){ + return id; + } + + + +} diff --git a/src/main/java/org/gcube/portlets/user/td/gwtservice/shared/tr/table/Validations.java b/src/main/java/org/gcube/portlets/user/td/gwtservice/shared/tr/table/Validations.java index 9c190f0..a7481ba 100644 --- a/src/main/java/org/gcube/portlets/user/td/gwtservice/shared/tr/table/Validations.java +++ b/src/main/java/org/gcube/portlets/user/td/gwtservice/shared/tr/table/Validations.java @@ -12,11 +12,12 @@ import org.gcube.portlets.user.td.gwtservice.shared.tr.ConditionCode; */ public class Validations implements Serializable { private static final long serialVersionUID = 4950002331717895999L; - protected String id;// Only for grid - protected String description; - protected Boolean valid; - protected ConditionCode conditionCode; - protected String validationColumnColumnId; + private String id;// Only for grid + private String title; + private String description; + private boolean valid; + private ConditionCode conditionCode; + private String validationColumnColumnId; /** * @@ -33,29 +34,15 @@ public class Validations implements Serializable { * @param conditionCode * @param validationColumnColumnId */ - public Validations(String id, String description, Boolean valid, ConditionCode conditionCode + public Validations(String id, String title, String description, boolean valid, ConditionCode conditionCode , String validationColumnColumnId) { this.id = id; + this.title=title; this.description = description; this.valid = valid; this.conditionCode = conditionCode; this.validationColumnColumnId=validationColumnColumnId; - } - - public String getDescription() { - return description; - } - - public void setDescription(String description) { - this.description = description; - } - - public Boolean isValid() { - return valid; - } - - public void setValid(Boolean valid) { - this.valid = valid; + } public String getId() { @@ -66,6 +53,30 @@ public class Validations implements Serializable { this.id = id; } + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public boolean isValid() { + return valid; + } + + public void setValid(boolean valid) { + this.valid = valid; + } + public ConditionCode getConditionCode() { return conditionCode; } @@ -73,9 +84,7 @@ public class Validations implements Serializable { public void setConditionCode(ConditionCode conditionCode) { this.conditionCode = conditionCode; } - - - + public String getValidationColumnColumnId() { return validationColumnColumnId; } @@ -86,14 +95,18 @@ public class Validations implements Serializable { @Override public String toString() { - return "Validations [id=" + id + ", description=" + description - + ", valid=" + valid + ", conditionCode=" + conditionCode - + ", validationColumnColumnId=" + validationColumnColumnId - + "]"; + return "Validations [id=" + id + ", title=" + title + ", description=" + + description + ", valid=" + valid + ", conditionCode=" + + conditionCode + ", validationColumnColumnId=" + + validationColumnColumnId + "]"; } + + + + }