use of nl.knaw.huygens.timbuctoo.search.EntityRef in project timbuctoo by HuygensING.
the class SearchResponseV2_1RefAdderTest method addsASearchResponseRefToTheSearchResult.
@Test
public void addsASearchResponseRefToTheSearchResult() {
SearchResponseV2_1RefAdder instance = new SearchResponseV2_1RefAdder();
SearchResponseV2_1 searchResponse = new SearchResponseV2_1();
EntityRef entityRef = new EntityRef("type", "id");
entityRef.setDisplayName("displayName");
instance.addRef(searchResponse, entityRef);
assertThat(searchResponse.getRefs(), Matchers.contains(SearchResponseV2_1RefMatcher.likeSearchResponseRef().withId("id").withType("type").withDisplayName("displayName").withPath("domain/types/id")));
}
use of nl.knaw.huygens.timbuctoo.search.EntityRef in project timbuctoo by HuygensING.
the class AbstractSearchDescription method createRef.
public EntityRef createRef(Vertex vertex) {
String id = getIdDescriptor().get(vertex);
EntityRef ref = new EntityRef(getType(), id);
String displayName = getDisplayNameDescriptor().get(vertex);
ref.setDisplayName(displayName);
Map<String, Object> data = Maps.newHashMap();
getDataPropertyDescriptors().entrySet().forEach(entry -> data.put(entry.getKey(), entry.getValue().get(vertex)));
ref.setData(data);
return ref;
}
use of nl.knaw.huygens.timbuctoo.search.EntityRef in project timbuctoo by HuygensING.
the class CnwPersonSearchDescription method createRef.
@Override
public EntityRef createRef(Vertex vertex) {
final ObjectMapper objectMapper = new ObjectMapper();
EntityRef entityRef = super.createRef(vertex);
Map<String, Object> data = entityRef.getData();
try {
final TypeReference<List<String>> listTypeReference = new TypeReference<List<String>>() {
};
data.put("networkDomains", objectMapper.readValue((String) vertex.value("cnwperson_networkDomains"), listTypeReference));
data.put("characteristics", objectMapper.readValue((String) vertex.value("cnwperson_characteristics"), listTypeReference));
data.put("combinedDomains", objectMapper.readValue((String) vertex.value("cnwperson_combinedDomains"), listTypeReference));
data.put("memberships", objectMapper.readValue((String) vertex.value("cnwperson_memberships"), listTypeReference));
data.put("periodicals", objectMapper.readValue((String) vertex.value("cnwperson_periodicals"), listTypeReference));
} catch (IOException e) {
LOG.error("Cannot read value for cnwperson with tim_id: {}", vertex.value("tim_id"), e);
}
entityRef.setData(data);
return entityRef;
}
use of nl.knaw.huygens.timbuctoo.search.EntityRef in project timbuctoo by HuygensING.
the class ReceptionSearchDescription method createRef.
@Override
public EntityRef createRef(Vertex vertex) {
Edge inEdge = vertex.edges(Direction.IN, getRelationNames()).next();
Vertex otherVertex = inEdge.outVertex();
EntityRef targetRef = super.createRef(vertex);
EntityRef sourceRef = otherSearch.getSearchDescription().createRef(otherVertex);
EntityRef ref = new EntityRef("wwrelation", (String) inEdge.property("tim_id").value());
ref.setRelationName(inEdge.label());
ref.setTargetData(targetRef.getData());
ref.setTargetName(targetRef.getDisplayName());
ref.setSourceData(sourceRef.getData());
ref.setSourceName(sourceRef.getDisplayName());
return ref;
}
use of nl.knaw.huygens.timbuctoo.search.EntityRef in project timbuctoo by HuygensING.
the class SearchResponseV2_1RefAdderTest method addsTheDataOfTheEntityRefToTheSearchResponseV2_1Ref.
@Test
public void addsTheDataOfTheEntityRefToTheSearchResponseV2_1Ref() {
SearchResponseV2_1RefAdder instance = new SearchResponseV2_1RefAdder();
SearchResponseV2_1 searchResponse = new SearchResponseV2_1();
EntityRef entityRef = new EntityRef("type", "id");
HashMap<String, Object> data = Maps.newHashMap();
entityRef.setData(data);
instance.addRef(searchResponse, entityRef);
assertThat(searchResponse.getRefs(), Matchers.contains(SearchResponseV2_1RefMatcher.likeSearchResponseRef().withData(data)));
}
Aggregations