Skip to content

Commit

Permalink
Merge branch 'pull/42' into feature-sigmet-model
Browse files Browse the repository at this point in the history
  • Loading branch information
kasarit committed Dec 13, 2019
2 parents 641fb63 + 5dbd4c1 commit b247bdb
Show file tree
Hide file tree
Showing 60 changed files with 2,798 additions and 378 deletions.
21 changes: 4 additions & 17 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<groupId>fi.fmi</groupId>
<artifactId>fmi-os-parent-pom</artifactId>
Expand Down Expand Up @@ -116,21 +117,6 @@
<version>26.0-jre</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.locationtech.jts</groupId>
<artifactId>jts-core</artifactId>
<version>1.15.0</version>
</dependency>
<dependency>
<groupId>org.locationtech.jts.io</groupId>
<artifactId>jts-io-common</artifactId>
<version>1.15.0</version>
</dependency>
<dependency>
<groupId>com.betadriven</groupId>
<artifactId>jackson-datatype-jts</artifactId>
<version>2.6-SNAPSHOT</version>
</dependency>
</dependencies>

<build>
Expand All @@ -141,4 +127,5 @@
</plugin>
</plugins>
</build>
</project>

</project>
11 changes: 9 additions & 2 deletions src/main/java/fi/fmi/avi/converter/ConversionHints.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;

