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);
}
}
}
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;
}
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;
}
Aggregations