Project

General

Profile

« Previous | Next » 

Revision 7d882578

Added by Andreas Müller about 7 years ago

ref #6362, ref #6365 remove occurrences of NonViralName, BotanicalName and ZoologicalName in cdmlib-app

View differences:

cdm-eflora/src/main/java/eu/etaxonomy/cdm/io/eflora/centralAfrica/ferns/CentralAfricaFernsImportBase.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
*/
9 9

  
10 10
package eu.etaxonomy.cdm.io.eflora.centralAfrica.ferns;
11 11

  
12
import java.lang.reflect.Method;
13 12
import java.sql.ResultSet;
14
import java.sql.ResultSetMetaData;
15 13
import java.sql.SQLException;
16
import java.sql.Timestamp;
17
import java.util.HashMap;
18 14
import java.util.HashSet;
19
import java.util.Map;
20 15
import java.util.Set;
21 16
import java.util.UUID;
22 17

  
23 18
import org.apache.commons.lang.StringUtils;
24 19
import org.apache.log4j.Logger;
25
import org.joda.time.DateTime;
26 20

  
27
import eu.etaxonomy.cdm.common.CdmUtils;
28 21
import eu.etaxonomy.cdm.io.common.CdmImportBase;
29 22
import eu.etaxonomy.cdm.io.common.ICdmIO;
30 23
import eu.etaxonomy.cdm.io.common.IPartitionedIO;
31
import eu.etaxonomy.cdm.io.common.ImportHelper;
32 24
import eu.etaxonomy.cdm.io.common.ResultSetPartitioner;
33 25
import eu.etaxonomy.cdm.io.common.Source;
34
import eu.etaxonomy.cdm.io.common.IImportConfigurator.EDITOR;
35 26
import eu.etaxonomy.cdm.io.common.mapping.DbImportMapping;
36
import eu.etaxonomy.cdm.model.agent.Team;
37
import eu.etaxonomy.cdm.model.common.AnnotatableEntity;
38
import eu.etaxonomy.cdm.model.common.Annotation;
39
import eu.etaxonomy.cdm.model.common.AnnotationType;
40 27
import eu.etaxonomy.cdm.model.common.CdmBase;
41
import eu.etaxonomy.cdm.model.common.ExtensionType;
42
import eu.etaxonomy.cdm.model.common.IdentifiableEntity;
43
import eu.etaxonomy.cdm.model.common.Language;
44
import eu.etaxonomy.cdm.model.common.MarkerType;
45
import eu.etaxonomy.cdm.model.common.User;
46
import eu.etaxonomy.cdm.model.name.BotanicalName;
28
import eu.etaxonomy.cdm.model.name.IBotanicalName;
47 29
import eu.etaxonomy.cdm.model.name.Rank;
48 30
import eu.etaxonomy.cdm.strategy.parser.NonViralNameParserImpl;
49 31

  
......
54 36
 */
