Search in sources :

Example 1 with RosterMemberModelImpl

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

the class RosterMemberPersistenceImpl method updateImpl.

@Override
public RosterMember updateImpl(RosterMember rosterMember) {
    rosterMember = toUnwrappedModel(rosterMember);
    boolean isNew = rosterMember.isNew();
    RosterMemberModelImpl rosterMemberModelImpl = (RosterMemberModelImpl) rosterMember;
    if (Validator.isNull(rosterMember.getUuid())) {
        String uuid = PortalUUIDUtil.generate();
        rosterMember.setUuid(uuid);
    }
    ServiceContext serviceContext = ServiceContextThreadLocal.getServiceContext();
    Date now = new Date();
    if (isNew && (rosterMember.getCreateDate() == null)) {
        if (serviceContext == null) {
            rosterMember.setCreateDate(now);
        } else {
            rosterMember.setCreateDate(serviceContext.getCreateDate(now));
        }
    }
    if (!rosterMemberModelImpl.hasSetModifiedDate()) {
        if (serviceContext == null) {
            rosterMember.setModifiedDate(now);
        } else {
            rosterMember.setModifiedDate(serviceContext.getModifiedDate(now));
        }
    }
    Session session = null;
    try {
        session = openSession();
        if (rosterMember.isNew()) {
            session.save(rosterMember);
            rosterMember.setNew(false);
        } else {
            rosterMember = (RosterMember) session.merge(rosterMember);
        }
    } catch (Exception e) {
        throw processException(e);
    } finally {
        closeSession(session);
    }
    finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
    if (isNew || !RosterMemberModelImpl.COLUMN_BITMASK_ENABLED) {
        finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
    } else {
        if ((rosterMemberModelImpl.getColumnBitmask() & FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID.getColumnBitmask()) != 0) {
            Object[] args = new Object[] { rosterMemberModelImpl.getOriginalUuid() };
            finderCache.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
            finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID, args);
            args = new Object[] { rosterMemberModelImpl.getUuid() };
            finderCache.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
            finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID, args);
        }
        if ((rosterMemberModelImpl.getColumnBitmask() & FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_ROSTERID.getColumnBitmask()) != 0) {
            Object[] args = new Object[] { rosterMemberModelImpl.getOriginalRosterId() };
            finderCache.removeResult(FINDER_PATH_COUNT_BY_ROSTERID, args);
            finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_ROSTERID, args);
            args = new Object[] { rosterMemberModelImpl.getRosterId() };
            finderCache.removeResult(FINDER_PATH_COUNT_BY_ROSTERID, args);
            finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_ROSTERID, args);
        }
    }
    entityCache.putResult(RosterMemberModelImpl.ENTITY_CACHE_ENABLED, RosterMemberImpl.class, rosterMember.getPrimaryKey(), rosterMember, false);
    rosterMember.resetOriginalValues();
    return rosterMember;
}
Also used : RosterMemberModelImpl(com.liferay.roster.model.impl.RosterMemberModelImpl) ServiceContext(com.liferay.portal.kernel.service.ServiceContext) Date(java.util.Date) NoSuchRosterMemberException(com.liferay.roster.exception.NoSuchRosterMemberException) 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 NoSuchRosterMemberException (com.liferay.roster.exception.NoSuchRosterMemberException)1 RosterMemberModelImpl (com.liferay.roster.model.impl.RosterMemberModelImpl)1 Date (java.util.Date)1