Project

General

Profile

Revision 825e3afb

ID825e3afbf4b9aa8aae6a6884ca18925989d24dcf
Parent c8363cf5
Child 8b7f15a5

Added by Andreas Müller over 3 years ago

ref #6535 fix calls to version number from other places

View differences:

cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/metadata/CdmMetaDataPropertyName.java
15 15
import eu.etaxonomy.cdm.model.common.TermType;
16 16

  
17 17
public enum CdmMetaDataPropertyName implements IKeyTerm{
18
	DB_SCHEMA_VERSION("Schema Version","SCHEMA_VERSION"),
19
	TERMS_VERSION("Term Version","TERM_VERSION"),
20
	DB_CREATE_DATE("Created","CREATED"),
21
	DB_CREATE_NOTE("Create Note","CREATE_NOTE"),
22
	INSTANCE_NAME("CDM Instance Name","INST_NAME"),
23
	INSTANCE_ID("CDM Instance ID","INST_ID");
18
	DB_SCHEMA_VERSION("Schema Version","SCHEMA_VERSION", 0),
19
	TERMS_VERSION("Term Version","TERM_VERSION", 1),
20
	DB_CREATE_DATE("Created","CREATED", 2),
21
	DB_CREATE_NOTE("Create Note","CREATE_NOTE", 3),
22
	INSTANCE_NAME("CDM Instance Name","INST_NAME", 4),
23
	INSTANCE_ID("CDM Instance ID","INST_ID", 5);
24 24

  
25 25
	// **************** END ENUM **********************/
26 26

  
27 27
    private String label;
28 28
    private String key;
29
    private int oldPropertyId;
29 30

  
30 31
    @SuppressWarnings("unused")
31 32
    private static final Logger logger = Logger.getLogger(TermType.class);
32 33

  
33
    private CdmMetaDataPropertyName(String label, String key){
34
    private CdmMetaDataPropertyName(String label, String key, int oldPropertyId){
34 35
        this.label = label;
35 36
        this.key = key;
37
        this.oldPropertyId = oldPropertyId;
36 38
    }
37 39

  
38 40
//**************** METHODS ****************************/
......
44 46
    }
45 47

  
46 48
    /**
49
     * SQL query with propertyName still being an int attribute
50
     * @return
51
     */
52
    public String getSqlQueryOld(){
53
        return String.format(
54
                "SELECT value FROM CdmMetaData WHERE propertyname=%d",
55
                this.oldPropertyId);
56
    }
57

  
58

  
59

  
60
    /**
47 61
     * {@inheritDoc}
48 62
     */
49 63
    @Override
......
77 91
        return null;
78 92
    }
79 93

  
80
// *************************** DELEGATE **************************************/
81

  
82
 public static void main(String[] var){
83
     System.out.println(DB_SCHEMA_VERSION.getSqlQuery());
84
 }
85 94

  
86 95
}
cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/database/CdmDataSourceBase.java
155 155
		try {
156 156
			return (String)getSingleValue(CdmMetaDataPropertyName.DB_SCHEMA_VERSION.getSqlQuery());
157 157
		} catch (SQLException e) {
158
			throw new CdmSourceException(e.getMessage());
158
		    try {
159
	            return (String)getSingleValue(CdmMetaDataPropertyName.DB_SCHEMA_VERSION.getSqlQueryOld());
160
	        } catch (SQLException e1) {
161
	            throw new CdmSourceException(e1.getMessage());
162
	        }
159 163
		}
160 164
	}
161 165

  
......
280 284

  
281 285
    @Override
