IDEMPIERE-1136 2Pack: Prevent unwanted overwrite of UUID key during pack in
This commit is contained in:
parent
1727029c25
commit
26fe7cf2bc
|
@ -56,7 +56,10 @@ public class AdElementHandler extends AbstractElementHandler {
|
|||
|
||||
M_Element mElement = findPO(ctx, element);
|
||||
if (mElement == null) {
|
||||
int id = findIdByColumn(ctx, X_AD_Element.Table_Name, X_AD_Element.COLUMNNAME_ColumnName, ColumnName, /*ignorecase=*/true);
|
||||
int id = 0;
|
||||
if (!hasUUIDKey(ctx, element)) {
|
||||
id = findIdByColumn(ctx, X_AD_Element.Table_Name, X_AD_Element.COLUMNNAME_ColumnName, ColumnName, /*ignorecase=*/true);
|
||||
}
|
||||
mElement = new M_Element(ctx.ctx, id, getTrxName(ctx));
|
||||
}
|
||||
List<String> excludes = defaultExcludeList(X_AD_Element.Table_Name);
|
||||
|
|
|
@ -64,7 +64,10 @@ public class AttachmentElementHandler extends AbstractElementHandler {
|
|||
return;
|
||||
}
|
||||
|
||||
int id = DB.getSQLValue(getTrxName(ctx), "SELECT AD_Attachment_ID FROM AD_Attachment WHERE Record_ID="+Record_ID+" AND AD_Table_ID="+AD_Table_ID);
|
||||
int id = 0;
|
||||
if (!hasUUIDKey(ctx, element)) {
|
||||
DB.getSQLValue(getTrxName(ctx), "SELECT AD_Attachment_ID FROM AD_Attachment WHERE Record_ID="+Record_ID+" AND AD_Table_ID="+AD_Table_ID);
|
||||
}
|
||||
mAttachment = new MAttachment(ctx.ctx, id > 0 ? id : 0, getTrxName(ctx));
|
||||
if (mAttachment.is_new()) {
|
||||
mAttachment.setAD_Table_ID(AD_Table_ID);
|
||||
|
|
|
@ -73,7 +73,10 @@ public class ColumnElementHandler extends AbstractElementHandler {
|
|||
filler.setTableReference("AD_Table_ID");
|
||||
tableid = mColumn.getAD_Table_ID();
|
||||
}
|
||||
int AD_Column_ID = findIdByColumnAndParentId(ctx, "AD_Column", "ColumnName", columnName, "AD_Table", tableid, /*ignorecase=*/true);
|
||||
int AD_Column_ID = 0;
|
||||
if (!hasUUIDKey(ctx, element)) {
|
||||
AD_Column_ID = findIdByColumnAndParentId(ctx, "AD_Column", "ColumnName", columnName, "AD_Table", tableid, /*ignorecase=*/true);
|
||||
}
|
||||
mColumn = new MColumn(ctx.ctx, AD_Column_ID > 0 ? AD_Column_ID : 0, getTrxName(ctx));
|
||||
if (mColumn.getAD_Column_ID() == 0 && isOfficialId(element, "AD_Column_ID")) {
|
||||
mColumn.setAD_Column_ID(getIntValue(element, "AD_Column_ID"));
|
||||
|
|
|
@ -48,7 +48,10 @@ public class DynValRuleElementHandler extends AbstractElementHandler {
|
|||
X_AD_Val_Rule mValRule = findPO(ctx, element);
|
||||
if (mValRule == null)
|
||||
{
|
||||
int id = findIdByColumn(ctx, "AD_Val_Rule", "Name", name);
|
||||
int id = 0;
|
||||
if (!hasUUIDKey(ctx, element)) {
|
||||
id = findIdByColumn(ctx, "AD_Val_Rule", "Name", name);
|
||||
}
|
||||
mValRule = new X_AD_Val_Rule(ctx.ctx, id > 0 ? id : 0, getTrxName(ctx));
|
||||
}
|
||||
if (mValRule.getAD_Val_Rule_ID() == 0 && isOfficialId(element, "AD_Val_Rule_ID"))
|
||||
|
|
|
@ -61,7 +61,10 @@ public class EntityTypeElementHandler extends AbstractElementHandler{
|
|||
X_AD_EntityType m_EntityType = findPO(ctx, element);
|
||||
|
||||
if (m_EntityType == null) {
|
||||
int id = findIdByColumn(ctx, X_AD_EntityType.Table_Name, X_AD_EntityType.COLUMNNAME_Name, name, /*ignorecase=*/true);
|
||||
int id = 0;
|
||||
if (!hasUUIDKey(ctx, element)) {
|
||||
id = findIdByColumn(ctx, X_AD_EntityType.Table_Name, X_AD_EntityType.COLUMNNAME_Name, name, /*ignorecase=*/true);
|
||||
}
|
||||
m_EntityType = new X_AD_EntityType(ctx.ctx, id, getTrxName(ctx));
|
||||
}
|
||||
|
||||
|
|
|
@ -100,11 +100,14 @@ public class FieldElementHandler extends AbstractElementHandler {
|
|||
MField mField = findPO(ctx, element);
|
||||
if (mField == null)
|
||||
{
|
||||
StringBuffer sqlB = new StringBuffer(
|
||||
"select AD_Field_ID from AD_Field where AD_Column_ID = ")
|
||||
.append(AD_Column_ID)
|
||||
.append(" and AD_Tab_ID = ?");
|
||||
int id = DB.getSQLValue(getTrxName(ctx), sqlB.toString(), tabid);
|
||||
int id = 0;
|
||||
if (!hasUUIDKey(ctx, element)) {
|
||||
StringBuffer sqlB = new StringBuffer(
|
||||
"select AD_Field_ID from AD_Field where AD_Column_ID = ")
|
||||
.append(AD_Column_ID)
|
||||
.append(" and AD_Tab_ID = ?");
|
||||
id = DB.getSQLValue(getTrxName(ctx), sqlB.toString(), tabid);
|
||||
}
|
||||
mField = new MField(ctx.ctx, id > 0 ? id : 0, getTrxName(ctx));
|
||||
if (mField.is_new()) {
|
||||
mField.setAD_Column_ID(AD_Column_ID);
|
||||
|
|
|
@ -58,7 +58,10 @@ public class FieldGroupElementHandler extends AbstractElementHandler {
|
|||
X_AD_FieldGroup fieldGroup = findPO(ctx, element);
|
||||
if (fieldGroup == null)
|
||||
{
|
||||
int id = findIdByColumn(ctx, X_AD_FieldGroup.Table_Name, X_AD_FieldGroup.COLUMNNAME_Name, name);
|
||||
int id = 0;
|
||||
if (!hasUUIDKey(ctx, element)) {
|
||||
id = findIdByColumn(ctx, X_AD_FieldGroup.Table_Name, X_AD_FieldGroup.COLUMNNAME_Name, name);
|
||||
}
|
||||
fieldGroup = new X_AD_FieldGroup(ctx.ctx, id > 0 ? id : 0, getTrxName(ctx));
|
||||
}
|
||||
PoFiller pf = new PoFiller(ctx, fieldGroup, element, this);
|
||||
|
|
|
@ -66,10 +66,12 @@ public class FormAccessElementHandler extends AbstractElementHandler {
|
|||
return;
|
||||
}
|
||||
|
||||
Query query = new Query(ctx.ctx, "AD_Form_Access", "AD_Form_ID = ? AND AD_Role_ID = ?", getTrxName(ctx));
|
||||
po = query.setParameters(new Object[]{AD_Form_ID, AD_Role_ID})
|
||||
.setClient_ID()
|
||||
.<MFormAccess>first();
|
||||
if (!hasUUIDKey(ctx, element)) {
|
||||
Query query = new Query(ctx.ctx, "AD_Form_Access", "AD_Form_ID = ? AND AD_Role_ID = ?", getTrxName(ctx));
|
||||
po = query.setParameters(new Object[]{AD_Form_ID, AD_Role_ID})
|
||||
.setClient_ID()
|
||||
.<MFormAccess>first();
|
||||
}
|
||||
if (po == null)
|
||||
{
|
||||
po = new MFormAccess(ctx.ctx, 0, getTrxName(ctx));
|
||||
|
|
|
@ -50,7 +50,10 @@ public class FormElementHandler extends AbstractElementHandler {
|
|||
MForm mForm = findPO(ctx, element);
|
||||
if (mForm == null) {
|
||||
String name = getStringValue(element, "Name");
|
||||
int id = findIdByName(ctx, "AD_Form", name);
|
||||
int id = 0;
|
||||
if (!hasUUIDKey(ctx, element)) {
|
||||
id = findIdByName(ctx, "AD_Form", name);
|
||||
}
|
||||
mForm = new MForm(ctx.ctx, id > 0 ? id : 0, getTrxName(ctx));
|
||||
}
|
||||
PoFiller filler = new PoFiller(ctx, mForm, element, this);
|
||||
|
|
|
@ -56,7 +56,10 @@ public class ImpFormatElementHandler extends AbstractElementHandler {
|
|||
|
||||
X_AD_ImpFormat mImpFormat = findPO(ctx, element);
|
||||
if (mImpFormat == null) {
|
||||
int id = findIdByName(ctx, "AD_ImpFormat", name);
|
||||
int id = 0;
|
||||
if (!hasUUIDKey(ctx, element)) {
|
||||
id = findIdByName(ctx, "AD_ImpFormat", name);
|
||||
}
|
||||
mImpFormat = new X_AD_ImpFormat(ctx.ctx, id > 0 ? id : 0,
|
||||
getTrxName(ctx));
|
||||
}
|
||||
|
|
|
@ -102,8 +102,11 @@ public class ImpFormatRowElementHandler extends AbstractElementHandler {
|
|||
}
|
||||
}
|
||||
|
||||
StringBuilder sqlB = new StringBuilder ("SELECT AD_ImpFormat_Row_ID FROM AD_ImpFormat_Row WHERE AD_Column_ID=? AND AD_ImpFormat_ID=?");
|
||||
int id = DB.getSQLValue(getTrxName(ctx),sqlB.toString(),columnId,impFormatId);
|
||||
int id = 0;
|
||||
if (!hasUUIDKey(ctx, element)) {
|
||||
StringBuilder sqlB = new StringBuilder ("SELECT AD_ImpFormat_Row_ID FROM AD_ImpFormat_Row WHERE AD_Column_ID=? AND AD_ImpFormat_ID=?");
|
||||
id = DB.getSQLValue(getTrxName(ctx),sqlB.toString(),columnId,impFormatId);
|
||||
}
|
||||
mImpFormatRow = new X_AD_ImpFormat_Row(ctx.ctx, id > 0 ? id : 0, getTrxName(ctx));
|
||||
|
||||
mImpFormatRow.setAD_Column_ID(columnId);
|
||||
|
|
|
@ -59,8 +59,11 @@ public class MenuElementHandler extends AbstractElementHandler {
|
|||
|
||||
X_AD_Menu mMenu = findPO(ctx, element);
|
||||
if (mMenu == null) {
|
||||
String menuName = getStringValue(element, "Name");
|
||||
int menuId = findIdByColumn(ctx, "AD_Menu", "Name", menuName);
|
||||
int menuId = 0;
|
||||
if (!hasUUIDKey(ctx, element)) {
|
||||
String menuName = getStringValue(element, "Name");
|
||||
menuId = findIdByColumn(ctx, "AD_Menu", "Name", menuName);
|
||||
}
|
||||
mMenu = new X_AD_Menu(ctx.ctx, menuId > 0 ? menuId : 0, getTrxName(ctx));
|
||||
}
|
||||
PoFiller filler = new PoFiller(ctx, mMenu, element, this);
|
||||
|
|
|
@ -46,9 +46,11 @@ public class MessageElementHandler extends AbstractElementHandler {
|
|||
if (isProcessElement(ctx.ctx, entitytype)) {
|
||||
MMessage mMessage = findPO(ctx, element);
|
||||
if (mMessage == null) {
|
||||
String value = getStringValue(element, "Value");
|
||||
int id = findIdByColumn(ctx, "AD_Message", "value", value);
|
||||
|
||||
int id = 0;
|
||||
if (!hasUUIDKey(ctx, element)) {
|
||||
String value = getStringValue(element, "Value");
|
||||
id = findIdByColumn(ctx, "AD_Message", "value", value);
|
||||
}
|
||||
mMessage = new MMessage(ctx.ctx, id > 0 ? id : 0, getTrxName(ctx));
|
||||
}
|
||||
PoFiller filler = new PoFiller(ctx, mMessage, element, this);
|
||||
|
|
|
@ -37,7 +37,10 @@ public class ModelValidatorElementHandler extends AbstractElementHandler{
|
|||
|
||||
X_AD_ModelValidator validator = findPO(ctx, element);
|
||||
if (validator == null) {
|
||||
int id = findIdByColumn(ctx, X_AD_ModelValidator.Table_Name, X_AD_ModelValidator.COLUMNNAME_Name, name, /*ignorecase=*/true);
|
||||
int id = 0;
|
||||
if (!hasUUIDKey(ctx, element)) {
|
||||
id = findIdByColumn(ctx, X_AD_ModelValidator.Table_Name, X_AD_ModelValidator.COLUMNNAME_Name, name, /*ignorecase=*/true);
|
||||
}
|
||||
validator = new X_AD_ModelValidator(ctx.ctx, id, getTrxName(ctx));
|
||||
}
|
||||
List<String> excludes = defaultExcludeList(X_AD_ModelValidator.Table_Name);
|
||||
|
|
|
@ -52,7 +52,10 @@ public class ModificationElementHandler extends AbstractElementHandler{
|
|||
|
||||
X_AD_Modification modification = findPO(ctx, element);
|
||||
if (modification == null) {
|
||||
int id = findIdByColumn(ctx, X_AD_Modification.Table_Name, X_AD_Modification.COLUMNNAME_Name, name, /*ignorecase=*/true);
|
||||
int id = 0;
|
||||
if (!hasUUIDKey(ctx, element)) {
|
||||
id = findIdByColumn(ctx, X_AD_Modification.Table_Name, X_AD_Modification.COLUMNNAME_Name, name, /*ignorecase=*/true);
|
||||
}
|
||||
modification = new X_AD_Modification(ctx.ctx, id, getTrxName(ctx));
|
||||
}
|
||||
List<String> excludes = defaultExcludeList(X_AD_Modification.Table_Name);
|
||||
|
|
|
@ -60,10 +60,12 @@ public class OrgRoleElementHandler extends AbstractElementHandler {
|
|||
Element orgElement = element.properties.get("AD_Org_ID");
|
||||
int orgId = ReferenceUtils.resolveReference(ctx.ctx, orgElement, getTrxName(ctx));
|
||||
|
||||
Query query = new Query(ctx.ctx, "AD_Role_OrgAccess", "AD_Role_ID=? and AD_Org_ID=?", getTrxName(ctx));
|
||||
po = query.setParameters(new Object[]{roleId, orgId})
|
||||
.setClient_ID()
|
||||
.<X_AD_Role_OrgAccess>first();
|
||||
if (!hasUUIDKey(ctx, element)) {
|
||||
Query query = new Query(ctx.ctx, "AD_Role_OrgAccess", "AD_Role_ID=? and AD_Org_ID=?", getTrxName(ctx));
|
||||
po = query.setParameters(new Object[]{roleId, orgId})
|
||||
.setClient_ID()
|
||||
.<X_AD_Role_OrgAccess>first();
|
||||
}
|
||||
|
||||
if (po == null) {
|
||||
po = new X_AD_Role_OrgAccess(ctx.ctx, 0, getTrxName(ctx));
|
||||
|
|
|
@ -55,8 +55,11 @@ public class PrintFormatElementHandler extends AbstractElementHandler {
|
|||
|
||||
X_AD_PrintFormat mPrintFormat = findPO(ctx, element);
|
||||
if (mPrintFormat == null) {
|
||||
String name = getStringValue(element, "Name");
|
||||
int id = findIdByColumn(ctx, "AD_PrintFormat", "Name", name);
|
||||
int id = 0;
|
||||
if (!hasUUIDKey(ctx, element)) {
|
||||
String name = getStringValue(element, "Name");
|
||||
id = findIdByColumn(ctx, "AD_PrintFormat", "Name", name);
|
||||
}
|
||||
mPrintFormat = new X_AD_PrintFormat(ctx.ctx, id > 0 ? id : 0, getTrxName(ctx));
|
||||
}
|
||||
PoFiller filler = new PoFiller(ctx, mPrintFormat, element, this);
|
||||
|
|
|
@ -64,8 +64,11 @@ public class PrintFormatItemElementHandler extends AbstractElementHandler {
|
|||
return;
|
||||
}
|
||||
|
||||
String name = getStringValue(element, "Name");
|
||||
int id = findIdByNameAndParentId(ctx, "AD_PrintFormatItem", name, "AD_PrintFormat", parentId);
|
||||
int id = 0;
|
||||
if (!hasUUIDKey(ctx, element)) {
|
||||
String name = getStringValue(element, "Name");
|
||||
id = findIdByNameAndParentId(ctx, "AD_PrintFormatItem", name, "AD_PrintFormat", parentId);
|
||||
}
|
||||
mPrintFormatItem = new X_AD_PrintFormatItem(ctx.ctx, id > 0 ? id : 0, getTrxName(ctx));
|
||||
mPrintFormatItem.setAD_PrintFormat_ID(parentId);
|
||||
excludes.add(I_AD_PrintFormatItem.COLUMNNAME_AD_PrintFormat_ID);
|
||||
|
|
|
@ -46,8 +46,10 @@ public class PrintPaperElementHandler extends AbstractElementHandler {
|
|||
|
||||
if (printPaper == null) {
|
||||
String printPaperName = getStringValue(element, "Name", excludes);
|
||||
int id = findIdByName(ctx, "AD_PrintPaper", printPaperName);
|
||||
|
||||
int id = 0;
|
||||
if (!hasUUIDKey(ctx, element)) {
|
||||
id = findIdByName(ctx, "AD_PrintPaper", printPaperName);
|
||||
}
|
||||
printPaper = new X_AD_PrintPaper(ctx.ctx, id > 0 ? id : 0, getTrxName(ctx));
|
||||
printPaper.setName(printPaperName);
|
||||
}
|
||||
|
|
|
@ -66,9 +66,11 @@ public class ProcessAccessElementHandler extends AbstractElementHandler {
|
|||
element.unresolved = "AD_Process_ID " + (processElement.contents != null ? processElement.contents.toString() : "");
|
||||
return;
|
||||
}
|
||||
|
||||
Query query = new Query(ctx.ctx, "AD_Process_Access", "AD_Role_ID=? and AD_Process_ID=?", getTrxName(ctx));
|
||||
po = query.setParameters(new Object[]{roleid, processid}).first();
|
||||
|
||||
if (!hasUUIDKey(ctx, element)) {
|
||||
Query query = new Query(ctx.ctx, "AD_Process_Access", "AD_Role_ID=? and AD_Process_ID=?", getTrxName(ctx));
|
||||
po = query.setParameters(new Object[]{roleid, processid}).first();
|
||||
}
|
||||
if (po == null)
|
||||
{
|
||||
po = new X_AD_Process_Access(ctx.ctx, 0, getTrxName(ctx));
|
||||
|
|
|
@ -62,7 +62,10 @@ public class ProcessElementHandler extends AbstractElementHandler {
|
|||
String value = getStringValue(element, "Value");
|
||||
|
||||
// Get New process.
|
||||
int id = findIdByColumn(ctx, "AD_Process", "Value", value);
|
||||
int id = 0;
|
||||
if (!hasUUIDKey(ctx, element)) {
|
||||
id = findIdByColumn(ctx, "AD_Process", "Value", value);
|
||||
}
|
||||
mProcess = new X_AD_Process(ctx.ctx, id > 0 ? id : 0, getTrxName(ctx));
|
||||
}
|
||||
|
||||
|
|
|
@ -69,7 +69,9 @@ public class ProcessParaElementHandler extends AbstractElementHandler {
|
|||
return;
|
||||
}
|
||||
|
||||
id = findIdByColumnAndParentId(ctx, "AD_Process_Para", "ColumnName", name, "AD_Process", masterId);
|
||||
if (!hasUUIDKey(ctx, element)) {
|
||||
id = findIdByColumnAndParentId(ctx, "AD_Process_Para", "ColumnName", name, "AD_Process", masterId);
|
||||
}
|
||||
mProcessPara = new X_AD_Process_Para(ctx.ctx, id > 0 ? id : 0, getTrxName(ctx));
|
||||
mProcessPara.setAD_Process_ID(masterId);
|
||||
excludes.add(I_AD_Process_Para.COLUMNNAME_AD_Process_ID);
|
||||
|
|
|
@ -60,7 +60,10 @@ public class ReferenceElementHandler extends AbstractElementHandler {
|
|||
|
||||
X_AD_Reference mReference = findPO(ctx, element);
|
||||
if (mReference == null) {
|
||||
int id = findIdByName(ctx, "AD_Reference", name);
|
||||
int id = 0;
|
||||
if (!hasUUIDKey(ctx, element)) {
|
||||
id = findIdByName(ctx, "AD_Reference", name);
|
||||
}
|
||||
mReference = new X_AD_Reference(ctx.ctx, id > 0 ? id : 0, getTrxName(ctx));
|
||||
}
|
||||
List<String> excludes = defaultExcludeList(X_AD_Reference.Table_Name);
|
||||
|
|
|
@ -59,7 +59,10 @@ public class ReferenceListElementHandler extends AbstractElementHandler {
|
|||
AD_Reference_ID = ReferenceUtils.resolveReference(ctx.ctx, referenceElement, getTrxName(ctx));
|
||||
}
|
||||
|
||||
int AD_Ref_List_ID = findIdByColumnAndParentId(ctx, "AD_Ref_List", "Value", value, "AD_Reference", AD_Reference_ID);
|
||||
int AD_Ref_List_ID = 0;
|
||||
if (!hasUUIDKey(ctx, element)) {
|
||||
AD_Ref_List_ID = findIdByColumnAndParentId(ctx, "AD_Ref_List", "Value", value, "AD_Reference", AD_Reference_ID);
|
||||
}
|
||||
mRefList = new X_AD_Ref_List(ctx.ctx, AD_Ref_List_ID, getTrxName(ctx));
|
||||
}
|
||||
|
||||
|
|
|
@ -67,22 +67,26 @@ public class ReferenceTableElementHandler extends AbstractElementHandler {
|
|||
if (AD_Reference_ID <= 0 && isOfficialId(element, "AD_Reference_ID"))
|
||||
AD_Reference_ID = getIntValue(element, "AD_Reference_ID");
|
||||
|
||||
String sql = "SELECT * FROM AD_Ref_Table WHERE AD_Reference_ID = ?";
|
||||
PreparedStatement pstmt = null;
|
||||
ResultSet rs = null;
|
||||
try {
|
||||
pstmt = DB.prepareStatement(sql, getTrxName(ctx));
|
||||
pstmt.setInt(1, AD_Reference_ID);
|
||||
rs = pstmt.executeQuery();
|
||||
if (rs.next()) {
|
||||
refTable = new X_AD_Ref_Table(ctx.ctx, rs, getTrxName(ctx));
|
||||
} else {
|
||||
refTable = new X_AD_Ref_Table(ctx.ctx, 0, getTrxName(ctx));
|
||||
if (!hasUUIDKey(ctx, element)) {
|
||||
String sql = "SELECT * FROM AD_Ref_Table WHERE AD_Reference_ID = ?";
|
||||
PreparedStatement pstmt = null;
|
||||
ResultSet rs = null;
|
||||
try {
|
||||
pstmt = DB.prepareStatement(sql, getTrxName(ctx));
|
||||
pstmt.setInt(1, AD_Reference_ID);
|
||||
rs = pstmt.executeQuery();
|
||||
if (rs.next()) {
|
||||
refTable = new X_AD_Ref_Table(ctx.ctx, rs, getTrxName(ctx));
|
||||
} else {
|
||||
refTable = new X_AD_Ref_Table(ctx.ctx, 0, getTrxName(ctx));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new DatabaseAccessException(e.getLocalizedMessage(), e);
|
||||
} finally {
|
||||
DB.close(rs, pstmt);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new DatabaseAccessException(e.getLocalizedMessage(), e);
|
||||
} finally {
|
||||
DB.close(rs, pstmt);
|
||||
} else {
|
||||
refTable = new X_AD_Ref_Table(ctx.ctx, 0, getTrxName(ctx));
|
||||
}
|
||||
}
|
||||
String action = refTable.is_new() ? "New" : "Update";
|
||||
|
|
|
@ -90,7 +90,10 @@ public class ReportViewColElementHandler extends AbstractElementHandler {
|
|||
sql.append(" AND FunctionColumn = ?");
|
||||
sql.append(" AND AD_ReportView_ID = ?");
|
||||
|
||||
int id = DB.getSQLValue(getTrxName(ctx), sql.toString(), functionColumn, AD_ReportView_ID);
|
||||
int id = 0;
|
||||
if (!hasUUIDKey(ctx, element)) {
|
||||
id = DB.getSQLValue(getTrxName(ctx), sql.toString(), functionColumn, AD_ReportView_ID);
|
||||
}
|
||||
mReportviewCol = new X_AD_ReportView_Col(ctx.ctx, id > 0 ? id : 0, getTrxName(ctx));
|
||||
mReportviewCol.setAD_ReportView_ID(AD_ReportView_ID);
|
||||
if (AD_Column_ID > 0) {
|
||||
|
|
|
@ -57,8 +57,11 @@ public class ReportViewElementHandler extends AbstractElementHandler {
|
|||
|
||||
X_AD_ReportView mReportview = findPO(ctx, element);
|
||||
if (mReportview == null) {
|
||||
String name = getStringValue(element, "Name");
|
||||
int id = findIdByName(ctx, "AD_ReportView", name);
|
||||
int id = 0;
|
||||
if (!hasUUIDKey(ctx, element)) {
|
||||
String name = getStringValue(element, "Name");
|
||||
id = findIdByName(ctx, "AD_ReportView", name);
|
||||
}
|
||||
mReportview = new X_AD_ReportView(ctx.ctx, id, getTrxName(ctx));
|
||||
}
|
||||
PoFiller filler = new PoFiller(ctx, mReportview, element, this);
|
||||
|
|
|
@ -69,7 +69,10 @@ public class RoleElementHandler extends AbstractElementHandler {
|
|||
MRole mRole = findPO(ctx, element);
|
||||
if (mRole == null) {
|
||||
String name = getStringValue(element, "Name", excludes);
|
||||
int id = findIdByName(ctx, "AD_Role", name);
|
||||
int id = 0;
|
||||
if (!hasUUIDKey(ctx, element)) {
|
||||
id = findIdByName(ctx, "AD_Role", name);
|
||||
}
|
||||
mRole = new MRole(ctx.ctx, id > 0 ? id : 0, getTrxName(ctx));
|
||||
mRole.setName(name);
|
||||
}
|
||||
|
|
|
@ -85,11 +85,14 @@ public class TabElementHandler extends AbstractElementHandler {
|
|||
return;
|
||||
}
|
||||
|
||||
String sql = "SELECT AD_Tab_ID FROM AD_Tab where AD_Window_ID = ? "
|
||||
+ " AND Name = ?"
|
||||
+ " AND AD_Table_ID = ?";
|
||||
|
||||
int id = DB.getSQLValue(getTrxName(ctx), sql, windowId, name, tableId);
|
||||
int id = 0;
|
||||
if (!hasUUIDKey(ctx, element)) {
|
||||
String sql = "SELECT AD_Tab_ID FROM AD_Tab where AD_Window_ID = ? "
|
||||
+ " AND Name = ?"
|
||||
+ " AND AD_Table_ID = ?";
|
||||
|
||||
id = DB.getSQLValue(getTrxName(ctx), sql, windowId, name, tableId);
|
||||
}
|
||||
mTab = new MTab(ctx.ctx, id > 0 ? id : 0, getTrxName(ctx));
|
||||
mTab.setAD_Table_ID(tableId);
|
||||
mTab.setName(name);
|
||||
|
|
|
@ -58,16 +58,18 @@ public class TableElementHandler extends AbstractElementHandler {
|
|||
|
||||
MTable mTable = findPO(ctx, element);
|
||||
if (mTable == null) {
|
||||
int id = 0;
|
||||
String tableName = getStringValue(element, "TableName", excludes);
|
||||
|
||||
int id = packIn.getTableId(tableName);
|
||||
if (id <= 0) {
|
||||
id = findIdByColumn(ctx, "AD_Table", "TableName", tableName);
|
||||
if (id > 0)
|
||||
packIn.addTable(tableName, id);
|
||||
}
|
||||
if (id > 0 && isTableProcess(ctx, id)) {
|
||||
return;
|
||||
if (!hasUUIDKey(ctx, element)) {
|
||||
id = packIn.getTableId(tableName);
|
||||
if (id <= 0) {
|
||||
id = findIdByColumn(ctx, "AD_Table", "TableName", tableName);
|
||||
if (id > 0)
|
||||
packIn.addTable(tableName, id);
|
||||
}
|
||||
if (id > 0 && isTableProcess(ctx, id)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
mTable = new MTable(ctx.ctx, id > 0 ? id : 0, getTrxName(ctx));
|
||||
|
|
|
@ -67,8 +67,10 @@ public class TaskAccessElementHandler extends AbstractElementHandler {
|
|||
return;
|
||||
}
|
||||
|
||||
Query query = new Query(ctx.ctx, "AD_Task_Access", "AD_Role_ID=? and AD_Task_ID=?", getTrxName(ctx));
|
||||
po = query.setParameters(new Object[]{roleid, taskid}).first();
|
||||
if (!hasUUIDKey(ctx, element)) {
|
||||
Query query = new Query(ctx.ctx, "AD_Task_Access", "AD_Role_ID=? and AD_Task_ID=?", getTrxName(ctx));
|
||||
po = query.setParameters(new Object[]{roleid, taskid}).first();
|
||||
}
|
||||
if (po == null){
|
||||
po = new X_AD_Task_Access(ctx.ctx, 0, getTrxName(ctx));
|
||||
po.setAD_Role_ID(roleid);
|
||||
|
|
|
@ -50,8 +50,11 @@ public class TaskElementHandler extends AbstractElementHandler {
|
|||
|
||||
MTask mTask = findPO(ctx, element);
|
||||
if (mTask == null) {
|
||||
String name = getStringValue(element, "Name");
|
||||
int id = findIdByName(ctx, "AD_Task", name);
|
||||
int id = 0;
|
||||
if (!hasUUIDKey(ctx, element)) {
|
||||
String name = getStringValue(element, "Name");
|
||||
id = findIdByName(ctx, "AD_Task", name);
|
||||
}
|
||||
mTask = new MTask(ctx.ctx, id > 0 ? id : 0, getTrxName(ctx));
|
||||
}
|
||||
|
||||
|
|
|
@ -73,8 +73,10 @@ public class UserRoleElementHandler extends AbstractElementHandler {
|
|||
Element orgElement = element.properties.get(I_AD_User_Roles.COLUMNNAME_AD_Org_ID);
|
||||
orgid = ReferenceUtils.resolveReference(ctx.ctx, orgElement, getTrxName(ctx));
|
||||
|
||||
Query query = new Query(ctx.ctx, "AD_User_Roles", "AD_User_ID = ? AND AD_Role_ID = ? AND AD_Org_ID = ?", getTrxName(ctx));
|
||||
po = query.setParameters(new Object[]{userid, roleid, orgid}).first();
|
||||
if (!hasUUIDKey(ctx, element)) {
|
||||
Query query = new Query(ctx.ctx, "AD_User_Roles", "AD_User_ID = ? AND AD_Role_ID = ? AND AD_Org_ID = ?", getTrxName(ctx));
|
||||
po = query.setParameters(new Object[]{userid, roleid, orgid}).first();
|
||||
}
|
||||
if (po == null) {
|
||||
po = new X_AD_User_Roles(ctx.ctx, 0, getTrxName(ctx));
|
||||
po.setAD_Org_ID(orgid);
|
||||
|
|
|
@ -66,8 +66,10 @@ public class WindowAccessElementHandler extends AbstractElementHandler {
|
|||
return;
|
||||
}
|
||||
|
||||
Query query = new Query(ctx.ctx, "AD_Window_Access", "AD_Role_ID=? and AD_Window_ID=?", getTrxName(ctx));
|
||||
po = query.setParameters(new Object[]{roleid, windowid}).first();
|
||||
if (!hasUUIDKey(ctx, element)) {
|
||||
Query query = new Query(ctx.ctx, "AD_Window_Access", "AD_Role_ID=? and AD_Window_ID=?", getTrxName(ctx));
|
||||
po = query.setParameters(new Object[]{roleid, windowid}).first();
|
||||
}
|
||||
if (po == null) {
|
||||
po = new X_AD_Window_Access(ctx.ctx, 0, getTrxName(ctx));
|
||||
po.setAD_Role_ID(roleid);
|
||||
|
|
|
@ -63,12 +63,14 @@ public class WindowElementHandler extends AbstractElementHandler {
|
|||
if (isProcessElement(ctx.ctx, entitytype)) {
|
||||
MWindow mWindow = findPO(ctx, element);
|
||||
if (mWindow == null) {
|
||||
int id = 0;
|
||||
String name = getStringValue(element, "Name", excludes);
|
||||
int id = findIdByName(ctx, "AD_Window", name);
|
||||
if (id > 0 && windows.contains(id)) {
|
||||
return;
|
||||
if (!hasUUIDKey(ctx, element)) {
|
||||
id = findIdByName(ctx, "AD_Window", name);
|
||||
if (id > 0 && windows.contains(id)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
mWindow = new MWindow(ctx.ctx, id > 0 ? id : 0, getTrxName(ctx));
|
||||
mWindow.setName(name);
|
||||
} else {
|
||||
|
|
|
@ -67,8 +67,10 @@ public class WorkflowAccessElementHandler extends AbstractElementHandler {
|
|||
element.unresolved = "AD_Workflow_ID";
|
||||
}
|
||||
|
||||
Query query = new Query(ctx.ctx, "AD_Workflow_Access", "AD_Role_ID=? and AD_Workflow_ID=?", getTrxName(ctx));
|
||||
po = query.setParameters(new Object[]{roleid, workflowid}).first();
|
||||
if (!hasUUIDKey(ctx, element)) {
|
||||
Query query = new Query(ctx.ctx, "AD_Workflow_Access", "AD_Role_ID=? and AD_Workflow_ID=?", getTrxName(ctx));
|
||||
po = query.setParameters(new Object[]{roleid, workflowid}).first();
|
||||
}
|
||||
if (po == null) {
|
||||
po = new MWorkflowAccess(ctx.ctx, 0, getTrxName(ctx));
|
||||
po.setAD_Role_ID(roleid);
|
||||
|
|
|
@ -63,11 +63,14 @@ public class WorkflowElementHandler extends AbstractElementHandler {
|
|||
|
||||
MWorkflow mWorkflow = findPO(ctx, element);
|
||||
if (mWorkflow == null) {
|
||||
int id = 0;
|
||||
String workflowValue = getStringValue(element, "Value", excludes);
|
||||
int id = findIdByColumn(ctx, "AD_Workflow", "Value", workflowValue);
|
||||
if (id > 0 && workflows.contains(id)) {
|
||||
element.skip = true;
|
||||
return;
|
||||
if (!hasUUIDKey(ctx, element)) {
|
||||
id = findIdByColumn(ctx, "AD_Workflow", "Value", workflowValue);
|
||||
if (id > 0 && workflows.contains(id)) {
|
||||
element.skip = true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
mWorkflow = new MWorkflow(ctx.ctx, id > 0 ? id : 0, getTrxName(ctx));
|
||||
|
|
|
@ -74,10 +74,12 @@ public class WorkflowNodeElementHandler extends AbstractElementHandler {
|
|||
}
|
||||
|
||||
String workflowNodeValue = getStringValue(element, "Value", excludes);
|
||||
StringBuilder sqlB = new StringBuilder(
|
||||
int id = 0;
|
||||
if (!hasUUIDKey(ctx, element)) {
|
||||
StringBuilder sqlB = new StringBuilder(
|
||||
"SELECT AD_WF_Node_ID FROM AD_WF_Node WHERE AD_Workflow_ID=? and Value =?");
|
||||
|
||||
int id = DB.getSQLValue(getTrxName(ctx), sqlB.toString(), workflowId, workflowNodeValue);
|
||||
id = DB.getSQLValue(getTrxName(ctx), sqlB.toString(), workflowId, workflowNodeValue);
|
||||
}
|
||||
mWFNode = new MWFNode(ctx.ctx, id > 0 ? id : 0, getTrxName(ctx));
|
||||
mWFNode.setValue(workflowNodeValue);
|
||||
mWFNode.setAD_Workflow_ID(workflowId);
|
||||
|
|
|
@ -78,9 +78,12 @@ public class WorkflowNodeNextConditionElementHandler extends
|
|||
return;
|
||||
}
|
||||
|
||||
int seqNo = getIntValue(element, "SeqNo");
|
||||
String sql = "SELECT AD_WF_NextCondition_ID FROM AD_WF_NextCondition WHERE AD_WF_NodeNext_ID =? AND SeqNo=?";
|
||||
int id = DB.getSQLValue(getTrxName(ctx), sql, new Object[] {wfNodeNextId, seqNo});
|
||||
int id = 0;
|
||||
if (!hasUUIDKey(ctx, element)) {
|
||||
int seqNo = getIntValue(element, "SeqNo");
|
||||
String sql = "SELECT AD_WF_NextCondition_ID FROM AD_WF_NextCondition WHERE AD_WF_NodeNext_ID =? AND SeqNo=?";
|
||||
id = DB.getSQLValue(getTrxName(ctx), sql, new Object[] {wfNodeNextId, seqNo});
|
||||
}
|
||||
|
||||
mWFNodeNextCondition = new MWFNextCondition(ctx.ctx, id > 0 ? id : 0, getTrxName(ctx));
|
||||
mWFNodeNextCondition.setAD_WF_NodeNext_ID(wfNodeNextId);
|
||||
|
|
|
@ -94,7 +94,10 @@ public class WorkflowNodeNextElementHandler extends AbstractElementHandler {
|
|||
return;
|
||||
}
|
||||
|
||||
int AD_WF_NodeNext_ID = DB.getSQLValue(getTrxName(ctx), "SELECT AD_WF_NodeNext_ID FROM AD_WF_NodeNext WHERE AD_WF_Node_ID=? and AD_WF_NEXT_ID =?", wfNodeId, AD_WF_Next_ID);
|
||||
int AD_WF_NodeNext_ID = 0;
|
||||
if (!hasUUIDKey(ctx, element)) {
|
||||
AD_WF_NodeNext_ID = DB.getSQLValue(getTrxName(ctx), "SELECT AD_WF_NodeNext_ID FROM AD_WF_NodeNext WHERE AD_WF_Node_ID=? and AD_WF_NEXT_ID =?", wfNodeId, AD_WF_Next_ID);
|
||||
}
|
||||
|
||||
mWFNodeNext = new MWFNodeNext(ctx.ctx, AD_WF_NodeNext_ID, getTrxName(ctx));
|
||||
mWFNodeNext.setAD_WF_Node_ID(wfNodeId);
|
||||
|
|
|
@ -574,7 +574,25 @@ public abstract class AbstractElementHandler implements ElementHandler {
|
|||
}
|
||||
return po;
|
||||
}
|
||||
|
||||
protected boolean hasUUIDKey(PIPOContext ctx, Element element) {
|
||||
String tableName = element.getElementValue();
|
||||
String uuidColumn = PO.getUUIDColumnName(tableName);
|
||||
String uuid = element.properties.get(uuidColumn).contents.toString();
|
||||
return (uuid != null && uuid.trim().length() == 36);
|
||||
}
|
||||
|
||||
protected String getUUIDKey(PIPOContext ctx, Element element) {
|
||||
String tableName = element.getElementValue();
|
||||
String uuidColumn = PO.getUUIDColumnName(tableName);
|
||||
if (element.properties.containsKey(uuidColumn)) {
|
||||
String uuid = element.properties.get(uuidColumn).contents.toString();
|
||||
if (uuid != null && uuid.trim().length() == 36)
|
||||
return uuid.trim();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param atts
|
||||
|
|
Loading…
Reference in New Issue