added state to location search service
LocationBasedServices/mowesta/master There was a failure building this commit

added weatherstation as device type
This commit is contained in:
pobel
2019-11-27 17:08:24 +01:00
parent 04ea643512
commit fd56ca5ba1
7 changed files with 259 additions and 4 deletions
@@ -14,8 +14,12 @@ public enum OperatingSystem {
/**
* Apple iOS.
*/
IOS;
IOS,
/**
* Weather Station
*/
WEATHER_STATION_OS;
@Override
public String toString() {
return name().toLowerCase();
@@ -67,7 +67,7 @@ public interface ILocationService {
@Path("cities")
@ApiOperation(value = "Returns a page of cities.", tags = { Tags.DEFAULT, Tags.LOCATION })
@ApiResponses({
@ApiResponse(code=HttpServletResponse.SC_OK, message="City digest page retrieved successfully.", response=CityPage.class),
@ApiResponse(code=HttpServletResponse.SC_OK, message="City page retrieved successfully.", response=CityPage.class),
@ApiResponse(code=HttpServletResponse.SC_BAD_REQUEST, message="Invalid request parameter.")
})
@PermitAll
@@ -107,4 +107,76 @@ public interface ILocationService {
@Produces({MediaType.APPLICATION_JSON})
Response getCityBoundary(@ApiParam(value = "The city id.", required = true) @PathParam("id") @Valid @Min(0) long id);
/**
* Returns a page of states that match the query.
*
* @param pageConfig The page configuration.
* @param context The search context.
* @param term The search term.
* @return A page of users whose name or login contains the search term.
*/
@GET
@Path("states/search")
@ApiOperation(value = "Returns a page of state digests whose name matches the term.", tags = { Tags.DEFAULT, Tags.LOCATION })
@ApiResponses({
@ApiResponse(code=HttpServletResponse.SC_OK, message="State digest page retrieved successfully.", response=StateDigestPage.class),
@ApiResponse(code=HttpServletResponse.SC_BAD_REQUEST, message="Invalid request parameter.")
})
@PermitAll
Response searchStates(@BeanParam @Valid PageConfig pageConfig, @BeanParam @Valid SearchContext context,
@ApiParam(value="The search term.", required=true) @QueryParam("term") @NotNull @Valid String term);
/**
* Returns a page of states.
*
* @param pageConfig The page configuration.
* @return A page of states.
*/
@GET
@Path("states")
@ApiOperation(value = "Returns a page of states.", tags = { Tags.DEFAULT, Tags.LOCATION })
@ApiResponses({
@ApiResponse(code=HttpServletResponse.SC_OK, message="State page retrieved successfully.", response=StatePage.class),
@ApiResponse(code=HttpServletResponse.SC_BAD_REQUEST, message="Invalid request parameter.")
})
@PermitAll
Response getStates(@BeanParam @Valid PageConfig pageConfig);
/**
* Returns a particular state.
*
* @param id The id of the state.
* @return The state, if exits.
*/
@GET
@Path("states/{id: [0-9]+}")
@ApiOperation(value = "Gets a state with a particular id.", tags = {Tags.DEFAULT, Tags.LOCATION})
@ApiResponses({
@ApiResponse(code = HttpServletResponse.SC_OK, message = "State retrieved successfully.", response=State.class),
@ApiResponse(code = HttpServletResponse.SC_NOT_FOUND, message = "The state does not exists."),
})
@PermitAll
Response getState(@ApiParam(value = "The state id.", required = true) @PathParam("id") @Valid @Min(0) long id);
/**
* Returns a geojson representation of the state boundaries.
*
* @param id The id of the state.
* @return The boundaries of geojson or an error code.
*/
@GET
@Path("state/{id: [0-9]+}/boundary")
@ApiOperation(value = "Gets the state boundary for a state with a particular id.", tags = {Tags.DEFAULT, Tags.LOCATION})
@ApiResponses({
@ApiResponse(code = HttpServletResponse.SC_OK, message = "State boundary retrieved successfully.", response=Geometry.class),
@ApiResponse(code = HttpServletResponse.SC_NO_CONTENT, message = "The state boundary are not available."),
@ApiResponse(code = HttpServletResponse.SC_NOT_FOUND, message = "The state does not exist."),
})
@PermitAll
@Produces({MediaType.APPLICATION_JSON})
Response getStateBoundary(@ApiParam(value = "The state id.", required = true) @PathParam("id") @Valid @Min(0) long id);
}
@@ -17,7 +17,7 @@ import io.swagger.annotations.ApiModelProperty;
/**
* A base class for cities, states and countries to share common
* fields.
*
*
* @author Marcus
*/
@XmlRootElement
@@ -0,0 +1,95 @@
package com.mowesta.api.location;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import javax.validation.constraints.NotNull;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlRootElement;
/**
* Represents a state with full details.
*
* @author Sebastian, Tobias
*/
@XmlRootElement
@ApiModel(description = "Represents a state with all details.", parent = Location.class)
public class State extends StateDigest {
/**
* The timezone of the state.
*/
@NotNull
@XmlAttribute(required = true)
@ApiModelProperty(value = "The timezone of the state.", required = true)
private String timezone;
/**
* The optional population of the state.
*/
@XmlAttribute(required = false)
@ApiModelProperty(value = "The population of the state.", required = false)
private Integer population;
/**
* The optional wikipedia entry.
*/
@XmlAttribute(required = false)
@ApiModelProperty(value = "The optional wikipedia entry of the state.", required = false)
private String wikipedia;
/**
* Returns the timezone.
*
* @return The timezone.
*/
public String getTimezone() {
return timezone;
}
/**
* Sets the timezone.
*
* @param timezone The timezone to set.
*/
public void setTimezone(String timezone) {
this.timezone = timezone;
}
/**
* Returns the population.
*
* @return The population.
*/
public Integer getPopulation() {
return population;
}
/**
* Sets the population.
*
* @param population The population to set.
*/
public void setPopulation(Integer population) {
this.population = population;
}
/**
* Returns the wikipedia.
*
* @return The wikipedia.
*/
public String getWikipedia() {
return wikipedia;
}
/**
* Sets the wikipedia.
*
* @param wikipedia The wikipedia to set.
*/
public void setWikipedia(String wikipedia) {
this.wikipedia = wikipedia;
}
}
@@ -0,0 +1,46 @@
package com.mowesta.api.location;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import javax.validation.constraints.NotNull;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlRootElement;
/**
* A minimal data transfer object for a state that only contains
* the fields required for a fancy search interface.
*
* @author Sebastian, Tobias
*/
@XmlRootElement
@ApiModel(description = "Represents the digest of a state.", parent = Location.class)
public class StateDigest extends Location {
/**
* The country of the state.
*/
@NotNull
@XmlAttribute(required = true)
@ApiModelProperty(value = "The country of the state.", required = true)
private Location country;
/**
* Returns the country.
*
* @return The country.
*/
public Location getCountry() {
return country;
}
/**
* Sets the country.
*
* @param country The country to set.
*/
public void setCountry(Location country) {
this.country = country;
}
}
@@ -0,0 +1,19 @@
package com.mowesta.api.location;
import com.mowesta.api.Page;
import io.swagger.annotations.ApiModel;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlSeeAlso;
/**
* A page of state digests.
*
* @author Sebastian, Tobias
*/
@XmlRootElement
@XmlSeeAlso(StateDigest.class)
@ApiModel(description = "Represents a page of state digests.", parent = Page.class)
public class StateDigestPage extends Page<StateDigest> {
}
@@ -0,0 +1,19 @@
package com.mowesta.api.location;
import com.mowesta.api.Page;
import io.swagger.annotations.ApiModel;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlSeeAlso;
/**
* A page of states.
*
* @author Sebastian, Tobias
*/
@XmlRootElement
@XmlSeeAlso(State.class)
@ApiModel(description = "Represents a page of states.", parent = Page.class)
public class StatePage extends Page<State> {
}