Project

General

Profile

« Previous | Next » 

Revision 55b8caff

Added by Andreas Müller over 6 years ago

ref #5499 latest Edaphobase import changes

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(){
140
        String dbms = Source.POSTGRESQL9;
141
        String strServer = "130.133.70.26";  //BGBM-PESISQL
142
        String strDB = "edaphobase5";
143
        int port = 5432;
144
        String userName = "postgres";
145
        return  makeSource(dbms, strServer, strDB, port, userName, null);
146
    }
147

  
139 148

  
140 149

  
141 150

  
app-import/src/main/java/eu/etaxonomy/cdm/app/edaphobase/EdaphobaseActivator.java
37 37
    //database validation status (create, update, validate ...)
38 38
    static DbSchemaValidation dbSchemaValidation = DbSchemaValidation.CREATE;
39 39

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

  
42 43
//    static final ICdmDataSource cdmDestination = CdmDestinations.localH2();
43 44
//    static final ICdmDataSource cdmDestination = CdmDestinations.cdm_local_edaphobase();
app-import/src/main/java/eu/etaxonomy/cdm/io/edaphobase/EdaphobaseImportTransformer.java
55 55
        else if (key.equals("Form")){return Rank.FORM();}
56 56
        else if (key.equals("Infraorder")){return Rank.INFRAORDER();}
57 57
//        else if (key.equals("Hyporder")){return Rank.HYPORDER();}
58
//        else if (key.equals("Group")){return Rank.GREX();}
58

  
59
        //to be discussed, but handles epithet correctly during import
60
        else if (key.equals("Group")){return Rank.SPECIESGROUP();}
59 61
        return null;
60 62
    }
61 63

  
app-import/src/main/java/eu/etaxonomy/cdm/io/edaphobase/EdaphobaseTaxonImport.java
72 72

  
73 73
    @Override
74 74
    protected String getRecordQuery(EdaphobaseImportConfigurator config) {
75
        String result = " SELECT DISTINCT t.*, r.value as rankStr, pr.value as parentRankStr, ppr.value as grandParentRankStr, "
75
        String result = " SELECT DISTINCT t.*, r.value_summary as rankStr, pr.value_summary as parentRankStr, ppr.value_summary as grandParentRankStr, "
76 76
                    + " pt.name as parentName, ppt.name as grandParentName "
77 77
                + " FROM tax_taxon t "
78 78
                    + " LEFT JOIN tax_taxon pt ON t.parent_taxon_fk = pt.taxon_id "
79 79
                    + " LEFT JOIN tax_taxon ppt ON pt.parent_taxon_fk = ppt.taxon_id"
80
                    + " LEFT OUTER JOIN tax_rank_en r ON r.element_id = t.tax_rank_fk "
81
                    + " LEFT OUTER JOIN tax_rank_en pr ON pr.element_id = pt.tax_rank_fk "
82
                    + " LEFT OUTER JOIN tax_rank_en ppr ON ppr.element_id = ppt.tax_rank_fk "
80
                    + " LEFT OUTER JOIN selective_list.element r ON r.element_id = t.tax_rank_fk "
81
                    + " LEFT OUTER JOIN selective_list.element pr ON pr.element_id = pt.tax_rank_fk "
82
                    + " LEFT OUTER JOIN selective_list.element ppr ON ppr.element_id = ppt.tax_rank_fk "
83 83
                + " WHERE t.taxon_id IN (@IDSET)";
84 84
        result = result.replace("@IDSET", IPartitionedIO.ID_LIST_TOKEN);
85 85
        return result;
......
143 143

  
144 144
        TaxonBase<?> taxonBase;
145 145

  
146
        rankStr= extractEnglish(rankStr);
147
        parentRankStr= extractEnglish(parentRankStr);
148
        grandParentRankStr= extractEnglish(grandParentRankStr);
149

  
146 150
        //Name etc.
147 151
        Rank rank = makeRank(state, rankStr);
148 152
        checkRankMarker(state, rank);
......
205 209
    }
206 210

  
207 211

  
212
    /**
213
     * @param rankStr
214
     * @return
215
     */
216
    private String extractEnglish(String rankStr) {
217
        if (rankStr == null){
218
            return null;
219
        }
220
        String[] splits = rankStr.split(", ");
221
        if (splits.length != 3){
222
            String message = "Wrong rank format: "+  rankStr;
223
            logger.error(message);
224
            return null;
225
        }
226
        return splits[1].trim();
227
    }
228

  
229

  
208 230
    static Map<Integer,UUID> idMap = new HashMap<>();
209 231
    static{
210 232
        idMap.put(86594, UUID.fromString("715c2370-45a4-450c-99f7-e196758979ca"));  //Aporrectodea caliginosa
......
337 359
                if (StringUtils.isBlank(name.getGenusOrUninomial())){
338 360
                    name.setGenusOrUninomial(nameStr);
339 361
                }
340
            }else if (rank.isInfraGeneric()){
362
            }else if (rank.isInfraGenericButNotSpeciesGroup()){
341 363
                if (StringUtils.isBlank(name.getInfraGenericEpithet())){
342 364
                    name.setInfraGenericEpithet(nameStr);
343 365
                }

Also available in: Unified diff