Search in sources :

Example 1 with MBrowse

use of org.adempiere.model.MBrowse in project adempiere by adempiere.

the class Browser method getInfoColumnForAxisField.

/**
	 * Get Info_Column for Axis Field
	 * @param field defined as Axis
	 * @return Info_Column with Axis Field
	 */
public List<MBrowseField> getInfoColumnForAxisField(MBrowseField field) {
    List<MBrowseField> list = new ArrayList<MBrowseField>();
    axisParameters = new ArrayList<>();
    axisParametersValues = new ArrayList<>();
    try {
        I_AD_View_Column xcol, pcol, ycol;
        xcol = field.getAD_View_Column();
        pcol = field.getAxis_Parent_Column();
        ycol = field.getAxis_Column();
        String columnName = xcol.getAD_Column().getColumnName();
        MBrowseField fieldKey = ((MBrowse) field.getAD_Browse()).getFieldKey();
        if (fieldKey == null)
            throw new AdempiereException("@NotFound@ @IsKey@");
        MTable xTable = (MTable) ycol.getAD_View_Definition().getAD_Table();
        String xTableName = xTable.getTableName();
        String keyColumn = MQuery.getZoomColumnName(columnName);
        String tableName = MQuery.getZoomTableName(columnName);
        String whereClause = "";
        if (pcol != null && pcol.getAD_View_Column_ID() > 0) {
            MTable parentTable = MTable.get(field.getCtx(), tableName);
            MColumn parentColumn = getParentColumn(parentTable.getAD_Table_ID());
            if (parentColumn == null)
                throw new AdempiereException("@NotFound@ @IsParent@");
            //	BR [ 242 ]
            if (field.getAD_Val_Rule_ID() > 0)
                whereClause = Env.parseContext(Env.getCtx(), getWindowNo(), field.getAD_Val_Rule().getCode(), false);
        }
        MLookup lookup = MLookupFactory.get(Env.getCtx(), 0, xcol.getAD_Column_ID(), field.getAD_Reference_ID(), m_language, keyColumn, field.getAD_Reference_Value_ID(), false, whereClause);
        int cols = 0;
        StringBuilder axisSql = new StringBuilder("(SELECT ");
        axisSql.append("SUM(").append(ycol.getAD_Column().getColumnName()).append(") FROM  ").append(ycol.getAD_View_Definition().getAD_Table().getTableName()).append(" WHERE ").append(xTableName).append(".").append(fieldKey.getAD_View_Column().getAD_Column().getColumnName()).append("=").append(fieldKey.getAD_View_Column().getColumnSQL());
        for (int id : getAxisRecordIds(tableName, whereClause)) {
            cols++;
            String display = lookup.getDisplay(id).trim();
            display = display.length() > 12 ? display.substring(1, 12) + "_" + cols : display;
            String joinColumn = Msg.translate(m_language, ycol.getAD_Column().getColumnName());
            joinColumn = joinColumn.length() > 15 ? joinColumn.substring(1, 15) : joinColumn;
            String sqlColName = display + "/" + joinColumn;
            String colName = lookup.getDisplay(id).trim() + "/" + Msg.translate(m_language, ycol.getAD_Column().getColumnName());
            StringBuilder axisWhere = new StringBuilder(" ");
            axisWhere.append(getAxisSQLWhere(ycol)).append(" AND ").append(xcol.getAD_View_Definition().getTableAlias()).append(".").append(xcol.getAD_Column().getColumnName());
            StringBuffer select = new StringBuffer();
            select.append(axisSql).append(axisWhere);
            select.append("=").append(id).append(")");
            MViewColumn viewColumn = new MViewColumn(field.getCtx(), 0, field.get_TrxName());
            MViewColumn.copyValues((MViewColumn) ycol, viewColumn);
            viewColumn.setAD_View_Column_ID(ycol.getAD_View_Column_ID());
            viewColumn.setAD_Column_ID(ycol.getAD_Column_ID());
            viewColumn.setColumnSQL(select.toString());
            viewColumn.setColumnName("\"" + sqlColName + "\"");
            MBrowseField browseField = new MBrowseField((MBrowse) field.getAD_Browse(), viewColumn);
            browseField.setAD_Browse_ID(field.getAD_Browse_ID());
            browseField.setAD_Element_ID(field.getAD_Element_ID());
            browseField.setName(colName);
            browseField.setDescription(viewColumn.getDescription());
            browseField.setHelp(viewColumn.getHelp());
            if (viewColumn.get_ID() > 0)
                browseField.setAD_View_Column_ID(viewColumn.getAD_View_Column_ID());
            browseField.setIsActive(true);
            browseField.setIsIdentifier(viewColumn.isIdentifier());
            browseField.setIsRange(false);
            browseField.setIsQueryCriteria(false);
            browseField.setAD_Reference_ID(ycol.getAD_Column().getAD_Reference_ID());
            browseField.setAD_Reference_Value_ID(ycol.getAD_Column().getAD_Reference_Value_ID());
            browseField.setIsKey(false);
            browseField.setIsDisplayed(true);
            browseField.setAxis_Column_ID(field.getAxis_Column_ID());
            browseField.setAxis_Parent_Column_ID(field.getAxis_Parent_Column_ID());
            browseField.setIsReadOnly(field.isReadOnly());
            browseField.setAD_Element_ID(field.getAD_Element_ID());
            list.add(browseField);
            log.finest("Added Column=" + sqlColName + " SQL = " + select);
        }
    } catch (Exception e) {
        throw new AdempiereException(e);
    }
    return list;
}
Also used : MColumn(org.compiere.model.MColumn) MBrowseField(org.adempiere.model.MBrowseField) MLookup(org.compiere.model.MLookup) ArrayList(java.util.ArrayList) I_AD_View_Column(org.adempiere.model.I_AD_View_Column) MBrowse(org.adempiere.model.MBrowse) SQLException(java.sql.SQLException) IOException(java.io.IOException) DBException(org.adempiere.exceptions.DBException) AdempiereException(org.adempiere.exceptions.AdempiereException) MViewColumn(org.adempiere.model.MViewColumn) MTable(org.compiere.model.MTable) AdempiereException(org.adempiere.exceptions.AdempiereException)

