use of org.adempiere.pipo.exception.POSaveFailedException in project adempiere by adempiere.
the class FieldGroupElementHandler method startElement.
public void startElement(Properties ctx, Element element) throws SAXException {
String elementValue = element.getElementValue();
int AD_Backup_ID = -1;
String Object_Status = null;
Attributes atts = element.attributes;
log.info(elementValue + " " + atts.getValue("Name"));
String entitytype = atts.getValue("EntityType");
String name = atts.getValue("Name");
if (isProcessElement(ctx, entitytype)) {
int id = get_IDWithColumn(ctx, X_AD_FieldGroup.Table_Name, X_AD_FieldGroup.COLUMNNAME_Name, name);
X_AD_FieldGroup fieldGroup = new X_AD_FieldGroup(ctx, id, getTrxName(ctx));
if (id <= 0 && atts.getValue("AD_FieldGroup_ID") != null && Integer.parseInt(atts.getValue("AD_FieldGroup_ID")) <= PackOut.MAX_OFFICIAL_ID)
fieldGroup.setAD_FieldGroup_ID(Integer.parseInt(atts.getValue("AD_FieldGroup_ID")));
if (id > 0) {
AD_Backup_ID = copyRecord(ctx, X_AD_FieldGroup.Table_Name, fieldGroup);
Object_Status = "Update";
if (processedFieldGroups.contains(id)) {
element.skip = true;
return;
}
} else {
Object_Status = "New";
AD_Backup_ID = 0;
}
PoFiller pf = new PoFiller(fieldGroup, atts);
pf.setBoolean(X_AD_FieldGroup.COLUMNNAME_IsActive);
pf.setString(X_AD_FieldGroup.COLUMNNAME_Name);
pf.setString(X_AD_FieldGroup.COLUMNNAME_EntityType);
pf.setString(X_AD_FieldGroup.COLUMNNAME_FieldGroupType);
pf.setBoolean(X_AD_FieldGroup.COLUMNNAME_IsCollapsedByDefault);
if (fieldGroup.save(getTrxName(ctx)) == true) {
record_log(ctx, 1, fieldGroup.getName(), "FieldGroup", fieldGroup.get_ID(), AD_Backup_ID, Object_Status, X_AD_FieldGroup.Table_Name, get_IDWithColumn(ctx, "AD_Table", "TableName", X_AD_FieldGroup.Table_Name));
element.recordId = fieldGroup.getAD_FieldGroup_ID();
processedFieldGroups.add(fieldGroup.getAD_FieldGroup_ID());
} else {
record_log(ctx, 0, fieldGroup.getName(), "FieldGroup", fieldGroup.get_ID(), AD_Backup_ID, Object_Status, X_AD_FieldGroup.Table_Name, get_IDWithColumn(ctx, "AD_Table", "TableName", X_AD_FieldGroup.Table_Name));
throw new POSaveFailedException("Reference");
}
} else {
element.skip = true;
}
}
use of org.adempiere.pipo.exception.POSaveFailedException in project adempiere by adempiere.
the class ProcessParaElementHandler method startElement.
public void startElement(Properties ctx, Element element) throws SAXException {
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("process") && element.parent.defer) {
element.defer = true;
return;
}
String name = atts.getValue("Name");
int id = 0;
int masterId = 0;
String processValue = "";
if (element.parent != null && element.parent.getElementValue().equals("process") && element.parent.recordId > 0) {
masterId = element.parent.recordId;
} else {
processValue = atts.getValue("ADProcessValueID");
if (processValue != null && processValue.trim().length() > 0) {
masterId = get_IDWithColumn(ctx, "AD_Process", "Value", processValue);
} else {
//for backward compatibility
processValue = atts.getValue("ADProcessNameID");
masterId = get_IDWithColumn(ctx, "AD_Process", "Name", processValue);
}
}
if (masterId <= 0) {
element.defer = true;
element.unresolved = "AD_Process: " + processValue;
return;
}
id = get_IDWithMasterAndColumn(ctx, "AD_Process_Para", "Name", name, "AD_Process", masterId);
X_AD_Process_Para m_Process_para = new X_AD_Process_Para(ctx, id, getTrxName(ctx));
int AD_Backup_ID = -1;
String Object_Status = null;
if (id <= 0 && atts.getValue("AD_Process_Para_ID") != null && Integer.parseInt(atts.getValue("AD_Process_Para_ID")) <= PackOut.MAX_OFFICIAL_ID)
m_Process_para.setAD_Process_Para_ID(Integer.parseInt(atts.getValue("AD_Process_Para_ID")));
if (id > 0) {
AD_Backup_ID = copyRecord(ctx, "AD_Process_Para", m_Process_para);
Object_Status = "Update";
} else {
Object_Status = "New";
AD_Backup_ID = 0;
}
m_Process_para.setName(atts.getValue("Name"));
m_Process_para.setAD_Process_ID(masterId);
m_Process_para.setColumnName(atts.getValue("ColumnName"));
m_Process_para.setEntityType(atts.getValue("EntityType"));
name = atts.getValue("ADElementNameID");
if (name != null && name.trim().length() > 0) {
id = get_IDWithColumn(ctx, "AD_Element", "ColumnName", name);
if (id <= 0) /** Check Packout version - 005 */
{
id = get_IDWithColumn(ctx, "AD_Element", "Name", name);
}
// Setup Element
X_AD_Element adElement = new X_AD_Element(ctx, id, getTrxName(ctx));
if (adElement.getAD_Element_ID() == 0) {
String columnName = m_Process_para.getColumnName();
id = get_IDWithColumn(ctx, "AD_Element", "ColumnName", columnName);
if (id > 0) {
adElement = new X_AD_Element(ctx, id, getTrxName(ctx));
} else {
adElement.setColumnName(columnName);
adElement.setEntityType(m_Process_para.getEntityType());
adElement.setPrintName(name);
adElement.setName(m_Process_para.getName());
if (adElement.save(getTrxName(ctx)) == true) {
record_log(ctx, 1, m_Process_para.getName(), "Element", adElement.getAD_Element_ID(), AD_Backup_ID, "New", "AD_Element", get_IDWithColumn(ctx, "AD_Table", "TableName", "AD_Element"));
} else {
record_log(ctx, 0, m_Process_para.getName(), "Element", adElement.getAD_Element_ID(), AD_Backup_ID, "New", "AD_Element", get_IDWithColumn(ctx, "AD_Table", "TableName", "AD_Element"));
}
}
}
m_Process_para.setAD_Element_ID(adElement.getAD_Element_ID());
}
name = atts.getValue("ADReferenceNameID");
if (name != null && name.trim().length() > 0) {
id = get_IDWithColumn(ctx, "AD_Reference", "Name", name);
if (id <= 0) {
element.defer = true;
element.unresolved = "AD_Reference: " + name;
return;
}
m_Process_para.setAD_Reference_ID(id);
}
name = atts.getValue("ADReferenceValueNameID");
if (name != null && name.trim().length() > 0) {
id = get_IDWithColumn(ctx, "AD_Reference", "Name", name);
if (id <= 0) {
element.defer = true;
element.unresolved = "AD_Reference: " + name;
return;
}
m_Process_para.setAD_Reference_Value_ID(id);
}
name = atts.getValue("ADValRuleNameID");
if (name != null && name.trim().length() > 0) {
id = get_IDWithColumn(ctx, "AD_Val_Rule", "Name", name);
if (id <= 0) {
element.defer = true;
element.unresolved = "AD_Val_Rule: " + name;
return;
}
m_Process_para.setAD_Val_Rule_ID(id);
}
m_Process_para.setDefaultValue(getStringValue(atts, "DefaultValue"));
m_Process_para.setDefaultValue2(getStringValue(atts, "DefaultValue2"));
m_Process_para.setDescription(getStringValue(atts, "Description"));
m_Process_para.setHelp(getStringValue(atts, "Help"));
m_Process_para.setIsActive(atts.getValue("isActive") != null ? Boolean.valueOf(atts.getValue("isActive")).booleanValue() : true);
m_Process_para.setReadOnlyLogic(getStringValue(atts, "ReadOnlyLogic"));
m_Process_para.setDisplayLogic(getStringValue(atts, "DisplayLogic"));
m_Process_para.setVFormat(getStringValue(atts, "VFormat"));
m_Process_para.setValueMax(getStringValue(atts, "ValueMax"));
m_Process_para.setValueMin(getStringValue(atts, "ValueMin"));
m_Process_para.setSeqNo(Integer.parseInt(atts.getValue("SeqNo")));
m_Process_para.setFieldLength(Integer.parseInt(atts.getValue("FieldLength")));
m_Process_para.setIsCentrallyMaintained(Boolean.valueOf(atts.getValue("isCentrallyMaintained")).booleanValue());
m_Process_para.setIsMandatory(Boolean.valueOf(atts.getValue("isMandatory")).booleanValue());
m_Process_para.setIsRange(Boolean.valueOf(atts.getValue("isRange")).booleanValue());
if (m_Process_para.save(getTrxName(ctx)) == true) {
record_log(ctx, 1, m_Process_para.getName(), "Process_para", m_Process_para.get_ID(), AD_Backup_ID, Object_Status, "AD_Process_para", get_IDWithColumn(ctx, "AD_Table", "TableName", "AD_Process_para"));
} else {
record_log(ctx, 0, m_Process_para.getName(), "Process_para", m_Process_para.get_ID(), AD_Backup_ID, Object_Status, "AD_Process_para", get_IDWithColumn(ctx, "AD_Table", "TableName", "AD_Process_para"));
throw new POSaveFailedException("ProcessPara");
}
} else {
element.skip = true;
}
}
use of org.adempiere.pipo.exception.POSaveFailedException in project adempiere by adempiere.
the class ReferenceListElementHandler method startElement.
public void startElement(Properties ctx, Element element) throws SAXException {
String elementValue = element.getElementValue();
int AD_Backup_ID = -1;
String Object_Status = null;
Attributes atts = element.attributes;
log.info(elementValue + " " + atts.getValue("Name"));
// TODO: Solve for date issues with valuefrom valueto
String entitytype = atts.getValue("EntityType");
if (isProcessElement(ctx, entitytype)) {
if (element.parent != null && element.parent.skip) {
element.skip = true;
return;
}
String name = atts.getValue("Name");
String value = atts.getValue("Value");
int AD_Reference_ID = 0;
if (element.parent != null && element.parent.getElementValue().equals("reference") && element.parent.recordId > 0) {
AD_Reference_ID = element.parent.recordId;
} else {
AD_Reference_ID = get_IDWithColumn(ctx, "AD_Reference", "Name", atts.getValue("ADRefenceNameID"));
}
int AD_Ref_List_ID = get_IDWithMasterAndColumn(ctx, "AD_Ref_List", "Value", value, "AD_Reference", AD_Reference_ID);
X_AD_Ref_List m_Ref_List = new X_AD_Ref_List(ctx, AD_Ref_List_ID, getTrxName(ctx));
if (AD_Ref_List_ID <= 0 && atts.getValue("AD_Ref_List_ID") != null && Integer.parseInt(atts.getValue("AD_Ref_List_ID")) <= PackOut.MAX_OFFICIAL_ID)
m_Ref_List.setAD_Ref_List_ID(Integer.parseInt(atts.getValue("AD_Ref_List_ID")));
if (AD_Ref_List_ID > 0) {
AD_Backup_ID = copyRecord(ctx, "AD_Ref_List", m_Ref_List);
Object_Status = "Update";
} else {
Object_Status = "New";
AD_Backup_ID = 0;
}
m_Ref_List.setAD_Reference_ID(AD_Reference_ID);
m_Ref_List.setDescription(getStringValue(atts, "Description"));
m_Ref_List.setEntityType(atts.getValue("EntityType"));
m_Ref_List.setName(atts.getValue("Name"));
m_Ref_List.setValue(value);
m_Ref_List.setIsActive(atts.getValue("isActive") != null ? Boolean.valueOf(atts.getValue("isActive")).booleanValue() : true);
if (m_Ref_List.save(getTrxName(ctx)) == true) {
record_log(ctx, 1, m_Ref_List.getName(), "Reference List", m_Ref_List.get_ID(), AD_Backup_ID, Object_Status, "AD_Ref_List", get_IDWithColumn(ctx, "AD_Table", "TableName", "AD_Ref_List"));
} else {
record_log(ctx, 0, m_Ref_List.getName(), "Reference List", m_Ref_List.get_ID(), AD_Backup_ID, Object_Status, "AD_Ref_List", get_IDWithColumn(ctx, "AD_Table", "TableName", "AD_Ref_List"));
throw new POSaveFailedException("ReferenceList");
}
} else {
element.skip = true;
}
}
use of org.adempiere.pipo.exception.POSaveFailedException in project adempiere by adempiere.
the class ReportViewColElementHandler method startElement.
public void startElement(Properties ctx, Element element) throws SAXException {
String elementValue = element.getElementValue();
int AD_Backup_ID = -1;
String Object_Status = null;
Attributes atts = element.attributes;
log.info(elementValue + " " + atts.getValue("ADReportViewColID"));
String entitytype = atts.getValue("EntityType");
if (isProcessElement(ctx, entitytype)) {
String name = atts.getValue("ADReportviewNameID");
int AD_ReportView_ID = 0;
if (element.parent != null && element.parent.getElementValue().equals("reportview") && element.parent.recordId > 0) {
AD_ReportView_ID = element.parent.recordId;
} else {
AD_ReportView_ID = get_IDWithColumn(ctx, "AD_ReportView", "Name", name);
}
if (AD_ReportView_ID <= 0) {
element.defer = true;
return;
}
name = atts.getValue("ADColumnNameID");
int AD_Column_ID = 0;
if (name != null && name.trim().length() > 0) {
AD_Column_ID = get_IDWithColumn(ctx, "AD_Column", "Name", name);
if (AD_Column_ID <= 0) {
element.defer = true;
return;
}
}
String functionColumn = getStringValue(atts, "FunctionColumn");
StringBuffer sql = new StringBuffer("SELECT AD_Reportview_Col_ID FROM AD_Reportview_Col ").append(" WHERE AD_Column_ID ");
if (AD_Column_ID > 0)
sql.append(" = " + AD_Column_ID);
else
sql.append(" IS NULL ");
sql.append(" AND FunctionColumn = ?");
int id = DB.getSQLValue(getTrxName(ctx), sql.toString(), functionColumn);
if (id < 0)
id = 0;
X_AD_ReportView_Col m_Reportview_Col = new X_AD_ReportView_Col(ctx, id, getTrxName(ctx));
if (id <= 0 && atts.getValue("AD_ReportView_Col_ID") != null && Integer.parseInt(atts.getValue("AD_ReportView_Col_ID")) <= PackOut.MAX_OFFICIAL_ID)
m_Reportview_Col.setAD_ReportView_Col_ID(Integer.parseInt(atts.getValue("AD_ReportView_Col_ID")));
if (id > 0) {
AD_Backup_ID = copyRecord(ctx, "AD_Reportview_Col", m_Reportview_Col);
Object_Status = "Update";
} else {
Object_Status = "New";
AD_Backup_ID = 0;
}
boolean isGroupFunction = Boolean.valueOf(atts.getValue("isGroupFunction")).booleanValue();
m_Reportview_Col.setAD_ReportView_ID(AD_ReportView_ID);
if (AD_Column_ID > 0) {
m_Reportview_Col.setAD_Column_ID(id);
}
m_Reportview_Col.setFunctionColumn(functionColumn);
m_Reportview_Col.setIsActive(atts.getValue("isActive") != null ? Boolean.valueOf(atts.getValue("isActive")).booleanValue() : true);
m_Reportview_Col.setIsGroupFunction(isGroupFunction);
if (m_Reportview_Col.save(getTrxName(ctx)) == true) {
record_log(ctx, 1, "" + m_Reportview_Col.getAD_ReportView_ID(), "Reportview_Col", m_Reportview_Col.get_ID(), AD_Backup_ID, Object_Status, "AD_Reportview_Col", get_IDWithColumn(ctx, "AD_Table", "TableName", "AD_Reportview_Col"));
} else {
record_log(ctx, 0, "" + m_Reportview_Col.getAD_ReportView_ID(), "Reportview_Col", m_Reportview_Col.get_ID(), AD_Backup_ID, Object_Status, "AD_Reportview_Col", get_IDWithColumn(ctx, "AD_Table", "TableName", "AD_Reportview_Col"));
throw new POSaveFailedException("ReportViewCol");
}
} else {
element.skip = true;
}
}
use of org.adempiere.pipo.exception.POSaveFailedException in project adempiere by adempiere.
the class ReportViewElementHandler method startElement.
public void startElement(Properties ctx, Element element) throws SAXException {
String elementValue = element.getElementValue();
int AD_Backup_ID = -1;
String Object_Status = null;
Attributes atts = element.attributes;
log.info(elementValue + " " + atts.getValue("ADReportviewnameID"));
//String entitytype = atts.getValue("EntityType");
String name = atts.getValue("ADReportviewnameID");
int id = get_ID(ctx, "AD_ReportView", name);
X_AD_ReportView m_Reportview = new X_AD_ReportView(ctx, id, getTrxName(ctx));
if (id <= 0 && atts.getValue("AD_ReportView_ID") != null && Integer.parseInt(atts.getValue("AD_ReportView_ID")) <= PackOut.MAX_OFFICIAL_ID)
m_Reportview.setAD_ReportView_ID(Integer.parseInt(atts.getValue("AD_ReportView_ID")));
if (id > 0) {
AD_Backup_ID = copyRecord(ctx, "AD_Reportview", m_Reportview);
Object_Status = "Update";
} else {
Object_Status = "New";
AD_Backup_ID = 0;
}
String Name = atts.getValue("ADTableNameID");
id = get_IDWithColumn(ctx, "AD_Table", "TableName", Name);
MTable m_Table = null;
if (id == 0) {
m_Table = new MTable(ctx, 0, getTrxName(ctx));
m_Table.setAccessLevel("3");
m_Table.setName(Name);
m_Table.setTableName(Name);
if (m_Table.save(getTrxName(ctx)) == true) {
record_log(ctx, 1, m_Table.getName(), "Table", m_Table.get_ID(), 0, "New", "AD_Table", get_IDWithColumn(ctx, "AD_Table", "TableName", "AD_Table"));
} else {
record_log(ctx, 0, m_Table.getName(), "Table", m_Table.get_ID(), 0, "New", "AD_Table", get_IDWithColumn(ctx, "AD_Table", "TableName", "AD_Table"));
}
id = get_IDWithColumn(ctx, "AD_Table", "TableName", Name);
}
m_Reportview.setAD_Table_ID(id);
m_Reportview.setDescription(getStringValue(atts, "Description"));
m_Reportview.setEntityType(atts.getValue("EntityType"));
m_Reportview.setName(atts.getValue("Name"));
m_Reportview.setIsActive(atts.getValue("isActive") != null ? Boolean.valueOf(atts.getValue("isActive")).booleanValue() : true);
m_Reportview.setOrderByClause(getStringValue(atts, "OrderByClause"));
m_Reportview.setWhereClause(getStringValue(atts, "WhereClause"));
if (m_Reportview.save(getTrxName(ctx)) == true) {
record_log(ctx, 1, m_Reportview.getName(), "Reportview", m_Reportview.get_ID(), AD_Backup_ID, Object_Status, "AD_Reportview", get_IDWithColumn(ctx, "AD_Table", "TableName", "AD_Reportview"));
element.recordId = m_Reportview.getAD_ReportView_ID();
} else {
record_log(ctx, 0, m_Reportview.getName(), "Reportview", m_Reportview.get_ID(), AD_Backup_ID, Object_Status, "AD_Reportview", get_IDWithColumn(ctx, "AD_Table", "TableName", "AD_Reportview"));
throw new POSaveFailedException("ReportView");
}
}
Aggregations