Project

General

Profile

« Previous | Next » 

Revision 76a5e528

Added by Andreas Müller almost 6 years ago

ref #5499, ref #6517 latest changes to Edaphobase import (also stable uuids)

View differences:

app-import/src/main/java/eu/etaxonomy/cdm/app/common/CdmDestinations.java
390 390
        return makeDestination(dbType, cdmServer, cdmDB, -1, cdmUserName, null);
391 391
    }
392 392

  
393
    public static ICdmDataSource cdm_postgres_edaphobase(){
394
        DatabaseTypeEnum dbType = DatabaseTypeEnum.PostgreSQL;
395
        String cdmServer = "130.133.70.26";
396
        String cdmDB = "cdm_edaphobase";
397
        String cdmUserName = "edaphobase";
398
        int port = 5433;
399
        return makeDestination(dbType, cdmServer, cdmDB, port, cdmUserName, null);
400
    }
401

  
402
    public static ICdmDataSource cdm_test_postgres_edaphobase(){
403
        DatabaseTypeEnum dbType = DatabaseTypeEnum.PostgreSQL;
404
        String cdmServer = "160.45.63.175";
405
        String cdmDB = "cdm_edaphobase";
406
        String cdmUserName = "edaphobase";
407
        int port = 5432;
408
        return makeDestination(dbType, cdmServer, cdmDB, port, cdmUserName, null);
409
    }
410

  
411
    public static ICdmDataSource cdm_test_postgres__ssh_edaphobase(){
412
        DatabaseTypeEnum dbType = DatabaseTypeEnum.PostgreSQL;
413
        String cdmServer = "localhost";
414
        String cdmDB = "cdm_edaphobase";
415
        String cdmUserName = "edaphobase";
416
        int port = 13306;
417
        return makeDestination(dbType, cdmServer, cdmDB, port, cdmUserName, null);
418
    }
419

  
393 420
    public static ICdmDataSource cdm_local_caryo_spp(){
394 421
        DatabaseTypeEnum dbType = DatabaseTypeEnum.MySQL;
395 422
        String cdmServer = "127.0.0.1";
app-import/src/main/java/eu/etaxonomy/cdm/app/common/CdmImportSources.java
145 145
        return  makeSource(dbms, strServer, strDB, port, userName, null);
146 146
    }
147 147

  
148
    public static Source EDAPHOBASE8(){
149
        String dbms = Source.POSTGRESQL9;  //TODO 10
150
        String strServer = "130.133.70.26";  //BGBM-PESISQL
151
        String strDB = "edaphobase8";
152
        int port = 5433;
153
        String userName = "edaphobase";
154
        return  makeSource(dbms, strServer, strDB, port, userName, null);
155
    }
156

  
148 157
}
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.EDAPHOBASE6();
41
    static final Source edaphoSource = CdmImportSources.EDAPHOBASE8();
42 42

  
43 43
//    static final ICdmDataSource cdmDestination = CdmDestinations.localH2();
44
    static final ICdmDataSource cdmDestination = CdmDestinations.cdm_local_edaphobase();
44
//    static final ICdmDataSource cdmDestination = CdmDestinations.cdm_local_edaphobase();
45 45
//    static final ICdmDataSource cdmDestination = CdmDestinations.cdm_production_edaphobase();
46
//    static final ICdmDataSource cdmDestination = CdmDestinations.cdm_postgres_edaphobase();
47
//    static final ICdmDataSource cdmDestination = CdmDestinations.cdm_test_postgres_edaphobase();
48
    static final ICdmDataSource cdmDestination = CdmDestinations.cdm_test_postgres_edaphobase();
49

  
50

  
46 51

  
47 52
    //feature tree uuid
48 53
    private static final UUID featureTreeUuid = UUID.fromString("a543d66a-e310-4b3e-a9fa-b729afefad16");
......
59 64
    private static final boolean doReferences = true;
60 65
    private static final boolean doDescriptions = false;
61 66

  
67
    //logging
68
    private static final boolean ignoreSubgenus = true;
69
    private static final boolean ignore4nomial = true;
70

  
62 71

  
63 72
    //check - import
64 73
    static CHECK check = CHECK.IMPORT_WITHOUT_CHECK;
......
77 86
        config.setDoDescriptions(doDescriptions);
78 87
        config.setCheck(check);
79 88

  
89
        config.setIgnoreSubgenus(ignoreSubgenus);
90
        config.setIgnore4nomial(ignore4nomial);
91

  
80 92
        CdmDefaultImport<EdaphobaseImportConfigurator> myImport = new CdmDefaultImport<>();
81 93
        myImport.invoke(config);
82 94

  
app-import/src/main/java/eu/etaxonomy/cdm/io/edaphobase/EdaphobaseImportConfigurator.java
50 50
    public String getEdaphobaseSecundumTitle() {return edaphobaseSecundumTitle;}
