Search in sources :

Example 11 with MRole

use of org.compiere.model.MRole in project adempiere by adempiere.

the class GridSynchronizer method stateChange.

/**
	 * @param event
	 */
public void stateChange(StateChangeEvent event) {
    MRole role = MRole.getDefault();
    child.query(false, 0, role.getMaxQueryRecords());
}
Also used : MRole(org.compiere.model.MRole)

Example 12 with MRole

use of org.compiere.model.MRole in project adempiere by adempiere.

the class APanel method actionButton.

/**************************************************************************
	 *	Start Button Process
	 *  @param vButton button
	 */
protected void actionButton(VButton vButton) {
    log.info(vButton.toString());
    if (m_curTab.hasChangedCurrentTabAndParents()) {
        String msg = CLogger.retrieveErrorString("Please ReQuery Window");
        ADialog.error(m_curWindowNo, this, null, msg);
        return;
    }
    boolean startWOasking = false;
    //		boolean batch = false;
    String col = vButton.getColumnName();
    //  Zoom
    if (col.equals("Record_ID")) {
        int AD_Table_ID = Env.getContextAsInt(m_ctx, m_curWindowNo, "AD_Table_ID");
        int Record_ID = Env.getContextAsInt(m_ctx, m_curWindowNo, "Record_ID");
        AEnv.zoom(AD_Table_ID, Record_ID);
        return;
    }
    //  save first	---------------
    if (m_curTab.needSave(true, false))
        if (!cmd_save(true))
            return;
    // Save included tabs if necessary - teo_sarca BF [ 2876892 ]
    for (GridTab includedTab : m_curTab.getIncludedTabs()) {
        if (includedTab.needSave(true, false))
            if (!includedTab.dataSave(true))
                return;
    }
    //
    int table_ID = m_curTab.getAD_Table_ID();
    //	Record_ID
    int record_ID = m_curTab.getRecord_ID();
    //	Record_ID - Language Handling
    if (record_ID == -1 && m_curTab.getKeyColumnName().equals("AD_Language"))
        record_ID = Env.getContextAsInt(m_ctx, m_curWindowNo, "AD_Language_ID");
    //	Record_ID - Change Log ID
    if (record_ID == -1 && (vButton.getProcess_ID() == 306 || vButton.getProcess_ID() == 307)) {
        Integer id = (Integer) m_curTab.getValue("AD_ChangeLog_ID");
        record_ID = id.intValue();
    }
    //	Ensure it's saved
    if (record_ID == -1 && m_curTab.getKeyColumnName().endsWith("_ID")) {
        ADialog.error(m_curWindowNo, this, "SaveErrorRowNotFound");
        return;
    }
    boolean isProcessMandatory = false;
    //	Pop up Payment Rules
    if (col.equals("PaymentRule")) {
        VPayment vp = new VPayment(m_curWindowNo, m_curTab, vButton);
        if (//	may not be allowed
        vp.isInitOK())
            vp.setVisible(true);
        vp.dispose();
        if (vp.needSave()) {
            cmd_save(false);
            cmd_refresh();
        }
    } else //	Pop up Document Action (Workflow)
    if (col.equals("DocAction")) {
        isProcessMandatory = true;
        VDocAction vda = new VDocAction(m_curWindowNo, m_curTab, vButton, record_ID);
        //	Something to select from?
        if (vda.getNumberOfOptions() == 0) {
            vda.dispose();
            log.info("DocAction - No Options");
            return;
        } else {
            vda.setVisible(true);
            if (!vda.isStartProcess())
                return;
            //				batch = vda.isBatch();
            startWOasking = true;
            vda.dispose();
        }
    } else //  Pop up Create From
    if (col.equals("CreateFrom")) {
        // Run form only if the button has no process defined - teo_sarca [ 1974354 ]
        if (vButton.getProcess_ID() <= 0) {
            ICreateFrom cf = VCreateFromFactory.create(m_curTab);
            if (cf != null) {
                if (cf.isInitOK()) {
                    cf.showWindow();
                    cf.closeWindow();
                    m_curTab.dataRefresh();
                } else
                    cf.closeWindow();
                return;
            }
        //	else may start process
        }
    } else //  Posting -----
    if (col.equals("Posted") && MRole.getDefault().isShowAcct()) {
        //  Check Doc Status
        String processed = Env.getContext(m_ctx, m_curWindowNo, "Processed");
        if (!processed.equals("Y")) {
            String docStatus = Env.getContext(m_ctx, m_curWindowNo, "DocStatus");
            if (DocAction.STATUS_Completed.equals(docStatus) || DocAction.STATUS_Closed.equals(docStatus) || DocAction.STATUS_Reversed.equals(docStatus) || DocAction.STATUS_Voided.equals(docStatus))
                ;
            else {
                ADialog.error(m_curWindowNo, this, "PostDocNotComplete");
                return;
            }
        }
        // try to get table and record id from context data (eg for unposted view)
        // otherwise use current table/record
        int tableId = Env.getContextAsInt(m_ctx, m_curWindowNo, "AD_Table_ID", true);
        int recordId = Env.getContextAsInt(m_ctx, m_curWindowNo, "Record_ID", true);
        if (tableId == 0 || recordId == 0) {
            tableId = m_curTab.getAD_Table_ID();
            recordId = m_curTab.getRecord_ID();
        }
        //  Check Post Status
        Object ps = m_curTab.getValue("Posted");
        if (ps != null && ps.equals("Y")) {
            new org.compiere.acct.AcctViewer(Env.getContextAsInt(m_ctx, m_curWindowNo, "AD_Client_ID"), tableId, recordId);
        } else {
            if (ADialog.ask(m_curWindowNo, this, "PostImmediate?")) {
                //	force when problems
                boolean force = ps != null && !ps.equals("N");
                String error = AEnv.postImmediate(m_curWindowNo, Env.getAD_Client_ID(m_ctx), tableId, recordId, force);
                if (error != null)
                    ADialog.error(m_curWindowNo, this, "PostingError-N", error);
                cmd_refresh();
            }
        }
        return;
    }
    //  Posted
    /**
		 *  Start Process ----
		 *  or invoke user form
		 */
    log.config("Process_ID=" + vButton.getProcess_ID() + ", Record_ID=" + record_ID);
    if (vButton.getProcess_ID() == 0) {
        if (isProcessMandatory) {
            ADialog.error(m_curWindowNo, this, null, Msg.parseTranslation(m_ctx, "@NotFound@ @AD_Process_ID@"));
        }
        return;
    }
    //	Save item changed
    if (m_curTab.needSave(true, false))
        if (!cmd_save(true))
            return;
    // call form
    MProcess pr = new MProcess(m_ctx, vButton.getProcess_ID(), null);
    //	Validate Access
    MRole role = MRole.getDefault(m_ctx, false);
    Boolean accessRW = role.checkProcessAccess(pr.getAD_Process_ID());
    if (accessRW == null || !accessRW.booleanValue()) {
        ADialog.error(m_curWindowNo, this, null, Msg.parseTranslation(m_ctx, "@AccessCannotProcess@"));
        return;
    }
    //	
    int form_ID = pr.getAD_Form_ID();
    if (form_ID != 0) {
        if (m_curTab.needSave(true, false))
            if (!cmd_save(true))
                return;
        //	Yamel Senih FR [ 114 ] 2015-11-23 Add Support to Dialog for create from
        FormFrame ff = new FormFrame(getWindowNo());
        String title = vButton.getDescription();
        if (title == null || title.length() == 0)
            title = vButton.getName();
        ProcessInfo pi = new ProcessInfo(title, vButton.getProcess_ID(), table_ID, record_ID);
        pi.setAD_User_ID(Env.getAD_User_ID(m_ctx));
        pi.setAD_Client_ID(Env.getAD_Client_ID(m_ctx));
        ff.setProcessInfo(pi);
        ff.openForm(form_ID);
        ff.pack();
        AEnv.showCenterScreen(ff);
        //	Refresh
        m_curTab.dataRefresh();
        //	End Yamel Senih
        return;
    }
    int browse_ID = pr.getAD_Browse_ID();
    if (browse_ID != 0) {
        if (m_curTab.needSave(true, false))
            if (!cmd_save(true))
                return;
        String title = vButton.getDescription();
        if (title == null || title.length() == 0)
            title = vButton.getName();
        ProcessInfo pi = new ProcessInfo(title, vButton.getProcess_ID(), table_ID, record_ID);
        pi.setAD_User_ID(Env.getAD_User_ID(m_ctx));
        pi.setAD_Client_ID(Env.getAD_Client_ID(m_ctx));
        FormFrame ff = new FormFrame(getWindowNo());
        ff.setProcessInfo(pi);
        MBrowse browse = new MBrowse(Env.getCtx(), browse_ID, null);
        new VBrowser(ff, true, getWindowNo(), "", browse, "", true, "", Env.isSOTrx(Env.getCtx(), m_curWindowNo));
        ff.pack();
        AEnv.showCenterScreen(ff);
        //	Yamel Senih
        //	Refresh
        m_curTab.dataRefresh();
        return;
    } else {
        ProcessModalDialog dialog = new ProcessModalDialog(m_ctx, Env.getWindow(m_curWindowNo), Env.getHeader(m_ctx, m_curWindowNo), this, m_curWindowNo, vButton.getProcess_ID(), table_ID, record_ID, startWOasking);
        //	BR [ 323 ]
        if (!startWOasking) {
            dialog.validate();
            dialog.pack();
            AEnv.showCenterWindow(Env.getWindow(m_curWindowNo), dialog);
        }
    }
}
Also used : VDocAction(org.compiere.grid.ed.VDocAction) MProcess(org.compiere.model.MProcess) FormFrame(org.compiere.apps.form.FormFrame) MRole(org.compiere.model.MRole) VPayment(org.compiere.grid.VPayment) ProcessInfo(org.compiere.process.ProcessInfo) MBrowse(org.adempiere.model.MBrowse) Point(java.awt.Point) VBrowser(org.eevolution.form.VBrowser) ICreateFrom(org.compiere.grid.ICreateFrom) GridTab(org.compiere.model.GridTab)

