* ================================================================================
* Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
* ================================================================================
+ * Modifications Copyright © 2023 Deutsche Telekom.
+ * ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
protected GraphTraversal<Vertex, E> traversal = null;
protected Admin<Vertex, E> completeTraversal = null;
+ protected QueryBuilder<E> containerQuery;
+ protected QueryBuilder<E> parentQuery;
+
/**
* Instantiates a new graph traversal builder.
*
traversal.has(AAIProperties.NODE_TYPE, type);
}
stepIndex++;
- markContainer();
+ markContainerIndex();
return (QueryBuilder<Vertex>) this;
}
return this;
}
- /**
- * @{inheritDoc}
- */
@Override
public <E2> E2 getQuery() {
return (E2) this.traversal;
}
- /**
- * @{inheritDoc}
- */
@Override
public QueryBuilder<E> getParentQuery() {
-
- return cloneQueryAtStep(parentStepIndex);
+ return this.parentQuery != null
+ ? this.parentQuery
+ : cloneQueryAtStep(parentStepIndex);
}
@Override
if (this.parentStepIndex == 0) {
return removeQueryStepsBetween(0, containerStepIndex);
} else {
- return cloneQueryAtStep(containerStepIndex);
+ return this.containerQuery;
}
}
- /**
- * @{inheritDoc}
- */
@Override
public void markParentBoundary() {
+ this.parentQuery = cloneQueryAtStep(stepIndex);
parentStepIndex = stepIndex;
}
@Override
- public void markContainer() {
+ public void markContainerIndex() {
+ this.containerQuery = cloneQueryAtStep(stepIndex);
containerStepIndex = stepIndex;
}
- /**
- * @{inheritDoc}
- */
@Override
public Vertex getStart() {
return this.start;
if (this.completeTraversal == null) {
executeQuery();
}
- return this.completeTraversal.toList();
+ // clone is necessary since toList would optimize traversal steps
+ // which messes with the indeces that are registered while parsing
+ return this.completeTraversal.clone().toList();
}
protected QueryBuilder<Edge> has(String key, String value) {