Author: kmorin Date: 2009-11-06 19:00:58 +0100 (Fri, 06 Nov 2009) New Revision: 314 Modified: wikengo_core-wikitty/wikengo_core-wikitty-jdbc-impl/src/main/java/org/sharengo/wikitty/jdbc/WikittyExtensionStorageJDBC.java wikengo_core-wikitty/wikengo_core-wikitty-jdbc-impl/src/main/java/org/sharengo/wikitty/jdbc/WikittyJDBCUtil.java wikengo_core-wikitty/wikengo_core-wikitty-jdbc-impl/src/main/java/org/sharengo/wikitty/jdbc/WikittyStorageJDBC.java Log: add order in the extension fields Modified: wikengo_core-wikitty/wikengo_core-wikitty-jdbc-impl/src/main/java/org/sharengo/wikitty/jdbc/WikittyExtensionStorageJDBC.java =================================================================== --- wikengo_core-wikitty/wikengo_core-wikitty-jdbc-impl/src/main/java/org/sharengo/wikitty/jdbc/WikittyExtensionStorageJDBC.java 2009-11-04 16:04:53 UTC (rev 313) +++ wikengo_core-wikitty/wikengo_core-wikitty-jdbc-impl/src/main/java/org/sharengo/wikitty/jdbc/WikittyExtensionStorageJDBC.java 2009-11-06 18:00:58 UTC (rev 314) @@ -58,6 +58,10 @@ */ static protected String selectionQ = "jdbc.queries.select"; /** + * ordered selection with where clause query property name + */ + static protected String orderedWhereSelectionQ = "jdbc.queries.select.where.order"; + /** * basic selection with where clause query property name */ static protected String whereSelectionQ = "jdbc.queries.select.where"; @@ -164,10 +168,11 @@ batch.append(String.format(conf.getProperty(adminInsertQ), ext.getId(), ext.getName(), ext.getVersion(), ext.getRequires() != null ? "'" + ext.getRequires() + "'" : "null")); - for (String fieldName : ext.getFieldNames()) { - FieldType type = ext.getFieldType(fieldName); + for (int i = 0 ; i < ext.getFieldNames().size() ; i++) { + FieldType type = ext.getFieldType(ext.getFieldNames().get(i)); batch.append(String.format(conf.getProperty(dataInsertQ), - ext.getId(), fieldName.replace(" ", WORD_SEPARATOR), type.toDefinition(fieldName.replace(" ", WORD_SEPARATOR)))); + ext.getId(), ext.getFieldNames().get(i).replace(" ", WORD_SEPARATOR), + type.toDefinition(ext.getFieldNames().get(i).replace(" ", WORD_SEPARATOR)), i)); } } else { log.warn("The extension is found " + id); @@ -353,8 +358,8 @@ LinkedHashMap<String, FieldType> fieldTypes = new LinkedHashMap<String, FieldType>(); //get the data with the id "id" in the data table ResultSet dataResultSet = statement.executeQuery( - String.format(conf.getProperty(whereSelectionQ), "*", - dataTable, COL_ID, "'" + id + "'")); + String.format(conf.getProperty(orderedWhereSelectionQ), "*", + dataTable, COL_ID, "'" + id + "'", COL_FIELDRANK)); dataResultSet.beforeFirst(); while (dataResultSet.next()) { String fieldDef = dataResultSet.getString(COL_FIELDTYPE); Modified: wikengo_core-wikitty/wikengo_core-wikitty-jdbc-impl/src/main/java/org/sharengo/wikitty/jdbc/WikittyJDBCUtil.java =================================================================== --- wikengo_core-wikitty/wikengo_core-wikitty-jdbc-impl/src/main/java/org/sharengo/wikitty/jdbc/WikittyJDBCUtil.java 2009-11-04 16:04:53 UTC (rev 313) +++ wikengo_core-wikitty/wikengo_core-wikitty-jdbc-impl/src/main/java/org/sharengo/wikitty/jdbc/WikittyJDBCUtil.java 2009-11-06 18:00:58 UTC (rev 314) @@ -71,6 +71,10 @@ */ static final public String COL_FIELDTYPE = "fieldType"; /** + * field rank in the extension_data table + */ + static final public String COL_FIELDRANK = "fieldRank"; + /** * boolean value column in the wikitty_data table */ static final public String COL_BOOLEAN_VALUE = "booleanValue"; Modified: wikengo_core-wikitty/wikengo_core-wikitty-jdbc-impl/src/main/java/org/sharengo/wikitty/jdbc/WikittyStorageJDBC.java =================================================================== --- wikengo_core-wikitty/wikengo_core-wikitty-jdbc-impl/src/main/java/org/sharengo/wikitty/jdbc/WikittyStorageJDBC.java 2009-11-04 16:04:53 UTC (rev 313) +++ wikengo_core-wikitty/wikengo_core-wikitty-jdbc-impl/src/main/java/org/sharengo/wikitty/jdbc/WikittyStorageJDBC.java 2009-11-06 18:00:58 UTC (rev 314) @@ -258,7 +258,7 @@ COL_TEXT_VALUE, wikitty.getId(), ext.getName(), fieldName + "[" + i + "/" + list.size() + "]", - "'" + value + "'")); + "'" + value.replace("'", "''") + "'")); } break; case WIKITTY: @@ -280,7 +280,7 @@ COL_TEXT_VALUE, wikitty.getId(), ext.getName(), fieldName + "[" + i + "/" + list.size() + "]", - "'" + value + "'")); + "'" + value.replace("'", "''") + "'")); } break; } @@ -344,7 +344,7 @@ batch.append(String.format( conf.getProperty(dataInsertQ), COL_TEXT_VALUE, wikitty.getId(), ext.getName(), - fieldName, "'" + stringValue + "'")); + fieldName, "'" + stringValue.replace("'", "''") + "'")); } else { System.out.println("#####DEBUG####" + type.toDefinition(fieldName)); if (type.isNotNull()) { @@ -359,7 +359,7 @@ batch.append(String.format( conf.getProperty(dataInsertQ), COL_TEXT_VALUE, wikitty.getId(), ext.getName(), - fieldName, "'" + objectValue.toString() + "'")); + fieldName, "'" + objectValue.toString().replace("'", "''") + "'")); } else { System.out.println("#####DEBUG####" + type.toDefinition(fieldName)); if (type.isNotNull()) { @@ -374,7 +374,7 @@ batch.append(String.format( conf.getProperty(dataInsertQ), COL_TEXT_VALUE, wikitty.getId(), ext.getName(), - fieldName, "'" + objectValue.toString() + "'")); + fieldName, "'" + objectValue.toString().replace("'", "''") + "'")); } else { System.out.println("#####DEBUG####" + type.toDefinition(fieldName)); if (type.isNotNull()) { @@ -579,7 +579,7 @@ * @param id the id of the wikitty to restore * @param version the version of the wikitty to restore * @param extensionList the list of the extensions of the wikitty to restore - * @param resulSet the ResultSet as the result of the selection of the in the data table + * @param resultSet the ResultSet as the result of the selection of the in the data table * @param fqFieldName minimum field to restore * @return */
participants (1)
-
kmorin@users.nuiton.org