use of org.vertexium.search.IndexHint in project vertexium by visallo.
the class GraphBaseWithSearchIndex method saveElementMutations.
@Override
public Iterable<Element> saveElementMutations(Iterable<ElementMutation> mutations, Authorizations authorizations) {
List<Element> elements = new ArrayList<>();
List<Element> elementsToAddToIndex = new ArrayList<>();
List<ElementAndIterableExtendedDataMutation> extendedDataToIndex = new ArrayList<>();
for (ElementMutation m : mutations) {
if (m instanceof ExistingElementMutation && !m.hasChanges()) {
elements.add(((ExistingElementMutation) m).getElement());
continue;
}
IndexHint indexHint = m.getIndexHint();
m.setIndexHint(IndexHint.DO_NOT_INDEX);
Element element = m.save(authorizations);
elements.add(element);
if (indexHint == IndexHint.INDEX) {
elementsToAddToIndex.add(element);
// noinspection unchecked
extendedDataToIndex.add(new ElementAndIterableExtendedDataMutation(element, m.getExtendedData()));
}
}
getSearchIndex().addElements(this, elementsToAddToIndex, authorizations);
for (ElementAndIterableExtendedDataMutation ed : extendedDataToIndex) {
getSearchIndex().addElementExtendedData(this, ed.element, ed.extendedData, authorizations);
}
return elements;
}
use of org.vertexium.search.IndexHint in project vertexium by visallo.
the class InMemoryEdge method prepareMutation.
@Override
@SuppressWarnings("unchecked")
public ExistingEdgeMutation prepareMutation() {
return new ExistingEdgeMutation(this) {
@Override
public Edge save(Authorizations authorizations) {
IndexHint indexHint = getIndexHint();
Visibility oldVisibility = InMemoryEdge.this.getVisibility();
saveExistingElementMutation(this, indexHint, authorizations);
Edge edge = getElement();
if (indexHint != IndexHint.DO_NOT_INDEX) {
saveMutationToSearchIndex(edge, oldVisibility, getNewElementVisibility(), getAlterPropertyVisibilities(), getExtendedData(), authorizations);
}
return edge;
}
};
}
use of org.vertexium.search.IndexHint in project vertexium by visallo.
the class InMemoryVertex method prepareMutation.
@Override
@SuppressWarnings("unchecked")
public ExistingElementMutation<Vertex> prepareMutation() {
return new ExistingElementMutationImpl<Vertex>(this) {
@Override
public Vertex save(Authorizations authorizations) {
IndexHint indexHint = getIndexHint();
Visibility oldElementVisibility = InMemoryVertex.this.getVisibility();
saveExistingElementMutation(this, indexHint, authorizations);
Vertex vertex = getElement();
if (indexHint != IndexHint.DO_NOT_INDEX) {
saveMutationToSearchIndex(vertex, oldElementVisibility, getNewElementVisibility(), getAlterPropertyVisibilities(), getExtendedData(), authorizations);
}
return vertex;
}
};
}
Aggregations