Project

General

Profile

« Previous | Next » 

Revision a5767950

Added by Andreas Müller about 11 years ago

Latest AlgaTerra Import developments

View differences:

app-import/src/main/java/eu/etaxonomy/cdm/io/algaterra/AlgaTerraSiteImagesImport.java
67 67
	protected String getRecordQuery(BerlinModelImportConfigurator config) {
68 68
			String strQuery =    
69 69
						
70
				" SELECT si.*, si.Comment as FigurePhrase, si.Picture as fileName " +
70
				" SELECT si.*, si.Comment as FigurePhrase, si.PictureFile as fileName " +
71 71
	            " FROM SiteImages si  " 
72 72
	            + 	" WHERE (si.SiteID IN (" + ID_LIST_TOKEN + ")  )"  
73 73
	            + " ORDER BY EcoFactFk ";
......
98 98
                
99 99
        		if ((i++ % modCount) == 0 && i!= 1 ){ logger.info(pluralString + " handled: " + (i-1));}
100 100
				
101
				int figureId = rs.getInt("VoucherImageID");
101
				int figureId = rs.getInt("SiteId");
102 102
				int ecoFactFk = rs.getInt("EcoFactFk");
103 103
				
104 104
				
......
107 107
				try {
108 108
					
109 109
					//TODO use deduplicated ecofact
110
					FieldObservation fieldObservation = ecoFactFieldObservationMap.get(ecoFactFk);
110
					FieldObservation fieldObservation = ecoFactFieldObservationMap.get(String.valueOf(ecoFactFk));
111 111
					
112 112
					if (fieldObservation == null){
113 113
						logger.warn("Could not find eco fact field observation (" + ecoFactFk +") for site image " +  figureId);
......
118 118
					//field observation
119 119
					Media media = handleSingleImage(rs, fieldObservation, state, partitioner);
120 120
					
121
					handleTypeImageSpecificFields(rs, media, state);
121
					handleSiteImageSpecificFields(rs, media, state);
122 122
					
123 123
					unitsToSave.add(fieldObservation); 
124 124
					
......
144 144

  
145 145

  
146 146

  
147
	private void handleTypeImageSpecificFields(ResultSet rs, Media media, AlgaTerraImportState state) throws SQLException {
147
	private void handleSiteImageSpecificFields(ResultSet rs, Media media, AlgaTerraImportState state) throws SQLException {
148 148
		//TODO
149 149
		
150 150
	}
app-import/src/main/java/eu/etaxonomy/cdm/io/algaterra/AlgaTerraTypeImagesImport.java
16 16
import java.util.Map;
17 17
import java.util.Set;
18 18

  
19
import org.apache.commons.lang.StringUtils;
20 19
import org.apache.log4j.Logger;
21 20
import org.springframework.stereotype.Component;
22 21

  
23
import eu.etaxonomy.cdm.api.facade.DerivedUnitFacade;
24
import eu.etaxonomy.cdm.api.facade.DerivedUnitFacade.DerivedUnitType;
25
import eu.etaxonomy.cdm.api.facade.DerivedUnitFacadeNotSupportedException;
26
import eu.etaxonomy.cdm.database.update.TableNameChanger;
27 22
import eu.etaxonomy.cdm.io.algaterra.validation.AlgaTerraTypeImportValidator;
28 23
import eu.etaxonomy.cdm.io.berlinModel.in.BerlinModelImportConfigurator;
29 24
import eu.etaxonomy.cdm.io.berlinModel.in.BerlinModelImportState;
30 25
import eu.etaxonomy.cdm.io.berlinModel.in.BerlinModelReferenceImport;
31
import eu.etaxonomy.cdm.io.berlinModel.in.BerlinModelTaxonNameImport;
32 26
import eu.etaxonomy.cdm.io.common.IOValidator;
33 27
import eu.etaxonomy.cdm.io.common.ResultSetPartitioner;
34 28
import eu.etaxonomy.cdm.model.common.CdmBase;
35 29
import eu.etaxonomy.cdm.model.media.Media;
36
import eu.etaxonomy.cdm.model.name.BotanicalName;
37
import eu.etaxonomy.cdm.model.name.Rank;
38
import eu.etaxonomy.cdm.model.name.SpecimenTypeDesignation;
39
import eu.etaxonomy.cdm.model.name.SpecimenTypeDesignationStatus;
40
import eu.etaxonomy.cdm.model.name.TaxonNameBase;
41
import eu.etaxonomy.cdm.model.occurrence.Collection;
42 30
import eu.etaxonomy.cdm.model.occurrence.DerivedUnit;
43 31
import eu.etaxonomy.cdm.model.occurrence.DerivedUnitBase;
44
import eu.etaxonomy.cdm.model.occurrence.FieldObservation;
45 32
import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase;
46 33
import eu.etaxonomy.cdm.model.reference.Reference;
47 34

  
......
220 207
	 */
221 208
	protected boolean isIgnore(BerlinModelImportState bmState){
222 209
		AlgaTerraImportConfigurator config = ((AlgaTerraImportState) bmState).getAlgaTerraConfigurator();
223
//		return !  ( config.isDoTypes() && config.isDoImages()) ;
224
		return false;
210
		return !  ( config.isDoTypes() && config.isDoImages()) ;
211
//		return false;
225 212
	}
226 213
	
227 214
}
app-import/src/main/java/eu/etaxonomy/cdm/io/algaterra/AlgaTerraVoucherImagesImport.java
26 26
import eu.etaxonomy.cdm.io.common.ResultSetPartitioner;
27 27
import eu.etaxonomy.cdm.model.common.CdmBase;
28 28
import eu.etaxonomy.cdm.model.media.Media;
29
import eu.etaxonomy.cdm.model.occurrence.DerivedUnit;
30 29
import eu.etaxonomy.cdm.model.occurrence.DerivedUnitBase;
31 30
import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase;
32 31

  
......
107 106
				
108 107
				try {
109 108
					
110
					DerivedUnitBase<?> derivedUnit = ecoFactMap.get(ecoFactFk);
109
					DerivedUnitBase<?> derivedUnit = ecoFactMap.get(String.valueOf(ecoFactFk));
111 110
					
112 111
					if (derivedUnit == null){
113 112
						logger.warn("Could not find eco fact specimen (" + ecoFactFk +") for voucher image " +  figureId);
114 113
					}else{
115
						
114
						logger.warn("DerivedUnit for ecoFact-derived unit is null");
116 115
					}
117 116
					
118 117
					//field observation
119 118
					Media media = handleSingleImage(rs, derivedUnit, state, partitioner);
120 119
					
121
					handleTypeImageSpecificFields(rs, media, state);
122
					
123
					unitsToSave.add(derivedUnit); 
120
					handleVoucherImageSpecificFields(rs, media, state);
124 121
					
122
					if (derivedUnit != null){
123
						unitsToSave.add(derivedUnit); 
124
					}else{
125
						logger.warn("DerivedUnit is null");
126
					}
125 127

  
126 128
				} catch (Exception e) {
127 129
					logger.warn("Exception in " + getTableName() + ": VoucherImageId " + figureId + ". " + e.getMessage());
......
144 146

  
145 147

  
146 148

  
147
	private void handleTypeImageSpecificFields(ResultSet rs, Media media, AlgaTerraImportState state) throws SQLException {
149
	private void handleVoucherImageSpecificFields(ResultSet rs, Media media, AlgaTerraImportState state) throws SQLException {
148 150
		//TODO
149 151
		
150 152
	}
......
170 172
			nameSpace = AlgaTerraSpecimenImportBase.ECO_FACT_DERIVED_UNIT_NAMESPACE;
171 173
			cdmClass = DerivedUnitBase.class;
172 174
			idSet = ecoFactIdSet;
173
			Map<String, DerivedUnitBase> typeSpecimenMap = (Map<String,DerivedUnitBase>)getCommonService().getSourcedObjectsByIdInSource(cdmClass, idSet, nameSpace);
174
			result.put(nameSpace, typeSpecimenMap);
175
			Map<String, DerivedUnitBase> specimenMap = (Map<String,DerivedUnitBase>)getCommonService().getSourcedObjectsByIdInSource(cdmClass, idSet, nameSpace);
176
			result.put(nameSpace, specimenMap);
175 177

  
176 178
			
177 179
		} catch (SQLException e) {

Also available in: Unified diff