Example 13 with MRole

use of org.compiere.model.MRole in project adempiere by adempiere.

the class AEnv method actionPerformed.

//  addMenuItem
/**
	 *  Perform action command for common menu items.
	 * 	Created in AMenu.createMenu(), APanel.createMenu(), FormFrame.createMenu()
	 *  @param actionCommand known action command
	 *  @param WindowNo window no
	 *  @param c Container parent
	 *  @return true if actionCommand was found and performed
	 */
public static boolean actionPerformed(String actionCommand, int WindowNo, Container c) {
    MRole role = MRole.getDefault();
    //  File Menu   ------------------------
    if (actionCommand.equals("PrintScreen")) {
        PrintScreenPainter.printScreen(Env.getFrame(c));
    } else if (actionCommand.equals("ScreenShot")) {
        ScreenShot.createJPEG(Env.getFrame(c), null);
    } else //	}
    if (actionCommand.equals("Exit")) {
        if (ADialog.ask(WindowNo, c, "ExitApplication?")) {
            AMenu aMenu = (AMenu) Env.getWindow(0);
            aMenu.dispose();
        }
    } else if (actionCommand.equals("Logout")) {
        AMenu aMenu = (AMenu) Env.getWindow(0);
        aMenu.logout();
    } else //  View Menu   ------------------------
    if (actionCommand.equals("InfoProduct") && AEnv.canAccessInfo("PRODUCT")) {
        org.compiere.apps.search.Info.showProduct(Env.getFrame(c), WindowNo);
    } else if (actionCommand.equals("InfoBPartner") && AEnv.canAccessInfo("BPARTNER")) {
        org.compiere.apps.search.Info.showBPartner(Env.getFrame(c), WindowNo);
    } else if (actionCommand.equals("InfoAsset") && AEnv.canAccessInfo("ASSET")) {
        org.compiere.apps.search.Info.showAsset(Env.getFrame(c), WindowNo);
    } else if (actionCommand.equals("InfoAccount") && MRole.getDefault().isShowAcct() && AEnv.canAccessInfo("ACCOUNT")) {
        new org.compiere.acct.AcctViewer();
    } else if (actionCommand.equals("InfoSchedule") && AEnv.canAccessInfo("SCHEDULE")) {
        new org.compiere.apps.search.InfoSchedule(Env.getFrame(c), null, false);
    } else //FR [ 1966328 ] 
    if (actionCommand.equals("InfoMRP") && AEnv.canAccessInfo("MRP")) {
        CFrame frame = (CFrame) Env.getFrame(c);
        int m_menu_id = MMenu.getMenu_ID("MRP Info");
        AMenu menu = AEnv.getAMenu(frame);
        //	async load
        AMenuStartItem form = new AMenuStartItem(m_menu_id, true, Msg.translate(Env.getCtx(), "MRP Info"), menu);
        form.start();
    } else if (actionCommand.equals("InfoCRP") && AEnv.canAccessInfo("CRP")) {
        CFrame frame = (CFrame) Env.getFrame(c);
        int m_menu_id = MMenu.getMenu_ID("CRP Info");
        AMenu menu = AEnv.getAMenu(frame);
        //	async load
        AMenuStartItem form = new AMenuStartItem(m_menu_id, true, Msg.translate(Env.getCtx(), "CRP Info"), menu);
        form.start();
    } else if (actionCommand.equals("InfoOrder") && AEnv.canAccessInfo("ORDER")) {
        org.compiere.apps.search.Info.showOrder(Env.getFrame(c), WindowNo, "");
    } else if (actionCommand.equals("InfoInvoice") && AEnv.canAccessInfo("INVOICE")) {
        org.compiere.apps.search.Info.showInvoice(Env.getFrame(c), WindowNo, "");
    } else if (actionCommand.equals("InfoInOut") && AEnv.canAccessInfo("INOUT")) {
        org.compiere.apps.search.Info.showInOut(Env.getFrame(c), WindowNo, "");
    } else if (actionCommand.equals("InfoPayment") && AEnv.canAccessInfo("PAYMENT")) {
        org.compiere.apps.search.Info.showPayment(Env.getFrame(c), WindowNo, "");
    } else if (actionCommand.equals("InfoCashLine") && AEnv.canAccessInfo("CASHJOURNAL")) {
        org.compiere.apps.search.Info.showCashLine(Env.getFrame(c), WindowNo, "");
    } else if (actionCommand.equals("InfoAssignment") && AEnv.canAccessInfo("RESOURCE")) {
        org.compiere.apps.search.Info.showAssignment(Env.getFrame(c), WindowNo, "");
    } else //  Go Menu     ------------------------
    if (actionCommand.equals("WorkFlow")) {
        startWorkflowProcess(0, 0);
    } else if (actionCommand.equals("Home")) {
        showWindow(Env.getWindow(0));
    } else //  Tools Menu  ------------------------
    if (actionCommand.equals("Calculator")) {
        Calculator calc = new org.compiere.grid.ed.Calculator(Env.getFrame(c));
        calc.setDisposeOnEqual(false);
        AEnv.showCenterScreen(calc);
    } else if (actionCommand.equals("Calendar")) {
        AEnv.showCenterScreen(new org.compiere.grid.ed.Calendar(Env.getFrame(c)));
    } else if (actionCommand.equals("Editor")) {
        AEnv.showCenterScreen(new org.compiere.grid.ed.Editor(Env.getFrame(c)));
    } else if (actionCommand.equals("Script")) {
        new BeanShellEditor(Env.getFrame(c));
    } else if (actionCommand.equals("Preference")) {
        if (role.isShowPreference()) {
            AEnv.showCenterScreen(new Preference(Env.getFrame(c), WindowNo));
        }
    } else //  Help Menu   ------------------------
    if (actionCommand.equals("Online")) {
        Env.startBrowser(org.compiere.Adempiere.getOnlineHelpURL());
    } else if (actionCommand.equals("EMailSupport")) {
        ADialog.createSupportEMail(Env.getFrame(c), Env.getFrame(c).getTitle(), "\n\n");
    } else if (actionCommand.equals("About")) {
        AEnv.showCenterScreen(new AboutBox(Env.getFrame(c)));
    } else
        return false;
    //
    return true;
}
Also used : MRole(org.compiere.model.MRole) Calculator(org.compiere.grid.ed.Calculator) CFrame(org.compiere.swing.CFrame) Calculator(org.compiere.grid.ed.Calculator)

Example 14 with MRole

use of org.compiere.model.MRole in project adempiere by adempiere.

the class RoleElementHandler 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 name = atts.getValue("Name");
    int id = get_ID(ctx, "AD_Role", name);
    MRole m_Role = new MRole(ctx, id, getTrxName(ctx));
    int AD_Backup_ID = -1;
    String Object_Status = null;
    if (id <= 0 && atts.getValue("AD_Role_ID") != null && Integer.parseInt(atts.getValue("AD_Role_ID")) <= PackOut.MAX_OFFICIAL_ID)
        m_Role.setAD_Role_ID(Integer.parseInt(atts.getValue("AD_Role_ID")));
    if (id > 0) {
        AD_Backup_ID = copyRecord(ctx, "AD_Role", m_Role);
        Object_Status = "Update";
    } else {
        Object_Status = "New";
        AD_Backup_ID = 0;
    }
    m_Role.setName(name);
    name = atts.getValue("treemenuname");
    if (name != null && name.trim().length() > 0) {
        id = get_IDWithColumn(ctx, "AD_Tree", "Name", name);
        if (id <= 0) {
            element.defer = true;
            return;
        }
        m_Role.setAD_Tree_Menu_ID(id);
    }
    name = atts.getValue("treeorgname");
    if (name != null && name.trim().length() > 0) {
        id = get_IDWithColumn(ctx, "AD_Tree", "Name", name);
        if (id <= 0) {
            element.defer = true;
            return;
        }
        m_Role.setAD_Tree_Org_ID(id);
    }
    name = atts.getValue("currencycode");
    if (name != null && name.trim().length() > 0) {
        id = get_IDWithColumn(ctx, "C_Currency", "ISO_Code", name);
        if (id <= 0) {
            element.defer = true;
            return;
        }
        m_Role.setC_Currency_ID(id);
    }
    name = atts.getValue("supervisorid");
    if (name != null && name.trim().length() > 0) {
        id = get_IDWithColumn(ctx, "AD_User", "Name", name);
        if (id <= 0) {
            element.defer = true;
            return;
        }
        m_Role.setC_Currency_ID(id);
    }
    m_Role.setDescription(getStringValue(atts, "Description"));
    String amtApproval = getStringValue(atts, "AmtApproval");
    if (amtApproval != null)
        m_Role.setAmtApproval(new BigDecimal(amtApproval));
    m_Role.setIsActive(atts.getValue("isActive") != null ? Boolean.valueOf(atts.getValue("isActive")).booleanValue() : true);
    m_Role.setIsAccessAllOrgs(atts.getValue("isAccessAllOrgs") != null ? Boolean.valueOf(atts.getValue("isAccessAllOrgs")).booleanValue() : true);
    m_Role.setIsCanApproveOwnDoc(atts.getValue("isCanApproveOwnDoc") != null ? Boolean.valueOf(atts.getValue("isCanApproveOwnDoc")).booleanValue() : true);
    m_Role.setIsCanExport(atts.getValue("isCanExport") != null ? Boolean.valueOf(atts.getValue("isCanExport")).booleanValue() : true);
    m_Role.setIsCanReport(atts.getValue("isCanReport") != null ? Boolean.valueOf(atts.getValue("isCanReport")).booleanValue() : true);
    m_Role.setIsChangeLog(atts.getValue("isChangeLog") != null ? Boolean.valueOf(atts.getValue("isChangeLog")).booleanValue() : true);
    m_Role.setIsManual(atts.getValue("isManual") != null ? Boolean.valueOf(atts.getValue("isManual")).booleanValue() : true);
    m_Role.setIsPersonalAccess(atts.getValue("isPersonalAccess") != null ? Boolean.valueOf(atts.getValue("isPersonalAccess")).booleanValue() : true);
    m_Role.setIsPersonalLock(atts.getValue("isPersonalLock") != null ? Boolean.valueOf(atts.getValue("isPersonalLock")).booleanValue() : true);
    m_Role.setIsShowAcct(atts.getValue("isShowAcct") != null ? Boolean.valueOf(atts.getValue("isShowAcct")).booleanValue() : true);
    m_Role.setIsUseUserOrgAccess(atts.getValue("isUseUserOrgAccess") != null ? Boolean.valueOf(atts.getValue("isUseUserOrgAccess")).booleanValue() : true);
    m_Role.setOverwritePriceLimit(atts.getValue("isOverwritePriceLimit") != null ? Boolean.valueOf(atts.getValue("isOverwritePriceLimit")).booleanValue() : true);
    m_Role.setPreferenceType(atts.getValue("PreferenceType"));
    m_Role.setUserLevel(atts.getValue("UserLevel"));
    m_Role.setAllow_Info_Account(Boolean.valueOf(atts.getValue("AllowInfoAccount")));
    m_Role.setAllow_Info_Asset(Boolean.valueOf(atts.getValue("AllowInfoAsset")));
    m_Role.setAllow_Info_BPartner(Boolean.valueOf(atts.getValue("AllowInfoBPartner")));
    m_Role.setAllow_Info_CashJournal(Boolean.valueOf(atts.getValue("AllowInfoCashJournal")));
    m_Role.setAllow_Info_InOut(Boolean.valueOf(atts.getValue("AllowInfoInOut")));
    m_Role.setAllow_Info_Invoice(Boolean.valueOf(atts.getValue("AllowInfoInvoice")));
    m_Role.setAllow_Info_Order(Boolean.valueOf(atts.getValue("AllowInfoOrder")));
    m_Role.setAllow_Info_Payment(Boolean.valueOf(atts.getValue("AllowInfoPayment")));
    m_Role.setAllow_Info_Product(Boolean.valueOf(atts.getValue("AllowInfoProduct")));
    m_Role.setAllow_Info_Resource(Boolean.valueOf(atts.getValue("AllowInfoResource")));
    m_Role.setAllow_Info_Schedule(Boolean.valueOf(atts.getValue("AllowInfoSchedule")));
    m_Role.setAllow_Info_Schedule(Boolean.valueOf(atts.getValue("AllowInfoCRP")));
    m_Role.setAllow_Info_Schedule(Boolean.valueOf(atts.getValue("AllowInfoMRP")));
    if (m_Role.save(getTrxName(ctx)) == true) {
        record_log(ctx, 1, m_Role.getName(), "Role", m_Role.get_ID(), AD_Backup_ID, Object_Status, "AD_Role", get_IDWithColumn(ctx, "AD_Table", "TableName", "AD_Role"));
    } else {
        record_log(ctx, 0, m_Role.getName(), "Role", m_Role.get_ID(), AD_Backup_ID, Object_Status, "AD_Role", get_IDWithColumn(ctx, "AD_Table", "TableName", "AD_Role"));
        throw new POSaveFailedException("Role");
    }
}
Also used : MRole(org.compiere.model.MRole) Attributes(org.xml.sax.Attributes) POSaveFailedException(org.adempiere.pipo.exception.POSaveFailedException) BigDecimal(java.math.BigDecimal)

