use of org.olat.portfolio.model.structel.EPMapShort in project OpenOLAT by OpenOLAT.
the class EPNotificationsHandler method getTitleItemForPublisher.
/**
* returns a TitleItem instance for the given Publisher p If you already
* have a reference to the map, use
* <code>getTitleItemForMap(EPAbstractMap amap)</code>
*
* @param p
* @return
*/
private TitleItem getTitleItemForPublisher(Publisher p) {
Long resId = p.getResId();
if (logger.isDebug())
logger.debug("loading map with resourceableid: " + resId);
EPFrontendManager epMgr = CoreSpringFactory.getImpl(EPFrontendManager.class);
EPMapShort map = epMgr.loadMapShortByResourceId(resId);
return getTitleItemForMap(map);
}
use of org.olat.portfolio.model.structel.EPMapShort in project OpenOLAT by OpenOLAT.
the class EPPolicyManager method getMapPolicies.
/**
* Return a list of wrapper containing the read policies of the map
* @param map
*/
public List<EPMapPolicy> getMapPolicies(PortfolioStructureMapRef mapRef) {
EPMapShort map = dbInstance.getCurrentEntityManager().find(EPMapShort.class, mapRef.getKey());
List<EPMapPolicy> policies = new ArrayList<EPMapPolicy>();
Set<EPStructureElementToGroupRelation> relations = map.getGroups();
for (EPStructureElementToGroupRelation relation : relations) {
if (relation.isDefaultGroup()) {
continue;
}
EPMapPolicy policy = getEquivalentWrapper(relation, policies);
if (policy == null) {
policy = new EPMapPolicy();
policy.setTo(relation.getValidTo());
policy.setFrom(relation.getValidFrom());
policies.add(policy);
}
String role = relation.getRole();
if (role.startsWith(EPMapPolicy.Type.user.name())) {
List<Identity> identities = groupDao.getMembers(relation.getGroup(), GroupRoles.participant.name());
policy.addRelation(relation);
policy.setType(EPMapPolicy.Type.user);
policy.addIdentities(identities);
} else if (role.startsWith(EPMapPolicy.Type.group.name())) {
policy.addRelation(relation);
BusinessGroup group = businessGroupDao.findBusinessGroup(relation.getGroup());
policy.addGroup(group);
policy.setType(EPMapPolicy.Type.group);
} else if (role.startsWith(EPMapPolicy.Type.invitation.name())) {
policy.addRelation(relation);
Invitation invitation = invitationDao.findInvitation(relation.getGroup());
policy.setInvitation(invitation);
policy.setType(EPMapPolicy.Type.invitation);
} else if (role.startsWith(EPMapPolicy.Type.allusers.name())) {
policy.addRelation(relation);
policy.setType(EPMapPolicy.Type.allusers);
}
}
return policies;
}
use of org.olat.portfolio.model.structel.EPMapShort in project openolat by klemens.
the class EPStructureManager method loadMapShortByResourceId.
/**
* @param olatResourceable cannot be null
* @return The structure element or null if not found
*/
public EPMapShort loadMapShortByResourceId(Long resourceableId) {
StringBuilder sb = new StringBuilder();
sb.append("select element from ").append(EPMapShort.class.getName()).append(" element").append(" inner join fetch element.olatResource resource").append(" where resource.resId=:resourceId and resource.resName in ('EPDefaultMap','EPStructuredMap','EPStructuredMapTemplate')");
DBQuery query = dbInstance.createQuery(sb.toString());
query.setLong("resourceId", resourceableId);
@SuppressWarnings("unchecked") List<EPMapShort> resources = query.list();
// if not found, it is an empty list
if (resources.isEmpty())
return null;
return resources.get(0);
}
use of org.olat.portfolio.model.structel.EPMapShort in project openolat by klemens.
the class EPNotificationsHandler method getTitleItemForPublisher.
/**
* returns a TitleItem instance for the given Publisher p If you already
* have a reference to the map, use
* <code>getTitleItemForMap(EPAbstractMap amap)</code>
*
* @param p
* @return
*/
private TitleItem getTitleItemForPublisher(Publisher p) {
Long resId = p.getResId();
if (logger.isDebug())
logger.debug("loading map with resourceableid: " + resId);
EPFrontendManager epMgr = CoreSpringFactory.getImpl(EPFrontendManager.class);
EPMapShort map = epMgr.loadMapShortByResourceId(resId);
return getTitleItemForMap(map);
}
use of org.olat.portfolio.model.structel.EPMapShort in project OpenOLAT by OpenOLAT.
the class EPNotificationsHandler method createSubscriptionInfo.
@Override
public SubscriptionInfo createSubscriptionInfo(Subscriber subscriber, Locale locale, Date compareDate) {
SubscriptionInfo si = null;
Publisher publisher = subscriber.getPublisher();
EPFrontendManager epMgr = CoreSpringFactory.getImpl(EPFrontendManager.class);
EPMapShort amap = epMgr.loadMapShortByResourceId(publisher.getResId());
if (isInkoveValid(amap, compareDate, publisher)) {
// init the helper;
String rootBusinessPath = "[EPDefaultMap:" + amap.getKey() + "]";
EPNotificationsHelper helper = new EPNotificationsHelper(rootBusinessPath, locale);
String resName = amap.getOlatResource().getResourceableTypeName();
si = new SubscriptionInfo(subscriber.getKey(), publisher.getType(), getTitleItemForMap(amap), null);
List<SubscriptionListItem> allItems = new ArrayList<SubscriptionListItem>(0);
// get subscriptionListItems according to map type
if ("EPDefaultMap".equals(resName) || "EPStructuredMapTemplate".equals(resName)) {
allItems = helper.getAllSubscrItemsDefault(compareDate, amap);
} else if ("EPStructuredMap".equals(resName)) {
allItems = helper.getAllSubscrItemsStructured(compareDate, amap);
}
for (SubscriptionListItem item : allItems) {
si.addSubscriptionListItem(item);
}
}
if (si == null) {
// no info, return empty
si = NotificationsManager.getInstance().getNoSubscriptionInfo();
}
return si;
}
Aggregations