use of org.molgenis.api.metadata.v3.exception.ReadOnlyFieldException in project molgenis by molgenis.
the class EntityTypeRequestMapperImpl method updateEntityType.
@SuppressWarnings({ "java:S1192" })
private // ATTRIBUTES constant in this class is not related to the one in this switch
void updateEntityType(EntityType entityType, Entry<String, Object> entry) {
switch(entry.getKey()) {
case "package":
String packageId = String.valueOf(entry.getValue());
Package pack = metaDataService.getPackage(packageId).orElseThrow(() -> new UnknownPackageException(packageId));
entityType.setPackage(pack);
break;
case "id":
case "abstract":
throw new ReadOnlyFieldException(entry.getKey(), "entityType");
case "extends":
String extendsValue = String.valueOf(entry.getValue());
EntityType parent = metaDataService.getEntityType(extendsValue).orElseThrow(() -> new UnknownEntityTypeException(extendsValue));
entityType.setExtends(parent);
break;
case "label":
I18nValue label = I18nValueMapper.toI18nValue(entry.getValue());
processI18nLabel(label, entityType);
break;
case "description":
I18nValue description = I18nValueMapper.toI18nValue(entry.getValue());
processI18nDescription(description, entityType);
break;
case "attributes":
if (entry.getValue() != null) {
Iterable<Attribute> attributes = mapAttributes(entityType, entry);
entityType.setOwnAllAttributes(attributes);
} else {
throw new EmptyAttributesException();
}
break;
case "tags":
case "backend":
throw new UnsupportedFieldException(entry.getKey());
default:
throw new InvalidKeyException("entityType", entry.getKey());
}
}
Aggregations