use of org.olat.portfolio.model.structel.EPMapShort in project OpenOLAT by OpenOLAT.
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 OpenOLAT.
the class EPChangelogController method updateChangelogDisplay.
/**
* update the changelog-list according to selected date. this method is
* invoked on initForm and again when user changes date in dateChooser
*/
private void updateChangelogDisplay() {
// init the helper;
String path = getWindowControl().getBusinessControl().getAsString();
EPNotificationsHelper helper = new EPNotificationsHelper(path, getLocale());
// get the date from the dateChooser component
Date compareDate = dateChooser.getDate();
EPMapShort mapShort = ePFMgr.loadMapShortByResourceId(map.getOlatResource().getResourceableId());
List<SubscriptionListItem> allItems = new ArrayList<SubscriptionListItem>(0);
// get subscriptionListItems according to map type
if (map instanceof EPDefaultMap || map instanceof EPStructuredMapTemplate) {
allItems = helper.getAllSubscrItemsDefault(compareDate, mapShort);
} else if (map instanceof EPStructuredMap) {
allItems = helper.getAllSubscrItemsStructured(compareDate, mapShort);
}
List<SubscriptionItemBundle> bundles = getItemBundlesForSubscriptionItems(allItems);
flc.contextPut("subscriptionItems", bundles);
}
use of org.olat.portfolio.model.structel.EPMapShort in project openolat by klemens.
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 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;
}
use of org.olat.portfolio.model.structel.EPMapShort in project openolat by klemens.
the class EPChangelogController method updateChangelogDisplay.
/**
* update the changelog-list according to selected date. this method is
* invoked on initForm and again when user changes date in dateChooser
*/
private void updateChangelogDisplay() {
// init the helper;
String path = getWindowControl().getBusinessControl().getAsString();
EPNotificationsHelper helper = new EPNotificationsHelper(path, getLocale());
// get the date from the dateChooser component
Date compareDate = dateChooser.getDate();
EPMapShort mapShort = ePFMgr.loadMapShortByResourceId(map.getOlatResource().getResourceableId());
List<SubscriptionListItem> allItems = new ArrayList<SubscriptionListItem>(0);
// get subscriptionListItems according to map type
if (map instanceof EPDefaultMap || map instanceof EPStructuredMapTemplate) {
allItems = helper.getAllSubscrItemsDefault(compareDate, mapShort);
} else if (map instanceof EPStructuredMap) {
allItems = helper.getAllSubscrItemsStructured(compareDate, mapShort);
}
List<SubscriptionItemBundle> bundles = getItemBundlesForSubscriptionItems(allItems);
flc.contextPut("subscriptionItems", bundles);
}
Aggregations