Skip to content

Commit

Permalink
fixes from joses review
Browse files Browse the repository at this point in the history
  • Loading branch information
david-blasby committed Sep 18, 2024
1 parent 6623ea7 commit dd1db6e
Show file tree
Hide file tree
Showing 24 changed files with 838 additions and 93 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import org.fao.geonet.ogcapi.records.controller.model.Root;
import org.fao.geonet.ogcapi.records.model.OgcApiLink;
import org.fao.geonet.ogcapi.records.model.XsltModel;
import org.fao.geonet.ogcapi.records.service.RecordService;
import org.fao.geonet.ogcapi.records.util.CollectionInfoBuilder;
import org.fao.geonet.ogcapi.records.util.LinksItemsBuilder;
import org.fao.geonet.ogcapi.records.util.MediaTypeUtil;
Expand Down Expand Up @@ -69,25 +68,17 @@ public class CapabilitiesApiController {

@Autowired
ConcurrentMapCacheManager cacheManager;

@Autowired
private SourceRepository sourceRepository;

@Autowired
private SearchConfiguration configuration;

@Autowired
MediaTypeUtil mediaTypeUtil;

@Autowired
CollectionInfoBuilder collectionInfoBuilder;

@Autowired
RecordService recordService;
private SourceRepository sourceRepository;
@Autowired
private SearchConfiguration configuration;

/**
* Landing page end-point.
*
*/
@io.swagger.v3.oas.annotations.Operation(
summary = "Landing page.",
Expand Down Expand Up @@ -126,7 +117,7 @@ public ResponseEntity<Root> getLandingPage(@ApiIgnore HttpServletRequest request

CollectionInfo collectionInfo = collectionInfoBuilder
.buildFromSource(source, language, requestBaseUrl,
configuration.getFormat(mediaType), configuration,request);
configuration.getFormat(mediaType), configuration, request);
root.setSystemInfo(collectionInfo);
}

Expand All @@ -137,10 +128,10 @@ public ResponseEntity<Root> getLandingPage(@ApiIgnore HttpServletRequest request

configuration.getFormats(Operations.root).forEach(f ->
root.addLinksItem(new OgcApiLink()
.href(requestBaseUrl + "collections?f=" + f.getName())
.type("Catalogue collections")
.rel("self")
.type(f.getMimeType())));
.href(requestBaseUrl + "collections?f=" + f.getName())
.type("Catalogue collections")
.rel("self")
.type(f.getMimeType())));

addOpenApiLinks(root, requestBaseUrl);
addConformanceLinks(root, requestBaseUrl);
Expand Down Expand Up @@ -185,7 +176,6 @@ private void addConformanceLinks(Root root, String baseUrl) {
.rel(CONFORMANCE_REL)
.type(MediaType.TEXT_HTML_VALUE));


root.addLinksItem(new OgcApiLink()
.href(baseUrl + CONFORMANCE_REL + "?f=json")
.title(title + " as JSON")
Expand Down Expand Up @@ -226,7 +216,7 @@ public ResponseEntity<Conformance> conformanceDeclaration(@ApiIgnore HttpServlet
"http://www.opengis.net/spec/ogcapi-records-1/1.0/conf/html",
"http://www.opengis.net/spec/ogcapi-records-1/1.0/conf/json",
"http://www.opengis.net/spec/ogcapi-records-1/1.0/conf/sorting"
));
));

