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