use of org.olat.modules.taxonomy.model.TaxonomyLevelTypeImpl in project OpenOLAT by OpenOLAT.
the class TaxonomyLevelTypeDAO method cloneTaxonomyLevelType.
public TaxonomyLevelType cloneTaxonomyLevelType(TaxonomyLevelTypeRef typeRef) {
TaxonomyLevelType reloadedType = loadTaxonomyLevelTypeByKey(typeRef.getKey());
TaxonomyLevelTypeImpl type = new TaxonomyLevelTypeImpl();
type.setCreationDate(new Date());
type.setLastModified(type.getCreationDate());
type.setIdentifier(reloadedType.getIdentifier() + " (Copy)");
type.setDisplayName(reloadedType.getDisplayName());
type.setDescription(reloadedType.getDescription());
type.setExternalId("");
// default settings
type.setDocumentsLibraryManageCompetenceEnabled(reloadedType.isDocumentsLibraryManageCompetenceEnabled());
type.setDocumentsLibraryTeachCompetenceReadEnabled(reloadedType.isDocumentsLibraryTargetCompetenceReadEnabled());
type.setDocumentsLibraryTeachCompetenceReadParentLevels(reloadedType.getDocumentsLibraryTeachCompetenceReadParentLevels());
type.setDocumentsLibraryTeachCompetenceWriteEnabled(reloadedType.isDocumentsLibraryTeachCompetenceWriteEnabled());
type.setDocumentsLibraryHaveCompetenceReadEnabled(reloadedType.isDocumentsLibraryHaveCompetenceReadEnabled());
type.setDocumentsLibraryTargetCompetenceReadEnabled(reloadedType.isDocumentsLibraryTargetCompetenceReadEnabled());
// root
type.setTaxonomy(reloadedType.getTaxonomy());
dbInstance.getCurrentEntityManager().persist(type);
return type;
}
use of org.olat.modules.taxonomy.model.TaxonomyLevelTypeImpl in project OpenOLAT by OpenOLAT.
the class TaxonomyLevelTypeDAO method createTaxonomyLevelType.
public TaxonomyLevelType createTaxonomyLevelType(String identifier, String displayName, String description, String externalId, Taxonomy taxonomy) {
TaxonomyLevelTypeImpl type = new TaxonomyLevelTypeImpl();
type.setCreationDate(new Date());
type.setLastModified(type.getCreationDate());
if (StringHelper.containsNonWhitespace(identifier)) {
type.setIdentifier(identifier);
} else {
type.setIdentifier(UUID.randomUUID().toString());
}
type.setDisplayName(displayName);
type.setDescription(description);
type.setExternalId(externalId);
// default settings
type.setDocumentsLibraryManageCompetenceEnabled(true);
type.setDocumentsLibraryTeachCompetenceReadEnabled(true);
type.setDocumentsLibraryTeachCompetenceReadParentLevels(0);
type.setDocumentsLibraryTeachCompetenceWriteEnabled(false);
type.setDocumentsLibraryHaveCompetenceReadEnabled(true);
type.setDocumentsLibraryTargetCompetenceReadEnabled(true);
// root
type.setTaxonomy(taxonomy);
dbInstance.getCurrentEntityManager().persist(type);
return type;
}
use of org.olat.modules.taxonomy.model.TaxonomyLevelTypeImpl in project OpenOLAT by OpenOLAT.
the class TaxonomyLevelTypeDAOTest method allowSubTypes.
@Test
public void allowSubTypes() {
Taxonomy taxonomy = taxonomyDao.createTaxonomy("Tax-type", "Typed taxonomy", "A typed taxonomy", "");
TaxonomyLevelType type = taxonomyLevelTypeDao.createTaxonomyLevelType("Type-parent", "A type", null, null, taxonomy);
TaxonomyLevelType subType1 = taxonomyLevelTypeDao.createTaxonomyLevelType("Type-sub-1", "A type", null, null, taxonomy);
TaxonomyLevelType subType2 = taxonomyLevelTypeDao.createTaxonomyLevelType("Type-sub-2", "A type", null, null, taxonomy);
dbInstance.commitAndCloseSession();
taxonomyLevelTypeToTypeDao.addAllowedSubType(type, subType1);
taxonomyLevelTypeToTypeDao.addAllowedSubType(type, subType2);
dbInstance.commitAndCloseSession();
TaxonomyLevelTypeImpl reloadedType = (TaxonomyLevelTypeImpl) taxonomyLevelTypeDao.loadTaxonomyLevelTypeByKey(type.getKey());
Assert.assertNotNull(reloadedType.getAllowedTaxonomyLevelSubTypes());
Assert.assertEquals(2, reloadedType.getAllowedTaxonomyLevelSubTypes().size());
Set<TaxonomyLevelTypeToType> allowedTypeSet = reloadedType.getAllowedTaxonomyLevelSubTypes();
List<TaxonomyLevelType> allowedSubTypes = allowedTypeSet.stream().map(t -> t.getAllowedSubTaxonomyLevelType()).collect(Collectors.toList());
Assert.assertTrue(allowedSubTypes.contains(subType1));
Assert.assertTrue(allowedSubTypes.contains(subType2));
}
use of org.olat.modules.taxonomy.model.TaxonomyLevelTypeImpl in project openolat by klemens.
the class TaxonomyLevelTypeDAO method createTaxonomyLevelType.
public TaxonomyLevelType createTaxonomyLevelType(String identifier, String displayName, String description, String externalId, Taxonomy taxonomy) {
TaxonomyLevelTypeImpl type = new TaxonomyLevelTypeImpl();
type.setCreationDate(new Date());
type.setLastModified(type.getCreationDate());
if (StringHelper.containsNonWhitespace(identifier)) {
type.setIdentifier(identifier);
} else {
type.setIdentifier(UUID.randomUUID().toString());
}
type.setDisplayName(displayName);
type.setDescription(description);
type.setExternalId(externalId);
// default settings
type.setDocumentsLibraryManageCompetenceEnabled(true);
type.setDocumentsLibraryTeachCompetenceReadEnabled(true);
type.setDocumentsLibraryTeachCompetenceReadParentLevels(0);
type.setDocumentsLibraryTeachCompetenceWriteEnabled(false);
type.setDocumentsLibraryHaveCompetenceReadEnabled(true);
type.setDocumentsLibraryTargetCompetenceReadEnabled(true);
// root
type.setTaxonomy(taxonomy);
dbInstance.getCurrentEntityManager().persist(type);
return type;
}
use of org.olat.modules.taxonomy.model.TaxonomyLevelTypeImpl in project openolat by klemens.
the class TaxonomyLevelTypeDAO method cloneTaxonomyLevelType.
public TaxonomyLevelType cloneTaxonomyLevelType(TaxonomyLevelTypeRef typeRef) {
TaxonomyLevelType reloadedType = loadTaxonomyLevelTypeByKey(typeRef.getKey());
TaxonomyLevelTypeImpl type = new TaxonomyLevelTypeImpl();
type.setCreationDate(new Date());
type.setLastModified(type.getCreationDate());
type.setIdentifier(reloadedType.getIdentifier() + " (Copy)");
type.setDisplayName(reloadedType.getDisplayName());
type.setDescription(reloadedType.getDescription());
type.setExternalId("");
// default settings
type.setDocumentsLibraryManageCompetenceEnabled(reloadedType.isDocumentsLibraryManageCompetenceEnabled());
type.setDocumentsLibraryTeachCompetenceReadEnabled(reloadedType.isDocumentsLibraryTargetCompetenceReadEnabled());
type.setDocumentsLibraryTeachCompetenceReadParentLevels(reloadedType.getDocumentsLibraryTeachCompetenceReadParentLevels());
type.setDocumentsLibraryTeachCompetenceWriteEnabled(reloadedType.isDocumentsLibraryTeachCompetenceWriteEnabled());
type.setDocumentsLibraryHaveCompetenceReadEnabled(reloadedType.isDocumentsLibraryHaveCompetenceReadEnabled());
type.setDocumentsLibraryTargetCompetenceReadEnabled(reloadedType.isDocumentsLibraryTargetCompetenceReadEnabled());
// root
type.setTaxonomy(reloadedType.getTaxonomy());
dbInstance.getCurrentEntityManager().persist(type);
return type;
}
Aggregations