コード例 #1
0
  /**
   * Caches the asset in the entity cache if it is enabled.
   *
   * @param asset the asset
   */
  @Override
  public void cacheResult(Asset asset) {
    EntityCacheUtil.putResult(
        AssetModelImpl.ENTITY_CACHE_ENABLED, AssetImpl.class, asset.getPrimaryKey(), asset);

    asset.resetOriginalValues();
  }
コード例 #2
0
  @Override
  public Asset updateImpl(com.liferay.ams.model.Asset asset, boolean merge) throws SystemException {
    asset = toUnwrappedModel(asset);

    Session session = null;

    try {
      session = openSession();

      BatchSessionUtil.update(session, asset, merge);

      asset.setNew(false);
    } catch (Exception e) {
      throw processException(e);
    } finally {
      closeSession(session);
    }

    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);

    EntityCacheUtil.putResult(
        AssetModelImpl.ENTITY_CACHE_ENABLED, AssetImpl.class, asset.getPrimaryKey(), asset);

    return asset;
  }
コード例 #3
0
  @Override
  protected Asset removeImpl(Asset asset) throws SystemException {
    asset = toUnwrappedModel(asset);

    Session session = null;

    try {
      session = openSession();

      BatchSessionUtil.delete(session, asset);
    } catch (Exception e) {
      throw processException(e);
    } finally {
      closeSession(session);
    }

    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);

    FinderCacheUtil.removeResult(FINDER_PATH_FIND_ALL, FINDER_ARGS_EMPTY);

    EntityCacheUtil.removeResult(
        AssetModelImpl.ENTITY_CACHE_ENABLED, AssetImpl.class, asset.getPrimaryKey());

    return asset;
  }
コード例 #4
0
  /**
   * Clears the cache for the asset.
   *
   * <p>The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link
   * com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
   */
  @Override
  public void clearCache(Asset asset) {
    EntityCacheUtil.removeResult(
        AssetModelImpl.ENTITY_CACHE_ENABLED, AssetImpl.class, asset.getPrimaryKey());

    FinderCacheUtil.removeResult(FINDER_PATH_FIND_ALL, FINDER_ARGS_EMPTY);
  }
コード例 #5
0
  /**
   * Clears the cache for the asset.
   *
   * <p>The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link
   * com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
   */
  @Override
  public void clearCache(Asset asset) {
    EntityCacheUtil.removeResult(
        AssetModelImpl.ENTITY_CACHE_ENABLED, AssetImpl.class, asset.getPrimaryKey());

    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
  }
コード例 #6
0
 /**
  * Caches the assets in the entity cache if it is enabled.
  *
  * @param assets the assets
  */
 public void cacheResult(List<Asset> assets) {
   for (Asset asset : assets) {
     if (EntityCacheUtil.getResult(
             AssetModelImpl.ENTITY_CACHE_ENABLED, AssetImpl.class, asset.getPrimaryKey())
         == null) {
       cacheResult(asset);
     }
   }
 }
コード例 #7
0
  public int compareTo(Asset asset) {
    long primaryKey = asset.getPrimaryKey();

    if (getPrimaryKey() < primaryKey) {
      return -1;
    } else if (getPrimaryKey() > primaryKey) {
      return 1;
    } else {
      return 0;
    }
  }
コード例 #8
0
 /**
  * Caches the assets in the entity cache if it is enabled.
  *
  * @param assets the assets
  */
 @Override
 public void cacheResult(List<Asset> assets) {
   for (Asset asset : assets) {
     if (EntityCacheUtil.getResult(
             AssetModelImpl.ENTITY_CACHE_ENABLED, AssetImpl.class, asset.getPrimaryKey())
         == null) {
       cacheResult(asset);
     } else {
       asset.resetOriginalValues();
     }
   }
 }
コード例 #9
0
  @Override
  public boolean equals(Object obj) {
    if (this == obj) {
      return true;
    }

    if (!(obj instanceof Asset)) {
      return false;
    }

    Asset asset = (Asset) obj;

    long primaryKey = asset.getPrimaryKey();

    if (getPrimaryKey() == primaryKey) {
      return true;
    } else {
      return false;
    }
  }
コード例 #10
0
  @Override
  public boolean equals(Object obj) {
    if (obj == null) {
      return false;
    }

    Asset asset = null;

    try {
      asset = (Asset) obj;
    } catch (ClassCastException cce) {
      return false;
    }

    long primaryKey = asset.getPrimaryKey();

    if (getPrimaryKey() == primaryKey) {
      return true;
    } else {
      return false;
    }
  }
コード例 #11
0
  protected Asset toUnwrappedModel(Asset asset) {
    if (asset instanceof AssetImpl) {
      return asset;
    }

    AssetImpl assetImpl = new AssetImpl();

    assetImpl.setNew(asset.isNew());
    assetImpl.setPrimaryKey(asset.getPrimaryKey());

    assetImpl.setAssetId(asset.getAssetId());
    assetImpl.setCompanyId(asset.getCompanyId());
    assetImpl.setUserId(asset.getUserId());
    assetImpl.setUserName(asset.getUserName());
    assetImpl.setCreateDate(asset.getCreateDate());
    assetImpl.setModifiedDate(asset.getModifiedDate());
    assetImpl.setDefinitionId(asset.getDefinitionId());
    assetImpl.setSerialNumber(asset.getSerialNumber());
    assetImpl.setInactiveDate(asset.getInactiveDate());
    assetImpl.setActive(asset.isActive());

    return assetImpl;
  }
コード例 #12
0
  @Override
  public Asset updateImpl(com.liferay.ams.model.Asset asset) throws SystemException {
    asset = toUnwrappedModel(asset);

    boolean isNew = asset.isNew();

    Session session = null;

    try {
      session = openSession();

      if (asset.isNew()) {
        session.save(asset);

        asset.setNew(false);
      } else {
        session.merge(asset);
      }
    } catch (Exception e) {
      throw processException(e);
    } finally {
      closeSession(session);
    }

    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);

    if (isNew) {
      FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
    }

    EntityCacheUtil.putResult(
        AssetModelImpl.ENTITY_CACHE_ENABLED, AssetImpl.class, asset.getPrimaryKey(), asset);

    asset.resetOriginalValues();

    return asset;
  }