Project

General

Profile

Revision 2a235907

ID2a235907f0166dc4792957a2ccc7c70a5c02aac5
Parent e76ff5da
Child 92fdeae1

Added by Andreas Müller 5 months ago

cleanup

View differences:

cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/faunaEuropaea/FaunaEuropaeaAdditionalTaxonDataImport.java
111 111
					if (infraGenericEpithet == null) {
112 112
						String genusOrUninomial = targetNonViralName.getGenusOrUninomial();
113 113
						String specificEpithet = targetNonViralName.getSpecificEpithet();
114
						List<TaxonBase> foundTaxa = getTaxonService().listTaxaByName(Taxon.class, genusOrUninomial, "*", specificEpithet,
114
						List<Taxon> foundTaxa = getTaxonService().listTaxaByName(Taxon.class, genusOrUninomial, "*", specificEpithet,
115 115
								"*", "*", null, pageSize, 1, null);
116 116
						if (foundTaxa.size() == 1) {
117 117
							// one matching Taxon found
cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/faunaEuropaea/FaunaEuropaeaHeterotypicSynonymImport.java
20 20

  
21 21
import eu.etaxonomy.cdm.io.common.CdmImportBase;
22 22
import eu.etaxonomy.cdm.io.common.ICdmImport;
23
import eu.etaxonomy.cdm.model.name.HomotypicalGroup;
24 23
import eu.etaxonomy.cdm.model.name.NameRelationship;
25 24
import eu.etaxonomy.cdm.model.name.TaxonName;
26 25
import eu.etaxonomy.cdm.model.taxon.Synonym;
......
33 32
 *
34 33
 * @author a.babadshanjan
35 34
 * @since 22.09.2009
36
 * @version 1.0
37 35
 */
38 36
@Component
39
public class FaunaEuropaeaHeterotypicSynonymImport extends CdmImportBase<FaunaEuropaeaImportConfigurator, FaunaEuropaeaImportState>
40
implements ICdmImport<FaunaEuropaeaImportConfigurator, FaunaEuropaeaImportState> {
41
	private static final Logger logger = Logger
42
			.getLogger(FaunaEuropaeaHeterotypicSynonymImport.class);
43

  
44
	/* (non-Javadoc)
45
	 * @see eu.etaxonomy.cdm.io.common.CdmIoBase#doCheck(eu.etaxonomy.cdm.io.common.IoStateBase)
46
	 */
37
public class FaunaEuropaeaHeterotypicSynonymImport
38
        extends CdmImportBase<FaunaEuropaeaImportConfigurator, FaunaEuropaeaImportState>
39
        implements ICdmImport<FaunaEuropaeaImportConfigurator, FaunaEuropaeaImportState> {
40

  
41
    private static final long serialVersionUID = -4195183108743873247L;
42
    private static final Logger logger = Logger.getLogger(FaunaEuropaeaHeterotypicSynonymImport.class);
43

  
47 44
	@Override
48 45
	protected boolean doCheck(FaunaEuropaeaImportState state) {
49 46
		logger.warn("Checking for heterotypic synonyms for basionyms not yet implemented");
50 47
		return false;
51 48
	}
52 49

  
53
	/* (non-Javadoc)
54
	 * @see eu.etaxonomy.cdm.io.common.CdmIoBase#doInvoke(eu.etaxonomy.cdm.io.common.IoStateBase)
55
	 */
56 50
	@Override
57 51
	protected void doInvoke(FaunaEuropaeaImportState state) {
58 52

  
......
84 78

  
85 79
				if (((i % limit) == 0 && i != 1 ) || i == nbrOfSynonyms) {
86 80

  
87
					HomotypicalGroup homotypicalGroup = null;
88
					Set<TaxonName> basionyms = null;
89 81
					Set<NameRelationship> nameRelations = null;
90
					TaxonName basionym = null;
91 82
					Set<Taxon> taxonBases = null;
92 83
					Taxon acceptedTaxon = null;
93 84
					TaxonName synonymName = null;
94 85
					NameRelationship nameRelation = null;
95 86
					TaxonName acceptedName = null;
96 87

  
97
					for (TaxonBase synonym : synonymList) {
88
					for (TaxonBase<?> synonym : synonymList) {
98 89
						synonymName = synonym.getName();
99 90
						if (synonymName.isGroupsBasionym()) {
100 91
							nameRelations = synonymName.getNameRelations();
......
138 129
		return;
139 130
	}
140 131

  
141
	/* (non-Javadoc)
142
	 * @see eu.etaxonomy.cdm.io.common.CdmIoBase#isIgnore(eu.etaxonomy.cdm.io.common.IoStateBase)
143
	 */
144 132
	@Override
145 133
	protected boolean isIgnore(FaunaEuropaeaImportState state) {
146 134
		return !(state.getConfig().isDoHeterotypicSynonymsForBasionyms());
cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/faunaEuropaea/FaunaEuropaeaImportBase.java
33 33
/**
34 34
 * @author a.babadshanjan
35 35
 * @since 11.05.2009
36
 * @version 1.0
37 36
 */
38
public abstract class FaunaEuropaeaImportBase extends CdmImportBase<FaunaEuropaeaImportConfigurator, FaunaEuropaeaImportState>
39
implements ICdmImport<FaunaEuropaeaImportConfigurator,FaunaEuropaeaImportState> {
40
	private static final Logger logger = Logger.getLogger(FaunaEuropaeaImportBase.class);
37
public abstract class FaunaEuropaeaImportBase
38
        extends CdmImportBase<FaunaEuropaeaImportConfigurator, FaunaEuropaeaImportState>
39
        implements ICdmImport<FaunaEuropaeaImportConfigurator,FaunaEuropaeaImportState> {
40

  
41
    private static final Logger logger = Logger.getLogger(FaunaEuropaeaImportBase.class);
41 42

  
42 43
//	/* Max number of taxa to retrieve (for test purposes) */
43 44
//	protected static final int maxTaxa = 1000;
......
107 108
		}
108 109
	}
109 110

  
110

  
111
	/**
112
	 * @param state
113
	 * @param sourceRef
114
	 */
115 111
	protected Classification getClassificationFor(FaunaEuropaeaImportState state, Reference sourceRef) {
116 112

  
117 113
		Classification tree;
cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/faunaEuropaea/FaunaEuropaeaRelTaxonIncludeImport.java
58 58
@Component
59 59
public class FaunaEuropaeaRelTaxonIncludeImport extends FaunaEuropaeaImportBase  {
60 60

  
61
	public static final String OS_NAMESPACE_TAXON = "Taxon";
61
    private static final long serialVersionUID = 4068337179814111891L;
62
    private static final Logger logger = Logger.getLogger(FaunaEuropaeaRelTaxonIncludeImport.class);
63

  
64
    public static final String OS_NAMESPACE_TAXON = "Taxon";
62 65
	private static final String AUCT_STRING = "auct.";
63
	private static final Logger logger = Logger.getLogger(FaunaEuropaeaRelTaxonIncludeImport.class);
64 66
	//private static final String acceptedTaxonUUID = "A9C24E42-69F5-4681-9399-041E652CF338"; // any accepted taxon uuid, taken from original fauna europaea database
65 67
	//private static final String acceptedTaxonUUID = "E23E6295-836A-4332-BF72-7D29949C7C60"; //faunaEu_1_3
66 68
	//private static final String acceptedTaxonUUID = "bab7642e-f733-4a21-848d-a15250d2f4ed"; //for faunEu (2.4)
67 69
	private static final String acceptedTaxonUUID = "DADA6F44-B7B5-4C0A-9F32-980F54B02C36"; // for MfNFaunaEuropaea
68 70

  
69
	private Map<UUID, TeamOrPersonBase> agentMap = new HashMap<UUID, TeamOrPersonBase>();
71
	private Map<UUID, TeamOrPersonBase> agentMap = new HashMap<>();
70 72

  
71 73

  
72 74
	private Reference sourceRef;
......
125 127

  
126 128

  
127 129
		// the uuid of an accepted taxon is needed here. any accepted taxon will do.
128
		TaxonBase taxon = getTaxonService().find(UUID.fromString(acceptedTaxonUUID));
130
		TaxonBase<?> taxon = getTaxonService().find(UUID.fromString(acceptedTaxonUUID));
129 131
		sourceRef = taxon.getSec();
130 132

  
131 133
		Classification tree = getClassificationFor(state, sourceRef);
......
178 180
     */
179 181
    private void createAgentMap(FaunaEuropaeaImportState state) {
180 182

  
181

  
182 183
        List<String> propertyPaths = new ArrayList<String>();
183 184
        propertyPaths.add("sources");
184 185

  
......
190 191
        for (Object[] person: result){
191 192
            idInSource = Integer.valueOf((String)person[1]);
192 193
            UUID agentUuid = (UUID) person[0];
193

  
194

  
195 194
            state.getAgentMap().put(idInSource, agentUuid);
196 195
        }
197 196
    }
......
357 356
		String orderClause = " ORDER BY dbo.Taxon.TAX_RNK_ID ASC ";
358 357

  
359 358

  
360

  
361

  
362 359
		String countQuery =
363 360
			selectCount + fromClause;
364 361

  
......
399 396
				UUID parentUuid = UUID.fromString(parentUuidStr);
400 397

  
401 398
				if (!childParentMap.containsKey(childUuid)) {
402

  
403 399
						childParentMap.put(childUuid, parentUuid);
404

  
405 400
				} else {
406 401
					if(logger.isDebugEnabled()) {
407 402
						logger.debug("Duplicated child UUID (" + childUuid + ")");
......
441 436
		commitTransaction(txStatus);
442 437
	}
443 438

  
444

  
445

  
446 439
	/** Retrieve synonyms from FauEuDB DB */
447 440
	private void processHeterotypicSynonyms(FaunaEuropaeaImportState state, String fromClause) {
448 441

  
......
486 479
		return;
487 480
	}
488 481

  
489

  
490

  
491

  
492 482
	private void storeSynonymRelationships(ResultSet rs, int count, FaunaEuropaeaImportState state)
493 483
	throws SQLException {
494 484

  
......
552 542
		return synonymAcceptedMap;
553 543
	}
554 544

  
555

  
556

  
557

  
558

  
559 545
	/* Creates parent-child relationships.
560 546
	 * Parent-child pairs are retrieved in blocks via findByUUID(Set<UUID>) from CDM DB.
561 547
	 */
562 548
	private void createParentChildRelationships(FaunaEuropaeaImportState state, Map<UUID, UUID> childParentMap, Map<UUID, UUID> taxonSpecialistMap, Map<UUID, UUID> taxonGroupCoordinatorMap, TransactionStatus tx) {
563 549
		//gets the taxon "Hydroscaphidae"(family)
564
		TaxonBase taxon = getTaxonService().find(UUID.fromString(acceptedTaxonUUID));
550
		TaxonBase<?> taxon = getTaxonService().find(UUID.fromString(acceptedTaxonUUID));
565 551
		sourceRef = taxon.getSec();
566 552
		int limit = state.getConfig().getLimitSave();
567 553

  
568 554
		Classification tree = getClassificationFor(state, sourceRef);
569 555

  
570
		Set<TaxonBase> childSet = new HashSet<TaxonBase>(limit);
556
		Set<TaxonBase> childSet = new HashSet<>(limit);
571 557

  
572 558
		Set<UUID> childKeysSet = childParentMap.keySet();
573
		Set<UUID> parentValuesSet = new HashSet<UUID>(childParentMap.values());
559
		Set<UUID> parentValuesSet = new HashSet<>(childParentMap.values());
574 560
		logger.debug("Start reading children and parents");
575 561
		if (logger.isInfoEnabled()) {
576 562
			logger.info("Start reading children and parents");
......
579 565
		List<TaxonBase> parents = getTaxonService().find(parentValuesSet);
580 566
		logger.info(children.size() + "children are available");
581 567
		logger.info(parents.size() + "parents are available");
582
		Map<UUID, TaxonBase> parentsMap = new HashMap<UUID, TaxonBase>(parents.size());
568
		Map<UUID, TaxonBase> parentsMap = new HashMap<>(parents.size());
583 569

  
584
		for (TaxonBase taxonBase : parents){
570
		for (TaxonBase<?> taxonBase : parents){
585 571
			parentsMap.put(taxonBase.getUuid(), taxonBase);
586 572
		}
587 573

  
......
593 579
			for (UUID uuid : parentValuesSet) {
594 580
				logger.trace("parent uuid query: " + uuid);
595 581
			}
596
			for (TaxonBase tb : children) {
582
			for (TaxonBase<?> tb : children) {
597 583
				logger.trace("child uuid result: " + tb.getUuid());
598 584
			}
599
			for (TaxonBase tb : parents) {
585
			for (TaxonBase<?> tb : parents) {
600 586
				logger.trace("parent uuid result: " + tb.getUuid());
601 587
			}
602 588
		}
......
1147 1133
	        // Start transaction
1148 1134
	        TransactionStatus txStatus = startTransaction(true);
1149 1135
	        logger.info("Started new transaction. Fetching some " + parentPluralString + " first (max: " + limit + ") ...");
1150
	        List<TaxonBase> taxonList = null;
1151
	        Set<TaxonBase> synonymList = new HashSet<TaxonBase>();
1136
	        List<Taxon> taxonList = null;
1137
	        Set<TaxonBase> synonymList = new HashSet<>();
1152 1138

  
1153 1139

  
1154 1140
	        while ((taxonList  = getTaxonService().listTaxaByName(Taxon.class, "*", "*", "*", "*", "*", Rank.SPECIES(), pageSize, pageNumber, null)).size() > 0) {
......
1224 1210
    * @return
1225 1211
    */
1226 1212
   private Set<TaxonBase> createInferredSynonymsForTaxonList(FaunaEuropaeaImportState state,
1227
            List<TaxonBase> taxonList) {
1213
            List<Taxon> taxonList) {
1228 1214

  
1229 1215
       Taxon acceptedTaxon;
1230 1216
       Classification classification = null;
1231
       Set<TaxonBase> inferredSynonyms = new HashSet<TaxonBase>();
1232
       List<Synonym> inferredSynonymsLocal= new ArrayList<Synonym>();
1217
       Set<TaxonBase> inferredSynonyms = new HashSet<>();
1218
       List<Synonym> inferredSynonymsLocal= new ArrayList<>();
1233 1219
       boolean localSuccess = true;
1234 1220

  
1235 1221
       HashMap<Integer, TaxonName> inferredSynonymsDataToBeSaved = new HashMap<>();

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)