Example 2 with MBrowse

use of org.adempiere.model.MBrowse in project adempiere by adempiere.

the class ASPGenerateLevel method addNodeToLevel.

//	doIt
private void addNodeToLevel(MTreeNode nn) {
    // Add Menu
    MMenu menu = new MMenu(getCtx(), nn.getNode_ID(), get_TrxName());
    if (menu.getAction().equals(MMenu.ACTION_Window)) {
        MWindow window = new MWindow(getCtx(), menu.getAD_Window_ID(), get_TrxName());
        int asp_window_id = DB.getSQLValueEx(get_TrxName(), "SELECT ASP_Window_ID FROM ASP_Window WHERE ASP_Level_ID = ? AND AD_Window_ID = ?", p_ASP_Level_ID, window.getAD_Window_ID());
        X_ASP_Window aspWindow = null;
        if (asp_window_id < 1) {
            // Add Window, Tabs and Fields (if IsGenerateFields)
            aspWindow = new X_ASP_Window(getCtx(), 0, get_TrxName());
            aspWindow.setASP_Level_ID(p_ASP_Level_ID);
            aspWindow.setAD_Window_ID(window.getAD_Window_ID());
            aspWindow.setASP_Status(p_ASP_Status);
            if (aspWindow.save()) {
                noWindows++;
                asp_window_id = aspWindow.getASP_Window_ID();
            }
        } else {
            aspWindow = new X_ASP_Window(getCtx(), asp_window_id, get_TrxName());
        }
        // tabs
        for (MTab tab : window.getTabs(true, get_TrxName())) {
            int asp_tab_id = DB.getSQLValueEx(get_TrxName(), "SELECT ASP_Tab_ID FROM ASP_Tab WHERE ASP_Window_ID = ? AND AD_Tab_ID = ?", asp_window_id, tab.getAD_Tab_ID());
            X_ASP_Tab aspTab = null;
            if (asp_tab_id < 1) {
                aspTab = new X_ASP_Tab(getCtx(), 0, get_TrxName());
                aspTab.setASP_Window_ID(asp_window_id);
                aspTab.setAD_Tab_ID(tab.getAD_Tab_ID());
                aspTab.setASP_Status(p_ASP_Status);
                aspTab.setAllFields(!p_IsGenerateFields);
                if (aspTab.save()) {
                    noTabs++;
                    asp_tab_id = aspTab.getASP_Tab_ID();
                }
            } else {
                aspTab = new X_ASP_Tab(getCtx(), asp_tab_id, get_TrxName());
            }
            // fields
            for (MField field : tab.getFields(true, get_TrxName())) {
                if (p_IsGenerateFields) {
                    if (DB.getSQLValueEx(get_TrxName(), "SELECT COUNT(*) FROM ASP_Field WHERE ASP_Tab_ID = ? AND AD_Field_ID = ?", aspTab.getASP_Tab_ID(), field.getAD_Field_ID()) < 1) {
                        X_ASP_Field aspField = new X_ASP_Field(getCtx(), 0, get_TrxName());
                        aspField.setASP_Tab_ID(aspTab.getASP_Tab_ID());
                        aspField.setAD_Field_ID(field.getAD_Field_ID());
                        aspField.setASP_Status(p_ASP_Status);
                        if (aspField.save())
                            noFields++;
                    }
                }
                // verify if a field is a button and assign permission to the corresponding process
                MColumn column = MColumn.get(getCtx(), field.getAD_Column_ID());
                if (column.getAD_Reference_ID() == DisplayType.Button) {
                    if (column.getAD_Process_ID() > 0) {
                        generateProcess(column.getAD_Process_ID());
                    }
                }
            }
        }
    } else if (menu.getAction().equals(MMenu.ACTION_Process) || menu.getAction().equals(MMenu.ACTION_Report)) {
        generateProcess(menu.getAD_Process_ID());
    } else if (menu.getAction().equals(MMenu.ACTION_Form)) {
        // Add Form
        MForm form = new MForm(getCtx(), menu.getAD_Form_ID(), get_TrxName());
        if (DB.getSQLValueEx(get_TrxName(), "SELECT COUNT(*) FROM ASP_Form WHERE ASP_Level_ID = ? AND AD_Form_ID = ?", p_ASP_Level_ID, form.getAD_Form_ID()) < 1) {
            X_ASP_Form aspForm = new X_ASP_Form(getCtx(), 0, get_TrxName());
            aspForm.setASP_Level_ID(p_ASP_Level_ID);
            aspForm.setAD_Form_ID(form.getAD_Form_ID());
            aspForm.setASP_Status(p_ASP_Status);
            if (aspForm.save())
                noForms++;
        }
    } else if (menu.getAction().equals(MMenu.ACTION_SmartBrowse)) {
        // Add Browse
        MBrowse browse = new MBrowse(getCtx(), menu.getAD_Browse_ID(), get_TrxName());
        if (DB.getSQLValueEx(get_TrxName(), "SELECT COUNT(*) FROM ASP_Browse WHERE ASP_Level_ID = ? AND AD_Browse_ID = ?", p_ASP_Level_ID, browse.getAD_Browse_ID()) < 1) {
            X_ASP_Browse aspBrowse = new X_ASP_Browse(getCtx(), 0, get_TrxName());
            aspBrowse.setASP_Level_ID(p_ASP_Level_ID);
            aspBrowse.setAD_Browse_ID(browse.getAD_Browse_ID());
            aspBrowse.setASP_Status(p_ASP_Status);
            if (aspBrowse.save())
                noBrowses++;
        }
    } else if (menu.getAction().equals(MMenu.ACTION_Task)) {
        // Add Task
        MTask task = new MTask(getCtx(), menu.getAD_Task_ID(), get_TrxName());
        if (DB.getSQLValueEx(get_TrxName(), "SELECT COUNT(*) FROM ASP_Task WHERE ASP_Level_ID = ? AND AD_Task_ID = ?", p_ASP_Level_ID, task.getAD_Task_ID()) < 1) {
            X_ASP_Task aspTask = new X_ASP_Task(getCtx(), 0, get_TrxName());
            aspTask.setASP_Level_ID(p_ASP_Level_ID);
            aspTask.setAD_Task_ID(task.getAD_Task_ID());
            aspTask.setASP_Status(p_ASP_Status);
            if (aspTask.save())
                noTasks++;
        }
    } else if (menu.getAction().equals(MMenu.ACTION_WorkFlow)) {
        generateWorkflow(menu.getAD_Workflow_ID());
    }
}
Also used : MColumn(org.compiere.model.MColumn) X_ASP_Field(org.compiere.model.X_ASP_Field) MTab(org.compiere.model.MTab) MMenu(org.compiere.model.MMenu) MWindow(org.compiere.model.MWindow) X_ASP_Tab(org.compiere.model.X_ASP_Tab) MBrowse(org.adempiere.model.MBrowse) MForm(org.compiere.model.MForm) MTask(org.compiere.model.MTask) X_ASP_Task(org.compiere.model.X_ASP_Task) X_ASP_Form(org.compiere.model.X_ASP_Form) X_ASP_Window(org.compiere.model.X_ASP_Window) MField(org.compiere.model.MField) X_ASP_Browse(org.eevolution.model.X_ASP_Browse)

