📄 entitypersistentmgr.java
字号:
/* * $Id: EntityPersistentMgr.java 5462 2005-08-05 18:35:48Z jonesde $ * * Copyright (c) 2004 The Open For Business Project - www.ofbiz.org * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT * OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR * THE USE OR OTHER DEALINGS IN THE SOFTWARE. * */package org.ofbiz.shark.instance;import java.util.ArrayList;import java.util.Iterator;import java.util.LinkedList;import java.util.List;import java.util.Date;import java.util.Map;import org.ofbiz.base.util.Debug;import org.ofbiz.base.util.UtilMisc;import org.ofbiz.base.util.UtilValidate;import org.ofbiz.entity.GenericDelegator;import org.ofbiz.entity.GenericEntityException;import org.ofbiz.entity.GenericValue;import org.ofbiz.entity.util.EntityListIterator;import org.ofbiz.entity.model.DynamicViewEntity;import org.ofbiz.entity.model.ModelKeyMap;import org.ofbiz.entity.condition.EntityCondition;import org.ofbiz.entity.condition.EntityConditionList;import org.ofbiz.entity.condition.EntityExpr;import org.ofbiz.entity.condition.EntityJoinOperator;import org.ofbiz.entity.condition.EntityOperator;import org.ofbiz.entity.condition.EntityComparisonOperator;import org.ofbiz.shark.container.SharkContainer;import org.enhydra.shark.api.RootException;import org.enhydra.shark.api.SharkTransaction;import org.enhydra.shark.api.internal.instancepersistence.*;import org.enhydra.shark.api.internal.working.CallbackUtilities;/** * Shark Persistance Manager Implementation * * @author <a href="mailto:jaz@ofbiz.org">Andy Zeneski</a> * @version $Rev: 5462 $ * @since 3.1 */public class EntityPersistentMgr implements PersistentManagerInterface { public static final String module = EntityPersistentMgr.class.getName(); protected CallbackUtilities callBackUtil = null; public void configure(CallbackUtilities callBackUtil) throws RootException { this.callBackUtil = callBackUtil; } public void shutdownDatabase() throws PersistenceException { } // store methods public void persist(ProcessMgrPersistenceInterface processMgr, SharkTransaction trans) throws PersistenceException { try { ((ProcessMgr) processMgr).store(); } catch (GenericEntityException e) { throw new PersistenceException(e); } } public void persist(ProcessPersistenceInterface process, SharkTransaction trans) throws PersistenceException { try { ((Process) process).store(); } catch (GenericEntityException e) { throw new PersistenceException(e); } } public void persistExternalRequester(String processId, Object req, SharkTransaction trans) throws PersistenceException { ProcessPersistenceInterface proc = this.restoreProcess(processId, trans); proc.setExternalRequester(req); this.persist(proc, trans); } public void persist(ActivityPersistenceInterface activity, SharkTransaction trans) throws PersistenceException { try { ((Activity) activity).store(); } catch (GenericEntityException e) { throw new PersistenceException(e); } } public void persist(ResourcePersistenceInterface resource, SharkTransaction trans) throws PersistenceException { try { ((Resource) resource).store(); } catch (GenericEntityException e) { throw new PersistenceException(e); } } public void persist(AssignmentPersistenceInterface assignment, SharkTransaction trans) throws PersistenceException { try { ((Assignment) assignment).store(); } catch (GenericEntityException e) { throw new PersistenceException(e); } } public void persist(AssignmentPersistenceInterface assignment, String oldResUname, SharkTransaction trans) throws PersistenceException { // TODO: look into this, if it is used only for re-assigning then have it expire/create new assignment persist(assignment, trans); } public void persist(ProcessVariablePersistenceInterface processVariable, SharkTransaction trans) throws PersistenceException { try { ((ProcessVariable) processVariable).store(); } catch (GenericEntityException e) { throw new PersistenceException(e); } } public void persist(ActivityVariablePersistenceInterface activityVariable, SharkTransaction trans) throws PersistenceException { try { ((ActivityVariable) activityVariable).store(); } catch (GenericEntityException e) { throw new PersistenceException(e); } } public void persist(AndJoinEntryInterface andJoin, SharkTransaction trans) throws PersistenceException { try { ((AndJoinEntry) andJoin).store(); } catch (GenericEntityException e) { throw new PersistenceException(e); } } public void persist(DeadlinePersistenceInterface dpe, SharkTransaction ti) throws PersistenceException { try { ((Deadline) dpe).store(); } catch (GenericEntityException e) { throw new PersistenceException(e); } } // restore methods public ProcessMgrPersistenceInterface restoreProcessMgr(String mgrName, SharkTransaction trans) throws PersistenceException { return ProcessMgr.getInstance(this, mgrName); } public ProcessPersistenceInterface restoreProcess(String processId, SharkTransaction trans) throws PersistenceException { return Process.getInstance(this, processId); } public ActivityPersistenceInterface restoreActivity(String activityId, SharkTransaction trans) throws PersistenceException { return Activity.getInstance(this, activityId); } public ResourcePersistenceInterface restoreResource(String resourceId, SharkTransaction trans) throws PersistenceException { return Resource.getInstance(this, resourceId); } public AssignmentPersistenceInterface restoreAssignment(String activityId, String userName, SharkTransaction trans) throws PersistenceException { return Assignment.getInstance(this, activityId, userName); } public boolean restore(ProcessVariablePersistenceInterface processVariablePersistenceInterface, SharkTransaction trans) throws PersistenceException { if (Debug.verboseOn()) Debug.log(":: ProcessVariablePersistenceInterface ::", module); if (processVariablePersistenceInterface == null) { return false; } try { ((ProcessVariable) processVariablePersistenceInterface).reload(); } catch (GenericEntityException e) { Debug.logError(e, module); throw new PersistenceException(e); } return true; } public boolean restore(ActivityVariablePersistenceInterface activityVariablePersistenceInterface, SharkTransaction trans) throws PersistenceException { if (Debug.verboseOn()) Debug.log(":: ActivityVariablePersistenceInterface ::", module); if (activityVariablePersistenceInterface == null) { return false; } try { ((ActivityVariable) activityVariablePersistenceInterface).reload(); } catch (GenericEntityException e) { Debug.logError(e, module); throw new PersistenceException(e); } return true; } // remove/delete methods public void deleteProcessMgr(String mgrName, SharkTransaction trans) throws PersistenceException { if (Debug.infoOn()) Debug.log(":: deleteProcessMgr ::", module); try { ((ProcessMgr) restoreProcessMgr(mgrName, trans)).remove(); } catch (GenericEntityException e) { throw new PersistenceException(e); } } public void deleteProcess(String processId, boolean admin, SharkTransaction trans) throws PersistenceException { if (admin) { if (Debug.infoOn()) Debug.log(":: deleteProcess ::", module); Process process = (Process) this.restoreProcess(processId, trans); List activities = this.getAllActivitiesForProcess(processId, trans); if (activities != null) { Iterator i = activities.iterator(); while (i.hasNext()) { Activity activity = (Activity) i.next(); try { activity.remove(); } catch (GenericEntityException e) { throw new PersistenceException(e); } } } try { process.remove(); } catch (GenericEntityException e) { throw new PersistenceException(e); } } } public void deleteActivity(String activityId, SharkTransaction trans) throws PersistenceException { if (Debug.infoOn()) Debug.log(":: deleteActivity ::", module); Activity activity = (Activity) this.restoreActivity(activityId, trans); List assignments = this.getAllAssignmentsForActivity(activityId, trans); if (assignments != null) { Iterator i = assignments.iterator(); while (i.hasNext()) { Assignment assignment = (Assignment) i.next(); try { assignment.remove(); } catch (GenericEntityException e) { throw new PersistenceException(e); } } try { activity.remove(); } catch (GenericEntityException e) { throw new PersistenceException(e); } } } public void deleteResource(String userName, SharkTransaction trans) throws PersistenceException { if (Debug.infoOn()) Debug.log(":: deleteResource ::", module); try { ((Resource) restoreResource(userName, trans)).remove(); } catch (GenericEntityException e) { throw new PersistenceException(e); } } public void deleteAssignment(String activityId, String userName, SharkTransaction trans) throws PersistenceException { if (Debug.infoOn()) Debug.log(":: deleteAssignment ::", module); try { ((Assignment) restoreAssignment(activityId, userName, trans)).remove(); } catch (GenericEntityException e) { throw new PersistenceException(e); } } public void deleteAndJoinEntries(String procId, String asDefId, String aDefId, SharkTransaction trans) throws PersistenceException { if (Debug.infoOn()) Debug.log(":: deleteAndJoinEntries ::", module); GenericDelegator delegator = SharkContainer.getDelegator(); try { delegator.removeByAnd("WfAndJoin", UtilMisc.toMap("processId", procId, "activitySetDefId", asDefId, "activityDefId", aDefId)); } catch (GenericEntityException e) { throw new PersistenceException(e); } } public void deleteDeadlines(String procId, SharkTransaction trans) throws PersistenceException { GenericDelegator delegator = SharkContainer.getDelegator(); try { delegator.removeByAnd("WfDeadline", UtilMisc.toMap("processId", procId)); } catch (GenericEntityException e) { throw new PersistenceException(e); } } public void deleteDeadlines(String procId, String actId, SharkTransaction trans) throws PersistenceException { GenericDelegator delegator = SharkContainer.getDelegator(); try { delegator.removeByAnd("WfDeadline", UtilMisc.toMap("processId", procId, "activityId", actId)); } catch (GenericEntityException e) { throw new PersistenceException(e); } } public void delete(ProcessVariablePersistenceInterface processVariable, SharkTransaction trans) throws PersistenceException { // don't delete variables } public void delete(ActivityVariablePersistenceInterface activityVariable, SharkTransaction trans) throws PersistenceException { // don't delete variables } public List getProcessMgrsWhere(SharkTransaction trans, String sqlWhere) throws PersistenceException { if (sqlWhere != null) { Debug.log("Attempt to call getProcessMgrsWhere() - " + sqlWhere, module); throw new PersistenceException("Method not available to this implementation! (" + sqlWhere + ")"); } return this.getAllProcessMgrs(trans); } public List getAllProcessMgrs(SharkTransaction trans) throws PersistenceException { if (Debug.verboseOn()) Debug.log(":: getAllProcessMgrs ::", module); GenericDelegator delegator = SharkContainer.getDelegator(); List createdList = new ArrayList(); List lookupList = null; try { lookupList = delegator.findAll("WfProcessMgr"); } catch (GenericEntityException e) { Debug.logError(e, module); throw new PersistenceException(e); } if (lookupList != null && lookupList.size() > 0) { Iterator i = lookupList.iterator(); while (i.hasNext()) { GenericValue v = (GenericValue) i.next(); createdList.add(ProcessMgr.getInstance(this, v)); }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -