Search in sources :

Example 81 with AbstractArtefact

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);
    }
}
Also used : AbstractArtefact(org.olat.portfolio.model.artefacts.AbstractArtefact) ArrayList(java.util.ArrayList)

Example 82 with AbstractArtefact

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;
}
Also used : AbstractArtefact(org.olat.portfolio.model.artefacts.AbstractArtefact) DBQuery(org.olat.core.commons.persistence.DBQuery)

Example 83 with AbstractArtefact

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());
}
Also used : EPCreateLiveBlogArtefactStep00(org.olat.modules.webFeed.portfolio.EPCreateLiveBlogArtefactStep00) AbstractArtefact(org.olat.portfolio.model.artefacts.AbstractArtefact) StepsMainRunController(org.olat.core.gui.control.generic.wizard.StepsMainRunController) Step(org.olat.core.gui.control.generic.wizard.Step) Date(java.util.Date) StepRunnerCallback(org.olat.core.gui.control.generic.wizard.StepRunnerCallback)

Example 84 with AbstractArtefact

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());
}
Also used : AbstractArtefact(org.olat.portfolio.model.artefacts.AbstractArtefact) StepsMainRunController(org.olat.core.gui.control.generic.wizard.StepsMainRunController) Step(org.olat.core.gui.control.generic.wizard.Step) Date(java.util.Date) StepRunnerCallback(org.olat.core.gui.control.generic.wizard.StepRunnerCallback)

Example 85 with AbstractArtefact

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));
}
Also used : PortfolioStructureMap(org.olat.portfolio.model.structel.PortfolioStructureMap) User(org.olat.core.id.User) BusinessGroup(org.olat.group.BusinessGroup) AbstractArtefact(org.olat.portfolio.model.artefacts.AbstractArtefact) PortfolioStructure(org.olat.portfolio.model.structel.PortfolioStructure) Identity(org.olat.core.id.Identity) Test(org.junit.Test)

Aggregations

AbstractArtefact (org.olat.portfolio.model.artefacts.AbstractArtefact)164 PortfolioStructure (org.olat.portfolio.model.structel.PortfolioStructure)70 Test (org.junit.Test)54 ArrayList (java.util.ArrayList)36 Date (java.util.Date)20 PortfolioStructureMap (org.olat.portfolio.model.structel.PortfolioStructureMap)18 DBQuery (org.olat.core.commons.persistence.DBQuery)10 Link (org.olat.core.gui.components.link.Link)10 Identity (org.olat.core.id.Identity)10 VFSContainer (org.olat.core.util.vfs.VFSContainer)10 CollectRestriction (org.olat.portfolio.model.restriction.CollectRestriction)10 List (java.util.List)8 EPFilterSettings (org.olat.portfolio.model.EPFilterSettings)8 GenericTreeNode (org.olat.core.gui.components.tree.GenericTreeNode)6 Step (org.olat.core.gui.control.generic.wizard.Step)6 StepRunnerCallback (org.olat.core.gui.control.generic.wizard.StepRunnerCallback)6 StepsMainRunController (org.olat.core.gui.control.generic.wizard.StepsMainRunController)6 OLATResourceable (org.olat.core.id.OLATResourceable)6 EPAbstractMap (org.olat.portfolio.model.structel.EPAbstractMap)6 EPStructureElement (org.olat.portfolio.model.structel.EPStructureElement)6