import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
+import java.util.List;
+import java.util.Map;
import java.util.Optional;
import org.apache.tinkerpop.gremlin.structure.Vertex;
import org.onap.aai.introspection.Loader;
import org.onap.aai.serialization.db.DBSerializer;
import org.onap.aai.serialization.queryformats.exceptions.AAIFormatVertexException;
+import org.onap.aai.serialization.queryformats.params.AsTree;
import org.onap.aai.serialization.queryformats.params.Depth;
import org.onap.aai.serialization.queryformats.params.NodesOnly;
import org.onap.aai.serialization.queryformats.utils.UrlBuilder;
import org.onap.aai.util.AAIConfig;
+import java.util.Optional;
+
public class ResourceWithSoT extends MultiFormatMapper {
protected JsonParser parser = new JsonParser();
protected final DBSerializer serializer;
this.serializer = builder.getSerializer();
this.depth = builder.getDepth();
this.nodesOnly = builder.isNodesOnly();
+ this.isTree = builder.isTree();
}
@Override
return 100;
}
- public static class Builder implements NodesOnly<Builder>, Depth<Builder> {
+ public static class Builder implements NodesOnly<Builder>, Depth<Builder>, AsTree<Builder> {
protected final Loader loader;
protected final DBSerializer serializer;
protected boolean nodesOnly = false;
protected int depth = 1;
protected boolean modelDriven = false;
+ protected boolean tree = false;
public Builder(Loader loader, DBSerializer serializer, UrlBuilder urlBuilder) {
this.loader = loader;
return this;
}
+ protected boolean isTree() { return this.tree; }
+
+ public Builder isTree(Boolean tree) {
+ this.tree = tree;
+ return this;
+ }
+
public Builder nodesOnly(Boolean nodesOnly) {
this.nodesOnly = nodesOnly;
return this;
@Override
protected Optional<JsonObject> getJsonFromVertex(Vertex v) throws AAIFormatVertexException {
// Null check
- if (v == null)
+ if (v == null) {
return null;
+ }
JsonObject json = new JsonObject();
Object lastModifiedTimestampObj = v.property(AAIProperties.LAST_MOD_TS).value();
Object sotObj = v.property(AAIProperties.SOURCE_OF_TRUTH).value();
Object lastModSotObj = v.property(AAIProperties.LAST_MOD_SOURCE_OF_TRUTH).value();
- long createdTimestamp = Long.valueOf(createdTimestampObj.toString());
- long lastModifiedTimestamp = Long.valueOf(lastModifiedTimestampObj.toString());
- long threshold = Long.valueOf(AAIConfig.get("aai.resource.format.threshold", "10"));
+ long createdTimestamp = Long.parseLong(createdTimestampObj.toString());
+ long lastModifiedTimestamp = Long.parseLong(lastModifiedTimestampObj.toString());
+ long threshold = Long.parseLong(AAIConfig.get("aai.resource.format.threshold", "10"));
// Add to the property field of the JSON payload
json.addProperty("aai-created-ts", createdTimestampObj.toString());
return Optional.of(json);
}
+
+ @Override
+ protected Optional<JsonObject> getJsonFromVertex(Vertex input, Map<String, List<String>> properties) throws AAIFormatVertexException {
+ return Optional.empty();
+ }
}