Search in sources :

Example 61 with CoursePropertyManager

use of org.olat.course.properties.CoursePropertyManager in project OpenOLAT by OpenOLAT.

the class DENCourseNode method cleanupOnDelete.

@Override
public void cleanupOnDelete(ICourse course) {
    super.cleanupOnDelete(course);
    CoursePropertyManager cpm = PersistingCoursePropertyManager.getInstance(course);
    cpm.deleteNodeProperties(this, CONF_CANCEL_ENROLL_ENABLED);
    DENManager denManager = DENManager.getInstance();
    // empty List as first argument, so all dates for this course node are going to delete
    denManager.persistDENSettings(new ArrayList<KalendarEvent>(), course, this);
}
Also used : DENManager(de.bps.course.nodes.den.DENManager) KalendarEvent(org.olat.commons.calendar.model.KalendarEvent) CoursePropertyManager(org.olat.course.properties.CoursePropertyManager) PersistingCoursePropertyManager(org.olat.course.properties.PersistingCoursePropertyManager)

Example 62 with CoursePropertyManager

use of org.olat.course.properties.CoursePropertyManager in project OpenOLAT by OpenOLAT.

the class PublishProcess method publishToCatalog.

protected void publishToCatalog(String choiceValue, List<CategoryLabel> labels) {
    CoursePropertyManager cpm = course.getCourseEnvironment().getCoursePropertyManager();
    CourseNode rootNode = course.getRunStructure().getRootNode();
    Property prop = cpm.findCourseNodeProperty(rootNode, null, null, "catalog-choice");
    if (prop == null) {
        prop = cpm.createCourseNodePropertyInstance(rootNode, null, null, "catalog-choice", null, null, choiceValue, null);
        cpm.saveProperty(prop);
    } else {
        prop.setStringValue(choiceValue);
        cpm.updateProperty(prop);
    }
    CatalogManager cm = CoreSpringFactory.getImpl(CatalogManager.class);
    List<CatalogEntry> refParentCategories = cm.getCatalogCategoriesFor(repositoryEntry);
    a_a: for (CategoryLabel label : labels) {
        CatalogEntry category = label.getCategory();
        CatalogEntry parentCategory = label.getParentCategory();
        if (label.isDeleted()) {
            // test
            if (category.getKey() != null) {
                List<CatalogEntry> children = cm.getChildrenOf(category);
                for (CatalogEntry child : children) {
                    if (child.getRepositoryEntry() != null && child.getRepositoryEntry().equalsByPersistableKey(repositoryEntry)) {
                        cm.deleteCatalogEntry(child);
                    }
                }
            }
        } else if (category.getKey() == null) {
            // it's a new entry -> check if not already in catalog at this position
            for (Iterator<CatalogEntry> refIt = refParentCategories.iterator(); refIt.hasNext(); ) {
                CatalogEntry refParentCategory = refIt.next();
                if (refParentCategory.equalsByPersistableKey(parentCategory)) {
                    refIt.remove();
                    break a_a;
                }
            }
            category.setOwnerGroup(BaseSecurityManager.getInstance().createAndPersistSecurityGroup());
            cm.addCatalogEntry(parentCategory, category);
        } else {
            for (Iterator<CatalogEntry> refIt = refParentCategories.iterator(); refIt.hasNext(); ) {
                CatalogEntry refParentCategory = refIt.next();
                if (refParentCategory.equalsByPersistableKey(category)) {
                    refIt.remove();
                }
            }
        }
    }
}
Also used : CatalogEntry(org.olat.repository.CatalogEntry) List(java.util.List) ArrayList(java.util.ArrayList) CourseNode(org.olat.course.nodes.CourseNode) CategoryLabel(org.olat.course.editor.PublishStepCatalog.CategoryLabel) Property(org.olat.properties.Property) CoursePropertyManager(org.olat.course.properties.CoursePropertyManager) CatalogManager(org.olat.repository.manager.CatalogManager)

Example 63 with CoursePropertyManager

use of org.olat.course.properties.CoursePropertyManager in project OpenOLAT by OpenOLAT.

the class CustomDBController method updateDBList.

