use of org.olat.portfolio.model.structel.EPStructuredMapTemplate in project openolat by klemens.
the class PortfolioRepositoryIndexer method doIndex.
@Override
public void doIndex(SearchResourceContext resourceContext, Object object, OlatFullIndexer indexWriter) throws IOException, InterruptedException {
if (!portfolioModule.isEnabled())
return;
if (isLogDebugEnabled())
logDebug("Index portfolio templates...");
RepositoryEntry repositoryEntry = (RepositoryEntry) object;
OLATResource ores = repositoryEntry.getOlatResource();
PortfolioStructure element = structureManager.loadPortfolioStructure(ores);
// only index templates
if (element instanceof EPStructuredMapTemplate) {
resourceContext.setDocumentType(TYPE);
resourceContext.setParentContextType(TYPE);
resourceContext.setParentContextName(repositoryEntry.getDisplayname());
resourceContext.setFilePath(element.getKey().toString());
Document document = PortfolioMapDocument.createDocument(resourceContext, element);
indexWriter.addDocument(document);
}
}
use of org.olat.portfolio.model.structel.EPStructuredMapTemplate in project openolat by klemens.
the class EPStructureDetailsController method formOK.
/**
* @see org.olat.core.gui.components.form.flexible.impl.FormBasicController#formOK(org.olat.core.gui.UserRequest)
*/
@Override
protected void formOK(final UserRequest ureq) {
editStructure = ePFMgr.reloadPortfolioStructure(editStructure);
editStructure.setTitle(titleEl.getValue());
editStructure.setDescription(descriptionEl.getValue());
editStructure.setArtefactRepresentationMode(viewRadio.getSelectedKey());
if (rootStructure instanceof EPStructuredMapTemplate && restrictionElements != null) {
clearErrors();
editStructure.getCollectRestrictions().clear();
setCollectRestrictions();
for (final SingleSelection restrictionElement : restrictionElements) {
final CollectRestriction restriction = (CollectRestriction) restrictionElement.getUserObject();
if (restriction.isValid()) {
final CollectRestriction cr = new CollectRestriction(restriction);
editStructure.getCollectRestrictions().add(cr);
}
}
}
ePFMgr.savePortfolioStructure(editStructure);
fireEvent(ureq, new EPStructureEvent(EPStructureEvent.CHANGE, editStructure));
}
use of org.olat.portfolio.model.structel.EPStructuredMapTemplate in project openolat by klemens.
the class EPStructureDetailsController method validateFormLogic.
/**
* @see org.olat.core.gui.components.form.flexible.impl.FormBasicController#validateFormLogic(org.olat.core.gui.UserRequest)
*/
@Override
protected boolean validateFormLogic(UserRequest ureq) {
if (rootStructure instanceof EPStructuredMapTemplate && restrictionElements != null) {
setCollectRestrictions();
clearErrors();
ArrayList<String> usedTypes = new ArrayList<String>();
int i = 0;
boolean hasError = false;
for (SingleSelection restrictionElement : restrictionElements) {
CollectRestriction restriction = (CollectRestriction) restrictionElement.getUserObject();
if (usedTypes.contains(restriction.getArtefactType())) {
StaticTextElement thisErrorEl = errorElements.get(i);
thisErrorEl.setVisible(true);
thisErrorEl.setValue(translate("collect.restriction.duplicate.type"));
hasError = true;
}
usedTypes.add(restriction.getArtefactType());
boolean hasRestriction = StringHelper.containsNonWhitespace(restriction.getRestriction());
boolean hasArtType = StringHelper.containsNonWhitespace(restriction.getArtefactType());
boolean hasAmount = restriction.getAmount() > 0;
boolean isValid = restriction.isValid();
if (!isValid && (hasRestriction || hasArtType || hasAmount)) {
StaticTextElement thisErrorEl = errorElements.get(i);
thisErrorEl.setVisible(true);
thisErrorEl.setValue(translate("collect.restriction.incomplete"));
hasError = true;
}
i++;
}
return !hasError;
}
return true;
}
use of org.olat.portfolio.model.structel.EPStructuredMapTemplate in project OpenOLAT by OpenOLAT.
the class EPStructureManager method removeAuthor.
/**
* Remove an author to repository entry linked to the map
* @param map
* @param author
*/
public void removeAuthor(PortfolioStructureMap map, Identity author) {
if (map instanceof EPStructuredMapTemplate) {
EPStructuredMapTemplate mapImpl = (EPStructuredMapTemplate) map;
RepositoryEntry re = repositoryManager.lookupRepositoryEntry(mapImpl.getOlatResource(), true);
if (repositoryEntyRelationDao.hasRole(author, re, GroupRoles.owner.name())) {
repositoryEntyRelationDao.removeRole(author, re, GroupRoles.owner.name());
}
}
}
use of org.olat.portfolio.model.structel.EPStructuredMapTemplate in project OpenOLAT by OpenOLAT.
the class EPStructureManager method addAuthor.
/**
* Add an author to the repository entry linked to the map
* @param map
* @param author
*/
public void addAuthor(PortfolioStructureMap map, Identity author) {
if (map instanceof EPStructuredMapTemplate) {
EPStructuredMapTemplate mapImpl = (EPStructuredMapTemplate) map;
RepositoryEntry re = repositoryManager.lookupRepositoryEntry(mapImpl.getOlatResource(), true);
if (!repositoryEntyRelationDao.hasRole(author, re, GroupRoles.owner.name())) {
repositoryEntyRelationDao.addRole(author, re, GroupRoles.owner.name());
}
}
}
Aggregations