public static void addUndefined(SQLBase base) { Set<String> tableNames = base.getTableNames(); for (String tableName : tableNames) { SQLTable table = base.getTable(tableName); SQLField fieldPrimaryKey = table.getKey(); if (fieldPrimaryKey != null && fieldPrimaryKey.getType().getJavaType().getSuperclass() != null && fieldPrimaryKey.getType().getJavaType().getSuperclass() == Number.class) { String patch = "INSERT INTO \"" + tableName + "\"(\"" + fieldPrimaryKey.getName() + "\") VALUES (1)"; base.execute(patch); } } }
/** * Check si la table posséde au moins une ligne avec un ordre different null le cas cas échéant le * crée * * @param base */ public static void correct(SQLBase base) { Set<String> tableNames = base.getTableNames(); for (String tableName : tableNames) { if (base.getTable(tableName).contains("ORDRE")) { SQLSelect select = new SQLSelect(base); select.addSelect("ORDRE"); List l = base.getDataSource().execute(select.asString()); if (l == null || l.size() == 0) { SQLRowValues rowVals = new SQLRowValues(base.getTable(tableName)); rowVals.put("ORDRE", 0); try { rowVals.commit(); } catch (SQLException e) { e.printStackTrace(); } } } } // TODO Checker que toutes les tables sont dans FWK_UNDEFINED_ID }
public static void setOrder(SQLBase base) { Set<String> tableNames = base.getTableNames(); for (String tableName : tableNames) { SQLTable table = base.getTable(tableName); // SQLField fieldPrimaryKey = table.getKey(); SQLField field = table.getOrderField(); if (field != null) { base.execute( "ALTER TABLE \"" + tableName + "\" ALTER COLUMN \"" + field.getName() + "\" SET DEFAULT 0;"); base.execute( "ALTER TABLE \"" + tableName + "\" ALTER COLUMN \"" + field.getName() + "\" SET NOT NULL;"); } } }