Commit f673eba4 by Suma Shivaprasad Committed by Madhan Neethiraj

ATLAS-1644: Taxonomy API /api/atlas/v1/taxonomies is broken

parent 6a4fcb95
......@@ -20,8 +20,10 @@ package org.apache.atlas.catalog.query;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.NoSuchElementException;
import org.apache.atlas.catalog.Request;
import org.apache.atlas.catalog.VertexWrapper;
......@@ -31,7 +33,9 @@ import org.apache.atlas.catalog.projection.Projection;
import org.apache.atlas.catalog.projection.ProjectionResult;
import org.apache.atlas.repository.Constants;
import org.apache.atlas.repository.graph.AtlasGraphProvider;
import org.apache.atlas.repository.graphdb.AtlasElement;
import org.apache.atlas.repository.graphdb.AtlasGraph;
import org.apache.atlas.repository.graphdb.AtlasVertex;
import org.apache.atlas.typesystem.persistence.Id;
import com.tinkerpop.blueprints.Compare;
......@@ -113,7 +117,42 @@ public abstract class BaseQuery implements AtlasQuery {
protected abstract Pipe getQueryPipe();
protected GremlinPipeline getRootVertexPipeline() {
return new GremlinPipeline(getGraph().getVertices());
return new GremlinPipeline(unWrapVertices());
}
protected Iterable<Object> unWrapVertices() {
final Iterable<AtlasVertex> vertices = getGraph().getVertices();
Iterable<Object> vertexIterable = new Iterable<Object>() {
Iterator<Object> iterator = new Iterator<Object>() {
Iterator<AtlasVertex> wrapperIterator = vertices.iterator();
@Override
public boolean hasNext() {
return wrapperIterator.hasNext();
}
@Override
public Object next() {
if (hasNext()) {
return ((AtlasElement) wrapperIterator.next().getV()).getWrappedElement();
} else {
throw new NoSuchElementException();
}
}
@Override
public void remove() {
throw new UnsupportedOperationException("Remove not supported");
}
};
@Override
public Iterator<Object> iterator() {
return iterator;
}
};
return vertexIterable;
}
protected Pipe getNotDeletedPipe() {
......
......@@ -166,4 +166,6 @@ public interface AtlasElement {
* @return
*/
boolean isIdAssigned();
<T> T getWrappedElement();
}
......@@ -17,6 +17,7 @@
*/
package org.apache.atlas.repository.graphdb.titan0;
import java.lang.Override;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
......@@ -134,7 +135,7 @@ public class Titan0Element<T extends Element> implements AtlasElement {
}
// not in interface
@Override
public T getWrappedElement() {
return wrappedElement;
}
......
......@@ -48,7 +48,6 @@ import com.thinkaurelius.titan.core.TitanElement;
*/
public class Titan1Element<T extends Element> implements AtlasElement {
private T element;
protected Titan1Graph graph;
......@@ -121,8 +120,7 @@ public class Titan1Element<T extends Element> implements AtlasElement {
return element.id();
}
//not in interface
@Override
public T getWrappedElement() {
return element;
}
......
......@@ -65,6 +65,7 @@ public abstract class BaseService {
try {
return provider.getResources(request);
} catch (RuntimeException e) {
LOG.error("Error while retrieving taxonomy ", e);
throw wrapRuntimeException(e);
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment