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