Search in sources :

Example 36 with POSaveFailedException

use of org.adempiere.pipo.exception.POSaveFailedException in project adempiere by adempiere.

the class BrowseElementHandler 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_Browse", name);
        if (id > 0 && browses.contains(id)) {
            return;
        }
        MBrowse m_Browse = new MBrowse(ctx, id, getTrxName(ctx));
        if (id <= 0 && atts.getValue("AD_Browse_ID") != null && Integer.parseInt(atts.getValue("AD_Browse_ID")) <= PackOut.MAX_OFFICIAL_ID)
            m_Browse.setAD_Browse_ID(Integer.parseInt(atts.getValue("AD_Browse_ID")));
        String Object_Status = null;
        int AD_Backup_ID = -1;
        if (id > 0) {
            AD_Backup_ID = copyRecord(ctx, "AD_Browse", m_Browse);
            Object_Status = "Update";
        } else {
            Object_Status = "New";
            AD_Backup_ID = 0;
        }
        if (getStringValue(atts, "ADViewNameID") != null) {
            name = atts.getValue("ADViewNameID");
            id = get_IDWithColumn(ctx, "AD_View", "Name", name);
            if (id <= 0) {
                element.defer = true;
                element.unresolved = "AD_View: " + name;
                return;
            }
            m_Browse.setAD_View_ID(id);
        }
        if (getStringValue(atts, "ADProcessNameID") != null) {
            name = atts.getValue("ADProcessNameID");
            if (name != null && name.trim().length() > 0) {
                id = get_IDWithColumn(ctx, "AD_Process", "Name", name);
                if (id <= 0) {
                    element.defer = true;
                    element.unresolved = "AD_Process: " + name;
                    return;
                }
                m_Browse.setAD_Process_ID(id);
            }
        }
        if (getStringValue(atts, "ADWindowNameID") != null) {
            name = atts.getValue("ADWindowNameID");
            if (name != null && name.trim().length() > 0) {
                id = get_IDWithColumn(ctx, "AD_Window", "Name", name);
                if (id <= 0) {
                    element.defer = true;
                    element.unresolved = "AD_Window: " + name;
                    return;
                }
                m_Browse.setAD_Window_ID(id);
            }
        }
        m_Browse.setValue(atts.getValue("Value"));
        m_Browse.setName(atts.getValue("Name"));
        m_Browse.setDescription(getStringValue(atts, "Description"));
        m_Browse.setHelp(getStringValue(atts, "Help"));
        m_Browse.setIsActive(atts.getValue("isActive") != null ? Boolean.valueOf(atts.getValue("isActive")).booleanValue() : true);
        m_Browse.setIsCollapsibleByDefault(atts.getValue("IsCollapsibleByDefault") != null ? Boolean.valueOf(atts.getValue("IsCollapsibleByDefault")).booleanValue() : true);
        m_Browse.setIsDeleteable(atts.getValue("IsDeleteable") != null ? Boolean.valueOf(atts.getValue("IsDeleteable")).booleanValue() : true);
        m_Browse.setIsExecutedQueryByDefault(atts.getValue("IsExecutedQueryByDefault") != null ? Boolean.valueOf(atts.getValue("IsExecutedQueryByDefault")).booleanValue() : true);
        m_Browse.setIsSelectedByDefault(atts.getValue("IsSelectedByDefault") != null ? Boolean.valueOf(atts.getValue("IsSelectedByDefault")).booleanValue() : true);
        m_Browse.setIsShowTotal(atts.getValue("IsShowTotal") != null ? Boolean.valueOf(atts.getValue("IsShowTotal")).booleanValue() : true);
        m_Browse.setEntityType(atts.getValue("EntityType"));
        m_Browse.setWhereClause(atts.getValue("WhereClause"));
        m_Browse.setAccessLevel(atts.getValue("AccessLevel"));
        if (m_Browse.save(getTrxName(ctx)) == true) {
            record_log(ctx, 1, m_Browse.getName(), "Browse", m_Browse.get_ID(), AD_Backup_ID, Object_Status, "AD_Browse", get_IDWithColumn(ctx, "AD_Table", "TableName", "AD_Browse"));
            element.recordId = m_Browse.getAD_Browse_ID();
            browses.add(m_Browse.getAD_Browse_ID());
        } else {
            record_log(ctx, 0, m_Browse.getName(), "Browse", m_Browse.get_ID(), AD_Backup_ID, Object_Status, "AD_Browse", get_IDWithColumn(ctx, "AD_Table", "TableName", "AD_Browse"));
            throw new POSaveFailedException("Browse");
        }
    } else {
        element.skip = true;
    }
}
Also used : Attributes(org.xml.sax.Attributes) POSaveFailedException(org.adempiere.pipo.exception.POSaveFailedException) MBrowse(org.adempiere.model.MBrowse)

Example 37 with POSaveFailedException

use of org.adempiere.pipo.exception.POSaveFailedException in project adempiere by adempiere.

the class BrowseFieldElementHandler 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("browse") && element.parent.defer) {
            element.defer = true;
            return;
        }
        String browsename = atts.getValue("ADBrowseNameID");
        String colviewname = atts.getValue("ADViewColumnNameID");
        String viewName = atts.getValue("ADViewNameID");
        int viewid = get_IDWithColumn(ctx, "AD_View", "Name", viewName);
        if (viewid <= 0) {
            element.defer = true;
            return;
        }
        int viewcolumnid = get_IDWithMasterAndColumn(ctx, "AD_View_Column", "ColumnName", colviewname, "AD_View", viewid);
        if (viewcolumnid <= 0) {
            element.defer = true;
            return;
        }
        int browseid = 0;
        if (element.parent != null && element.parent.getElementValue().equals("browse") && element.parent.recordId > 0) {
            browseid = element.parent.recordId;
        } else {
            StringBuffer sqlB = new StringBuffer("SELECT AD_Browse_ID from AD_Browse WHERE AD_Browse_ID = " + browseid).append(" and Name = '" + browsename + "'").append(" and AD_View_ID = ?");
            browseid = DB.getSQLValue(getTrxName(ctx), sqlB.toString(), viewid);
            if (element.parent != null && element.parent.getElementValue().equals("browse") && browseid > 0) {
                element.parent.recordId = browseid;
            }
        }
        if (browseid > 0) {
            StringBuffer sqlB = new StringBuffer("SELECT AD_Browse_Field_ID from AD_Browse_Field where AD_View_Column_ID = ").append(viewcolumnid).append(" and AD_Browse_ID = ?");
            int id = DB.getSQLValue(getTrxName(ctx), sqlB.toString(), browseid);
            final MBrowseField m_BrowseField = new MBrowseField(ctx, id, getTrxName(ctx));
            if (id <= 0 && atts.getValue("AD_Browse_Field_ID") != null && Integer.parseInt(atts.getValue("AD_Browse_Field_ID")) <= PackOut.MAX_OFFICIAL_ID)
                m_BrowseField.setAD_Browse_Field_ID(Integer.parseInt(atts.getValue("AD_Browse_Field_ID")));
            int AD_Backup_ID = -1;
            String Object_Status = null;
            if (id > 0) {
                AD_Backup_ID = copyRecord(ctx, "AD_Browse_Field", m_BrowseField);
                Object_Status = "Update";
            } else {
                Object_Status = "New";
                AD_Backup_ID = 0;
            }
            m_BrowseField.setName(atts.getValue("Name"));
            m_BrowseField.setAD_View_Column_ID(viewcolumnid);
            m_BrowseField.setAD_Browse_ID(browseid);
            m_BrowseField.setEntityType(atts.getValue("EntityType"));
            m_BrowseField.setIsCentrallyMaintained(Boolean.valueOf(atts.getValue("isCentrallyMaintained")).booleanValue());
            m_BrowseField.setIsMandatory(Boolean.valueOf(atts.getValue("isMandatory")).booleanValue());
            m_BrowseField.setIsDisplayed(Boolean.valueOf(atts.getValue("Displayed")).booleanValue());
            m_BrowseField.setIsReadOnly(Boolean.valueOf(atts.getValue("isReadOnly")).booleanValue());
            m_BrowseField.setDefaultValue(atts.getValue("DefaultValue"));
            m_BrowseField.setInfoFactoryClass(getStringValue(atts, "InfoFactoryClass"));
            m_BrowseField.setDefaultValue2(atts.getValue("DefaultValue2"));
            m_BrowseField.setReadOnlyLogic(atts.getValue("ReadOnlyLogic"));
            m_BrowseField.setDisplayLogic(atts.getValue("DisplayLogic"));
            m_BrowseField.setVFormat(atts.getValue("VFormat"));
            m_BrowseField.setFieldLength(Integer.parseInt(atts.getValue("FieldLength")));
            m_BrowseField.setValueMin(atts.getValue("ValueMin"));
            m_BrowseField.setValueMin(atts.getValue("ValueMax"));
            String Name = atts.getValue("ADValRuleNameID");
            id = get_IDWithColumn(ctx, "AD_Val_Rule", "Name", Name);
            m_BrowseField.setAD_Val_Rule_ID(id);
            m_BrowseField.setSeqNo(Integer.parseInt(atts.getValue("SeqNo")));
            m_BrowseField.setSeqNoGrid(Integer.parseInt(atts.getValue("SeqNoGrid")));
            //	Is Information Only #556
            m_BrowseField.setIsInfoOnly(Boolean.valueOf(atts.getValue("IsInfoOnly")).booleanValue());
            m_BrowseField.setSortNo(Integer.parseInt(atts.getValue("SortNo")));
            m_BrowseField.setIsOrderBy(Boolean.valueOf(atts.getValue("IsOrderBy")).booleanValue());
            m_BrowseField.setDescription(getStringValue(atts, "Description"));
            m_BrowseField.setHelp(getStringValue(atts, "Help"));
            m_BrowseField.setIsActive(atts.getValue("isActive") != null ? Boolean.valueOf(atts.getValue("isActive")).booleanValue() : true);
            m_BrowseField.setIsRange(atts.getValue("isRange") != null ? Boolean.valueOf(atts.getValue("isRange")).booleanValue() : true);
            m_BrowseField.setIsKey(atts.getValue("isKey") != null ? Boolean.valueOf(atts.getValue("isKey")).booleanValue() : true);
            m_BrowseField.setIsQueryCriteria(atts.getValue("isQueryCriteria") != null ? Boolean.valueOf(atts.getValue("isQueryCriteria")).booleanValue() : true);
            m_BrowseField.setIsIdentifier(atts.getValue("isIdentifier") != null ? Boolean.valueOf(atts.getValue("isIdentifier")).booleanValue() : true);
            Name = atts.getValue("ADReferenceNameID");
            id = get_IDWithColumn(ctx, "AD_Reference", "Name", Name);
            m_BrowseField.setAD_Reference_ID(id);
            // Name = atts.getValue("ADValRuleNameID");
            // id = get_IDWithColumn(ctx, "AD_Val_Rule", "Name", Name);
            // m_BrowseField.setAD_Val_Rule_ID(id);
            Name = atts.getValue("ADReferenceNameValueID");
            id = get_IDWithColumn(ctx, "AD_Reference", "Name", Name);
            m_BrowseField.setAD_Reference_Value_ID(id);
            Name = atts.getValue("ADAxisViewColumnNameID");
            id = get_IDWithMasterAndColumn(ctx, "AD_View_Column", "ColumnName", Name, "AD_View", viewid);
            m_BrowseField.setAxis_Column_ID(id);
            Name = atts.getValue("ADAxisParentViewColumnNameID");
            id = get_IDWithMasterAndColumn(ctx, "AD_View_Column", "ColumnName", Name, "AD_View", viewid);
            m_BrowseField.setAxis_Parent_Column_ID(id);
            // Setup Element.
            Name = atts.getValue("ADElementNameID");
            id = get_IDWithColumn(ctx, "AD_Element", "ColumnName", Name);
            X_AD_Element adElement = new X_AD_Element(ctx, id, getTrxName(ctx));
            String Object_Status_col = Object_Status;
            if (adElement.getAD_Element_ID() == 0) {
                // Object_Status = "New";
                adElement.setColumnName(m_BrowseField.getAD_View_Column().getAD_Column().getColumnName());
                adElement.setEntityType(m_BrowseField.getEntityType());
                adElement.setPrintName(m_BrowseField.getName());
                adElement.setName(m_BrowseField.getName());
                if (adElement.save(getTrxName(ctx)) == true) {
                    record_log(ctx, 1, m_BrowseField.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_BrowseField.getName(), "Element", adElement.getAD_Element_ID(), AD_Backup_ID, "New", "AD_Element", get_IDWithColumn(ctx, "AD_Table", "TableName", "AD_Element"));
                }
            }
            Object_Status = Object_Status_col;
            m_BrowseField.setAD_Element_ID(adElement.getAD_Element_ID());
            if (m_BrowseField.save(getTrxName(ctx)) == true) {
                record_log(ctx, 1, m_BrowseField.getName(), "BrowseField", m_BrowseField.get_ID(), AD_Backup_ID, Object_Status, "AD_Browse_Field", get_IDWithColumn(ctx, "AD_Table", "TableName", "AD_Browse_Field"));
                element.recordId = m_BrowseField.getAD_Browse_Field_ID();
            } else {
                record_log(ctx, 0, m_BrowseField.getName(), "BrowseField", m_BrowseField.get_ID(), AD_Backup_ID, Object_Status, "AD_Browse_Field", get_IDWithColumn(ctx, "AD_Table", "TableName", "AD_Browse_Field"));
                throw new POSaveFailedException("Failed to save field definition.");
            }
        } else {
            element.defer = true;
            return;
        }
    } else {
        element.skip = true;
    }
}
Also used : MBrowseField(org.adempiere.model.MBrowseField) Attributes(org.xml.sax.Attributes) POSaveFailedException(org.adempiere.pipo.exception.POSaveFailedException) X_AD_Element(org.compiere.model.X_AD_Element)

