use of org.olat.portfolio.model.structel.EPStructureElementToGroupRelation in project openolat by klemens.
the class EPPolicyManager method applyPolicy.
private List<EPStructureElementToGroupRelation> applyPolicy(EPMapPolicy policy, PortfolioStructureMap map) {
List<EPStructureElementToGroupRelation> savedPolicies = new ArrayList<EPStructureElementToGroupRelation>();
switch(policy.getType()) {
case user:
savedPolicies.add(applyPolicyToUsers(policy, map));
break;
case group:
for (BusinessGroup group : policy.getGroups()) {
savedPolicies.add(applyPolicyToGroup(group.getBaseGroup(), policy, map));
}
break;
case invitation:
Invitation invitation = policy.getInvitation();
EPStructureElementToGroupRelation invitationPolicy = applyPolicyToInvitation(invitation, policy, map);
savedPolicies.add(invitationPolicy);
break;
case allusers:
EPStructureElementToGroupRelation allUsersPolicy = applyPolicyToAllUsers(policy, map);
savedPolicies.add(allUsersPolicy);
break;
}
return savedPolicies;
}
use of org.olat.portfolio.model.structel.EPStructureElementToGroupRelation in project openolat by klemens.
the class EPPolicyManager method applyPolicyToAllUsers.
private EPStructureElementToGroupRelation applyPolicyToAllUsers(EPMapPolicy wrapper, PortfolioStructureMap map) {
List<EPStructureElementToGroupRelation> currentRelations = wrapper.getRelations();
if (!currentRelations.isEmpty()) {
EPStructureElementToGroupRelation currentRelation = currentRelations.get(0);
updatePolicy(currentRelation, wrapper.getFrom(), wrapper.getTo());
return currentRelation;
}
return createBaseRelation(map, null, EPMapPolicy.Type.allusers.name(), wrapper.getFrom(), wrapper.getTo());
}
use of org.olat.portfolio.model.structel.EPStructureElementToGroupRelation in project openolat by klemens.
the class EPPolicyManager method applyPolicyToInvitation.
private EPStructureElementToGroupRelation applyPolicyToInvitation(Invitation invitation, EPMapPolicy policy, PortfolioStructureMap map) {
invitation = dbInstance.getCurrentEntityManager().merge(invitation);
Group secGroup = invitation.getBaseGroup();
Collection<EPStructureElementToGroupRelation> currentRelations = map.getGroups();
for (EPStructureElementToGroupRelation currentRelation : currentRelations) {
if (secGroup.equals(currentRelation.getGroup())) {
updatePolicy(currentRelation, policy.getFrom(), policy.getTo());
return currentRelation;
}
}
return createBaseRelation(map, secGroup, EPMapPolicy.Type.invitation.name(), policy.getFrom(), policy.getTo());
}
use of org.olat.portfolio.model.structel.EPStructureElementToGroupRelation in project openolat by klemens.
the class EPPolicyManager method updateMapPolicies.
/**
* Update the map policies of a map. The missing policies are deleted!
* @param map
* @param policies
*/
public PortfolioStructureMap updateMapPolicies(PortfolioStructureMap map, List<EPMapPolicy> policies) {
map = dbInstance.getCurrentEntityManager().merge(map);
List<EPStructureElementToGroupRelation> savedPolicies = new ArrayList<EPStructureElementToGroupRelation>();
for (EPMapPolicy wrapper : policies) {
savedPolicies.addAll(applyPolicy(wrapper, map));
}
Collection<EPStructureElementToGroupRelation> currentRelations = new ArrayList<>(map.getGroups());
for (EPStructureElementToGroupRelation currentRelation : currentRelations) {
if (currentRelation.isDefaultGroup()) {
continue;
}
boolean inUse = savedPolicies.contains(currentRelation);
if (!inUse) {
map.getGroups().remove(currentRelation);
}
}
return dbInstance.getCurrentEntityManager().merge(map);
}
use of org.olat.portfolio.model.structel.EPStructureElementToGroupRelation in project openolat by klemens.
the class EPStructureManager method importPortfolioMapTemplate.
/**
* Import the structure.
* @param root
* @param identity
* @return
*/
public PortfolioStructureMap importPortfolioMapTemplate(PortfolioStructure root, OLATResource resource) {
EPStructuredMapTemplate el = new EPStructuredMapTemplate();
fillStructureElement(el, root.getTitle(), root.getDescription(), resource);
EPStructuredMapTemplate rootTemp = (EPStructuredMapTemplate) root;
rootTemp.setStructureElSource(null);
el.setStyle(((EPStructureElement) root).getStyle());
importEPStructureElementRecursively((EPStructureElement) root, el);
// create an empty group
Group ownerGroup = groupDao.createGroup();
EPStructureElementToGroupRelation relation = createBaseRelation(el, ownerGroup);
Set<EPStructureElementToGroupRelation> relations = new HashSet<>();
relations.add(relation);
el.setGroups(relations);
return el;
}
Aggregations