1
|
/**
|
2
|
*
|
3
|
*/
|
4
|
package eu.etaxonomy.cdm.io.tcsxml;
|
5
|
|
6
|
import java.util.Map;
|
7
|
|
8
|
import org.apache.log4j.Logger;
|
9
|
import org.jdom.Element;
|
10
|
import org.jdom.Namespace;
|
11
|
import org.springframework.stereotype.Component;
|
12
|
|
13
|
import eu.etaxonomy.cdm.common.DoubleResult;
|
14
|
import eu.etaxonomy.cdm.common.XmlHelp;
|
15
|
import eu.etaxonomy.cdm.io.common.ICdmIO;
|
16
|
import eu.etaxonomy.cdm.io.common.IImportConfigurator;
|
17
|
import eu.etaxonomy.cdm.io.common.MapWrapper;
|
18
|
import eu.etaxonomy.cdm.io.tcsrdf.TcsRdfImportState;
|
19
|
import eu.etaxonomy.cdm.model.common.CdmBase;
|
20
|
|
21
|
/**
|
22
|
* @author a.mueller
|
23
|
*
|
24
|
*/
|
25
|
@Component
|
26
|
public class TcsXmlMetaDataImport extends TcsXmlImportBase implements ICdmIO<IImportConfigurator> {
|
27
|
private static final Logger logger = Logger.getLogger(TcsXmlMetaDataImport.class);
|
28
|
|
29
|
private static int modCount = 1000;
|
30
|
|
31
|
public TcsXmlMetaDataImport(){
|
32
|
super();
|
33
|
}
|
34
|
|
35
|
@Override
|
36
|
public boolean doCheck(IImportConfigurator config){
|
37
|
boolean result = true;
|
38
|
//result &= checkArticlesWithoutJournal(config);
|
39
|
//result &= checkPartOfJournal(config);
|
40
|
|
41
|
return result;
|
42
|
}
|
43
|
|
44
|
|
45
|
|
46
|
@Override
|
47
|
public boolean doInvoke(TcsXmlImportState state){
|
48
|
logger.info("start make MetaData ...");
|
49
|
boolean success = true;
|
50
|
String childName;
|
51
|
boolean obligatory;
|
52
|
|
53
|
// MapWrapper<ReferenceBase> referenceMap = (MapWrapper<ReferenceBase>)stores.get(ICdmIO.REFERENCE_STORE);
|
54
|
|
55
|
TcsXmlImportConfigurator config = state.getConfig();
|
56
|
Element elDataSet = getDataSetElement(config);
|
57
|
Namespace tcsNamespace = config.getTcsXmlNamespace();
|
58
|
|
59
|
DoubleResult<Element, Boolean> doubleResult;
|
60
|
childName = "MetaData";
|
61
|
obligatory = false;
|
62
|
doubleResult = XmlHelp.getSingleChildElement(elDataSet, childName, tcsNamespace, obligatory);
|
63
|
success &= doubleResult.getSecondResult();
|
64
|
Element elMetaData = doubleResult.getFirstResult();
|
65
|
|
66
|
childName = "Simple";
|
67
|
obligatory = true;
|
68
|
doubleResult = XmlHelp.getSingleChildElement(elMetaData, childName, tcsNamespace, obligatory);
|
69
|
success &= doubleResult.getSecondResult();
|
70
|
Element elSimple = doubleResult.getFirstResult();
|
71
|
//TODO do simple MetaData
|
72
|
|
73
|
childName = "MetaDataDetailed";
|
74
|
obligatory = false;
|
75
|
doubleResult = XmlHelp.getSingleChildElement(elMetaData, childName, tcsNamespace, obligatory);
|
76
|
success &= doubleResult.getSecondResult();
|
77
|
Element elMetaDataDetailed = doubleResult.getFirstResult();
|
78
|
|
79
|
success &= config.getPlaceholderClass().makeMetaDataDetailed(config, elMetaDataDetailed);
|
80
|
// try {
|
81
|
// List<Object> args = Arrays.asList(tcsConfig, elMetaDataDetailed);
|
82
|
// tcsConfig.getFunctionMetaDataDetailed().invoke(this, args);
|
83
|
// } catch (IllegalArgumentException e) {
|
84
|
// e.printStackTrace();
|
85
|
// success = false;
|
86
|
// } catch (IllegalAccessException e) {
|
87
|
// e.printStackTrace();
|
88
|
// success = false;
|
89
|
// } catch (InvocationTargetException e) {
|
90
|
// e.printStackTrace();
|
91
|
// success = false;
|
92
|
// }
|
93
|
|
94
|
logger.info("end make MetaData ...");
|
95
|
return success;
|
96
|
}
|
97
|
|
98
|
|
99
|
/* (non-Javadoc)
|
100
|
* @see eu.etaxonomy.cdm.io.common.CdmIoBase#isIgnore(eu.etaxonomy.cdm.io.common.IImportConfigurator)
|
101
|
*/
|
102
|
protected boolean isIgnore(IImportConfigurator config){
|
103
|
TcsXmlImportConfigurator tcsConfig = (TcsXmlImportConfigurator)config;
|
104
|
return (! tcsConfig.isDoMetaData());
|
105
|
}
|
106
|
|
107
|
}
|