use of org.incode.module.classification.dom.impl.applicability.Applicability 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;
}
use of org.incode.module.classification.dom.impl.applicability.Applicability in project estatio by estatio.
the class Taxonomy method applicable.
@Action(domainEvent = ApplicableToDomainEvent.class)
@ActionLayout(cssClassFa = "fa-plus")
@MemberOrder(name = "appliesTo", sequence = "1")
public Category applicable(@ParameterLayout(named = "Application tenancy") final String atPath, @ParameterLayout(named = "Domain type") final String domainTypeName) {
Applicability applicability = new Applicability(this, atPath, domainTypeName);
repositoryService.persistAndFlush(applicability);
return this;
}
use of org.incode.module.classification.dom.impl.applicability.Applicability in project estatio by estatio.
the class Taxonomy_applicable_IntegTest method can_add_applicability_for_same_domain_types_with_different_atPath.
@Test
public void can_add_applicability_for_same_domain_types_with_different_atPath() {
// eg given an applicability for "/ITA" and 'DemoObject', can also add an applicability for "/ITA/MIL" and 'DemoObject'
Taxonomy italianColours = (Taxonomy) categoryRepository.findByParentAndName(null, "Italian Colours");
final List<Applicability> byDomainTypeAndUnderAtPath = applicabilityRepository.findByDomainTypeAndUnderAtPath(DemoObjectWithAtPath.class, "/ITA");
assertThat(byDomainTypeAndUnderAtPath).hasSize(2);
assertThat(byDomainTypeAndUnderAtPath).extracting(Applicability::getTaxonomy).extracting(Taxonomy::getFullyQualifiedName).containsOnly("Italian Colours", "Sizes");
// when
wrap(italianColours).applicable("/ITA/MIL", DemoObjectWithAtPath.class.getName());
// then
final List<Applicability> byDomainTypeAndUnderAtPathNew = applicabilityRepository.findByDomainTypeAndUnderAtPath(DemoObjectWithAtPath.class, "/ITA/MIL");
assertThat(byDomainTypeAndUnderAtPathNew).hasSize(3);
assertThat(byDomainTypeAndUnderAtPathNew).extracting(Applicability::getTaxonomy).extracting(Taxonomy::getFullyQualifiedName).containsOnly("Italian Colours", "Sizes");
}
use of org.incode.module.classification.dom.impl.applicability.Applicability in project estatio by estatio.
the class Taxonomy_notApplicable_IntegTest method happy_case.
@Test
public void happy_case() {
// given
Taxonomy italianColours = (Taxonomy) categoryRepository.findByParentAndName(null, "Italian Colours");
List<Applicability> applicabilities = applicabilityRepository.findByDomainTypeAndUnderAtPath(DemoObjectWithAtPath.class, "/ITA");
assertThat(applicabilities).extracting(Applicability::getTaxonomy).extracting(Taxonomy::getName).containsOnly("Italian Colours", "Sizes");
Applicability italianColoursApplicability = applicabilities.stream().filter(applicability -> applicability.getTaxonomy().getName().equals("Italian Colours")).findFirst().get();
// when
wrap(italianColours).notApplicable(italianColoursApplicability);
// then
List<Applicability> newApplicabilities = applicabilityRepository.findByDomainTypeAndUnderAtPath(DemoObjectWithAtPath.class, "/ITA");
assertThat(newApplicabilities).extracting(Applicability::getTaxonomy).extracting(Taxonomy::getName).containsOnly("Sizes");
}
use of org.incode.module.classification.dom.impl.applicability.Applicability in project estatio by estatio.
the class Taxonomy_notApplicable_IntegTest method existing_classifications_are_ignored.
@Test
public void existing_classifications_are_ignored() {
// given
Taxonomy italianColours = (Taxonomy) categoryRepository.findByParentAndName(null, "Italian Colours");
List<Applicability> applicabilities = applicabilityRepository.findByDomainTypeAndUnderAtPath(DemoObjectWithAtPath.class, "/ITA");
assertThat(applicabilities).extracting(Applicability::getTaxonomy).extracting(Taxonomy::getName).contains("Italian Colours");
Applicability italianColoursApplicability = applicabilities.stream().filter(applicability -> applicability.getTaxonomy().getName().equals("Italian Colours")).findFirst().get();
DemoObjectWithAtPath demoFooInItaly = demoObjectMenu.listAllDemoObjectsWithAtPath().stream().filter(d -> d.getName().equals("Demo foo (in Italy)")).findFirst().get();
List<Classification> classifications = classificationRepository.findByClassified(demoFooInItaly);
assertThat(classifications).extracting(Classification::getTaxonomy).contains(italianColours);
// when
wrap(italianColours).notApplicable(italianColoursApplicability);
// then
assertThat(classificationRepository.findByClassified(demoFooInItaly)).extracting(Classification::getTaxonomy).contains(italianColours);
}
Aggregations