use of org.olat.portfolio.model.artefacts.AbstractArtefact in project OpenOLAT by OpenOLAT.
the class EPFrontendManagerTest method testTaggingOfArtefacts.
@Test
public void testTaggingOfArtefacts() {
AbstractArtefact artefact = epFrontendManager.createAndPersistArtefact(ident1, "Forum");
dbInstance.commitAndCloseSession();
assertNotNull(artefact);
epFrontendManager.setArtefactTag(ident1, artefact, "Hello");
epFrontendManager.setArtefactTag(ident2, artefact, "Hello");
epFrontendManager.setArtefactTag(ident2, artefact, "Tchao");
dbInstance.commitAndCloseSession();
List<String> tags = epFrontendManager.getArtefactTags(artefact);
assertNotNull(tags);
assertEquals(2, tags.size());
assertTrue(tags.get(0).equals("Hello") || tags.get(1).equals("Hello"));
assertTrue(tags.get(0).equals("Tchao") || tags.get(1).equals("Tchao"));
}
use of org.olat.portfolio.model.artefacts.AbstractArtefact in project OpenOLAT by OpenOLAT.
the class EPFrontendManagerTest method deleteMap_pageAndPolicy.
/**
* Delete a map with policies
*/
@Test
public void deleteMap_pageAndPolicy() {
Identity id = JunitTestHelper.createAndPersistIdentityAsRndUser("frtuse-5");
PortfolioStructureMap map = epFrontendManager.createAndPersistPortfolioDefaultMap(id, "Delete map", "Description");
PortfolioStructure page = epFrontendManager.createAndPersistPortfolioPage(map, "Page while be deleted", "Page description");
AbstractArtefact artefact = epFrontendManager.createAndPersistArtefact(id, "Forum");
epFrontendManager.addArtefactToStructure(id, artefact, page);
dbInstance.commitAndCloseSession();
// add policy
List<EPMapPolicy> policies = new ArrayList<EPMapPolicy>();
EPMapPolicy userPolicy = new EPMapPolicy();
userPolicy.setType(Type.user);
userPolicy.getIdentities().add(ident2);
userPolicy.getIdentities().add(ident3);
policies.add(userPolicy);
epFrontendManager.updateMapPolicies(map, policies);
dbInstance.commitAndCloseSession();
// reload and check
PortfolioStructure reloadedMap = epFrontendManager.loadPortfolioStructureByKey(map.getKey());
Assert.assertNotNull(reloadedMap);
OLATResource reloadedResource = reloadedMap.getOlatResource();
Assert.assertNotNull(reloadedResource);
Assert.assertEquals(map, reloadedMap);
boolean shared = epFrontendManager.isMapShared(reloadedResource);
Assert.assertTrue(shared);
boolean visibleToIdent2 = epFrontendManager.isMapVisible(ident2, reloadedResource);
Assert.assertTrue(visibleToIdent2);
// delete the map
epFrontendManager.deletePortfolioStructure(reloadedMap);
dbInstance.commit();
boolean deletedShared = epFrontendManager.isMapShared(reloadedResource);
Assert.assertFalse(deletedShared);
boolean deletedVisibleToIdent2 = epFrontendManager.isMapVisible(ident2, reloadedResource);
Assert.assertFalse(deletedVisibleToIdent2);
}
use of org.olat.portfolio.model.artefacts.AbstractArtefact in project OpenOLAT by OpenOLAT.
the class EPFrontendManagerTest method deleteMap_withOldPolicy.
@Test
public void deleteMap_withOldPolicy() {
// create map
Identity id = JunitTestHelper.createAndPersistIdentityAsRndUser("frtuse-7");
PortfolioStructureMap map = epFrontendManager.createAndPersistPortfolioDefaultMap(id, "Delete map", "Description");
PortfolioStructure page = epFrontendManager.createAndPersistPortfolioPage(map, "Page while be deleted", "Page description");
AbstractArtefact artefact = epFrontendManager.createAndPersistArtefact(id, "Forum");
epFrontendManager.addArtefactToStructure(id, artefact, page);
dbInstance.commit();
// create an old policy manually
SecurityGroup secGroup = securityManager.createAndPersistSecurityGroup();
Policy policy = securityManager.createAndPersistPolicy(secGroup, "allusers_" + Constants.PERMISSION_READ, map.getOlatResource());
Assert.assertNotNull(policy);
dbInstance.commitAndCloseSession();
// delete the map
PortfolioStructure reloadedMap = epFrontendManager.loadPortfolioStructureByKey(map.getKey());
epFrontendManager.deletePortfolioStructure(reloadedMap);
dbInstance.commit();
}
use of org.olat.portfolio.model.artefacts.AbstractArtefact in project OpenOLAT by OpenOLAT.
the class EPPerformanceTest method createAndFillArtefact.
/**
* create a heavy filled artefact!
* @param j number of artefact
* @return
*/
private AbstractArtefact createAndFillArtefact(int j) {
AbstractArtefact artefact = epFrontendManager.createAndPersistArtefact(ident1, ForumArtefact.FORUM_ARTEFACT_TYPE);
artefact.setFulltextContent(getLoremStringFactor512(2));
artefact.setReflexion(getLoremStringFactor512(3));
artefact.setDescription(LOREM_STRING_512);
artefact.setTitle("Test Artefact number" + j);
artefact.setSignature(60);
artefact.setCollectionDate(new Date());
artefact.setBusinessPath("a dummy businessPath entry");
artefact.setSource("some Forum was my source");
return epFrontendManager.updateArtefact(artefact);
}
use of org.olat.portfolio.model.artefacts.AbstractArtefact in project OpenOLAT by OpenOLAT.
the class EPPerformanceTest method internalTestManyArtefactCreation.
private void internalTestManyArtefactCreation(int artefactAmount) {
long start = System.currentTimeMillis();
Runtime r = Runtime.getRuntime();
for (int j = 0; j < artefactAmount; j++) {
AbstractArtefact artefact = createAndFillArtefact(j);
// tag the artefacts
if (j % 2 == 0) {
epFrontendManager.setArtefactTags(ident1, artefact, tagList1);
} else {
epFrontendManager.setArtefactTags(ident1, artefact, tagList2);
}
if (j % 10 == 0) {
DBFactory.getInstance().closeSession();
}
if (j % 100 == 0) {
logger.info("created another 100 artefacts! -> " + j);
logger.info(" free memory: " + r.freeMemory());
}
}
// for
// load the whole artefact list
long now = System.currentTimeMillis();
logger.info("created " + artefactAmount + " artefacts in: " + (now - start) + " ms.");
start = System.currentTimeMillis();
List<AbstractArtefact> artList = epFrontendManager.getArtefactPoolForUser(ident1);
now = System.currentTimeMillis();
logger.info("querying all of them took: " + (now - start) + " ms.");
assertEquals(artList.size(), artefactAmount);
// filter artefacts by tags
EPFilterSettings filterSettings = new EPFilterSettings();
filterSettings.setTagFilter(new ArrayList<String>(Arrays.asList("Schule")));
start = System.currentTimeMillis();
artList = epFrontendManager.filterArtefactsByFilterSettings(filterSettings, ident1, new Roles(false, false, false, false, false, false, false));
now = System.currentTimeMillis();
logger.info("filter artefacts by one tag took: " + (now - start) + " ms.");
assertEquals(artList.size(), artefactAmount / 2);
filterSettings.setTagFilter(tagList1);
start = System.currentTimeMillis();
artList = epFrontendManager.filterArtefactsByFilterSettings(filterSettings, ident1, new Roles(false, false, false, false, false, false, false));
now = System.currentTimeMillis();
logger.info("filter artefacts by tagList1 took: " + (now - start) + " ms.");
assertEquals(artList.size(), artefactAmount / 2);
}
Aggregations