diff --git a/src/main/java/org/gcube/portlets/user/dataminermanager/client/computations/ComputationsPanel.java b/src/main/java/org/gcube/portlets/user/dataminermanager/client/computations/ComputationsPanel.java index a792958..d318171 100644 --- a/src/main/java/org/gcube/portlets/user/dataminermanager/client/computations/ComputationsPanel.java +++ b/src/main/java/org/gcube/portlets/user/dataminermanager/client/computations/ComputationsPanel.java @@ -32,6 +32,7 @@ public class ComputationsPanel extends SimpleContainer { public ComputationsPanel() { super(); + Log.debug("ComputationsPanel"); init(); create(); bind(); diff --git a/src/main/java/org/gcube/portlets/user/dataminermanager/client/computations/ComputationsViewerPanel.java b/src/main/java/org/gcube/portlets/user/dataminermanager/client/computations/ComputationsViewerPanel.java index 75fb50d..c03d216 100644 --- a/src/main/java/org/gcube/portlets/user/dataminermanager/client/computations/ComputationsViewerPanel.java +++ b/src/main/java/org/gcube/portlets/user/dataminermanager/client/computations/ComputationsViewerPanel.java @@ -37,8 +37,9 @@ public class ComputationsViewerPanel extends FramedPanel { public ComputationsViewerPanel(ComputationData computationData) { super(); - Log.debug("ComputationsPanel"); - this.computationData=computationData; + Log.debug("ComputationsViewerPanel"); + this.computationData = computationData; + Log.debug("ComputationData: " + computationData); init(); create(); @@ -54,19 +55,25 @@ public class ComputationsViewerPanel extends FramedPanel { setResize(true); setHeadingText("Computations Viewer"); setBodyStyle("backgroundColor:white;"); - + } private void create() { - v = new VerticalLayoutContainer(); - v.setScrollMode(ScrollMode.AUTO); - add(v); - createView(); - forceLayout(); + try { + v = new VerticalLayoutContainer(); + v.setScrollMode(ScrollMode.AUTO); + add(v); + createView(); + forceLayout(); + } catch (Throwable e) { + Log.error("Error creating ComputationsViewerPanel: " + + e.getLocalizedMessage()); + e.printStackTrace(); + } } - private void createView() { + if (computationData == null) { Log.error("ComputationData is null!"); UtilsGXT3.alert("Error", @@ -74,6 +81,15 @@ public class ComputationsViewerPanel extends FramedPanel { return; } + if (computationData.getComputationId() == null + || computationData.getComputationId().getId() == null + || computationData.getComputationId().getId().isEmpty()) { + Log.error("Error in computationId: " + computationData); + UtilsGXT3.alert("Error", + "No information on computation id is retrieved!"); + return; + } + SimpleContainer sectionTitle = new SimpleContainer(); // title HtmlLayoutContainer title = new HtmlLayoutContainer( @@ -82,7 +98,8 @@ public class ComputationsViewerPanel extends FramedPanel { + ""); sectionTitle.add(title, new MarginData()); sectionTitle.getElement().getStyle().setMarginRight(20, Unit.PX); - // v.add(sectionTitle, new VerticalLayoutData(1, -1, new Margins(0))); + // v.add(sectionTitle, new VerticalLayoutData(1, -1, new + // Margins(0))); v.add(sectionTitle, new VerticalLayoutData(-1, -1, new Margins(10))); if (computationData.getOutputParameters() != null @@ -105,195 +122,258 @@ public class ComputationsViewerPanel extends FramedPanel { FieldSet operatorFieldSet = operatorView(); v.add(operatorFieldSet, new VerticalLayoutData(-1, -1, new Margins(10))); - - } private FieldSet operatorView() { - VerticalLayoutContainer operatorVBox = new VerticalLayoutContainer(); - TextField operatorNameField = new TextField(); - operatorNameField.setValue(computationData.getComputationId() - .getOperatorName()); - operatorNameField.setReadOnly(true); - FieldLabel operatorNameLabel = new FieldLabel(operatorNameField, - "Operator Name"); - operatorNameLabel.setLabelWidth(200); - operatorNameLabel.setLabelWordWrap(true); - operatorVBox.add(operatorNameLabel, new VerticalLayoutData(1, -1, - new Margins(0,4,0,4))); + try { - TextArea operatorDescriptionField = new TextArea(); - operatorDescriptionField.setHeight(40); - operatorDescriptionField.setValue(computationData - .getOperatorDescription()); - operatorDescriptionField.setReadOnly(true); - FieldLabel operatorDescriptionLabel = new FieldLabel( - operatorDescriptionField, "Operator Description"); - operatorDescriptionLabel.setLabelWidth(200); - operatorDescriptionLabel.setLabelWordWrap(true); - operatorDescriptionLabel.setHeight(65); - operatorVBox.add(operatorDescriptionLabel, new VerticalLayoutData(1, - -1, new Margins(0,5,0,5))); + VerticalLayoutContainer operatorVBox = new VerticalLayoutContainer(); + TextField operatorNameField = new TextField(); + operatorNameField.setValue(computationData.getComputationId() + .getOperatorName()); + operatorNameField.setReadOnly(true); + FieldLabel operatorNameLabel = new FieldLabel(operatorNameField, + "Operator Name"); + operatorNameLabel.setLabelWidth(200); + operatorNameLabel.setLabelWordWrap(true); + operatorVBox.add(operatorNameLabel, new VerticalLayoutData(1, -1, + new Margins(0, 4, 0, 4))); - FieldSet operatorFieldSet = new FieldSet(); - operatorFieldSet.setHeadingText("Operator Details"); - operatorFieldSet.setCollapsible(true); - operatorFieldSet.setHeight(130); - operatorFieldSet.add(operatorVBox); - operatorFieldSet.getElement().getStyle().setMarginBottom(120, Unit.PX); - operatorFieldSet.getElement().getStyle().setMarginRight(20, Unit.PX); - return operatorFieldSet; + TextArea operatorDescriptionField = new TextArea(); + operatorDescriptionField.setHeight(40); + operatorDescriptionField.setValue(computationData + .getOperatorDescription()); + operatorDescriptionField.setReadOnly(true); + FieldLabel operatorDescriptionLabel = new FieldLabel( + operatorDescriptionField, "Operator Description"); + operatorDescriptionLabel.setLabelWidth(200); + operatorDescriptionLabel.setLabelWordWrap(true); + operatorDescriptionLabel.setHeight(65); + operatorVBox.add(operatorDescriptionLabel, new VerticalLayoutData( + 1, -1, new Margins(0, 5, 0, 5))); + + FieldSet operatorFieldSet = new FieldSet(); + operatorFieldSet.setHeadingText("Operator Details"); + operatorFieldSet.setCollapsible(true); + operatorFieldSet.setHeight(130); + operatorFieldSet.add(operatorVBox); + operatorFieldSet.getElement().getStyle() + .setMarginBottom(120, Unit.PX); + operatorFieldSet.getElement().getStyle() + .setMarginRight(20, Unit.PX); + return operatorFieldSet; + } catch (Throwable e) { + Log.error("Error in ComputationsViewerPanel in operator: " + + e.getLocalizedMessage()); + e.printStackTrace(); + throw e; + } } private FieldSet detailsView() { - VerticalLayoutContainer detailsVBox = new VerticalLayoutContainer(); - TextField startDateField = new TextField(); - startDateField.setValue(computationData.getStartDate()); - startDateField.setReadOnly(true); - FieldLabel startDateLabel = new FieldLabel(startDateField, "Start Date"); - startDateLabel.setLabelWidth(200); - startDateLabel.setLabelWordWrap(true); - detailsVBox.add(startDateLabel, new VerticalLayoutData(1, -1, - new Margins(0,4,0,4))); + try { + VerticalLayoutContainer detailsVBox = new VerticalLayoutContainer(); + TextField startDateField = new TextField(); + startDateField.setValue(computationData.getStartDate()); + startDateField.setReadOnly(true); + FieldLabel startDateLabel = new FieldLabel(startDateField, + "Start Date"); + startDateLabel.setLabelWidth(200); + startDateLabel.setLabelWordWrap(true); + detailsVBox.add(startDateLabel, new VerticalLayoutData(1, -1, + new Margins(0, 4, 0, 4))); - TextField endDateField = new TextField(); - endDateField.setValue(computationData.getEndDate()); - endDateField.setReadOnly(true); - FieldLabel endDateLabel = new FieldLabel(endDateField, "End Date"); - endDateLabel.setLabelWidth(200); - endDateLabel.setLabelWordWrap(true); - detailsVBox.add(endDateLabel, new VerticalLayoutData(1, -1, - new Margins(0,4,0,4))); + TextField endDateField = new TextField(); + endDateField.setValue(computationData.getEndDate()); + endDateField.setReadOnly(true); + FieldLabel endDateLabel = new FieldLabel(endDateField, "End Date"); + endDateLabel.setLabelWidth(200); + endDateLabel.setLabelWordWrap(true); + detailsVBox.add(endDateLabel, new VerticalLayoutData(1, -1, + new Margins(0, 4, 0, 4))); - TextField statusField = new TextField(); - statusField.setValue(computationData.getStatus()); - statusField.setReadOnly(true); - FieldLabel statusLabel = new FieldLabel(statusField, "Status"); - statusLabel.setLabelWidth(200); - statusLabel.setLabelWordWrap(true); - detailsVBox.add(statusLabel, new VerticalLayoutData(1, -1, new Margins( - 0,4,0,4))); + TextField statusField = new TextField(); + statusField.setValue(computationData.getStatus()); + statusField.setReadOnly(true); + FieldLabel statusLabel = new FieldLabel(statusField, "Status"); + statusLabel.setLabelWidth(200); + statusLabel.setLabelWordWrap(true); + detailsVBox.add(statusLabel, new VerticalLayoutData(1, -1, + new Margins(0, 4, 0, 4))); - TextField vreField = new TextField(); - vreField.setValue(computationData.getVre()); - vreField.setReadOnly(true); - FieldLabel vreLabel = new FieldLabel(vreField, "VRE"); - vreLabel.setLabelWidth(200); - vreLabel.setLabelWordWrap(true); - detailsVBox - .add(vreLabel, new VerticalLayoutData(1, -1, new Margins(0,4,0,4))); + TextField vreField = new TextField(); + vreField.setValue(computationData.getVre()); + vreField.setReadOnly(true); + FieldLabel vreLabel = new FieldLabel(vreField, "VRE"); + vreLabel.setLabelWidth(200); + vreLabel.setLabelWordWrap(true); + detailsVBox.add(vreLabel, new VerticalLayoutData(1, -1, + new Margins(0, 4, 0, 4))); - FieldSet detailsFieldSet = new FieldSet(); - detailsFieldSet.setHeadingText("Computation Details"); - detailsFieldSet.setCollapsible(true); - detailsFieldSet.add(detailsVBox); - detailsFieldSet.getElement().getStyle().setMarginRight(20, Unit.PX); - return detailsFieldSet; + FieldSet detailsFieldSet = new FieldSet(); + detailsFieldSet.setHeadingText("Computation Details"); + detailsFieldSet.setCollapsible(true); + detailsFieldSet.add(detailsVBox); + detailsFieldSet.getElement().getStyle().setMarginRight(20, Unit.PX); + return detailsFieldSet; + } catch (Throwable e) { + Log.error("Error in ComputationsViewerPanel in details: " + + e.getLocalizedMessage()); + e.printStackTrace(); + throw e; + } } private FieldSet inputView() { - VerticalLayoutContainer inputVBox = new VerticalLayoutContainer(); - LinkedHashMap input = computationData - .getInputParameters(); - for (String key : input.keySet()) { - ComputationValue computationValue = input.get(key); - FieldLabel fieldLabel = null; - SimpleContainer simpleContainer; - switch (computationValue.getType()) { - case File: - ComputationValueFile computationValueFile=(ComputationValueFile) computationValue; - simpleContainer=new ComputationValueFilePanel(computationValueFile); - fieldLabel = new FieldLabel(simpleContainer, key); - fieldLabel.setLabelWidth(200); - fieldLabel.setLabelWordWrap(true); - break; - case Image: - ComputationValueImage computationValueImage=(ComputationValueImage) computationValue; - simpleContainer=new ComputationValueImagePanel(computationValueImage); - fieldLabel = new FieldLabel(simpleContainer, key); - fieldLabel.setLabelWidth(200); - fieldLabel.setLabelWordWrap(true); - break; - case FileList: - ComputationValueFileList computationValueFileList=(ComputationValueFileList) computationValue; - simpleContainer=new ComputationValueFileListPanel(computationValueFileList); - fieldLabel = new FieldLabel(simpleContainer, key); - fieldLabel.setLabelWidth(200); - fieldLabel.setLabelWordWrap(true); - break; - case String: - default: - TextField textField = new TextField(); - textField.setValue(computationValue.getValue()); - textField.setReadOnly(true); - fieldLabel = new FieldLabel(textField, key); - fieldLabel.setLabelWidth(200); - fieldLabel.setLabelWordWrap(true); - break; + try { + VerticalLayoutContainer inputVBox = new VerticalLayoutContainer(); + LinkedHashMap input = computationData + .getInputParameters(); + for (String key : input.keySet()) { + ComputationValue computationValue = input.get(key); + Log.debug("Input: [key=" + key + ", ComputationValue=" + + computationValue + "]"); + FieldLabel fieldLabel = null; + SimpleContainer simpleContainer; + if(computationValue==null){ + TextField textField = new TextField(); + textField.setReadOnly(true); + fieldLabel = new FieldLabel(textField, key); + fieldLabel.setLabelWidth(200); + fieldLabel.setLabelWordWrap(true); + inputVBox.add(fieldLabel, new VerticalLayoutData(1, -1, + new Margins(0, 4, 0, 4))); + continue; + } + + + switch (computationValue.getType()) { + case File: + ComputationValueFile computationValueFile = (ComputationValueFile) computationValue; + simpleContainer = new ComputationValueFilePanel( + computationValueFile); + fieldLabel = new FieldLabel(simpleContainer, key); + fieldLabel.setLabelWidth(200); + fieldLabel.setLabelWordWrap(true); + break; + case Image: + ComputationValueImage computationValueImage = (ComputationValueImage) computationValue; + simpleContainer = new ComputationValueImagePanel( + computationValueImage); + fieldLabel = new FieldLabel(simpleContainer, key); + fieldLabel.setLabelWidth(200); + fieldLabel.setLabelWordWrap(true); + break; + case FileList: + ComputationValueFileList computationValueFileList = (ComputationValueFileList) computationValue; + simpleContainer = new ComputationValueFileListPanel( + computationValueFileList); + fieldLabel = new FieldLabel(simpleContainer, key); + fieldLabel.setLabelWidth(200); + fieldLabel.setLabelWordWrap(true); + break; + case String: + default: + TextField textField = new TextField(); + textField.setValue(computationValue.getValue()); + textField.setReadOnly(true); + fieldLabel = new FieldLabel(textField, key); + fieldLabel.setLabelWidth(200); + fieldLabel.setLabelWordWrap(true); + break; + } + inputVBox.add(fieldLabel, new VerticalLayoutData(1, -1, + new Margins(0, 4, 0, 4))); } - inputVBox.add(fieldLabel, new VerticalLayoutData(1, -1, - new Margins(0,4,0,4))); - } - FieldSet inputFieldSet = new FieldSet(); - inputFieldSet.setHeadingText("Input Parameters"); - inputFieldSet.setCollapsible(true); - inputFieldSet.add(inputVBox); - inputFieldSet.getElement().getStyle().setMarginRight(20, Unit.PX); - return inputFieldSet; + FieldSet inputFieldSet = new FieldSet(); + inputFieldSet.setHeadingText("Input Parameters"); + inputFieldSet.setCollapsible(true); + inputFieldSet.add(inputVBox); + inputFieldSet.getElement().getStyle().setMarginRight(20, Unit.PX); + return inputFieldSet; + } catch (Throwable e) { + Log.error("Error in ComputationsViewerPanel creating input view: " + + e.getLocalizedMessage()); + e.printStackTrace(); + throw e; + } } private FieldSet outputView() { - VerticalLayoutContainer outputVBox = new VerticalLayoutContainer(); - LinkedHashMap output = computationData - .getOutputParameters(); - for (String key : output.keySet()) { - ComputationValue computationValue = output.get(key); - FieldLabel fieldLabel = null; - SimpleContainer simpleContainer; - switch (computationValue.getType()) { - case File: - ComputationValueFile computationValueFile=(ComputationValueFile) computationValue; - simpleContainer=new ComputationValueFilePanel(computationValueFile); - fieldLabel = new FieldLabel(simpleContainer, key); - fieldLabel.setLabelWidth(200); - fieldLabel.setLabelWordWrap(true); - break; - case Image: - ComputationValueImage computationValueImage=(ComputationValueImage) computationValue; - simpleContainer=new ComputationValueImagePanel(computationValueImage); - fieldLabel = new FieldLabel(simpleContainer, key); - fieldLabel.setLabelWidth(200); - fieldLabel.setLabelWordWrap(true); - break; - case FileList: - ComputationValueFileList computationValueFileList=(ComputationValueFileList) computationValue; - simpleContainer=new ComputationValueFileListPanel(computationValueFileList); - fieldLabel = new FieldLabel(simpleContainer, key); - fieldLabel.setLabelWidth(200); - fieldLabel.setLabelWordWrap(true); - case String: - default: - TextField textField = new TextField(); - textField.setValue(computationValue.getValue()); - textField.setReadOnly(true); - fieldLabel = new FieldLabel(textField, key); - fieldLabel.setLabelWidth(200); - fieldLabel.setLabelWordWrap(true); - break; + try { + VerticalLayoutContainer outputVBox = new VerticalLayoutContainer(); + LinkedHashMap output = computationData + .getOutputParameters(); + for (String key : output.keySet()) { + ComputationValue computationValue = output.get(key); + Log.debug("Output: [key=" + key + ", ComputationValue=" + + computationValue + "]"); + FieldLabel fieldLabel = null; + SimpleContainer simpleContainer; + if(computationValue==null){ + TextField textField = new TextField(); + textField.setReadOnly(true); + fieldLabel = new FieldLabel(textField, key); + fieldLabel.setLabelWidth(200); + fieldLabel.setLabelWordWrap(true); + outputVBox.add(fieldLabel, new VerticalLayoutData(1, -1, + new Margins(0, 4, 0, 4))); + continue; + } + + switch (computationValue.getType()) { + case File: + ComputationValueFile computationValueFile = (ComputationValueFile) computationValue; + simpleContainer = new ComputationValueFilePanel( + computationValueFile); + fieldLabel = new FieldLabel(simpleContainer, key); + fieldLabel.setLabelWidth(200); + fieldLabel.setLabelWordWrap(true); + break; + case Image: + ComputationValueImage computationValueImage = (ComputationValueImage) computationValue; + simpleContainer = new ComputationValueImagePanel( + computationValueImage); + fieldLabel = new FieldLabel(simpleContainer, key); + fieldLabel.setLabelWidth(200); + fieldLabel.setLabelWordWrap(true); + break; + case FileList: + ComputationValueFileList computationValueFileList = (ComputationValueFileList) computationValue; + simpleContainer = new ComputationValueFileListPanel( + computationValueFileList); + fieldLabel = new FieldLabel(simpleContainer, key); + fieldLabel.setLabelWidth(200); + fieldLabel.setLabelWordWrap(true); + case String: + default: + TextField textField = new TextField(); + textField.setValue(computationValue.getValue()); + textField.setReadOnly(true); + fieldLabel = new FieldLabel(textField, key); + fieldLabel.setLabelWidth(200); + fieldLabel.setLabelWordWrap(true); + break; + } + outputVBox.add(fieldLabel, new VerticalLayoutData(1, -1, + new Margins(0, 4, 0, 4))); } - outputVBox.add(fieldLabel, new VerticalLayoutData(1, -1, - new Margins(0,4,0,4))); - } - FieldSet outputFieldSet = new FieldSet(); - outputFieldSet.setHeadingText("Output Result"); - outputFieldSet.setCollapsible(true); - outputFieldSet.add(outputVBox); - outputFieldSet.getElement().getStyle().setMarginRight(20, Unit.PX); - return outputFieldSet; + FieldSet outputFieldSet = new FieldSet(); + outputFieldSet.setHeadingText("Output Result"); + outputFieldSet.setCollapsible(true); + outputFieldSet.add(outputVBox); + outputFieldSet.getElement().getStyle().setMarginRight(20, Unit.PX); + return outputFieldSet; + } catch (Throwable e) { + Log.error("Error in ComputationsViewerPanel creating output view: " + + e.getLocalizedMessage()); + e.printStackTrace(); + throw e; + } } } diff --git a/src/main/java/org/gcube/portlets/user/dataminermanager/server/DataMinerManagerServiceImpl.java b/src/main/java/org/gcube/portlets/user/dataminermanager/server/DataMinerManagerServiceImpl.java index ed2941a..dc450e4 100644 --- a/src/main/java/org/gcube/portlets/user/dataminermanager/server/DataMinerManagerServiceImpl.java +++ b/src/main/java/org/gcube/portlets/user/dataminermanager/server/DataMinerManagerServiceImpl.java @@ -1,5 +1,6 @@ package org.gcube.portlets.user.dataminermanager.server; +import java.util.LinkedHashMap; import java.util.List; import java.util.Map; @@ -343,6 +344,8 @@ public class DataMinerManagerServiceImpl extends RemoteServiceServlet implements logger.debug("OutputDataByComputationItemt(): " + itemDescription); Map properties = StorageUtil.getProperties( aslSession.getUsername(), itemDescription.getId()); + + logger.debug("Properties: " + properties); SClient smClient = SessionUtil.getSClient(aslSession, session); ComputationData computationData = smClient diff --git a/src/main/java/org/gcube/portlets/user/dataminermanager/server/smservice/SClient4WPS.java b/src/main/java/org/gcube/portlets/user/dataminermanager/server/smservice/SClient4WPS.java index c113101..6dd1df0 100644 --- a/src/main/java/org/gcube/portlets/user/dataminermanager/server/smservice/SClient4WPS.java +++ b/src/main/java/org/gcube/portlets/user/dataminermanager/server/smservice/SClient4WPS.java @@ -261,7 +261,7 @@ public class SClient4WPS extends SClient { operatorsClass.add(op); - //logger.debug("OperatorClass: " + operatorsClass); + // logger.debug("OperatorClass: " + operatorsClass); return operatorsClass; } @@ -356,7 +356,7 @@ public class SClient4WPS extends SClient { return; } catch (Throwable e) { - logger.error("RequestCapability(): "+e.getLocalizedMessage()); + logger.error("RequestCapability(): " + e.getLocalizedMessage()); e.printStackTrace(); throw new Exception(e.getLocalizedMessage(), e); } finally { @@ -989,7 +989,7 @@ public class SClient4WPS extends SClient { @Override public OutputData getOutputDataByComputationId(ComputationId computationId) throws Exception { - Map resources = retrieveOutput(computationId); + LinkedHashMap resources = retrieveOutput(computationId); MapResource mapResource = new MapResource("mapResource", "Resources", "Resources", resources); OutputData outputData = new OutputData(computationId, mapResource); @@ -997,10 +997,10 @@ public class SClient4WPS extends SClient { return outputData; } - private Map retrieveOutput(ComputationId computationId) - throws Exception { - Map outputResource = new LinkedHashMap<>(); - Map outputParameters = new LinkedHashMap<>(); + private LinkedHashMap retrieveOutput( + ComputationId computationId) throws Exception { + LinkedHashMap outputResource = new LinkedHashMap<>(); + LinkedHashMap outputParameters = new LinkedHashMap<>(); ProcessInformations processInformations = runningProcess .get(computationId); @@ -1289,73 +1289,159 @@ public class SClient4WPS extends SClient { @Override public ComputationData getComputationDataByComputationProperties( Map computationProperties) throws Exception { - if (computationProperties == null || computationProperties.isEmpty()) { - throw new Exception("Invalid computation properties: " - + computationProperties); - } + try { + if (computationProperties == null + || computationProperties.isEmpty()) { + throw new Exception("Invalid computation properties: " + + computationProperties); + } - String compId = computationProperties.get("computation_id"); + String compId = computationProperties.get("computation_id"); - String operatorId = computationProperties.get("operator_id"); - String operatorName = computationProperties.get("operator_name"); - String operatorDescritpion = computationProperties - .get("operator_description"); - String vre = computationProperties.get("VRE"); - String startDate = computationProperties.get("start_date"); - String endDate = computationProperties.get("end_date"); - String status = computationProperties.get("status"); - String executionType = computationProperties.get("execution_type"); + String operatorId = computationProperties.get("operator_id"); + String operatorName = computationProperties.get("operator_name"); + String operatorDescritpion = computationProperties + .get("operator_description"); + String vre = computationProperties.get("VRE"); + String startDate = computationProperties.get("start_date"); + String endDate = computationProperties.get("end_date"); + String status = computationProperties.get("status"); + String executionType = computationProperties.get("execution_type"); - ComputationId computationId = new ComputationId(); - computationId.setId(compId); - computationId.setOperatorId(operatorId); - computationId.setOperatorName(operatorName); + ComputationId computationId = new ComputationId(); + computationId.setId(compId); + computationId.setOperatorId(operatorId); + computationId.setOperatorName(operatorName); - LinkedHashMap inputValueParameters = new LinkedHashMap<>(); - LinkedHashMap outputValueParameters = new LinkedHashMap<>(); + LinkedHashMap inputValueParameters = new LinkedHashMap<>(); + LinkedHashMap outputValueParameters = new LinkedHashMap<>(); - for (String key : computationProperties.keySet()) { - if (key != null) { - if (key.startsWith("input")) { - int inputSeparatorIndex = key.indexOf("_"); - String inputKey = key.substring(inputSeparatorIndex + 1); - if (inputKey.compareToIgnoreCase("user.name") != 0 - && inputKey.compareToIgnoreCase("scope") != 0) { - inputValueParameters.put(inputKey, - computationProperties.get(key)); + for (String key : computationProperties.keySet()) { + if (key != null) { + if (key.startsWith("input")) { + int inputSeparatorIndex = key.indexOf("_"); + String inputKey = key + .substring(inputSeparatorIndex + 1); + if (inputKey.compareToIgnoreCase("user.name") != 0 + && inputKey.compareToIgnoreCase("scope") != 0) { + inputValueParameters.put(inputKey, + computationProperties.get(key)); - } + } - } else { - if (key.startsWith("output")) { - int outputSeparatorIndex = key.indexOf("_"); - String outputKey = key - .substring(outputSeparatorIndex + 1); - outputValueParameters.put(outputKey, - computationProperties.get(key)); + } else { + if (key.startsWith("output")) { + int outputSeparatorIndex = key.indexOf("_"); + String outputKey = key + .substring(outputSeparatorIndex + 1); + outputValueParameters.put(outputKey, + computationProperties.get(key)); + + } } } - } + + ComputationValueBuilder computationValueBuilder = new ComputationValueBuilder( + inputValueParameters); + LinkedHashMap inputParameters = computationValueBuilder + .create(); + computationValueBuilder = new ComputationValueBuilder( + outputValueParameters); + LinkedHashMap outputParameters = computationValueBuilder + .create(); + + logger.debug("inputParameters: " + inputParameters); + logger.debug("outputParameters: " + outputParameters); + + LinkedHashMap inputParametersSorted = new LinkedHashMap<>(); + LinkedHashMap outputParametersSorted = new LinkedHashMap<>(); + + ProcessInformations processInfos = describeProcess(operatorId); + if (processInfos != null) { + for (InputDescriptionType inputDesc : processInfos.getInputs()) { + if (inputDesc != null + && inputDesc.getIdentifier() != null + && inputDesc.getIdentifier().getStringValue() != null) { + logger.debug("InputParametr Match: " + + inputDesc.getIdentifier().getStringValue()); + ComputationValue inputComputationValue = inputParameters + .get(inputDesc.getIdentifier().getStringValue()); + inputParametersSorted.put(inputDesc.getIdentifier() + .getStringValue(), inputComputationValue); + } + + } + + } else { + inputParametersSorted.putAll(inputParameters); + } + + ArrayList keys=new ArrayList<>(outputParameters.keySet()); + Comparator comparator = new Comparator() { + public int compare(String c1, String c2) { + Integer c1Int=null; + + try { + c1Int=Integer.valueOf(c1); + } catch(NumberFormatException e){ + + } + + Integer c2Int=null; + + try { + c2Int=Integer.valueOf(c2); + } catch(NumberFormatException e){ + + } + + if(c1Int!=null && c2Int!=null){ + return c1Int.compareTo(c2Int); + } else { + if(c1Int==null && c2Int==null){ + return c1.compareTo(c2); + } else { + if(c1Int==null){ + return -1; + } else { + return 1; + + } + } + } + } + }; + + Collections.sort(keys, comparator); + for(String key:keys){ + ComputationValue outputComputationValue = outputParameters + .get(key); + outputParametersSorted.put(key, outputComputationValue); + } + + ComputationData computationData = new ComputationData( + computationId, inputParametersSorted, + outputParametersSorted, operatorDescritpion, startDate, + endDate, status, executionType, vre); + + logger.debug("ComputationData: " + computationData); + return computationData; + + } catch (DataMinerServiceException e) { + logger.error("Error in getComutationDataByComputationProperties: " + + e.getLocalizedMessage()); + e.printStackTrace(); + throw e; + } catch (Throwable e) { + logger.error("Error in getComutationDataByComputationProperties: " + + e.getLocalizedMessage()); + e.printStackTrace(); + throw new Exception(e.getLocalizedMessage(), e); + } - ComputationValueBuilder computationValueBuilder = new ComputationValueBuilder( - inputValueParameters); - LinkedHashMap inputParameters = computationValueBuilder - .create(); - computationValueBuilder = new ComputationValueBuilder( - outputValueParameters); - LinkedHashMap outputParameters = computationValueBuilder - .create(); - - ComputationData computationData = new ComputationData(computationId, - inputParameters, outputParameters, operatorDescritpion, - startDate, endDate, status, executionType, vre); - - logger.debug("ComputationData: " + computationData); - return computationData; - } } diff --git a/src/main/java/org/gcube/portlets/user/dataminermanager/shared/Constants.java b/src/main/java/org/gcube/portlets/user/dataminermanager/shared/Constants.java index 62a24db..f46bb2a 100644 --- a/src/main/java/org/gcube/portlets/user/dataminermanager/shared/Constants.java +++ b/src/main/java/org/gcube/portlets/user/dataminermanager/shared/Constants.java @@ -19,9 +19,9 @@ public class Constants { public static final String DEFAULT_USER = "giancarlo.panichi"; public static final String DEFAULT_ROLE = "OrganizationMember"; - //public static final String DEFAULT_SCOPE = "/gcube/devsec/devVRE"; + public static final String DEFAULT_SCOPE = "/gcube/devsec/devVRE"; // public final static String DEFAULT_SCOPE = "/gcube/devNext"; - public final static String DEFAULT_SCOPE = "/gcube/devNext/NextNext"; + //public final static String DEFAULT_SCOPE = "/gcube/devNext/NextNext"; diff --git a/src/main/java/org/gcube/portlets/user/dataminermanager/shared/data/computations/ComputationValue.java b/src/main/java/org/gcube/portlets/user/dataminermanager/shared/data/computations/ComputationValue.java index 937ec5c..0f9d520 100644 --- a/src/main/java/org/gcube/portlets/user/dataminermanager/shared/data/computations/ComputationValue.java +++ b/src/main/java/org/gcube/portlets/user/dataminermanager/shared/data/computations/ComputationValue.java @@ -16,6 +16,7 @@ public class ComputationValue implements Serializable { public ComputationValue() { super(); + this.type = ComputationValueType.String; } public ComputationValue(ComputationValueType type) { diff --git a/src/main/java/org/gcube/portlets/user/dataminermanager/shared/data/computations/ComputationValueFile.java b/src/main/java/org/gcube/portlets/user/dataminermanager/shared/data/computations/ComputationValueFile.java index f2d7415..097ad0b 100644 --- a/src/main/java/org/gcube/portlets/user/dataminermanager/shared/data/computations/ComputationValueFile.java +++ b/src/main/java/org/gcube/portlets/user/dataminermanager/shared/data/computations/ComputationValueFile.java @@ -13,7 +13,7 @@ public class ComputationValueFile extends ComputationValue { private String mimeType; public ComputationValueFile() { - super(); + super(ComputationValueType.File); } public ComputationValueFile(String url, String fileName, String mimeType) { diff --git a/src/main/java/org/gcube/portlets/user/dataminermanager/shared/data/computations/ComputationValueFileList.java b/src/main/java/org/gcube/portlets/user/dataminermanager/shared/data/computations/ComputationValueFileList.java index ad82a23..ea94daa 100644 --- a/src/main/java/org/gcube/portlets/user/dataminermanager/shared/data/computations/ComputationValueFileList.java +++ b/src/main/java/org/gcube/portlets/user/dataminermanager/shared/data/computations/ComputationValueFileList.java @@ -15,7 +15,7 @@ public class ComputationValueFileList extends ComputationValue { private String separator; public ComputationValueFileList() { - super(); + super(ComputationValueType.FileList); } public ComputationValueFileList(ArrayList fileList, diff --git a/src/main/java/org/gcube/portlets/user/dataminermanager/shared/data/computations/ComputationValueImage.java b/src/main/java/org/gcube/portlets/user/dataminermanager/shared/data/computations/ComputationValueImage.java index 430b2f1..d87d875 100644 --- a/src/main/java/org/gcube/portlets/user/dataminermanager/shared/data/computations/ComputationValueImage.java +++ b/src/main/java/org/gcube/portlets/user/dataminermanager/shared/data/computations/ComputationValueImage.java @@ -13,7 +13,7 @@ public class ComputationValueImage extends ComputationValue { private String mimeType; public ComputationValueImage(){ - super(); + super(ComputationValueType.Image); } public ComputationValueImage(String url, String fileName, String mimeType) { diff --git a/src/main/java/org/gcube/portlets/user/dataminermanager/shared/data/output/MapResource.java b/src/main/java/org/gcube/portlets/user/dataminermanager/shared/data/output/MapResource.java index a1e2f3f..67f9d3f 100644 --- a/src/main/java/org/gcube/portlets/user/dataminermanager/shared/data/output/MapResource.java +++ b/src/main/java/org/gcube/portlets/user/dataminermanager/shared/data/output/MapResource.java @@ -4,6 +4,7 @@ package org.gcube.portlets.user.dataminermanager.shared.data.output; import java.io.Serializable; +import java.util.LinkedHashMap; import java.util.Map; /** @@ -18,7 +19,7 @@ public class MapResource extends Resource implements Serializable { * */ private static final long serialVersionUID = 8772836076910728324L; - private Map map; + private LinkedHashMap map; /** * @@ -29,7 +30,7 @@ public class MapResource extends Resource implements Serializable { } public MapResource(String resourceId, String name, String description, - Map map) { + LinkedHashMap map) { super(resourceId, name, description, ResourceType.MAP); this.map = map; } @@ -38,7 +39,7 @@ public class MapResource extends Resource implements Serializable { return map; } - public void setMap(Map map) { + public void setMap(LinkedHashMap map) { this.map = map; } diff --git a/src/main/resources/org/gcube/portlets/user/dataminermanager/dataminermanager.gwt.xml b/src/main/resources/org/gcube/portlets/user/dataminermanager/dataminermanager.gwt.xml index 36e1280..42a6cf3 100644 --- a/src/main/resources/org/gcube/portlets/user/dataminermanager/dataminermanager.gwt.xml +++ b/src/main/resources/org/gcube/portlets/user/dataminermanager/dataminermanager.gwt.xml @@ -10,7 +10,7 @@ - + @@ -36,14 +36,12 @@ value="ENABLED" /> --> - -