use of org.olat.modules.taxonomy.Taxonomy in project openolat by klemens.
the class TaxonomyWebServiceTest method deleteTaxonomyLevel.
@Test
public void deleteTaxonomyLevel() throws IOException, URISyntaxException {
Taxonomy taxonomy = taxonomyService.createTaxonomy("REST-Del-1", "Taxonomy on rest", "Delete is sad!", "DELETE-tax-1");
TaxonomyLevel rootLevel = taxonomyService.createTaxonomyLevel("REST-Del-root", "Root level on rest", "Level", "Ext-55", null, null, taxonomy);
TaxonomyLevel levelToDelete = taxonomyService.createTaxonomyLevel("REST-Del-u-1", "Sub level on rest", "Level", "Ext-56", null, rootLevel, taxonomy);
dbInstance.commitAndCloseSession();
Assert.assertNotNull(taxonomy);
RestConnection conn = new RestConnection();
Assert.assertTrue(conn.login("administrator", "openolat"));
URI request = UriBuilder.fromUri(getContextURI()).path("taxonomy").path(taxonomy.getKey().toString()).path("levels").path(levelToDelete.getKey().toString()).build();
HttpDelete method = conn.createDelete(request, MediaType.APPLICATION_JSON);
HttpResponse response = conn.execute(method);
Assert.assertEquals(200, response.getStatusLine().getStatusCode());
EntityUtils.consume(response.getEntity());
// check the deleted value
TaxonomyLevel deletedLevel = taxonomyService.getTaxonomyLevel(new TaxonomyLevelRefImpl(levelToDelete.getKey()));
Assert.assertNull(deletedLevel);
TaxonomyLevel survivingRootLevel = taxonomyService.getTaxonomyLevel(new TaxonomyLevelRefImpl(rootLevel.getKey()));
Assert.assertNotNull(survivingRootLevel);
}
use of org.olat.modules.taxonomy.Taxonomy in project openolat by klemens.
the class TaxonomyWebServiceTest method disallowTaxonomyLevelTypeAllowedSubType.
@Test
public void disallowTaxonomyLevelTypeAllowedSubType() throws IOException, URISyntaxException {
Taxonomy taxonomy = taxonomyService.createTaxonomy("REST-Tax-6", "Taxonomy on rest", "Rest is cool", "Ext-tax-6");
TaxonomyLevelType type = taxonomyService.createTaxonomyLevelType("REST-Type-6", "Type 6 on rest", "Type", "EXT-Type-6", taxonomy);
TaxonomyLevelType subType1 = taxonomyService.createTaxonomyLevelType("REST-Type-6-1", "Type 6.1 on rest", "Type", "EXT-Type-6-1", taxonomy);
TaxonomyLevelType subType2 = taxonomyService.createTaxonomyLevelType("REST-Type-6-2", "Type 6.2 on rest", "Type", "EXT-Type-6-2", taxonomy);
TaxonomyLevelType subType3 = taxonomyService.createTaxonomyLevelType("REST-Type-6-3", "Type 6.3 on rest", "Type", "EXT-Type-6-3", taxonomy);
dbInstance.commit();
List<TaxonomyLevelType> allowedSubTypes = new ArrayList<>();
allowedSubTypes.add(subType1);
allowedSubTypes.add(subType2);
allowedSubTypes.add(subType3);
type = taxonomyService.updateTaxonomyLevelType(type, allowedSubTypes);
dbInstance.commitAndCloseSession();
RestConnection conn = new RestConnection();
Assert.assertTrue(conn.login("administrator", "openolat"));
URI request = UriBuilder.fromUri(getContextURI()).path("taxonomy").path(taxonomy.getKey().toString()).path("types").path(type.getKey().toString()).path("allowedSubTypes").path(subType2.getKey().toString()).build();
HttpDelete method = conn.createDelete(request, MediaType.APPLICATION_JSON);
HttpResponse response = conn.execute(method);
Assert.assertEquals(200, response.getStatusLine().getStatusCode());
EntityUtils.consume(response.getEntity());
TaxonomyLevelType reloadedType = taxonomyService.getTaxonomyLevelType(type);
Set<TaxonomyLevelTypeToType> typeToTypes = reloadedType.getAllowedTaxonomyLevelSubTypes();
Assert.assertEquals(2, typeToTypes.size());
boolean found1 = false;
boolean found2 = false;
boolean found3 = false;
for (TaxonomyLevelTypeToType typeToType : typeToTypes) {
TaxonomyLevelType subType = typeToType.getAllowedSubTaxonomyLevelType();
if (subType1.getKey().equals(subType.getKey())) {
found1 = true;
} else if (subType2.getKey().equals(subType.getKey())) {
found2 = true;
} else if (subType3.getKey().equals(subType.getKey())) {
found3 = true;
}
}
Assert.assertTrue(found1);
Assert.assertFalse(found2);
Assert.assertTrue(found3);
}
use of org.olat.modules.taxonomy.Taxonomy in project openolat by klemens.
the class TaxonomyWebServiceTest method removeTaxonomyLevelCompetence.
@Test
public void removeTaxonomyLevelCompetence() throws IOException, URISyntaxException {
Identity id = JunitTestHelper.createAndPersistIdentityAsRndUser("competence-4");
Taxonomy taxonomy = taxonomyService.createTaxonomy("REST-Tax-8", "Taxonomy on rest", "PUT is cool, yes!", "PUT-tax-2");
TaxonomyLevel level = taxonomyService.createTaxonomyLevel("REST-Tax-r-8", "Root level on rest", "Level", "Ext-23", null, null, taxonomy);
TaxonomyCompetence competence = taxonomyService.addTaxonomyLevelCompetences(level, id, TaxonomyCompetenceTypes.target, null);
dbInstance.commitAndCloseSession();
Assert.assertNotNull(competence);
// make sure we have something to delete
TaxonomyCompetence reloadedCompetence = taxonomyService.getTaxonomyCompetence(competence);
Assert.assertNotNull(reloadedCompetence);
dbInstance.commitAndCloseSession();
// remove the competence
RestConnection conn = new RestConnection();
Assert.assertTrue(conn.login("administrator", "openolat"));
URI request = UriBuilder.fromUri(getContextURI()).path("taxonomy").path(taxonomy.getKey().toString()).path("levels").path(level.getKey().toString()).path("competences").path(competence.getKey().toString()).build();
HttpDelete method = conn.createDelete(request, MediaType.APPLICATION_JSON);
HttpResponse response = conn.execute(method);
Assert.assertEquals(200, response.getStatusLine().getStatusCode());
EntityUtils.consume(response.getEntity());
// check the database
List<TaxonomyCompetence> competences = taxonomyService.getTaxonomyCompetences(id, TaxonomyCompetenceTypes.target);
Assert.assertNotNull(competences);
Assert.assertEquals(0, competences.size());
}
use of org.olat.modules.taxonomy.Taxonomy in project openolat by klemens.
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);
}
use of org.olat.modules.taxonomy.Taxonomy in project openolat by klemens.
the class IdentityCompetencesController method doRemoveCompetence.
private void doRemoveCompetence(IdentityCompetenceRow row) {
Taxonomy taxonomy = row.getTaxonomy();
TaxonomyCompetence competence = row.getCompetence();
String before = taxonomyService.toAuditXml(competence);
taxonomyService.removeTaxonomyLevelCompetence(competence);
taxonomyService.auditLog(TaxonomyCompetenceAuditLog.Action.removeCompetence, before, null, null, taxonomy, competence, assessedIdentity, getIdentity());
loadModel();
tableEl.reset(true, true, true);
String competenceTypeName = translate(row.getCompetenceType().name());
String levelDisplayName = StringHelper.escapeHtml(row.getTaxonomyLevel().getDisplayName());
showInfo("confirm.removed.competence", new String[] { competenceTypeName, levelDisplayName });
}
Aggregations