Project

General

Profile

« Previous | Next » 

Revision 4a5c4812

Added by Andreas Müller over 2 years ago

add DianthusIdentifierActivator

View differences:

app-import/src/main/java/eu/etaxonomy/cdm/app/caryophyllales/DianthusIdentifierActivator.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.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.log4j.Logger;
18

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

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

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

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

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

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

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

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

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

  
56
    private void doImport(ICdmDataSource cdmDestination){
57

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

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

  
70
    private InputStreamReader getNepenthesIdentifier() {
71

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

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

Also available in: Unified diff