if (!mediaType.equals(MediaType.TEXT_HTML)) {
return ResponseEntity.ok(conformance);
Expand All @@ -248,7 +238,6 @@ public ResponseEntity<Conformance> conformanceDeclaration(@ApiIgnore HttpServlet

/**
* Collections information end-point.
*
*/
@io.swagger.v3.oas.annotations.Operation(
summary = "Collections available from this API.",
Expand Down Expand Up @@ -282,7 +271,7 @@ public ResponseEntity<Content> describeCollections(@ApiIgnore HttpServletRequest
sources.forEach(s -> content.addCollectionsItem(
collectionInfoBuilder.buildFromSource(
s, language, requestBaseUrl, configuration.getFormat(mediaType),
configuration,request)));
configuration, request)));

// TODO: Accept format parameter.
List<OgcApiLink> linkList = LinksItemsBuilder.build(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,21 +67,16 @@ public class CollectionApiController {
@Autowired
@Qualifier("xsltViewResolver")
ViewResolver viewResolver;

@Autowired
private CollectionService collectionService;

@Autowired
MessageSource messages;

@Autowired
private SearchConfiguration configuration;

@Autowired
MediaTypeUtil mediaTypeUtil;

@Autowired
CollectionInfoBuilder collectionInfoBuilder;
@Autowired
private CollectionService collectionService;
@Autowired
private SearchConfiguration configuration;

/**
* Describe a collection.
Expand Down Expand Up @@ -136,7 +131,7 @@ public ResponseEntity<CollectionInfo> describeCollection(

CollectionInfo collectionInfo = collectionInfoBuilder
.buildFromSource(source, language, requestBaseUrl,
configuration.getFormat(mediaType), configuration,request);
configuration.getFormat(mediaType), configuration, request);

return ResponseEntity.ok(collectionInfo);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import org.fao.geonet.ogcapi.records.model.OgcApiExtent;
import org.fao.geonet.ogcapi.records.model.OgcApiLanguage;
import org.fao.geonet.ogcapi.records.model.OgcApiLink;
import org.fao.geonet.ogcapi.records.model.OgcApiSchema;
import org.fao.geonet.ogcapi.records.model.OgcApiTheme;

/**
Expand All @@ -33,52 +34,70 @@
@XmlAccessorType(XmlAccessType.FIELD)
public class CollectionInfo {

/**
* Fixed value of "Catalog".
*/
//required cf. https://github.com/opengeospatial/ogcapi-records/blob/master/core/openapi/schemas/catalog.yaml
@JsonProperty("type")
@JacksonXmlProperty(localName = "type")
private String type = "catalog";

//cf. https://github.com/opengeospatial/ogcapi-records/blob/master/core/openapi/schemas/catalog.yaml
// cf. https://github.com/opengeospatial/ogcapi-records/blob/master/core/openapi/schemas/catalog.yaml
// NOTE: spec says this should be "record" or ["record","catalog"].
/**Fixed value of "record", "catalog" or both.*/
@JsonProperty("itemType")
@JacksonXmlProperty(localName = "itemType")
private String itemType = "record";


/**The identifier of the catalog.*/
/**
* The identifier of the catalog.
*/
@JsonProperty("id")
@JacksonXmlProperty(localName = "id")
private String id;

/**A human-readable name given to the resource.*/
/**
* A human-readable name given to the resource.
*/
@JsonProperty("title")
@JacksonXmlProperty(localName = "title")
private String title;

/**A free-text account of the resource.*/
/**
* A free-text account of the resource.
*/
@JsonProperty("description")
@JacksonXmlProperty(localName = "description")
private String description;

/**links for this object.*/
/**
* links for this object.
*/
@JsonProperty("links")
@JacksonXmlProperty(localName = "links")
@JsonInclude(Include.NON_EMPTY)
private List<OgcApiLink> links = new ArrayList<>();

/**The spatiotemporal coverage of this catalog.*/
/**
* The spatiotemporal coverage of this catalog.
*/
@JsonProperty("extent")
@JacksonXmlProperty(localName = "extent")
private OgcApiExtent extent;

/**The list of supported coordinate reference systems.*/
/**
* The list of supported coordinate reference systems.
*/
@JsonProperty("crs")
@JacksonXmlProperty(localName = "crs")
@JsonInclude(Include.NON_EMPTY)
private List<String> crs = null;

/** A list of contacts qualified by their role(s) in association
* to the record or the resource described by the record. */
/**
* A list of contacts qualified by their role(s) in association to the record or the resource
* described by the record.
*/
@JsonProperty("contacts")
@JacksonXmlProperty(localName = "contacts")
@JsonInclude(Include.NON_EMPTY)
Expand Down Expand Up @@ -171,6 +190,76 @@ public class CollectionInfo {
private List<String> defaultSortOrder = null;


//--------------------------------------------------------------------------
// these are properties in the written spec, but not in the .yaml definition
//--------------------------------------------------------------------------

/**
* The extensions/conformance classes used in this catalog object.
*/
@JsonProperty("conformsTo")
@JacksonXmlProperty(localName = "conformsTo")
@JsonInclude(Include.NON_EMPTY)
private String conformsTo = null;

/**The list of languages in which records from the collection can be represented.*/
@JsonProperty("recordLanguages")
@JacksonXmlProperty(localName = "recordLanguages")
@JsonInclude(Include.NON_EMPTY)
private List<String> recordLanguages = null;


/**
* The name of the array property in the catalog used to encode records in-line.
* The default value is records.
*/
@JsonProperty("recordsArrayName")
@JacksonXmlProperty(localName = "recordsArrayName")
@JsonInclude(Include.NON_EMPTY)
private String recordsArrayName = null;

/**A list of schemes related to this catalog.*/
@JsonProperty("schemes")
@JacksonXmlProperty(localName = "schemes")
@JsonInclude(Include.NON_EMPTY)
private List<OgcApiSchema> schemes = null;


//--------------------------------------------------------------------------


public String getConformsTo() {
return conformsTo;
}

public void setConformsTo(String conformsTo) {
this.conformsTo = conformsTo;
}

public List<String> getRecordLanguages() {
return recordLanguages;
}

public void setRecordLanguages(List<String> recordLanguages) {
this.recordLanguages = recordLanguages;
}

public String getRecordsArrayName() {
return recordsArrayName;
}

public void setRecordsArrayName(String recordsArrayName) {
this.recordsArrayName = recordsArrayName;
}

public List<OgcApiSchema> getSchemes() {
return schemes;
}

public void setSchemes(List<OgcApiSchema> schemes) {
this.schemes = schemes;
}

public List<String> getDefaultSortOrder() {
return defaultSortOrder;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
/**
* (c) 2024 Open Source Geospatial Foundation - all rights reserved This code is licensed under the
* GPL 2.0 license, available at the root application directory.
*/

package org.fao.geonet.ogcapi.records.controller.model;

import com.fasterxml.jackson.annotation.JsonCreator;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,14 @@ public class Root {

/**
* This is the collection info for the main-portal.
*
* <p>THIS IS NON-STANDARD (not in the ogcapi spec)!
*
* <p>The landing page JSON also includes a new property systemInfo which contains a catalog.yaml
* object in it.
* I'm not sure if this is allowed in the spec, but it allows for more metadata about the
* entire GN system ("ogcapi-records" server). This is useful for making a nicer landing page
* (cf. pygeoapi's landing page).
*/
@JsonProperty("systemInfo")
@JacksonXmlProperty(localName = "systemInfo")
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/**
* (c) 2024 Open Source Geospatial Foundation - all rights reserved This code is licensed under the
* GPL 2.0 license, available at the root application directory.
*/

package org.fao.geonet.ogcapi.records.model;

/**
* OgcApiComponent.
*
* <p>cf. https://github.com/opengeospatial/ogcapi-records/blob/master/core/openapi/schemas/schema.yaml
*
* <p>TODO - This is a very complex object with many pattern properties. I've left this empty
* for now. When this is needed, please fill in (also, include the x-* properties used elsewhere).
*/
public class OgcApiComponent {

}
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@
* cf. https://github.com/opengeospatial/ogcapi-records/blob/master/core/openapi/schemas/theme.yaml
*
* <p>Entity/concept identifiers from this knowledge
* system. it is recommended that a resolvable URI be used for
* each entity/concept identifier.
* system. it is recommended that a resolvable URI be used for each entity/concept identifier.
*/
public class OgcApiConcept {

Expand Down
Loading

0 comments on commit dd1db6e

Please sign in to comment.