⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 omserviceimpl2.java

📁 EOS的一个很好的例子.包括页面构件、展现构件
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
    public RoleParticipant[] queryRoles(Element criteria) throws WFOMException {
        return null;
    }

    /**
     * implement this method later
     */
    public OrganizationParticipant[] queryOrgs(Element criteria)
            throws WFOMException {
        return null;
    }

    private ArrayList executeGetOrgByPerson(String userID)
    		throws WFOMException {
    	
    	if (userID == null || userID.equals(""))
    		return new ArrayList();
    	
    	String sqlStr = "select o.orgID, o.orgName, o.orgSEQ from EOSOperator a, EOSORG_T_Employee b, EOSORG_T_Organization o " +
    			"where a.operatorID = b.operatorID and b.orgID = o.orgID and a.userID=? ";
        Connection conn = null;
        DataAccessService das = ServiceFactory.getDataAccessService();
        PreparedStatement prst = null;
        ResultSet rs = null;
        PersistenceBroker broker = null;
        ArrayList partiList = new ArrayList();
        try {
            broker = getOrgBroker();
            conn = broker.getConnection();
            prst = conn.prepareStatement(sqlStr);
            prst.setString(1, userID);
            rs = prst.executeQuery();
            String orgId = "", orgName = "", orgSeq = "";
            while (rs.next()) {
                OrganizationParticipant parti = new OrganizationParticipant();
                orgId = String.valueOf(rs.getInt(1));
                orgName = rs.getString(2);
                orgSeq = rs.getString(3);
                parti.setID(orgId);
                parti.setName(orgName);
                parti
                        .setType(DefineConst.PARTICIPANTINFO_PARTICIPANTLIST_TYPE_ORGANIZATION);
                partiList.add(parti);
                break;
            }
            rs.close();
            rs = null;
            prst.close();
            prst = null;
            StringBuffer buff = new StringBuffer("");
            if (orgSeq != null && !orgSeq.equals("")) {
            	String s[] = orgSeq.split("\\.");
            	for (int i=1; i<s.length - 1; i++) {
            		if (!s[i].equals("") && !s[i].equals(".")) {
            			if (!(buff.toString().equals("")))
            				buff.append(",");
            			buff.append(s[i]);
            		}
            		
            	}
            	if (!(buff.toString().equals(""))) {
            		sqlStr = "select o.orgID, o.orgName from EOSORG_T_Organization o where orgID in (" + buff.toString() + ")";
            		prst = conn.prepareStatement(sqlStr);
            		rs = prst.executeQuery();
            		while (rs.next()) {
                        OrganizationParticipant parti = new OrganizationParticipant();
                        orgId = String.valueOf(rs.getInt(1));
                        orgName = rs.getString(2);
                        parti.setID(orgId);
                        parti.setName(orgName);
                        parti.setType(DefineConst.PARTICIPANTINFO_PARTICIPANTLIST_TYPE_ORGANIZATION);
                        partiList.add(parti);
            		}
            		rs.close();
            		rs = null;
            		prst.close();
            		prst = null;
            	}
            }

        } catch (DataAccessException e) {
            throw new WFOMException(e.getMessage());
        } catch (SQLException e) {
            throw new WFOMException(e.getMessage());
        } catch (DataServiceException e) {
            throw new WFOMException(e.getMessage());
        } finally {
            try {
                if (rs != null)
                    rs.close();
                if (prst != null)
                	prst.close();
                if (conn != null)
                    conn.close();
                if (broker != null)
                    broker.close();
            } catch (SQLException e2) {
                throw new WFOMException(e2.getMessage());
            } catch (DataServiceException e) {
                throw new WFOMException(e.getMessage());
            }

        }
        return partiList;
    }
    /**
     * @param sqlStr
     * @return @throws
     *         WFOMException
     */
    private ArrayList executeQueryPosition(String sqlStr, String para1)
            throws WFOMException {
        Connection conn = null;
        DataAccessService das = ServiceFactory.getDataAccessService();
        PreparedStatement prst = null;
        ResultSet rs = null;
        PersistenceBroker broker = null;
        ArrayList partiList = new ArrayList();
        try {
            broker = getOrgBroker();
            conn = broker.getConnection();
            prst = conn.prepareStatement(sqlStr);
            prst.setString(1, para1);
            rs = prst.executeQuery();
            int i = 0;
            while (rs.next()) {
                PositionParticipant parti = new PositionParticipant();
                parti.setID(String.valueOf(rs.getInt(1)));
                parti.setName(rs.getString(2));
                //                parti.setATTR_POSITIONFULLNAME(rs.getString(3));
                //                parti.setATTR_ORGID(rs.getString(4));
                //                parti.setATTR_MANAGERPOSI(rs.getString(5));
                //                parti.setATTR_GRADE(rs.getString(6));
                parti
                        .setType(DefineConst.PARTICIPANTINFO_PARTICIPANTLIST_TYPE_POSITION);
                partiList.add(i, parti);
                i++;
            }

        } catch (DataAccessException e) {
            throw new WFOMException(e.getMessage());
        } catch (SQLException e) {
            throw new WFOMException(e.getMessage());
        } catch (DataServiceException e) {
            throw new WFOMException(e.getMessage());
        } finally {
            try {
                if (rs != null)
                    rs.close();
                if (prst != null)
                	prst.close();
                if (conn != null)
                    conn.close();
                if (broker != null)
                    broker.close();
            } catch (SQLException e2) {
                throw new WFOMException(e2.getMessage());
            } catch (DataServiceException e) {
                throw new WFOMException(e.getMessage());
            }

        }
        return partiList;
    }

    /**
     * @throws WFOMException
     *  
     */
    private PositionParticipant[] queryPositionTypeOR(String orgID,
            String roleID) throws WFOMException {
        if (orgID == null || orgID == "")
            throw new WFOMException("orgID is null!");
        if (roleID == null || roleID == "")
            throw new WFOMException("roleID is null!");
        String[] orgids = orgID.split(",");
        String orgIDStr = null;
        for (int i = 0; i < orgids.length; i++) {
            if (!StringUtil.isNum(orgids[i])) {
                throw new WFOMException("orgID is not number splited by [,]");
            }
        }

        int num = orgids.length;
        String orgsCond = "";
        for (int i = 0; i < num - 1; i++) {
            orgsCond += "?,";
        }
        orgsCond += "?";
        String sql = "select * from EOSORG_T_POSITION where ORGID in("
                + orgsCond
                + ") and positionID in(select positionID from EOSORG_T_POSITIONROLE where roleID=?)";

        Connection conn = null;
        DataAccessService das = ServiceFactory.getDataAccessService();
        PreparedStatement prst = null;
        ResultSet rs = null;
        PersistenceBroker broker = null;
        ArrayList partiList = new ArrayList();
        try {
            broker = getOrgBroker();
            conn = broker.getConnection();
            prst = conn.prepareStatement(sql);
            //if input orgID which splited by comma, it'll throw exception [invalid numble]
            for (int i = 1; i <= num; i++) {
                prst.setString(i, orgids[i-1]);
            }
            prst.setString(num+1, roleID);
            rs = prst.executeQuery();
            int i = 0;
            while (rs.next()) {
                PositionParticipant parti = new PositionParticipant();
                parti.setID(String.valueOf(rs.getInt(1)));
                parti.setName(rs.getString(2));
                parti
                        .setType(DefineConst.PARTICIPANTINFO_PARTICIPANTLIST_TYPE_POSITION);
                partiList.add(i, parti);
                i++;
            }

        } catch (DataAccessException e) {
            throw new WFOMException(e.getMessage());
        } catch (SQLException e) {
            throw new WFOMException(e.getMessage());
        } catch (DataServiceException e) {
            throw new WFOMException(e.getMessage());
        } finally {
            try {
                if (rs != null)
                    rs.close();
                if (prst != null)
                	prst.close();
                if (conn != null)
                    conn.close();
                if (broker != null)
                    broker.close();
            } catch (SQLException e2) {
                throw new WFOMException(e2.getMessage());
            } catch (DataServiceException e) {
                throw new WFOMException(e.getMessage());
            }

        }

        PositionParticipant[] ret = new PositionParticipant[partiList.size()];
        for (int i = 0; i < ret.length; i++) {
            ret[i] = (PositionParticipant) partiList.get(i);
        }
        return ret;
    }

	private static PersistenceBroker getOrgBroker() throws DataAccessException {
		EOSParameter para = new EOSParameter();
		para.setUnitName("fborg");
		para.setUnitId("0");
		PersistenceBroker broker = null;
		try {
			broker = para.getDBBroker();
		} catch (DBManagerException e) {
			e.printStackTrace();
			throw new DataAccessException(e.getMessage());
		} catch (ProcessException e) {
			e.printStackTrace();
			throw new DataAccessException(e.getMessage());
		}
		return broker;
	}
	
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -