Search in sources :

Example 1 with ExistingElementMutation

use of org.vertexium.mutation.ExistingElementMutation in project vertexium by visallo.

the class GraphBase method saveElementMutations.

@Override
public Iterable<Element> saveElementMutations(Iterable<ElementMutation> mutations, Authorizations authorizations) {
    List<Element> elements = new ArrayList<>();
    for (ElementMutation m : mutations) {
        if (m instanceof ExistingElementMutation && !m.hasChanges()) {
            elements.add(((ExistingElementMutation) m).getElement());
            continue;
        }
        Element element = m.save(authorizations);
        elements.add(element);
    }
    return elements;
}
Also used : ExistingElementMutation(org.vertexium.mutation.ExistingElementMutation) ElementMutation(org.vertexium.mutation.ElementMutation) ExistingElementMutation(org.vertexium.mutation.ExistingElementMutation)

Example 2 with ExistingElementMutation

use of org.vertexium.mutation.ExistingElementMutation 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)

Aggregations

ElementMutation (org.vertexium.mutation.ElementMutation)2 ExistingElementMutation (org.vertexium.mutation.ExistingElementMutation)2 ArrayList (java.util.ArrayList)1 IndexHint (org.vertexium.search.IndexHint)1