use of org.olat.portfolio.model.structel.EPStructuredMapTemplate 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.EPStructuredMapTemplate in project openolat by klemens.
the class EPStructureManager method createPortfolioMapTemplate.
/**
* Create a map template, create an OLAT resource and a repository entry with a security group
* of type owner to the repository and add the identity has an owner.
* @param identity
* @param title
* @param description
* @return The structure element
*/
public PortfolioStructureMap createPortfolioMapTemplate(Identity identity, String title, String description) {
EPStructuredMapTemplate el = new EPStructuredMapTemplate();
fillStructureElement(el, title, description);
// create a repository entry with default security settings
RepositoryEntry re = createRepositoryEntry(identity, el.getOlatResource(), title);
dbInstance.commit();
Group ownerGroup = repositoryService.getDefaultGroup(re);
EPStructureElementToGroupRelation relation = createBaseRelation(el, ownerGroup);
Set<EPStructureElementToGroupRelation> relations = new HashSet<>();
relations.add(relation);
el.setGroups(relations);
return el;
}
use of org.olat.portfolio.model.structel.EPStructuredMapTemplate in project openolat by klemens.
the class EPStructureManager method removeStructureRecursively.
public void removeStructureRecursively(PortfolioStructure struct) {
List<PortfolioStructure> children = loadStructureChildren(struct);
for (PortfolioStructure childstruct : children) {
removeStructureRecursively(childstruct);
}
// remove artefact-links
List<AbstractArtefact> thisStructsArtefacts = getArtefacts(struct);
for (AbstractArtefact artefact : thisStructsArtefacts) {
removeArtefactFromStructure(artefact, struct, false);
}
// remove from parent
PortfolioStructure parent = loadStructureParent(struct);
if (parent == null && struct.getRoot() != null)
parent = struct.getRoot();
removeStructure(parent, struct);
// remove collect restriction
struct.getCollectRestrictions().clear();
// remove sharings
if (struct instanceof EPAbstractMap) {
((EPAbstractMap) struct).getGroups().clear();
}
// remove comments and ratings
CommentAndRatingService commentAndRatingService = CoreSpringFactory.getImpl(CommentAndRatingService.class);
commentAndRatingService.deleteAllIgnoringSubPath(struct.getOlatResource());
// FXOLAT-431 remove subscriptions if the current struct is a map
if (struct instanceof EPAbstractMap) {
SubscriptionContext subsContext = new SubscriptionContext(EPNotificationsHandler.TYPENNAME, struct.getResourceableId(), EPNotificationsHandler.TYPENNAME);
NotificationsManager.getInstance().delete(subsContext);
}
// remove structure itself
struct = (EPStructureElement) dbInstance.loadObject((EPStructureElement) struct);
dbInstance.deleteObject(struct);
if (struct instanceof EPAbstractMap) {
removeBaseGroup((EPAbstractMap) struct);
}
// which need the resource
if (!(struct instanceof EPStructuredMapTemplate)) {
resourceManager.deleteOLATResourceable(struct);
}
}
use of org.olat.portfolio.model.structel.EPStructuredMapTemplate in project openolat by klemens.
the class EPStructureManager method createAndPersistPortfolioMapTemplateFromEntry.
/**
* Create a template map with the given repsoitory entry and olat resource (in the repository entry).
* The repository entry must already be persisted.
* @param identity
* @param entry
* @return
*/
public PortfolioStructureMap createAndPersistPortfolioMapTemplateFromEntry(Identity identity, RepositoryEntry entry) {
EPStructuredMapTemplate el = (EPStructuredMapTemplate) loadPortfolioStructure(entry.getOlatResource());
if (el == null) {
el = new EPStructuredMapTemplate();
}
el.setTitle(entry.getDisplayname());
el.setDescription(entry.getDescription());
el.setOlatResource(entry.getOlatResource());
// create security group
Group group = repositoryEntyRelationDao.getDefaultGroup(entry);
if (group == null) {
group = groupDao.createGroup();
groupDao.addMembershipTwoWay(group, identity, GroupRoles.owner.name());
}
EPStructureElementToGroupRelation relation = createBaseRelation(el, group);
Set<EPStructureElementToGroupRelation> relations = new HashSet<>();
relations.add(relation);
el.setGroups(relations);
dbInstance.saveObject(el);
return el;
}
use of org.olat.portfolio.model.structel.EPStructuredMapTemplate in project openolat by klemens.
the class EPStructureManager method loadPortfolioStructuredMap.
public PortfolioStructureMap loadPortfolioStructuredMap(IdentityRef identity, PortfolioStructureMap template, OLATResourceable targetOres, String targetSubPath, String targetBusinessPath) {
if (template == null)
throw new NullPointerException();
if (!(template instanceof EPStructuredMapTemplate))
throw new AssertException("Only template are acceptable");
StringBuilder sb = new StringBuilder();
sb.append("select map from ").append(EPStructuredMap.class.getName()).append(" map").append(" left join fetch map.targetResource as targetResource").append(" inner join map.groups as relGroup on relGroup.defaultGroup=true").append(" inner join relGroup.group as baseGroup").append(" where map.structuredMapSource=:template");
if (targetOres != null) {
sb.append(" and targetResource.resourceableId=:resourceId").append(" and targetResource.resourceableTypeName=:resourceType");
}
if (targetSubPath != null) {
sb.append(" and targetResource.subPath=:subPath");
}
if (targetBusinessPath != null) {
sb.append(" and targetResource.businessPath=:businessPath");
}
sb.append(" and exists (select membership from bgroupmember as membership ").append(" where baseGroup=membership.group and membership.identity.key=:identityKey and membership.role='").append(GroupRoles.owner.name()).append("'").append(" )");
TypedQuery<PortfolioStructureMap> query = dbInstance.getCurrentEntityManager().createQuery(sb.toString(), PortfolioStructureMap.class).setParameter("template", template).setParameter("identityKey", identity.getKey());
if (targetOres != null) {
query.setParameter("resourceId", targetOres.getResourceableId());
query.setParameter("resourceType", targetOres.getResourceableTypeName());
}
if (targetSubPath != null) {
query.setParameter("subPath", targetSubPath);
}
if (targetBusinessPath != null) {
query.setParameter("businessPath", targetBusinessPath);
}
List<PortfolioStructureMap> maps = query.getResultList();
// if not found, it is an empty list
return maps.isEmpty() ? null : maps.get(0);
}
Aggregations