Project

General

Profile

Download (3.12 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.edaphobase;
10

    
11
import java.io.IOException;
12
import java.io.InputStreamReader;
13

    
14
import org.apache.log4j.Logger;
15

    
16
import eu.etaxonomy.cdm.app.common.CdmDestinations;
17
import eu.etaxonomy.cdm.common.CdmUtils;
18
import eu.etaxonomy.cdm.database.DbSchemaValidation;
19
import eu.etaxonomy.cdm.database.ICdmDataSource;
20
import eu.etaxonomy.cdm.io.common.CdmDefaultImport;
21
import eu.etaxonomy.cdm.io.common.IImportConfigurator.CHECK;
22
import eu.etaxonomy.cdm.io.terms.RepresentationCsvImportConfigurator;
23
import eu.etaxonomy.cdm.model.common.Language;
24

    
25
/**
26
 * @author a.mueller
27
 * @date 04.12.2015
28
 */
29
public class EdaphobaseRankActivator {
30
    @SuppressWarnings("unused")
31
    private static final Logger logger = Logger.getLogger(EdaphobaseRankActivator.class);
32

    
33
    //database validation status (create, update, validate ...)
34
    static DbSchemaValidation dbSchemaValidation = DbSchemaValidation.VALIDATE;
35

    
36
    static final ICdmDataSource cdmDestination = CdmDestinations.localH2();
37
//    static final ICdmDataSource cdmDestination = CdmDestinations.cdm_local_edaphobase();
38
//    static final ICdmDataSource cdmDestination = CdmDestinations.cdm_production_edaphobase();
39

    
40
    //check - import
41
    static CHECK check = CHECK.IMPORT_WITHOUT_CHECK;
42

    
43
    private void doImport(ICdmDataSource cdmDestination){
44

    
45
        InputStreamReader source = getGermanRanks();
46
        RepresentationCsvImportConfigurator config= RepresentationCsvImportConfigurator.NewInstance(source, cdmDestination);
47
        config.setDbSchemaValidation(dbSchemaValidation);
48
        config.setLanguageUuid(Language.uuidGerman);
49

    
50
        CdmDefaultImport<RepresentationCsvImportConfigurator> myImport = new CdmDefaultImport<>();
51
        myImport.invoke(config);
52

    
53
        config.setLanguageUuid(Language.uuidLatin);
54
        config.setSource(getLatinRanks());
55
        myImport.invoke(config);
56

    
57
    }
58

    
59
    private InputStreamReader getGermanRanks() {
60
        String filename = "Rank_de.csv";
61
        String path = "terms" + CdmUtils.getFolderSeperator() + filename;
62
        try {
63
            InputStreamReader input = CdmUtils.getUtf8ResourceReader(path);
64
            return input;
65
        } catch (IOException e) {
66
            e.printStackTrace();
67
            System.exit(-1);
68
            return null;
69
        }
70
    }
71

    
72
    private InputStreamReader getLatinRanks() {
73
        String filename = "Rank_la.csv";
74
        String path = "terms" + CdmUtils.getFolderSeperator() + filename;
75
        try {
76
            InputStreamReader input = CdmUtils.getUtf8ResourceReader(path);
77
            return input;
78
        } catch (IOException e) {
79
            e.printStackTrace();
80
            System.exit(-1);
81
            return null;
82
        }
83
    }
84

    
85

    
86
    /**
87
     * @param args
88
     */
89
    public static void main(String[] args) {
90
        EdaphobaseRankActivator me = new EdaphobaseRankActivator();
91
        me.doImport(cdmDestination);
92
        System.exit(0);
93
    }
94
}
(2-2/2)