IDEMPIERE-720 UUID Generator doesn't work #resolve

This commit is contained in:
Carlos Ruiz 2013-03-21 13:26:49 -05:00
parent 5781427ac6
commit 17560dba8e
1 changed files with 9 additions and 1 deletions

View File

@ -23,6 +23,7 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.UUID;
import java.util.logging.Level;
import org.adempiere.exceptions.DBException;
import org.compiere.model.MColumn;
@ -48,6 +49,9 @@ public class UUIDGenerator extends SvrProcess {
private String tableName;
/** Logger */
private static CLogger log = CLogger.getCLogger(UUIDGenerator.class);
/**
* @see org.compiere.process.SvrProcess#prepare()
*/
@ -94,7 +98,7 @@ public class UUIDGenerator extends SvrProcess {
String columnName = PO.getUUIDColumnName(cTableName);
int AD_Column_ID = DB.getSQLValue(null, "SELECT AD_Column_ID FROM AD_Column Where AD_Table_ID = ? AND ColumnName = ?", AD_Table_ID, columnName);
if (AD_Column_ID <= 0) {
System.out.println("Adding UUID to " + cTableName);
if (log.isLoggable(Level.INFO)) log.info("Adding UUID to " + cTableName);
count++;
//create column
MColumn mColumn = new MColumn(getCtx(), 0, null);
@ -142,6 +146,10 @@ public class UUIDGenerator extends SvrProcess {
} else {
compositeKeys = Arrays.asList(table.getKeyColumns());
}
if ((compositeKeys == null || compositeKeys.size() == 0) && keyColumn == null) {
log.warning("Cannot update orphan table " + table.getTableName() + " (not ID neither parents)");
return;
}
if (compositeKeys == null) {
sql.append(keyColumn);
} else {