argos/dmp-backend/core/src/main/java/eu/eudat/service/fielddatahelper/FieldDataHelperServiceProvi...

73 lines
2.0 KiB
Java
Raw Normal View History

2023-10-27 17:46:34 +02:00
package eu.eudat.service.fielddatahelper;
import eu.eudat.commons.enums.FieldType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
2023-10-31 10:19:52 +01:00
import org.springframework.stereotype.Component;
2023-10-27 17:46:34 +02:00
2023-10-31 10:19:52 +01:00
@Component
2023-10-27 17:46:34 +02:00
public class FieldDataHelperServiceProvider {
@Autowired
private ApplicationContext applicationContext;
public FieldDataHelperService get(FieldType type){
BaseFieldDataHelperService<?, ?, ?, ? > item = null;
2023-10-27 17:46:34 +02:00
switch (type) {
case DATA_REPOSITORIES:
case PUB_REPOSITORIES:
case JOURNAL_REPOSITORIES:
case TAXONOMIES:
case LICENSES:
case PUBLICATIONS:
case REGISTRIES:
case SERVICES:
case RESEARCHERS:
case INTERNAL_DMP_ENTRIES_DATASETS:
case INTERNAL_DMP_ENTRIES_DMPS:
case INTERNAL_DMP_ENTRIES_RESEARCHERS:
case ORGANIZATIONS: {
item = this.applicationContext.getBean(LabelAndMultiplicityFieldDataHelperService.class);
2023-10-27 17:46:34 +02:00
break;
}
case RADIO_BOX: {
item = this.applicationContext.getBean(RadioBoxFieldDataHelperService.class);
break;
}
case RICH_TEXT_AREA:
case DATE_PICKER:
case TEXT_AREA:
case FREE_TEXT:
case TAGS:
case DATASET_IDENTIFIER:
case CURRENCY:
case CHECK_BOX:
2024-01-30 15:31:03 +01:00
case BOOLEAN_DECISION:
case VALIDATION: {
item = this.applicationContext.getBean(LabelFieldDataHelperService.class);
2023-10-27 17:46:34 +02:00
break;
}
2023-10-27 17:46:34 +02:00
case UPLOAD: {
item = this.applicationContext.getBean(UploadFieldDataHelperService.class);
break;
}
case EXTERNAL_DATASETS: {
item = this.applicationContext.getBean(ExternalDatasetFieldDataHelperService.class);
break;
}
2024-01-31 09:44:48 +01:00
case SELECT: {
item = this.applicationContext.getBean(SelectFieldDataHelperService.class);
2023-10-30 14:07:59 +01:00
break;
}
case AUTO_COMPLETE: {
2024-01-31 13:33:24 +01:00
item = this.applicationContext.getBean(ExternalSelectFieldDataHelperService.class);
2023-10-30 14:07:59 +01:00
break;
}
2023-10-27 17:46:34 +02:00
default: throw new RuntimeException("unrecognized builder " + type.getValue());
}
item.setFieldType(type);
return item;
2023-10-27 17:46:34 +02:00
}
}