Search in sources :

Example 1 with RosterModelImpl

use of com.liferay.roster.model.impl.RosterModelImpl in project liferay-ide by liferay.

the class RosterPersistenceImpl method updateImpl.

@Override
public Roster updateImpl(Roster roster) {
    roster = toUnwrappedModel(roster);
    boolean isNew = roster.isNew();
    RosterModelImpl rosterModelImpl = (RosterModelImpl) roster;
    if (Validator.isNull(roster.getUuid())) {
        String uuid = PortalUUIDUtil.generate();
        roster.setUuid(uuid);
    }
    ServiceContext serviceContext = ServiceContextThreadLocal.getServiceContext();
    Date now = new Date();
    if (isNew && (roster.getCreateDate() == null)) {
        if (serviceContext == null) {
            roster.setCreateDate(now);
        } else {
            roster.setCreateDate(serviceContext.getCreateDate(now));
        }
    }
    if (!rosterModelImpl.hasSetModifiedDate()) {
        if (serviceContext == null) {
            roster.setModifiedDate(now);
        } else {
            roster.setModifiedDate(serviceContext.getModifiedDate(now));
        }
    }
    Session session = null;
    try {
        session = openSession();
        if (roster.isNew()) {
            session.save(roster);
            roster.setNew(false);
        } else {
            roster = (Roster) session.merge(roster);
        }
    } catch (Exception e) {
        throw processException(e);
    } finally {
        closeSession(session);
    }
    finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
    if (isNew || !RosterModelImpl.COLUMN_BITMASK_ENABLED) {
        finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
    } else {
        if ((rosterModelImpl.getColumnBitmask() & FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID.getColumnBitmask()) != 0) {
            Object[] args = new Object[] { rosterModelImpl.getOriginalUuid() };
            finderCache.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
            finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID, args);
            args = new Object[] { rosterModelImpl.getUuid() };
            finderCache.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
            finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID, args);
        }
        if ((rosterModelImpl.getColumnBitmask() & FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_CLUBID.getColumnBitmask()) != 0) {
            Object[] args = new Object[] { rosterModelImpl.getOriginalClubId() };
            finderCache.removeResult(FINDER_PATH_COUNT_BY_CLUBID, args);
            finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_CLUBID, args);
            args = new Object[] { rosterModelImpl.getClubId() };
            finderCache.removeResult(FINDER_PATH_COUNT_BY_CLUBID, args);
            finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_CLUBID, args);
        }
    }
    entityCache.putResult(RosterModelImpl.ENTITY_CACHE_ENABLED, RosterImpl.class, roster.getPrimaryKey(), roster, false);
    roster.resetOriginalValues();
    return roster;
}
Also used : ServiceContext(com.liferay.portal.kernel.service.ServiceContext) Date(java.util.Date) NoSuchRosterException(com.liferay.roster.exception.NoSuchRosterException) RosterModelImpl(com.liferay.roster.model.impl.RosterModelImpl) Session(com.liferay.portal.kernel.dao.orm.Session)

Aggregations

Session (com.liferay.portal.kernel.dao.orm.Session)1 ServiceContext (com.liferay.portal.kernel.service.ServiceContext)1 NoSuchRosterException (com.liferay.roster.exception.NoSuchRosterException)1 RosterModelImpl (com.liferay.roster.model.impl.RosterModelImpl)1 Date (java.util.Date)1