Revision bff8d9fe
Added by Andreas Müller over 5 years ago
cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/erms/ErmsReferenceImport.java | ||
---|---|---|
1 | 1 |
/** |
2 | 2 |
* Copyright (C) 2007 EDIT |
3 |
* European Distributed Institute of Taxonomy
|
|
3 |
* European Distributed Institute of Taxonomy |
|
4 | 4 |
* http://www.e-taxonomy.eu |
5 |
*
|
|
5 |
* |
|
6 | 6 |
* The contents of this file are subject to the Mozilla Public License Version 1.1 |
7 | 7 |
* See LICENSE.TXT at the top of this package for the full license terms. |
8 | 8 |
*/ |
... | ... | |
26 | 26 |
import eu.etaxonomy.cdm.io.common.mapping.DbImportObjectCreationMapper; |
27 | 27 |
import eu.etaxonomy.cdm.io.common.mapping.DbImportStringMapper; |
28 | 28 |
import eu.etaxonomy.cdm.io.common.mapping.DbImportTruncatedStringMapper; |
29 |
import eu.etaxonomy.cdm.io.common.mapping.DbNotYetImplementedMapper; |
|
30 | 29 |
import eu.etaxonomy.cdm.io.common.mapping.IMappingImport; |
31 | 30 |
import eu.etaxonomy.cdm.io.pesi.erms.validation.ErmsReferenceImportValidator; |
32 | 31 |
import eu.etaxonomy.cdm.model.common.AnnotationType; |
... | ... | |
40 | 39 |
/** |
41 | 40 |
* @author a.mueller |
42 | 41 |
* @since 20.02.2010 |
43 |
* @version 1.0 |
|
44 | 42 |
*/ |
45 | 43 |
@Component |
46 | 44 |
public class ErmsReferenceImport extends ErmsImportBase<Reference> implements IMappingImport<Reference, ErmsImportState>{ |
47 |
private static final Logger logger = Logger.getLogger(ErmsReferenceImport.class); |
|
48 |
|
|
49 |
private DbImportMapping mapping; |
|
50 |
|
|
51 |
|
|
45 |
private static final long serialVersionUID = -2345972558542643378L; |
|
46 |
|
|
47 |
private static final Logger logger = Logger.getLogger(ErmsReferenceImport.class); |
|
48 |
|
|
49 |
private DbImportMapping<ErmsImportState, ErmsImportConfigurator> mapping; |
|
50 |
|
|
52 | 51 |
private int modCount = 10000; |
53 | 52 |
private static final String pluralString = "sources"; |
54 | 53 |
private static final String dbTableName = "sources"; |
... | ... | |
58 | 57 |
super(pluralString, dbTableName, cdmTargetClass); |
59 | 58 |
} |
60 | 59 |
|
61 |
|
|
62 |
/* (non-Javadoc) |
|
63 |
* @see eu.etaxonomy.cdm.io.berlinModel.in.BerlinModelImportBase#getRecordQuery(eu.etaxonomy.cdm.io.berlinModel.in.BerlinModelImportConfigurator) |
|
64 |
*/ |
|
65 | 60 |
@Override |
66 | 61 |
protected String getRecordQuery(ErmsImportConfigurator config) { |
67 |
String strRecordQuery =
|
|
68 |
" SELECT * " +
|
|
62 |
String strRecordQuery = |
|
63 |
" SELECT * " + |
|
69 | 64 |
" FROM sources " + |
70 | 65 |
" WHERE ( sources.id IN (" + ID_LIST_TOKEN + ") )"; |
71 | 66 |
return strRecordQuery; |
72 | 67 |
} |
73 | 68 |
|
74 |
/* (non-Javadoc) |
|
75 |
* @see eu.etaxonomy.cdm.io.erms.ErmsImportBase#getMapping() |
|
76 |
*/ |
|
77 |
protected DbImportMapping getMapping() { |
|
69 |
@Override |
|
70 |
protected DbImportMapping<ErmsImportState, ErmsImportConfigurator> getMapping() { |
|
78 | 71 |
if (mapping == null){ |
79 |
mapping = new DbImportMapping(); |
|
80 |
|
|
72 |
mapping = new DbImportMapping<>();
|
|
73 |
|
|
81 | 74 |
mapping.addMapper(DbImportObjectCreationMapper.NewInstance(this, "id", REFERENCE_NAMESPACE)); //id |
82 | 75 |
ExtensionType imisExtType = getExtensionType( ErmsTransformer.IMIS_UUID, "imis", "imis", "imis"); |
83 | 76 |
mapping.addMapper(DbImportExtensionMapper.NewInstance("imis_id", imisExtType)); |
84 |
|
|
77 |
|
|
85 | 78 |
mapping.addMapper(DbImportTruncatedStringMapper.NewInstance("source_name", "titleCache", "title")); |
86 | 79 |
mapping.addMapper(DbImportStringMapper.NewInstance("source_abstract", "referenceAbstract")); |
87 | 80 |
mapping.addMapper(DbImportAnnotationMapper.NewInstance("source_note", AnnotationType.EDITORIAL(), Language.DEFAULT())); |
88 |
|
|
81 |
|
|
89 | 82 |
//or as Extension? |
90 | 83 |
mapping.addMapper(DbImportExtensionMapper.NewInstance("source_link", ExtensionType.URL())); |
91 |
|
|
84 |
|
|
92 | 85 |
//not yet implemented |
93 | 86 |
mapping.addMapper(DbIgnoreMapper.NewInstance("source_type", "Handled by ObjectCreateMapper - but mapping not yet fully correct. See comments there.")); |
94 | 87 |
mapping.addMapper(DbIgnoreMapper.NewInstance("source_orig_fn", "Currently not needed. Holds information about pdf files.")); |
... | ... | |
97 | 90 |
} |
98 | 91 |
return mapping; |
99 | 92 |
} |
100 |
|
|
101 |
/* (non-Javadoc) |
|
102 |
* @see eu.etaxonomy.cdm.io.common.mapping.IMappingImport#createObject(java.sql.ResultSet, eu.etaxonomy.cdm.io.common.ImportStateBase) |
|
103 |
*/ |
|
104 |
public Reference createObject(ResultSet rs, ErmsImportState state) throws SQLException { |
|
93 |
|
|
94 |
@Override |
|
95 |
public Reference createObject(ResultSet rs, ErmsImportState state) throws SQLException { |
|
105 | 96 |
int id = rs.getInt("id"); |
106 | 97 |
String type = rs.getString("source_type"); |
107 | 98 |
Reference ref; |
... | ... | |
112 | 103 |
ref = ReferenceFactory.newDatabase(); |
113 | 104 |
}else if (type.equalsIgnoreCase("e")){ |
114 | 105 |
//TODO is this correct, maybe mark as "informal" |
115 |
ref = ReferenceFactory.newGeneric();
|
|
106 |
ref = ReferenceFactory.newGeneric(); |
|
116 | 107 |
}else if (type.equalsIgnoreCase("i")){ |
117 | 108 |
//TODO is this correct? |
118 | 109 |
ref = ReferenceFactory.newGeneric(); |
... | ... | |
124 | 115 |
return ref; |
125 | 116 |
} |
126 | 117 |
|
127 |
/* (non-Javadoc) |
|
128 |
* @see eu.etaxonomy.cdm.io.berlinModel.in.IPartitionedIO#getRelatedObjectsForPartition(java.sql.ResultSet) |
|
129 |
*/ |
|
130 |
public Map<Object, Map<String, ? extends CdmBase>> getRelatedObjectsForPartition(ResultSet rs, ErmsImportState state) { |
|
131 |
Map<Object, Map<String, ? extends CdmBase>> result = new HashMap<Object, Map<String, ? extends CdmBase>>(); |
|
118 |
@Override |
|
119 |
public Map<Object, Map<String, ? extends CdmBase>> getRelatedObjectsForPartition(ResultSet rs, ErmsImportState state) { |
|
120 |
Map<Object, Map<String, ? extends CdmBase>> result = new HashMap<>(); |
|
132 | 121 |
return result; //not needed |
133 | 122 |
} |
134 |
|
|
135 |
/* (non-Javadoc) |
|
136 |
* @see eu.etaxonomy.cdm.io.common.CdmIoBase#doCheck(eu.etaxonomy.cdm.io.common.IImportConfigurator) |
|
137 |
*/ |
|
123 |
|
|
138 | 124 |
@Override |
139 | 125 |
protected boolean doCheck(ErmsImportState state){ |
140 | 126 |
IOValidator<ErmsImportState> validator = new ErmsReferenceImportValidator(); |
141 | 127 |
return validator.validate(state); |
142 | 128 |
} |
143 |
|
|
144 |
|
|
145 |
/* (non-Javadoc) |
|
146 |
* @see eu.etaxonomy.cdm.io.common.CdmIoBase#isIgnore(eu.etaxonomy.cdm.io.common.IImportConfigurator) |
|
147 |
*/ |
|
148 |
protected boolean isIgnore(ErmsImportState state){ |
|
129 |
|
|
130 |
@Override |
|
131 |
protected boolean isIgnore(ErmsImportState state){ |
|
149 | 132 |
//TODO |
150 | 133 |
return state.getConfig().getDoReferences() != IImportConfigurator.DO_REFERENCES.ALL; |
151 | 134 |
} |
152 | 135 |
|
153 |
|
|
154 |
|
|
155 |
|
|
156 |
|
|
157 | 136 |
} |
Also available in: Unified diff
ref #1444 cleanup erms import code