use of org.adempiere.pipo.exception.POSaveFailedException in project adempiere by adempiere.
the class EntityTypeElementHandler method startElement.
public void startElement(Properties ctx, Element element) throws SAXException {
final String elementValue = element.getElementValue();
final Attributes atts = element.attributes;
final String entitytype = atts.getValue(I_AD_EntityType.COLUMNNAME_EntityType);
log.info(elementValue + " " + entitytype);
if (isProcessElement(ctx, entitytype)) {
int id = get_IDWithColumn(ctx, I_AD_EntityType.Table_Name, I_AD_EntityType.COLUMNNAME_EntityType, entitytype);
final MEntityType entity = new MEntityType(ctx, id, getTrxName(ctx));
final int AD_Backup_ID;
final String Object_Status;
if (id <= 0 && getIntValue(atts, I_AD_EntityType.COLUMNNAME_AD_EntityType_ID, 0) <= PackOut.MAX_OFFICIAL_ID) {
entity.setAD_EntityType_ID(getIntValue(atts, I_AD_EntityType.COLUMNNAME_AD_EntityType_ID, 0));
}
if (id > 0) {
AD_Backup_ID = copyRecord(ctx, I_AD_EntityType.Table_Name, entity);
Object_Status = "Update";
} else {
Object_Status = "New";
AD_Backup_ID = 0;
}
entity.setName(getStringValue(atts, I_AD_EntityType.COLUMNNAME_Name));
entity.setDescription(getStringValue(atts, I_AD_EntityType.COLUMNNAME_Description));
entity.setHelp(getStringValue(atts, I_AD_EntityType.COLUMNNAME_Help));
entity.setEntityType(getStringValue(atts, I_AD_EntityType.COLUMNNAME_EntityType));
entity.setVersion(atts.getValue(I_AD_EntityType.COLUMNNAME_Version));
entity.setIsActive(getBooleanValue(atts, I_AD_EntityType.COLUMNNAME_IsActive, true));
entity.setModelPackage(getStringValue(atts, I_AD_EntityType.COLUMNNAME_ModelPackage));
entity.setClasspath(getStringValue(atts, I_AD_EntityType.COLUMNNAME_Classpath));
if (entity.save(getTrxName(ctx)) == true) {
record_log(ctx, 1, entity.getEntityType(), TAG_Name, entity.get_ID(), AD_Backup_ID, Object_Status, I_AD_EntityType.Table_Name, I_AD_EntityType.Table_ID);
} else {
record_log(ctx, 0, entity.getEntityType(), TAG_Name, entity.get_ID(), AD_Backup_ID, Object_Status, I_AD_EntityType.Table_Name, I_AD_EntityType.Table_ID);
throw new POSaveFailedException("Failed to save message.");
}
} else {
element.skip = true;
}
}
use of org.adempiere.pipo.exception.POSaveFailedException in project adempiere by adempiere.
the class FieldElementHandler method startElement.
public void startElement(Properties ctx, Element element) throws SAXException {
final String include_tabname = element.attributes.getValue("ADIncludeTabNameID");
// Set Included Tab ID if this task was previously postponed
if (element.defer && element.recordId > 0 && include_tabname != null) {
MField field = new MField(ctx, element.recordId, getTrxName(ctx));
setIncluded_Tab_ID(ctx, field, include_tabname);
field.saveEx();
return;
}
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("tab") && element.parent.defer) {
element.defer = true;
return;
}
String name = atts.getValue("Name");
String tabname = atts.getValue("ADTabNameID");
String colname = atts.getValue("ADColumnNameID");
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) {
element.defer = true;
return;
}
int windowid = get_ID(ctx, "AD_Window", atts.getValue("ADWindowNameID"));
if (windowid <= 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) {
element.defer = true;
return;
}
int tabid = 0;
if (element.parent != null && element.parent.getElementValue().equals("tab") && element.parent.recordId > 0) {
tabid = element.parent.recordId;
} else {
StringBuffer sqlB = new StringBuffer("select AD_Tab_ID from AD_Tab where AD_Window_ID = " + windowid).append(" and Name = '" + tabname + "'").append(" and AD_Table_ID = ?");
tabid = DB.getSQLValue(getTrxName(ctx), sqlB.toString(), tableid);
if (element.parent != null && element.parent.getElementValue().equals("tab") && tabid > 0) {
element.parent.recordId = tabid;
}
}
if (tabid > 0) {
StringBuffer sqlB = new StringBuffer("select AD_Field_ID from AD_Field where AD_Column_ID = ").append(columnid).append(" and AD_Tab_ID = ?");
int id = DB.getSQLValue(getTrxName(ctx), sqlB.toString(), tabid);
final MField m_Field = new MField(ctx, id, getTrxName(ctx));
if (id <= 0 && atts.getValue("AD_Field_ID") != null && Integer.parseInt(atts.getValue("AD_Field_ID")) <= PackOut.MAX_OFFICIAL_ID)
m_Field.setAD_Field_ID(Integer.parseInt(atts.getValue("AD_Field_ID")));
int AD_Backup_ID = -1;
String Object_Status = null;
if (id > 0) {
AD_Backup_ID = copyRecord(ctx, "AD_Field", m_Field);
Object_Status = "Update";
} else {
Object_Status = "New";
AD_Backup_ID = 0;
}
m_Field.setName(atts.getValue("Name"));
m_Field.setAD_Column_ID(columnid);
name = atts.getValue("ADFieldGroupNameID");
id = get_IDWithColumn(ctx, "AD_FieldGroup", "Name", name);
m_Field.setAD_FieldGroup_ID(id);
m_Field.setAD_Tab_ID(tabid);
m_Field.setEntityType(atts.getValue("EntityType"));
m_Field.setIsSameLine(Boolean.valueOf(atts.getValue("SameLine")).booleanValue());
m_Field.setIsCentrallyMaintained(Boolean.valueOf(atts.getValue("isCentrallyMaintained")).booleanValue());
m_Field.setIsDisplayed(Boolean.valueOf(atts.getValue("Displayed")).booleanValue());
// m_Field.setIsEncrypted(Boolean.valueOf(atts.getValue("isEncrypted")).booleanValue());
m_Field.setIsFieldOnly(Boolean.valueOf(atts.getValue("isFieldOnly")).booleanValue());
m_Field.setIsHeading(Boolean.valueOf(atts.getValue("isHeading")).booleanValue());
m_Field.setIsReadOnly(Boolean.valueOf(atts.getValue("isReadOnly")).booleanValue());
m_Field.setSeqNo(Integer.parseInt(atts.getValue("SeqNo")));
m_Field.setDisplayLength(Integer.parseInt(atts.getValue("DisplayLength")));
m_Field.setDescription(getStringValue(atts, "Description"));
m_Field.setHelp(getStringValue(atts, "Help"));
m_Field.setIsActive(atts.getValue("isActive") != null ? Boolean.valueOf(atts.getValue("isActive")).booleanValue() : true);
String sortNo = getStringValue(atts, "SortNo");
if (sortNo != null)
m_Field.setSortNo(new BigDecimal(sortNo));
m_Field.setDisplayLogic(getStringValue(atts, "DisplayLogic"));
String Name = atts.getValue("ADReferenceNameID");
id = get_IDWithColumn(ctx, "AD_Reference", "Name", Name);
m_Field.setAD_Reference_ID(id);
Name = atts.getValue("ADValRuleNameID");
id = get_IDWithColumn(ctx, "AD_Val_Rule", "Name", Name);
m_Field.setAD_Val_Rule_ID(id);
Name = atts.getValue("ADReferenceNameValueID");
id = get_IDWithColumn(ctx, "AD_Reference", "Name", Name);
m_Field.setAD_Reference_Value_ID(id);
m_Field.setInfoFactoryClass(getStringValue(atts, "InfoFactoryClass"));
if ("Y".equals(atts.getValue("isMandatory")))
m_Field.setIsMandatory(atts.getValue("isMandatory"));
else if ("N".equals(atts.getValue("isMandatory")))
m_Field.setIsMandatory(atts.getValue("isMandatory"));
m_Field.setDefaultValue(atts.getValue("DefaultValue"));
if (atts.getValue("IsDisplayedGrid") != null)
m_Field.setIsDisplayedGrid(Boolean.valueOf(atts.getValue("IsDisplayedGrid")).booleanValue());
if (atts.getValue("PreferredWidth") != null)
m_Field.setPreferredWidth(Integer.parseInt(atts.getValue("PreferredWidth")));
setIncluded_Tab_ID(ctx, m_Field, include_tabname);
if (m_Field.save(getTrxName(ctx)) == true) {
record_log(ctx, 1, m_Field.getName(), "Field", m_Field.get_ID(), AD_Backup_ID, Object_Status, "AD_Field", get_IDWithColumn(ctx, "AD_Table", "TableName", "AD_Field"));
element.recordId = m_Field.getAD_Field_ID();
} else {
record_log(ctx, 0, m_Field.getName(), "Field", m_Field.get_ID(), AD_Backup_ID, Object_Status, "AD_Field", get_IDWithColumn(ctx, "AD_Table", "TableName", "AD_Field"));
throw new POSaveFailedException("Failed to save field definition.");
}
// If Included Tab not found, then postpone this task for later processing
if (m_Field.getAD_Field_ID() > 0 && include_tabname != null && m_Field.getIncluded_Tab_ID() <= 0) {
element.defer = true;
}
} else {
element.defer = true;
return;
}
} else {
element.skip = true;
}
}
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;
}
}
Aggregations