use of org.olat.portfolio.model.restriction.CollectRestriction in project openolat by klemens.
the class EPStructureManager method copyOrUpdateCollectRestriction.
/**
* @param source
* @param target
* @param update if true, the old existing restrictions will be overwritten
*/
private void copyOrUpdateCollectRestriction(PortfolioStructure source, PortfolioStructure target, boolean update) {
if (source == null || target == null) {
return;
}
List<CollectRestriction> targetRestrictions = target.getCollectRestrictions();
if ((source.getCollectRestrictions() == null || source.getCollectRestrictions().isEmpty()) && (target.getCollectRestrictions() != null && !target.getCollectRestrictions().isEmpty()) && update) {
// remove former existing restrictions
targetRestrictions.clear();
return;
}
if (update) {
targetRestrictions.clear();
}
for (CollectRestriction sourceRestriction : source.getCollectRestrictions()) {
CollectRestriction targetRestriction = new CollectRestriction();
targetRestriction.setArtefactType(sourceRestriction.getArtefactType());
targetRestriction.setAmount(sourceRestriction.getAmount());
targetRestriction.setRestriction(sourceRestriction.getRestriction());
targetRestrictions.add(targetRestriction);
}
}
use of org.olat.portfolio.model.restriction.CollectRestriction in project openolat by klemens.
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.restriction.CollectRestriction in project openolat by klemens.
the class EPCollectRestrictionResultController method setMessage.
public void setMessage(List<CollectRestriction> restrictions, boolean passed) {
List<String> errors = new ArrayList<String>();
for (CollectRestriction restriction : restrictions) {
String error = getMessage(restriction, getTranslator(), null);
errors.add(error);
}
Boolean passedObj = new Boolean(passed);
mainVc.contextPut("messages", errors);
mainVc.contextPut("restrictionsPassed", passedObj);
mainVc.setDirty(true);
}
use of org.olat.portfolio.model.restriction.CollectRestriction in project openolat by klemens.
the class EPStructureDetailsController method formInnerEvent.
@Override
protected void formInnerEvent(final UserRequest ureq, final FormItem source, final FormEvent event) {
if (source instanceof FormLink && source.getUserObject() instanceof CollectRestriction) {
final CollectRestriction restriction = (CollectRestriction) source.getUserObject();
if (source.getName().startsWith("collect.restriction.add.")) {
addCollectRestriction(restriction);
} else if (source.getName().startsWith("collect.restriction.del.")) {
deleteCollectRestriction(restriction);
}
// secure title and description before redraw UI
editStructure.setTitle(titleEl.getValue());
editStructure.setDescription(descriptionEl.getValue());
editStructure.setArtefactRepresentationMode(viewRadio.getSelectedKey());
setCollectRestrictions();
updateUI(ureq);
}
super.formInnerEvent(ureq, source, event);
}
use of org.olat.portfolio.model.restriction.CollectRestriction in project openolat by klemens.
the class EPStructureDetailsController method setCollectRestrictions.
protected void setCollectRestrictions() {
if (restrictionElements == null || restrictionElements.isEmpty()) {
return;
}
for (int i = 0; i < restrictionElements.size(); i++) {
final SingleSelection restrictionElement = restrictionElements.get(i);
final SingleSelection restrictToArtefactElement = restrictToArtefactElements.get(i);
final TextElement amountElement = amountElements.get(i);
final CollectRestriction cr = (CollectRestriction) restrictionElement.getUserObject();
String restriction = "";
if (restrictionElement.isOneSelected()) {
restriction = restrictionElement.getSelectedKey();
}
String artefactType = "";
if (restrictToArtefactElement.isOneSelected()) {
artefactType = restrictToArtefactElement.getSelectedKey();
}
final String amount = amountElement.getValue();
cr.setRestriction(restriction);
cr.setArtefactType(artefactType);
if (StringHelper.containsNonWhitespace(amount)) {
try {
cr.setAmount(Integer.parseInt(amount));
} catch (final NumberFormatException e) {
logWarn("Wrong format for number", e);
}
}
}
}
Aggregations