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

📄 entitypersistentmgr.java

📁 Sequoia ERP是一个真正的企业级开源ERP解决方案。它提供的模块包括:电子商务应用(e-commerce), POS系统(point of sales),知识管理,存货与仓库管理
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
        return valid;    }    /**    * Returns all assignments that are ever created for that activity, no    * matter if activity is already in "closed" state or some of its sub-states.    */    public List getAllAssignmentsForActivity(String activityId, SharkTransaction trans) throws PersistenceException {        GenericDelegator delegator = SharkContainer.getDelegator();        List createdList = new ArrayList();        List lookupList = null;        try {            lookupList = delegator.findByAnd("WfAssignment", UtilMisc.toMap("activityId", activityId));        } 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;    }    /**    * If activity is in "closed" state, or some of its sub-states, returns an    * empty list, otherwise returns all assignments that are ever created for    * that activity.    */    public List getAllAssignmentsForNotClosedActivity(String activityId, SharkTransaction trans) throws PersistenceException {        Activity at = Activity.getInstance(this, activityId);        if (at.getState().startsWith("closed")) {            return new ArrayList();        } else {            return getAllAssignmentsForActivity(activityId, trans);        }    }    /**    * If activity is in "closed" state, or some of its sub-states, returns an    * empty list, otherwise it returns either all assignments that are ever    * created for that activity if activity is not accepted, or just the    * assignment for the resource that accepted activity.    */    public List getAllValidAssignmentsForActivity(String activityId, SharkTransaction trans) throws PersistenceException {        Activity at = Activity.getInstance(this, activityId);        if (at.getState().startsWith("closed")) {            return new ArrayList();        }        List assignments = getAllAssignmentsForActivity(activityId, trans);        if (at.getResourceUsername() == null) {            return assignments;        }        List valid = new ArrayList();        Iterator i = assignments.iterator();        while (i.hasNext()) {            Assignment as = (Assignment) i.next();            if (at.getResourceUsername().equals(as.getResourceUsername())) {                valid.add(as);            }        }        return valid;    }    public List getAllVariablesForProcess(String processId, SharkTransaction trans) throws PersistenceException {        if (Debug.verboseOn()) Debug.log(":: getAllVariablesForProcess ::", module);        GenericDelegator delegator = SharkContainer.getDelegator();        List createdList = new ArrayList();        List lookupList = null;        try {            lookupList = delegator.findByAnd("WfProcessVariable", UtilMisc.toMap("processId", processId));        } catch (GenericEntityException e) {            Debug.logError(e, module);            throw new PersistenceException(e);        }        if (lookupList != null && lookupList.size() > 0) {            Debug.log("Lookup list contains : " + lookupList.size(), module);            Iterator i = lookupList.iterator();            while (i.hasNext()) {                GenericValue v = (GenericValue) i.next();                createdList.add(ProcessVariable.getInstance(this, v));            }        } else {            Debug.log("Lookup list empty", module);        }        if (Debug.verboseOn()) Debug.log("Returning list : " + createdList.size(), module);        //Debug.log(new Exception(), "Stack Trace", module);        return createdList;    }    public List getAllVariablesForActivity(String activityId, SharkTransaction trans) throws PersistenceException {        if (Debug.verboseOn()) Debug.log(":: getAllVariablesForActivity ::", module);        GenericDelegator delegator = SharkContainer.getDelegator();        List createdList = new ArrayList();        List lookupList = null;        try {            lookupList = delegator.findByAnd("WfActivityVariable", UtilMisc.toMap("activityId", activityId));        } 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(ActivityVariable.getInstance(this, v));            }        }        return createdList;    }    public List getResourceRequestersProcessIds(String userName, SharkTransaction trans) throws PersistenceException {        GenericDelegator delegator = SharkContainer.getDelegator();        List idList = new ArrayList();        List lookupList = null;        try {            lookupList = delegator.findByAnd("WfProcess", UtilMisc.toMap("resourceReqId", userName));        } catch (GenericEntityException e) {            throw new PersistenceException(e);        }        if (!UtilValidate.isEmpty(lookupList)) {            Iterator i = lookupList.iterator();            while (i.hasNext()) {                GenericValue v = (GenericValue) i.next();                idList.add(v.getString("processId"));            }        }        return idList;    }    public List getAndJoinEntries(String procId, String asDefId, String aDefId, SharkTransaction trans) throws PersistenceException {        List createdList = new ArrayList();        List lookupList = getAndJoinValues(procId, asDefId, aDefId);        if (lookupList != null && lookupList.size() > 0) {            Iterator i = lookupList.iterator();            while (i.hasNext()) {                GenericValue v = (GenericValue) i.next();                createdList.add(AndJoinEntry.getInstance(this, v));            }        }        return createdList;    }    public int howManyAndJoinEntries(String procId, String asDefId, String aDefId, SharkTransaction trans) throws PersistenceException {        List lookupList = getAndJoinValues(procId, asDefId, aDefId);        return lookupList.size();    }    public List getAllDeadlinesForProcess(String procId, SharkTransaction trans) throws PersistenceException {        List lookupList = getDeadlineValues(UtilMisc.toList(new EntityExpr("processId", EntityOperator.EQUALS, procId)));        return getDealineObjects(lookupList);    }    public List getAllDeadlinesForProcess(String procId, long timeLimit, SharkTransaction trans) throws PersistenceException {        List lookupList = getDeadlineValues(UtilMisc.toList(new EntityExpr("processId", EntityOperator.EQUALS, procId),                new EntityExpr("timeLimit", EntityOperator.LESS_THAN, new Long(timeLimit))));        return getDealineObjects(lookupList);    }    public List getAllIdsForProcessesWithExpiriedDeadlines(long l, SharkTransaction trans) throws PersistenceException {        if (Debug.infoOn()) Debug.log(":: getAllIdsForProcessesWithExpiriedDeadlines ::", module);        GenericDelegator delegator = SharkContainer.getDelegator();        List processIds = new ArrayList();        DynamicViewEntity view = new DynamicViewEntity();        view.addMemberEntity("WFDL", "WfDeadline");        view.addMemberEntity("WFPR", "WfProcess");        view.addMemberEntity("WFAC", "WfActivity");        view.addAlias("WFPR", "currentState", "processState", null, null, null, null);        view.addAlias("WFAC", "currentState", "activityState", null, null, null, null);        view.addViewLink("WFDL", "WFPR", Boolean.FALSE, ModelKeyMap.makeKeyMapList("processId"));        view.addViewLink("WFDL", "WFAC", Boolean.FALSE, ModelKeyMap.makeKeyMapList("activityId"));        EntityListIterator eli = null;        try {            EntityCondition procState = new EntityExpr("processState", EntityOperator.EQUALS, "open.running");            EntityCondition actState1 = new EntityExpr("activityState", EntityOperator.EQUALS, "open.not_running.not_started");            EntityCondition actState2 = new EntityExpr("activityState", EntityOperator.EQUALS, "open.running");            EntityCondition actState = new EntityConditionList(UtilMisc.toList(actState1, actState2), EntityOperator.OR);            EntityCondition timeCond = new EntityExpr("timeLimit", EntityOperator.LESS_THAN, new Long(l));            EntityCondition cond = new EntityConditionList(UtilMisc.toList(timeCond, procState, actState), EntityOperator.AND);            eli = delegator.findListIteratorByCondition(view, cond, null, null, null, null);            GenericValue v = null;            while ((v = (GenericValue) eli.next()) != null) {                processIds.add(v.getString("processId"));            }        } catch (GenericEntityException e) {            throw new PersistenceException(e);        } finally {            if (eli != null) {                try {                    eli.close();                } catch (GenericEntityException e) {                    throw new PersistenceException(e);                }            }        }        return processIds;    }    public List getAllDeadlinesForActivity(String procId, String actId, SharkTransaction trans) throws PersistenceException {        List lookupList = getDeadlineValues(UtilMisc.toList(new EntityExpr("processId", EntityOperator.EQUALS, procId),                new EntityExpr("activityId", EntityOperator.EQUALS, actId)));        return getDealineObjects(lookupList);    }    public List getAllDeadlinesForActivity(String procId, String actId, long timeLimit, SharkTransaction trans) throws PersistenceException {        List lookupList = getDeadlineValues(UtilMisc.toList(new EntityExpr("processId", EntityOperator.EQUALS, procId),                new EntityExpr("activityId", EntityOperator.EQUALS, actId),                new EntityExpr("timeLimit", EntityOperator.LESS_THAN, new Long(timeLimit))));        return getDealineObjects(lookupList);    }    public int getExecuteCount(String procId, String asDefId, String aDefId, SharkTransaction trans) throws PersistenceException {        GenericDelegator delegator = SharkContainer.getDelegator();        long count = 0;        try {            count = delegator.findCountByAnd("WfActivity", UtilMisc.toMap("processId", procId, "setDefinitionId", asDefId, "definitionId", aDefId));        } catch (GenericEntityException e) {            throw new PersistenceException(e);        }        return (int) count;    }    private List getAndJoinValues(String processId, String activitySetDefId, String activityDefId) throws PersistenceException {        GenericDelegator delegator = SharkContainer.getDelegator();        List lookupList = null;        try {            lookupList = delegator.findByAnd("WfAndJoin", UtilMisc.toMap("processId", processId,                    "activitySetDefId", activitySetDefId, "activityDefId", activityDefId));        } catch (GenericEntityException e) {            throw new PersistenceException(e);        }        if (lookupList == null) {            lookupList = new ArrayList();        }        return lookupList;    }    private List getDeadlineValues(List exprList) throws PersistenceException {        GenericDelegator delegator = SharkContainer.getDelegator();        List lookupList = null;        if (exprList == null) {            lookupList = new ArrayList();        } else {            try {                lookupList = delegator.findByAnd("WfDeadline", exprList);            } catch (GenericEntityException e) {                throw new PersistenceException(e);            }            if (lookupList == null) {                lookupList = new ArrayList();            }        }        return lookupList;    }    private List getDealineObjects(List deadlineValues) {        List deadlines = new ArrayList();        if (deadlineValues != null) {            Iterator i = deadlineValues.iterator();            while (i.hasNext()) {                GenericValue v = (GenericValue) i.next();                deadlines.add(Deadline.getInstance(this, v));            }        }        return deadlines;    }    // create methods    public ActivityPersistenceInterface createActivity() {        return new Activity(this, SharkContainer.getDelegator());    }    public ProcessPersistenceInterface createProcess() {        return new Process(this, SharkContainer.getDelegator());    }    public ProcessMgrPersistenceInterface createProcessMgr() {        return new ProcessMgr(this, SharkContainer.getDelegator());    }    public AssignmentPersistenceInterface createAssignment() {        return new Assignment(this, SharkContainer.getDelegator());    }    public ResourcePersistenceInterface createResource() {        return new Resource(this, SharkContainer.getDelegator());    }    public ProcessVariablePersistenceInterface createProcessVariable() {        return new ProcessVariable(this, SharkContainer.getDelegator());    }    public ActivityVariablePersistenceInterface createActivityVariable() {        return new ActivityVariable(this, SharkContainer.getDelegator());    }    public AndJoinEntryInterface createAndJoinEntry() {        return new AndJoinEntry(this, SharkContainer.getDelegator());    }    public DeadlinePersistenceInterface createDeadline() {        return new Deadline(this, SharkContainer.getDelegator());    }    public synchronized String getNextId(String string) throws PersistenceException {        GenericDelegator delegator = SharkContainer.getDelegator();        return delegator.getNextSeqId("SharkWorkflowSeq").toString();    }    public List getAssignmentsWhere(SharkTransaction trans, String sqlWhere) throws PersistenceException {        if (sqlWhere != null) {            Debug.log("Attempt to call getAssignmentsWhere() - " + sqlWhere, module);            throw new PersistenceException("Method not available to this implementation! (" + sqlWhere + ")");        }        return this.getAllAssignments(trans);    }    public List getProcessesWhere(SharkTransaction trans, String sqlWhere) throws PersistenceException {        if (sqlWhere != null) {            Debug.log("Attempt to call getProcessesWhere() - " + sqlWhere, module);            throw new PersistenceException("Method not available to this implementation! (" + sqlWhere + ")");        }        return this.getAllProcesses(trans);    }    public List getActivitiesWhere(SharkTransaction trans, String sqlWhere) throws PersistenceException {        if (sqlWhere != null) {            Debug.log("Attempt to call getActivitiesWhere() - " + sqlWhere, module);            throw new PersistenceException("Method not available to this implementation! (" + sqlWhere + ")");        }        return this.getAllActivities(trans);    }}

⌨️ 快捷键说明

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