Search in sources :

Example 11 with ReferenceManager

use of org.olat.resource.references.ReferenceManager in project OpenOLAT by OpenOLAT.

the class PortfolioHandler method readyToDelete.

@Override
public boolean readyToDelete(RepositoryEntry entry, Identity identity, Roles roles, Locale locale, ErrorList errors) {
    EPFrontendManager ePFMgr = CoreSpringFactory.getImpl(EPFrontendManager.class);
    PortfolioStructure map = ePFMgr.loadPortfolioStructure(entry.getOlatResource());
    if (map instanceof EPStructuredMapTemplate) {
        EPStructuredMapTemplate exercise = (EPStructuredMapTemplate) map;
        if (ePFMgr.isTemplateInUse(exercise, null, null, null)) {
            return false;
        }
    }
    ReferenceManager refM = CoreSpringFactory.getImpl(ReferenceManager.class);
    String referencesSummary = refM.getReferencesToSummary(entry.getOlatResource(), locale);
    if (referencesSummary != null) {
        Translator translator = Util.createPackageTranslator(RepositoryManager.class, locale);
        errors.setError(translator.translate("details.delete.error.references", new String[] { referencesSummary, entry.getDisplayname() }));
        return false;
    }
    return true;
}
Also used : EPStructuredMapTemplate(org.olat.portfolio.model.structel.EPStructuredMapTemplate) Translator(org.olat.core.gui.translator.Translator) PortfolioStructure(org.olat.portfolio.model.structel.PortfolioStructure) EPFrontendManager(org.olat.portfolio.manager.EPFrontendManager) ReferenceManager(org.olat.resource.references.ReferenceManager)

Example 12 with ReferenceManager

use of org.olat.resource.references.ReferenceManager in project OpenOLAT by OpenOLAT.

the class PodcastHandler method readyToDelete.

@Override
public boolean readyToDelete(RepositoryEntry entry, Identity identity, Roles roles, Locale locale, ErrorList errors) {
    ReferenceManager refM = CoreSpringFactory.getImpl(ReferenceManager.class);
    String referencesSummary = refM.getReferencesToSummary(entry.getOlatResource(), locale);
    if (referencesSummary != null) {
        Translator translator = Util.createPackageTranslator(RepositoryManager.class, locale);
        errors.setError(translator.translate("details.delete.error.references", new String[] { referencesSummary, entry.getDisplayname() }));
        return false;
    }
    return true;
}
Also used : Translator(org.olat.core.gui.translator.Translator) ReferenceManager(org.olat.resource.references.ReferenceManager)

Example 13 with ReferenceManager

use of org.olat.resource.references.ReferenceManager in project OpenOLAT by OpenOLAT.

the class QTIHandler method readyToDelete.

@Override
public boolean readyToDelete(RepositoryEntry entry, Identity identity, Roles roles, Locale locale, ErrorList errors) {
    ReferenceManager refM = CoreSpringFactory.getImpl(ReferenceManager.class);
    String referencesSummary = refM.getReferencesToSummary(entry.getOlatResource(), locale);
    if (referencesSummary != null) {
        Translator translator = Util.createPackageTranslator(RepositoryManager.class, locale);
        errors.setError(translator.translate("details.delete.error.references", new String[] { referencesSummary, entry.getDisplayname() }));
        return false;
    }
    if (CoordinatorManager.getInstance().getCoordinator().getLocker().isLocked(entry.getOlatResource(), null)) {
        Translator translator = Util.createPackageTranslator(RepositoryManager.class, locale);
        errors.setError(translator.translate("details.delete.error.editor", new String[] { entry.getDisplayname() }));
        return false;
    }
    return true;
}
Also used : Translator(org.olat.core.gui.translator.Translator) ReferenceManager(org.olat.resource.references.ReferenceManager)

Example 14 with ReferenceManager

use of org.olat.resource.references.ReferenceManager in project OpenOLAT by OpenOLAT.

the class PublishProcess method deleteRefs.

/**
 * Delete references to resourceables of node with ident courseNodeIdent.
 *
 * @param courseNode
 */
private void deleteRefs(CourseNode courseNode) {
    ReferenceManager refM = CoreSpringFactory.getImpl(ReferenceManager.class);
    List<Reference> courseRefs = refM.getReferences(course);
    for (Iterator<Reference> iter = courseRefs.iterator(); iter.hasNext(); ) {
        Reference ref = iter.next();
        if (!ref.getUserdata().equals(courseNode.getIdent()))
            continue;
        refM.delete(ref);
        break;
    }
}
Also used : Reference(org.olat.resource.references.Reference) ReferenceManager(org.olat.resource.references.ReferenceManager)

Example 15 with ReferenceManager

use of org.olat.resource.references.ReferenceManager in project openolat by klemens.

the class PortfolioHandler method readyToDelete.

@Override
public boolean readyToDelete(RepositoryEntry entry, Identity identity, Roles roles, Locale locale, ErrorList errors) {
    EPFrontendManager ePFMgr = CoreSpringFactory.getImpl(EPFrontendManager.class);
    PortfolioStructure map = ePFMgr.loadPortfolioStructure(entry.getOlatResource());
    if (map instanceof EPStructuredMapTemplate) {
        EPStructuredMapTemplate exercise = (EPStructuredMapTemplate) map;
        if (ePFMgr.isTemplateInUse(exercise, null, null, null)) {
            return false;
        }
    }
    ReferenceManager refM = CoreSpringFactory.getImpl(ReferenceManager.class);
    String referencesSummary = refM.getReferencesToSummary(entry.getOlatResource(), locale);
    if (referencesSummary != null) {
        Translator translator = Util.createPackageTranslator(RepositoryManager.class, locale);
        errors.setError(translator.translate("details.delete.error.references", new String[] { referencesSummary, entry.getDisplayname() }));
        return false;
    }
    return true;
}
Also used : EPStructuredMapTemplate(org.olat.portfolio.model.structel.EPStructuredMapTemplate) Translator(org.olat.core.gui.translator.Translator) PortfolioStructure(org.olat.portfolio.model.structel.PortfolioStructure) EPFrontendManager(org.olat.portfolio.manager.EPFrontendManager) ReferenceManager(org.olat.resource.references.ReferenceManager)

Aggregations

ReferenceManager (org.olat.resource.references.ReferenceManager)18 Translator (org.olat.core.gui.translator.Translator)16 CorruptedCourseException (org.olat.course.CorruptedCourseException)2 EPFrontendManager (org.olat.portfolio.manager.EPFrontendManager)2 EPStructuredMapTemplate (org.olat.portfolio.model.structel.EPStructuredMapTemplate)2 PortfolioStructure (org.olat.portfolio.model.structel.PortfolioStructure)2 Reference (org.olat.resource.references.Reference)2 UserManager (org.olat.user.UserManager)2