Search in sources :

Example 1 with Fields

use of org.nextprot.api.solr.index.EntryIndex.Fields in project nextprot-api by calipho-sib.

the class ChromosomeFieldBuilderDiffTest method testGeneBand.

@SuppressWarnings("unchecked")
private void testGeneBand(Entry entry) {
    Fields field = Fields.GENE_BAND;
    ChromosomeFieldBuilder cfb = new ChromosomeFieldBuilder();
    cfb.initializeBuilder(entry);
    Set<String> actualSet = new TreeSet<String>();
    List<String> geneBandValues = cfb.getFieldValue(field, List.class);
    for (String s : geneBandValues) actualSet.addAll(Arrays.asList(s.split(" ")));
    // in the current pam implementation the data is the same
    // but can contains several times the same values and have a different order
    // nevertheless the set of unique values should be the same
    Set<String> expectedSet = new TreeSet<String>();
    List<String> expectedValues = (List<String>) getValueForFieldInCurrentSolrImplementation(entry.getUniqueName(), field);
    for (String s : expectedValues) expectedSet.addAll(Arrays.asList(s.split(" ")));
    // showActualAndExpectedValues(expectedSet,actualSet, "gene_band");
    assertEquals(expectedSet, actualSet);
}
Also used : Fields(org.nextprot.api.solr.index.EntryIndex.Fields) ChromosomeFieldBuilder(org.nextprot.api.tasks.solr.indexer.entry.impl.ChromosomeFieldBuilder) TreeSet(java.util.TreeSet) List(java.util.List)

Example 2 with Fields

use of org.nextprot.api.solr.index.EntryIndex.Fields in project nextprot-api by calipho-sib.

the class EntryBaseSolrIndexer method convertToSolrDocument.

@Override
public SolrInputDocument convertToSolrDocument(Entry entry) {
    fieldsBuilderMap = new HashMap<>();
    initializeFieldBuilders(fieldsBuilderMap);
    SolrInputDocument doc = new SolrInputDocument();
    for (Fields f : Fields.values()) {
        // Directly computed by SOLR
        if (f == Fields.TEXT || f == Fields.SCORE)
            continue;
        FieldBuilder fb = fieldsBuilderMap.get(f);
        fb.setGold(isGold);
        fb.setTerminologyService(terminologyservice);
        fb.setEntryBuilderService(entryBuilderService);
        fb.setPublicationService(publicationService);
        fb.setEntryReportStatsService(entryReportStatsService);
        fb.initializeBuilder(entry);
        Object o = fb.getFieldValue(f, f.getClazz());
        doc.addField(f.getName(), o);
    }
    // Reset all fields builders
    for (Fields f : Fields.values()) {
        // Directly computed by SOLR
        if (f == Fields.TEXT || f == Fields.SCORE)
            continue;
        fieldsBuilderMap.get(f).reset();
    }
    return doc;
}
Also used : SolrInputDocument(org.apache.solr.common.SolrInputDocument) Fields(org.nextprot.api.solr.index.EntryIndex.Fields) FieldBuilder(org.nextprot.api.tasks.solr.indexer.entry.FieldBuilder) EntryFieldBuilder(org.nextprot.api.tasks.solr.indexer.entry.EntryFieldBuilder)

Example 3 with Fields

use of org.nextprot.api.solr.index.EntryIndex.Fields in project nextprot-api by calipho-sib.

the class BuildersTest method shouldCoverAllSolrFields.

@Test
public void shouldCoverAllSolrFields() {
    Map<Fields, FieldBuilder> map = new HashMap<>();
    EntrySolrIndexer.initializeFieldBuilders(map);
    StringBuilder sb = new StringBuilder();
    for (Fields f : Fields.values()) {
        if (!f.equals(Fields.SCORE) && !f.equals(Fields.TEXT) && !map.containsKey(f)) {
            sb.append(f + ",");
        }
    }
    if (!sb.toString().isEmpty()) {
        fail("Missing " + sb.toString().split(",").length + " fields " + " :" + sb.toString());
    }
}
Also used : Fields(org.nextprot.api.solr.index.EntryIndex.Fields) HashMap(java.util.HashMap) FieldBuilder(org.nextprot.api.tasks.solr.indexer.entry.FieldBuilder) AbstractUnitBaseTest(org.nextprot.api.commons.dbunit.AbstractUnitBaseTest) Test(org.junit.Test)

