2024-04-26 12:50:56 +02:00
|
|
|
package org.opencdmp.model.publicapi.datasetwizard;
|
2023-11-28 11:54:08 +01:00
|
|
|
|
2024-04-26 12:50:56 +02:00
|
|
|
import org.opencdmp.commons.types.descriptiontemplate.RuleEntity;
|
2023-11-28 11:54:08 +01:00
|
|
|
|
|
|
|
public class Rule {
|
|
|
|
private String sourceField;
|
|
|
|
private String targetField;
|
|
|
|
private String requiredValue;
|
|
|
|
private String type;
|
|
|
|
|
|
|
|
public String getSourceField() {
|
2024-05-02 09:46:36 +02:00
|
|
|
return this.sourceField;
|
2023-11-28 11:54:08 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public void setSourceField(String sourceField) {
|
|
|
|
this.sourceField = sourceField;
|
|
|
|
}
|
|
|
|
|
|
|
|
public String getTargetField() {
|
2024-05-02 09:46:36 +02:00
|
|
|
return this.targetField;
|
2023-11-28 11:54:08 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public void setTargetField(String targetField) {
|
|
|
|
this.targetField = targetField;
|
|
|
|
}
|
|
|
|
|
|
|
|
public String getRequiredValue() {
|
2024-05-02 09:46:36 +02:00
|
|
|
return this.requiredValue;
|
2023-11-28 11:54:08 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public void setRequiredValue(String requiredValue) {
|
|
|
|
this.requiredValue = requiredValue;
|
|
|
|
}
|
|
|
|
|
|
|
|
public String getType() {
|
2024-05-02 09:46:36 +02:00
|
|
|
return this.type;
|
2023-11-28 11:54:08 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public void setType(String type) {
|
|
|
|
this.type = type;
|
|
|
|
}
|
|
|
|
|
|
|
|
public Rule fromDefinitionRule(RuleEntity rule) {
|
|
|
|
this.targetField = rule.getTarget();
|
2024-03-20 17:40:34 +01:00
|
|
|
//TODO
|
|
|
|
if (rule.getTextValue() != null && !rule.getTextListValue().isEmpty()) this.requiredValue = rule.getTextValue();
|
|
|
|
else if (rule.getDateValue() != null) this.requiredValue = rule.getDateValue().toString();
|
2024-05-02 09:46:36 +02:00
|
|
|
else if (rule.getBooleanValue() != null) this.requiredValue = rule.getBooleanValue().toString();
|
2024-03-20 17:40:34 +01:00
|
|
|
else if (rule.getTextListValue() != null) this.requiredValue = String.join(", ", rule.getTextListValue());
|
2023-11-28 11:54:08 +01:00
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|