Project

General

Profile

« Previous | Next » 

Revision 2ec5e873

Added by Andreas Müller about 12 years ago

latest developments for PESI export

View differences:

cdm-pesi/src/main/java/eu/etaxonomy/cdm/app/pesi/PesiExportActivator.java
9 9
*/
10 10
package eu.etaxonomy.cdm.app.pesi;
11 11

  
12
import java.sql.SQLException;
12 13
import java.util.UUID;
13 14

  
14 15
import org.apache.log4j.Logger;
......
41 42
	static final UUID secUuid = UUID.fromString("d03ef02a-f226-4cb1-bdb4-f6c154f08a34");
42 43
	static final int sourceSecId = 7331;
43 44
	static final int isHomotypicId = 72;
45
	static final int nameIdStart = 10000000;
44 46
	
45 47
	static final int partitionSize = 5000;
46 48
	
......
49 51

  
50 52
	//NomeclaturalCode
51 53
	static final NomenclaturalCode nomenclaturalCode  = NomenclaturalCode.ICBN;
54
	
55
	static final boolean deleteAll = true;
52 56

  
53 57
// ****************** ALL *****************************************
54 58
	
......
99 103
		config.setDoReferences(doReferences);
100 104
		config.setCheck(check);
101 105
		config.setLimitSave(partitionSize);
102
		
103

  
106
		config.setNameIdStart(nameIdStart);
107
		if (deleteAll){
108
			destination.update("EXEC sp_deleteAllData()");
109
		}
104 110

  
105 111
		// invoke export
106 112
		CdmDefaultExport<PesiExportConfigurator> pesiExport = new CdmDefaultExport<PesiExportConfigurator>();
cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/out/PesiExportConfigurator.java
35 35
	private DO_REFERENCES doReferences = DO_REFERENCES.ALL;
36 36
	private boolean doTaxa = true;
37 37
	private boolean doRelTaxa = true;
38
	private int nameIdStart = 10000000;
38 39

  
39 40

  
40 41
	public static PesiExportConfigurator NewInstance(Source pesiDestination, ICdmDataSource source) {
......
147 148
		this.doRelTaxa = doRelTaxa;
148 149
	}
149 150

  
151
	/**
152
	 * Number that is added to the cdm id in case a name is stored by its own id
153
	 * not the taxons id.
154
	 * @return
155
	 */
156
	public int getNameIdStart() {
157
		return nameIdStart;
158
	}
159

  
160
	public void setNameIdStart(int nameIdStart) {
161
		this.nameIdStart = nameIdStart;
162
	}
163

  
150 164

  
151 165

  
152 166

  
cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/out/PesiExportState.java
16 16

  
17 17
import eu.etaxonomy.cdm.io.common.DbExportStateBase;
18 18
import eu.etaxonomy.cdm.model.common.CdmBase;
19
import eu.etaxonomy.cdm.model.name.TaxonNameBase;
19 20

  
20 21
/**
21 22
 * The export state class.
......
58 59
		// We use the Cdm.id for Datawarehouse.id
59 60
		if (cdmBase == null) {
60 61
			return null;
61
		} else {
62
		} else if (cdmBase.isInstanceOf(TaxonNameBase.class)){
63
			return cdmBase.getId() + this.getConfig().getNameIdStart();
64
		}else{
62 65
			return cdmBase.getId();
63 66
		}
64 67
	}
cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/out/PesiTaxonExport.java
41 41
import eu.etaxonomy.cdm.model.common.CdmBase;
42 42
import eu.etaxonomy.cdm.model.common.Extension;
43 43
import eu.etaxonomy.cdm.model.common.ExtensionType;
44
import eu.etaxonomy.cdm.model.common.IdentifiableEntity;
44 45
import eu.etaxonomy.cdm.model.common.IdentifiableSource;
45 46
import eu.etaxonomy.cdm.model.common.Language;
46 47
import eu.etaxonomy.cdm.model.name.NameTypeDesignation;
......
171 172

  
172 173
		mapping.addMapper(MethodMapper.NewInstance("DerivedFromGuid", this));
173 174
		mapping.addMapper(MethodMapper.NewInstance("CacheCitation", this));
174
		mapping.addMapper(MethodMapper.NewInstance("OriginalDB", this));
175
//		mapping.addMapper(MethodMapper.NewInstance("OriginalDB", this));
176
		mapping.addMapper(MethodMapper.NewInstance("OriginalDB", this.getClass(), "getOriginalDB", IdentifiableEntity.class) );
177
		
175 178
		mapping.addMapper(MethodMapper.NewInstance("LastAction", this));
176 179
		mapping.addMapper(MethodMapper.NewInstance("LastActionDate", this));
177 180
		mapping.addMapper(MethodMapper.NewInstance("ExpertName", this));
......
193 196
	 */