private void updateDBList(FormItemContainer formLayout) {
    ICourse course = CourseFactory.loadCourse(courseKey);
    CoursePropertyManager cpm = course.getCourseEnvironment().getCoursePropertyManager();
    CourseNode rootNode = ((CourseEditorTreeNode) course.getEditorTreeModel().getRootNode()).getCourseNode();
    Property p = cpm.findCourseNodeProperty(rootNode, null, null, CustomDBMainController.CUSTOM_DB);
    List<String> databases = new ArrayList<>();
    if (p != null && p.getTextValue() != null) {
        String[] dbs = p.getTextValue().split(":");
        for (String db : dbs) {
            databases.add(db);
        }
    }
    List<String> currentlyUsed = courseDbManager.getUsedCategories(course);
    for (String db : currentlyUsed) {
        if (!databases.contains(db)) {
            databases.add(db);
        }
    }
    int count = 0;
    for (String db : databases) {
        if (!StringHelper.containsNonWhitespace(db))
            continue;
        uifactory.addStaticExampleText("category_" + count, "customDb.category", db, formLayout);
        String url = Settings.getServerContextPathURI() + RestSecurityHelper.SUB_CONTEXT + "/repo/courses/" + courseKey + "/db/" + db;
        uifactory.addStaticExampleText("url_" + count, "customDb.url", url, formLayout);
        final FormLayoutContainer buttonLayout = FormLayoutContainer.createButtonLayout("buttonLayout_" + count, getTranslator());
        formLayout.add(buttonLayout);
        FormLink resetDb = uifactory.addFormLink("db-reset_" + count, "customDb.reset", "customDb.reset", buttonLayout, Link.BUTTON_SMALL);
        resetDb.setUserObject(db);
        resetDb.setVisible(!readOnly);
        resetDbs.add(resetDb);
        FormLink deleteDb = uifactory.addFormLink("db-delete_" + count, "delete", "delete", buttonLayout, Link.BUTTON_SMALL);
        deleteDb.setUserObject(db);
        deleteDb.setVisible(!readOnly);
        deleteDbs.add(deleteDb);
        FormLink exportDb = uifactory.addFormLink("db-export_" + count, "customDb.export", "customDb.export", buttonLayout, Link.BUTTON_SMALL);
        exportDb.setUserObject(db);
        exportDbs.add(exportDb);
        count++;
    }
}
Also used : CourseEditorTreeNode(org.olat.course.tree.CourseEditorTreeNode) ArrayList(java.util.ArrayList) FormLayoutContainer(org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer) ICourse(org.olat.course.ICourse) CourseNode(org.olat.course.nodes.CourseNode) FormLink(org.olat.core.gui.components.form.flexible.elements.FormLink) Property(org.olat.properties.Property) CoursePropertyManager(org.olat.course.properties.CoursePropertyManager)

Example 64 with CoursePropertyManager

use of org.olat.course.properties.CoursePropertyManager in project OpenOLAT by OpenOLAT.

the class TaskFolderCallback method event.

/**
 * @see org.olat.core.gui.control.DefaultController#event(org.olat.core.gui.UserRequest,
 *      org.olat.core.gui.components.Component, org.olat.core.gui.control.Event)
 */
@Override
public void event(UserRequest ureq, Component source, Event event) {
    if (log.isDebug())
        log.debug("event source=" + source + " " + event.toString());
    if (source == btfButton) {
        // check if there are already assigned tasks
        CoursePropertyManager cpm = PersistingCoursePropertyManager.getInstance(course);
        List<Property> assignedProps = cpm.listCourseNodeProperties(node, null, null, TaskController.PROP_ASSIGNED);
        if (assignedProps.size() == 0) {
            // no task assigned
            String relPath = TACourseNode.getTaskFolderPathRelToFolderRoot(course, node);
            OlatRootFolderImpl rootFolder = new OlatRootFolderImpl(relPath, null);
            OlatNamedContainerImpl namedFolder = new OlatNamedContainerImpl(translate("taskfolder"), rootFolder);
            namedFolder.setLocalSecurityCallback(getTaskFolderSecCallback(relPath));
            frc = new FolderRunController(namedFolder, false, ureq, getWindowControl());
            // listenTo(frc);
            frc.addControllerListener(this);
            CloseableModalController cmc = new CloseableModalController(getWindowControl(), translate("folder.close"), frc.getInitialComponent());
            cmc.activate();
        } else {
            // already assigned task => open dialog with warn
            String[] args = new String[] { new Integer(assignedProps.size()).toString() };
            dialogBoxController = activateOkCancelDialog(ureq, "", getTranslator().translate("taskfolder.overwriting.confirm", args), dialogBoxController);
        }
    } else if (source == vfButton) {
        // switch to new dialog
        OlatNamedContainerImpl namedContainer = TACourseNode.getNodeFolderContainer(node, course.getCourseEnvironment());
        Quota quota = QuotaManager.getInstance().getCustomQuota(namedContainer.getRelPath());
        if (quota == null) {
            Quota defQuota = QuotaManager.getInstance().getDefaultQuota(QuotaConstants.IDENTIFIER_DEFAULT_NODES);
            quota = QuotaManager.getInstance().createQuota(namedContainer.getRelPath(), defQuota.getQuotaKB(), defQuota.getUlLimitKB());
        }
        SubscriptionContext subContext = SolutionFileUploadNotificationHandler.getSubscriptionContext(course.getCourseEnvironment(), node);
        VFSSecurityCallback secCallback = new FullAccessWithQuotaCallback(quota, subContext);
        namedContainer.setLocalSecurityCallback(secCallback);
        FolderRunController folderCtrl = new FolderRunController(namedContainer, false, ureq, getWindowControl());
        CloseableModalController cmc = new CloseableModalController(getWindowControl(), translate("close"), folderCtrl.getInitialComponent());
        cmc.activate();
    } else if (source == editScoringConfigButton) {
        scoringController.setDisplayOnly(false);
        editScoring.contextPut("isOverwriting", new Boolean(true));
    }
}
Also used : CloseableModalController(org.olat.core.gui.control.generic.closablewrapper.CloseableModalController) OlatNamedContainerImpl(org.olat.core.commons.modules.bc.vfs.OlatNamedContainerImpl) OlatRootFolderImpl(org.olat.core.commons.modules.bc.vfs.OlatRootFolderImpl) FullAccessWithQuotaCallback(org.olat.core.util.vfs.callbacks.FullAccessWithQuotaCallback) Quota(org.olat.core.util.vfs.Quota) FolderRunController(org.olat.core.commons.modules.bc.FolderRunController) SubscriptionContext(org.olat.core.commons.services.notifications.SubscriptionContext) Property(org.olat.properties.Property) VFSSecurityCallback(org.olat.core.util.vfs.callbacks.VFSSecurityCallback) CoursePropertyManager(org.olat.course.properties.CoursePropertyManager) PersistingCoursePropertyManager(org.olat.course.properties.PersistingCoursePropertyManager)

