use of org.motechproject.mds.exception.field.FieldReadOnlyException in project motech by motech.
the class FieldReader method readField.
public void readField() throws IOException {
Field field = new Field();
field.setEntity(entity);
jsonReader.beginObject();
field.setName(objectReader.readString("name"));
field.setDisplayName(objectReader.readString("displayName"));
field.setRequired(objectReader.readBoolean("required"));
field.setUnique(objectReader.readBoolean("unique"));
field.setDefaultValue(objectReader.readString("defaultValue"));
field.setTooltip(objectReader.readString("tooltip"));
field.setPlaceholder(objectReader.readString("placeholder"));
field.setNonEditable(objectReader.readBoolean("nonEditable"));
field.setNonDisplayable(objectReader.readBoolean("nonDisplayable"));
field.setType(importContext.getType(objectReader.readString("type")));
readMetadata(field);
readValidations(field);
readSettings(field);
jsonReader.endObject();
Field existingField = entity.getField(field.getName());
if (null == existingField || !existingField.isReadOnly()) {
entity.addField(field);
} else {
throw new FieldReadOnlyException(entity.getName(), existingField.getName());
}
}
Aggregations