Skip to content

Commit

Permalink
Merge pull request #477 from chrisvpeters/AUS-4215
Browse files Browse the repository at this point in the history
Aus 4215
  • Loading branch information
jia020 authored Sep 25, 2024
2 parents c48a35f + 5e55c89 commit f924797
Show file tree
Hide file tree
Showing 4 changed files with 136 additions and 42 deletions.
4 changes: 2 additions & 2 deletions .github/coverage/jacoco.csv
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
GROUP,PACKAGE,CLASS,INSTRUCTION_MISSED,INSTRUCTION_COVERED,BRANCH_MISSED,BRANCH_COVERED,LINE_MISSED,LINE_COVERED,COMPLEXITY_MISSED,COMPLEXITY_COVERED,METHOD_MISSED,METHOD_COVERED
Portal-Core,org.auscope.portal.core.server,PortalProfileXmlWebApplicationContext,24,0,2,0,5,0,3,0,2,0
Portal-Core,org.auscope.portal.core.server,PortalPropertySourcesPlaceholderConfigurer,99,0,10,0,25,0,8,0,3,0
Portal-Core,org.auscope.portal.core.server,PortalProfileXmlWebApplicationContext,24,0,2,0,5,0,3,0,2,0
Portal-Core,org.auscope.portal.core.server,OgcServiceProviderType,0,36,0,2,0,6,0,3,0,2
Portal-Core,org.auscope.portal.core.services.methodmakers,GeonetworkMethodMaker,210,0,0,0,39,0,7,0,7,0
Portal-Core,org.auscope.portal.core.services.methodmakers,SOSMethodMaker,4,295,8,18,1,61,8,8,0,3
Expand Down Expand Up @@ -49,8 +49,8 @@ Portal-Core,org.auscope.portal.core.services.responses.wcs,SingleValue,0,17,0,0,
Portal-Core,org.auscope.portal.core.services.responses.wcs,CoverageOfferingBrief,45,120,2,4,18,27,8,8,6,7
Portal-Core,org.auscope.portal.core.services.responses.wcs,SimpleEnvelope,77,137,4,6,16,28,6,10,2,9
Portal-Core,org.auscope.portal.core.services.responses.wcs,TimeConstraint,41,65,5,5,5,14,4,8,1,6
Portal-Core,org.auscope.portal.core.services.responses.wcs,RectifiedGrid,89,244,0,8,17,63,1,21,1,17
Portal-Core,org.auscope.portal.core.services.responses.wcs,SimpleTimePosition,0,45,0,0,0,13,0,3,0,3
Portal-Core,org.auscope.portal.core.services.responses.wcs,RectifiedGrid,89,244,0,8,17,63,1,21,1,17
Portal-Core,org.auscope.portal.core.services.responses.wcs,AxisDescriptionImpl,4,79,1,3,1,16,1,6,0,5
Portal-Core,org.auscope.portal.core.services.csw.custom,CustomRegistry,78,0,8,0,23,0,15,0,11,0
Portal-Core,org.auscope.portal.core.server.http,HttpServiceCaller,236,163,15,15,56,41,22,10,12,5
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import org.auscope.portal.core.view.knownlayer.KnownLayerSelector;
import org.auscope.portal.core.view.knownlayer.WMSSelector;
import org.auscope.portal.core.view.knownlayer.WMSSelectors;
import org.json.JSONArray;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Lazy;
Expand Down Expand Up @@ -333,19 +334,76 @@ public void updateKnownLayersCache(boolean updateCSWRecordsWithKnownLayerInfo) {

Set<String> onlineResourceEndpoints = new HashSet<>();
ArrayList<String> layerNames = new ArrayList<>();

JSONArray onlineResourceOrderList = null;
boolean onlineReorder = false;

if (kl.getOnlineResourceOrder() != null) {
onlineReorder = true;

onlineResourceOrderList = kl.getOnlineResourceOrder();

for (int i = 0; i < onlineResourceOrderList.length(); i++) {

JSONArray resourceOrderItem = (JSONArray) onlineResourceOrderList.get(i);

if ((resourceOrderItem).length() == 2) {
String resourceOrderName = (String) resourceOrderItem.get(0);
int resourceOrderIndex = (int) resourceOrderItem.get(1);
}
}
}

for (CSWRecord rec : knownLayerAndRecords.getBelongingRecords()) {
if (rec != null) {
// Update the CSW record with KnownLayer information required for searching (name and description)
rec.addKnownLayerId(knownLayerAndRecords.getKnownLayer().getId());
rec.addKnownLayerName(knownLayerAndRecords.getKnownLayer().getName());
rec.addKnownLayerDescription(knownLayerAndRecords.getKnownLayer().getDescription());
recordsToUpdate.add(rec);
// OnlineResources
for (AbstractCSWOnlineResource onlineResource : rec.getOnlineResources()) {
if (onlineResource.getLinkage() != null) {
onlineResourceEndpoints.add(onlineResource.getLinkage().getHost());
// Update the CSW record with KnownLayer information required for searching
// (name and description)
rec.addKnownLayerId(knownLayerAndRecords.getKnownLayer().getId());
rec.addKnownLayerName(knownLayerAndRecords.getKnownLayer().getName());
rec.addKnownLayerDescription(knownLayerAndRecords.getKnownLayer().getDescription());

recordsToUpdate.add(rec);
// OnlineResources
if (rec.getOnlineResources() != null) {

// reorder online resources based on onlineResourceOrder specified in
// layers.yaml (if present)
if (onlineReorder) {
List<AbstractCSWOnlineResource> newOnlineResourceList = new ArrayList<>();

// add the resources and reorder afterwards
for (AbstractCSWOnlineResource onlineResource : rec.getOnlineResources()) {
newOnlineResourceList.add(onlineResource);
}

for (int i = 0; i < onlineResourceOrderList.length(); i++) {
JSONArray resourceOrderItem = (JSONArray) onlineResourceOrderList.get(i);
if ((resourceOrderItem).length() == 2) {
String resourceOrderName = (String) resourceOrderItem.get(0);
int resourceOrderIndex = (int) resourceOrderItem.get(1) - 1;

// find online resource with the name resourceOrderName
for (AbstractCSWOnlineResource onlineResource : rec.getOnlineResources()) {
if (onlineResource.getName().equalsIgnoreCase(resourceOrderName)) {
try {
newOnlineResourceList.remove(resourceOrderIndex);
newOnlineResourceList.add(resourceOrderIndex, onlineResource);
} catch (Exception e) {
logger.error("Error reordeing online resources " + kl.getName() + " :" + e.getMessage());
}
}
}
}
}
rec.setOnlineResources(newOnlineResourceList);
}

for (AbstractCSWOnlineResource onlineResource : rec.getOnlineResources()) {
if (onlineResource.getLinkage() != null) {
onlineResourceEndpoints.add(onlineResource.getLinkage().getHost());
}
layerNames.add(onlineResource.getName());
}
layerNames.add(onlineResource.getName());
}
viewMappedRecords.add(viewCSWRecordFactory.toView(rec));
}
Expand All @@ -362,7 +420,8 @@ public void updateKnownLayersCache(boolean updateCSWRecordsWithKnownLayerInfo) {
List<ModelMap> viewCapabilityRecords = new ArrayList<>();
String layerName = null;
if (layerNames.size() > 0) {
layerName = layerNames.get(0);
layerName = layerNames.get(0); // TODO: - rather than getting the first - should get online resource
// that matches selector in layers.yaml??
}
for (GetCapabilitiesRecord rec : knownLayerAndRecords.getCapabilitiesRecords()) {
viewCapabilityRecords.add(viewGetCapabilitiesFactory.toView(rec, layerName));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,9 @@ public class KnownLayer implements Serializable {
/** geoJson bbox */
private JSONArray bbox;

/** onlineResourceOrder */
private JSONArray onlineResourceOrder;

/**
* Creates a new KnownLayer
*
Expand Down Expand Up @@ -541,6 +544,14 @@ public JSONArray getBBox() {
return bbox;
}

/**
* @return the onlineResourceOrder
*/
public JSONArray getOnlineResourceOrder() {
return onlineResourceOrder;
}


/**
* Set the VMF - polygon
*
Expand Down Expand Up @@ -583,5 +594,27 @@ public void setBBox(JSONArray bboxGeoJson) {
}

}


/**
* Set the setOnlineResourceOrder
*
* @param orderList
*/
public void setOnlineResourceOrder(JSONArray orderList) {
this.onlineResourceOrder = new JSONArray();

for (int i = 0; i < orderList.length(); i++) {

JSONArray oldResourceOrder = (JSONArray) orderList.get(i);

JSONArray newResourceOrder = new JSONArray();
newResourceOrder.put(oldResourceOrder.get(0)); // online reosurce name
newResourceOrder.put(oldResourceOrder.get(1)); // online resource order - numeric - starting at 1
this.onlineResourceOrder.put(newResourceOrder);

}

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -29,37 +29,39 @@ public WMSWFSSelector(String featureTypeName, String layerName, String[] service

@Override
public RelationType isRelatedRecord(CSWRecord record) {
List<AbstractCSWOnlineResource> cSWResources = record.getOnlineResources();
List<AbstractCSWOnlineResource> cSWResources = record.getOnlineResources();

// Check for strong association to begin with
for (AbstractCSWOnlineResource onlineResource : cSWResources) {
if (layerName.equals(onlineResource.getName()) || featureTypeName.equals(onlineResource.getName())) {
// OK we have a match, check we don't explicitly/implicitly exclude it
// based on its URL
if (serviceEndpoints != null && serviceEndpoints.length > 0) {
boolean matched = false;
for (String url : serviceEndpoints) {
if (onlineResource.getLinkage() != null ) {
if (onlineResource.getLinkage().toString().indexOf(url) >= 0) {
matched = true;
break;
}
}
}
if (cSWResources != null) {
// Check for strong association to begin with
for (AbstractCSWOnlineResource onlineResource : cSWResources) {
if (layerName.equals(onlineResource.getName()) || featureTypeName.equals(onlineResource.getName())) {
// OK we have a match, check we don't explicitly/implicitly exclude it
// based on its URL
if (serviceEndpoints != null && serviceEndpoints.length > 0) {
boolean matched = false;
for (String url : serviceEndpoints) {
if (onlineResource.getLinkage() != null ) {
if (onlineResource.getLinkage().toString().indexOf(url) >= 0) {
matched = true;
break;
}
}
}

// Our list of endpoints will be saying either
// 'Include only this list of urls'
// 'Exclude any of these urls'
if ((includeEndpoints && matched) || (!includeEndpoints && !matched)) {
return RelationType.Belongs;
}
} else {
// Otherwise this knownlayer makes no restrictions on URL
return RelationType.Belongs;
}
}
}
return RelationType.NotRelated;
// Our list of endpoints will be saying either
// 'Include only this list of urls'
// 'Exclude any of these urls'
if ((includeEndpoints && matched) || (!includeEndpoints && !matched)) {
return RelationType.Belongs;
}
} else {
// Otherwise this knownlayer makes no restrictions on URL
return RelationType.Belongs;
}
}
}
}
return RelationType.NotRelated;
}

public String getFeatureTypeName() {
Expand Down

0 comments on commit f924797

Please sign in to comment.