1
|
package eu.dnetlib.data.transformation.service;
|
2
|
|
3
|
import javax.annotation.Resource;
|
4
|
|
5
|
import eu.dnetlib.common.profile.ResourceDao;
|
6
|
import eu.dnetlib.data.collective.transformation.VocabularyRegistry;
|
7
|
import eu.dnetlib.data.collective.transformation.utils.TransformationRulesImportTool;
|
8
|
import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpDocumentNotFoundException;
|
9
|
import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpException;
|
10
|
|
11
|
public class DataTransformerFactory {
|
12
|
|
13
|
@Resource(name = "vocabularyRegistry")
|
14
|
private VocabularyRegistry vocabularyRegistry;
|
15
|
|
16
|
@Resource(name = "transformationTemplate")
|
17
|
private org.springframework.core.io.Resource transformationTemplate;
|
18
|
|
19
|
@Resource(name = "defaultSchema")
|
20
|
private org.springframework.core.io.Resource defaultSchema;
|
21
|
|
22
|
@Resource(name = "transformationRuleProfileUtil")
|
23
|
private TransformationRulesImportTool transformationRuleProfileUtil;
|
24
|
|
25
|
@Resource(name = "resourceDao")
|
26
|
private ResourceDao resourceDao;
|
27
|
|
28
|
public SimpleDataTransformer createTransformer(final String ruleid) throws ISLookUpDocumentNotFoundException, ISLookUpException {
|
29
|
// String profile = lookupLocator.getService().getResourceProfile(ruleid);
|
30
|
SimpleDataTransformer transformer = new SimpleDataTransformer(ruleid);
|
31
|
try {
|
32
|
transformer.setupEngine(vocabularyRegistry, transformationTemplate, defaultSchema, transformationRuleProfileUtil, resourceDao);
|
33
|
} catch (Exception e) {
|
34
|
throw new IllegalStateException(e);
|
35
|
}
|
36
|
return transformer;
|
37
|
}
|
38
|
}
|