net.n2oapp.framework.api.metadata.local.CompiledObject Maven / Gradle / Ivy
package net.n2oapp.framework.api.metadata.local;
import lombok.Getter;
import lombok.Setter;
import net.n2oapp.framework.api.data.validation.Validation;
import net.n2oapp.framework.api.metadata.Compiled;
import net.n2oapp.framework.api.metadata.aware.IdAware;
import net.n2oapp.framework.api.metadata.aware.PropertiesAware;
import net.n2oapp.framework.api.metadata.global.dao.object.AbstractParameter;
import net.n2oapp.framework.api.metadata.global.dao.object.N2oObject;
import net.n2oapp.framework.api.metadata.global.dao.object.field.ObjectSimpleField;
import java.util.*;
import static java.util.Objects.isNull;
import static java.util.Objects.nonNull;
/**
* Скомпилированный объект, описыващий object.xml файл
*/
@Getter
@Setter
public class CompiledObject implements Compiled, IdAware {
public static final String VALIDATION_RESULT_PARAM = "validation";
private String id;
private String name;
private Map operations;
private List objectFields;
private Map objectFieldsMap;
//все валидации объекта
private List validations;
//все валидации объекта разложенные в мапу по идентификаторам
private Map validationsMap;
private String tableName;
private String appName;
private String moduleName;
private String serviceName;
private List fieldValidations;
public Map getObjectFieldsMap() {
return objectFieldsMap;
}
public List getObjectFields() {
return objectFields;
}
public void addValidation(Validation v) {
if (isNull(validations))
validations = new ArrayList<>();
if (isNull(validationsMap))
validationsMap = new HashMap<>();
validationsMap.put(v.getId(), v);
validations.add(v);
}
@Getter
@Setter
public static class Operation extends N2oObject.Operation implements Compiled, PropertiesAware {
private Map properties;
private Map inParametersMap;
private Map outParametersMap;
private Map failOutParametersMap;
private List validationList;
private Map validationsMap;
private Map whiteListValidationsMap;
public Map getWhiteListValidationsMap() {
return nonNull(whiteListValidationsMap) ? whiteListValidationsMap : Collections.emptyMap();
}
public void setWhiteListValidationsMap(Map whiteListValidationsMap) {
this.whiteListValidationsMap = whiteListValidationsMap;
}
public boolean isValidationEnable() {
return nonNull(getValidationList()) && !getValidationList().isEmpty();
}
public Map getValidationsMap() {
return nonNull(validationsMap) ? validationsMap : Collections.emptyMap();
}
}
}