Example 3 with MBrowse

use of org.adempiere.model.MBrowse in project adempiere by adempiere.

the class POSActionMenu method executeCommand.

private void executeCommand(Command command) {
    Waiting waiting = new Waiting(pos.getFrame(), Msg.parseTranslation(pos.getCtx(), "@Processing@"), false, 120);
    try {
        CommandReceiver receiver = commandManager.getCommandReceivers(command.getEvent());
        if (command.getCommand() == CommandManager.GENERATE_IMMEDIATE_INVOICE && pos.getC_Order_ID() > 0 && pos.isCompleted() && !pos.isVoided()) {
            receiver.setCtx(pos.getCtx());
            receiver.setPartnerId(queryPartner.getRecord_ID());
            receiver.setOrderId(pos.getC_Order_ID());
            receiver.setPOSId(pos.getC_POS_ID());
            receiver.setBankAccountId(pos.getC_BankAccount_ID());
            MBPartner partner = MBPartner.get(pos.getCtx(), receiver.getPartnerId());
            Optional<String> taxId = Optional.ofNullable(partner.getTaxID());
            String processMessage = receiver.getName() + " @DisplayDocumentInfo@ : " + pos.getDocumentNo() + " @To@ @C_BPartner_ID@ : " + partner.getName() + " @TaxID@ : " + taxId.orElse("");
            if (ADialog.ask(pos.getWindowNo(), popupMenu, "StartProcess?", Msg.parseTranslation(pos.getCtx(), processMessage))) {
                AEnv.showCenterScreen(waiting);
                command.execute(receiver);
                ProcessInfo processInfo = receiver.getProcessInfo();
                waiting.setVisible(false);
                if (processInfo != null && processInfo.isError()) {
                    showError(processInfo);
                } else {
                    afterExecutionCommand(command);
                    showOkMessage(processInfo);
                    if (processInfo != null)
                        pos.setOrder(processInfo.getRecord_ID());
                    pos.refreshHeader();
                    //	Print Ticket
                    pos.printTicket();
                }
            }
        } else //Reverse The Sales Transaction
        if (command.getCommand() == CommandManager.GENERATE_REVERSE_SALES && pos.getC_Order_ID() > 0 && !pos.isReturnMaterial() && !pos.isVoided() && !pos.isClosed()) {
            receiver.setCtx(pos.getCtx());
            receiver.setOrderId(pos.getC_Order_ID());
            receiver.setPOSId(pos.getC_POS_ID());
            receiver.setPartnerId(pos.getC_BPartner_ID());
            receiver.setBankAccountId(pos.getC_BankAccount_ID());
            String processMessage = receiver.getName() + " @order.no@ : " + pos.getDocumentNo() + " @To@ @C_BPartner_ID@ : " + pos.getBPName();
            if (ADialog.ask(pos.getWindowNo(), popupMenu, "StartProcess?", Msg.parseTranslation(pos.getCtx(), processMessage))) {
                AEnv.showCenterScreen(waiting);
                command.execute(receiver);
                ProcessInfo processInfo = receiver.getProcessInfo();
                waiting.setVisible(false);
                if (processInfo != null && processInfo.isError()) {
                    showError(processInfo);
                } else {
                    afterExecutionCommand(command);
                    showOkMessage(processInfo);
                }
                pos.printTicket();
            }
        } else //Return product
        if (command.getCommand() == CommandManager.GENERATE_RETURN && pos.getC_Order_ID() > 0 && !pos.isReturnMaterial() && pos.isCompleted()) {
            receiver.setCtx(pos.getCtx());
            receiver.setOrderId(pos.getC_Order_ID());
            receiver.setPOSId(pos.getC_POS_ID());
            receiver.setPartnerId(pos.getC_BPartner_ID());
            receiver.setBankAccountId(pos.getC_BankAccount_ID());
            String processMessage = receiver.getName() + " @DisplayDocumentInfo@ : " + pos.getDocumentNo() + " @To@ @C_BPartner_ID@ : " + pos.getBPName();
            if (ADialog.ask(pos.getWindowNo(), popupMenu, "StartProcess?", Msg.parseTranslation(pos.getCtx(), processMessage))) {
                AEnv.showCenterScreen(waiting);
                command.execute(receiver);
                ProcessInfo processInfo = receiver.getProcessInfo();
                waiting.setVisible(false);
                if (processInfo != null && processInfo.isError()) {
                    showError(processInfo);
                } else {
                    afterExecutionCommand(command);
                    showOkMessage(processInfo);
                    //execute out transaction
                    if (processInfo != null && processInfo.getRecord_ID() > 0) {
                        pos.setOrder(processInfo.getRecord_ID());
                        pos.refreshHeader();
                    }
                }
            }
        } else if (command.getCommand() == CommandManager.GENERATE_WITHDRAWAL) {
            Env.setContext(pos.getCtx(), pos.getWindowNo(), "C_POS_ID", pos.getC_POS_ID());
            Dimension size = new Dimension(1024, 768);
            FormFrame ff = new FormFrame(pos.getWindowNo());
            ff.setSize(size);
            MBrowse browse = new MBrowse(Env.getCtx(), 50056, null);
            new VBrowser(ff, true, pos.getWindowNo(), "", browse, "", true, "", true);
            ff.pack();
            AEnv.showCenterScreen(ff);
        } else if (command.getCommand() == CommandManager.CLOSE_STATEMENT) {
            Env.setContext(pos.getCtx(), pos.getWindowNo(), "C_POS_ID", pos.getC_POS_ID());
            Dimension size = new Dimension(1024, 768);
            FormFrame ff = new FormFrame(pos.getWindowNo());
            ff.setSize(size);
            MBrowse browse = new MBrowse(Env.getCtx(), 50057, null);
            new VBrowser(ff, true, pos.getWindowNo(), "", browse, "", true, "", true);
            ff.pack();
            AEnv.showCenterScreen(ff);
        }
    } catch (Exception exception) {
        waiting.setVisible(false);
        ADialog.error(pos.getWindowNo(), pos.getFrame(), exception.getLocalizedMessage());
    } finally {
        waiting.setVisible(false);
        waiting = null;
    }
}
Also used : CommandReceiver(org.adempiere.pos.command.CommandReceiver) FormFrame(org.compiere.apps.form.FormFrame) MBPartner(org.compiere.model.MBPartner) ProcessInfo(org.compiere.process.ProcessInfo) Dimension(java.awt.Dimension) MBrowse(org.adempiere.model.MBrowse) VBrowser(org.eevolution.form.VBrowser) AdempiereException(org.adempiere.exceptions.AdempiereException) Waiting(org.compiere.apps.Waiting)

