baseturbinerole.java

来自「jetspeed源代码」· Java 代码 · 共 986 行 · 第 1/3 页

JAVA
986
字号
        }        else        {            // the following code is to determine if a new query is            // called for.  If the criteria is the same as the last            // one, just return the collection.            boolean newCriteria = true;                            criteria.add(TurbineUserGroupRolePeer.ROLE_ID, getRoleId() );                        if (!lastTurbineUserGroupRolesCriteria.equals(criteria))            {                collTurbineUserGroupRoles = TurbineUserGroupRolePeer.doSelectJoinTurbineGroup(criteria);            }        }        lastTurbineUserGroupRolesCriteria = criteria;        return collTurbineUserGroupRoles;    }                                                                                                                                                                                                                                                                /**     * If this collection has already been initialized with     * an identical criteria, it returns the collection.     * Otherwise if this TurbineRole is new, it will return     * an empty collection; or if this TurbineRole has previously     * been saved, it will retrieve related TurbineUserGroupRoles from storage.     *     * This method is protected by default in order to keep the public     * api reasonable.  You can provide public methods for those you     * actually need in TurbineRole.     */    protected List getTurbineUserGroupRolesJoinTurbineRole(Criteria criteria)        throws TorqueException    {        if (collTurbineUserGroupRoles == null)        {            if (isNew())            {               collTurbineUserGroupRoles = new ArrayList();            }            else            {                            criteria.add(TurbineUserGroupRolePeer.ROLE_ID, getRoleId() );                            collTurbineUserGroupRoles = TurbineUserGroupRolePeer.doSelectJoinTurbineRole(criteria);            }        }        else        {            // the following code is to determine if a new query is            // called for.  If the criteria is the same as the last            // one, just return the collection.            boolean newCriteria = true;                            criteria.add(TurbineUserGroupRolePeer.ROLE_ID, getRoleId() );                        if (!lastTurbineUserGroupRolesCriteria.equals(criteria))            {                collTurbineUserGroupRoles = TurbineUserGroupRolePeer.doSelectJoinTurbineRole(criteria);            }        }        lastTurbineUserGroupRolesCriteria = criteria;        return collTurbineUserGroupRoles;    }                                          private static List fieldNames = null;    /**     * Generate a list of field names.     */    public static synchronized List getFieldNames()    {        if (fieldNames == null)        {            fieldNames = new ArrayList();              fieldNames.add("RoleId");              fieldNames.add("RoleName");              fieldNames.add("Objectdata");              fieldNames = Collections.unmodifiableList(fieldNames);        }        return fieldNames;    }    /**     * Retrieves a field from the object by name passed in     * as a String.     */    public Object getByName(String name)    {          if (name.equals("RoleId"))        {                return new Integer(getRoleId());            }          if (name.equals("RoleName"))        {                return getRoleName();            }          if (name.equals("Objectdata"))        {                return getObjectdata();            }          return null;    }        /**     * Retrieves a field from the object by name passed in     * as a String.  The String must be one of the static     * Strings defined in this Class' Peer.     */    public Object getByPeerName(String name)    {          if (name.equals(TurbineRolePeer.ROLE_ID ))        {                return new Integer(getRoleId());            }          if (name.equals(TurbineRolePeer.ROLE_NAME ))        {                return getRoleName();            }          if (name.equals(TurbineRolePeer.OBJECTDATA ))        {                return getObjectdata();            }          return null;    }    /**     * Retrieves a field from the object by Position as specified     * in the xml schema.  Zero-based.     */    public Object getByPosition(int pos)    {            if ( pos == 0 )        {                return new Integer(getRoleId());            }              if ( pos == 1 )        {                return getRoleName();            }              if ( pos == 2 )        {                return getObjectdata();            }              return null;    }         /**     * Stores the object in the database.  If the object is new,     * it inserts it; otherwise an update is performed.     */    public void save() throws Exception    {          save(TurbineRolePeer.getMapBuilder()                .getDatabaseMap().getName());      }    /**     * Stores the object in the database.  If the object is new,     * it inserts it; otherwise an update is performed.       * Note: this code is here because the method body is     * auto-generated conditionally and therefore needs to be     * in this file instead of in the super class, BaseObject.       */    public void save(String dbName) throws TorqueException    {        Connection con = null;          try        {            con = Transaction.begin(dbName);            save(con);            Transaction.commit(con);        }        catch(TorqueException e)        {            Transaction.safeRollback(con);            throw e;        }      }      /** flag to prevent endless save loop, if this object is referenced        by another object which falls in this transaction. */    private boolean alreadyInSave = false;      /**     * Stores the object in the database.  If the object is new,     * it inserts it; otherwise an update is performed.  This method     * is meant to be used as part of a transaction, otherwise use     * the save() method and the connection details will be handled     * internally     */    public void save(Connection con) throws TorqueException    {          if (!alreadyInSave)        {            alreadyInSave = true;              // If this object has been modified, then save it to the database.            if (isModified())            {                if (isNew())                {                    TurbineRolePeer.doInsert((TurbineRole)this, con);                    setNew(false);                }                else                {                    TurbineRolePeer.doUpdate((TurbineRole)this, con);                }                      if (isCacheOnSave())                {                    TurbineRoleManager.putInstance(this);                }              }                                                                  if (collTurbineRolePermissions != null )            {                for (int i = 0; i < collTurbineRolePermissions.size(); i++)                {                    ((TurbineRolePermission)collTurbineRolePermissions.get(i)).save(con);                }            }                                                                      if (collTurbineUserGroupRoles != null )            {                for (int i = 0; i < collTurbineUserGroupRoles.size(); i++)                {                    ((TurbineUserGroupRole)collTurbineUserGroupRoles.get(i)).save(con);                }            }                          alreadyInSave = false;        }      }    /**     * Specify whether to cache the object after saving to the db.     * This method returns false     */    protected boolean isCacheOnSave()    {        return true;    }                              /**     * Set the PrimaryKey using ObjectKey.     *     * @param ObjectKey roleId     */    public void setPrimaryKey(ObjectKey roleId)        throws TorqueException {            setRoleId(((NumberKey)roleId).intValue());        }    /**     * Set the PrimaryKey using a String.     */    public void setPrimaryKey(String key) throws TorqueException    {            setRoleId(Integer.parseInt(key));        }      /**     * returns an id that differentiates this object from others     * of its class.     */    public ObjectKey getPrimaryKey()    {          return SimpleKey.keyFor(getRoleId());      }     /**     * Makes a copy of this object.     * It creates a new object filling in the simple attributes.       * It then fills all the association collections.       */      public TurbineRole copy() throws TorqueException    {        TurbineRole copyObj = new TurbineRole();            copyObj.setRoleId(roleId);          copyObj.setRoleName(roleName);          copyObj.setObjectdata(objectdata);                        copyObj.setRoleId(0);                                                                                      List v = getTurbineRolePermissions();        for (int i = 0; i < v.size(); i++)        {            TurbineRolePermission obj = (TurbineRolePermission) v.get(i);            copyObj.addTurbineRolePermission(obj.copy());        }                                                                          v = getTurbineUserGroupRoles();        for (int i = 0; i < v.size(); i++)        {            TurbineUserGroupRole obj = (TurbineUserGroupRole) v.get(i);            copyObj.addTurbineUserGroupRole(obj.copy());        }                            return copyObj;    }    /**     * returns a peer instance associated with this om.  Since Peer classes     * are not to have any instance attributes, this method returns the     * same instance for all member of this class. The method could therefore     * be static, but this would prevent one from overriding the behavior.     */    public TurbineRolePeer getPeer()    {        return peer;    }}

⌨️ 快捷键说明

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