Project

General

Profile

« Previous | Next » 

Revision 7cfab6d6

Added by Andreas Müller 4 months ago

rename package for VocabularyTreeCreator

View differences:

cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/database/update/v532_53x/VocabularyTreeCreator.java
1
/**
2
* Copyright (C) 2021 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.database.update.v532_53x;
10

  
11
import java.sql.SQLException;
12
import java.util.ArrayList;
13
import java.util.List;
14

  
15
import eu.etaxonomy.cdm.common.monitor.IProgressMonitor;
16
import eu.etaxonomy.cdm.database.ICdmDataSource;
17
import eu.etaxonomy.cdm.database.update.CaseType;
18
import eu.etaxonomy.cdm.database.update.ISchemaUpdaterStep;
19
import eu.etaxonomy.cdm.database.update.SchemaUpdateResult;
20
import eu.etaxonomy.cdm.database.update.SchemaUpdaterStepBase;
21

  
22
/**
23
 * #6794
24
 * @author a.mueller
25
 * @since 22.04.2021
26
 */
27
public class VocabularyTreeCreator extends SchemaUpdaterStepBase {
28

  
29
    protected VocabularyTreeCreator(List<ISchemaUpdaterStep> stepList, String stepName) {
30
        super(stepList, stepName);
31
    }
32
    @Override
33
    public List<ISchemaUpdaterStep> getInnerSteps() {
34
        List<ISchemaUpdaterStep> result = new ArrayList<>();
35

  
36
        return result;
37
    }
38

  
39
    @Override
40
    public void invoke(ICdmDataSource datasource, IProgressMonitor monitor, CaseType caseType,
41
            SchemaUpdateResult result) throws SQLException {
42

  
43
        //before this the tree (or graph) attribute needs to be added to TermVocabulary
44

  
45
        //Create tree
46
        //Set ordered flag
47
        //set flat flag depending on existing terms
48
        //getTermsOrdered
49
        //for each Term
50
             //addToTree
51
             //TODO decide on kindOf vs. partOf
52
        //do the same for hierarchical terms
53
        //add tree to vocabulary
54

  
55
        //TODO how to handle AUD data
56

  
57
//        boolean includeAudit = true;
58
//        int osbId = getMaxId1(datasource, "OriginalSourceBase", includeAudit, monitor, caseType, result);
59
//
60
//        String sql = "SELECT * "
61
//                + " FROM "+caseType.transformTo(tableName)+" t "
62
//                + " WHERE t."+this.citationsIdAttr+" IS NOT NULL OR t."+this.detailAttr+" IS NOT NULL ";
63
//
64
//        ResultSet rs = datasource.executeQuery(sql);
65
//        while(rs.next()){
66
//            int tnId = rs.getInt("id");
67
//            Integer citationId = nullSafeInt(rs, citationsIdAttr);
68
//            Integer createdById = nullSafeInt(rs, "createdBy_id");
69
//            String detail = rs.getString(detailAttr);
70
//
71
//            sql = "INSERT INTO @@OriginalSourceBase@@ (DTYPE, sourceType, uuid, id, citation_id, citationMicroReference, createdBy_id, created, "+sourcedAttr+")"
72
//               + " VALUES ('"+dtype+"', '"+sourceType+"','"+UUID.randomUUID()+"'," + osbId + ", " + citationId + "," + nullSafeParam(detail) + "," + createdById + ",'" + this.getNowString() + "',"+tnId+")";
73
//            datasource.executeUpdate(caseType.replaceTableNames(sql));
74
//
75
//            osbId++;
76
//        }
77
    }
78
}
cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/database/update/v533_53x/VocabularyTreeCreator.java
1
/**
2
* Copyright (C) 2021 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.database.update.v533_53x;
10

  
11
import java.sql.SQLException;
12
import java.util.ArrayList;
13
import java.util.List;
14

  
15
import eu.etaxonomy.cdm.common.monitor.IProgressMonitor;
16
import eu.etaxonomy.cdm.database.ICdmDataSource;
17
import eu.etaxonomy.cdm.database.update.CaseType;
18
import eu.etaxonomy.cdm.database.update.ISchemaUpdaterStep;
19
import eu.etaxonomy.cdm.database.update.SchemaUpdateResult;
20
import eu.etaxonomy.cdm.database.update.SchemaUpdaterStepBase;
21

  
22
/**
23
 * #6794
24
 * @author a.mueller
25
 * @since 22.04.2021
26
 */
27
public class VocabularyTreeCreator extends SchemaUpdaterStepBase {
28

  
29
    protected VocabularyTreeCreator(List<ISchemaUpdaterStep> stepList, String stepName) {
30
        super(stepList, stepName);
31
    }
32
    @Override
33
    public List<ISchemaUpdaterStep> getInnerSteps() {
34
        List<ISchemaUpdaterStep> result = new ArrayList<>();
35

  
36
        return result;
37
    }
38

  
39
    @Override
40
    public void invoke(ICdmDataSource datasource, IProgressMonitor monitor, CaseType caseType,
41
            SchemaUpdateResult result) throws SQLException {
42

  
43
        //before this the tree (or graph) attribute needs to be added to TermVocabulary
44

  
45
        //Create tree
46
        //Set ordered flag
47
        //set flat flag depending on existing terms
48
        //getTermsOrdered
49
        //for each Term
50
             //addToTree
51
             //TODO decide on kindOf vs. partOf
52
        //do the same for hierarchical terms
53
        //add tree to vocabulary
54

  
55
        //TODO how to handle AUD data
56

  
57
//        boolean includeAudit = true;
58
//        int osbId = getMaxId1(datasource, "OriginalSourceBase", includeAudit, monitor, caseType, result);
59
//
60
//        String sql = "SELECT * "
61
//                + " FROM "+caseType.transformTo(tableName)+" t "
62
//                + " WHERE t."+this.citationsIdAttr+" IS NOT NULL OR t."+this.detailAttr+" IS NOT NULL ";
63
//
64
//        ResultSet rs = datasource.executeQuery(sql);
65
//        while(rs.next()){
66
//            int tnId = rs.getInt("id");
67
//            Integer citationId = nullSafeInt(rs, citationsIdAttr);
68
//            Integer createdById = nullSafeInt(rs, "createdBy_id");
69
//            String detail = rs.getString(detailAttr);
70
//
71
//            sql = "INSERT INTO @@OriginalSourceBase@@ (DTYPE, sourceType, uuid, id, citation_id, citationMicroReference, createdBy_id, created, "+sourcedAttr+")"
72
//               + " VALUES ('"+dtype+"', '"+sourceType+"','"+UUID.randomUUID()+"'," + osbId + ", " + citationId + "," + nullSafeParam(detail) + "," + createdById + ",'" + this.getNowString() + "',"+tnId+")";
73
//            datasource.executeUpdate(caseType.replaceTableNames(sql));
74
//
75
//            osbId++;
76
//        }
77
    }
78
}

Also available in: Unified diff