2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 package org.onap.aai.serialization.engines;
23 import org.apache.tinkerpop.gremlin.structure.Vertex;
24 import org.apache.tinkerpop.gremlin.structure.VertexProperty;
25 import org.onap.aai.introspection.Loader;
26 import org.onap.aai.serialization.db.JanusGraphSingleton;
28 import java.util.ArrayList;
29 import java.util.Iterator;
30 import java.util.List;
32 public class JanusGraphDBEngine extends TransactionalGraphEngine {
35 * Instantiates a new JanusGraph DB engine.
37 * @param style the style
38 * @param loader the loader
40 public JanusGraphDBEngine(QueryStyle style, Loader loader) {
41 super(style, loader, JanusGraphSingleton.getInstance());
45 * Instantiates a new JanusGraph DB engine.
47 * @param style the style
48 * @param loader the loader
49 * @param connect the connect
51 public JanusGraphDBEngine(QueryStyle style, Loader loader, boolean connect) {
54 this.singleton = JanusGraphSingleton.getInstance();
62 public boolean setListProperty(Vertex v, String name, List<?> objs) {
64 // clear out list full replace style
66 Iterator<VertexProperty<Object>> iterator = v.properties(name);
67 while (iterator.hasNext()) {
68 iterator.next().remove();
71 for (Object obj : objs) {
72 v.property(name, obj);
82 public List<Object> getListProperty(Vertex v, String name) {
84 List<Object> result = new ArrayList<>();
86 Iterator<VertexProperty<Object>> iterator = v.properties(name);
88 while (iterator.hasNext()) {
89 result.add(iterator.next().value());
92 if (result.isEmpty()) {