Search in sources :

Example 16 with Taxonomy

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

the class CategoryRepository_createTaxonomy_IntegTest method when_name_already_in_use.

@Test
public void when_name_already_in_use() {
    // given
    Taxonomy italianColours = (Taxonomy) categoryRepository.findByReference("ITACOL");
    assertThat(italianColours.getName()).isEqualTo("Italian Colours");
    sessionManagementService.nextSession();
    // then
    expectedException.expect(JDODataStoreException.class);
    expectedException.expectMessage("Classification_fullyQualifiedName_UNQ");
    // when
    categoryRepository.createTaxonomy("Italian Colours");
}
Also used : Taxonomy(org.incode.module.classification.dom.impl.category.taxonomy.Taxonomy) Test(org.junit.Test)

Example 17 with Taxonomy

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

the class CategoryRepository_findByParentAndName_IntegTest method when_none.

@Test
public void when_none() {
    // given
    Taxonomy parentFrenchColours = (Taxonomy) categoryRepository.findByReference("FRCOL");
    // when
    Category childFrenchColours = categoryRepository.findByParentAndName(parentFrenchColours, "Nonexisting");
    // then
    assertThat(childFrenchColours).isNull();
}
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)

Example 18 with Taxonomy

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

the class ClassificationForOccImport method importData.

@Override
public List<Object> importData(final Object previousRow) {
    final Lease lease = leaseRepository.findLeaseByReference(getLeaseReference());
    if (lease == null) {
        throw new IllegalArgumentException(String.format("No lease found for '%s'", getLeaseReference()));
    }
    final Unit unit = unitRepository.findUnitByReference(getUnitReference());
    if (unit == null) {
        throw new IllegalArgumentException(String.format("No unit found for '%s'", getUnitReference()));
    }
    final Occupancy occupancy = occupancyRepository.findByLease(lease).stream().filter(x -> x.getUnit().equals(unit)).findFirst().get();
    if (occupancy == null) {
        throw new IllegalArgumentException(String.format("No occupancy found for lease '%s' and unit '%s'", getLeaseReference(), getUnitReference()));
    }
    final Taxonomy taxonomy = (Taxonomy) categoryRepository.findByReference(getTaxonomyReference());
    if (taxonomy == null) {
        throw new IllegalArgumentException(String.format("No taxonomy found for '%s'", getTaxonomyReference()));
    }
    final Category category = categoryRepository.findByTaxonomyAndReference(taxonomy, getCategoryReference());
    if (category == null) {
        throw new IllegalArgumentException(String.format("No category found for '%s'", getCategoryReference()));
    }
    final Classification classification = classificationRepository.create(category, occupancy);
    return Lists.newArrayList(classification);
}
Also used : Category(org.incode.module.classification.dom.impl.category.Category) Lease(org.estatio.module.lease.dom.Lease) Taxonomy(org.incode.module.classification.dom.impl.category.taxonomy.Taxonomy) Occupancy(org.estatio.module.lease.dom.occupancy.Occupancy) Classification(org.incode.module.classification.dom.impl.classification.Classification) Unit(org.estatio.module.asset.dom.Unit)

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