import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.List;
import java.util.Map;
import javax.ws.rs.core.MediaType;
@Override
public List<Vertex> getVertices(String type, Map<String, Object> filter) throws CrudException {
+ return getVertices(type, filter, new HashSet<String>());
+ }
+
+ @Override
+ public List<Vertex> getVertices(String type, Map<String, Object> filter, HashSet<String> properties) throws CrudException {
filter.put(org.onap.schema.OxmModelValidator.Metadata.NODE_TYPE.propertyName(), type);
+ List<NameValuePair> queryParams = convertToNameValuePair(filter);
+ queryParams.addAll(convertToNameValuePair("properties", properties));
String url = baseObjectUrl + "/filter" + "?"
- + URLEncodedUtils.format(convertToNameValuePair(filter), Charset.defaultCharset());
+ + URLEncodedUtils.format(queryParams, Charset.defaultCharset());
OperationResult getResult = client.get(url, createHeader(), MediaType.APPLICATION_JSON_TYPE);
return nvpList;
}
+
+ // https://stackoverflow.com/questions/26942330/convert-mapstring-string-to-listnamevaluepair-is-this-the-most-efficient
+ private List<NameValuePair> convertToNameValuePair(String key, HashSet<String> values) {
+ List<NameValuePair> nvpList = new ArrayList<>(values.size());
+
+ values.forEach((value) -> nvpList.add(new BasicNameValuePair(key, value)));
+
+ return nvpList;
+ }
private Map<String, List<String>> createHeader() {
Map<String, List<String>> headers = new HashMap<>();