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

📄 entitypersistentmgr.java

📁 Sequoia ERP是一个真正的企业级开源ERP解决方案。它提供的模块包括:电子商务应用(e-commerce), POS系统(point of sales),知识管理,存货与仓库管理
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
        }        if (Debug.verboseOn()) Debug.log("ProcessMgr : " + createdList.size(), module);        return createdList;    }    public List getResourcesWhere(SharkTransaction trans, String sqlWhere) throws PersistenceException {        if (sqlWhere != null) {            Debug.log("Attempt to call getResourcesWhere() - " + sqlWhere, module);            throw new PersistenceException("Method not available to this implementation! (" + sqlWhere + ")");        }        return this.getAllResources(trans);    }    public List getAllResources(SharkTransaction trans) throws PersistenceException {        if (Debug.verboseOn()) Debug.log(":: getAllResources ::", module);        GenericDelegator delegator = SharkContainer.getDelegator();        List createdList = new ArrayList();        List lookupList = null;        try {            lookupList = delegator.findAll("WfResource");        } catch (GenericEntityException e) {            throw new PersistenceException(e);        }        if (lookupList != null && lookupList.size() > 0) {            Iterator i = lookupList.iterator();            while (i.hasNext()) {                GenericValue v = (GenericValue) i.next();                createdList.add(Resource.getInstance(this, v));            }        }        return createdList;    }    public List getAllAssignments(SharkTransaction trans) throws PersistenceException {        if (Debug.verboseOn()) Debug.log(":: getAllAssignments ::", module);        GenericDelegator delegator = SharkContainer.getDelegator();        List createdList = new ArrayList();        List lookupList = null;        try {            lookupList = delegator.findAll("WfAssignment");        } catch (GenericEntityException e) {            throw new PersistenceException(e);        }        if (lookupList != null && lookupList.size() > 0) {            Iterator i = lookupList.iterator();            while (i.hasNext()) {                GenericValue v = (GenericValue) i.next();                createdList.add(Assignment.getInstance(this, v));            }        }        return createdList;    }    public List getAllProcesses(SharkTransaction trans) throws PersistenceException {        if (Debug.verboseOn()) Debug.log(":: getAllProcesses ::", module);        GenericDelegator delegator = SharkContainer.getDelegator();        List createdList = new ArrayList();        List lookupList = null;        try {            lookupList = delegator.findAll("WfProcess");        } catch (GenericEntityException e) {            throw new PersistenceException(e);        }        if (lookupList != null && lookupList.size() > 0) {            Iterator i = lookupList.iterator();            while (i.hasNext()) {                GenericValue v = (GenericValue) i.next();                createdList.add(Process.getInstance(this, v));            }        }        return createdList;    }    public List getAllActivities(SharkTransaction trans) throws PersistenceException {        if (Debug.verboseOn()) Debug.log(":: getAllActivities ::", module);        GenericDelegator delegator = SharkContainer.getDelegator();        List createdList = new ArrayList();        List lookupList = null;        try {            lookupList = delegator.findAll("WfActivity");        } catch (GenericEntityException e) {            throw new PersistenceException(e);        }        if (lookupList != null && lookupList.size() > 0) {            Iterator i = lookupList.iterator();            while (i.hasNext()) {                GenericValue v = (GenericValue) i.next();                createdList.add(Activity.getInstance(this, v));            }        }        return createdList;    }    public List getAllProcessesForMgr(String mgrName, SharkTransaction trans) throws PersistenceException {        if (Debug.verboseOn()) Debug.log(":: getAllProcessesForMgr ::", module);        return this.getProcessesForMgr(mgrName, null, trans);    }    public List getProcessesForMgr(String mgrName, String state, SharkTransaction trans) throws PersistenceException {        if (Debug.verboseOn()) Debug.log(":: getProcessesForMgr ::", module);        GenericDelegator delegator = SharkContainer.getDelegator();        List createdList = new ArrayList();        List lookupList = null;        Map findBy = UtilMisc.toMap("mgrName", mgrName);        if (state != null) {            findBy.put("currentState", state);        }        try {            lookupList = delegator.findByAnd("WfProcess", findBy);        } catch (GenericEntityException e) {            throw new PersistenceException(e);        }        if (lookupList != null && lookupList.size() > 0) {            Iterator i = lookupList.iterator();            while (i.hasNext()) {                GenericValue v = (GenericValue) i.next();                createdList.add(Process.getInstance(this, v));            }        }        return createdList;    }    public List getAllRunningProcesses(SharkTransaction trans) throws PersistenceException {        GenericDelegator delegator = SharkContainer.getDelegator();        List runningStates = UtilMisc.toList("open.running");        List order = UtilMisc.toList("startedTime");        List createdList = new ArrayList();        List lookupList = null;        try {            lookupList = delegator.findByCondition("WfProcess",                    makeStateListCondition("currentState", runningStates, EntityOperator.EQUALS, EntityOperator.OR), null, order);        } catch (GenericEntityException e) {            throw new PersistenceException(e);        }        if (!UtilValidate.isEmpty(lookupList)) {            Iterator i = lookupList.iterator();            while (i.hasNext()) {                GenericValue v = (GenericValue) i.next();                createdList.add(Process.getInstance(this, v));            }        }        return createdList;    }    protected List findFinishedProcesses(SharkTransaction trans, String packageId, String processDefId, String packageVer, Date finishedBefore) throws PersistenceException {        GenericDelegator delegator = SharkContainer.getDelegator();        List finsihedStates = UtilMisc.toList("closed.completed", "closed.terminated", "closed.aborted");        List order = UtilMisc.toList("lastStateTime");        List createdList = new ArrayList();        List lookupList = null;        try {            EntityCondition stateCond = this.makeStateListCondition("currentState", finsihedStates, EntityOperator.EQUALS, EntityOperator.OR);            EntityCondition cond = this.makeProcessFilterCondition(stateCond, packageId, processDefId, packageVer, finishedBefore);            lookupList = delegator.findByCondition("WfProcess", cond, null, order);        } catch (GenericEntityException e) {            throw new PersistenceException(e);        }        if (!UtilValidate.isEmpty(lookupList)) {            Iterator i = lookupList.iterator();            while (i.hasNext()) {                GenericValue v = (GenericValue) i.next();                createdList.add(Process.getInstance(this, v));            }        }        return createdList;    }    public List getAllFinishedProcesses(SharkTransaction trans) throws PersistenceException {        return this.findFinishedProcesses(trans, null, null, null, null);    }    public List getAllFinishedProcesses(SharkTransaction trans, Date finishedBefore) throws PersistenceException {        return this.findFinishedProcesses(trans, null, null, null, finishedBefore);    }    public List getAllFinishedProcesses(SharkTransaction trans, String packageId) throws PersistenceException {        return this.findFinishedProcesses(trans, packageId, null, null, null);    }    public List getAllFinishedProcesses(SharkTransaction trans, String packageId, String processDefId) throws PersistenceException {        return this.findFinishedProcesses(trans, packageId, processDefId, null, null);    }    public List getAllFinishedProcesses(SharkTransaction trans, String packageId, String processDefId, String packageVer) throws PersistenceException {        return this.findFinishedProcesses(trans, packageId, processDefId, packageVer, null);    }    private EntityCondition makeStateListCondition(String field, List states, EntityComparisonOperator operator, EntityJoinOperator jop) throws GenericEntityException {        if (states != null) {            if (states.size() > 1) {                List exprs = new LinkedList();                Iterator i = states.iterator();                while (i.hasNext()) {                    exprs.add(new EntityExpr(field, operator, i.next()));                }                return new EntityConditionList(exprs, jop);            } else {                return new EntityExpr(field, operator, states.get(0));            }        } else {            throw new GenericEntityException("Cannot create entity condition from list :" + states);        }    }    private EntityCondition makeProcessFilterCondition(EntityCondition cond, String packageId, String processDefId, String packageVer, Date finishBefore) {        EntityCondition newCond = null;        List exprs = new LinkedList();        if (packageId != null) {            exprs.add(new EntityExpr("packageId", EntityOperator.EQUALS, packageId));        }        if (processDefId != null) {            exprs.add(new EntityExpr("definitionId", EntityOperator.EQUALS, processDefId));        }        if (packageVer != null) {            exprs.add(new EntityExpr("packageVer", EntityOperator.EQUALS, packageVer));        }        if (finishBefore != null) {            exprs.add(new EntityExpr("lastStateTime", EntityOperator.LESS_THAN, finishBefore));        }        if (exprs.size() > 0) {            newCond = new EntityConditionList(exprs, EntityJoinOperator.AND);        }        if (newCond != null) {            if (cond != null) {                return new EntityConditionList(UtilMisc.toList(cond, newCond), EntityJoinOperator.AND);            } else {                return newCond;            }        } else {            return cond;        }    }    protected List findProcessActivities(String processId, List states, EntityComparisonOperator operator, SharkTransaction trans) throws PersistenceException {        GenericDelegator delegator = SharkContainer.getDelegator();        List createdList = new ArrayList();        List order = UtilMisc.toList("lastStateTime");        List lookupList = null;        try {            EntityCondition cond = null;            EntityCondition proc = new EntityExpr("processId", EntityOperator.EQUALS, processId);            if (states != null) {                EntityCondition stateCond = this.makeStateListCondition("currentState", states, operator, EntityOperator.OR);                cond = new EntityConditionList(UtilMisc.toList(proc, stateCond), EntityOperator.AND);            } else {                cond = proc;            }            lookupList = delegator.findByCondition("WfActivity", cond, null, order);        } catch (GenericEntityException e) {            throw new PersistenceException(e);        }        if (lookupList != null && lookupList.size() > 0) {            Iterator i = lookupList.iterator();            while (i.hasNext()) {                GenericValue v = (GenericValue) i.next();                createdList.add(Activity.getInstance(this, v));            }        }        return createdList;    }    public List getAllActivitiesForProcess(String processId, SharkTransaction trans) throws PersistenceException {        return this.findProcessActivities(processId, null, null, trans);    }    public List getActivitiesForProcess(String processId, String actState, SharkTransaction trans) throws PersistenceException {        return this.findProcessActivities(processId, UtilMisc.toList(actState), null, trans);    }    public List getAllFinishedActivitiesForProcess(String processId, SharkTransaction trans) throws PersistenceException {        List finishedStates = UtilMisc.toList("closed.completed", "closed.terminated", "closed.aborted");        return this.findProcessActivities(processId, finishedStates, EntityOperator.EQUALS, trans);    }    public List getAllActiveActivitiesForProcess(String processId, SharkTransaction trans) throws PersistenceException {        List finishedStates = UtilMisc.toList("closed.completed", "closed.terminated", "closed.aborted");        return this.findProcessActivities(processId, finishedStates, EntityOperator.NOT_EQUAL, trans);    }    /**    * Returns all assignments for the resource, no matter if its activity    * is in "closed" state (or some of its sub-states).    */    public List getAllAssignmentsForResource(String user, SharkTransaction trans) throws PersistenceException {        GenericDelegator delegator = SharkContainer.getDelegator();        List createdList = new ArrayList();        List lookupList = null;        try {            lookupList = delegator.findByAnd("WfAssignment", UtilMisc.toMap("userName", user));        } catch (GenericEntityException e) {            throw new PersistenceException(e);        }        if (lookupList != null && lookupList.size() > 0) {            Iterator i = lookupList.iterator();            while (i.hasNext()) {                GenericValue v = (GenericValue) i.next();                createdList.add(Assignment.getInstance(this, v));            }        }        return createdList;    }    /**    * Returns all assignments which activity is not in "closed" state, or some    * of its sub-states.    */    public List getAllAssignmentsForNotClosedActivitiesForResource(String user, SharkTransaction trans) throws PersistenceException {        List allAssignments = getAllAssignmentsForResource(user, trans);        List notClosed = new ArrayList();        Iterator i = allAssignments.iterator();        while (i.hasNext()) {            Assignment as = (Assignment) i.next();            Activity at = Activity.getInstance(this, as.getActivityId());            if (!at.getState().startsWith("closed")) {                notClosed.add(as);            }        }        return notClosed;    }    /**    * Returns only the assignments that can be currently executed by the resource    * with a given username. This means the ones which activity is not finished    * and not accepted (it doesn't have getResourceUsername() field set), and the    * ones which activity is accepted by this resource (its getResourceUsername()    * field is set to the resource with given username).    */    public List getAllValidAssignmentsForResource(String user, SharkTransaction trans) throws PersistenceException {        List allAssignments = getAllAssignmentsForResource(user, trans);        List valid = new ArrayList();        Iterator i = allAssignments.iterator();        while (i.hasNext()) {            Assignment as = (Assignment) i.next();            Activity at = Activity.getInstance(this, as.getActivityId());            if (!at.getState().startsWith("closed")) {                if (at.getResourceUsername() == null || user.equals(at.getResourceUsername())) {                    valid.add(as);                }            }        }

⌨️ 快捷键说明

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