Project

General

Profile

Revision 7c0a9421

ID7c0a9421f8fe9876aa27214df73b7a38fcab6757
Parent b0beaac0
Child 577592e3

Added by Andreas Müller over 2 years ago

ref #5499 latest changes to edaphobase import

View differences:

app-import/src/main/java/eu/etaxonomy/cdm/app/common/CdmImportSources.java
136 136
        return  makeSource(dbms, strServer, strDB, port, userName, null);
137 137
    }
138 138

  
139
    public static Source EDAPHOBASE5(){
139
    public static Source EDAPHOBASE6(){
140 140
        String dbms = Source.POSTGRESQL9;
141 141
        String strServer = "130.133.70.26";  //BGBM-PESISQL
142
        String strDB = "edaphobase5";
142
        String strDB = "edaphobase6";
143 143
        int port = 5432;
144 144
        String userName = "postgres";
145 145
        return  makeSource(dbms, strServer, strDB, port, userName, null);
app-import/src/main/java/eu/etaxonomy/cdm/app/edaphobase/EdaphobaseActivator.java
38 38
    static DbSchemaValidation dbSchemaValidation = DbSchemaValidation.CREATE;
39 39

  
40 40
//    static final Source edaphoSource = CdmImportSources.EDAPHOBASE();
41
    static final Source edaphoSource = CdmImportSources.EDAPHOBASE5();
41
    static final Source edaphoSource = CdmImportSources.EDAPHOBASE6();
42 42

  
43 43
//    static final ICdmDataSource cdmDestination = CdmDestinations.localH2();
44
//    static final ICdmDataSource cdmDestination = CdmDestinations.cdm_local_edaphobase();
45
    static final ICdmDataSource cdmDestination = CdmDestinations.cdm_production_edaphobase();
44
    static final ICdmDataSource cdmDestination = CdmDestinations.cdm_local_edaphobase();
45
//    static final ICdmDataSource cdmDestination = CdmDestinations.cdm_production_edaphobase();
46 46

  
47 47
    //feature tree uuid
48 48
    private static final UUID featureTreeUuid = UUID.fromString("a543d66a-e310-4b3e-a9fa-b729afefad16");
......
57 57
    private static final boolean doTaxa = true;
58 58
    private static final boolean doSynonyms = true;
59 59
    private static final boolean doReferences = true;
60
    private static final boolean doDescriptions = true;
60
    private static final boolean doDescriptions = false;
61 61

  
62 62

  
63 63
    //check - import
app-import/src/main/java/eu/etaxonomy/cdm/io/edaphobase/EdaphobaseImportTransformer.java
60 60
        else if (key.equals("Variety")){return Rank.VARIETY();}
61 61
        else if (key.equals("Form")){return Rank.FORM();}
62 62
        else if (key.equals("Infraorder")){return Rank.INFRAORDER();}
63
//        else if (key.equals("Hyporder")){return Rank.HYPORDER();}
63
//      else if (key.equals("Hyporder")){return Rank.HYPORDER();}
64 64

  
65 65
        //to be discussed, but handles epithet correctly during import
66 66
        else if (key.equals("Group")){return Rank.SPECIESGROUP();}
app-import/src/main/java/eu/etaxonomy/cdm/io/edaphobase/EdaphobaseTaxonImport.java
30 30
import eu.etaxonomy.cdm.model.common.Language;
31 31
import eu.etaxonomy.cdm.model.common.Marker;
32 32
import eu.etaxonomy.cdm.model.common.MarkerType;
33
import eu.etaxonomy.cdm.model.common.OrderedTermVocabulary;
33 34
import eu.etaxonomy.cdm.model.common.Representation;
34 35
import eu.etaxonomy.cdm.model.name.IZoologicalName;
35 36
import eu.etaxonomy.cdm.model.name.Rank;
37
import eu.etaxonomy.cdm.model.name.RankClass;
36 38
import eu.etaxonomy.cdm.model.name.TaxonNameFactory;
37 39
import eu.etaxonomy.cdm.model.reference.Reference;
38 40
import eu.etaxonomy.cdm.model.reference.ReferenceFactory;
......
72 74

  
73 75
    @Override
74 76
    protected String getRecordQuery(EdaphobaseImportConfigurator config) {
75
        String result = " SELECT DISTINCT t.*, r.value_summary as rankStr, pr.value_summary as parentRankStr, ppr.value_summary as grandParentRankStr, "
76
                    + " pt.name as parentName, ppt.name as grandParentName "
77
        String result = " SELECT DISTINCT t.*, r.value_summary as rankStr, pr.value_summary as parentRankStr, ppr.value_summary as grandParentRankStr, pppr.value_summary as grandGrandParentRankStr, "
78
                    + " pt.name as parentName, ppt.name as grandParentName, pppt.name as grandGrandParentName "
77 79
                + " FROM tax_taxon t "
78 80
                    + " LEFT JOIN tax_taxon pt ON t.parent_taxon_fk = pt.taxon_id "
79
                    + " LEFT JOIN tax_taxon ppt ON pt.parent_taxon_fk = ppt.taxon_id"
81
                    + " LEFT JOIN tax_taxon ppt ON pt.parent_taxon_fk = ppt.taxon_id "
82
                    + " LEFT JOIN tax_taxon pppt ON ppt.parent_taxon_fk = pppt.taxon_id "
80 83
                    + " LEFT OUTER JOIN selective_list.element r ON r.element_id = t.tax_rank_fk "
81 84
                    + " LEFT OUTER JOIN selective_list.element pr ON pr.element_id = pt.tax_rank_fk "
82 85
                    + " LEFT OUTER JOIN selective_list.element ppr ON ppr.element_id = ppt.tax_rank_fk "
86
                    + " LEFT OUTER JOIN selective_list.element pppr ON pppr.element_id = pppt.tax_rank_fk "
83 87
                + " WHERE t.taxon_id IN (@IDSET)";
84 88
        result = result.replace("@IDSET", IPartitionedIO.ID_LIST_TOKEN);
85 89
        return result;
......
138 142
        String rankStr = rs.getString("rankStr");
139 143
        String parentRankStr = rs.getString("parentRankStr");
140 144
        String grandParentRankStr = rs.getString("grandParentRankStr");
145
        String grandGrandParentRankStr = rs.getString("grandGrandParentRankStr");
141 146
        String parentNameStr = rs.getString("parentName");
142 147
        String grandParentNameStr = rs.getString("grandParentName");
148
        String grandGrandParentNameStr = rs.getString("grandGrandParentName");
143 149

  
144 150
        TaxonBase<?> taxonBase;
145 151

  
146 152
        rankStr= extractEnglish(rankStr);
147 153
        parentRankStr= extractEnglish(parentRankStr);
148 154
        grandParentRankStr= extractEnglish(grandParentRankStr);
155
        grandGrandParentRankStr= extractEnglish(grandGrandParentRankStr);
149 156

  
150 157
        //Name etc.
151 158
        Rank rank = makeRank(state, rankStr);
......
156 163
        setNamePart(parentNameStr, parentRank, name);
157 164
        Rank parentParentRank = makeRank(state, grandParentRankStr);
158 165
        setNamePart(grandParentNameStr, parentParentRank, name);
159
        if (parentParentRank != null && parentParentRank.isLower(Rank.GENUS()) || isBlank(name.getGenusOrUninomial()) ){
160
            logger.warn("Grandparent rank is lower than genus for " + name.getTitleCache() + " (edapho-id: " + id + "; cdm-id: " + name.getId());
166
        Rank grandParentParentRank = makeRank(state, grandGrandParentRankStr);
167
        setNamePart(grandGrandParentNameStr, grandParentParentRank, name);
168
        if (grandParentParentRank != null && grandParentParentRank.isLower(Rank.GENUS()) || isBlank(name.getGenusOrUninomial()) ){
169
            logger.warn("Grand-Grandparent rank is lower than genus for " +
170
                    name.getTitleCache() + " (edapho-id: " + id + "; cdm-id: " + name.getId() + ")");
161 171
        }
162 172

  
163 173
        //Authors
......
255 265

  
256 266
        if (rank != null){
257 267
            Set<Marker> markers = rank.getMarkers();
258
            if ( markers.size() == 0){  //we assume that no markers exist. at least not for markers of unused ranks
268
            if ( markers.size() == 0){  //we assume that no markers exist, at least not for markers of unused ranks
259 269
                UUID edaphoRankMarkerTypeUuid = state.getTransformer().getMarkerTypeUuid("EdaphoRankMarker");
260 270
                MarkerType marker = getMarkerType(state, edaphoRankMarkerTypeUuid, "Edaphobase rank", "Rank used in Edaphobase", "EdaRk" );
261 271
                Representation rep = Representation.NewInstance("Rang, verwendet in Edaphobase", "Edaphobase Rang", "EdaRg", Language.GERMAN());
......
264 274
                getTermService().saveOrUpdate(rank);
265 275
            }
266 276
        }else{
267
            logger.warn("Rank is null and marker can not be set");
277
            logger.info("Rank is null and marker can not be set");
268 278
        }
269 279
    }
270 280

  
......
356 366
    private void setNamePart(String nameStr, Rank rank, IZoologicalName name) {
357 367
        if (rank != null){
358 368
            if (rank.isSupraGeneric() || rank.isGenus()){
359
                if (StringUtils.isBlank(name.getGenusOrUninomial())){
369
                if (isBlank(name.getGenusOrUninomial())){
360 370
                    name.setGenusOrUninomial(nameStr);
361 371
                }
362 372
            }else if (rank.isInfraGenericButNotSpeciesGroup()){
363
                if (StringUtils.isBlank(name.getInfraGenericEpithet())){
373
                if (isBlank(name.getInfraGenericEpithet())){
364 374
                    name.setInfraGenericEpithet(nameStr);
365 375
                }
366 376
            }else if (rank.isSpeciesAggregate() || rank.isSpecies()){
367
                if (StringUtils.isBlank(name.getSpecificEpithet())){
377
                if (isBlank(name.getSpecificEpithet())){
368 378
                    name.setSpecificEpithet(nameStr);
369 379
                }
370 380
            }else if (rank.isInfraSpecific()){
371
                if (StringUtils.isBlank(name.getInfraSpecificEpithet())){
381
                if (isBlank(name.getInfraSpecificEpithet())){
372 382
                    name.setInfraSpecificEpithet(nameStr);
373 383
                }
374 384
            }
......
379 389
        Rank rank = null;
380 390
        try {
381 391
            rank = state.getTransformer().getRankByKey(rankStr);
392
            if (rank == null && rankStr != null){
393
                if (rankStr.equals("Cohort")){
394
                    //position not really clear #7285
395
                    Rank lowerRank = Rank.SUPERORDER();
396
                    rank = this.getRank(state, Rank.uuidCohort, "Cohort", "Cohort", null,
397
                            (OrderedTermVocabulary<Rank>)Rank.GENUS().getVocabulary(),
398
                            lowerRank, RankClass.Suprageneric);
399
                }else if (rankStr.equals("Hyporder")){
400
                    rank = this.getRank(state, Rank.uuidHyporder, "Hyporder", "Hyporder", null,
401
                            (OrderedTermVocabulary<Rank>)Rank.GENUS().getVocabulary(),
402
                            Rank.SUBORDER(), RankClass.Suprageneric);
403
                }
404
            }
382 405
        } catch (UndefinedTransformerMethodException e) {
383 406
            e.printStackTrace();
384 407
        }

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)