Example 4 with MBrowse

use of org.adempiere.model.MBrowse in project adempiere by adempiere.

the class DynamicDashBoard method prepareSelectQuery.

/**
	 * 
	 * @return String<br>
	 * 
	 *         This method builds the sql query to generate Result set. It creates Columns and labels as well.
	 * 
	 * 
	 */
public String prepareSelectQuery() {
    // Getting isDisplayed fields based on the Browse ID
    StringBuffer whereClause = new StringBuffer(X_AD_Browse.COLUMNNAME_AD_Browse_ID + " = " + browseId + " AND isDisplayed = 'Y'");
    List<MBrowseField> fieldList = new Query(Env.getCtx(), I_AD_Browse_Field.Table_Name, whereClause.toString(), null).setOnlyActiveRecords(true).setOrderBy(X_AD_Browse_Field.COLUMNNAME_SeqNo).list();
    if (fieldList != null && !fieldList.isEmpty()) {
        lable = new Label[fieldList.size()];
        column = new Column[fieldList.size()];
        sqlQuery = sqlQuery.append(" SELECT ");
        if (zoomWindowId > 0 && zoomTabId > 0) {
            MBrowseField zoomField = new MBrowseField(Env.getCtx(), zoomFieldId, null);
            if (!fieldList.contains(zoomField)) {
                StringBuffer columnWhereClause = new StringBuffer("AD_View_Column_ID = " + zoomField.getAD_View_Column_ID());
                MViewColumn viewColumn = new Query(Env.getCtx(), I_AD_View_Column.Table_Name, columnWhereClause.toString(), null).setOnlyActiveRecords(true).first();
                sqlQuery = sqlQuery.append(viewColumn.getColumnSQL() + ", ");
            } else {
                displayZoomCol = Boolean.TRUE;
            }
            whereClause = new StringBuffer("AD_Tab_ID= " + zoomTabId);
            zoomTab = new Query(Env.getCtx(), I_AD_Tab.Table_Name, whereClause.toString(), null).setOnlyActiveRecords(true).first();
            if (zoomTab != null) {
                // Getting Zoom table based on the zoom tab
                whereClause = new StringBuffer("AD_Table_ID= " + zoomTab.getAD_Table_ID());
                zoomTable = new Query(Env.getCtx(), I_AD_Table.Table_Name, whereClause.toString(), null).setOnlyActiveRecords(true).first();
                if (zoomTable != null) {
                    // table or view? based on suffix "_v". It assumed that
                    // created view is having this suffix
                    //@The View Name must be Actual Table Name and It must ends with one of above suffixes @
                    //If this view combination of multiple tables, the view name must be prefix with any one of Joining Tables
                    //And That table should have primary key::: Eg: AD_USer_v, here AD_User_ID is Primary key of AD_User
                    zoomTableName = zoomTable.getTableName();
                    if (zoomTable.isView()) {
                        if (zoomTableName.endsWith("_vt")) {
                            zoomTableColumnName = zoomTableName.replace("_vt", "_ID");
                            sqlQuery = sqlQuery.append(zoomTableColumnName + ", ");
                        } else // if view ends with _v only
                        if (zoomTableName.endsWith("_v")) {
                            zoomTableColumnName = zoomTableName.replace("_v", "_ID");
                            sqlQuery = sqlQuery.append(zoomTableColumnName + ", ");
                        }
                    } else {
                        zoomTableColumnName = zoomTable.getTableName() + "_ID";
                    }
                }
            }
        }
        int i = 0;
        for (MBrowseField field : fieldList) {
            if (i != 0) {
                sqlQuery = sqlQuery.append(", ");
            }
            // creating column and preparing sql query with db column names
            column[i] = new Column(field.getName(), null, null);
            StringBuffer columnWhereClause = new StringBuffer("AD_View_Column_ID = " + field.getAD_View_Column_ID());
            MViewColumn viewColumn = new Query(Env.getCtx(), I_AD_View_Column.Table_Name, columnWhereClause.toString(), null).setOnlyActiveRecords(true).first();
            sqlQuery = sqlQuery.append(viewColumn.getColumnName().replaceFirst("_", "."));
            i = i + 1;
        }
    }
    whereClause = new StringBuffer("AD_Browse_ID= " + browseId);
    MBrowse browse = new Query(Env.getCtx(), I_AD_Browse.Table_Name, whereClause.toString(), null).setOnlyActiveRecords(true).first();
    if (browse != null) {
        whereClause = new StringBuffer("AD_View_ID= " + browse.getAD_View_ID());
        List<MViewDefinition> list = new Query(Env.getCtx(), I_AD_View_Definition.Table_Name, whereClause.toString(), null).setOnlyActiveRecords(true).list();
        whereClause = new StringBuffer(X_AD_View_Definition.COLUMNNAME_AD_Table_ID + " = " + list.get(0).getAD_Table_ID());
        table = new Query(Env.getCtx(), I_AD_Table.Table_Name, whereClause.toString(), null).setOnlyActiveRecords(true).first();
        StringBuffer joinClause = new StringBuffer();
        for (MViewDefinition viewDefinition : list) {
            if (viewDefinition.getJoinClause() == null)
                joinClause.append(" " + viewDefinition.getTableAlias());
            else
                joinClause.append(" " + viewDefinition.getJoinClause());
        }
        // Associating sql query with table name 
        sqlQuery.append(" FROM " + table.getTableName()).append(joinClause.toString());
        //get where clause of this Smart Browse
        String where = browse.getWhereClause();
        if (where != null) {
            boolean success = true;
            do {
                int index = where.indexOf("@");
                int index2 = where.indexOf("@", index + 1);
                boolean integer = false;
                int replacedValue = 0;
                String replacedString = null;
                if (index > 0 || index2 > 0) {
                    String subString1 = where.substring(index + 1, index2);
                    if (subString1.contains("#")) {
                        if (subString1.endsWith("_ID")) {
                            replacedValue = Env.getContextAsInt(ctx, subString1);
                            integer = true;
                        } else {
                            replacedString = Env.getContext(ctx, subString1);
                        }
                        if (integer) {
                            where = where.replaceAll(where.substring(index, index2 + 1), String.valueOf(replacedValue));
                        } else {
                            where = where.replaceAll(where.substring(index, index2 + 1), "'" + replacedString + "'");
                        }
                    } else {
                        where = where.replaceAll(where.substring(index, index2 + 1), where.substring(index + 1, index2));
                    }
                    success = true;
                } else {
                    success = false;
                }
            } while (success);
            sqlQuery.append(" Where " + where);
        }
    }
    return sqlQuery.toString();
}
Also used : MBrowseField(org.adempiere.model.MBrowseField) MQuery(org.compiere.model.MQuery) Query(org.compiere.model.Query) I_AD_View_Column(org.adempiere.model.I_AD_View_Column) MViewColumn(org.adempiere.model.MViewColumn) Column(org.zkoss.zul.Column) MViewDefinition(org.adempiere.model.MViewDefinition) MBrowse(org.adempiere.model.MBrowse) MViewColumn(org.adempiere.model.MViewColumn)