Example 65 with CoursePropertyManager

use of org.olat.course.properties.CoursePropertyManager in project OpenOLAT by OpenOLAT.

the class StatusManager method loadStatusFormData.

/**
 * Initializes the user profile with the data from the database
 *
 * @param ident The current Subject
 */
public void loadStatusFormData(StatusForm statusForm, CourseNode node, UserCourseEnvironment userCourseEnv) {
    Identity identity = userCourseEnv.getIdentityEnvironment().getIdentity();
    CoursePropertyManager cpm = userCourseEnv.getCourseEnvironment().getCoursePropertyManager();
    Property statusProperty;
    statusProperty = cpm.findCourseNodeProperty(node, identity, null, PROPERTY_KEY_STATUS);
    if (statusProperty == null) {
        // found no status property => init DEFAULT value
        statusForm.setSelectedStatus(StatusForm.STATUS_VALUE_INITIAL);
    } else {
        String value = statusProperty.getStringValue();
        statusForm.setSelectedStatus(value);
    }
}
Also used : Identity(org.olat.core.id.Identity) Property(org.olat.properties.Property) CoursePropertyManager(org.olat.course.properties.CoursePropertyManager)

Aggregations

CoursePropertyManager (org.olat.course.properties.CoursePropertyManager)108 Property (org.olat.properties.Property)62 PersistingCoursePropertyManager (org.olat.course.properties.PersistingCoursePropertyManager)44 Identity (org.olat.core.id.Identity)28 File (java.io.File)18 ICourse (org.olat.course.ICourse)18 ProjectBrokerManager (org.olat.course.nodes.projectbroker.service.ProjectBrokerManager)14 CourseNode (org.olat.course.nodes.CourseNode)12 Project (org.olat.course.nodes.projectbroker.datamodel.Project)12 RepositoryEntry (org.olat.repository.RepositoryEntry)12 AssessmentChangedEvent (org.olat.course.assessment.AssessmentChangedEvent)10 UserNodeAuditManager (org.olat.course.auditing.UserNodeAuditManager)10 ProjectGroupManager (org.olat.course.nodes.projectbroker.service.ProjectGroupManager)10 BusinessGroup (org.olat.group.BusinessGroup)10 XStream (com.thoughtworks.xstream.XStream)8 OlatRootFolderImpl (org.olat.core.commons.modules.bc.vfs.OlatRootFolderImpl)8 TaskExecutorManager (org.olat.core.commons.services.taskexecutor.TaskExecutorManager)8 PackageTranslator (org.olat.core.gui.translator.PackageTranslator)8 Translator (org.olat.core.gui.translator.Translator)8 SyncerExecutor (org.olat.core.util.coordinate.SyncerExecutor)8