refs 4823: DataMiner - Preserve the order of the output (Example Bionym Local)

Task-Url: https://support.d4science.org/issues/4823

In the case of Check The Computation, now the interaface shows the input parameters in the order requested by the algorithm and the output parameters sorted by name

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/data-miner-manager@130969 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Giancarlo Panichi 2016-08-04 13:34:52 +00:00
parent 0c14d3966e
commit e310813cde
11 changed files with 417 additions and 247 deletions

View File

@ -32,6 +32,7 @@ public class ComputationsPanel extends SimpleContainer {
public ComputationsPanel() {
super();
Log.debug("ComputationsPanel");
init();
create();
bind();

View File

@ -37,8 +37,9 @@ public class ComputationsViewerPanel extends FramedPanel {
public ComputationsViewerPanel(ComputationData computationData) {
super();
Log.debug("ComputationsPanel");
Log.debug("ComputationsViewerPanel");
this.computationData = computationData;
Log.debug("ComputationData: " + computationData);
init();
create();
@ -58,15 +59,21 @@ public class ComputationsViewerPanel extends FramedPanel {
}
private void create() {
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 {
+ "</b></center>");
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,11 +122,11 @@ public class ComputationsViewerPanel extends FramedPanel {
FieldSet operatorFieldSet = operatorView();
v.add(operatorFieldSet, new VerticalLayoutData(-1, -1, new Margins(10)));
}
private FieldSet operatorView() {
try {
VerticalLayoutContainer operatorVBox = new VerticalLayoutContainer();
TextField operatorNameField = new TextField();
operatorNameField.setValue(computationData.getComputationId()
@ -132,25 +149,35 @@ public class ComputationsViewerPanel extends FramedPanel {
operatorDescriptionLabel.setLabelWidth(200);
operatorDescriptionLabel.setLabelWordWrap(true);
operatorDescriptionLabel.setHeight(65);
operatorVBox.add(operatorDescriptionLabel, new VerticalLayoutData(1,
-1, new Margins(0,5,0,5)));
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);
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() {
try {
VerticalLayoutContainer detailsVBox = new VerticalLayoutContainer();
TextField startDateField = new TextField();
startDateField.setValue(computationData.getStartDate());
startDateField.setReadOnly(true);
FieldLabel startDateLabel = new FieldLabel(startDateField, "Start Date");
FieldLabel startDateLabel = new FieldLabel(startDateField,
"Start Date");
startDateLabel.setLabelWidth(200);
startDateLabel.setLabelWordWrap(true);
detailsVBox.add(startDateLabel, new VerticalLayoutData(1, -1,
@ -171,8 +198,8 @@ public class ComputationsViewerPanel extends FramedPanel {
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)));
detailsVBox.add(statusLabel, new VerticalLayoutData(1, -1,
new Margins(0, 4, 0, 4)));
TextField vreField = new TextField();
vreField.setValue(computationData.getVre());
@ -180,8 +207,8 @@ public class ComputationsViewerPanel extends FramedPanel {
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)));
detailsVBox.add(vreLabel, new VerticalLayoutData(1, -1,
new Margins(0, 4, 0, 4)));
FieldSet detailsFieldSet = new FieldSet();
detailsFieldSet.setHeadingText("Computation Details");
@ -189,34 +216,58 @@ public class ComputationsViewerPanel extends FramedPanel {
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() {
try {
VerticalLayoutContainer inputVBox = new VerticalLayoutContainer();
LinkedHashMap<String, ComputationValue> 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);
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);
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);
simpleContainer = new ComputationValueFileListPanel(
computationValueFileList);
fieldLabel = new FieldLabel(simpleContainer, key);
fieldLabel.setLabelWidth(200);
fieldLabel.setLabelWordWrap(true);
@ -242,34 +293,57 @@ public class ComputationsViewerPanel extends FramedPanel {
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() {
try {
VerticalLayoutContainer outputVBox = new VerticalLayoutContainer();
LinkedHashMap<String, ComputationValue> 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);
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);
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);
simpleContainer = new ComputationValueFileListPanel(
computationValueFileList);
fieldLabel = new FieldLabel(simpleContainer, key);
fieldLabel.setLabelWidth(200);
fieldLabel.setLabelWordWrap(true);
@ -294,6 +368,12 @@ public class ComputationsViewerPanel extends FramedPanel {
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;
}
}
}

View File

@ -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<String, String> properties = StorageUtil.getProperties(
aslSession.getUsername(), itemDescription.getId());
logger.debug("Properties: " + properties);
SClient smClient = SessionUtil.getSClient(aslSession, session);
ComputationData computationData = smClient

View File

@ -989,7 +989,7 @@ public class SClient4WPS extends SClient {
@Override
public OutputData getOutputDataByComputationId(ComputationId computationId)
throws Exception {
Map<String, Resource> resources = retrieveOutput(computationId);
LinkedHashMap<String, Resource> 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<String, Resource> retrieveOutput(ComputationId computationId)
throws Exception {
Map<String, Resource> outputResource = new LinkedHashMap<>();
Map<String, Parameter> outputParameters = new LinkedHashMap<>();
private LinkedHashMap<String, Resource> retrieveOutput(
ComputationId computationId) throws Exception {
LinkedHashMap<String, Resource> outputResource = new LinkedHashMap<>();
LinkedHashMap<String, Parameter> outputParameters = new LinkedHashMap<>();
ProcessInformations processInformations = runningProcess
.get(computationId);
@ -1289,7 +1289,9 @@ public class SClient4WPS extends SClient {
@Override
public ComputationData getComputationDataByComputationProperties(
Map<String, String> computationProperties) throws Exception {
if (computationProperties == null || computationProperties.isEmpty()) {
try {
if (computationProperties == null
|| computationProperties.isEmpty()) {
throw new Exception("Invalid computation properties: "
+ computationProperties);
}
@ -1318,7 +1320,8 @@ public class SClient4WPS extends SClient {
if (key != null) {
if (key.startsWith("input")) {
int inputSeparatorIndex = key.indexOf("_");
String inputKey = key.substring(inputSeparatorIndex + 1);
String inputKey = key
.substring(inputSeparatorIndex + 1);
if (inputKey.compareToIgnoreCase("user.name") != 0
&& inputKey.compareToIgnoreCase("scope") != 0) {
inputValueParameters.put(inputKey,
@ -1350,12 +1353,95 @@ public class SClient4WPS extends SClient {
LinkedHashMap<String, ComputationValue> outputParameters = computationValueBuilder
.create();
ComputationData computationData = new ComputationData(computationId,
inputParameters, outputParameters, operatorDescritpion,
startDate, endDate, status, executionType, vre);
logger.debug("inputParameters: " + inputParameters);
logger.debug("outputParameters: " + outputParameters);
LinkedHashMap<String, ComputationValue> inputParametersSorted = new LinkedHashMap<>();
LinkedHashMap<String, ComputationValue> 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<String> keys=new ArrayList<>(outputParameters.keySet());
Comparator<String> comparator = new Comparator<String>() {
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);
}
}
}

View File

@ -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";

View File

@ -16,6 +16,7 @@ public class ComputationValue implements Serializable {
public ComputationValue() {
super();
this.type = ComputationValueType.String;
}
public ComputationValue(ComputationValueType type) {

View File

@ -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) {

View File

@ -15,7 +15,7 @@ public class ComputationValueFileList extends ComputationValue {
private String separator;
public ComputationValueFileList() {
super();
super(ComputationValueType.FileList);
}
public ComputationValueFileList(ArrayList<ComputationValue> fileList,

View File

@ -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) {

View File

@ -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<String, Resource> map;
private LinkedHashMap<String, Resource> map;
/**
*
@ -29,7 +30,7 @@ public class MapResource extends Resource implements Serializable {
}
public MapResource(String resourceId, String name, String description,
Map<String, Resource> map) {
LinkedHashMap<String, Resource> 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<String, Resource> map) {
public void setMap(LinkedHashMap<String, Resource> map) {
this.map = map;
}

View File

@ -36,14 +36,12 @@
value="ENABLED" /> <set-property name="log_SystemLogger" value="ENABLED"
/> -->
<set-property name="log_ConsoleLogger" value="DISABLED" />
<set-property name="log_DivLogger" value="DISABLED" />
<set-property name="log_GWTLogger" value="DISABLED" />
<set-property name="log_SystemLogger" value="DISABLED" />
<source path='client' />
<source path='shared' />