Skip to content

Commit

Permalink
Merge pull request #138 from opengeospatial/issue#134
Browse files Browse the repository at this point in the history
Added check to collect collections on basis of itemType and items.
  • Loading branch information
dstenger authored Mar 2, 2021
2 parents af4e2fc + 1a09587 commit 810b8ee
Showing 1 changed file with 19 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import java.net.URI;
import java.util.*;

import org.apache.commons.lang3.StringUtils;
import org.opengis.cite.ogcapifeatures10.CommonDataFixture;
import org.opengis.cite.ogcapifeatures10.SuiteAttribute;
import org.opengis.cite.ogcapifeatures10.openapi3.TestPoint;
Expand Down Expand Up @@ -227,10 +228,24 @@ public void validateFeatureCollectionsMetadataOperationResponse_Content( TestPoi

private List<Map<String, Object>> createCollectionsMap( List<Object> collections ) {
List<Map<String, Object>> collectionsMap = new ArrayList<>();
for ( Object collection : collections ) {
collectionsMap.add( (Map<String, Object>) collection );
if ( noOfCollections > 0 && collectionsMap.size() >= noOfCollections )
return collectionsMap;
for (Object collectionObj : collections) {
Map<String, Object> collection = (Map<String, Object>) collectionObj;
if (null != collection.get("id")) {
String itemType = (String) collection.get("itemType");
if (StringUtils.isEmpty(itemType) || itemType.equalsIgnoreCase("feature")) {
List<Object> links = (List<Object>) collection.get("links");
for (Object linkObj : links) {
Map<String, Object> link = (Map<String, Object>) linkObj;
if (link.get("rel").equals("items")) {
collectionsMap.add(collection);
break;
}
}
}
if (noOfCollections > 0 && collectionsMap.size() >= noOfCollections) {
return collectionsMap;
}
}
}
return collectionsMap;
}
Expand Down

0 comments on commit 810b8ee

Please sign in to comment.