IDEMPIERE-1347 2Pack: ColumnElementHandler should ensure column exists in database when IsSyncDatabase=Y.
This commit is contained in:
parent
b2061ea8ef
commit
53731cbfff
|
@ -51,7 +51,6 @@ public class ColumnElementHandler extends AbstractElementHandler {
|
|||
|
||||
public void startElement(PIPOContext ctx, Element element)
|
||||
throws SAXException {
|
||||
int success = 0;
|
||||
String entitytype = getStringValue(element, "EntityType");
|
||||
if (isProcessElement(ctx.ctx, entitytype)) {
|
||||
if (isParentDefer(element, I_AD_Table.Table_Name)) {
|
||||
|
@ -78,8 +77,13 @@ public class ColumnElementHandler extends AbstractElementHandler {
|
|||
return;
|
||||
}
|
||||
|
||||
if (!mColumn.is_new() && !mColumn.is_Changed())
|
||||
if (!mColumn.is_new() && !mColumn.is_Changed()) {
|
||||
boolean syncDatabase = "Y".equalsIgnoreCase(getStringValue(element, "IsSyncDatabase"));
|
||||
if (syncDatabase) {
|
||||
syncColumn(ctx, mColumn, "Sync", false);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
X_AD_Package_Imp_Detail impDetail = createImportDetail(ctx, element.qName, X_AD_Column.Table_Name, X_AD_Column.Table_ID);
|
||||
String action = null;
|
||||
|
@ -156,6 +160,16 @@ public class ColumnElementHandler extends AbstractElementHandler {
|
|||
}
|
||||
|
||||
if (recreateColumn || syncDatabase) {
|
||||
syncColumn(ctx, mColumn, action, recreateColumn);
|
||||
}
|
||||
} else {
|
||||
element.skip = true;
|
||||
}
|
||||
}
|
||||
|
||||
private void syncColumn(PIPOContext ctx, MColumn mColumn, String action,
|
||||
boolean recreateColumn) throws SAXException {
|
||||
int success = 0;
|
||||
MTable table = new MTable(ctx.ctx, mColumn.getAD_Table_ID(), getTrxName(ctx));
|
||||
if (!table.isView() && !mColumn.isVirtualColumn()) {
|
||||
success = createColumn(ctx, table, mColumn, recreateColumn);
|
||||
|
@ -171,10 +185,6 @@ public class ColumnElementHandler extends AbstractElementHandler {
|
|||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
element.skip = true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if column exists in database and modify. If not create column.
|
||||
|
|
Loading…
Reference in New Issue