Project

General

Profile

« Previous | Next » 

Revision 106a1a1e

Added by Andreas Müller about 12 years ago

some small improvements on PESI

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;
13 12
import java.util.UUID;
14 13

  
15 14
import org.apache.log4j.Logger;
......
17 16
import eu.etaxonomy.cdm.app.common.CdmDestinations;
18 17
import eu.etaxonomy.cdm.database.ICdmDataSource;
19 18
import eu.etaxonomy.cdm.io.common.CdmDefaultExport;
19
import eu.etaxonomy.cdm.io.common.DbExportConfiguratorBase.IdType;
20 20
import eu.etaxonomy.cdm.io.common.IExportConfigurator.CHECK;
21 21
import eu.etaxonomy.cdm.io.common.IExportConfigurator.DO_REFERENCES;
22 22
import eu.etaxonomy.cdm.io.common.Source;
......
53 53
	static final NomenclaturalCode nomenclaturalCode  = NomenclaturalCode.ICBN;
54 54
	
55 55
	static final boolean deleteAll = true;
56
	
57
	static final IdType idType = IdType.CDM_ID_WITH_EXCEPTIONS;
56 58

  
57 59
// ****************** ALL *****************************************
58 60
	
......
103 105
		config.setDoReferences(doReferences);
104 106
		config.setCheck(check);
105 107
		config.setLimitSave(partitionSize);
108
		config.setIdType(idType);
106 109
		config.setNameIdStart(nameIdStart);
