IsochronesResponseInfo.java

  1. /*
  2.  * This file is part of Openrouteservice.
  3.  *
  4.  * Openrouteservice is free software; you can redistribute it and/or modify it under the terms of the
  5.  * GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1
  6.  * of the License, or (at your option) any later version.
  7.  *
  8.  * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
  9.  * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  10.  * See the GNU Lesser General Public License for more details.
  11.  *
  12.  * You should have received a copy of the GNU Lesser General Public License along with this library;
  13.  * if not, see <https://www.gnu.org/licenses/>.
  14.  */

  15. package org.heigit.ors.api.responses.isochrones;

  16. import com.fasterxml.jackson.annotation.JsonIgnore;
  17. import com.fasterxml.jackson.annotation.JsonInclude;
  18. import com.fasterxml.jackson.annotation.JsonProperty;
  19. import com.graphhopper.util.Helper;
  20. import io.swagger.v3.oas.annotations.media.Schema;
  21. import org.heigit.ors.api.EndpointsProperties;
  22. import org.heigit.ors.api.SystemMessageProperties;
  23. import org.heigit.ors.api.requests.isochrones.IsochronesRequest;
  24. import org.heigit.ors.api.responses.common.engineinfo.EngineInfo;
  25. import org.heigit.ors.api.util.AppInfo;
  26. import org.heigit.ors.api.util.SystemMessage;
  27. import org.heigit.ors.config.AppConfig;

  28. @Schema(name = "IsochronesResponseInfo", description = "Information about the request")
  29. @JsonInclude(JsonInclude.Include.NON_DEFAULT)
  30. public class IsochronesResponseInfo {
  31.     @Schema(description = "ID of the request (as passed in by the query)", example = "request123")
  32.     @JsonProperty("id")
  33.     private String id;

  34.     @Schema(description = "Copyright and attribution information", example = "openrouteservice.org | OpenStreetMap contributors")
  35.     @JsonProperty("attribution")
  36.     private String attribution;
  37.     @Schema(description = "The MD5 hash of the OSM planet file that was used for generating graphs", example = "c0327ba6")
  38.     @JsonProperty("osm_file_md5_hash")
  39.     private String osmFileMD5Hash;
  40.     @Schema(description = "The service that was requested", example = "isochrones")
  41.     @JsonProperty("service")
  42.     private final String service;
  43.     @Schema(description = "Time that the request was made (UNIX Epoch time)", example = "1549549847974")
  44.     @JsonProperty("timestamp")
  45.     private final long timeStamp;

  46.     @Schema(description = "The information that was used for generating the isochrones")
  47.     @JsonProperty("query")
  48.     private final IsochronesRequest request;

  49.     @Schema(description = "Information about the isochrones service")
  50.     @JsonProperty("engine")
  51.     private final EngineInfo engineInfo;

  52.     @Schema(description = "System message", example = "A message string configured in the service")
  53.     @JsonProperty("system_message")
  54.     private final String systemMessage;

  55.     public IsochronesResponseInfo(IsochronesRequest request, SystemMessageProperties systemMessageProperties, EndpointsProperties endpointsProperties) {
  56.         service = "isochrones";
  57.         timeStamp = System.currentTimeMillis();

  58.         if (AppConfig.hasValidMD5Hash())
  59.             osmFileMD5Hash = AppConfig.getMD5Hash();

  60.         if (!Helper.isEmpty(endpointsProperties.getIsochrones().getAttribution()))
  61.             attribution = endpointsProperties.getIsochrones().getAttribution();

  62.         if (request.hasId())
  63.             id = request.getId();

  64.         engineInfo = new EngineInfo(AppInfo.getEngineInfo());

  65.         this.request = request;

  66.         this.systemMessage = SystemMessage.getSystemMessage(request, systemMessageProperties);
  67.     }

  68.     @JsonIgnore
  69.     public void setGraphDate(String graphDate) {
  70.         engineInfo.setGraphDate(graphDate);
  71.     }

  72. }