import eu.etaxonomy.cdm.model.common.TermType;
public enum CdmMetaDataPropertyName implements IKeyTerm{
- DB_SCHEMA_VERSION("Schema Version","SCHEMA_VERSION"),
- TERMS_VERSION("Term Version","TERM_VERSION"),
- DB_CREATE_DATE("Created","CREATED"),
- DB_CREATE_NOTE("Create Note","CREATE_NOTE"),
- INSTANCE_NAME("CDM Instance Name","INST_NAME"),
- INSTANCE_ID("CDM Instance ID","INST_ID");
+ DB_SCHEMA_VERSION("Schema Version","SCHEMA_VERSION", 0),
+ TERMS_VERSION("Term Version","TERM_VERSION", 1),
+ DB_CREATE_DATE("Created","CREATED", 2),
+ DB_CREATE_NOTE("Create Note","CREATE_NOTE", 3),
+ INSTANCE_NAME("CDM Instance Name","INST_NAME", 4),
+ INSTANCE_ID("CDM Instance ID","INST_ID", 5);
// **************** END ENUM **********************/
private String label;
private String key;
+ private int oldPropertyId;
@SuppressWarnings("unused")
private static final Logger logger = Logger.getLogger(TermType.class);
- private CdmMetaDataPropertyName(String label, String key){
+ private CdmMetaDataPropertyName(String label, String key, int oldPropertyId){
this.label = label;
this.key = key;
+ this.oldPropertyId = oldPropertyId;
}
//**************** METHODS ****************************/
this.key);
}
+ /**
+ * SQL query with propertyName still being an int attribute
+ * @return
+ */
+ public String getSqlQueryOld(){
+ return String.format(
+ "SELECT value FROM CdmMetaData WHERE propertyname=%d",
+ this.oldPropertyId);
+ }
+
+
+
/**
* {@inheritDoc}
*/
return null;
}
-// *************************** DELEGATE **************************************/
-
- public static void main(String[] var){
- System.out.println(DB_SCHEMA_VERSION.getSqlQuery());
- }
}
\ No newline at end of file
try {\r
return (String)getSingleValue(CdmMetaDataPropertyName.DB_SCHEMA_VERSION.getSqlQuery());\r
} catch (SQLException e) {\r
- throw new CdmSourceException(e.getMessage());\r
+ try {\r
+ return (String)getSingleValue(CdmMetaDataPropertyName.DB_SCHEMA_VERSION.getSqlQueryOld());\r
+ } catch (SQLException e1) {\r
+ throw new CdmSourceException(e1.getMessage());\r
+ }\r
}\r
}\r
\r
\r
@Override\r
public Map<CdmMetaDataPropertyName, String> getMetaDataMap() throws CdmSourceException {\r
- Map<CdmMetaDataPropertyName, String> cdmMetaDataMap = new HashMap<CdmMetaDataPropertyName, String>();\r
+ Map<CdmMetaDataPropertyName, String> cdmMetaDataMap = new HashMap<>();\r
\r
for(CdmMetaDataPropertyName mdpn : CdmMetaDataPropertyName.values()) {\r
String value = null;\r
try {\r
value = (String)getSingleValue(mdpn.getSqlQuery());\r
- } catch (SQLException e) {\r
- throw new CdmSourceException(this.toString(), e.getMessage());\r
+ } catch (SQLException e1) {\r
+ try {\r
+ value = (String)getSingleValue(mdpn.getSqlQueryOld());\r
+ } catch (SQLException e) {\r
+ throw new CdmSourceException(this.toString(), e.getMessage());\r
+ }\r
}\r
if(value != null) {\r
cdmMetaDataMap.put(mdpn, value);\r
public String getDbSchemaVersion() throws CdmSourceException {
try {
return (String)getSingleValue(CdmMetaDataPropertyName.DB_SCHEMA_VERSION.getSqlQuery());
- } catch (SQLException e) {
- throw new CdmSourceException(e.getMessage());
+ } catch (SQLException e1) {
+ try {
+ return (String)getSingleValue(CdmMetaDataPropertyName.DB_SCHEMA_VERSION.getSqlQueryOld());
+ } catch (SQLException e) {
+ throw new CdmSourceException(e.getMessage());
+ }
}
}
}
ResultSet tables = connection.getMetaData().getTables(connection.getCatalog(), null, metadataTableName, null);
if(tables.first()){
- ResultSet resultSet = connection.createStatement().executeQuery(CdmMetaDataPropertyName.DB_SCHEMA_VERSION.getSqlQuery());
+ ResultSet resultSet;
+ try {
+ resultSet = connection.createStatement().executeQuery(CdmMetaDataPropertyName.DB_SCHEMA_VERSION.getSqlQuery());
+ } catch (Exception e) {
+ try {
+ resultSet = connection.createStatement().executeQuery(CdmMetaDataPropertyName.DB_SCHEMA_VERSION.getSqlQueryOld());
+ } catch (Exception e1) {
+ throw e1;
+ }
+ }
String version = null;
if(resultSet.next()){
version = resultSet.getString(1);
public String getDbSchemaVersion() throws CdmSourceException {
try {
return (String)getSingleValue(CdmMetaDataPropertyName.DB_SCHEMA_VERSION.getSqlQuery());
- } catch (SQLException e) {
- throw new CdmSourceException(e.getMessage());
+ } catch (SQLException e1) {
+ try {
+ return (String)getSingleValue(CdmMetaDataPropertyName.DB_SCHEMA_VERSION.getSqlQueryOld());
+ } catch (SQLException e) {
+ throw new CdmSourceException(e.getMessage());
+ }
}
}
@Override
public Map<CdmMetaDataPropertyName, String> getCdmMetadataMap() throws CdmSourceException {
- Map<CdmMetaDataPropertyName, String> cdmMetaDataMap = new HashMap<CdmMetaDataPropertyName, String>();
+ Map<CdmMetaDataPropertyName, String> cdmMetaDataMap = new HashMap<>();
for(CdmMetaDataPropertyName mdpn : CdmMetaDataPropertyName.values()){
String value = null;
try {
value = (String)getSingleValue(mdpn.getSqlQuery());
- } catch (SQLException e) {
- throw new CdmSourceException(e.getMessage());
+ } catch (SQLException e1) {
+ try {
+ value = (String)getSingleValue(mdpn.getSqlQueryOld());
+ } catch (SQLException e) {
+ throw new CdmSourceException(e.getMessage());
+ }
}
if(value != null) {
cdmMetaDataMap.put(mdpn, value);