use of org.olat.portfolio.model.artefacts.AbstractArtefact in project OpenOLAT by OpenOLAT.
the class EPArtefactManager method filterArtefactsByTags.
/**
* @param allArtefacts
* @param filterSettings (containing tags to filter for or boolean if filter should keep only artefacts without a tag)
* @param collect the tags found in the filtered artefacts
* @return filtered artefact list
*/
private void filterArtefactsByTags(List<AbstractArtefact> artefacts, EPFilterSettings filterSettings, Set<String> cloud) {
List<String> tags = filterSettings.getTagFilter();
// either search for artefacts with given tags, or such with no one!
List<AbstractArtefact> toRemove = new ArrayList<AbstractArtefact>();
if (tags != null && tags.size() != 0) {
// allowed!
for (AbstractArtefact artefact : artefacts) {
List<String> artefactTags = getArtefactTags(artefact);
if (!artefactTags.containsAll(tags)) {
toRemove.add(artefact);
} else if (cloud != null) {
cloud.addAll(artefactTags);
}
}
artefacts.removeAll(toRemove);
} else if (filterSettings.isNoTagFilterSet()) {
for (AbstractArtefact artefact : artefacts) {
if (!getArtefactTags(artefact).isEmpty()) {
toRemove.add(artefact);
}
}
artefacts.removeAll(toRemove);
}
}
use of org.olat.portfolio.model.artefacts.AbstractArtefact in project OpenOLAT by OpenOLAT.
the class EPArtefactManager method loadArtefactsByBusinessPath.
protected List<AbstractArtefact> loadArtefactsByBusinessPath(String businessPath, Identity author) {
if (!StringHelper.containsNonWhitespace(businessPath))
return null;
StringBuilder sb = new StringBuilder();
sb.append("select artefact from ").append(AbstractArtefact.class.getName()).append(" artefact").append(" where artefact.businessPath=:bpath");
if (author != null) {
sb.append(" and artefact.author=:ident");
}
DBQuery query = dbInstance.createQuery(sb.toString());
query.setString("bpath", businessPath);
if (author != null) {
query.setEntity("ident", author);
}
@SuppressWarnings("unchecked") List<AbstractArtefact> artefacts = query.list();
// if not found, it is an empty list
if (artefacts.isEmpty())
return null;
return artefacts;
}
use of org.olat.portfolio.model.artefacts.AbstractArtefact in project OpenOLAT by OpenOLAT.
the class EPAddArtefactController method prepareNewLiveBlogArtefactWizzard.
private void prepareNewLiveBlogArtefactWizzard(UserRequest ureq) {
EPArtefactHandler<?> artHandler = portfolioModule.getArtefactHandler(LiveBlogArtefact.TYPE);
AbstractArtefact artefact1 = artHandler.createArtefact();
artefact1.setAuthor(getIdentity());
artefact1.setCollectionDate(new Date());
// preset as signed by 60%
artefact1.setSignature(60);
Step start = new EPCreateLiveBlogArtefactStep00(ureq, preSelectedStruct, artefact1);
// no vfsTemp!, blog doesn't need a directory
StepRunnerCallback finish = new EPArtefactWizzardStepCallback();
collectStepsCtrl = new StepsMainRunController(ureq, getWindowControl(), start, finish, null, translate("create.blog.artefact.wizzard.title"), "o_sel_artefact_add_wizard o_sel_artefact_add_blog_wizard");
listenTo(collectStepsCtrl);
getWindowControl().pushAsModalDialog(collectStepsCtrl.getInitialComponent());
}
use of org.olat.portfolio.model.artefacts.AbstractArtefact in project OpenOLAT by OpenOLAT.
the class EPAddArtefactController method prepareFileArtefactWizzard.
/**
* prepare a file artefact and open with wizzard initialized with a special
* first step for file-artefacts
*
* @param ureq
*/
private void prepareFileArtefactWizzard(UserRequest ureq) {
EPArtefactHandler<?> artHandler = portfolioModule.getArtefactHandler(FileArtefact.FILE_ARTEFACT_TYPE);
AbstractArtefact artefact1 = artHandler.createArtefact();
artefact1.setAuthor(getIdentity());
artefact1.setSource(translate("file.artefact.source.info"));
artefact1.setCollectionDate(new Date());
artefact1.setSignature(-30);
vfsTemp = ePFMgr.getArtefactsTempContainer(getIdentity());
Step start = new EPCreateFileArtefactStep00(ureq, artefact1, preSelectedStruct, vfsTemp);
StepRunnerCallback finish = new EPArtefactWizzardStepCallback(vfsTemp);
collectStepsCtrl = new StepsMainRunController(ureq, getWindowControl(), start, finish, null, translate("create.file.artefact.wizzard.title"), "o_sel_artefact_add_wizard o_sel_artefact_add_file_wizard");
listenTo(collectStepsCtrl);
getWindowControl().pushAsModalDialog(collectStepsCtrl.getInitialComponent());
}
use of org.olat.portfolio.model.artefacts.AbstractArtefact in project OpenOLAT by OpenOLAT.
the class UserDeletionManagerTest method testDeleteIdentity.
@Test
public void testDeleteIdentity() {
String username = "id-to-del-" + UUID.randomUUID();
String email = username + "@frentix.com";
User user = userManager.createUser("first" + username, "last" + username, email);
user.setProperty(UserConstants.COUNTRY, "");
user.setProperty(UserConstants.CITY, "Basel");
user.setProperty(UserConstants.INSTITUTIONALNAME, "Del-23");
user.setProperty(UserConstants.INSTITUTIONALUSERIDENTIFIER, "Del-24");
Identity identity = securityManager.createAndPersistIdentityAndUser(username, null, user, BaseSecurityModule.getDefaultAuthProviderIdentifier(), username, "secret");
dbInstance.commitAndCloseSession();
// add some stuff
// a default map
PortfolioStructureMap map = epFrontendManager.createAndPersistPortfolioDefaultMap(identity, "A map to delete", "This map must be deleted");
Assert.assertNotNull(map);
// a template
PortfolioStructureMap template = epStructureManager.createPortfolioMapTemplate(identity, "A template to delete", "This template must be deleted");
epStructureManager.savePortfolioStructure(template);
// an artefact
AbstractArtefact artefact = epFrontendManager.createAndPersistArtefact(identity, "Forum");
dbInstance.commit();
Assert.assertNotNull(artefact);
// a group
BusinessGroup group = businessGroupService.createBusinessGroup(identity, "Group", "Group", -1, -1, false, false, null);
Assert.assertNotNull(group);
dbInstance.commitAndCloseSession();
// delete the identity
userDeletionManager.deleteIdentity(identity);
dbInstance.commit();
// check
Identity deletedIdentity = securityManager.loadIdentityByKey(identity.getKey());
Assert.assertNotNull(deletedIdentity);
// check that the artefacts are deleted
List<AbstractArtefact> artefacts = epFrontendManager.getArtefactPoolForUser(deletedIdentity);
Assert.assertNull(artefacts);
// check that the maps are deleted (1)
List<PortfolioStructure> maps = epFrontendManager.getStructureElementsForUser(deletedIdentity, ElementType.DEFAULT_MAP);
Assert.assertNotNull(maps);
Assert.assertEquals(0, maps.size());
// check that the maps are deleted (2)
PortfolioStructure deletedMap = epStructureManager.loadPortfolioStructureByKey(map.getKey());
Assert.assertNull(deletedMap);
// check membership of group
boolean isMember = businessGroupService.isIdentityInBusinessGroup(deletedIdentity, group);
Assert.assertFalse(isMember);
User deletedUser = deletedIdentity.getUser();
String institutionalName = deletedUser.getProperty(UserConstants.INSTITUTIONALNAME, null);
Assert.assertFalse(StringHelper.containsNonWhitespace(institutionalName));
String institutionalId = deletedUser.getProperty(UserConstants.INSTITUTIONALUSERIDENTIFIER, null);
Assert.assertFalse(StringHelper.containsNonWhitespace(institutionalId));
String deletedEmail = deletedUser.getProperty(UserConstants.EMAIL, null);
Assert.assertNotNull(deletedEmail);
Assert.assertFalse(email.equals(deletedEmail));
}
Aggregations