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);
}
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();
}
}
}
}
}
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++;
}
}
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));
}
}
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);
}
}
Aggregations