コード例 #1
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;
  }
コード例 #2
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;
  }