Permalink
Browse files

Add block, initial swagger dependencies and documentation

  • Loading branch information...
1 parent 88a3eca commit 13f2742179f556465acf82666ba3b402e13cc6bb @jmarin jmarin committed Oct 18, 2012
View
@@ -102,7 +102,7 @@
<artifactId>aspectjweaver</artifactId>
<version>${aspectj.version}</version>
</dependency>
-
+
<!-- Hibernate Spatial -->
<dependency>
@@ -252,23 +252,30 @@
</dependency>
<!-- Monitoring -->
-
+
+ <dependency>
+ <groupId>com.yammer.metrics</groupId>
+ <artifactId>metrics-core</artifactId>
+ <version>${metrics.version}</version>
+ </dependency>
<dependency>
- <groupId>com.yammer.metrics</groupId>
- <artifactId>metrics-core</artifactId>
- <version>${metrics.version}</version>
+ <groupId>com.yammer.metrics</groupId>
+ <artifactId>metrics-web</artifactId>
+ <version>${metrics.version}</version>
</dependency>
<dependency>
- <groupId>com.yammer.metrics</groupId>
- <artifactId>metrics-web</artifactId>
- <version>${metrics.version}</version>
+ <groupId>com.yammer.metrics</groupId>
+ <artifactId>metrics-jersey</artifactId>
+ <version>${metrics.version}</version>
</dependency>
+
+ <!-- Documentation -->
<dependency>
- <groupId>com.yammer.metrics</groupId>
- <artifactId>metrics-jersey</artifactId>
- <version>${metrics.version}</version>
+ <groupId>com.wordnik</groupId>
+ <artifactId>swagger-jaxrs_2.9.1</artifactId>
+ <version>1.1.0</version>
+ <scope>compile</scope>
</dependency>
-
<!-- Testing -->
<dependency>
@@ -0,0 +1,57 @@
+package org.geo.spatialsearch.census.model;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.Table;
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlType;
+
+/**
+ *
+ * @author Juan Marin
+ *
+ */
+
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "Block")
+@XmlRootElement(name = "Block")
+@Entity
+@Table(name = "block2010", schema = "census")
+public class Block2010 extends CensusGeoBaseObject {
+
+ @Column(name = "STATEFP10")
+ private String statefp;
+
+ @Column(name = "COUNTYFP10")
+ private String countyfp;
+
+ @Column(name = "GEOID10")
+ private String geoid;
+
+ public String getStatefp() {
+ return statefp;
+ }
+
+ public void setStatefp(String statefp) {
+ this.statefp = statefp;
+ }
+
+ public String getCountyfp() {
+ return countyfp;
+ }
+
+ public void setCountyfp(String countyfp) {
+ this.countyfp = countyfp;
+ }
+
+ public String getGeoid() {
+ return geoid;
+ }
+
+ public void setGeoid(String geoid) {
+ this.geoid = geoid;
+ }
+
+}
@@ -10,9 +10,7 @@
*/
public enum CensusGeographyEnum {
STATE2010("state2010"), COUNTY2010("county2010"), TRACT2010("tract2010"), BLOCK2010(
- "block2010"), CONGRESSIONAL_DISTRICT("congdistrict"), PLACE(
- "censusplace"), MSA("msa"), TRIBAL("tribalnation"), STATE_HOUSE_DISTRICT(
- "statehouse"), STATE_SENATE_DISTRICT("statesenate"), ALL("all");
+ "block2010"), ALL("all");
private String externalGeographyType;
@@ -7,12 +7,13 @@
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
+import org.geo.spatialsearch.census.model.Block2010;
import org.geo.spatialsearch.census.model.State2010;
/**
*
* @author Juan Marin
- *
+ *
*/
@XmlAccessorType(XmlAccessType.FIELD)
public class CensusLookupBaseResponse {
@@ -26,30 +27,9 @@
// @XmlElement(name = "censusTract")
// private List<Tract2000> tracts;
//
- // @XmlElement(name = "block")
- // private List<Block2000> blocks;
- //
- // @XmlElement(name = "censusPlace")
- // private List<Place> places;
- //
- // @XmlElement(name = "stateSenateDistrict")
- // private List<StateSenateDistrict> stateSenateDistricts;
- //
- // @XmlElement(name = "stateHouseDistrict")
- // private List<StateHouseDistrict> stateHouseDistricts;
- //
- // @XmlElement(name = "msa")
- // private List<MSA> msas;
- //
- // @XmlElement(name = "congressionalDistrict")
- // private List<CongDistrict> congDistricts;
- //
- // @XmlElement(name = "tribalNations")
- // private List<Tribal> tribalNations;
- //
- // @XmlElement(name = "USF")
- // private List<Usf> usfList;
- //
+ @XmlElement(name = "block")
+ private List<Block2010> blocks;
+
public CensusLookupBaseResponse() {
}
@@ -86,93 +66,15 @@ public void setStates(List<State2010> states) {
// this.tracts = tracts;
// }
//
- // public List<Block2000> getBlocks() {
- // if (blocks == null) {
- // blocks = new ArrayList<Block2000>();
- // }
- // return blocks;
- // }
- //
- // public void setBlocks(List<Block2000> blocks) {
- // this.blocks = blocks;
- // }
- //
- // public List<Place> getPlaces() {
- // if (places == null) {
- // places = new ArrayList<Place>();
- // }
- // return places;
- // }
- //
- // public void setPlaces(List<Place> places) {
- // this.places = places;
- // }
- //
- // public List<StateSenateDistrict> getStateSenateDistricts() {
- // if (stateSenateDistricts == null) {
- // stateSenateDistricts = new ArrayList<StateSenateDistrict>();
- // }
- // return stateSenateDistricts;
- // }
- //
- // public void setStateSenateDistricts(List<StateSenateDistrict>
- // stateSenateDistricts) {
- // this.stateSenateDistricts = stateSenateDistricts;
- // }
- //
- // public List<StateHouseDistrict> getStateHouseDistricts() {
- // if (stateHouseDistricts == null) {
- // stateHouseDistricts = new ArrayList<StateHouseDistrict>();
- // }
- // return stateHouseDistricts;
- // }
- //
- // public void setStateHouseDistricts(List<StateHouseDistrict>
- // stateHouseDistricts) {
- // this.stateHouseDistricts = stateHouseDistricts;
- // }
- //
- // public List<MSA> getMsas() {
- // if (msas == null) {
- // msas = new ArrayList<MSA>();
- // }
- // return msas;
- // }
- //
- // public void setMsas(List<MSA> msas) {
- // this.msas = msas;
- // }
- //
- // public List<CongDistrict> getCongDistricts() {
- // if (congDistricts == null) {
- // congDistricts = new ArrayList<CongDistrict>();
- // }
- // return congDistricts;
- // }
- //
- // public void setCongDistricts(List<CongDistrict> congDistricts) {
- // this.congDistricts = congDistricts;
- // }
- //
- // public void setTribalNations(List<Tribal> tribalNations) {
- // this.tribalNations = tribalNations;
- // }
- //
- // public List<Tribal> getTribalNations() {
- // if (tribalNations == null){
- // tribalNations = new ArrayList<Tribal>();
- // }
- // return tribalNations;
- // }
- //
- // public void setUsfList(List<Usf> usfList) {
- // this.usfList = usfList;
- // }
- //
- // public List<Usf> getUsfList() {
- // if (usfList == null){
- // usfList = new ArrayList<Usf>();
- // }
- // return usfList;
- // }
+ public List<Block2010> getBlocks() {
+ if (blocks == null) {
+ blocks = new ArrayList<Block2010>();
+ }
+ return blocks;
+ }
+
+ public void setBlocks(List<Block2010> blocks) {
+ this.blocks = blocks;
+ }
+
}
@@ -22,6 +22,9 @@
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
+import com.wordnik.swagger.annotations.Api;
+import com.wordnik.swagger.annotations.ApiOperation;
+import com.wordnik.swagger.annotations.ApiParam;
import com.yammer.metrics.annotation.Timed;
/**
@@ -35,6 +38,7 @@
@Scope(value = "singleton")
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML,
"application/x-javascript" })
+@Api(value = "census", basePath = "/census", description = "Census API")
public class CensusResourceImpl implements CensusResource {
@Autowired
@@ -45,20 +49,25 @@
@Qualifier("exceptionHandler")
private ExceptionHandler handler;
- //private static final String CENSUS_BY_COORDINATES = "Census-findByCoordinates";
- //private static final String CENSUS_BY_FIPSCODE = "Census-findGeographyByFips";
- //private static final String CENSUS_BY_GEOGRAPHY_NAME = "Census-findGeographyByName";
+ // private static final String CENSUS_BY_COORDINATES =
+ // "Census-findByCoordinates";
+ // private static final String CENSUS_BY_FIPSCODE =
+ // "Census-findGeographyByFips";
+ // private static final String CENSUS_BY_GEOGRAPHY_NAME =
+ // "Census-findGeographyByName";
@Override
@Path(value = "{geography}")
@GET
@Timed
- public Response findByCoordinates(@Context UriInfo uriInfo,
- @PathParam(value = "geography") String geography,
- @QueryParam(value = "latitude") double latitude,
- @QueryParam(value = "longitude") double longitude,
- @DefaultValue("xml") @QueryParam(value = "format") String format,
- @QueryParam(value = "callback") String callback) {
+ @ApiOperation(value = "Find Geography by Coordinates", notes = "Returns a Census Geography at a certain latitude, longitude", httpMethod = "GET")
+ public Response findByCoordinates(
+ @Context UriInfo uriInfo,
+ @ApiParam(value = "geography", required = true) @PathParam(value = "geography") String geography,
+ @ApiParam(value = "latitude", required = true) @QueryParam(value = "latitude") double latitude,
+ @ApiParam(value = "longitude", required = true) @QueryParam(value = "longitude") double longitude,
+ @ApiParam(value = "format", required = false) @DefaultValue("xml") @QueryParam(value = "format") String format,
+ @ApiParam(value = "callback", required = false) @QueryParam(value = "callback") String callback) {
CensusGeographyEnum geographyType = CensusGeographyEnum
.getGeographyTypeWithKey(geography);
CensusLookupResponse apiResponse = new CensusLookupResponse();
@@ -70,7 +79,8 @@ public Response findByCoordinates(@Context UriInfo uriInfo,
handler.handle(apiResponse, ex);
exception = ex;
}
- //APIStatsProfiler.captureStatistics(CENSUS_BY_COORDINATES, apiResponse,uriInfo, true, exception);
+ // APIStatsProfiler.captureStatistics(CENSUS_BY_COORDINATES,
+ // apiResponse,uriInfo, true, exception);
Response response = RestFormatUtil
.format(format, callback, apiResponse);
return response;
Oops, something went wrong.

0 comments on commit 13f2742

Please sign in to comment.