argos/backend/core/src/main/java/org/opencdmp/model/builder/commonmodels/dmpblueprint/SystemFieldCommonModelBuild...

40 lines
1.7 KiB
Java

package org.opencdmp.model.builder.commonmodels.dmpblueprint;
import org.opencdmp.commonmodels.enums.DmpBlueprintSystemFieldType;
import org.opencdmp.commonmodels.models.dmpblueprint.SystemFieldModel;
import org.opencdmp.commons.types.dmpblueprint.SystemFieldEntity;
import org.opencdmp.convention.ConventionService;
import gr.cite.tools.exception.MyApplicationException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
@Component
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public class SystemFieldCommonModelBuilder extends FieldCommonModelBuilder<SystemFieldModel, SystemFieldEntity> {
@Autowired
public SystemFieldCommonModelBuilder(
ConventionService conventionService) {
super(conventionService);
}
protected SystemFieldModel getInstance() {
return new SystemFieldModel();
}
protected SystemFieldModel buildChild(SystemFieldEntity data, SystemFieldModel model) {
switch (data.getType()){
case AccessRights -> model.setSystemFieldType(DmpBlueprintSystemFieldType.AccessRights);
case Contact -> model.setSystemFieldType(DmpBlueprintSystemFieldType.Contact);
case Description -> model.setSystemFieldType(DmpBlueprintSystemFieldType.Description);
case Language -> model.setSystemFieldType(DmpBlueprintSystemFieldType.Language);
case Title -> model.setSystemFieldType(DmpBlueprintSystemFieldType.Title);
case User -> model.setSystemFieldType(DmpBlueprintSystemFieldType.User);
default -> throw new MyApplicationException("unrecognized type " + data.getType());
}
return model;
}
}