Search in sources :

Example 1 with PropertyParserFactory

use of nl.knaw.huygens.timbuctoo.search.description.propertyparser.PropertyParserFactory in project timbuctoo by HuygensING.

the class DcarLegislationSearchDescription method createSortDescription.

private SortDescription createSortDescription() {
    PropertyParserFactory propertyParserFactory = new PropertyParserFactory();
    List<SortFieldDescription> sortFieldDescriptions = Lists.newArrayList(newSortFieldDescription().withName("dynamic_sort_title").withDefaultValue("").withProperty(localProperty().withName("dcarlegislation_titleEng").withParser(propertyParserFactory.getParser(String.class))).build(), newSortFieldDescription().withName("dynamic_k_date").withDefaultValue(0).withProperty(localProperty().withName("dcarlegislation_date1").withParser(propertyParserFactory.getParser(Datable.class))).build());
    return new SortDescription(sortFieldDescriptions);
}
Also used : BuildableSortFieldDescription.newSortFieldDescription(nl.knaw.huygens.timbuctoo.search.description.sort.BuildableSortFieldDescription.newSortFieldDescription) SortFieldDescription(nl.knaw.huygens.timbuctoo.search.description.sort.SortFieldDescription) SortDescription(nl.knaw.huygens.timbuctoo.search.description.sort.SortDescription) PropertyParserFactory(nl.knaw.huygens.timbuctoo.search.description.propertyparser.PropertyParserFactory)

Example 2 with PropertyParserFactory

use of nl.knaw.huygens.timbuctoo.search.description.propertyparser.PropertyParserFactory in project timbuctoo by HuygensING.

the class ListFacetGetterTest method getFacetReturnsParsedValueKeysAndTheirCounts.

@Test
public void getFacetReturnsParsedValueKeysAndTheirCounts() {
    FacetGetter instance = new ListFacetGetter(new PropertyParserFactory().getParser(Gender.class));
    Map<String, Set<Vertex>> values = Maps.newHashMap();
    List<Vertex> vertices1 = newGraph().withVertex(v -> v.withTimId("1")).withVertex(v -> v.withTimId("2")).build().traversal().V().toList();
    List<Vertex> vertices2 = newGraph().withVertex(v -> v.withTimId("3")).build().traversal().V().toList();
    values.put("\"MALE\"", Sets.newHashSet(vertices1));
    values.put("\"FEMALE\"", Sets.newHashSet(vertices2));
    Facet facet = instance.getFacet(FACET_NAME, values);
    assertThat(facet.getName(), equalTo(FACET_NAME));
    assertThat(facet.getOptions(), containsInAnyOrder(new Facet.DefaultOption("MALE", 2), new Facet.DefaultOption("FEMALE", 1)));
}
Also used : FacetGetter(nl.knaw.huygens.timbuctoo.search.description.facet.FacetGetter) Set(java.util.Set) Test(org.junit.Test) Vertex(org.apache.tinkerpop.gremlin.structure.Vertex) PropertyParserFactory(nl.knaw.huygens.timbuctoo.search.description.propertyparser.PropertyParserFactory) Maps(com.google.common.collect.Maps) Sets(com.google.common.collect.Sets) List(java.util.List) Matchers.containsInAnyOrder(org.hamcrest.Matchers.containsInAnyOrder) Map(java.util.Map) Matchers.equalTo(org.hamcrest.Matchers.equalTo) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) Gender(nl.knaw.huygens.timbuctoo.model.Gender) TestGraphBuilder.newGraph(nl.knaw.huygens.timbuctoo.util.TestGraphBuilder.newGraph) Facet(nl.knaw.huygens.timbuctoo.search.description.facet.Facet) Vertex(org.apache.tinkerpop.gremlin.structure.Vertex) Set(java.util.Set) FacetGetter(nl.knaw.huygens.timbuctoo.search.description.facet.FacetGetter) Gender(nl.knaw.huygens.timbuctoo.model.Gender) PropertyParserFactory(nl.knaw.huygens.timbuctoo.search.description.propertyparser.PropertyParserFactory) Facet(nl.knaw.huygens.timbuctoo.search.description.facet.Facet) Test(org.junit.Test)

Aggregations

PropertyParserFactory (nl.knaw.huygens.timbuctoo.search.description.propertyparser.PropertyParserFactory)2 Maps (com.google.common.collect.Maps)1 Sets (com.google.common.collect.Sets)1 List (java.util.List)1 Map (java.util.Map)1 Set (java.util.Set)1 Gender (nl.knaw.huygens.timbuctoo.model.Gender)1 Facet (nl.knaw.huygens.timbuctoo.search.description.facet.Facet)1 FacetGetter (nl.knaw.huygens.timbuctoo.search.description.facet.FacetGetter)1 BuildableSortFieldDescription.newSortFieldDescription (nl.knaw.huygens.timbuctoo.search.description.sort.BuildableSortFieldDescription.newSortFieldDescription)1 SortDescription (nl.knaw.huygens.timbuctoo.search.description.sort.SortDescription)1 SortFieldDescription (nl.knaw.huygens.timbuctoo.search.description.sort.SortFieldDescription)1 TestGraphBuilder.newGraph (nl.knaw.huygens.timbuctoo.util.TestGraphBuilder.newGraph)1 Vertex (org.apache.tinkerpop.gremlin.structure.Vertex)1 MatcherAssert.assertThat (org.hamcrest.MatcherAssert.assertThat)1 Matchers.containsInAnyOrder (org.hamcrest.Matchers.containsInAnyOrder)1 Matchers.equalTo (org.hamcrest.Matchers.equalTo)1 Test (org.junit.Test)1