Example 15 with MRole

use of org.compiere.model.MRole in project adempiere by adempiere.

the class WFActivity method loadActivities.

/**
	 * 	Load Activities
	 * 	@return int
	 */
public int loadActivities() {
    resetDisplay(null);
    while (selTableModel.getRowCount() > 0) selTableModel.removeRow(0);
    long start = System.currentTimeMillis();
    ArrayList<MWFActivity> list = new ArrayList<MWFActivity>();
    String sql = "SELECT * FROM AD_WF_Activity a " + "WHERE a.Processed='N' AND a.WFState='OS' AND (" + //	Owner of Activity
    " a.AD_User_ID=?" + //	Invoker (if no invoker = all)
    " OR EXISTS (SELECT * FROM AD_WF_Responsible r WHERE a.AD_WF_Responsible_ID=r.AD_WF_Responsible_ID" + //	#2
    " AND COALESCE(r.AD_User_ID,0)=0 AND COALESCE(r.AD_Role_ID,0)=0 AND (a.AD_User_ID=? OR a.AD_User_ID IS NULL))" + // Responsible User
    " OR EXISTS (SELECT * FROM AD_WF_Responsible r WHERE a.AD_WF_Responsible_ID=r.AD_WF_Responsible_ID" + //	#3
    " AND r.AD_User_ID=?)" + //	Responsible Role
    " OR EXISTS (SELECT * FROM AD_WF_Responsible r INNER JOIN AD_User_Roles ur ON (r.AD_Role_ID=ur.AD_Role_ID)" + //	#4
    " WHERE a.AD_WF_Responsible_ID=r.AD_WF_Responsible_ID AND ur.AD_User_ID=?)" + //
    ") ORDER BY a.Priority DESC, Created";
    int AD_User_ID = Env.getAD_User_ID(Env.getCtx());
    MRole role = MRole.get(Env.getCtx(), Env.getAD_Role_ID(Env.getCtx()));
    sql = role.addAccessSQL(sql, "a", true, false);
    PreparedStatement pstmt = null;
    ResultSet rs = null;
    try {
        pstmt = DB.prepareStatement(sql, null);
        pstmt.setInt(1, AD_User_ID);
        pstmt.setInt(2, AD_User_ID);
        pstmt.setInt(3, AD_User_ID);
        pstmt.setInt(4, AD_User_ID);
        rs = pstmt.executeQuery();
        while (rs.next()) {
            MWFActivity activity = new MWFActivity(Env.getCtx(), rs, null);
            Object[] rowData = new Object[4];
            rowData[0] = new IDColumn(activity.get_ID());
            rowData[1] = activity.getPriority();
            rowData[2] = activity.getNodeName();
            rowData[3] = activity.getSummary();
            selTableModel.addRow(rowData);
            if (list.size() > MAX_ACTIVITIES_IN_LIST) {
                log.warning("More than " + MAX_ACTIVITIES_IN_LIST + " Activities - ignored");
                break;
            }
        }
    } catch (Exception e) {
        log.log(Level.SEVERE, sql, e);
    } finally {
        DB.close(rs, pstmt);
        rs = null;
        pstmt = null;
    }
    selTable.autoSize(false);
    log.fine("#" + selTable.getModel().getRowCount() + "(" + (System.currentTimeMillis() - start) + "ms)");
    return selTable.getModel().getRowCount();
}
Also used : MRole(org.compiere.model.MRole) ArrayList(java.util.ArrayList) PreparedStatement(java.sql.PreparedStatement) MWFActivity(org.compiere.wf.MWFActivity) IDColumn(org.compiere.minigrid.IDColumn) ResultSet(java.sql.ResultSet)

Aggregations

MRole (org.compiere.model.MRole)42 PreparedStatement (java.sql.PreparedStatement)14 ResultSet (java.sql.ResultSet)14 SQLException (java.sql.SQLException)11 ArrayList (java.util.ArrayList)7 Point (java.awt.Point)4 Properties (java.util.Properties)4 BigDecimal (java.math.BigDecimal)3 Statement (java.sql.Statement)3 GridField (org.compiere.model.GridField)3 GridTab (org.compiere.model.GridTab)3 QName (javax.xml.namespace.QName)2 MBrowse (org.adempiere.model.MBrowse)2 XFireFault (org.codehaus.xfire.fault.XFireFault)2 ICreateFrom (org.compiere.grid.ICreateFrom)2 MOrgInfo (org.compiere.model.MOrgInfo)2 MProcess (org.compiere.model.MProcess)2 MTable (org.compiere.model.MTable)2 MWFActivity (org.compiere.wf.MWFActivity)2 ADLoginRequest (pl.x3E.adInterface.ADLoginRequest)2