argos/dmp-backend/core/src/main/java/eu/eudat/model/publicapi/datasetwizard/Rule.java

54 lines
1.5 KiB
Java

package eu.eudat.model.publicapi.datasetwizard;
import eu.eudat.commons.types.descriptiontemplate.RuleEntity;
public class Rule {
private String sourceField;
private String targetField;
private String requiredValue;
private String type;
public String getSourceField() {
return sourceField;
}
public void setSourceField(String sourceField) {
this.sourceField = sourceField;
}
public String getTargetField() {
return targetField;
}
public void setTargetField(String targetField) {
this.targetField = targetField;
}
public String getRequiredValue() {
return requiredValue;
}
public void setRequiredValue(String requiredValue) {
this.requiredValue = requiredValue;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public Rule fromDefinitionRule(RuleEntity rule) {
this.targetField = rule.getTarget();
//TODO
if (rule.getTextValue() != null && !rule.getTextListValue().isEmpty()) this.requiredValue = rule.getTextValue();
else if (rule.getDateValue() != null) this.requiredValue = rule.getDateValue().toString();
else if (rule.getTextListValue() != null) this.requiredValue = String.join(", ", rule.getTextListValue());
else if (rule.getExternalIdentifier() != null) this.requiredValue = rule.getExternalIdentifier().getIdentifier();
return this;
}
}