Project

General

Profile

« Previous | Next » 

Revision cdf08d0f

Added by Andreas Müller about 12 years ago

bugfix for taxon name id mapping in PESI

View differences:

cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/out/PesiExportBase.java
15 15
import org.apache.log4j.Logger;
16 16

  
17 17
import eu.etaxonomy.cdm.io.common.DbExportBase;
18
import eu.etaxonomy.cdm.model.common.CdmBase;
18 19
import eu.etaxonomy.cdm.model.common.Marker;
19 20
import eu.etaxonomy.cdm.model.common.MarkerType;
20 21
import eu.etaxonomy.cdm.model.name.NonViralName;
......
77 78
		}
78 79
		return true;
79 80
	}
81
	
82
	protected Object getDbIdCdmWithExceptions(CdmBase cdmBase, PesiExportState state) {
83
		if (cdmBase.isInstanceOf(TaxonNameBase.class)){
84
			return ( cdmBase.getId() + state.getConfig().getNameIdStart() );
85
		}else{
86
			return super.getDbIdCdmWithExceptions(cdmBase, state);
87
		}
88
	}
80 89
}
cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/out/PesiTaxonExport.java
175 175
//		mapping.addMapper(MethodMapper.NewInstance("OriginalDB", this));
176 176
		mapping.addMapper(MethodMapper.NewInstance("OriginalDB", this.getClass(), "getOriginalDB", IdentifiableEntity.class) );
177 177
		
178
		mapping.addMapper(MethodMapper.NewInstance("LastAction", this));
179
		mapping.addMapper(MethodMapper.NewInstance("LastActionDate", this));
178
		mapping.addMapper(MethodMapper.NewInstance("LastAction", this.getClass(), "getLastAction",  IdentifiableEntity.class));
179
		mapping.addMapper(MethodMapper.NewInstance("LastActionDate", this.getClass(), "getLastActionDate",  IdentifiableEntity.class));
180 180
		mapping.addMapper(MethodMapper.NewInstance("ExpertName", this));
181 181
		mapping.addMapper(MethodMapper.NewInstance("SpeciesExpertName", this));
182 182

  
......
197 197
	private PesiExportMapping getNameMapping() {
198 198
		PesiExportMapping mapping = new PesiExportMapping(dbTableName);
199 199
		
200
//		mapping.addMapper(IdMapper.NewInstance("TaxonId"));
200
		mapping.addMapper(IdMapper.NewInstance("TaxonId"));
201 201

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

  
204
		mapping.addMapper(MethodMapper.NewInstance("LastAction", this));
205
		mapping.addMapper(MethodMapper.NewInstance("LastActionDate", this));
204
		mapping.addMapper(MethodMapper.NewInstance("LastAction", this.getClass(), "getLastAction", IdentifiableEntity.class));
205
		mapping.addMapper(MethodMapper.NewInstance("LastActionDate",  this.getClass(), "getLastAction", IdentifiableEntity.class));
206 206
		mapping.addMapper(MethodMapper.NewInstance("OriginalDB", this.getClass(), "getOriginalDB", IdentifiableEntity.class) );
207 207
		addNameMappers(mapping);
208 208
		
......
280 280
			expertUserIdExtensionType = (ExtensionType)getTermService().find(PesiTransformer.expertUserIdUuid);
281 281
			speciesExpertUserIdExtensionType = (ExtensionType)getTermService().find(PesiTransformer.speciesExpertUserIdUuid);
282 282

  
283
			//"PHASE 5: Handle names without taxa ...
284
			success &= doNames(state);
285

  
286
			
283 287
			//Export Taxa..
284 288
			success &= doPhase01(state, mapping);
285 289

  
......
292 296
			//"PHASE 4: Creating Inferred Synonyms...
293 297
			success &= doPhase04(state, mapping);
294 298
			
295
			success &= doNames(state);
296

  
299
			
297 300
			logger.info("*** Finished Making " + pluralString + " ..." + getSuccessString(success));
298 301

  
299 302
			if (!success){
......
781 784
	private boolean doNames(PesiExportState state)  throws SQLException {
782 785
		
783 786
		PesiExportMapping mapping = getNameMapping();
787
		mapping.initialize(state);
784 788
		int count = 0;
785 789
		int pastCount = 0;
786 790
		List<NonViralName> list;
......
798 802
		int partitionCount = 0;
799 803
		while ((list = getNextPureNamePartition(null, limit, partitionCount++)).size() > 0   ) {
800 804

  
801
			logger.info("Fetched " + list.size() + " " + pluralString + ". Exporting...");
805
			logger.info("Fetched " + list.size() + " names without taxa. Exporting...");
802 806
			for (NonViralName<?> taxonName : list) {
803 807
				doCount(count++, modCount, pluralString);
804 808
				success &= mapping.invoke(taxonName);
......
2030 2034
	 * @see MethodMapper
2031 2035
	 */
2032 2036
	@SuppressWarnings("unused")
2033
	private static String getLastAction(TaxonBase<?> taxon) {
2037
	private static String getLastAction(IdentifiableEntity<?> identEntity) {
2034 2038
		String result = null;
2035 2039
		try {
2036
		Set<Extension> extensions = taxon.getExtensions();
2040
		Set<Extension> extensions = identEntity.getExtensions();
2037 2041
		for (Extension extension : extensions) {
2038 2042
			if (extension.getType().equals(lastActionExtensionType)) {
2039 2043
				result = extension.getValue();
......
2052 2056
	 * @see MethodMapper
2053 2057
	 */
2054 2058
	@SuppressWarnings({ "unused" })
2055
	private static DateTime getLastActionDate(TaxonBase<?> taxon) {
2059
	private static DateTime getLastActionDate(IdentifiableEntity identEntity) {
2056 2060
		DateTime result = null;
2057 2061
		try {
2058
			Set<Extension> extensions = taxon.getExtensions();
2062
			Set<Extension> extensions = identEntity.getExtensions();
2059 2063
			for (Extension extension : extensions) {
2060 2064
				if (extension.getType().equals(lastActionDateExtensionType)) {
2061 2065
					String dateTime = extension.getValue();

Also available in: Unified diff