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");
}
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();
}
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);
}
Aggregations