use of org.adempiere.pipo.exception.POSaveFailedException in project adempiere by adempiere.
the class ViewColumnElementHandler method startElement.
public void startElement(Properties ctx, Element element) throws SAXException {
PackIn packIn = (PackIn) ctx.get("PackInProcess");
String elementValue = element.getElementValue();
Attributes atts = element.attributes;
log.info(elementValue + " " + atts.getValue("Name"));
String entitytype = atts.getValue("EntityType");
if (isProcessElement(ctx, entitytype)) {
if (element.parent != null && element.parent.getElementValue().equals("viewdefinition") && element.parent.defer) {
element.defer = true;
return;
}
String name = atts.getValue("Name");
String viewdenitionname = atts.getValue("ADViewDefinitionNameID");
String colname = atts.getValue("ADColumnNameID");
String viewColumnName = atts.getValue("ADViewColumnNameID");
String tableName = atts.getValue("ADTableNameID");
int tableid = packIn.getTableId(tableName);
if (tableid <= 0) {
tableid = get_IDWithColumn(ctx, "AD_Table", "TableName", tableName);
if (tableid > 0)
packIn.addTable(tableName, tableid);
}
if (tableid <= 0 && tableName.length() > 0) {
element.defer = true;
return;
}
int viewid = get_ID(ctx, "AD_View", atts.getValue("ADViewNameID"));
if (viewid <= 0) {
element.defer = true;
return;
}
int columnid = packIn.getColumnId(tableName, colname);
if (columnid <= 0) {
columnid = get_IDWithMasterAndColumn(ctx, "AD_Column", "ColumnName", colname, "AD_Table", tableid);
if (columnid > 0)
packIn.addColumn(tableName, colname, columnid);
}
if (columnid <= 0 && colname.length() > 0) {
element.defer = true;
return;
}
int viewdefinitionid = 0;
if (element.parent != null && element.parent.getElementValue().equals("viewdefinition") && element.parent.recordId > 0) {
viewdefinitionid = element.parent.recordId;
} else {
StringBuffer sqlB = new StringBuffer("select AD_View_Definition_ID from AD_View_Definition where AD_View_ID = " + viewid).append(" and TableAlias = '" + viewdenitionname + "'").append(" and AD_Table_ID = ?");
viewdefinitionid = DB.getSQLValue(getTrxName(ctx), sqlB.toString(), tableid);
if (element.parent != null && element.parent.getElementValue().equals("viewdefinition") && viewdefinitionid > 0) {
element.parent.recordId = viewdefinitionid;
}
}
if (viewdefinitionid > 0) {
StringBuilder sqlB = new StringBuilder("SELECT AD_View_Column_ID from AD_View_Column WHERE ColumnName=?").append(" AND AD_View_Definition_ID=?");
int id = DB.getSQLValue(getTrxName(ctx), sqlB.toString(), viewColumnName, viewdefinitionid);
final MViewColumn m_ColumnView = new MViewColumn(ctx, id, getTrxName(ctx));
if (id <= 0 && atts.getValue("AD_View_Column_ID") != null && Integer.parseInt(atts.getValue("AD_View_Column_ID")) <= PackOut.MAX_OFFICIAL_ID)
m_ColumnView.setAD_View_Column_ID(Integer.parseInt(atts.getValue("AD_View_Column_ID")));
int AD_Backup_ID = -1;
String Object_Status = null;
if (id > 0) {
AD_Backup_ID = copyRecord(ctx, "AD_View_Column_ID", m_ColumnView);
Object_Status = "Update";
} else {
Object_Status = "New";
AD_Backup_ID = 0;
}
m_ColumnView.setName(atts.getValue("Name"));
m_ColumnView.setAD_View_ID(viewid);
if (columnid > 0)
m_ColumnView.setAD_Column_ID(columnid);
m_ColumnView.setAD_View_Definition_ID(viewdefinitionid);
m_ColumnView.setEntityType(atts.getValue("EntityType"));
m_ColumnView.setColumnSQL(atts.getValue("ColumnSQL"));
m_ColumnView.setColumnName(viewColumnName);
// m_ColumnView.setIsReadOnly(Boolean.valueOf(
// atts.getValue("isReadOnly")).booleanValue());
m_ColumnView.setDescription(getStringValue(atts, "Description"));
m_ColumnView.setHelp(getStringValue(atts, "Help"));
m_ColumnView.setIsActive(atts.getValue("isActive") != null ? Boolean.valueOf(atts.getValue("isActive")).booleanValue() : true);
if (m_ColumnView.save(getTrxName(ctx)) == true) {
record_log(ctx, 1, m_ColumnView.getName(), "ViewColumn", m_ColumnView.get_ID(), AD_Backup_ID, Object_Status, "ViewColumn", get_IDWithColumn(ctx, "AD_Table", "TableName", "AD_View_Column"));
element.recordId = m_ColumnView.getAD_View_Column_ID();
} else {
record_log(ctx, 0, m_ColumnView.getName(), "ViewColumn", m_ColumnView.get_ID(), AD_Backup_ID, Object_Status, "AD_View_Column", get_IDWithColumn(ctx, "AD_Table", "TableName", "AD_View_Column"));
throw new POSaveFailedException("Failed to save view column definition.");
}
}
} else {
element.skip = true;
}
}
use of org.adempiere.pipo.exception.POSaveFailedException in project adempiere by adempiere.
the class ViewDefinitionElementHandler method startElement.
public void startElement(Properties ctx, Element element) throws SAXException {
String elementValue = element.getElementValue();
Attributes atts = element.attributes;
log.info(elementValue + " " + atts.getValue("ADViewDefinitionNameID"));
String entitytype = atts.getValue("EntityType");
if (isProcessElement(ctx, entitytype)) {
if (element.parent != null && element.parent.getElementValue().equals("view") && element.parent.defer) {
element.defer = true;
return;
}
String tableAlias = atts.getValue("ADViewDefinitionNameID");
int tableid = get_IDWithColumn(ctx, "AD_Table", "TableName", atts.getValue("ADTableNameID"));
if (tableid <= 0) {
element.defer = true;
return;
}
int viewid = 0;
if (element.parent != null && element.parent.getElementValue().equals("view") && element.parent.recordId > 0) {
viewid = element.parent.recordId;
} else {
viewid = get_ID(ctx, "AD_View", atts.getValue("ADViewNameID"));
if (element.parent != null && element.parent.getElementValue().equals("view") && viewid > 0) {
element.parent.recordId = viewid;
}
}
if (viewid <= 0) {
element.defer = true;
return;
}
StringBuffer sqlB = new StringBuffer("SELECT AD_View_Definition_ID FROM AD_View_Definition WHERE AD_View_ID = " + viewid + " and TableAlias = '" + tableAlias + "'" + " and AD_Table_ID = ?");
int id = DB.getSQLValue(getTrxName(ctx), sqlB.toString(), tableid);
MViewDefinition m_View_Definition = new MViewDefinition(ctx, id, getTrxName(ctx));
if (id <= 0 && atts.getValue("AD_View_Definition_ID") != null && Integer.parseInt(atts.getValue("AD_View_Definition_ID")) <= PackOut.MAX_OFFICIAL_ID)
m_View_Definition.setAD_View_Definition_ID(Integer.parseInt(atts.getValue("AD_View_Definition_ID")));
int AD_Backup_ID = -1;
String Object_Status = null;
if (id > 0) {
AD_Backup_ID = copyRecord(ctx, "AD_View_Definition", m_View_Definition);
Object_Status = "Update";
} else {
Object_Status = "New";
AD_Backup_ID = 0;
}
sqlB = null;
m_View_Definition.setTableAlias(tableAlias);
String name;
if (getStringValue(atts, "ADTableNameID") != null) {
name = atts.getValue("ADTableNameID");
id = get_IDWithColumn(ctx, "AD_Table", "TableName", name);
m_View_Definition.setAD_Table_ID(id);
}
m_View_Definition.setAD_View_ID(viewid);
m_View_Definition.setIsActive(atts.getValue("isActive") != null ? Boolean.valueOf(atts.getValue("isActive")).booleanValue() : true);
m_View_Definition.setProcessing(false);
m_View_Definition.setSeqNo(Integer.parseInt(atts.getValue("SeqNo")));
if (getStringValue(atts, "JoinClause") != null) {
m_View_Definition.setJoinClause(atts.getValue("JoinClause"));
}
if (m_View_Definition.save(getTrxName(ctx)) == true) {
record_log(ctx, 1, m_View_Definition.getTableAlias(), "ViewDefinition", m_View_Definition.get_ID(), AD_Backup_ID, Object_Status, "AD_View_Definition", get_IDWithColumn(ctx, "AD_Table", "TableName", "AD_View_Definition"));
element.recordId = m_View_Definition.getAD_View_Definition_ID();
} else {
record_log(ctx, 0, m_View_Definition.getTableAlias(), "ViewDefinition", m_View_Definition.get_ID(), AD_Backup_ID, Object_Status, "AD_View_Definition", get_IDWithColumn(ctx, "AD_Table", "TableName", "AD_View_Definition"));
throw new POSaveFailedException("ViewDefinition");
}
} else {
element.skip = true;
}
}
use of org.adempiere.pipo.exception.POSaveFailedException in project adempiere by adempiere.
the class WorkflowNodeNextElementHandler method startElement.
public void startElement(Properties ctx, Element element) throws SAXException {
Attributes atts = element.attributes;
String entitytype = atts.getValue("EntityType");
log.info("entitytype " + atts.getValue("EntityType"));
if (isProcessElement(ctx, entitytype)) {
if (element.parent != null && element.parent.skip) {
element.skip = true;
return;
}
String workflowName = atts.getValue("ADWorkflowNameID");
int workflowId = get_IDWithColumn(ctx, "AD_Workflow", "name", workflowName);
if (workflowId <= 0) {
element.defer = true;
element.unresolved = "AD_Workflow: " + workflowName;
return;
}
String workflowNodeName = atts.getValue("ADWorkflowNodeNameID").trim();
String workflowNodeNextName = atts.getValue("ADWorkflowNodeNextNameID").trim();
StringBuffer sqlB = new StringBuffer("SELECT ad_wf_node_id FROM AD_WF_Node WHERE AD_Workflow_ID=? and Name =?");
int wfNodeId = DB.getSQLValue(getTrxName(ctx), sqlB.toString(), workflowId, workflowNodeName);
if (wfNodeId <= 0) {
element.defer = true;
element.unresolved = "AD_WF_Node: " + workflowNodeName;
return;
}
int wfNodeNextId = DB.getSQLValue(getTrxName(ctx), sqlB.toString(), workflowId, workflowNodeNextName);
if (wfNodeNextId <= 0) {
element.defer = true;
element.unresolved = "AD_WF_Node: " + workflowNodeNextName;
return;
}
sqlB = new StringBuffer("SELECT ad_wf_nodenext_id FROM AD_WF_NodeNext WHERE ad_wf_node_id =? and ad_wf_next_id =?");
int id = DB.getSQLValue(getTrxName(ctx), sqlB.toString(), wfNodeId, wfNodeNextId);
MWFNodeNext m_WFNodeNext = new MWFNodeNext(ctx, id, getTrxName(ctx));
int AD_Backup_ID = -1;
String Object_Status = null;
if (id <= 0 && atts.getValue("AD_WF_NodeNext_ID") != null && Integer.parseInt(atts.getValue("AD_WF_NodeNext_ID")) <= PackOut.MAX_OFFICIAL_ID)
m_WFNodeNext.setAD_WF_NodeNext_ID(Integer.parseInt(atts.getValue("AD_WF_NodeNext_ID")));
if (id > 0) {
AD_Backup_ID = copyRecord(ctx, "AD_WF_NodeNext", m_WFNodeNext);
Object_Status = "Update";
} else {
Object_Status = "New";
AD_Backup_ID = 0;
}
m_WFNodeNext.setAD_WF_Node_ID(wfNodeId);
m_WFNodeNext.setAD_WF_Next_ID(wfNodeNextId);
m_WFNodeNext.setEntityType(atts.getValue("EntityType"));
m_WFNodeNext.setSeqNo(Integer.valueOf(atts.getValue("SeqNo")));
m_WFNodeNext.setIsActive(atts.getValue("isActive") != null ? Boolean.valueOf(atts.getValue("isActive")).booleanValue() : true);
m_WFNodeNext.setIsStdUserWorkflow(atts.getValue("IsStdUserWorkflow") != null ? Boolean.valueOf(atts.getValue("IsStdUserWorkflow")).booleanValue() : true);
log.info("about to execute m_WFNodeNext.save");
if (m_WFNodeNext.save(getTrxName(ctx)) == true) {
log.info("m_WFNodeNext save success");
record_log(ctx, 1, String.valueOf(m_WFNodeNext.get_ID()), "WFNodeNext", m_WFNodeNext.get_ID(), AD_Backup_ID, Object_Status, "AD_WF_NodeNext", get_IDWithColumn(ctx, "AD_Table", "TableName", "AD_WF_NodeNext"));
} else {
log.info("m_WFNodeNext save failure");
record_log(ctx, 0, String.valueOf(m_WFNodeNext.get_ID()), "WFNodeNext", m_WFNodeNext.get_ID(), AD_Backup_ID, Object_Status, "AD_WF_NodeNext", get_IDWithColumn(ctx, "AD_Table", "TableName", "AD_WF_NodeNext"));
throw new POSaveFailedException("WorkflowNodeNext");
}
} else {
element.skip = true;
}
}
use of org.adempiere.pipo.exception.POSaveFailedException in project adempiere by adempiere.
the class TableElementHandler method startElement.
public void startElement(Properties ctx, Element element) throws SAXException {
final PackIn packIn = (PackIn) ctx.get("PackInProcess");
final String elementValue = element.getElementValue();
final Attributes atts = element.attributes;
log.info(elementValue + " " + atts.getValue("ADTableNameID"));
final String entitytype = atts.getValue("EntityType");
if (isProcessElement(ctx, entitytype)) {
final String tableName = atts.getValue("ADTableNameID");
int id = packIn.getTableId(tableName);
if (id <= 0) {
id = get_IDWithColumn(ctx, "AD_Table", "TableName", tableName);
if (id > 0)
packIn.addTable(tableName, id);
}
if (id > 0 && isTableProcess(ctx, id) && element.pass == 1) {
return;
}
MTable m_Table = new MTable(ctx, id, getTrxName(ctx));
if (id <= 0 && atts.getValue("AD_Table_ID") != null && Integer.parseInt(atts.getValue("AD_Table_ID")) <= PackOut.MAX_OFFICIAL_ID)
m_Table.setAD_Table_ID(Integer.parseInt(atts.getValue("AD_Table_ID")));
int AD_Backup_ID = -1;
String Object_Status = null;
if (id > 0) {
AD_Backup_ID = copyRecord(ctx, "AD_Table", m_Table);
Object_Status = "Update";
} else {
Object_Status = "New";
AD_Backup_ID = 0;
}
m_Table.setTableName(tableName);
//
// Window
final String windowName = atts.getValue("ADWindowNameID");
if (!Util.isEmpty(windowName, true)) {
id = get_IDWithColumn(ctx, "AD_Window", "Name", windowName);
if (id > 0) {
m_Table.setAD_Window_ID(id);
} else if (!element.defer) {
element.defer = true;
element.unresolved = "Window:" + windowName;
} else {
log.warning("@NotFound@ @AD_Window_ID@:" + windowName);
}
}
//
// PO Window
final String poWindowName = getStringValue(atts, "POWindowNameID");
if (!Util.isEmpty(poWindowName, true)) {
id = get_IDWithColumn(ctx, "AD_Window", "Name", poWindowName);
if (id > 0) {
m_Table.setPO_Window_ID(id);
} else if (!element.defer) {
element.defer = true;
element.unresolved = "POWindow:" + poWindowName;
} else {
log.warning("@NotFound@ @PO_Window_ID@:" + poWindowName);
}
}
//
// Validation Rule
final String valRuleName = getStringValue(atts, "ADValRuleNameID");
if (!Util.isEmpty(valRuleName, true)) {
id = get_IDWithColumn(ctx, "AD_Val_Rule", "Name", valRuleName);
if (id > 0) {
m_Table.setAD_Val_Rule_ID(id);
} else {
element.defer = true;
element.unresolved = "ValRule:" + valRuleName;
}
}
//
m_Table.setAccessLevel(atts.getValue("AccessLevel"));
m_Table.setDescription(getStringValue(atts, "Description"));
m_Table.setEntityType(atts.getValue("EntityType"));
m_Table.setHelp(getStringValue(atts, "Help"));
m_Table.setIsActive(atts.getValue("isActive") != null ? Boolean.valueOf(atts.getValue("isActive")).booleanValue() : true);
m_Table.setImportTable(getStringValue(atts, "ImportTable"));
m_Table.setIsChangeLog(Boolean.valueOf(atts.getValue("isChangeLog")).booleanValue());
m_Table.setIsDeleteable(Boolean.valueOf(atts.getValue("isDeleteable")).booleanValue());
m_Table.setIsHighVolume(Boolean.valueOf(atts.getValue("isHighVolume")).booleanValue());
m_Table.setIsSecurityEnabled(Boolean.valueOf(atts.getValue("isSecurityEnabled")).booleanValue());
m_Table.setIsView(Boolean.valueOf(atts.getValue("isView")).booleanValue());
//m_Table.setLoadSeq(Integer.parseInt(atts.getValue("LoadSeq")));
m_Table.setName(atts.getValue("Name"));
m_Table.setReplicationType(getStringValue(atts, "ReplicationType"));
m_Table.setTableName(atts.getValue("TableName"));
if (m_Table.save(getTrxName(ctx)) == true) {
record_log(ctx, 1, m_Table.getName(), "Table", m_Table.get_ID(), AD_Backup_ID, Object_Status, "AD_Table", get_IDWithColumn(ctx, "AD_Table", "TableName", "AD_Table"));
tables.add(m_Table.getAD_Table_ID());
packIn.addTable(tableName, m_Table.getAD_Table_ID());
element.recordId = m_Table.getAD_Table_ID();
} else {
record_log(ctx, 0, m_Table.getName(), "Table", m_Table.get_ID(), AD_Backup_ID, Object_Status, "AD_Table", get_IDWithColumn(ctx, "AD_Table", "TableName", "AD_Table"));
throw new POSaveFailedException("Table");
}
} else {
element.skip = true;
}
}
use of org.adempiere.pipo.exception.POSaveFailedException in project adempiere by adempiere.
the class WindowElementHandler method startElement.
public void startElement(Properties ctx, Element element) throws SAXException {
// Check namespace.
String elementValue = element.getElementValue();
Attributes atts = element.attributes;
log.info(elementValue + " " + atts.getValue("Name"));
String entitytype = atts.getValue("EntityType");
if (isProcessElement(ctx, entitytype)) {
String name = atts.getValue("Name");
int id = get_ID(ctx, "AD_Window", name);
if (id > 0 && windows.contains(id)) {
return;
}
MWindow m_Window = new MWindow(ctx, id, getTrxName(ctx));
if (id <= 0 && atts.getValue("AD_Window_ID") != null && Integer.parseInt(atts.getValue("AD_Window_ID")) <= PackOut.MAX_OFFICIAL_ID)
m_Window.setAD_Window_ID(Integer.parseInt(atts.getValue("AD_Window_ID")));
String Object_Status = null;
int AD_Backup_ID = -1;
if (id > 0) {
AD_Backup_ID = copyRecord(ctx, "AD_Window", m_Window);
Object_Status = "Update";
} else {
Object_Status = "New";
AD_Backup_ID = 0;
}
m_Window.setName(name);
name = atts.getValue("ADImageNameID");
if (name != null && name.trim().length() > 0) {
id = get_IDWithColumn(ctx, "AD_Image", "Name", name);
/*
if (id <= 0) {
element.defer = true;
return;
}*/
if (id > 0)
m_Window.setAD_Image_ID(id);
}
name = atts.getValue("ADColorNameID");
if (name != null && name.trim().length() > 0) {
id = get_IDWithColumn(ctx, "AD_Color", "Name", name);
/*
if (id <= 0) {
element.defer = true;
return;
}*/
if (id > 0)
m_Window.setAD_Color_ID(id);
}
m_Window.setDescription(getStringValue(atts, "Description"));
m_Window.setEntityType(atts.getValue("EntityType"));
m_Window.setHelp(getStringValue(atts, "Help"));
m_Window.setIsActive(atts.getValue("isActive") != null ? Boolean.valueOf(atts.getValue("isActive")).booleanValue() : true);
m_Window.setIsBetaFunctionality(Boolean.valueOf(atts.getValue("isBetaFunctionality")).booleanValue());
m_Window.setIsDefault(Boolean.valueOf(atts.getValue("isDefault")).booleanValue());
m_Window.setIsSOTrx(Boolean.valueOf(atts.getValue("isSOTrx")).booleanValue());
m_Window.setName(atts.getValue("Name"));
m_Window.setProcessing(false);
if (!Util.isEmpty(atts.getValue("WinHeight"), true))
m_Window.setWinWidth(getValueInt(atts, "WinWidth", 0));
if (!Util.isEmpty(atts.getValue("WinHeight"), true))
m_Window.setWinHeight(getValueInt(atts, "WinHeight", 0));
m_Window.setWindowType(atts.getValue("WindowType"));
if (m_Window.save(getTrxName(ctx)) == true) {
record_log(ctx, 1, m_Window.getName(), "Window", m_Window.get_ID(), AD_Backup_ID, Object_Status, "AD_Window", get_IDWithColumn(ctx, "AD_Table", "TableName", "AD_Window"));
element.recordId = m_Window.getAD_Window_ID();
windows.add(m_Window.getAD_Window_ID());
} else {
record_log(ctx, 0, m_Window.getName(), "Window", m_Window.get_ID(), AD_Backup_ID, Object_Status, "AD_Window", get_IDWithColumn(ctx, "AD_Table", "TableName", "AD_Window"));
throw new POSaveFailedException("Window");
}
} else {
element.skip = true;
}
}
Aggregations