Search in sources :

Example 6 with IUserFragmentSubscription

use of org.apereo.portal.fragment.subscribe.IUserFragmentSubscription in project uPortal by Jasig.

the class SubscribedFragmentImporterExporter method importData.

@Transactional
@Override
public void importData(ExternalSubscribedFragments data) {
    final String username = data.getUsername();
    final IPerson person = getPerson(username, true);
    for (final SubscribedFragmentType subscribedFragmentType : data.getSubscribedFragments()) {
        final String fragmentOwner = subscribedFragmentType.getFragmentOwner();
        final IPerson fragmentPerson = getPerson(fragmentOwner, false);
        if (fragmentPerson == null) {
            throw new IllegalArgumentException("No fragmentOwner " + fragmentOwner + " exists to subscribe to, be sure to import all fragment owners first");
        }
        final IUserFragmentSubscription userFragmentSubscription = this.userFragmentSubscriptionDao.getUserFragmentInfo(person, fragmentPerson);
        if (userFragmentSubscription == null) {
            this.userFragmentSubscriptionDao.createUserFragmentInfo(person, fragmentPerson);
        }
    }
}
Also used : IPerson(org.apereo.portal.security.IPerson) IUserFragmentSubscription(org.apereo.portal.fragment.subscribe.IUserFragmentSubscription) Transactional(org.springframework.transaction.annotation.Transactional)

Example 7 with IUserFragmentSubscription

use of org.apereo.portal.fragment.subscribe.IUserFragmentSubscription in project uPortal by Jasig.

the class SubscribedFragmentImporterExporter method exportInternal.

private ExternalSubscribedFragments exportInternal(final IPerson person) {
    final ExternalSubscribedFragments data = new ExternalSubscribedFragments();
    data.setUsername(person.getUserName());
    final List<SubscribedFragmentType> subscribedFragments = data.getSubscribedFragments();
    for (final IUserFragmentSubscription userFragmentSubscription : this.userFragmentSubscriptionDao.getUserFragmentInfo(person)) {
        if (userFragmentSubscription.isActive()) {
            final SubscribedFragmentType subscribedFragmentType = new SubscribedFragmentType();
            subscribedFragmentType.setFragmentOwner(userFragmentSubscription.getFragmentOwner());
            subscribedFragments.add(subscribedFragmentType);
        }
    }
    if (subscribedFragments.isEmpty()) {
        return null;
    }
    Collections.sort(subscribedFragments, SubscribedFragmentTypeComparator.INSTANCE);
    return data;
}
Also used : IUserFragmentSubscription(org.apereo.portal.fragment.subscribe.IUserFragmentSubscription)

Example 8 with IUserFragmentSubscription

use of org.apereo.portal.fragment.subscribe.IUserFragmentSubscription in project uPortal by Jasig.

the class JpaUserFragmentSubscriptionDaoImpl method createUserFragmentInfo.

@Override
@PortalTransactional
public IUserFragmentSubscription createUserFragmentInfo(IPerson person, IPerson fragmentOwner) {
    final IUserFragmentSubscription userFragmentInfo = new UserFragmentSubscriptionImpl(person, fragmentOwner);
    this.getEntityManager().persist(userFragmentInfo);
    return userFragmentInfo;
}
Also used : IUserFragmentSubscription(org.apereo.portal.fragment.subscribe.IUserFragmentSubscription)

Aggregations

IUserFragmentSubscription (org.apereo.portal.fragment.subscribe.IUserFragmentSubscription)8 IPerson (org.apereo.portal.security.IPerson)4 RestrictedPerson (org.apereo.portal.security.provider.RestrictedPerson)2 IUserInstance (org.apereo.portal.user.IUserInstance)2 Transactional (org.springframework.transaction.annotation.Transactional)2 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)2 ModelAndView (org.springframework.web.servlet.ModelAndView)2 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 Locale (java.util.Locale)1 XPath (javax.xml.xpath.XPath)1 XPathExpressionException (javax.xml.xpath.XPathExpressionException)1 XPathFactory (javax.xml.xpath.XPathFactory)1 PortalException (org.apereo.portal.PortalException)1 UserPreferencesManager (org.apereo.portal.UserPreferencesManager)1 IUserFragmentSubscriptionDao (org.apereo.portal.fragment.subscribe.dao.IUserFragmentSubscriptionDao)1 IUserLayoutManager (org.apereo.portal.layout.IUserLayoutManager)1 DistributedUserLayout (org.apereo.portal.layout.dlm.DistributedUserLayout)1 FragmentDefinition (org.apereo.portal.layout.dlm.FragmentDefinition)1