282 286
    public Map<CdmMetaDataPropertyName, String> getMetaDataMap() throws CdmSourceException {
283
		Map<CdmMetaDataPropertyName, String> cdmMetaDataMap = new HashMap<CdmMetaDataPropertyName, String>();
287
		Map<CdmMetaDataPropertyName, String> cdmMetaDataMap = new HashMap<>();
284 288

  
285 289
		for(CdmMetaDataPropertyName mdpn : CdmMetaDataPropertyName.values()) {
286 290
			String value = null;
287 291
			try {
288 292
				value = (String)getSingleValue(mdpn.getSqlQuery());
289
			} catch (SQLException e) {
290
				throw new CdmSourceException(this.toString(), e.getMessage());
293
			} catch (SQLException e1) {
294
			    try {
295
	                value = (String)getSingleValue(mdpn.getSqlQueryOld());
296
	            } catch (SQLException e) {
297
	                throw new CdmSourceException(this.toString(), e.getMessage());
298
	            }
291 299
			}
292 300
			if(value != null) {
293 301
				cdmMetaDataMap.put(mdpn, value);
cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/database/WrappedCdmDataSource.java
152 152
	public String getDbSchemaVersion() throws CdmSourceException {
153 153
		try {
154 154
			return (String)getSingleValue(CdmMetaDataPropertyName.DB_SCHEMA_VERSION.getSqlQuery());
155
		} catch (SQLException e) {
156
			throw new CdmSourceException(e.getMessage());
155
		} catch (SQLException e1) {
156
		    try {
157
	            return (String)getSingleValue(CdmMetaDataPropertyName.DB_SCHEMA_VERSION.getSqlQueryOld());
158
	        } catch (SQLException e) {
159
	            throw new CdmSourceException(e.getMessage());
160
	        }
157 161
		}
158 162
	}
159 163

  
cdmlib-remote/src/main/java/eu/etaxonomy/cdm/opt/config/DataSourceConfigurer.java
167 167
            }
168 168
            ResultSet tables = connection.getMetaData().getTables(connection.getCatalog(), null, metadataTableName, null);
169 169
            if(tables.first()){
170
                ResultSet resultSet = connection.createStatement().executeQuery(CdmMetaDataPropertyName.DB_SCHEMA_VERSION.getSqlQuery());
170
                ResultSet resultSet;
171
                try {
172
                    resultSet = connection.createStatement().executeQuery(CdmMetaDataPropertyName.DB_SCHEMA_VERSION.getSqlQuery());
173
                } catch (Exception e) {
174
                    try {
175
                        resultSet = connection.createStatement().executeQuery(CdmMetaDataPropertyName.DB_SCHEMA_VERSION.getSqlQueryOld());
176
                    } catch (Exception e1) {
177
                        throw e1;
178
                    }
179
                }
171 180
                String version = null;
172 181
                if(resultSet.next()){
173 182
                    version = resultSet.getString(1);
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/DatabaseServiceHibernateImpl.java
134 134
	public  String getDbSchemaVersion() throws CdmSourceException  {
135 135
		try {
136 136
			return (String)getSingleValue(CdmMetaDataPropertyName.DB_SCHEMA_VERSION.getSqlQuery());
137
		} catch (SQLException e) {
138
			throw new CdmSourceException(e.getMessage());
137
		} catch (SQLException e1) {
138
		    try {
139
	            return (String)getSingleValue(CdmMetaDataPropertyName.DB_SCHEMA_VERSION.getSqlQueryOld());
140
	        } catch (SQLException e) {
141
	            throw new CdmSourceException(e.getMessage());
142
	        }
139 143
		}
140 144
	}
141 145

  
......
193 197

  
194 198
	@Override
195 199
	public Map<CdmMetaDataPropertyName, String> getCdmMetadataMap() throws CdmSourceException {
196
		Map<CdmMetaDataPropertyName, String> cdmMetaDataMap = new HashMap<CdmMetaDataPropertyName, String>();
200
		Map<CdmMetaDataPropertyName, String> cdmMetaDataMap = new HashMap<>();
197 201

  
198 202
		for(CdmMetaDataPropertyName mdpn : CdmMetaDataPropertyName.values()){
199 203
			String value = null;
200 204
			try {
201 205
				value = (String)getSingleValue(mdpn.getSqlQuery());
202
			} catch (SQLException e) {
203
				throw new CdmSourceException(e.getMessage());
206
			} catch (SQLException e1) {
207
			    try {
208
	                value = (String)getSingleValue(mdpn.getSqlQueryOld());
209
	            } catch (SQLException e) {
210
	                throw new CdmSourceException(e.getMessage());
211
	            }
204 212
			}
205 213
			if(value != null) {
206 214
				cdmMetaDataMap.put(mdpn, value);

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)