use of org.olat.portfolio.model.structel.PortfolioStructure in project openolat by klemens.
the class EPStructureManager method loadPortfolioStructure.
/**
* @param olatResourceable cannot be null
* @return The structure element or null if not found
*/
public PortfolioStructure loadPortfolioStructure(OLATResourceable olatResourceable) {
if (olatResourceable == null)
throw new NullPointerException();
OLATResource resource = resourceManager.findResourceable(olatResourceable);
if (resource == null)
return null;
StringBuilder sb = new StringBuilder();
sb.append("select element from ").append(EPStructureElement.class.getName()).append(" element").append(" where element.olatResource=:resource");
List<PortfolioStructure> resources = dbInstance.getCurrentEntityManager().createQuery(sb.toString(), PortfolioStructure.class).setParameter("resource", resource).getResultList();
// if not found, it is an empty list
return resources.isEmpty() ? null : resources.get(0);
}
use of org.olat.portfolio.model.structel.PortfolioStructure in project openolat by klemens.
the class EPFrontendManager method deleteUserData.
@Override
public void deleteUserData(Identity identity, String newDeletedUserName, File archivePath) {
deleteUsersArtefacts(identity);
List<PortfolioStructure> userPersonalMaps = getStructureElementsForUser(identity, ElementType.DEFAULT_MAP, ElementType.STRUCTURED_MAP);
for (PortfolioStructure portfolioStructure : userPersonalMaps) {
deletePortfolioStructure(portfolioStructure);
}
}
use of org.olat.portfolio.model.structel.PortfolioStructure in project openolat by klemens.
the class EPFrontendManager method deleteGroupDataFor.
@Override
public boolean deleteGroupDataFor(BusinessGroup group) {
final NarrowedPropertyManager npm = NarrowedPropertyManager.getInstance(group);
final Property mapKeyProperty = npm.findProperty(null, null, CollaborationTools.PROP_CAT_BG_COLLABTOOLS, CollaborationTools.KEY_PORTFOLIO);
if (mapKeyProperty != null) {
final Long mapKey = mapKeyProperty.getLongValue();
final String version = mapKeyProperty.getStringValue();
if (!"2".equals(version)) {
final PortfolioStructure map = loadPortfolioStructureByKey(mapKey);
if (map != null) {
deletePortfolioStructure(map);
}
}
return true;
}
return false;
}
use of org.olat.portfolio.model.structel.PortfolioStructure in project openolat by klemens.
the class EPFrontendManager method deleteArtefact.
/**
* delete an artefact and also its vfs-artefactContainer
* all used tags will also be deleted.
* @param artefact
*/
public void deleteArtefact(AbstractArtefact artefact) {
List<PortfolioStructure> linksToArtefact = structureManager.getAllReferencesForArtefact(artefact);
for (PortfolioStructure portfolioStructure : linksToArtefact) {
structureManager.removeArtefactFromStructure(artefact, portfolioStructure);
}
// load again as session might be closed between
artefact = artefactManager.loadArtefactByKey(artefact.getKey());
artefactManager.deleteArtefact(artefact);
}
use of org.olat.portfolio.model.structel.PortfolioStructure in project openolat by klemens.
the class EPStructureManager method getStructureElementsFromOthersWithoutPublic.
protected List<PortfolioStructure> getStructureElementsFromOthersWithoutPublic(IdentityRef ident, IdentityRef choosenOwner, ElementType... types) {
StringBuilder sb = new StringBuilder();
sb.append("select stEl from ").append(EPStructureElement.class.getName()).append(" stEl ").append(" inner join fetch stEl.olatResource as oRes ").append(" inner join stEl.groups as relGroup on relGroup.defaultGroup=false").append(" inner join relGroup.group as baseGroup").append(" inner join baseGroup.members as members").append(" where members.identity.key=:identityKey").append(" and (relGroup.validFrom is null or relGroup.validFrom<=:date)").append(" and (relGroup.validTo is null or relGroup.validTo>=:date)");
if (choosenOwner != null) {
sb.append(" and exists (select sgmsi from bgroupmember as sgmsi ").append(" where sgmsi.group=baseGroup and sgmsi.identity.key=:ownerKey").append(" )");
}
if (types != null && types.length > 0) {
sb.append(" and type(stEl) in (");
boolean first = true;
for (ElementType type : types) {
if (first)
first = false;
else
sb.append(",");
sb.append(getImplementation(type).getName());
}
sb.append(")");
}
TypedQuery<PortfolioStructure> query = dbInstance.getCurrentEntityManager().createQuery(sb.toString(), PortfolioStructure.class).setParameter("identityKey", ident.getKey()).setParameter("date", new Date());
if (choosenOwner != null) {
query.setParameter("ownerKey", choosenOwner.getKey());
}
return query.getResultList();
}
Aggregations