Skip to content

Commit

Permalink
Merge pull request #9 from mapcode-foundation/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
rijnb committed Jul 3, 2015
2 parents 646fcb5 + 03c1903 commit b975470
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 56 deletions.
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,15 @@ There's also an example HTML page in the `examples/index.html` for HTML/Javascri

## Release Notes

* 2.0.0.0

Based version 2.0.0 of the Java library.

Includes fixes and enhancements to data. For a complete description, read the Word file that ships with
the C version of the library (on Github).

This version no longer supports numeric codes for territories and alphabets.

* 1.50.3.0

Changed property names in REST API for territories: `code` is renamed to `number`, `name` is renamed to `alphaCode`.
Expand Down
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<artifactId>mapcode-rest-service</artifactId>

<packaging>war</packaging>
<version>1.50.3.0</version>
<version>2.0.0.0</version>

<name>Mapcode REST API Web Service</name>
<description>
Expand Down Expand Up @@ -87,7 +87,7 @@
<resteasy.version>3.0.11.Final</resteasy.version>
<slf4j.version>1.7.2</slf4j.version>

<mapcode.version>1.50.3</mapcode.version>
<mapcode.version>2.0.0</mapcode.version>
<speedtools.version>3.0.9</speedtools.version>

<maven-compiler-plugin.version>3.2</maven-compiler-plugin.version>
Expand Down
21 changes: 1 addition & 20 deletions src/main/java/com/mapcode/services/dto/AlphabetDTO.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.mapcode.Alphabet;
import com.tomtom.speedtools.apivalidation.ApiDTO;
import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;
Expand All @@ -34,21 +33,15 @@ public final class AlphabetDTO extends ApiDTO {
@Nonnull
private String name;

@Nonnull
private Integer number;

@Override
public void validate() {
validator().start();
validator().checkNotNull(true, "name", name);
validator().checkInteger(true, "numer", number, 0, Alphabet.values().length - 1);
validator().done();
}

public AlphabetDTO(@Nonnull final String name,
@Nonnull final Integer number) {
public AlphabetDTO(@Nonnull final String name) {
this.name = name;
this.number = number;
}

@SuppressWarnings("UnusedDeclaration")
Expand All @@ -70,18 +63,6 @@ public void setName(@Nonnull final String name) {
this.name = name;
}

@Nonnull
public Integer getNumber() {
beforeGet();
return number;
}

public void setNumber(@Nonnull final Integer number) {
beforeSet();
assert number != null;
this.number = number;
}

@Override
@Nonnull
public String toString() {
Expand Down
19 changes: 0 additions & 19 deletions src/main/java/com/mapcode/services/dto/TerritoryDTO.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.mapcode.Territory;
import com.mapcode.services.ApiConstants;
import com.tomtom.speedtools.apivalidation.ApiDTO;
import org.apache.commons.lang3.builder.EqualsBuilder;
Expand All @@ -41,9 +40,6 @@ public final class TerritoryDTO extends ApiDTO {
@Nonnull
private String alphaCodeMinimal;

@Nonnull
private Integer number;

@Nonnull
private String fullName;

Expand All @@ -62,7 +58,6 @@ public void validate() {
validator().checkNotNull(true, "alphaCode", alphaCode);
validator().checkNotNull(true, "alphaCodeMinimalUnambiguous", alphaCodeMinimalUnambiguous);
validator().checkNotNull(true, "alphaCodeMinimal", alphaCodeMinimal);
validator().checkInteger(true, "number", number, 0, Territory.values().length - 1);
validator().checkString(true, "fullName", fullName, ApiConstants.API_NAME_LEN_MIN, ApiConstants.API_NAME_LEN_MAX);
validator().checkString(false, "parentTerritory", parentTerritory, ApiConstants.API_NAME_LEN_MIN, ApiConstants.API_NAME_LEN_MAX);
validator().checkNotNull(false, "aliases", aliases);
Expand All @@ -73,15 +68,13 @@ public void validate() {
public TerritoryDTO(@Nonnull final String alphaCode,
@Nonnull final String alphaCodeMinimalUnambiguous,
@Nonnull final String alphaCodeMinimal,
@Nonnull final Integer number,
@Nonnull final String fullName,
@Nullable final String parentTerritory,
@Nonnull final String[] aliases,
@Nonnull final String[] fullNameAliases) {
this.alphaCode = alphaCode;
this.alphaCodeMinimalUnambiguous = alphaCodeMinimalUnambiguous;
this.alphaCodeMinimal = alphaCodeMinimal;
this.number = number;
this.fullName = fullName;
this.parentTerritory = parentTerritory;
this.aliases = aliases;
Expand Down Expand Up @@ -131,18 +124,6 @@ public void setAlphaCodeMinimal(@Nonnull final String alphaCodeMinimal) {
this.alphaCodeMinimal = alphaCodeMinimal;
}

@Nonnull
public Integer getNumber() {
beforeGet();
return number;
}

public void setNumber(@Nonnull final Integer number) {
beforeSet();
assert number != null;
this.number = number;
}

@Nonnull
public String getFullName() {
beforeGet();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ public class MapcodeResourceImpl implements MapcodeResource {
private final SystemMetricsCollector metricsCollector;

private static final String API_ERROR_VALID_TERRITORY_CODES = Joiner.on('|').join(Arrays.asList(Territory.values()).stream().
map(x -> (x.toString() + '(' + x.getNumber() + ')')).collect(Collectors.toList()));
map(x -> (x.toString())).collect(Collectors.toList()));
private static final String API_ERROR_VALID_ALPHABET_CODES = Joiner.on('|').join(Arrays.asList(Alphabet.values()).stream().
map(x -> (x.toString() + '(' + x.getNumber() + ')')).collect(Collectors.toList()));
map(x -> (x.toString())).collect(Collectors.toList()));
private static final String API_ERROR_VALID_TYPES = Joiner.on('|').join(Arrays.asList(ParamType.values()).stream().
map(x -> x).collect(Collectors.toList()));
private static final String API_ERROR_VALID_INCLUDES = Joiner.on('|').join(Arrays.asList(ParamInclude.values()).stream().
Expand All @@ -74,15 +74,14 @@ public class MapcodeResourceImpl implements MapcodeResource {
x.toString(),
x.toAlphaCode(AlphaCodeFormat.MINIMAL_UNAMBIGUOUS),
x.toAlphaCode(AlphaCodeFormat.MINIMAL),
x.getNumber(),
x.getFullName(),
(parentTerritory == null) ? null : parentTerritory.toString(),
x.getAliases(),
x.getFullNameAliases());
}).
collect(Collectors.toList());
private static final List<AlphabetDTO> ALL_ALPHABET_DTO = Arrays.asList(Alphabet.values()).stream().
map(x -> new AlphabetDTO(x.name(), x.getNumber())).
map(x -> new AlphabetDTO(x.name())).
collect(Collectors.toList());


Expand Down Expand Up @@ -436,7 +435,6 @@ public void getTerritory(
territory.toString(),
territory.toAlphaCode(AlphaCodeFormat.MINIMAL_UNAMBIGUOUS),
territory.toAlphaCode(AlphaCodeFormat.MINIMAL),
territory.getNumber(),
territory.getFullName(),
(parentTerritory == null) ? null : parentTerritory.toString(),
territory.getAliases(),
Expand Down Expand Up @@ -502,7 +500,7 @@ public void getAlphabet(
}

// Return the right territory information.
final AlphabetDTO result = new AlphabetDTO(alphabet.name(), alphabet.getNumber());
final AlphabetDTO result = new AlphabetDTO(alphabet.name());

// Validate the result (internal consistency check).
result.validate();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,6 @@ public class RootResourceImpl implements RootResource {

@Nonnull
private static final String HELP_TEXT = "" +
"MAPCODE API\n" +
"-----------\n\n" +

"GET /mapcode Returns this help page.\n" +
"GET /mapcode/version Returns the software version.\n" +
"GET /mapcode/metrics Returns some system metrics (also available from JMX).\n" +
Expand All @@ -64,8 +61,8 @@ public class RootResourceImpl implements RootResource {

" Query parameters:\n" +
" precision : Precision, range [0, 2] (default=0).\n" +
" territory : Territory to restrict results to, numeric or alpha code.\n" +
" alphabet : Alphabet to return results in, numeric or alpha code.\n\n" +
" territory : Territory to restrict results to.\n" +
" alphabet : Alphabet to return results in.\n\n" +

" include : Multiple options may be set, separated by comma's:\n" +
" offset = Include offset from mapcode center to lat/lon (in meters).\n" +
Expand All @@ -83,7 +80,7 @@ public class RootResourceImpl implements RootResource {
" code : Mapcode code (local or international).\n" +

" Query parameters:\n" +
" context : Optional mapcode territory context, numeric or alpha code.\n\n" +
" context : Optional mapcode territory context.\n\n" +

"GET /mapcode/territories [?offset={offset}&count={count}]\n" +
" Return a list of all territories.\n\n" +
Expand All @@ -92,7 +89,7 @@ public class RootResourceImpl implements RootResource {
" Return information for a single territory code.\n\n" +

" Path parameters:\n" +
" territory : Territory to get info for, numeric or alpha code.\n\n" +
" territory : Territory to get info for.\n\n" +

" Query parameters:\n" +
" context : Territory context (optional, for disambiguation).\n\n" +
Expand All @@ -104,7 +101,7 @@ public class RootResourceImpl implements RootResource {
" Return information for a specific alphabet.\n\n" +

" Path parameters:\n" +
" alphabet : Alphabet to get info for, numeric or alpha code.\n\n" +
" alphabet : Alphabet to get info for.\n\n" +

"General query parameters for methods which return a list of results:\n\n" +
" offset : Return list from 'offset' (negative value start counting from end).\n" +
Expand All @@ -129,7 +126,10 @@ public RootResourceImpl(
@Nonnull
public String getHelpHTML() {
LOG.info("getHelpHTML: show help page", mavenProperties.getPomVersion());
return "<html><pre>\n" + HELP_TEXT + "</pre></html>\n";
return "<html><pre>\n" +
"MAPCODE API (" + mavenProperties.getPomVersion() + ")\n" +
"-----------\n\n" +
HELP_TEXT + "</pre></html>\n";
}

@Override
Expand Down

0 comments on commit b975470

Please sign in to comment.