51 51
    public void setEdaphobaseSecundumTitle(String edaphobaseSecundumTitle) {this.edaphobaseSecundumTitle = edaphobaseSecundumTitle;}
52 52

  
53
    //logging
54
    private boolean ignoreSubgenus = true;
55
    public boolean isIgnoreSubgenus() {return ignoreSubgenus;}
56
    public void setIgnoreSubgenus(boolean ignoreSubgenus) {this.ignoreSubgenus = ignoreSubgenus;}
57

  
58
    private boolean ignore4nomial = true;
59
    public boolean isIgnore4nomial() {return ignore4nomial;}
60
    public void setIgnore4nomial(boolean ignore4nomial) {this.ignore4nomial = ignore4nomial;}
61

  
53 62

  
54 63
    /**
55 64
     * @param source
app-import/src/main/java/eu/etaxonomy/cdm/io/edaphobase/EdaphobaseTaxonImport.java
175 175
        String parentNameStr = rs.getString("parentName");
176 176
        String grandParentNameStr = rs.getString("grandParentName");
177 177
        String grandGrandParentNameStr = rs.getString("grandGrandParentName");
178
        String editUuid = rs.getString("edit_uuid");
178 179

  
179 180

  
180 181
        if (isDeleted){
......
297 298
            }
298 299
            name.setNomenclaturalReference(nomRef);
299 300
        }
300
        name.setNomenclaturalMicroReference(StringUtils.isBlank(pages)? null : pages);
301
        name.setNomenclaturalMicroReference(isBlank(pages)? null : pages);
301 302

  
302 303
        //taxon
303 304
        Reference secRef = state.getRelatedObject(REFERENCE_NAMESPACE, state.getConfig().getSecUuid().toString(), Reference.class);
......
328 329
        //id
329 330
        ImportHelper.setOriginalSource(taxonBase, state.getTransactionalSourceReference(), id, TAXON_NAMESPACE);
330 331
        ImportHelper.setOriginalSource(name, state.getTransactionalSourceReference(), id, TAXON_NAMESPACE);
332
        taxonBase.setUuid(UUID.fromString(editUuid));
331 333
        handleExampleIdentifiers(taxonBase, id);
332 334

  
333 335
        if (!nameAdditionUsed){
334 336
            logger.warn("name_addition not recognized: " +  nameAddition + ". ID="+id);
335 337
            name.setAppendedPhrase(nameAddition);
336 338
        }
337
        String orig = displayString.replace("nomen nudum [Hirschmann, 1951]", "Hirschmann, 1951")
338
                .replace("  ", " ");
339
        String nameTitleCache = name.getTitleCache().replace("species group", "group");
340
        String taxonTitleCache = taxonBase.getTitleCache().replace("species group", "group");
341
        if (!orig.equals(nameTitleCache) && !orig.equals(name.getFullTitleCache()) && !orig.equals(taxonTitleCache)){
339

  
340
        if (titleCacheDiffers(state, displayString, name, taxonBase)){
342 341
            String titleCache = taxonBase.getAppendedPhrase() != null ? taxonBase.getTitleCache() : name.getTitleCache();
343 342
            logger.warn("Displaystring differs from titleCache. ID=" + id + ".\n   " + displayString + "\n   " + titleCache);
344 343
        }
......
346 345

  
347 346

  
348 347
    /**
348
     * @param state
349
     * @param displayString
350
     * @param name
351
     * @param taxonBase
352
     * @return
353
     */
354
    private boolean titleCacheDiffers(EdaphobaseImportState state, String displayString, IZoologicalName name, TaxonBase<?> taxonBase) {
355
        String orig = displayString.replace("nomen nudum [Hirschmann, 1951]", "Hirschmann, 1951")
356
                .replace("  ", " ");
357
        String nameTitleCache = name.getTitleCache().replace("species group", "group");
358
        String taxonTitleCache = taxonBase.getTitleCache().replace("species group", "group");
359

  
360
//        if (state.getConfig().isIgnore4nomial() && orig.matches(".* subsp"))
361
        boolean result =
362
                !orig.equals(nameTitleCache)
363
                && !orig.equals(name.getFullTitleCache())
364
                && !orig.equals(taxonTitleCache);
365
        return result;
366
    }
367

  
368
    /**
349 369
     * @param authorStr
350 370
     * @return
351 371
     */
......
436 456
    private void handleExampleIdentifiers(TaxonBase<?> taxonBase, Integer id) {
437 457
        if (idMap.get(id) != null){
438 458
            taxonBase.setUuid(idMap.get(id));
459
            logger.warn("Override UUID for specific taxa. ID="+ id +  "; uuid="+idMap.get(id) + "; name="+ taxonBase.getName().getTitleCache());
439 460
        }
440 461
    }
441 462

  

Also available in: Unified diff