55 37
public abstract class CentralAfricaFernsImportBase<CDM_BASE extends CdmBase> extends CdmImportBase<CentralAfricaFernsImportConfigurator, CentralAfricaFernsImportState> implements ICdmIO<CentralAfricaFernsImportState>, IPartitionedIO<CentralAfricaFernsImportState> {
56 38
	private static final Logger logger = Logger.getLogger(CentralAfricaFernsImportBase.class);
57
	
39

  
58 40
	public static final UUID ID_IN_SOURCE_EXT_UUID = UUID.fromString("23dac094-e793-40a4-bad9-649fc4fcfd44");
59
	
41

  
60 42
	protected static final String TAXON_NAMESPACE = "African_pteridophytes_Taxon";
61 43
	protected static final String NAME_NAMESPACE = "African_pteridophytes_Name";
62 44
	protected static final String HIGHER_TAXON_NAMESPACE = "African_pteridophytes_Higher_Taxon";
63
	
45

  
64 46
	private NonViralNameParserImpl parser = NonViralNameParserImpl.NewInstance();
65
	
47

  
66 48

  
67 49
	private String pluralString;
68 50
	private String dbTableName;
69 51
	//TODO needed?
70 52
	private Class cdmTargetClass;
71
	
72 53

  
73
	
74
	
54

  
55

  
56

  
75 57
	/**
76 58
	 * @param dbTableName
77
	 * @param dbTableName2 
59
	 * @param dbTableName2
78 60
	 */
79 61
	public CentralAfricaFernsImportBase(String pluralString, String dbTableName, Class cdmTargetClass) {
80 62
		this.pluralString = pluralString;
......
82 64
		this.cdmTargetClass = cdmTargetClass;
83 65
	}
84 66

  
85
	protected void doInvoke(CentralAfricaFernsImportState state){
67
	@Override
68
    protected void doInvoke(CentralAfricaFernsImportState state){
86 69
		logger.info("start make " + getPluralString() + " ...");
87 70
		CentralAfricaFernsImportConfigurator config = state.getConfig();
88 71
		Source source = config.getSource();
89
			
72

  
90 73
		String strIdQuery = getIdQuery();
91 74
		String strRecordQuery = getRecordQuery(config);
92 75

  
......
101 84
			state.setUnsuccessfull();
102 85
			return;
103 86
		}
104
		
87

  
105 88
		logger.info("end make " + getPluralString() + " ... " + getSuccessString(true));
106 89
		return;
107 90
	}
108
	
109
	public boolean doPartition(ResultSetPartitioner partitioner, CentralAfricaFernsImportState state) {
91

  
92
	@Override
93
    public boolean doPartition(ResultSetPartitioner partitioner, CentralAfricaFernsImportState state) {
110 94
		boolean success = true ;
111 95
		Set objectsToSave = new HashSet();
112
		
96

  
113 97
 		DbImportMapping<?, ?> mapping = getMapping();
114 98
		mapping.initialize(state, cdmTargetClass);
115
		
99

  
116 100
		ResultSet rs = partitioner.getResultSet();
117 101
		try{
118 102
			while (rs.next()){
......
122 106
			logger.error("SQLException:" +  e);
123 107
			return false;
124 108
		}
125
	
109

  
126 110
		partitioner.startDoSave();
127 111
		getCommonService().save(objectsToSave);
128 112
		return success;
129 113
	}
130 114

  
131 115

  
132
	
116

  
133 117
	/**
134 118
	 * @return
135 119
	 */
136 120
	protected abstract DbImportMapping<?, ?> getMapping();
137
	
121

  
138 122
	/**
139 123
	 * @return
140 124
	 */
......
147 131
		String result = " SELECT id FROM " + getTableName();
148 132
		return result;
149 133
	}
150
	
134

  
151 135
	/* (non-Javadoc)
152 136
	 * @see eu.etaxonomy.cdm.io.berlinModel.in.IPartitionedIO#getPluralString()
153 137
	 */
154
	public String getPluralString(){
138
	@Override
139
    public String getPluralString(){
155 140
		return pluralString;
156 141
	}
157 142

  
......
161 146
	protected String getTableName(){
162 147
		return this.dbTableName;
163 148
	}
164
	
165
	
149

  
150

  
166 151
	/**
167 152
	 * Reads a foreign key field from the result set and adds its value to the idSet.
168 153
	 * @param rs
......
177 162
			idSet.add(id);
178 163
		}
179 164
	}
180
	
165

  
181 166
	/**
182 167
	 * Returns true if i is a multiple of recordsPerTransaction
183 168
	 * @param i
......
188 173
		startTransaction();
189 174
		return (i % recordsPerLoop) == 0;
190 175
	}
191
	
176

  
192 177
	protected void doLogPerLoop(int count, int recordsPerLog, String pluralString){
193 178
		if ((count % recordsPerLog ) == 0 && count!= 0 ){ logger.info(pluralString + " handled: " + (count));}
194 179
	}
195
	
196
	
197
	
198
	protected void setAuthor(BotanicalName taxonName, ResultSet rs, String taxonNumber, boolean isHigherTaxon) throws SQLException {
199
		
180

  
181

  
182

  
183
	protected void setAuthor(IBotanicalName taxonName, ResultSet rs, String taxonNumber, boolean isHigherTaxon) throws SQLException {
184

  
200 185
		String authorsFull = null;
201 186
		String authorsAbbrev = null;
202 187
		if (! isHigherTaxon){
......
247 232
					authorString = authorsAbbrev;
248 233
					if (StringUtils.isBlank(authorString)){
249 234
						logger.warn("Authors abbrev string could not be defined");
250
						authorString = authorsFull;	
235
						authorString = authorsFull;
251 236
					}
252 237
				}
253 238
			}
......
256 241
			authorString = authorsAbbrev;
257 242
			if (StringUtils.isBlank(authorString)){
258 243
				logger.warn(taxonNumber + ": Authors abbrev string could not be defined");
259
				authorString = authorsFull;	
244
				authorString = authorsFull;
260 245
			}
261 246
		}
262
		
247

  
263 248
		if (StringUtils.isNotBlank(authorString)){
264 249
			parser.handleAuthors(taxonName, taxonName.getNameCache().trim() + " " + authorString, authorString);
265 250
		}
......
274 259
	//		}
275 260
		}
276 261
	}
277
	
278
	
279 262

  
280 263

  
281
	
264

  
265

  
266

  
282 267
}

Also available in: Unified diff