Search in sources :

Example 11 with EPStructuredMapTemplate

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);
    }
}
Also used : EPStructuredMapTemplate(org.olat.portfolio.model.structel.EPStructuredMapTemplate) PortfolioStructure(org.olat.portfolio.model.structel.PortfolioStructure) OLATResource(org.olat.resource.OLATResource) RepositoryEntry(org.olat.repository.RepositoryEntry) PortfolioMapDocument(org.olat.search.service.document.PortfolioMapDocument) Document(org.apache.lucene.document.Document)

Example 12 with EPStructuredMapTemplate

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));
}
Also used : EPStructureEvent(org.olat.portfolio.ui.structel.EPStructureEvent) EPStructuredMapTemplate(org.olat.portfolio.model.structel.EPStructuredMapTemplate) SingleSelection(org.olat.core.gui.components.form.flexible.elements.SingleSelection) CollectRestriction(org.olat.portfolio.model.restriction.CollectRestriction)

Example 13 with EPStructuredMapTemplate

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;
}
Also used : EPStructuredMapTemplate(org.olat.portfolio.model.structel.EPStructuredMapTemplate) SingleSelection(org.olat.core.gui.components.form.flexible.elements.SingleSelection) ArrayList(java.util.ArrayList) CollectRestriction(org.olat.portfolio.model.restriction.CollectRestriction) StaticTextElement(org.olat.core.gui.components.form.flexible.elements.StaticTextElement)

Example 14 with EPStructuredMapTemplate

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());
        }
    }
}
Also used : EPStructuredMapTemplate(org.olat.portfolio.model.structel.EPStructuredMapTemplate) RepositoryEntry(org.olat.repository.RepositoryEntry)

Example 15 with EPStructuredMapTemplate

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());
        }
    }
}
Also used : EPStructuredMapTemplate(org.olat.portfolio.model.structel.EPStructuredMapTemplate) RepositoryEntry(org.olat.repository.RepositoryEntry)

Aggregations

EPStructuredMapTemplate (org.olat.portfolio.model.structel.EPStructuredMapTemplate)28 RepositoryEntry (org.olat.repository.RepositoryEntry)10 ArrayList (java.util.ArrayList)8 PortfolioStructure (org.olat.portfolio.model.structel.PortfolioStructure)8 HashSet (java.util.HashSet)6 Group (org.olat.basesecurity.Group)6 SingleSelection (org.olat.core.gui.components.form.flexible.elements.SingleSelection)6 CollectRestriction (org.olat.portfolio.model.restriction.CollectRestriction)6 EPStructureElementToGroupRelation (org.olat.portfolio.model.structel.EPStructureElementToGroupRelation)6 StaticTextElement (org.olat.core.gui.components.form.flexible.elements.StaticTextElement)4 EPStructuredMap (org.olat.portfolio.model.structel.EPStructuredMap)4 PortfolioStructureMap (org.olat.portfolio.model.structel.PortfolioStructureMap)4 OLATResource (org.olat.resource.OLATResource)4 Date (java.util.Date)2 Document (org.apache.lucene.document.Document)2 Test (org.junit.Test)2 CommentAndRatingService (org.olat.core.commons.services.commentAndRating.CommentAndRatingService)2 SubscriptionContext (org.olat.core.commons.services.notifications.SubscriptionContext)2 SubscriptionListItem (org.olat.core.commons.services.notifications.model.SubscriptionListItem)2 FormLink (org.olat.core.gui.components.form.flexible.elements.FormLink)2