Search in sources :

Example 1 with TaxonomyLevelTypeImpl

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;
}
Also used : TaxonomyLevelType(org.olat.modules.taxonomy.TaxonomyLevelType) TaxonomyLevelTypeImpl(org.olat.modules.taxonomy.model.TaxonomyLevelTypeImpl) Date(java.util.Date)

Example 2 with TaxonomyLevelTypeImpl

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;
}
Also used : TaxonomyLevelTypeImpl(org.olat.modules.taxonomy.model.TaxonomyLevelTypeImpl) Date(java.util.Date)

Example 3 with TaxonomyLevelTypeImpl

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));
}
Also used : TaxonomyLevelTypeToType(org.olat.modules.taxonomy.TaxonomyLevelTypeToType) List(java.util.List) DB(org.olat.core.commons.persistence.DB) TaxonomyLevelTypeImpl(org.olat.modules.taxonomy.model.TaxonomyLevelTypeImpl) Set(java.util.Set) OlatTestCase(org.olat.test.OlatTestCase) Autowired(org.springframework.beans.factory.annotation.Autowired) Test(org.junit.Test) Assert(org.junit.Assert) TaxonomyLevelType(org.olat.modules.taxonomy.TaxonomyLevelType) Collectors(java.util.stream.Collectors) Taxonomy(org.olat.modules.taxonomy.Taxonomy) Taxonomy(org.olat.modules.taxonomy.Taxonomy) TaxonomyLevelType(org.olat.modules.taxonomy.TaxonomyLevelType) TaxonomyLevelTypeToType(org.olat.modules.taxonomy.TaxonomyLevelTypeToType) TaxonomyLevelTypeImpl(org.olat.modules.taxonomy.model.TaxonomyLevelTypeImpl) Test(org.junit.Test)

Example 4 with TaxonomyLevelTypeImpl

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;
}
Also used : TaxonomyLevelTypeImpl(org.olat.modules.taxonomy.model.TaxonomyLevelTypeImpl) Date(java.util.Date)

Example 5 with TaxonomyLevelTypeImpl

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;
}
Also used : TaxonomyLevelType(org.olat.modules.taxonomy.TaxonomyLevelType) TaxonomyLevelTypeImpl(org.olat.modules.taxonomy.model.TaxonomyLevelTypeImpl) Date(java.util.Date)

Aggregations

TaxonomyLevelTypeImpl (org.olat.modules.taxonomy.model.TaxonomyLevelTypeImpl)6 Date (java.util.Date)4 TaxonomyLevelType (org.olat.modules.taxonomy.TaxonomyLevelType)4 List (java.util.List)2 Set (java.util.Set)2 Collectors (java.util.stream.Collectors)2 Assert (org.junit.Assert)2 Test (org.junit.Test)2 DB (org.olat.core.commons.persistence.DB)2 Taxonomy (org.olat.modules.taxonomy.Taxonomy)2 TaxonomyLevelTypeToType (org.olat.modules.taxonomy.TaxonomyLevelTypeToType)2 OlatTestCase (org.olat.test.OlatTestCase)2 Autowired (org.springframework.beans.factory.annotation.Autowired)2