107 110
		if (deleteAll){
108 111
			destination.update("EXEC sp_deleteAllData");
cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/out/PesiExportBase.java
20 20
import eu.etaxonomy.cdm.model.common.MarkerType;
21 21
import eu.etaxonomy.cdm.model.name.NonViralName;
22 22
import eu.etaxonomy.cdm.model.name.TaxonNameBase;
23
import eu.etaxonomy.cdm.model.taxon.Taxon;
24 23
import eu.etaxonomy.cdm.model.taxon.TaxonBase;
25 24

  
26 25
/**
cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/out/PesiExportState.java
49 49
	}
50 50

  
51 51
	/**
52
	 * TODO -> move to PesiExportBase
52 53
	 * Gets the Datawarehouse.id to a specific CDM object originally.
53 54
	 * Here it just returns the CDM object's id.
54 55
	 * @param cdmBase
......
56 57
	 */
57 58
	@Override
58 59
	public Integer getDbId(CdmBase cdmBase) {
59
		// We use the Cdm.id for Datawarehouse.id
60
		if (cdmBase == null) {
61
			return null;
62
		} else if (cdmBase.isInstanceOf(TaxonNameBase.class)){
63
			return cdmBase.getId() + this.getConfig().getNameIdStart();
64
		}else{
65
			return cdmBase.getId();
66
		}
60
		return (Integer)getCurrentIO().getDbId(cdmBase, this);
67 61
	}
68 62
	
69 63
	/**
cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/out/PesiRelTaxonExport.java
451 451
			code = CdmBase.deproxy(relationship, TaxonRelationship.class).getToTaxon().getName().getNomenclaturalCode();
452 452
		}else if (relationship.isInstanceOf(SynonymRelationship.class)){
453 453
			code = CdmBase.deproxy(relationship, SynonymRelationship.class).getAcceptedTaxon().getName().getNomenclaturalCode();
454
		} 
454
		}else if (relationship.isInstanceOf(NameRelationship.class)){
455
			code = CdmBase.deproxy(relationship,  NameRelationship.class).getFromName().getNomenclaturalCode();
456
		}
455 457
		if (code != null) {
456
			if (code.equals(NomenclaturalCode.ICZN)) {
457
				result = PesiTransformer.zoologicalTaxonRelation2RelTaxonQualifierCache(relationship);
458
			} else {
459
				result = PesiTransformer.taxonRelation2RelTaxonQualifierCache(relationship);
460
			}
458
			result = PesiTransformer.taxonRelation2RelTaxonQualifierCache(relationship, code);
461 459
		} else {
462 460
			logger.error("NomenclaturalCode is NULL while creating the following relationship: " + relationship.getUuid());
463 461
		}
cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/out/PesiTransformer.java
50 50
 *
51 51
 */
52 52
public final class PesiTransformer {
53
	
53 54
	private static final Logger logger = Logger.getLogger(PesiTransformer.class);
54 55

  
55 56
	public static final String auctString = "auct.";
......
210 211
	public static int IS_POTENTIAL_COMBINATION_FOR = 303;
211 212

  
212 213
	public static String STR_IS_BASIONYM_FOR = "is basionym for";
214
	public static String STR_IS_BASIONYM_FOR_ZOOL = "is original combination for";
213 215
	public static String STR_IS_LATER_HOMONYM_OF = "is later homonym of";
214 216
	public static String STR_IS_REPLACED_SYNONYM_FOR = "is replaced synonym for";
215 217
	public static String STR_IS_VALIDATION_OF = "is validation of";
......
235 237
	public static String STR_IS_PRO_PARTE_SYNONYM_OF = "is pro parte synonym of";
236 238
	public static String STR_IS_PARTIAL_SYNONYM_OF = "is partial synonym of";
237 239
	public static String STR_IS_HETEROTYPIC_SYNONYM_OF = "is heterotypic synonym of";
240
	public static String STR_IS_HETEROTYPIC_SYNONYM_OF_ZOOL = "is subjective synonym of";
238 241
	public static String STR_IS_HOMOTYPIC_SYNONYM_OF = "is homotypic synonym of";
242
	private static final String STR_IS_HOMOTYPIC_SYNONYM_OF_ZOOL = "is objective synonym of";
239 243
	public static String STR_IS_PRO_PARTE_AND_HOMOTYPIC_SYNONYM_OF = "is pro parte and homotypic synonym of";
240 244
	public static String STR_IS_PRO_PARTE_AND_HETEROTYPIC_SYNONYM_OF = "is pro parte and heterotypic synonym of";
241 245
	public static String STR_IS_PARTIAL_AND_HOMOTYPIC_SYNONYM_OF = "is partial and homotypic synonym of";
......
3161 3165
	 * @param relation
3162 3166
	 * @return
3163 3167
	 */
3164
	public static String taxonRelation2RelTaxonQualifierCache(RelationshipBase<?,?,?> relation){
3168
	public static String taxonRelation2RelTaxonQualifierCache(RelationshipBase<?,?,?> relation, NomenclaturalCode code){
3165 3169
		if (relation == null) {
3166 3170
			return null;
3167 3171
		}
......
3171 3175
		} else if (type.equals(SynonymRelationshipType.SYNONYM_OF())) {
3172 3176
			return STR_IS_SYNONYM_OF;
3173 3177
		} else if (type.equals(SynonymRelationshipType.HOMOTYPIC_SYNONYM_OF())) {
3174
			return STR_IS_HOMOTYPIC_SYNONYM_OF;
3175
		} else if (type.equals(SynonymRelationshipType.HETEROTYPIC_SYNONYM_OF())) {
3176
			return STR_IS_HETEROTYPIC_SYNONYM_OF;
3177
		} else if (type.equals(SynonymRelationshipType.INFERRED_EPITHET_OF())) {
3178
			return STR_IS_INFERRED_EPITHET_FOR;
3179
		} else if (type.equals(SynonymRelationshipType.INFERRED_GENUS_OF())) {
3180
			return STR_IS_INFERRED_GENUS_FOR;
3181
		} else if (type.equals(SynonymRelationshipType.POTENTIAL_COMBINATION_OF())) {
3182
			return STR_IS_POTENTIAL_COMBINATION_FOR;
3183
		} else if (type.equals(NameRelationshipType.BASIONYM())) {
3184
			return STR_IS_BASIONYM_FOR;
3185
		} else if (type.equals(NameRelationshipType.LATER_HOMONYM())) {
3186
			return STR_IS_LATER_HOMONYM_OF;
3187
		} else if (type.equals(NameRelationshipType.REPLACED_SYNONYM())) {
3188
			return STR_IS_REPLACED_SYNONYM_FOR;
3189
		} else if (type.equals(NameRelationshipType.VALIDATED_BY_NAME())) {
3190
			return STR_IS_VALIDATION_OF;
3191
		} else if (type.equals(NameRelationshipType.LATER_VALIDATED_BY_NAME())) {
3192
			return STR_IS_LATER_VALIDATION_OF;
3193
		} else if (type.equals(NameRelationshipType.CONSERVED_AGAINST())) {
3194
			return STR_IS_CONSERVED_AGAINST;
3195
		} else if (type.equals(NameRelationshipType.TREATED_AS_LATER_HOMONYM())) {
3196
			return STR_IS_TREATED_AS_LATER_HOMONYM_OF;
3197
		} else if (type.equals(NameRelationshipType.ORTHOGRAPHIC_VARIANT())) {
3198
			return STR_IS_ORTHOGRAPHIC_VARIANT_OF;
3199
		} else if (type.equals(NameRelationshipType.ALTERNATIVE_NAME())) {
3200
			return STR_IS_ALTERNATIVE_NAME_FOR;
3201
		} else {
3202
			logger.warn("No equivalent RelationshipType found in datawarehouse for: " + type.getTitleCache());
3203
		}
3204
			
3205
		// The following have no equivalent attribute in CDM
3206
//		IS_TYPE_OF
3207
//		IS_CONSERVED_TYPE_OF
3208
//		IS_REJECTED_TYPE_OF
3209
//		IS_FIRST_PARENT_OF
3210
//		IS_SECOND_PARENT_OF
3211
//		IS_FEMALE_PARENT_OF
3212
//		IS_MALE_PARENT_OF
3213
//		IS_REJECTED_IN_FAVOUR_OF
3214
//		HAS_SAME_TYPE_AS
3215
//		IS_LECTOTYPE_OF
3216
//		TYPE_NOT_DESIGNATED
3217
//		IS_PRO_PARTE_SYNONYM_OF
3218
//		IS_PARTIAL_SYNONYM_OF
3219
//		IS_PRO_PARTE_AND_HOMOTYPIC_SYNONYM_OF
3220
//		IS_PRO_PARTE_AND_HETEROTYPIC_SYNONYM_OF
3221
//		IS_PARTIAL_AND_HOMOTYPIC_SYNONYM_OF
3222
//		IS_PARTIAL_AND_HETEROTYPIC_SYNONYM_OF
3223

  
3224
		return null;
3225
	}
3226
	
3227
	/**
3228
	 * Returns the RelTaxonQualifierCache for a given zoological taxonRelation.
3229
	 * @param relation
3230
	 * @return
3231
	 */
3232
	public static String zoologicalTaxonRelation2RelTaxonQualifierCache(RelationshipBase<?,?,?> relation){
3233
		if (relation == null) {
3234
			return null;
3235
		}
3236
		RelationshipTermBase<?> type = relation.getType();
3237
		if (type.equals(TaxonRelationshipType.MISAPPLIED_NAME_FOR())) {
3238
			return STR_IS_MISAPPLIED_NAME_FOR;
3239
		} else if (type.equals(SynonymRelationshipType.SYNONYM_OF())) {
3240
			return STR_IS_SYNONYM_OF;
3241
		} else if (type.equals(SynonymRelationshipType.HOMOTYPIC_SYNONYM_OF())) {
3242
			return "is objective synonym of";
3178
			if (code.equals(NomenclaturalCode.ICZN)){
3179
				return STR_IS_HOMOTYPIC_SYNONYM_OF_ZOOL;
3180
			}else{
3181
				return STR_IS_HOMOTYPIC_SYNONYM_OF;
3182
			}
3243 3183
		} else if (type.equals(SynonymRelationshipType.HETEROTYPIC_SYNONYM_OF())) {
3244
			return "is subjective synonym of";
3184
			if (code.equals(NomenclaturalCode.ICZN)){
3185
				return STR_IS_HETEROTYPIC_SYNONYM_OF_ZOOL;
3186
			}else{
3187
				return STR_IS_HETEROTYPIC_SYNONYM_OF;
3188
			}
3245 3189
		} else if (type.equals(SynonymRelationshipType.INFERRED_EPITHET_OF())) {
3246 3190
			return STR_IS_INFERRED_EPITHET_FOR;
3247 3191
		} else if (type.equals(SynonymRelationshipType.INFERRED_GENUS_OF())) {
......
3249 3193
		} else if (type.equals(SynonymRelationshipType.POTENTIAL_COMBINATION_OF())) {
3250 3194
			return STR_IS_POTENTIAL_COMBINATION_FOR;
3251 3195
		} else if (type.equals(NameRelationshipType.BASIONYM())) {
3252
			return "is original combination for";
3196
			if (code.equals(NomenclaturalCode.ICZN)){
3197
				return STR_IS_BASIONYM_FOR_ZOOL;
3198
			}else{
3199
				return STR_IS_BASIONYM_FOR;
3200
			}
3253 3201
		} else if (type.equals(NameRelationshipType.LATER_HOMONYM())) {
3254 3202
			return STR_IS_LATER_HOMONYM_OF;
3255 3203
		} else if (type.equals(NameRelationshipType.REPLACED_SYNONYM())) {

Also available in: Unified diff