Expand All @@ -17,7 +18,7 @@
* no requirement that a given implementation supports all possible
* choices indicated below or that it can respond to requests to
* modify its functionality.
* <p>
*
* Implementations are free to ignore the hints completely, but should
* try to use an implementation option that is as close as possible
* to the request.
Expand Down Expand Up @@ -282,6 +283,11 @@ public final class ConversionHints implements Map<Object, Object>, Cloneable {
*/
public static final ConversionHints SIGMET;

/**
* A convenience ParsingHints including only the {@link ConversionHints#KEY_MESSAGE_TYPE} with value {@link ConversionHints#VALUE_MESSAGE_TYPE_AIRMET}
*/
public static final ConversionHints AIRMET;

/**
* A convenience ParsingHints including only the {@link ConversionHints#KEY_MESSAGE_TYPE} with value {@link MessageType#SPECIAL_AIR_REPORT}.
*/
Expand Down Expand Up @@ -349,6 +355,7 @@ public String toString() {
TAF = new ConversionHints(KEY_MESSAGE_TYPE, MessageType.TAF);
SPECI = new ConversionHints(KEY_MESSAGE_TYPE, MessageType.SPECI);
SIGMET = new ConversionHints(KEY_MESSAGE_TYPE, MessageType.SIGMET);
AIRMET = new ConversionHints(KEY_MESSAGE_TYPE, MessageType.AIRMET);
SPECIAL_AIR_REPORT = new ConversionHints(KEY_MESSAGE_TYPE, MessageType.SPECIAL_AIR_REPORT);

STRICT_PARSING = new ConversionHints(KEY_PARSING_MODE, VALUE_PARSING_MODE_STRICT);
Expand All @@ -367,7 +374,7 @@ public ConversionHints() {
this(null, true);
}

/**
/** SIGMET = new ConversionHints(KEY_MESSAGE_TYPE, MessageType.SIGMET);
* Creates ConversionHints with controlled modifiability.
*
* @param modifiable set true to create a modifiable hints instance
Expand Down
25 changes: 25 additions & 0 deletions src/main/java/fi/fmi/avi/converter/json/AIRMETJSONParser.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package fi.fmi.avi.converter.json;

import fi.fmi.avi.converter.AviMessageSpecificConverter;
import fi.fmi.avi.converter.ConversionHints;
import fi.fmi.avi.converter.ConversionResult;
import fi.fmi.avi.model.sigmet.AIRMET;
import fi.fmi.avi.model.sigmet.immutable.AIRMETImpl;

/**
* A simple wrapper to specialize {@link AbstractJSONParser} for SIGMET.
*/
public class AIRMETJSONParser extends AbstractJSONParser implements AviMessageSpecificConverter<String, AIRMET> {

/**
* Converts a JSON TAF message into TAF Object.
*
* @param input input message
* @param hints parsing hints
* @return the {@link ConversionResult} with the converter message and the possible conversion issues
*/
@Override
public ConversionResult<AIRMET> convertMessage(String input, ConversionHints hints) {
return doConvertMessage(input, AIRMET.class, AIRMETImpl.class, hints);
}
}
24 changes: 24 additions & 0 deletions src/main/java/fi/fmi/avi/converter/json/AIRMETJSONSerializer.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package fi.fmi.avi.converter.json;

import fi.fmi.avi.converter.AviMessageSpecificConverter;
import fi.fmi.avi.converter.ConversionHints;
import fi.fmi.avi.converter.ConversionResult;
import fi.fmi.avi.model.sigmet.AIRMET;

/**
* A simple wrapper to specialize {@link AbstractJSONSerializer} for SIGMET.
*/
public class AIRMETJSONSerializer extends AbstractJSONSerializer implements AviMessageSpecificConverter<AIRMET, String> {

/**
* Converts a SIGMET object into JSON.
*
* @param input input message
* @param hints parsing hints
* @return the {@link ConversionResult} with the converter message and the possible conversion issues
*/
@Override
public ConversionResult<String> convertMessage(AIRMET input, ConversionHints hints) {
return doConvertMessage(input, hints);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import java.io.IOException;

import com.bedatadriven.jackson.datatype.jts.JtsModule;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.datatype.jdk8.Jdk8Module;
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
Expand Down Expand Up @@ -41,12 +40,11 @@ protected <T extends AviationWeatherMessageOrCollection> ConversionResult<T> doC
final ObjectMapper om = new ObjectMapper();
om.registerModule(new Jdk8Module());
om.registerModule(new JavaTimeModule());
om.registerModule(new JtsModule());
try {
final Object o = om.readValue(input, implClz);
result.setConvertedMessage((T) o);
result.setStatus(ConversionResult.Status.SUCCESS);
} catch (final IOException e) {
} catch (final Exception e) {
result.addIssue(new ConversionIssue(ConversionIssue.Severity.ERROR, ConversionIssue.Type.OTHER, "Error parsing JSON", e));
result.setStatus(ConversionResult.Status.FAIL);
}
Expand Down
13 changes: 5 additions & 8 deletions src/main/java/fi/fmi/avi/converter/json/SIGMETJSONParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,19 @@
import fi.fmi.avi.model.sigmet.immutable.SIGMETImpl;

/**
* A simple wrapper to specialize {@link AbstractJSONParser} for TAF.
* A simple wrapper to specialize {@link AbstractJSONParser} for SIGMET.
*/
public class SIGMETJSONParser extends AbstractJSONParser implements AviMessageSpecificConverter<String, SIGMET> {

/**
* Converts a JSON SIGMET message into SIGMET Object.
*
* @param input
* input message
* @param hints
* parsing hints
* Converts a JSON TAF message into TAF Object.
*
* @param input input message
* @param hints parsing hints
* @return the {@link ConversionResult} with the converter message and the possible conversion issues
*/
@Override
public ConversionResult<SIGMET> convertMessage(final String input, final ConversionHints hints) {
public ConversionResult<SIGMET> convertMessage(String input, ConversionHints hints) {
return doConvertMessage(input, SIGMET.class, SIGMETImpl.class, hints);
}
}
21 changes: 21 additions & 0 deletions src/main/java/fi/fmi/avi/converter/json/conf/JSONConverter.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package fi.fmi.avi.converter.json.conf;

import fi.fmi.avi.converter.json.*;
import fi.fmi.avi.model.sigmet.AIRMET;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

Expand Down Expand Up @@ -49,6 +51,12 @@ public class JSONConverter {
public static final ConversionSpecification<SIGMET, String> SIGMET_POJO_TO_JSON_STRING = new ConversionSpecification<>(SIGMET.class, String.class,
null, "SIGMET, fmi-avi-messageconverter JSON");

/**
* Pre-configured spec for {@link AIRMET} to IWXXM 2.1 XML format AIRMET document String.
*/
public static final ConversionSpecification<AIRMET, String> AIRMET_POJO_TO_JSON_STRING = new ConversionSpecification<>(AIRMET.class, String.class,
null, "SIGMET, fmi-avi-messageconverter JSON");

/**
* Pre-configured spec for {@link TAFBulletin} to fmi-avi-messageconverter JSON TAFBulletin document String.
*/
Expand Down Expand Up @@ -99,6 +107,11 @@ public class JSONConverter {
*/
public static final ConversionSpecification<String, SIGMETBulletin> JSON_STRING_TO_SIGMET_BULLETIN_POJO = new ConversionSpecification<>(String.class,
SIGMETBulletin.class, "SIGMETBulletin, fmi-avi-messageconverter JSON", null);
/**
* Pre-configured spec for IWXXM 2.1 XML format AIRMET document DOM Node to {@link AIRMET}
*/
public static final ConversionSpecification<String, AIRMET> JSON_STRING_TO_AIRMET_POJO = new ConversionSpecification<>(String.class, AIRMET.class,
"AIRMET, fmi-avi-messageconverter JSON", null);


/**
Expand Down Expand Up @@ -153,6 +166,9 @@ public AviMessageSpecificConverter<String, SIGMET> sigmetJSONParser() {
return new SIGMETJSONParser();
}

@Bean
public AviMessageSpecificConverter<String, AIRMET> airmetJSONParser() {return new AIRMETJSONParser();}

@Bean
public AviMessageSpecificConverter<String, TAFBulletin> tafBulletinJSONParser() {
return new TAFBulletinJSONParser();
Expand All @@ -169,4 +185,9 @@ public AviMessageSpecificConverter<String, GenericMeteorologicalBulletin> generi
}


@Bean(name = "airmetJSONSerializer")
public AviMessageSpecificConverter<AIRMET, String> airmetJSONSerializer() {
return new AIRMETJSONSerializer();
}

}
16 changes: 16 additions & 0 deletions src/main/java/fi/fmi/avi/model/Airspace.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package fi.fmi.avi.model;

import java.util.Optional;

public interface Airspace {
public enum AirspaceType {
FIR,
UIR,
FIR_UIR,
CTA
}
AirspaceType getType();
Optional<Integer> getPart();
String getName();
String getDesignator();
}
Loading

0 comments on commit b247bdb

Please sign in to comment.