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