use of org.olat.portfolio.model.structel.PortfolioStructureMap in project OpenOLAT by OpenOLAT.
the class EPPageViewController method init.
private void init(UserRequest ureq) {
vC.contextPut("page", page);
PortfolioStructureMap parentOfPage = (PortfolioStructureMap) ePFMgr.loadStructureParent(page);
boolean parentMapClosed = StructureStatusEnum.CLOSED.equals(parentOfPage.getStatus());
vC.remove(vC.getComponent("checkResults"));
if (secCallback.isRestrictionsEnabled()) {
removeAsListenerAndDispose(resultCtrl);
List<CollectRestriction> restrictions = page.getCollectRestrictions();
if (!restrictions.isEmpty()) {
boolean check = ePFMgr.checkCollectRestriction(page);
resultCtrl = new EPCollectRestrictionResultController(ureq, getWindowControl());
resultCtrl.setMessage(restrictions, check);
vC.put("checkResults", resultCtrl.getInitialComponent());
listenTo(resultCtrl);
}
}
vC.remove(vC.getComponent("artefacts"));
List<AbstractArtefact> artefacts = ePFMgr.getArtefacts(page);
if (artefacts.size() != 0) {
EPMultiArtefactsController artefactCtrl = EPUIFactory.getConfigDependentArtefactsControllerForStructure(ureq, getWindowControl(), artefacts, page, secCallback);
vC.put("artefacts", artefactCtrl.getInitialComponent());
listenTo(artefactCtrl);
}
vC.remove(vC.getComponent("structElements"));
List<PortfolioStructure> structElements = ePFMgr.loadStructureChildren(page);
if (structElements.size() != 0) {
EPStructureElementsController structElCtrl = new EPStructureElementsController(ureq, getWindowControl(), structElements, secCallback, parentMapClosed);
vC.put("structElements", structElCtrl.getInitialComponent());
listenTo(structElCtrl);
}
vC.remove(vC.getComponent("addButton"));
if (!parentMapClosed && (secCallback.canAddArtefact() || secCallback.canAddStructure())) {
addButtonCtrl = new EPAddElementsController(ureq, getWindowControl(), page);
listenTo(addButtonCtrl);
if (secCallback.canAddArtefact()) {
addButtonCtrl.setShowLink(EPAddElementsController.ADD_ARTEFACT);
}
if (secCallback.canAddStructure()) {
addButtonCtrl.setShowLink(EPAddElementsController.ADD_STRUCTUREELEMENT);
}
vC.put("addButton", addButtonCtrl.getInitialComponent());
}
vC.remove(vC.getComponent("commentCtrl"));
if (secCallback.canCommentAndRate()) {
removeAsListenerAndDispose(commentsAndRatingCtr);
boolean anonym = ureq.getUserSession().getRoles().isGuestOnly();
CommentAndRatingSecurityCallback ratingSecCallback = new CommentAndRatingDefaultSecurityCallback(getIdentity(), false, anonym);
commentsAndRatingCtr = new UserCommentsAndRatingsController(ureq, getWindowControl(), map.getOlatResource(), page.getKey().toString(), ratingSecCallback, true, true, true);
listenTo(commentsAndRatingCtr);
vC.put("commentCtrl", commentsAndRatingCtr.getInitialComponent());
}
}
use of org.olat.portfolio.model.structel.PortfolioStructureMap in project OpenOLAT by OpenOLAT.
the class AbstractPortfolioMapIndexer method doIndex.
@Override
public void doIndex(SearchResourceContext searchResourceContext, Object object, OlatFullIndexer indexerWriter) throws IOException, InterruptedException {
if (!portfolioModule.isEnabled())
return;
SearchResourceContext resourceContext = new SearchResourceContext();
int firstResult = 0;
List<PortfolioStructure> structures = null;
do {
structures = frontendManager.getStructureElements(firstResult, 500, getElementType());
for (PortfolioStructure structure : structures) {
if (structure instanceof PortfolioStructureMap) {
PortfolioStructureMap map = (PortfolioStructureMap) structure;
if (accept(map)) {
resourceContext.setDocumentType(getDocumentType());
resourceContext.setBusinessControlFor(map.getOlatResource());
Document document = PortfolioMapDocument.createDocument(resourceContext, map);
indexerWriter.addDocument(document);
}
}
}
firstResult += structures.size();
} while (structures != null && structures.size() == BATCH_SIZE);
}
use of org.olat.portfolio.model.structel.PortfolioStructureMap in project OpenOLAT by OpenOLAT.
the class OLATUpgrade_11_0_0 method processAssessmentPropertyForPortfolio.
private void processAssessmentPropertyForPortfolio(Identity assessedIdentity, AssessmentEntryImpl entry, PortfolioCourseNode cNode, ICourse course) {
entry.setAssessmentStatus(AssessmentEntryStatus.notStarted);
Long courseResId = course.getCourseEnvironment().getCourseResourceableId();
RepositoryEntry mapEntry = cNode.getReferencedRepositoryEntry();
if (mapEntry != null) {
PortfolioStructureMap template = (PortfolioStructureMap) ePFMgr.loadPortfolioStructure(mapEntry.getOlatResource());
if (template != null) {
OLATResourceable courseOres = OresHelper.createOLATResourceableInstance(CourseModule.class, courseResId);
PortfolioStructureMap copy = ePFMgr.loadPortfolioStructureMap(assessedIdentity, template, courseOres, cNode.getIdent(), null);
if (copy != null) {
String status = copy.getStatus();
if (StructureStatusEnum.CLOSED.equals(status)) {
entry.setAssessmentStatus(AssessmentEntryStatus.inReview);
} else {
entry.setAssessmentStatus(AssessmentEntryStatus.inProgress);
}
}
}
}
}
use of org.olat.portfolio.model.structel.PortfolioStructureMap in project OpenOLAT by OpenOLAT.
the class EPImportTest method testCopy.
@Test
public void testCopy() throws URISyntaxException {
Identity ident = JunitTestHelper.createAndPersistIdentityAsRndUser("ImPort-1");
// save the map
PortfolioStructureMap map = epStructureManager.createPortfolioMapTemplate(ident, "import-map-1", "map-template");
epStructureManager.savePortfolioStructure(map);
dbInstance.commitAndCloseSession();
// check that the author are in the
OLATResource resource = resourceManager.findResourceable(map.getResourceableId(), map.getResourceableTypeName());
RepositoryEntry re = repositoryManager.lookupRepositoryEntry(resource, false);
Assert.assertNotNull(re);
dbInstance.commitAndCloseSession();
RepositoryEntry copy = repositoryService.copy(re, ident, "ImPort - (Copy 1)");
Assert.assertNotNull(copy);
dbInstance.commitAndCloseSession();
PortfolioStructure copiedMap = epFrontendManager.loadPortfolioStructure(copy.getOlatResource());
Assert.assertNotNull(copiedMap);
}
use of org.olat.portfolio.model.structel.PortfolioStructureMap in project OpenOLAT by OpenOLAT.
the class EPPolicyManagerTest method createPolicy_invitation.
@Test
public void createPolicy_invitation() {
Identity user = JunitTestHelper.createAndPersistIdentityAsRndUser("Policy-User-2-");
PortfolioStructureMap map = epFrontendManager.createAndPersistPortfolioDefaultMap(user, "Title", "Description");
Invitation invitation = invitationDao.createAndPersistInvitation();
dbInstance.commit();
invitation.setFirstName("John");
invitation.setLastName("Smith Portfolio");
EPMapPolicy policy = new EPMapPolicy();
policy.setType(EPMapPolicy.Type.invitation);
policy.setInvitation(invitation);
policyManager.updateMapPolicies(map, Collections.singletonList(policy));
dbInstance.commitAndCloseSession();
// check that the policy is saved
List<EPMapPolicy> policies = policyManager.getMapPolicies(map);
Assert.assertNotNull(policies);
Assert.assertEquals(1, policies.size());
EPMapPolicy invitationPolicy = policies.get(0);
Assert.assertEquals(EPMapPolicy.Type.invitation, invitationPolicy.getType());
// convert invitation to identity
Identity invitee = invitationDao.createIdentityFrom(invitation, Locale.ENGLISH);
dbInstance.commitAndCloseSession();
// check is shared
boolean shared = policyManager.isMapShared(map.getOlatResource());
Assert.assertTrue(shared);
boolean visible = epFrontendManager.isMapVisible(invitee, map.getOlatResource());
Assert.assertTrue(visible);
}
Aggregations