Project

General

Profile

Revision d5182728

IDd51827281118a38dc88c07c4d40647d6ce95326b
Parent 606365fa
Child a2a69c81

Added by Andreas Müller over 2 years ago

ref #6510 add Rank translation import activator

View differences:

app-import/src/main/java/eu/etaxonomy/cdm/app/edaphobase/EdaphobaseRankActivator.java
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

  
24
/**
25
 * @author a.mueller
26
 * @date 04.12.2015
27
 *
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.CREATE;
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
    static final InputStreamReader rankSource = getGermanRanks();
41

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

  
45
    private void doImport(InputStreamReader source, ICdmDataSource cdmDestination){
46

  
47

  
48
        RepresentationCsvImportConfigurator config= RepresentationCsvImportConfigurator.NewInstance(source, cdmDestination);
49
        config.setDbSchemaValidation(dbSchemaValidation);
50

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

  
54
    }
55

  
56

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

  
73
    }
74

  
75

  
76
    /**
77
     * @param args
78
     */
79
    public static void main(String[] args) {
80
        EdaphobaseRankActivator me = new EdaphobaseRankActivator();
81
        me.doImport(rankSource, cdmDestination);
82
        System.exit(0);
83
    }
84
}

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)