Search in sources :

Example 1 with IndexHint

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;
}
Also used : IndexHint(org.vertexium.search.IndexHint) ExistingElementMutation(org.vertexium.mutation.ExistingElementMutation) ArrayList(java.util.ArrayList) ElementMutation(org.vertexium.mutation.ElementMutation) ExistingElementMutation(org.vertexium.mutation.ExistingElementMutation)

Example 2 with IndexHint

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;
        }
    };
}
Also used : ExistingEdgeMutation(org.vertexium.mutation.ExistingEdgeMutation) IndexHint(org.vertexium.search.IndexHint)

Example 3 with IndexHint

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;
        }
    };
}
Also used : IndexHint(org.vertexium.search.IndexHint) ExistingElementMutationImpl(org.vertexium.mutation.ExistingElementMutationImpl)

Aggregations

IndexHint (org.vertexium.search.IndexHint)3 ArrayList (java.util.ArrayList)1 ElementMutation (org.vertexium.mutation.ElementMutation)1 ExistingEdgeMutation (org.vertexium.mutation.ExistingEdgeMutation)1 ExistingElementMutation (org.vertexium.mutation.ExistingElementMutation)1 ExistingElementMutationImpl (org.vertexium.mutation.ExistingElementMutationImpl)1