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

77 lines
2.2 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 eu.eudat.model.persist.descriptiontemplatedefinition.fielddata.LabelDataPersist;
2023-10-27 17:46:34 +02:00
import gr.cite.tools.data.builder.Builder;
import org.springframework.beans.factory.annotation.Autowired;
2023-10-31 10:19:52 +01:00
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
2023-10-27 17:46:34 +02:00
import org.springframework.context.ApplicationContext;
2023-10-31 10:19:52 +01:00
import org.springframework.context.annotation.Scope;
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 BOOLEAN_DECISION:
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:
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;
}
2023-10-30 14:07:59 +01:00
case WORD_LIST: {
2023-11-30 12:38:36 +01:00
item = this.applicationContext.getBean(WordListFieldDataHelperService.class);
2023-10-30 14:07:59 +01:00
break;
}
case AUTO_COMPLETE: {
item = this.applicationContext.getBean(AutoCompleteFieldDataHelperService.class);
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
}
}