Example 4 with Fields

use of org.nextprot.api.solr.index.EntryIndex.Fields in project nextprot-api by calipho-sib.

the class ChromosomeFieldBuilderDiffTest method testChrLoc.

private void testChrLoc(Entry entry) {
    Fields field = Fields.CHR_LOC;
    ChromosomeFieldBuilder cfb = new ChromosomeFieldBuilder();
    cfb.initializeBuilder(entry);
    // build a set with the list of actual values in field (which are separated by spaces)
    Set<String> actualSet = new TreeSet<String>();
    String actualValue = cfb.getFieldValue(field, String.class);
    actualSet.addAll(Arrays.asList(actualValue.split(" ")));
    // in the current pam implementation the data is the same
    // but can contain several times the same values (and may have a different order)
    // nevertheless the set of unique values should be the same
    Set<String> expectedSet = new TreeSet<String>();
    String expectedValue = (String) getValueForFieldInCurrentSolrImplementation(entry.getUniqueName(), field);
    expectedSet.addAll(Arrays.asList(expectedValue.replace(",", "").split(" ")));
    // showActualAndExpectedValues(expectedSet,actualSet, "chr_loc");
    assertEquals(expectedSet, actualSet);
}
Also used : Fields(org.nextprot.api.solr.index.EntryIndex.Fields) ChromosomeFieldBuilder(org.nextprot.api.tasks.solr.indexer.entry.impl.ChromosomeFieldBuilder) TreeSet(java.util.TreeSet)

Example 5 with Fields

use of org.nextprot.api.solr.index.EntryIndex.Fields in project nextprot-api by calipho-sib.

the class ChromosomeFieldBuilderIntegrationTest method testChrLoc.

@Test
public void testChrLoc() {
    Fields field = Fields.CHR_LOC;
    String entryName = "NX_Q06124";
    Entry entry = entryBuilderService.build(EntryConfig.newConfig(entryName).withChromosomalLocations());
    ChromosomeFieldBuilder cfb = new ChromosomeFieldBuilder();
    cfb.initializeBuilder(entry);
    String chrLocValue = cfb.getFieldValue(field, String.class);
    assertTrue(chrLocValue.contains("12q24.13"));
}
Also used : Entry(org.nextprot.api.core.domain.Entry) Fields(org.nextprot.api.solr.index.EntryIndex.Fields) ChromosomeFieldBuilder(org.nextprot.api.tasks.solr.indexer.entry.impl.ChromosomeFieldBuilder) SolrBuildIntegrationTest(org.nextprot.api.tasks.solr.indexer.entry.SolrBuildIntegrationTest) Test(org.junit.Test)

Aggregations

Fields (org.nextprot.api.solr.index.EntryIndex.Fields)6 FieldBuilder (org.nextprot.api.tasks.solr.indexer.entry.FieldBuilder)3 ChromosomeFieldBuilder (org.nextprot.api.tasks.solr.indexer.entry.impl.ChromosomeFieldBuilder)3 TreeSet (java.util.TreeSet)2 Test (org.junit.Test)2 EntryFieldBuilder (org.nextprot.api.tasks.solr.indexer.entry.EntryFieldBuilder)2 HashMap (java.util.HashMap)1 List (java.util.List)1 SolrInputDocument (org.apache.solr.common.SolrInputDocument)1 AbstractUnitBaseTest (org.nextprot.api.commons.dbunit.AbstractUnitBaseTest)1 Entry (org.nextprot.api.core.domain.Entry)1 SolrBuildIntegrationTest (org.nextprot.api.tasks.solr.indexer.entry.SolrBuildIntegrationTest)1 Reflections (org.reflections.Reflections)1