194 197
	private PesiExportMapping getNameMapping() {
195 198
		PesiExportMapping mapping = new PesiExportMapping(dbTableName);
196
		ExtensionType extensionType = null;
197 199
		
198 200
//		mapping.addMapper(IdMapper.NewInstance("TaxonId"));
199
//		mapping.addMapper(DbObjectMapper.NewInstance("sec", "sourceFk")); //OLD:mapping.addMapper(MethodMapper.NewInstance("SourceFK", this.getClass(), "getSourceFk", standardMethodParameter, PesiExportState.class));
200
//		mapping.addMapper(MethodMapper.NewInstance("TaxonStatusFk", this.getClass(), "getTaxonStatusFk", standardMethodParameter, PesiExportState.class));
201
//		mapping.addMapper(MethodMapper.NewInstance("TaxonStatusCache", this.getClass(), "getTaxonStatusCache", standardMethodParameter, PesiExportState.class));
202
//		mapping.addMapper(MethodMapper.NewInstance("QualityStatusFk", this)); // PesiTransformer.QualityStatusCache2QualityStatusFk?
203
//
204
//		mapping.addMapper(MethodMapper.NewInstance("GUID", this));
205
//		//TODO implement again
206
////		mapping.addMapper(MethodMapper.NewInstance("IdInSource", this));
207
//
208
//		mapping.addMapper(MethodMapper.NewInstance("DerivedFromGuid", this));
209
//		mapping.addMapper(MethodMapper.NewInstance("CacheCitation", this));
210
//		mapping.addMapper(MethodMapper.NewInstance("OriginalDB", this));
211
//		mapping.addMapper(MethodMapper.NewInstance("LastAction", this));
212
//		mapping.addMapper(MethodMapper.NewInstance("LastActionDate", this));
213
//		mapping.addMapper(MethodMapper.NewInstance("ExpertName", this));
214
//		mapping.addMapper(MethodMapper.NewInstance("SpeciesExpertName", this));
215
//
216
//		mapping.addMapper(MethodMapper.NewInstance("AuthorString", this));  //For Taxon because Misapplied Names are handled differently
217
		
201

  
202
		//		mapping.addMapper(MethodMapper.NewInstance("TaxonStatusFk", this.getClass(), "getTaxonStatusFk", standardMethodParameter, PesiExportState.class));
203

  
204
		mapping.addMapper(MethodMapper.NewInstance("LastAction", this));
205
		mapping.addMapper(MethodMapper.NewInstance("LastActionDate", this));
206
		mapping.addMapper(MethodMapper.NewInstance("OriginalDB", this.getClass(), "getOriginalDB", IdentifiableEntity.class) );
218 207
		addNameMappers(mapping);
208
		
209
		//TODO add author mapper, taxonStatusFk, TaxonStatusCache, TypeNameFk
210
//		mapping.addMapper(MethodMapper.NewInstance("IdInSource", this));
211
//	immer 2 f?r E+M ?	mapping.addMapper(MethodMapper.NewInstance("QualityStatusFk", this)); // PesiTransformer.QualityStatusCache2QualityStatusFk?
212
//		mapping.addMapper(MethodMapper.NewInstance("TaxonStatusCache", this.getClass(), "getTaxonStatusCache", standardMethodParameter, PesiExportState.class));
219 213

  
220 214
		return mapping;
221 215
	}
