use of org.olat.portfolio.model.structel.EPStructureElementToGroupRelation in project openolat by klemens.
the class EPPolicyManager method createBaseRelation.
private EPStructureElementToGroupRelation createBaseRelation(PortfolioStructureMap map, Group group, String role, Date from, Date to) {
// create security group
EPStructureElementToGroupRelation relation = new EPStructureElementToGroupRelation();
relation.setDefaultGroup(false);
relation.setCreationDate(new Date());
relation.setGroup(group);
relation.setStructureElement((EPStructureElement) map);
relation.setRole(role);
relation.setValidFrom(from);
relation.setValidTo(to);
map.getGroups().add(relation);
return relation;
}
use of org.olat.portfolio.model.structel.EPStructureElementToGroupRelation in project openolat by klemens.
the class EPStructureManager method createBaseRelation.
private EPStructureElementToGroupRelation createBaseRelation(EPStructureElement element, Group ownerGroup) {
// create security group
EPStructureElementToGroupRelation relation = new EPStructureElementToGroupRelation();
relation.setDefaultGroup(true);
relation.setCreationDate(new Date());
relation.setGroup(ownerGroup);
relation.setStructureElement(element);
return relation;
}
use of org.olat.portfolio.model.structel.EPStructureElementToGroupRelation in project openolat by klemens.
the class EPStructureManager method createPortfolioStructuredMap.
protected PortfolioStructureMap createPortfolioStructuredMap(PortfolioStructureMap template, Identity identity, String title, String description, OLATResourceable targetOres, String targetSubPath, String targetBusinessPath) {
EPStructuredMap el = new EPStructuredMap();
el.setStructuredMapSource((EPStructuredMapTemplate) template);
el.setStructureElSource(template.getKey());
if (template != null) {
copyOrUpdateCollectRestriction(template, el, false);
}
EPTargetResource targetResource = el.getTargetResource();
if (targetOres != null) {
targetResource.setResourceableId(targetOres.getResourceableId());
targetResource.setResourceableTypeName(targetOres.getResourceableTypeName());
}
if (StringHelper.containsNonWhitespace(targetSubPath)) {
targetResource.setSubPath(targetSubPath);
}
if (StringHelper.containsNonWhitespace(targetBusinessPath)) {
targetResource.setBusinessPath(targetBusinessPath);
}
fillStructureElement(el, title, description);
// create security group
EPStructureElementToGroupRelation ownerGroup = createBaseGroup(el, identity);
Set<EPStructureElementToGroupRelation> relations = new HashSet<>();
relations.add(ownerGroup);
el.setGroups(relations);
return el;
}
use of org.olat.portfolio.model.structel.EPStructureElementToGroupRelation 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.EPStructureElementToGroupRelation 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;
}
Aggregations