use of org.olat.modules.taxonomy.TaxonomyLevel in project OpenOLAT by OpenOLAT.
the class NewItemOptionsController method formOK.
@Override
protected void formOK(UserRequest ureq) {
String typeKey = typeEl.getSelectedKey();
QItemFactory factory = keyToFactoryMap.get(typeKey);
String title = titleEl.getValue();
TaxonomyLevel taxonomyLevel = null;
if (taxonomyLevelEl.isOneSelected()) {
String selectedKey = taxonomyLevelEl.getSelectedKey();
taxonomyLevel = qpoolTaxonomyTreeBuilder.getTaxonomyLevel(selectedKey);
}
fireEvent(ureq, new QItemCreationCmdEvent(title, taxonomyLevel, factory));
}
use of org.olat.modules.taxonomy.TaxonomyLevel in project OpenOLAT by OpenOLAT.
the class GeneralMetadataEditController method buildTaxonomyLevelEl.
private void buildTaxonomyLevelEl() {
qpoolTaxonomyTreeBuilder.loadTaxonomyLevelsSelection(getIdentity(), securityCallback.canRemoveTaxonomy(), ignoreCompetences);
String[] selectableKeys = qpoolTaxonomyTreeBuilder.getSelectableKeys();
String[] selectableValues = qpoolTaxonomyTreeBuilder.getSelectableValues();
taxonomyLevelEl.setKeysAndValues(selectableKeys, selectableValues, null);
if (item instanceof QuestionItemImpl) {
QuestionItemImpl itemImpl = (QuestionItemImpl) item;
TaxonomyLevel selectedTaxonomyLevel = itemImpl.getTaxonomyLevel();
if (selectedTaxonomyLevel != null) {
String selectedTaxonomyLevelKey = String.valueOf(selectedTaxonomyLevel.getKey());
for (String taxonomyKey : qpoolTaxonomyTreeBuilder.getSelectableKeys()) {
if (taxonomyKey.equals(selectedTaxonomyLevelKey)) {
taxonomyLevelEl.select(taxonomyKey, true);
}
}
if (!taxonomyLevelEl.isOneSelected() && itemImpl.getTaxonomyLevel() != null) {
if (selectableKeys.length == 0) {
selectableKeys = new String[] { "dummy" };
selectableValues = new String[1];
}
selectableValues[0] = itemImpl.getTaxonomyLevel().getDisplayName();
taxonomyLevelEl.setEnabled(false);
}
}
}
taxonomyLevelEl.addActionListener(FormEvent.ONCHANGE);
setTaxonomicPath();
}
use of org.olat.modules.taxonomy.TaxonomyLevel in project OpenOLAT by OpenOLAT.
the class MetadataBulkChangeController method formOKGeneral.
private void formOKGeneral(QuestionItemImpl itemImpl) {
if (isEnabled(topicEl))
itemImpl.setTopic(topicEl.getValue());
if (isEnabled(keywordsEl))
itemImpl.setKeywords(keywordsEl.getValue());
if (isEnabled(coverageEl))
itemImpl.setCoverage(coverageEl.getValue());
if (isEnabled(addInfosEl))
itemImpl.setAdditionalInformations(addInfosEl.getValue());
if (isEnabled(languageEl))
itemImpl.setLanguage(languageEl.getValue());
if (isEnabled(taxonomyLevelEl)) {
String selectedKey = taxonomyLevelEl.getSelectedKey();
TaxonomyLevel taxonomyLevel = qpoolTaxonomyTreeBuilder.getTaxonomyLevel(selectedKey);
itemImpl.setTaxonomyLevel(taxonomyLevel);
}
}
use of org.olat.modules.taxonomy.TaxonomyLevel in project OpenOLAT by OpenOLAT.
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.TaxonomyLevel in project OpenOLAT by OpenOLAT.
the class TaxonomyWebServiceTest method updateTaxonomyLevel.
/**
* Update level.
*
* @throws IOException
* @throws URISyntaxException
*/
@Test
public void updateTaxonomyLevel() throws IOException, URISyntaxException {
Taxonomy taxonomy = taxonomyService.createTaxonomy("REST-Tax-4", "Taxonomy on rest", "PUT is cool, yes!", "PUT-tax-2");
TaxonomyLevel rootLevel = taxonomyService.createTaxonomyLevel("REST-Tax-u-1", "Root level on rest", "Level", "Ext-25", null, null, taxonomy);
TaxonomyLevel levelToUpdate = taxonomyService.createTaxonomyLevel("REST-Tax-u-1", "Sub level on rest", "Level", "Ext-26", null, rootLevel, taxonomy);
TaxonomyLevelType type = taxonomyService.createTaxonomyLevelType("Sub-type", "Type for a sub level", "All is in the title", "TYP-27", taxonomy);
dbInstance.commitAndCloseSession();
Assert.assertNotNull(taxonomy);
RestConnection conn = new RestConnection();
Assert.assertTrue(conn.login("administrator", "openolat"));
TaxonomyLevelVO levelVo = new TaxonomyLevelVO();
levelVo.setKey(levelToUpdate.getKey());
levelVo.setIdentifier("Updated id");
levelVo.setDisplayName("Updated name");
levelVo.setDescription("Updated description");
levelVo.setExternalId("Updated ext.");
levelVo.setTypeKey(type.getKey());
levelVo.setParentKey(rootLevel.getKey());
URI request = UriBuilder.fromUri(getContextURI()).path("taxonomy").path(taxonomy.getKey().toString()).path("levels").build();
HttpPut method = conn.createPut(request, MediaType.APPLICATION_JSON, true);
conn.addJsonEntity(method, levelVo);
HttpResponse response = conn.execute(method);
Assert.assertEquals(200, response.getStatusLine().getStatusCode());
// check the updated value
TaxonomyLevelVO updatedTaxonomyLevelVo = conn.parse(response, TaxonomyLevelVO.class);
Assert.assertNotNull(updatedTaxonomyLevelVo);
Assert.assertEquals("Updated id", updatedTaxonomyLevelVo.getIdentifier());
Assert.assertEquals("Updated name", updatedTaxonomyLevelVo.getDisplayName());
Assert.assertEquals("Updated description", updatedTaxonomyLevelVo.getDescription());
Assert.assertEquals("Updated ext.", updatedTaxonomyLevelVo.getExternalId());
Assert.assertEquals(rootLevel.getKey(), updatedTaxonomyLevelVo.getParentKey());
Assert.assertEquals(type.getKey(), updatedTaxonomyLevelVo.getTypeKey());
// check the database
TaxonomyLevel savedLevel = taxonomyService.getTaxonomyLevel(new TaxonomyLevelRefImpl(updatedTaxonomyLevelVo.getKey()));
Assert.assertNotNull(savedLevel);
Assert.assertEquals("Updated id", savedLevel.getIdentifier());
Assert.assertEquals("Updated name", savedLevel.getDisplayName());
Assert.assertEquals("Updated description", savedLevel.getDescription());
Assert.assertEquals("Updated ext.", savedLevel.getExternalId());
Assert.assertEquals(rootLevel.getKey(), savedLevel.getParent().getKey());
Assert.assertEquals(type.getKey(), savedLevel.getType().getKey());
}
Aggregations