import java.util.List;
import org.apache.tinkerpop.gremlin.structure.Vertex;
-
import org.openecomp.aai.db.props.AAIProperties;
import org.openecomp.aai.exceptions.AAIException;
import org.openecomp.aai.introspection.Introspector;
import org.openecomp.aai.introspection.exceptions.AAIUnknownObjectException;
import org.openecomp.aai.serialization.db.DBSerializer;
import org.openecomp.aai.serialization.queryformats.exceptions.AAIFormatVertexException;
+import org.openecomp.aai.serialization.queryformats.params.Depth;
+import org.openecomp.aai.serialization.queryformats.params.NodesOnly;
import org.openecomp.aai.serialization.queryformats.utils.UrlBuilder;
+
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
private final JsonParser parser;
private final UrlBuilder urlBuilder;
private final boolean includeUrl;
-
+ private final boolean nodesOnly;
+ private final int depth;
private Resource (Builder builder) {
this.parser = new JsonParser();
this.loader = builder.getLoader();
this.serializer = builder.getSerializer();
this.urlBuilder = builder.getUrlBuilder();
this.includeUrl = builder.isIncludeUrl();
+ this.nodesOnly = builder.isNodesOnly();
+ this.depth = builder.getDepth();
}
@Override
wrapper.add(v);
try {
- getSerializer().dbToObject(wrapper, obj, 1, false, "false");
+ getSerializer().dbToObject(wrapper, obj, this.depth, this.nodesOnly, "false");
} catch (AAIException | UnsupportedEncodingException e) {
throw new AAIFormatVertexException("Failed to format vertex - error while serializing: " + e.getMessage(), e);
}
private DBSerializer getSerializer() { return serializer; }
private JsonParser getParser() { return parser; }
- public static class Builder {
+ public static class Builder implements NodesOnly<Builder>, Depth<Builder> {
private final Loader loader;
private final DBSerializer serializer;
private final UrlBuilder urlBuilder;
private boolean includeUrl = false;
-
+ private boolean nodesOnly = false;
+ private int depth = 1;
public Builder(Loader loader, DBSerializer serializer, UrlBuilder urlBuilder) {
this.loader = loader;
this.serializer = serializer;
this.includeUrl = true;
return this;
}
-
- protected boolean isIncludeUrl() {
+
+ public Builder nodesOnly(Boolean nodesOnly) {
+ this.nodesOnly = nodesOnly;
+ return this;
+ }
+ public boolean isNodesOnly() {
+ return this.nodesOnly;
+ }
+ public Builder depth(Integer depth) {
+ this.depth = depth;
+ return this;
+ }
+ public int getDepth() {
+ return this.depth;
+ }
+ public boolean isIncludeUrl() {
return this.includeUrl;
}