Example 5 with MBrowse

use of org.adempiere.model.MBrowse in project adempiere by adempiere.

the class TabbedDesktop method openBrowse.

public CustomForm openBrowse(int browseId, Boolean isSOTrx) {
    MBrowse browse = new MBrowse(Env.getCtx(), browseId, null);
    CustomForm ff = WBrowser.openBrowse(0, browseId, "", isSOTrx);
    DesktopTabpanel tabPanel = new DesktopTabpanel();
    ff.setParent(tabPanel);
    preOpenNewTab();
    windowContainer.addWindow(tabPanel, browse.getTitle(), true);
    return ff;
}
Also used : CustomForm(org.adempiere.webui.panel.CustomForm) DesktopTabpanel(org.adempiere.webui.component.DesktopTabpanel) MBrowse(org.adempiere.model.MBrowse)

Aggregations

MBrowse (org.adempiere.model.MBrowse)16 MBrowseField (org.adempiere.model.MBrowseField)6 FormFrame (org.compiere.apps.form.FormFrame)4 ProcessInfo (org.compiere.process.ProcessInfo)4 AdempiereException (org.adempiere.exceptions.AdempiereException)3 MViewColumn (org.adempiere.model.MViewColumn)3 I_AD_View_Column (org.adempiere.model.I_AD_View_Column)2 CommandReceiver (org.adempiere.pos.command.CommandReceiver)2 CustomForm (org.adempiere.webui.panel.CustomForm)2 ICreateFrom (org.compiere.grid.ICreateFrom)2 GridTab (org.compiere.model.GridTab)2 MBPartner (org.compiere.model.MBPartner)2 MColumn (org.compiere.model.MColumn)2 MProcess (org.compiere.model.MProcess)2 MRole (org.compiere.model.MRole)2 Query (org.compiere.model.Query)2 VBrowser (org.eevolution.form.VBrowser)2 WBrowser (org.eevolution.form.WBrowser)2 Dimension (java.awt.Dimension)1 Point (java.awt.Point)1