Project

General

Profile

Download (3.38 KB) Statistics
| Branch: | Revision:
1
/**
2
* Copyright (C) 2015 EDIT
3
* European Distributed Institute of Taxonomy
4
* http://www.e-taxonomy.eu
5
*
6
* The contents of this file are subject to the Mozilla Public License Version 1.1
7
* See LICENSE.TXT at the top of this package for the full license terms.
8
*/
9
package eu.etaxonomy.cdm.app.caryophyllales;
10

    
11
import java.io.File;
12
import java.io.FileReader;
13
import java.io.IOException;
14
import java.io.InputStreamReader;
15
import java.util.UUID;
16

    
17
import org.apache.logging.log4j.LogManager;
18
import org.apache.logging.log4j.Logger;
19

    
20
import eu.etaxonomy.cdm.app.common.CdmDestinations;
21
import eu.etaxonomy.cdm.database.DbSchemaValidation;
22
import eu.etaxonomy.cdm.database.ICdmDataSource;
23
import eu.etaxonomy.cdm.io.common.CdmDefaultImport;
24
import eu.etaxonomy.cdm.io.common.IImportConfigurator.CHECK;
25
import eu.etaxonomy.cdm.io.identifier.IdentifierImportConfigurator;
26
import eu.etaxonomy.cdm.model.name.TaxonName;
27
import eu.etaxonomy.cdm.model.term.IdentifierType;
28

    
29
/**
30
 * @author a.mueller
31
 */
32
public class DianthusIdentifierActivator {
33

    
34
    @SuppressWarnings("unused")
35
    private static final Logger logger = LogManager.getLogger();
36

    
37
    //database validation status (create, update, validate ...)
38
    static DbSchemaValidation dbSchemaValidation = DbSchemaValidation.VALIDATE;
39

    
40
//    static final ICdmDataSource cdmDestination = CdmDestinations.cdm_local_caryo_spp();
41
    static final ICdmDataSource cdmDestination = CdmDestinations.cdm_production_caryophyllales_spp();
42

    
43
    static final UUID identifierUuid = IdentifierType.uuidWfoNameIdentifier;
44
    String filename = "Dianthus_WFO_IDs.csv";
45
//    String filename = "Cactaceae_SpeciesAndBelowWithoutWFO-ID.txt";
46
    boolean warnAndDoNotOverrideIfExists = true;
47

    
48
//    static final UUID identifierUuid = DefinedTerm.uuidWfoNameIdentifier;
49
//    String filename = "WFO2CDM_Cactaceae_WFO-ID.txt";
50

    
51
//    static final UUID identifierUuid = DefinedTerm.uuidIpniNameIdentifier;
52
//    String filename = "WFO2CDM_Cactaceae_IPNI-ID.txt";
53

    
54
    //check - import
55
    static CHECK check = CHECK.IMPORT_WITHOUT_CHECK;
56

    
57
    private void doImport(ICdmDataSource cdmDestination){
58

    
59
        InputStreamReader source = getNepenthesIdentifier();
60
        IdentifierImportConfigurator config= IdentifierImportConfigurator.NewInstance(source, cdmDestination);
61
        config.setWarnAndDoNotOverrideIfExists(warnAndDoNotOverrideIfExists);
62
        config.setDbSchemaValidation(dbSchemaValidation);
63
        config.setIdentifierTypeUuid(identifierUuid);
64
        config.setCdmClass(TaxonName.class);
65
        config.setCheck(check);
66

    
67
        CdmDefaultImport<IdentifierImportConfigurator> myImport = new CdmDefaultImport<>();
68
        myImport.invoke(config);
69
    }
70

    
71
    private InputStreamReader getNepenthesIdentifier() {
72

    
73
//        URI.create("file:////BGBM-PESIHPC/FloraMalesianaXml/fmvol14_final2.xml")
74
        String path = "C://opt//data//Caryophyllales";
75
        File file = new File(path + File.separator + filename);
76
        if (!file.exists()){
77
            System.exit(-1);
78
            return null;
79
        }
80
        try {
81
            InputStreamReader input = new FileReader(file);
82
            return input;
83
        } catch (IOException e) {
84
            e.printStackTrace();
85
            System.exit(-1);
86
            return null;
87
        }
88
    }
89

    
90
    public static void main(String[] args) {
91
        DianthusIdentifierActivator me = new DianthusIdentifierActivator();
92
        me.doImport(cdmDestination);
93
        System.exit(0);
94
    }
95
}
(8-8/20)