use of org.olat.modules.taxonomy.Taxonomy in project OpenOLAT by OpenOLAT.
the class TaxonomyModuleWebService method getTaxonomyWebService.
@Path("{taxonomyKey}")
public TaxonomyWebService getTaxonomyWebService(@PathParam("taxonomyKey") Long taxonomyKey, @Context HttpServletRequest httpRequest) {
Roles roles = getRoles(httpRequest);
if (!roles.isOLATAdmin()) {
throw new WebApplicationException(Response.serverError().status(Status.UNAUTHORIZED).build());
}
if (taxonomyKey == null || taxonomyKey.longValue() <= 0) {
throw new WebApplicationException(Response.serverError().status(Status.BAD_REQUEST).build());
}
TaxonomyService taxonomyService = CoreSpringFactory.getImpl(TaxonomyService.class);
Taxonomy taxonomy = taxonomyService.getTaxonomy(new TaxonomyRefImpl(taxonomyKey));
if (taxonomy == null) {
throw new WebApplicationException(Response.serverError().status(Status.NOT_FOUND).build());
}
return new TaxonomyWebService(taxonomy);
}
use of org.olat.modules.taxonomy.Taxonomy in project OpenOLAT by OpenOLAT.
the class QItemQueriesDAOTest method shouldGetItemsIsTeacher.
@Test
public void shouldGetItemsIsTeacher() {
Taxonomy taxonomy = taxonomyDao.createTaxonomy("QPool", "QPool", "", null);
TaxonomyLevel taxonomyLevel = taxonomyLevelDao.createTaxonomyLevel("QPool", "QPool", "QPool", null, null, null, null, taxonomy);
TaxonomyLevel taxonomySubLevel = taxonomyLevelDao.createTaxonomyLevel("QPool", "QPool", "QPool", null, null, taxonomyLevel, null, taxonomy);
Identity ownerAndTeacher = createRandomIdentity();
taxonomyCompetenceDao.createTaxonomyCompetence(TaxonomyCompetenceTypes.teach, taxonomyLevel, ownerAndTeacher, null);
Identity teacher = createRandomIdentity();
taxonomyCompetenceDao.createTaxonomyCompetence(TaxonomyCompetenceTypes.teach, taxonomyLevel, teacher, null);
Identity noTeacher = createRandomIdentity();
QuestionItemImpl item11 = createRandomItem(ownerAndTeacher);
item11.setTaxonomyLevel(taxonomyLevel);
QuestionItemImpl item12 = createRandomItem(ownerAndTeacher);
item12.setTaxonomyLevel(taxonomySubLevel);
dbInstance.commitAndCloseSession();
SearchQuestionItemParams params = new SearchQuestionItemParams(ownerAndTeacher, null);
List<QuestionItemView> loadedItems = qItemQueriesDao.getItems(params, null, 0, -1);
assertThat(filterByKey(loadedItems, item11).isTeacher()).isTrue();
assertThat(filterByKey(loadedItems, item12).isTeacher()).isTrue();
params = new SearchQuestionItemParams(ownerAndTeacher, null);
loadedItems = qItemQueriesDao.getItems(params, null, 0, -1);
assertThat(filterByKey(loadedItems, item11).isTeacher()).isTrue();
assertThat(filterByKey(loadedItems, item12).isTeacher()).isTrue();
params = new SearchQuestionItemParams(noTeacher, null);
loadedItems = qItemQueriesDao.getItems(params, null, 0, -1);
assertThat(filterByKey(loadedItems, item11).isTeacher()).isFalse();
assertThat(filterByKey(loadedItems, item12).isTeacher()).isFalse();
}
use of org.olat.modules.taxonomy.Taxonomy in project OpenOLAT by OpenOLAT.
the class DocumentPoolAdminConfigurationController method initForm.
@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
setFormDescription("admin.description");
String[] onValues = new String[] { translate("on") };
enableEl = uifactory.addCheckboxesHorizontal("document.pool.admin.enabled", formLayout, onKeys, onValues);
enableEl.addActionListener(FormEvent.ONCHANGE);
if (docPoolModule.isEnabled()) {
enableEl.select(onKeys[0], true);
}
String mountPoint = docPoolModule.getWebDAVMountPoint();
webDAVMountPointEl = uifactory.addTextElement("mount.point", "document.pool.webdav.mount.point", 32, mountPoint, formLayout);
webDAVMountPointEl.setMandatory(true);
String selectedTaxonomyTreeKey = docPoolModule.getTaxonomyTreeKey();
List<Taxonomy> taxonomyList = taxonomyService.getTaxonomyList();
String[] taxonomyKeys = new String[taxonomyList.size() + 1];
String[] taxonomyValues = new String[taxonomyList.size() + 1];
taxonomyKeys[0] = "";
taxonomyValues[0] = "-";
for (int i = taxonomyList.size(); i-- > 0; ) {
Taxonomy taxonomy = taxonomyList.get(i);
taxonomyKeys[i + 1] = taxonomy.getKey().toString();
taxonomyValues[i + 1] = taxonomy.getDisplayName();
}
taxonomyTreeEl = uifactory.addDropdownSingleselect("selected.taxonomy.tree", formLayout, taxonomyKeys, taxonomyValues, null);
taxonomyTreeEl.setMandatory(true);
boolean found = false;
if (StringHelper.containsNonWhitespace(selectedTaxonomyTreeKey)) {
for (String taxonomyKey : taxonomyKeys) {
if (taxonomyKey.equals(selectedTaxonomyTreeKey)) {
taxonomyTreeEl.select(taxonomyKey, true);
found = true;
}
}
}
if (!found && taxonomyKeys.length > 0) {
taxonomyTreeEl.select(taxonomyKeys[0], true);
}
templatesDirectoryEl = uifactory.addCheckboxesHorizontal("document.pool.templates.directory", formLayout, onKeys, onValues);
if (docPoolModule.isTemplatesDirectoryEnabled()) {
templatesDirectoryEl.select(onKeys[0], true);
}
FormLayoutContainer buttonsCont = FormLayoutContainer.createButtonLayout("buttons", getTranslator());
formLayout.add(buttonsCont);
uifactory.addFormSubmitButton("save", buttonsCont);
}
use of org.olat.modules.taxonomy.Taxonomy in project OpenOLAT by OpenOLAT.
the class DocumentPoolAdminController method doOpenPermissions.
private void doOpenPermissions(UserRequest ureq) {
removeAsListenerAndDispose(permissionsCtrl);
if (StringHelper.containsNonWhitespace(docPoolModule.getTaxonomyTreeKey())) {
WindowControl bwControl = addToHistory(ureq, OresHelper.createOLATResourceableType("Types"), null);
Taxonomy taxonomy = taxonomyService.getTaxonomy(new TaxonomyRefImpl(new Long(docPoolModule.getTaxonomyTreeKey())));
permissionsCtrl = new DocumentPoolAdminPermissionsController(ureq, bwControl, taxonomy);
listenTo(permissionsCtrl);
mainVC.put("segmentCmp", permissionsCtrl.getInitialComponent());
}
}
use of org.olat.modules.taxonomy.Taxonomy in project OpenOLAT by OpenOLAT.
the class QuestionPoolAdminConfigurationController method initForm.
@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
FormLayoutContainer moduleCont = FormLayoutContainer.createDefaultFormLayout("module", getTranslator());
moduleCont.setFormTitle(translate("admin.configuration.title"));
moduleCont.setRootForm(mainForm);
formLayout.add("module", moduleCont);
String[] onValues = new String[] { translate("on") };
reviewProcessEnabledEl = uifactory.addCheckboxesHorizontal("review.process.enabled", moduleCont, onKeys, onValues);
reviewProcessEnabledEl.addActionListener(FormEvent.ONCHANGE);
if (qpoolModule.isReviewProcessEnabled()) {
reviewProcessEnabledEl.select(onKeys[0], true);
}
collectionsEnabledEl = uifactory.addCheckboxesHorizontal("collections.enabled", moduleCont, onKeys, onValues);
if (qpoolModule.isCollectionsEnabled()) {
collectionsEnabledEl.select(onKeys[0], true);
}
poolsEnabledEl = uifactory.addCheckboxesHorizontal("pools.enabled", moduleCont, onKeys, onValues);
if (qpoolModule.isPoolsEnabled()) {
poolsEnabledEl.select(onKeys[0], true);
}
sharesEnabledEl = uifactory.addCheckboxesHorizontal("shares.enabled", moduleCont, onKeys, onValues);
if (qpoolModule.isSharesEnabled()) {
sharesEnabledEl.select(onKeys[0], true);
}
taxonomyEnabledEl = uifactory.addCheckboxesHorizontal("taxonomy.enabled", moduleCont, onKeys, onValues);
if (qpoolModule.isTaxonomyEnabled()) {
taxonomyEnabledEl.select(onKeys[0], true);
}
taxonomyEnabledEl.addActionListener(FormEvent.ONCHANGE);
List<Taxonomy> taxonomyList = taxonomyService.getTaxonomyList();
String[] taxonomyKeys = new String[taxonomyList.size() + 1];
String[] taxonomyValues = new String[taxonomyList.size() + 1];
taxonomyKeys[0] = "";
taxonomyValues[0] = "-";
for (int i = taxonomyList.size(); i-- > 0; ) {
Taxonomy taxonomy = taxonomyList.get(i);
taxonomyKeys[i + 1] = taxonomy.getKey().toString();
taxonomyValues[i + 1] = taxonomy.getDisplayName();
}
String selectedTaxonomyQPoolKey = qpoolModule.getTaxonomyQPoolKey();
taxonomyTreeEl = uifactory.addDropdownSingleselect("selected.taxonomy.tree", moduleCont, taxonomyKeys, taxonomyValues, null);
taxonomyTreeEl.setEnabled(false);
if (StringHelper.containsNonWhitespace(selectedTaxonomyQPoolKey)) {
for (String taxonomyKey : taxonomyKeys) {
if (taxonomyKey.equals(selectedTaxonomyQPoolKey)) {
taxonomyTreeEl.select(taxonomyKey, true);
}
}
}
String[] ignoreCompetencesKeys = new String[] { TAXONOMY_COMPETENCES, TAXONOMY_ALL };
ignoreCompetencesEl = uifactory.addDropdownSingleselect("taxonomy.selectable", moduleCont, ignoreCompetencesKeys, translateKeys(ignoreCompetencesKeys));
String selectedKey = qpoolModule.isIgnoreCompetences() ? TAXONOMY_ALL : TAXONOMY_COMPETENCES;
ignoreCompetencesEl.select(selectedKey, true);
importCreateTaxonomyLevelEl = uifactory.addCheckboxesHorizontal("import.create.subject", moduleCont, onKeys, onValues);
if (qpoolModule.isImportCreateTaxonomyLevel()) {
importCreateTaxonomyLevelEl.select(onKeys[0], true);
}
educationalContextEnabledEl = uifactory.addCheckboxesHorizontal("educational.context.enabled", moduleCont, onKeys, onValues);
if (qpoolModule.isEducationalContextEnabled()) {
educationalContextEnabledEl.select(onKeys[0], true);
}
educationalContextEnabledEl.addActionListener(FormEvent.ONCHANGE);
deleteQuestionsWithoutAuthorEl = uifactory.addCheckboxesHorizontal("delete.qustions.without.author", moduleCont, onKeys, onValues);
deleteQuestionsWithoutAuthorEl.setHelpTextKey("delete.qustions.without.author.info", null);
if (qpoolModule.isDeleteQuestionsWithoutAuthor()) {
deleteQuestionsWithoutAuthorEl.select(onKeys[0], true);
}
FormLayoutContainer poolManagerRightsCont = FormLayoutContainer.createDefaultFormLayout("poolManagerRights", getTranslator());
poolManagerRightsCont.setFormTitle(translate("admin.pool.manager.title"));
poolManagerRightsCont.setRootForm(mainForm);
formLayout.add("poolManagerRights", poolManagerRightsCont);
poolManagerRightsEl = uifactory.addCheckboxesVertical("pool.manager.allowed", poolManagerRightsCont, POOL_MANAGER_RIGHTS_KEYS, translateKeys(POOL_MANAGER_RIGHTS_KEYS), 1);
poolManagerRightsEl.select(POOL_MANAGER_EDIT_METADATA, qpoolModule.isPoolAdminAllowedToEditMetadata());
poolManagerRightsEl.select(POOL_MANAGER_EDIT_STATUS, qpoolModule.isPoolAdminAllowedToEditStatus());
poolManagerRightsEl.select(POOL_MANAGER_REVIEW_PROCESS, qpoolModule.isPoolAdminAllowedToConfigReviewProcess());
poolManagerRightsEl.select(POOL_MANAGER_TAXONOMY, qpoolModule.isPoolAdminAllowedToConfigTaxonomy());
poolManagerRightsEl.select(POOL_MANAGER_POOLS, qpoolModule.isPoolAdminAllowedToConfigPools());
poolManagerRightsEl.select(POOL_MANAGER_ITEM_TYPES, qpoolModule.isPoolAdminAllowedToConfigItemTypes());
poolManagerRightsEl.select(POOL_MANAGER_EDUCATIONAL_CONTEXT, qpoolModule.isPoolAdminAllowedToConfigEducationalContext());
FormLayoutContainer buttonsWrapperCont = FormLayoutContainer.createDefaultFormLayout("global", getTranslator());
buttonsWrapperCont.setRootForm(mainForm);
formLayout.add("buttonsWrapper", buttonsWrapperCont);
FormLayoutContainer buttonsCont = FormLayoutContainer.createButtonLayout("buttons", getTranslator());
buttonsWrapperCont.add(buttonsCont);
uifactory.addFormSubmitButton("save", buttonsCont);
}
Aggregations