......
228 222
		mapping.addMapper(DbStringMapper.NewInstance("InfraSpecificEpithet", "InfraSpecificEpithet"));
229 223
		mapping.addMapper(DbStringMapper.NewInstance("NameCache", "WebSearchName"));
230 224
		mapping.addMapper(DbStringMapper.NewInstance("TitleCache", "FullName"));
225
		//TODO FIXME incorrect mapping -> should be ref +  microref but is only microref
231 226
		mapping.addMapper(DbStringMapper.NewInstance("NomenclaturalMicroReference", "NomRefString"));
232 227
		mapping.addMapper(MethodMapper.NewInstance("WebShowName", this, TaxonNameBase.class));
233 228
		
......
242 237
		mapping.addMapper(MethodMapper.NewInstance("NameStatusFk", this, TaxonNameBase.class));
243 238
		mapping.addMapper(MethodMapper.NewInstance("NameStatusCache", this, TaxonNameBase.class));
244 239
		mapping.addMapper(MethodMapper.NewInstance("TypeFullnameCache", this, TaxonNameBase.class));
245

  
246
//		mapping.addMapper(MethodMapper.NewInstance("TypeDesignationStatusFk", this, TaxonNameBase.class));
247
//		mapping.addMapper(MethodMapper.NewInstance("TypeDesignationStatusCache", this, TaxonNameBase.class));
248

  
240
		//TODO TypeNameFk
241
		
249 242
		// FossilStatus (Fk, Cache)
250 243
		extensionType = (ExtensionType)getTermService().find(ErmsTransformer.uuidFossilStatus);
251 244
		if (extensionType != null) {
......
299 292
			//"PHASE 4: Creating Inferred Synonyms...
300 293
			success &= doPhase04(state, mapping);
301 294
			
302
			success &= doNames(state, mapping);
295
			success &= doNames(state);
303 296

  
304 297
			logger.info("*** Finished Making " + pluralString + " ..." + getSuccessString(success));
305 298

  
......
785 778
	 * @param mapping
786 779
	 * @return
787 780
	 */
788
	private boolean doNames(PesiExportState state, PesiExportMapping mapping)  throws SQLException {
781
	private boolean doNames(PesiExportState state)  throws SQLException {
789 782
		
783
		PesiExportMapping mapping = getNameMapping();
790 784
		int count = 0;
791 785
		int pastCount = 0;
792 786
		List<NonViralName> list;
......
795 789
		int limit = state.getConfig().getLimitSave();
796 790

  
797 791
		
798
		logger.info("PHASE 1: Export Taxa...");
792
		logger.info("PHASE 5: Export Pure Names ...");
799 793
		// Start transaction
800 794
		TransactionStatus txStatus = startTransaction(true);
801 795
		logger.info("Started new transaction. Fetching some " + pluralString + " (max: " + limit + ") ...");
......
808 802
			for (NonViralName<?> taxonName : list) {
809 803
				doCount(count++, modCount, pluralString);
810 804
				success &= mapping.invoke(taxonName);
811
				
812 805
			}
813 806

  
814 807
			// Commit transaction
......
1967 1960
	 * @return The <code>OriginalDB</code> attribute.
1968 1961
	 * @see MethodMapper
1969 1962
	 */
1970
	private static String getOriginalDB(TaxonBase<?> taxonBase) {
1963
	private static String getOriginalDB(IdentifiableEntity identEntity) {
1971 1964
		String result = "";
1972 1965
		try {
1973 1966

  
1974 1967
		// Sources from TaxonName
1975 1968
//		Set<IdentifiableSource> sources = taxonName.getSources();
1976
		Set<IdentifiableSource>  sources  = taxonBase.getSources();
1969
		Set<IdentifiableSource>  sources  = identEntity.getSources();
1977 1970
		
1978 1971
//		IdentifiableEntity<?> taxonBase = null;
1979 1972
//		if (sources != null && sources.isEmpty()) {

Also available in: Unified diff