use of org.incode.module.classification.dom.impl.category.Category in project estatio by estatio.
the class Category_ordinal_IntegTest method happy_case.
@Test
public void happy_case() {
// given
Category medium = categoryRepository.findByReference("M");
assertThat(medium.getFullyQualifiedOrdinal()).isEqualTo("1.2");
// when
medium.modifyOrdinal(99);
// then
assertThat(medium.getFullyQualifiedOrdinal()).isEqualTo("1.99");
}
use of org.incode.module.classification.dom.impl.category.Category 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