Search in sources :

Example 1 with Taxonomy

use of org.incode.module.classification.dom.impl.category.taxonomy.Taxonomy in project estatio by estatio.

the class T_classify method choices0Classify.

public Collection<Taxonomy> choices0Classify() {
    SortedSet<Applicability> applicableToClassHierarchy = Sets.newTreeSet();
    // pull together all the 'Applicability's for this domain type and all its supertypes.
    String atPath = getAtPath();
    if (atPath == null) {
        return Collections.emptyList();
    }
    appendDirectApplicabilities(atPath, classified.getClass(), applicableToClassHierarchy);
    // the obtain the corresponding 'Taxonomy's of each of these
    Set<Taxonomy> taxonomies = Sets.newTreeSet();
    taxonomies.addAll(applicableToClassHierarchy.stream().map(Applicability::getTaxonomy).distinct().collect(Collectors.toSet()));
    // remove any taxonomies already selected
    T_classifications t_classifications = new T_classifications(classified) {
    };
    serviceRegistry.injectServicesInto(t_classifications);
    final List<Classification> classifications = t_classifications.$$();
    final Set<Taxonomy> existing = classifications.stream().map(Classification::getTaxonomy).collect(Collectors.toSet());
    taxonomies.removeAll(existing);
    return taxonomies;
}
Also used : Taxonomy(org.incode.module.classification.dom.impl.category.taxonomy.Taxonomy) Applicability(org.incode.module.classification.dom.impl.applicability.Applicability) TranslatableString(org.apache.isis.applib.services.i18n.TranslatableString)

Example 2 with Taxonomy

use of org.incode.module.classification.dom.impl.category.taxonomy.Taxonomy in project estatio by estatio.

the class CategoryRepository method createTaxonomy.

// endregion
// region > createTaxonomy (programmatic)
@Programmatic
public Taxonomy createTaxonomy(final String name) {
    final Taxonomy taxonomy = new Taxonomy(name);
    repositoryService.persistAndFlush(taxonomy);
    taxonomy.setTaxonomy(taxonomy);
    return taxonomy;
}
Also used : Taxonomy(org.incode.module.classification.dom.impl.category.taxonomy.Taxonomy) Programmatic(org.apache.isis.applib.annotation.Programmatic)

Example 3 with Taxonomy

use of org.incode.module.classification.dom.impl.category.taxonomy.Taxonomy in project estatio by estatio.

the class ClassificationRepository method create.

// endregion
// region > create (programmatic)
@Programmatic
public Classification create(final Category category, final Object classified) {
    final Taxonomy taxonomy = category.getTaxonomy();
    final Class<? extends Classification> subtype = subtypeClassFor(classified, taxonomy);
    final Classification classification = repositoryService.instantiate(subtype);
    classification.setCategory(category);
    classification.setTaxonomy(taxonomy);
    final Bookmark bookmark = bookmarkService.bookmarkFor(classified);
    classification.setClassified(classified);
    classification.setClassifiedStr(bookmark.toString());
    repositoryService.persist(classification);
    return classification;
}
Also used : Bookmark(org.apache.isis.applib.services.bookmark.Bookmark) Taxonomy(org.incode.module.classification.dom.impl.category.taxonomy.Taxonomy) Programmatic(org.apache.isis.applib.annotation.Programmatic)

Example 4 with Taxonomy

use of org.incode.module.classification.dom.impl.category.taxonomy.Taxonomy in project estatio by estatio.

the class CategoryRepository_createTaxonomy_IntegTest method happy_case.

@Test
public void happy_case() {
    // when
    Taxonomy newTaxonomy = categoryRepository.createTaxonomy("New Taxonomy");
    // then
    assertThat(newTaxonomy.getName()).isEqualTo("New Taxonomy");
    assertThat(newTaxonomy.getParent()).isNull();
    assertThat(newTaxonomy.getReference()).isNull();
    assertThat(newTaxonomy.getOrdinal()).isEqualTo(1);
}
Also used : Taxonomy(org.incode.module.classification.dom.impl.category.taxonomy.Taxonomy) Test(org.junit.Test)

Example 5 with Taxonomy

use of org.incode.module.classification.dom.impl.category.taxonomy.Taxonomy in project estatio by estatio.

the class CategoryRepository_findByParentCascade_IntegTest method when_grandchildren.

@Test
public void when_grandchildren() {
    // given
    Taxonomy parentSizes = (Taxonomy) categoryRepository.findByReference("SIZES");
    // when
    List<Category> childrenSizes = categoryRepository.findByParentCascade(parentSizes);
    // then
    assertThat(childrenSizes).hasSize(9);
    assertThat(childrenSizes).extracting(Category::getFullyQualifiedName).containsOnly("Sizes/Large", "Sizes/Medium", "Sizes/Small", "Sizes/Large/Largest", "Sizes/Large/Larger", "Sizes/Large/Large", "Sizes/Small/Small", "Sizes/Small/Smaller", "Sizes/Small/Smallest");
}
Also used : Category(org.incode.module.classification.dom.impl.category.Category) Taxonomy(org.incode.module.classification.dom.impl.category.taxonomy.Taxonomy) Test(org.junit.Test)

Aggregations

Taxonomy (org.incode.module.classification.dom.impl.category.taxonomy.Taxonomy)18 Test (org.junit.Test)11 Category (org.incode.module.classification.dom.impl.category.Category)7 DemoObjectWithAtPath (org.incode.platform.dom.classification.integtests.demo.dom.demowithatpath.DemoObjectWithAtPath)5 Applicability (org.incode.module.classification.dom.impl.applicability.Applicability)4 Classification (org.incode.module.classification.dom.impl.classification.Classification)4 Programmatic (org.apache.isis.applib.annotation.Programmatic)2 TranslatableString (org.apache.isis.applib.services.i18n.TranslatableString)2 OtherObjectWithAtPath (org.incode.platform.dom.classification.integtests.demo.dom.otherwithatpath.OtherObjectWithAtPath)2 ClassificationForDemoObjectWithAtPath (org.incode.platform.dom.classification.integtests.dom.classification.dom.classification.demowithatpath.ClassificationForDemoObjectWithAtPath)2 ArrayList (java.util.ArrayList)1 DomainObject (org.apache.isis.applib.annotation.DomainObject)1 Bookmark (org.apache.isis.applib.services.bookmark.Bookmark)1 Property (org.estatio.module.asset.dom.Property)1 Unit (org.estatio.module.asset.dom.Unit)1 Lease (org.estatio.module.lease.dom.Lease)1 Occupancy (org.estatio.module.lease.dom.occupancy.Occupancy)1 ApplicationTenancy (org.isisaddons.module.security.dom.tenancy.ApplicationTenancy)1