Project

General

Profile

Download (2.88 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

    
16
import org.apache.log4j.Logger;
17

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

    
27
/**
28
 * @author a.mueller
29
 * @since 25.03.2017
30
 *
31
 */
32
public class NepenthesIdentifierActivator {
33

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

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

    
40
//    static final ICdmDataSource cdmDestination = CdmDestinations.localH2();
41
    static final ICdmDataSource cdmDestination = CdmDestinations.cdm_production_caryophyllales_nepenthaceae();
42

    
43
    //check - import
44
    static CHECK check = CHECK.IMPORT_WITHOUT_CHECK;
45

    
46
    private void doImport(ICdmDataSource cdmDestination){
47

    
48
        InputStreamReader source = getNepenthesIdentifier();
49
        IdentifierImportConfigurator config= IdentifierImportConfigurator.NewInstance(source, cdmDestination);
50
        config.setDbSchemaValidation(dbSchemaValidation);
51
        config.setIdentifierTypeUuid(DefinedTerm.uuidWfoNameIdentifier);
52
        config.setCdmClass(TaxonName.class);
53
        config.setCheck(check);
54

    
55
        CdmDefaultImport<IdentifierImportConfigurator> myImport = new CdmDefaultImport<>();
56
        myImport.invoke(config);
57

    
58
    }
59

    
60
    private InputStreamReader getNepenthesIdentifier() {
61
        String filename = "WfoIds.csv";
62

    
63
//        URI.create("file:////BGBM-PESIHPC/FloraMalesianaXml/fmvol14_final2.xml")
64
        String path = "C://opt//data//Caryophyllales";
65
        File file = new File(path + File.separator + filename);
66
        if (!file.exists()){
67
            System.exit(-1);
68
            return null;
69
        }
70
        try {
71
            InputStreamReader input = new FileReader(file);
72
            return input;
73
        } catch (IOException e) {
74
            e.printStackTrace();
75
            System.exit(-1);
76
            return null;
77
        }
78
    }
79

    
80

    
81
    /**
82
     * @param args
83
     */
84
    public static void main(String[] args) {
85
        NepenthesIdentifierActivator me = new NepenthesIdentifierActivator();
86
        me.doImport(cdmDestination);
87
        System.exit(0);
88
    }
89
}
(10-10/17)