Example 38 with POSaveFailedException

use of org.adempiere.pipo.exception.POSaveFailedException in project adempiere by adempiere.

the class VCollect method executePayment.

/**
	 * Process Window
	 * @return
	 * @return String
	 */
public void executePayment(String trxName) {
    if (pos.processOrder(trxName, isAllowsPartialPayment(), getBalance(pos.getOpenAmt()).signum() <= 0)) {
        processTenderTypes(trxName, pos.getOpenAmt());
        String error = getErrorMsg();
        if (error != null && error.length() > 0)
            throw new POSaveFailedException(Msg.parseTranslation(ctx, "@order.no@ " + pos.getDocumentNo() + ": " + getErrorMsg()));
    } else {
        throw new POSaveFailedException(Msg.parseTranslation(ctx, "@order.no@ " + pos.getDocumentNo() + ": " + "@ProcessRunError@" + " (" + pos.getProcessMsg() + ")"));
    }
}
Also used : POSaveFailedException(org.adempiere.pipo.exception.POSaveFailedException)

Aggregations

POSaveFailedException (org.adempiere.pipo.exception.POSaveFailedException)38 Attributes (org.xml.sax.Attributes)37 BigDecimal (java.math.BigDecimal)5 MTable (org.compiere.model.MTable)5 PackIn (org.adempiere.pipo.PackIn)4 X_AD_Element (org.compiere.model.X_AD_Element)4 PoFiller (org.adempiere.pipo.PoFiller)2 MWorkflow (org.compiere.wf.MWorkflow)2 AdempiereException (org.adempiere.exceptions.AdempiereException)1 MBrowse (org.adempiere.model.MBrowse)1 MBrowseField (org.adempiere.model.MBrowseField)1 MView (org.adempiere.model.MView)1 MViewColumn (org.adempiere.model.MViewColumn)1 MViewDefinition (org.adempiere.model.MViewDefinition)1 DatabaseAccessException (org.adempiere.pipo.exception.DatabaseAccessException)1 MColumn (org.compiere.model.MColumn)1 MEntityType (org.compiere.model.MEntityType)1 MField (org.compiere.model.MField)1 MForm (org.compiere.model.MForm)1 MMessage (org.compiere.model.MMessage)1