Skip to content
Snippets Groups Projects
Commit e4ee5ade authored by kfilippopolitis's avatar kfilippopolitis
Browse files

Added the filtering on rows which have null values

parent 89c85f06
No related branches found
No related tags found
1 merge request!23Dev/mip 62/mip engine integration with the mip portalbackend
package eu.hbp.mip.models.DTOs; package eu.hbp.mip.models.DTOs;
import com.google.gson.Gson;
import com.google.gson.annotations.SerializedName; import com.google.gson.annotations.SerializedName;
import eu.hbp.mip.utils.JsonConverters;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
import java.util.Arrays; import java.util.*;
import java.util.Hashtable;
import java.util.List;
@Getter @Getter
@Setter @Setter
...@@ -74,21 +72,84 @@ public class AlgorithmDTO { ...@@ -74,21 +72,84 @@ public class AlgorithmDTO {
private List<String> valueEnumerations; private List<String> valueEnumerations;
} }
@Getter
@Setter
public static class Rule
{
@SerializedName("id")
private String id;
@SerializedName("type")
private String type;
@SerializedName("operator")
private String operator;
@SerializedName("value")
private Object value;
public Rule(String id, String type, String operator, Object value) {
this.id = id;
this.type = type;
this.operator = operator;
this.value = value;
}
}
@Getter
@Setter
public static class Filters
{
@SerializedName("condition")
private String condition;
@SerializedName("rules")
private List<Object> rules;
@SerializedName("valid")
private boolean valid;
public Filters(String condition, List<Object> rules, boolean valid) {
this.condition = condition;
this.rules = rules;
this.valid = valid;
}
}
public MIPEngineBody convertToMIPEngineBody() public MIPEngineBody convertToMIPEngineBody()
{ {
MIPEngineBody mipEngineBody = new MIPEngineBody(); MIPEngineBody mipEngineBody = new MIPEngineBody();
MIPEngineBody.InputData inputData = new MIPEngineBody.InputData(); MIPEngineBody.InputData inputData = new MIPEngineBody.InputData();
List<Object> rules = new ArrayList<>();
this.parameters.forEach(parameter -> { this.parameters.forEach(parameter -> {
if(parameter.getName().equals("x")) if(parameter.getName().equals("x")) {
inputData.setX(Arrays.asList(parameter.getValue().split(","))); List<String> x = Arrays.asList(parameter.getValue().split(","));
if(parameter.getName().equals("y")) x.forEach(column -> rules.add(new Rule(column, parameter.getColumnValuesSQLType(), "is_not_null", null)));
inputData.setY(Arrays.asList(parameter.getValue().split(","))); inputData.setX(x);
if(parameter.getName().equals("datasets")) }
inputData.setDatasets(Arrays.asList(parameter.getValue().split(","))); if(parameter.getName().equals("y")) {
List<String> y = Arrays.asList(parameter.getValue().split(","));
y.forEach(column -> rules.add(new Rule(column, parameter.getColumnValuesSQLType(), "is_not_null", null)));
inputData.setY(y);
}
if(parameter.getName().equals("dataset")){
List<String> datasets = Arrays.asList(parameter.getValue().split(","));
rules.add(new Rule("dataset","string", "in", datasets));
inputData.setDatasets(datasets);
}
String pathology;
if(parameter.getName().equals("pathology")) if(parameter.getName().equals("pathology"))
inputData.setPathology(parameter.getValue()); inputData.setPathology(parameter.getValue());
if(parameter.getName().equals("filter")){
if (parameter.getValue() != "")
rules.add(JsonConverters.convertJsonStringToObject(parameter.getValue(), Filters.class));
}
}); });
Filters filters = new Filters("AND", rules, true);
inputData.setFilters(filters);
mipEngineBody.setInputdata(inputData); mipEngineBody.setInputdata(inputData);
return mipEngineBody; return mipEngineBody;
} }
......
...@@ -97,7 +97,7 @@ public class MIPEngineAlgorithmDTO { ...@@ -97,7 +97,7 @@ public class MIPEngineAlgorithmDTO {
public AlgorithmDTO convertToAlgorithmDTO() public AlgorithmDTO convertToAlgorithmDTO()
{ {
AlgorithmDTO algorithmDTO = new AlgorithmDTO(); AlgorithmDTO algorithmDTO = new AlgorithmDTO();
algorithmDTO.setName(this.name); algorithmDTO.setName(this.name.toUpperCase());
algorithmDTO.setLabel(this.label); algorithmDTO.setLabel(this.label);
algorithmDTO.setDesc(this.desc); algorithmDTO.setDesc(this.desc);
algorithmDTO.setType("mipengine"); algorithmDTO.setType("mipengine");
......
...@@ -22,7 +22,7 @@ public class MIPEngineBody { ...@@ -22,7 +22,7 @@ public class MIPEngineBody {
@SerializedName("datasets") @SerializedName("datasets")
private List<String> datasets; private List<String> datasets;
@SerializedName("filters") @SerializedName("filters")
private String filters; private AlgorithmDTO.Filters filters;
@SerializedName("x") @SerializedName("x")
private List<String> x; private List<String> x;
@SerializedName("y") @SerializedName("y")
......
...@@ -544,8 +544,8 @@ public class ExperimentService { ...@@ -544,8 +544,8 @@ public class ExperimentService {
// Run with the appropriate engine // Run with the appropriate engine
if (algorithmType.equals("mipengine")) { if (algorithmType.equals("mipengine")) {
MIPEngineBody mipEngineBody = experimentDTO.getAlgorithm().convertToMIPEngineBody(); MIPEngineBody mipEngineBody = experimentDTO.getAlgorithm().convertToMIPEngineBody();
String body = gson.toJson(mipEngineBody); String body = JsonConverters.convertObjectToJsonString(mipEngineBody);
String url = mipengineAlgorithmsUrl + "/" + algorithmName; String url = mipengineAlgorithmsUrl + "/" + algorithmName.toLowerCase();
logger.LogUserAction("url: " + url + ", body: " + body); logger.LogUserAction("url: " + url + ", body: " + body);
logger.LogUserAction("Algorithm runs on MIPEngine."); logger.LogUserAction("Algorithm runs on MIPEngine.");
return runMIPEngineExperiment(url, body); return runMIPEngineExperiment(url, body);
...@@ -601,7 +601,6 @@ public class ExperimentService { ...@@ -601,7 +601,6 @@ public class ExperimentService {
} catch (Exception e) { } catch (Exception e) {
throw new InternalServerError("Error occurred : " + e.getMessage()); throw new InternalServerError("Error occurred : " + e.getMessage());
} }
System.out.println(results);
// Results are stored in the experiment object // Results are stored in the experiment object
List<Object> resultDTOS = formattingMIPEngienResult(String.valueOf(results)); List<Object> resultDTOS = formattingMIPEngienResult(String.valueOf(results));
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment