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;
}
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;
}
Aggregations