Project

General

Profile

« Previous | Next » 

Revision 8422c0cd

Added by Andreas Müller almost 8 years ago

Remove generics from Reference in cdmlib-app #5830

View differences:

cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/indexFungorum/IndexFungorumGeneraImport.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
*/
......
21 21
import org.apache.log4j.Logger;
22 22
import org.springframework.stereotype.Component;
23 23

  
24
import eu.etaxonomy.cdm.common.CdmUtils;
25 24
import eu.etaxonomy.cdm.io.common.ResultSetPartitioner;
26 25
import eu.etaxonomy.cdm.io.pesi.out.PesiTransformer;
27 26
import eu.etaxonomy.cdm.model.common.CdmBase;
......
41 40
@Component
42 41
public class IndexFungorumGeneraImport  extends IndexFungorumImportBase {
43 42
	private static final Logger logger = Logger.getLogger(IndexFungorumGeneraImport.class);
44
	
43

  
45 44
	private static final String pluralString = "genera";
46 45
	private static final String dbTableName = "tblGenera";
47 46

  
......
49 48
		super(pluralString, dbTableName, null);
50 49
	}
51 50

  
52
	
53
	
51

  
52

  
54 53
	@Override
55 54
	protected String getIdQuery() {
56 55
		String result = " SELECT [RECORD NUMBER] FROM " + getTableName() +
......
63 62
	 */
64 63
	@Override
65 64
	protected String getRecordQuery(IndexFungorumImportConfigurator config) {
66
		String strRecordQuery = 
65
		String strRecordQuery =
67 66
				" SELECT DISTINCT c.[Family name], c.[Order name], c.[Subclass name], c.[Class name], c.[Subphylum name], c.[Phylum name], c.[Kingdom name], g.* " +
68 67
                " FROM tblGenera AS g LEFT OUTER JOIN  dbo.[tblPESIfungi-Classification] AS c ON g.[RECORD NUMBER] = c.PreferredNameFDCnumber " +
69
			" WHERE ( g.[RECORD NUMBER] IN (" + ID_LIST_TOKEN + ") )" + 
68
			" WHERE ( g.[RECORD NUMBER] IN (" + ID_LIST_TOKEN + ") )" +
70 69
			"";
71 70
		return strRecordQuery;
72 71
	}
73 72

  
74
	
75
	
76
	
73

  
74

  
75

  
77 76
	@Override
78 77
	public boolean doPartition(ResultSetPartitioner partitioner, IndexFungorumImportState state) {
79 78
		boolean success =true;
80
		Reference<?> sourceReference = state.getRelatedObject(NAMESPACE_REFERENCE, SOURCE_REFERENCE, Reference.class);
79
		Reference sourceReference = state.getRelatedObject(NAMESPACE_REFERENCE, SOURCE_REFERENCE, Reference.class);
81 80
		ResultSet rs = partitioner.getResultSet();
82 81
		Classification classification = getClassification(state);
83 82
		try {
......
87 86
				//DisplayName, NomRefCache
88 87

  
89 88
				Double id = (Double)rs.getObject("RECORD NUMBER");
90
				
91
				
89

  
90

  
92 91
				String preferredName = rs.getString("NAME OF FUNGUS");
93 92
				if (StringUtils.isBlank(preferredName)){
94 93
					logger.warn("Preferred name is blank. This case is not yet handled by IF import. RECORD NUMBER" + id);
95 94
				}
96
				
95

  
97 96
				Rank rank = Rank.GENUS();
98 97
				NonViralName<?> name = BotanicalName.NewInstance(rank);
99 98
				name.setGenusOrUninomial(preferredName);
100
				
99

  
101 100
				Taxon taxon = Taxon.NewInstance(name, sourceReference);
102 101
				Taxon parent = getParentTaxon(state, rs);
103 102
				classification.addParentChild(parent, taxon, null, null);
104
				
103

  
105 104
				//author + publication
106 105
				makeAuthorAndPublication(state, rs, name);
107 106
				//source
......
114 113
				getTaxonService().saveOrUpdate(taxon);
115 114
			}
116 115

  
117
			
116

  
118 117
		} catch (Exception e) {
119 118
			e.printStackTrace();
120 119
			logger.error(e.getMessage());
......
122 121
			success = false;
123 122
		}
124 123
		return success;
125
		
124

  
126 125
	}
127
	
126

  
128 127
	private Taxon getParentTaxon(IndexFungorumImportState state, ResultSet rs) throws SQLException {
129 128
		String parentName = getParentNameString(rs);
130 129
		if (parentName == null){
......
160 159
						}
161 160
					}
162 161
				}
163
			}	
162
			}
164 163
		}
165 164
		return parentName;
166 165
	}
......
172 171
		Class<?> cdmClass;
173 172
		Set<String> idSet;
174 173
		Map<Object, Map<String, ? extends CdmBase>> result = new HashMap<Object, Map<String, ? extends CdmBase>>();
175
		
174

  
176 175
		try{
177 176
			Set<String> taxonNameSet = new HashSet<String>();
178 177
			while (rs.next()){
179 178
//				handleForeignKey(rs, taxonIdSet,"tu_acctaxon" );
180 179
			}
181
			
180

  
182 181
			//taxon map
183 182
			nameSpace = NAMESPACE_SUPRAGENERIC_NAMES ;
184 183
			cdmClass = TaxonBase.class;
......
189 188
				taxonMap.put(CdmBase.deproxy(taxon.getName(), NonViralName.class).getGenusOrUninomial(), taxon);
190 189
			}
191 190
			result.put(nameSpace, taxonMap);
192
			
191

  
193 192
			//sourceReference
194
			Reference<?> sourceReference = getReferenceService().find(PesiTransformer.uuidSourceRefIndexFungorum);
193
			Reference sourceReference = getReferenceService().find(PesiTransformer.uuidSourceRefIndexFungorum);
195 194
			Map<String, Reference> referenceMap = new HashMap<String, Reference>();
196 195
			referenceMap.put(SOURCE_REFERENCE, sourceReference);
197 196
			result.put(NAMESPACE_REFERENCE, referenceMap);
198
			
197

  
199 198
		} catch (SQLException e) {
200 199
			throw new RuntimeException(e);
201 200
		}
202 201
		return result;
203 202
	}
204
	
203

  
205 204

  
206 205
	@Override
207 206
	protected boolean doCheck(IndexFungorumImportState state){
208 207
		return true;
209 208
	}
210
	
209

  
211 210
	@Override
212 211
	protected boolean isIgnore(IndexFungorumImportState state){
213 212
		return ! state.getConfig().isDoTaxa();

Also available in: Unified diff