73 lines
2.0 KiB
Java
73 lines
2.0 KiB
Java
package eu.eudat.service.fielddatahelper;
|
|
|
|
import eu.eudat.commons.enums.FieldType;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.context.ApplicationContext;
|
|
import org.springframework.stereotype.Component;
|
|
|
|
@Component
|
|
public class FieldDataHelperServiceProvider {
|
|
|
|
@Autowired
|
|
private ApplicationContext applicationContext;
|
|
|
|
public FieldDataHelperService get(FieldType type){
|
|
BaseFieldDataHelperService<?, ?, ?, ? > item = null;
|
|
|
|
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);
|
|
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 BOOLEAN_DECISION:
|
|
case VALIDATION: {
|
|
item = this.applicationContext.getBean(LabelFieldDataHelperService.class);
|
|
break;
|
|
}
|
|
case UPLOAD: {
|
|
item = this.applicationContext.getBean(UploadFieldDataHelperService.class);
|
|
break;
|
|
}
|
|
case EXTERNAL_DATASETS: {
|
|
item = this.applicationContext.getBean(ExternalDatasetFieldDataHelperService.class);
|
|
break;
|
|
}
|
|
case SELECT: {
|
|
item = this.applicationContext.getBean(SelectFieldDataHelperService.class);
|
|
break;
|
|
}
|
|
case AUTO_COMPLETE: {
|
|
item = this.applicationContext.getBean(AutoCompleteFieldDataHelperService.class);
|
|
break;
|
|
}
|
|
default: throw new RuntimeException("unrecognized builder " + type.getValue());
|
|
}
|
|
item.setFieldType(type);
|
|
return item;
|
|
}
|
|
}
|