Skip to content

Commit

Permalink
[Fix] fix presets
Browse files Browse the repository at this point in the history
  • Loading branch information
Nicolas Favier committed Dec 15, 2017
1 parent 0651798 commit 0b962bb
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 27 deletions.
4 changes: 1 addition & 3 deletions src/main/java/io/jawg/osmcontributor/rest/OsmBackend.java
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,7 @@ public List<OsmDto> getPoisDtosInBox(final Box box) throws NetworkException {

List<OsmDto> osmDtos = new ArrayList<>();

if (poiTypes == null || poiTypes.isEmpty()) {
poiTypes = poiManager.loadPoiTypes();
}
poiTypes = poiManager.loadPoiTypes();

for (Map.Entry<Long, PoiType> entry : poiTypes.entrySet()) {
final PoiType poiTypeDto = entry.getValue();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@

import com.google.gson.annotations.SerializedName;

import org.joda.time.DateTime;

import java.util.Map;

public class H2GeoPresetsDto {
Expand All @@ -30,7 +28,7 @@ public class H2GeoPresetsDto {
private int revision;

@SerializedName("lastUpdate")
private DateTime lastUpdate;
private String lastUpdate;

@SerializedName("presets")
private Map<String, H2GeoPresetsItemDto> presets;
Expand All @@ -43,11 +41,11 @@ public void setRevision(int revision) {
this.revision = revision;
}

public DateTime getLastUpdate() {
public String getLastUpdate() {
return lastUpdate;
}

public void setLastUpdate(DateTime lastUpdate) {
public void setLastUpdate(String lastUpdate) {
this.lastUpdate = lastUpdate;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,45 +1,58 @@
/**
* Copyright (C) 2016 eBusiness Information
*
* <p>
* This file is part of OSM Contributor.
*
* <p>
* OSM Contributor is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* <p>
* OSM Contributor is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* <p>
* You should have received a copy of the GNU General Public License
* along with OSM Contributor. If not, see <http://www.gnu.org/licenses/>.
*/
package io.jawg.osmcontributor.rest.mappers;

import org.joda.time.DateTime;
import org.joda.time.format.DateTimeFormat;
import org.joda.time.format.DateTimeFormatter;

import javax.inject.Inject;

import io.jawg.osmcontributor.model.entities.H2GeoPresets;
import io.jawg.osmcontributor.rest.dtos.dma.H2GeoPresetsDto;

public class H2GeoPresetsMapper {
H2GeoPresetsItemMapper h2GeoPresetsItemMapper;
private static final DateTimeFormatter formatter = DateTimeFormat.forPattern("yyyy-MM-dd'T'HH:mm:ss.SSSZ");
H2GeoPresetsItemMapper h2GeoPresetsItemMapper;

@Inject
public H2GeoPresetsMapper(H2GeoPresetsItemMapper h2GeoPresetsItemMapper) {
this.h2GeoPresetsItemMapper = h2GeoPresetsItemMapper;
}

@Inject
public H2GeoPresetsMapper(H2GeoPresetsItemMapper h2GeoPresetsItemMapper) {
this.h2GeoPresetsItemMapper = h2GeoPresetsItemMapper;
}
public H2GeoPresets convertToH2GeoPresets(H2GeoPresetsDto h2GeoPresetsDto) {
if (h2GeoPresetsDto == null) {
return null;
}
H2GeoPresets h2GeoPresets = new H2GeoPresets();
h2GeoPresets.setLastUpdate(formatStringToDate(h2GeoPresetsDto.getLastUpdate()));
h2GeoPresets.setPresets(
h2GeoPresetsItemMapper.convertToH2GeoPresetsItem(h2GeoPresetsDto.getPresets()));
h2GeoPresets.setRevision(h2GeoPresetsDto.getRevision());
return h2GeoPresets;
}

public H2GeoPresets convertToH2GeoPresets(H2GeoPresetsDto h2GeoPresetsDto) {
if (h2GeoPresetsDto == null) {
return null;
public static DateTime formatStringToDate(String localDateTimeString) {
if (localDateTimeString != null && !localDateTimeString.isEmpty()) {
return formatter.parseDateTime(localDateTimeString);
} else {
return null;
}
}
H2GeoPresets h2GeoPresets = new H2GeoPresets();
h2GeoPresets.setLastUpdate(h2GeoPresetsDto.getLastUpdate());
h2GeoPresets.setPresets(
h2GeoPresetsItemMapper.convertToH2GeoPresetsItem(h2GeoPresetsDto.getPresets()));
h2GeoPresets.setRevision(h2GeoPresetsDto.getRevision());
return h2GeoPresets;
}
}

0 comments on commit 0b962bb

Please sign in to comment.