Project

General

Profile

Revision 842cca86

ID842cca8603e19dc661cbaee84ff1ff4ef773f49e
Parent 4cfefef3
Child cc9428e1

Added by Andreas Müller about 2 years ago

ref #7530 add activators for CaryoSppIdentifier import and WfoAccess import

View differences:

app-import/src/main/java/eu/etaxonomy/cdm/app/caryophyllales/CaryoSppIdentifierActivator.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.common.CdmUtils;
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.common.DefinedTerm;
27
import eu.etaxonomy.cdm.model.name.TaxonName;
28

  
29
/**
30
 * @author a.mueller
31
 * @since 18.10.2017
32
 *
33
 */
34
public class CaryoSppIdentifierActivator {
35

  
36
    @SuppressWarnings("unused")
37
    private static final Logger logger = Logger.getLogger(CaryoSppIdentifierActivator.class);
38

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

  
42
//    static final ICdmDataSource cdmDestination = CdmDestinations.cdm_local_caryo_spp2();
43
    static final ICdmDataSource cdmDestination = CdmDestinations.cdm_production_caryophyllales_spp();
44

  
45
    private static final UUID idTypeUuid = DefinedTerm.uuidWfoNameIdentifier;
46
//    private static final UUID idTypeUuid = DefinedTerm.uuidIpniNameIdentifier;
47

  
48
    //check - import
49
    static CHECK check = CHECK.IMPORT_WITHOUT_CHECK;
50

  
51
    private void doImport(ICdmDataSource cdmDestination){
52

  
53
        InputStreamReader source = getIdentifierStream();
54
        IdentifierImportConfigurator config= IdentifierImportConfigurator.NewInstance(source, cdmDestination);
55
        config.setDbSchemaValidation(dbSchemaValidation);
56
        config.setIdentifierTypeUuid(idTypeUuid);
57
        config.setCdmClass(TaxonName.class);
58
        config.setCheck(check);
59
        config.setIgnoreEmptyIdentifier(true);
60

  
61
        CdmDefaultImport<IdentifierImportConfigurator> myImport = new CdmDefaultImport<>();
62
        myImport.invoke(config);
63

  
64
    }
65

  
66
    private InputStreamReader getIdentifierStream() {
67
        String filename = "Abgleich-CDM-WFO-GattungenUndTypen.csv";
68

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

  
86
    /**
87
     * @param args
88
     */
89
    public static void main(String[] args) {
90
        CaryoSppIdentifierActivator me = new CaryoSppIdentifierActivator();
91
        me.doImport(cdmDestination);
92
        System.exit(0);
93
    }
94
}
app-import/src/main/java/eu/etaxonomy/cdm/app/caryophyllales/WfoAccessActivator.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.IOException;
12
import java.net.URI;
13
import java.util.UUID;
14

  
15
import org.apache.log4j.Logger;
16

  
17
import eu.etaxonomy.cdm.app.common.CdmDestinations;
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.common.ImportResult;
23
import eu.etaxonomy.cdm.io.wfo.in.WfoAccessImportConfigurator;
24
import eu.etaxonomy.cdm.model.name.NomenclaturalCode;
25
import eu.etaxonomy.cdm.model.reference.Reference;
26
import eu.etaxonomy.cdm.model.reference.ReferenceFactory;
27

  
28
/**
29
 * @author a.mueller
30
 * @since 18.10.2017
31
 *
32
 */
33
public class WfoAccessActivator {
34

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

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

  
41
//    static final ICdmDataSource cdmDestination = CdmDestinations.localH2();
42
//    static final ICdmDataSource cdmDestination = CdmDestinations.cdm_test_test1();
43
    static final ICdmDataSource cdmDestination = CdmDestinations.cdm_production_caryophyllales_spp();
44
//    static final ICdmDataSource cdmDestination = CdmDestinations.cdm_local_caryo_spp();
45

  
46
    static int transactionLineCount = 1000;
47
//    static boolean addAuthorsToReferences = true;
48
//    static boolean reportDuplicateIdentifier = true;
49

  
50
//    static final String classificationName = "Tropicos Plumbaginaceae";
51
//    static final UUID parentNodeUuid = UUID.fromString("46755269-5b06-4308-9871-c55850610769");
52

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

  
56
    private void doImport(ICdmDataSource cdmDestination){
57

  
58
        URI source = getDianthusUri();
59
        WfoAccessImportConfigurator config;
60
        try {
61
            config = WfoAccessImportConfigurator.NewInstance(source, cdmDestination);
62

  
63
            config.setDbSchemaValidation(dbSchemaValidation);
64
            config.setCheck(check);
65
            config.setNomenclaturalCode(NomenclaturalCode.ICNAFP);
66
//            config.setClassificationName(classificationName);
67
            config.setSourceReference(getSourceReference());
68
//            config.setParentNodeUuid(parentNodeUuid);
69
            config.setTransactionLineCount(transactionLineCount);
70
//            config.setAddAuthorsToReference(addAuthorsToReferences);
71
//            config.setReportDuplicateIdentifier(reportDuplicateIdentifier);
72

  
73
            CdmDefaultImport<WfoAccessImportConfigurator> myImport = new CdmDefaultImport<>();
74
            ImportResult result = myImport.invoke(config);
75
            System.out.println(result.createReport());
76
        } catch (IOException e) {
77
            System.out.println("URI not 'found': " + source);
78
        }
79
    }
80

  
81
    private URI getDianthusUri(){
82
//        String fileName = "TropicosNameImportTest-input.txt";
83
        String fileName = "3_Families_and_Dianthus_mancorr.txt";
84
//        String fileName = "TropicosOutput2CDM_Plumbaginaceae.txt";
85

  
86
        URI uri = URI.create("file:////BGBM-PESIHPC/Caryophyllales/" +  fileName);
87
        return uri;
88
    }
89

  
90
    private Reference getSourceReference(){
91
        Reference result = ReferenceFactory.newDatabase();
92
        result.setTitle("WFO-Import Amara-Cheno-Polyg-Dianthus June 2018");
93
        result.setUuid(UUID.fromString("aa343bb2-dc02-4809-a558-2db1bcd7212d"));
94
        return result;
95
    }
96

  
97

  
98
    /**
99
     * @param args
100
     */
101
    public static void main(String[] args) {
102
        WfoAccessActivator me = new WfoAccessActivator();
103
        me.doImport(cdmDestination);
104
        System.exit(0);
105
    }
106
}
app-import/src/main/java/eu/etaxonomy/cdm/app/common/CdmDestinations.java
425 425
        return makeDestination(dbType, cdmServer, cdmDB, -1, cdmUserName, null);
426 426
    }
427 427

  
428
    public static ICdmDataSource cdm_local_caryo_spp2(){
429
        DatabaseTypeEnum dbType = DatabaseTypeEnum.MySQL;
430
        String cdmServer = "127.0.0.1";
431
        String cdmDB = "cdm_caryo_spp2";
432
        String cdmUserName = "edit";
433
        return makeDestination(dbType, cdmServer, cdmDB, -1, cdmUserName, null);
434
    }
435

  
428 436
	public static ICdmDataSource cdm_globis_production(){
429 437
		DatabaseTypeEnum dbType = DatabaseTypeEnum.MySQL;
430 438
		String cdmServer = "160.45.63.171";

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)