Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1854752d92 | ||
|
|
7b85810c29 | ||
|
|
5ff779aee4 | ||
|
|
a7c4480464 | ||
|
|
96a266c728 | ||
|
|
99e4b284bb | ||
|
|
25a810df05 | ||
|
|
66bed8c89f | ||
|
|
07e85b6f32 | ||
|
|
50c17ab504 | ||
|
|
735fc4191a | ||
|
|
1a8d471b3f | ||
|
|
3885c13007 | ||
|
|
d01cbd2d81 | ||
|
|
096d960c76 | ||
|
|
b681b0fa11 | ||
|
|
42a1e4b530 | ||
|
|
1eec320528 | ||
|
|
3efa42facb | ||
|
|
f2ba86687a | ||
|
|
92873bed80 | ||
|
|
cfaab5263e | ||
|
|
b083863b08 | ||
|
|
9e5b70fe70 | ||
|
|
5d5f1b7f1c | ||
|
|
aae820834b | ||
|
|
2635ee890d | ||
|
|
136b969add | ||
|
|
54a455ea24 | ||
|
|
9f938ef016 | ||
|
|
8a924840dd | ||
|
|
a5cfabbfd2 | ||
|
|
89487dd6ec | ||
|
|
fb8518fcb0 | ||
|
|
31e7af3097 | ||
|
|
373748cb9c | ||
|
|
1827b964ed | ||
|
|
b1e144df73 | ||
|
|
6bdc8fe3ea | ||
|
|
018287ee6b | ||
|
|
49d6925da8 | ||
|
|
0932fdd0b8 | ||
|
|
094f98b46b | ||
|
|
968d827fc2 | ||
|
|
82bd2fc466 | ||
|
|
9ca8a38360 | ||
|
|
ddef7184b8 | ||
|
|
91238440f7 | ||
|
|
9cb8bfe2f0 | ||
|
|
5f8cca15fa | ||
|
|
128c01e68d | ||
|
|
0f42047f50 | ||
|
|
2f58a3d287 | ||
|
|
b0252b1676 | ||
|
|
da424dc70b | ||
|
|
348462a10c | ||
|
|
b4cc029716 | ||
|
|
9fef73eb7a | ||
|
|
cc0f95af91 | ||
|
|
1d6e0cc64c | ||
|
|
bd838657e4 | ||
|
|
af9f3f63fe | ||
|
|
9b5ee375b9 | ||
|
|
149de17617 | ||
|
|
fc9c0e7b55 | ||
|
|
9094db9df9 | ||
|
|
1ce515ed9f | ||
|
|
ee26a8180b | ||
|
|
85a250bcf4 | ||
|
|
6bfc0c8de0 | ||
|
|
ef5ea9391d | ||
|
|
ee5435ae3d | ||
|
|
c5c711a28a | ||
|
|
0087b6263c | ||
|
|
0c8607112c | ||
|
|
073bc0bb94 | ||
|
|
002589e54d | ||
|
|
11ee74fa2e | ||
|
|
6f9a22c517 | ||
|
|
de7da597a4 | ||
|
|
2e8871d22e | ||
|
|
eb60289066 | ||
|
|
687eb76d4f | ||
|
|
57ee5e1748 | ||
|
|
8f7d88bcdd | ||
|
|
3544e31198 | ||
|
|
9ee69a56ac | ||
|
|
63b23ef902 | ||
|
|
fa88d592cb | ||
|
|
9a06bb2630 | ||
|
|
f18dbb57bd | ||
|
|
d3e56e9e0f | ||
|
|
2e5d06d9af |
Vendored
+11
-9
@@ -5,7 +5,7 @@ node {
|
||||
|
||||
// set environment variables
|
||||
env.ANDROID_SDK_ROOT = '/var/lib/android-sdk'
|
||||
env.JAVA_HOME = '/opt/openjdk-bin-11'
|
||||
env.JAVA_HOME = '/opt/openjdk-bin-17'
|
||||
env.PATH = "${env.JAVA_HOME}/bin:${env.PATH}"
|
||||
|
||||
// checkout code from scm
|
||||
@@ -26,7 +26,7 @@ node {
|
||||
// build the source code with gradle
|
||||
stage('Build') {
|
||||
withCredentials([string(credentialsId: 'mowesta-keystore-password', variable: 'PASSWD')]) {
|
||||
sh(script: './gradlew -Djenkins.build.number=' + env.BUILD_NUMBER + ' -Dandroid.keystore.password=$PASSWD clean build', label: "Building project.")
|
||||
sh(script: './gradlew -Djenkins.build.number=' + env.BUILD_NUMBER + ' -Dandroid.keystore.password=$PASSWD clean build -x test', label: "Building project.")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,19 +45,21 @@ node {
|
||||
|
||||
// deploy the build output on the server
|
||||
stage ('Deploy') {
|
||||
// release = true; // uncomment to temporary enable snapshot deployments
|
||||
// release = true; // uncomment to temporary enable snapshot deployments
|
||||
if (env.BRANCH_NAME == "master" && release) {
|
||||
echo "Deploying to production server ..."
|
||||
withCredentials([sshUserPrivateKey(credentialsId: "mowesta-server-key", keyFileVariable: "KEYFILE")]) {
|
||||
// sh 'scp -i $KEYFILE site-ear/build/libs/site-ear-' + version + '.ear wildfly@apps-pro.nes.uni-due.de:/opt/wildfly-21-mowesta/standalone/deployments/mowesta.ear'
|
||||
sh 'scp -i $KEYFILE android-app/build/outputs/apk/prod/release/*.apk wildfly@apps-pro.nes.uni-due.de:/opt/android/mowesta/'
|
||||
sh 'scp -i $KEYFILE android-app/build/outputs/bundle/prodRelease/*.aab wildfly@apps-pro.nes.uni-due.de:/opt/android/mowesta/'
|
||||
sh 'scp -i $KEYFILE service-war/build/libs/service-war-' + version + '.war wildfly@apps-pro.nes.uni-due.de:/opt/wildfly-31-mowesta/standalone/deployments/service-war.war'
|
||||
sh 'scp -i $KEYFILE web-war/build/libs/web-war-' + version + '.war wildfly@apps-pro.nes.uni-due.de:/opt/wildfly-31-mowesta/standalone/deployments/web-war.war'
|
||||
// sh 'scp -i $KEYFILE android-app/build/outputs/apk/prod/release/*.apk wildfly@apps-pro.nes.uni-due.de:/opt/android/mowesta/'
|
||||
// sh 'scp -i $KEYFILE android-app/build/outputs/bundle/prodRelease/*.aab wildfly@apps-pro.nes.uni-due.de:/opt/android/mowesta/'
|
||||
}
|
||||
} else if (env.BRANCH_NAME == "master") {
|
||||
/* echo "Deploying to beta server ..."
|
||||
echo "Deploying to beta server ..."
|
||||
withCredentials([sshUserPrivateKey(credentialsId: "mowesta-server-key", keyFileVariable: "KEYFILE")]) {
|
||||
sh 'scp -i $KEYFILE site-ear/build/libs/site-ear-' + version + '.ear wildfly@apps-dev.nes.uni-due.de:/opt/wildfly-21-beta/standalone/deployments/mowesta.ear'
|
||||
} */
|
||||
sh 'scp -i $KEYFILE service-war/build/libs/service-war-' + version + '.war mowesta@apps-dev.nes.uni-due.de:/home/mowesta/wildfly/standalone/deployments/service-war.war'
|
||||
sh 'scp -i $KEYFILE web-war/build/libs/web-war-' + version + '.war mowesta@apps-dev.nes.uni-due.de:/home/mowesta/wildfly/standalone/deployments/web-war.war'
|
||||
}
|
||||
} else {
|
||||
echo "Skipping deployment for non-master branch."
|
||||
}
|
||||
|
||||
@@ -14,3 +14,10 @@ To build the project, you will have to install [Java](http://www.oracle.com/tech
|
||||
|
||||
Pull requests and new commits to any branch are automatically built by a Jenkins service. A Gitea webhook informs the service about changes to the repository. In addition, the service will automatically scan the lbs Gitea organization for new repositories every hour. Successful builds of new commits are indicated by a green tick on the commit page. The build status of pull requests is currently not shown in Gitea. However, you can go to the [Jenkins](https://project.nes.uni-due.de/jenkins/job/LocationBasedServices/job/mowesta/) service to view the result of builds including the console output. To modify the build process, you can change the Jenkinsfile groovy script in the root of the repository, if necessary.
|
||||
|
||||
# Configuration
|
||||
|
||||
The MoWeSta backend uses a number of system properties to configure the location of input and output folders, the base url of videos and the forecast downlods. You can set them when starting wildfly by passing a ```-DpropretyName=propertyValue``` switch to the standalone.sh. The configurations are:
|
||||
|
||||
- *baseDirectory*: Defines where the input and output folders are placed. Default is working directory.
|
||||
- *limitedMode*: Defines whether to limit the forecast download to cosmo europe. Default is false.
|
||||
- *videoUrl*: Define the url to prefix the file names with. Default is https://www.mowesta.com/data/video.
|
||||
|
||||
+48
-30
@@ -1,45 +1,63 @@
|
||||
plugins {
|
||||
id 'org.hidetake.swagger.generator' version '2.18.2'
|
||||
id 'org.openapi.generator' version '6.0.0'
|
||||
}
|
||||
|
||||
description = "MoWeSta Android Api"
|
||||
|
||||
// downgrade jackson for Android, since versions > 2.9
|
||||
// will contain module-info.class files that will result
|
||||
// in a large number of android lint warnings
|
||||
versionJackson = "2.9.10"
|
||||
ext {
|
||||
swagger_annotations_version = "1.5.24"
|
||||
jackson_version = "2.10.3"
|
||||
jackson_databind_version = "2.10.3"
|
||||
jackson_databind_nullable_version = "0.2.2"
|
||||
jakarta_annotation_version = "1.3.5"
|
||||
feign_version = "10.11"
|
||||
feign_form_version = "3.8.0"
|
||||
junit_version = "5.7.0"
|
||||
scribejava_version = "8.0.0"
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation "io.swagger:swagger-annotations:$swagger_annotations_version"
|
||||
implementation "com.google.code.findbugs:jsr305:3.0.2"
|
||||
api "io.github.openfeign:feign-core:$feign_version"
|
||||
implementation "io.github.openfeign:feign-jackson:$feign_version"
|
||||
implementation "io.github.openfeign:feign-slf4j:$feign_version"
|
||||
implementation "io.github.openfeign:feign-okhttp:$feign_version"
|
||||
implementation "io.github.openfeign.form:feign-form:$feign_form_version"
|
||||
api "com.fasterxml.jackson.core:jackson-core:$jackson_version"
|
||||
api "com.fasterxml.jackson.core:jackson-annotations:$jackson_version"
|
||||
api "com.fasterxml.jackson.core:jackson-databind:$jackson_databind_version"
|
||||
implementation "org.openapitools:jackson-databind-nullable:$jackson_databind_nullable_version"
|
||||
implementation "com.fasterxml.jackson.datatype:jackson-datatype-jsr310:$jackson_version"
|
||||
implementation "com.github.scribejava:scribejava-core:$scribejava_version"
|
||||
implementation "jakarta.annotation:jakarta.annotation-api:$jakarta_annotation_version"
|
||||
api "de.grundid.opendatalab:geojson-jackson:${versionGeojson}"
|
||||
api "io.swagger:swagger-annotations:${versionSwagger}"
|
||||
api "com.fasterxml.jackson.core:jackson-core:${versionJackson}"
|
||||
api "com.fasterxml.jackson.core:jackson-annotations:${versionJackson}"
|
||||
api "com.fasterxml.jackson.core:jackson-databind:${versionJackson}"
|
||||
api "com.fasterxml.jackson.datatype:jackson-datatype-joda:${versionJackson}"
|
||||
api "javax.annotation:javax.annotation-api:${versionAnnotation}"
|
||||
api "io.github.openfeign:feign-core:9.4.0"
|
||||
api "io.github.openfeign:feign-jackson:9.4.0"
|
||||
compileOnly "org.apache.oltu.oauth2:org.apache.oltu.oauth2.client:1.0.1"
|
||||
swaggerCodegen 'io.swagger:swagger-codegen-cli:2.4.9'
|
||||
}
|
||||
|
||||
sourceSets.main.java.srcDirs = ['src/main/java', 'build/swagger/src/main/java']
|
||||
|
||||
swaggerSources {
|
||||
mowesta {
|
||||
inputFile = file(project(':common-api:').buildDir.path + '/swagger/mowesta.json')
|
||||
code {
|
||||
outputDir = file("${project.buildDir}/swagger")
|
||||
language = 'java'
|
||||
configFile = file('config.json')
|
||||
components = [ models: true, apis: 'Default']
|
||||
rawOptions = [ '--import-mappings', 'Geometry=org.geojson.Geometry']
|
||||
}
|
||||
}
|
||||
compileJava {
|
||||
dependsOn 'generateClient'
|
||||
}
|
||||
|
||||
task generateClient(type: org.openapitools.generator.gradle.plugin.tasks.GenerateTask) {
|
||||
dependsOn ':service-api:resolve'
|
||||
generatorName = "java"
|
||||
inputSpec = "$projectDir/../service-api/build/swagger/mowesta.json"
|
||||
outputDir = "$projectDir/build/swagger/"
|
||||
typeMappings.putAll(["Geometry":"org.geojson.Geometry"])
|
||||
generateModelTests = false
|
||||
generateModelDocumentation = false
|
||||
generateApiTests = false
|
||||
generateApiDocumentation = false
|
||||
configOptions = [
|
||||
invokerPackage: 'com.mowesta.android.feign',
|
||||
modelPackage: 'com.mowesta.android.feign.model',
|
||||
apiPackage: 'com.mowesta.android.feign.api',
|
||||
library: "feign",
|
||||
dateLibrary: "java8",
|
||||
importMappings: 'Geometry=org.geojson.Geometry',
|
||||
annotationLibrary: "none"
|
||||
]
|
||||
}
|
||||
|
||||
// require api build to access swagger definition
|
||||
tasks['resolveSwaggerTemplate'].dependsOn(project(':common-api').tasks['build'])
|
||||
// require swagger code gen before compilation
|
||||
compileJava.dependsOn('generateSwaggerCode')
|
||||
|
||||
@@ -1,325 +0,0 @@
|
||||
package com.mowesta.android.feign;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.oltu.oauth2.client.request.OAuthClientRequest.AuthenticationRequestBuilder;
|
||||
import org.apache.oltu.oauth2.client.request.OAuthClientRequest.TokenRequestBuilder;
|
||||
|
||||
import com.fasterxml.jackson.databind.DeserializationFeature;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.SerializationFeature;
|
||||
import com.fasterxml.jackson.datatype.joda.JodaModule;
|
||||
import com.mowesta.android.feign.auth.*;
|
||||
import com.mowesta.android.feign.auth.OAuth.AccessTokenListener;
|
||||
|
||||
import feign.Feign;
|
||||
import feign.RequestInterceptor;
|
||||
import feign.jackson.JacksonDecoder;
|
||||
import feign.jackson.JacksonEncoder;
|
||||
|
||||
@javax.annotation.Generated(value = "io.swagger.codegen.languages.JavaClientCodegen", date = "2017-10-20T17:10:12.901+02:00")
|
||||
public class ApiClient {
|
||||
public interface Api {}
|
||||
|
||||
protected ObjectMapper objectMapper;
|
||||
private String basePath = "https://www.mowesta.com/api";
|
||||
private Map<String, RequestInterceptor> apiAuthorizations;
|
||||
private Feign.Builder feignBuilder;
|
||||
|
||||
public ApiClient() {
|
||||
objectMapper = createObjectMapper();
|
||||
apiAuthorizations = new LinkedHashMap<String, RequestInterceptor>();
|
||||
feignBuilder = Feign.builder()
|
||||
.requestInterceptor(request -> {
|
||||
Map<String, Collection<String>> headers = request.request().headers();
|
||||
if (!headers.containsKey("Content-Type" ) && request.method().equals("DELETE") ) {
|
||||
request.header("Content-Type", "application/json");
|
||||
}
|
||||
})
|
||||
.encoder(new JacksonEncoder(objectMapper))
|
||||
.decoder(new JacksonDecoder(objectMapper));
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public ApiClient(String[] authNames) {
|
||||
this();
|
||||
for(String authName : authNames) {
|
||||
throw new RuntimeException("auth name \"" + authName + "\" not found in available auth names");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Basic constructor for single auth name
|
||||
* @param authName
|
||||
*/
|
||||
public ApiClient(String authName) {
|
||||
this(new String[]{authName});
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper constructor for single api key
|
||||
* @param authName
|
||||
* @param apiKey
|
||||
*/
|
||||
public ApiClient(String authName, String apiKey) {
|
||||
this(authName);
|
||||
this.setApiKey(apiKey);
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper constructor for single basic auth or password oauth2
|
||||
* @param authName
|
||||
* @param username
|
||||
* @param password
|
||||
*/
|
||||
public ApiClient(String authName, String username, String password) {
|
||||
this(authName);
|
||||
this.setCredentials(username, password);
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper constructor for single password oauth2
|
||||
* @param authName
|
||||
* @param clientId
|
||||
* @param secret
|
||||
* @param username
|
||||
* @param password
|
||||
*/
|
||||
public ApiClient(String authName, String clientId, String secret, String username, String password) {
|
||||
this(authName);
|
||||
this.getTokenEndPoint()
|
||||
.setClientId(clientId)
|
||||
.setClientSecret(secret)
|
||||
.setUsername(username)
|
||||
.setPassword(password);
|
||||
}
|
||||
|
||||
public String getBasePath() {
|
||||
return basePath;
|
||||
}
|
||||
|
||||
public ApiClient setBasePath(String basePath) {
|
||||
this.basePath = basePath;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Map<String, RequestInterceptor> getApiAuthorizations() {
|
||||
return apiAuthorizations;
|
||||
}
|
||||
|
||||
public void setApiAuthorizations(Map<String, RequestInterceptor> apiAuthorizations) {
|
||||
this.apiAuthorizations = apiAuthorizations;
|
||||
}
|
||||
|
||||
public Feign.Builder getFeignBuilder() {
|
||||
return feignBuilder;
|
||||
}
|
||||
|
||||
public ApiClient setFeignBuilder(Feign.Builder feignBuilder) {
|
||||
this.feignBuilder = feignBuilder;
|
||||
return this;
|
||||
}
|
||||
|
||||
private ObjectMapper createObjectMapper() {
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
objectMapper.enable(SerializationFeature.WRITE_ENUMS_USING_TO_STRING);
|
||||
objectMapper.enable(DeserializationFeature.READ_ENUMS_USING_TO_STRING);
|
||||
objectMapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
|
||||
objectMapper.disable(DeserializationFeature.FAIL_ON_INVALID_SUBTYPE);
|
||||
objectMapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
|
||||
objectMapper.registerModule(new JodaModule());
|
||||
return objectMapper;
|
||||
}
|
||||
|
||||
public ObjectMapper getObjectMapper(){
|
||||
return objectMapper;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a feign client for given API interface.
|
||||
*
|
||||
* Usage:
|
||||
* ApiClient apiClient = new ApiClient();
|
||||
* apiClient.setBasePath("http://localhost:8080");
|
||||
* XYZApi api = apiClient.buildClient(XYZApi.class);
|
||||
* XYZResponse response = api.someMethod(...);
|
||||
* @param <T> Type
|
||||
* @param clientClass Client class
|
||||
* @return The Client
|
||||
*/
|
||||
public <T extends Api> T buildClient(Class<T> clientClass) {
|
||||
return feignBuilder.target(clientClass, basePath);
|
||||
}
|
||||
|
||||
/**
|
||||
* Select the Accept header's value from the given accepts array:
|
||||
* if JSON exists in the given array, use it;
|
||||
* otherwise use all of them (joining into a string)
|
||||
*
|
||||
* @param accepts The accepts array to select from
|
||||
* @return The Accept header to use. If the given array is empty,
|
||||
* null will be returned (not to set the Accept header explicitly).
|
||||
*/
|
||||
public String selectHeaderAccept(String[] accepts) {
|
||||
if (accepts.length == 0) return null;
|
||||
if (StringUtil.containsIgnoreCase(accepts, "application/json")) return "application/json";
|
||||
return StringUtil.join(accepts, ",");
|
||||
}
|
||||
|
||||
/**
|
||||
* Select the Content-Type header's value from the given array:
|
||||
* if JSON exists in the given array, use it;
|
||||
* otherwise use the first one of the array.
|
||||
*
|
||||
* @param contentTypes The Content-Type array to select from
|
||||
* @return The Content-Type header to use. If the given array is empty,
|
||||
* JSON will be used.
|
||||
*/
|
||||
public String selectHeaderContentType(String[] contentTypes) {
|
||||
if (contentTypes.length == 0) return "application/json";
|
||||
if (StringUtil.containsIgnoreCase(contentTypes, "application/json")) return "application/json";
|
||||
return contentTypes[0];
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method to configure the first api key found
|
||||
* @param apiKey API key
|
||||
*/
|
||||
public void setApiKey(String apiKey) {
|
||||
for(RequestInterceptor apiAuthorization : apiAuthorizations.values()) {
|
||||
if (apiAuthorization instanceof ApiKeyAuth) {
|
||||
ApiKeyAuth keyAuth = (ApiKeyAuth) apiAuthorization;
|
||||
keyAuth.setApiKey(apiKey);
|
||||
return ;
|
||||
}
|
||||
}
|
||||
throw new RuntimeException("No API key authentication configured!");
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method to configure the username/password for basic auth or password OAuth
|
||||
* @param username Username
|
||||
* @param password Password
|
||||
*/
|
||||
public void setCredentials(String username, String password) {
|
||||
for(RequestInterceptor apiAuthorization : apiAuthorizations.values()) {
|
||||
if (apiAuthorization instanceof HttpBasicAuth) {
|
||||
HttpBasicAuth basicAuth = (HttpBasicAuth) apiAuthorization;
|
||||
basicAuth.setCredentials(username, password);
|
||||
return;
|
||||
}
|
||||
if (apiAuthorization instanceof OAuth) {
|
||||
OAuth oauth = (OAuth) apiAuthorization;
|
||||
oauth.getTokenRequestBuilder().setUsername(username).setPassword(password);
|
||||
return;
|
||||
}
|
||||
}
|
||||
throw new RuntimeException("No Basic authentication or OAuth configured!");
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method to configure the token endpoint of the first oauth found in the apiAuthorizations (there should be only one)
|
||||
* @return Token request builder
|
||||
*/
|
||||
public TokenRequestBuilder getTokenEndPoint() {
|
||||
for(RequestInterceptor apiAuthorization : apiAuthorizations.values()) {
|
||||
if (apiAuthorization instanceof OAuth) {
|
||||
OAuth oauth = (OAuth) apiAuthorization;
|
||||
return oauth.getTokenRequestBuilder();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method to configure authorization endpoint of the first oauth found in the apiAuthorizations (there should be only one)
|
||||
* @return Authentication request builder
|
||||
*/
|
||||
public AuthenticationRequestBuilder getAuthorizationEndPoint() {
|
||||
for(RequestInterceptor apiAuthorization : apiAuthorizations.values()) {
|
||||
if (apiAuthorization instanceof OAuth) {
|
||||
OAuth oauth = (OAuth) apiAuthorization;
|
||||
return oauth.getAuthenticationRequestBuilder();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method to pre-set the oauth access token of the first oauth found in the apiAuthorizations (there should be only one)
|
||||
* @param accessToken Access Token
|
||||
* @param expiresIn Validity period in seconds
|
||||
*/
|
||||
public void setAccessToken(String accessToken, Long expiresIn) {
|
||||
for(RequestInterceptor apiAuthorization : apiAuthorizations.values()) {
|
||||
if (apiAuthorization instanceof OAuth) {
|
||||
OAuth oauth = (OAuth) apiAuthorization;
|
||||
oauth.setAccessToken(accessToken, expiresIn);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method to configure the oauth accessCode/implicit flow parameters
|
||||
* @param clientId Client ID
|
||||
* @param clientSecret Client secret
|
||||
* @param redirectURI Redirect URI
|
||||
*/
|
||||
public void configureAuthorizationFlow(String clientId, String clientSecret, String redirectURI) {
|
||||
for(RequestInterceptor apiAuthorization : apiAuthorizations.values()) {
|
||||
if (apiAuthorization instanceof OAuth) {
|
||||
OAuth oauth = (OAuth) apiAuthorization;
|
||||
oauth.getTokenRequestBuilder()
|
||||
.setClientId(clientId)
|
||||
.setClientSecret(clientSecret)
|
||||
.setRedirectURI(redirectURI);
|
||||
oauth.getAuthenticationRequestBuilder()
|
||||
.setClientId(clientId)
|
||||
.setRedirectURI(redirectURI);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Configures a listener which is notified when a new access token is received.
|
||||
* @param accessTokenListener Acesss token listener
|
||||
*/
|
||||
public void registerAccessTokenListener(AccessTokenListener accessTokenListener) {
|
||||
for(RequestInterceptor apiAuthorization : apiAuthorizations.values()) {
|
||||
if (apiAuthorization instanceof OAuth) {
|
||||
OAuth oauth = (OAuth) apiAuthorization;
|
||||
oauth.registerAccessTokenListener(accessTokenListener);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets request interceptor based on authentication name
|
||||
* @param authName Authentiation name
|
||||
* @return Request Interceptor
|
||||
*/
|
||||
public RequestInterceptor getAuthorization(String authName) {
|
||||
return apiAuthorizations.get(authName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds an authorization to be used by the client
|
||||
* @param authName Authentication name
|
||||
* @param authorization Request interceptor
|
||||
*/
|
||||
public void addAuthorization(String authName, RequestInterceptor authorization) {
|
||||
if (apiAuthorizations.containsKey(authName)) {
|
||||
throw new RuntimeException("auth name \"" + authName + "\" already in api authorizations");
|
||||
}
|
||||
apiAuthorizations.put(authName, authorization);
|
||||
feignBuilder.requestInterceptor(authorization);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,86 +0,0 @@
|
||||
package com.mowesta.android.feign;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Utilities to support Swagger encoding formats in Feign.
|
||||
*/
|
||||
public final class EncodingUtils {
|
||||
|
||||
/**
|
||||
* Private constructor. Do not construct this class.
|
||||
*/
|
||||
private EncodingUtils() {}
|
||||
|
||||
/**
|
||||
* <p>Encodes a collection of query parameters according to the Swagger
|
||||
* collection format.</p>
|
||||
*
|
||||
* <p>Of the various collection formats defined by Swagger ("csv", "tsv",
|
||||
* etc), Feign only natively supports "multi". This utility generates the
|
||||
* other format types so it will be properly processed by Feign.</p>
|
||||
*
|
||||
* <p>Note, as part of reformatting, it URL encodes the parameters as
|
||||
* well.</p>
|
||||
* @param parameters The collection object to be formatted. This object will
|
||||
* not be changed.
|
||||
* @param collectionFormat The Swagger collection format (eg, "csv", "tsv",
|
||||
* "pipes"). See the
|
||||
* <a href="http://swagger.io/specification/#parameter-object-44">
|
||||
* Swagger Spec</a> for more details.
|
||||
* @return An object that will be correctly formatted by Feign.
|
||||
*/
|
||||
public static Object encodeCollection(Collection<?> parameters,
|
||||
String collectionFormat) {
|
||||
if (parameters == null) {
|
||||
return parameters;
|
||||
}
|
||||
List<String> stringValues = new ArrayList<>(parameters.size());
|
||||
for (Object parameter : parameters) {
|
||||
// ignore null values (same behavior as Feign)
|
||||
if (parameter != null) {
|
||||
stringValues.add(encode(parameter));
|
||||
}
|
||||
}
|
||||
// Feign natively handles single-element lists and the "multi" format.
|
||||
if (stringValues.size() < 2 || "multi".equals(collectionFormat)) {
|
||||
return stringValues;
|
||||
}
|
||||
// Otherwise return a formatted String
|
||||
String[] stringArray = stringValues.toArray(new String[0]);
|
||||
switch (collectionFormat) {
|
||||
case "csv":
|
||||
default:
|
||||
return StringUtil.join(stringArray, ",");
|
||||
case "ssv":
|
||||
return StringUtil.join(stringArray, " ");
|
||||
case "tsv":
|
||||
return StringUtil.join(stringArray, "\t");
|
||||
case "pipes":
|
||||
return StringUtil.join(stringArray, "|");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* URL encode a single query parameter.
|
||||
* @param parameter The query parameter to encode. This object will not be
|
||||
* changed.
|
||||
* @return The URL encoded string representation of the parameter. If the
|
||||
* parameter is null, returns null.
|
||||
*/
|
||||
public static String encode(Object parameter) {
|
||||
if (parameter == null) {
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
return URLEncoder.encode(parameter.toString(), "UTF-8");
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
// Should never happen, UTF-8 is always supported
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,42 +0,0 @@
|
||||
package com.mowesta.android.feign;
|
||||
|
||||
@javax.annotation.Generated(value = "io.swagger.codegen.languages.JavaClientCodegen", date = "2017-10-20T17:10:12.901+02:00")
|
||||
public class StringUtil {
|
||||
/**
|
||||
* Check if the given array contains the given value (with case-insensitive comparison).
|
||||
*
|
||||
* @param array The array
|
||||
* @param value The value to search
|
||||
* @return true if the array contains the value
|
||||
*/
|
||||
public static boolean containsIgnoreCase(String[] array, String value) {
|
||||
for (String str : array) {
|
||||
if (value == null && str == null) return true;
|
||||
if (value != null && value.equalsIgnoreCase(str)) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Join an array of strings with the given separator.
|
||||
* <p>
|
||||
* Note: This might be replaced by utility method from commons-lang or guava someday
|
||||
* if one of those libraries is added as dependency.
|
||||
* </p>
|
||||
*
|
||||
* @param array The array of strings
|
||||
* @param separator The separator
|
||||
* @return the resulting string
|
||||
*/
|
||||
public static String join(String[] array, String separator) {
|
||||
int len = array.length;
|
||||
if (len == 0) return "";
|
||||
|
||||
StringBuilder out = new StringBuilder();
|
||||
out.append(array[0]);
|
||||
for (int i = 1; i < len; i++) {
|
||||
out.append(separator).append(array[i]);
|
||||
}
|
||||
return out.toString();
|
||||
}
|
||||
}
|
||||
@@ -1,41 +0,0 @@
|
||||
package com.mowesta.android.feign.auth;
|
||||
|
||||
import feign.RequestInterceptor;
|
||||
import feign.RequestTemplate;
|
||||
|
||||
public class ApiKeyAuth implements RequestInterceptor {
|
||||
private final String location;
|
||||
private final String paramName;
|
||||
|
||||
private String apiKey;
|
||||
|
||||
public ApiKeyAuth(String location, String paramName) {
|
||||
this.location = location;
|
||||
this.paramName = paramName;
|
||||
}
|
||||
|
||||
public String getLocation() {
|
||||
return location;
|
||||
}
|
||||
|
||||
public String getParamName() {
|
||||
return paramName;
|
||||
}
|
||||
|
||||
public String getApiKey() {
|
||||
return apiKey;
|
||||
}
|
||||
|
||||
public void setApiKey(String apiKey) {
|
||||
this.apiKey = apiKey;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply(RequestTemplate template) {
|
||||
if ("query".equals(location)) {
|
||||
template.query(paramName, apiKey);
|
||||
} else if ("header".equals(location)) {
|
||||
template.header(paramName, apiKey);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,41 +0,0 @@
|
||||
package com.mowesta.android.feign.auth;
|
||||
|
||||
import feign.RequestInterceptor;
|
||||
import feign.RequestTemplate;
|
||||
import feign.auth.BasicAuthRequestInterceptor;
|
||||
|
||||
/**
|
||||
* An interceptor that adds the request header needed to use HTTP basic authentication.
|
||||
*/
|
||||
public class HttpBasicAuth implements RequestInterceptor {
|
||||
|
||||
private String username;
|
||||
private String password;
|
||||
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
|
||||
public void setUsername(String username) {
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
|
||||
public void setPassword(String password) {
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
public void setCredentials(String username, String password) {
|
||||
this.username = username;
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply(RequestTemplate template) {
|
||||
RequestInterceptor requestInterceptor = new BasicAuthRequestInterceptor(username, password);
|
||||
requestInterceptor.apply(template);
|
||||
}
|
||||
}
|
||||
@@ -1,198 +0,0 @@
|
||||
package com.mowesta.android.feign.auth;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import org.apache.oltu.oauth2.client.HttpClient;
|
||||
import org.apache.oltu.oauth2.client.OAuthClient;
|
||||
import org.apache.oltu.oauth2.client.request.OAuthClientRequest;
|
||||
import org.apache.oltu.oauth2.client.request.OAuthClientRequest.AuthenticationRequestBuilder;
|
||||
import org.apache.oltu.oauth2.client.request.OAuthClientRequest.TokenRequestBuilder;
|
||||
import org.apache.oltu.oauth2.client.response.OAuthClientResponse;
|
||||
import org.apache.oltu.oauth2.client.response.OAuthClientResponseFactory;
|
||||
import org.apache.oltu.oauth2.client.response.OAuthJSONAccessTokenResponse;
|
||||
import org.apache.oltu.oauth2.common.exception.OAuthProblemException;
|
||||
import org.apache.oltu.oauth2.common.exception.OAuthSystemException;
|
||||
import org.apache.oltu.oauth2.common.message.types.GrantType;
|
||||
import org.apache.oltu.oauth2.common.token.BasicOAuthToken;
|
||||
|
||||
import com.mowesta.android.feign.StringUtil;
|
||||
|
||||
import feign.Client;
|
||||
import feign.Request.Options;
|
||||
import feign.RequestInterceptor;
|
||||
import feign.RequestTemplate;
|
||||
import feign.Response;
|
||||
import feign.RetryableException;
|
||||
import feign.Util;
|
||||
|
||||
|
||||
public class OAuth implements RequestInterceptor {
|
||||
|
||||
static final int MILLIS_PER_SECOND = 1000;
|
||||
|
||||
public interface AccessTokenListener {
|
||||
void notify(BasicOAuthToken token);
|
||||
}
|
||||
|
||||
private volatile String accessToken;
|
||||
private Long expirationTimeMillis;
|
||||
private OAuthClient oauthClient;
|
||||
private TokenRequestBuilder tokenRequestBuilder;
|
||||
private AuthenticationRequestBuilder authenticationRequestBuilder;
|
||||
private AccessTokenListener accessTokenListener;
|
||||
|
||||
public OAuth(Client client, TokenRequestBuilder requestBuilder) {
|
||||
this.oauthClient = new OAuthClient(new OAuthFeignClient(client));
|
||||
this.tokenRequestBuilder = requestBuilder;
|
||||
}
|
||||
|
||||
public OAuth(Client client, OAuthFlow flow, String authorizationUrl, String tokenUrl, String scopes) {
|
||||
this(client, OAuthClientRequest.tokenLocation(tokenUrl).setScope(scopes));
|
||||
|
||||
switch(flow) {
|
||||
case accessCode:
|
||||
case implicit:
|
||||
tokenRequestBuilder.setGrantType(GrantType.AUTHORIZATION_CODE);
|
||||
break;
|
||||
case password:
|
||||
tokenRequestBuilder.setGrantType(GrantType.PASSWORD);
|
||||
break;
|
||||
case application:
|
||||
tokenRequestBuilder.setGrantType(GrantType.CLIENT_CREDENTIALS);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
authenticationRequestBuilder = OAuthClientRequest.authorizationLocation(authorizationUrl);
|
||||
}
|
||||
|
||||
public OAuth(OAuthFlow flow, String authorizationUrl, String tokenUrl, String scopes) {
|
||||
this(new Client.Default(null, null), flow, authorizationUrl, tokenUrl, scopes);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply(RequestTemplate template) {
|
||||
// If the request already have an authorization (eg. Basic auth), do nothing
|
||||
if (template.headers().containsKey("Authorization")) {
|
||||
return;
|
||||
}
|
||||
// If first time, get the token
|
||||
if (expirationTimeMillis == null || System.currentTimeMillis() >= expirationTimeMillis) {
|
||||
updateAccessToken();
|
||||
}
|
||||
if (getAccessToken() != null) {
|
||||
template.header("Authorization", "Bearer " + getAccessToken());
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void updateAccessToken() {
|
||||
OAuthJSONAccessTokenResponse accessTokenResponse;
|
||||
try {
|
||||
accessTokenResponse = oauthClient.accessToken(tokenRequestBuilder.buildBodyMessage());
|
||||
} catch (Exception e) {
|
||||
throw new RetryableException(e.getMessage(), e,null);
|
||||
}
|
||||
if (accessTokenResponse != null && accessTokenResponse.getAccessToken() != null) {
|
||||
setAccessToken(accessTokenResponse.getAccessToken(), accessTokenResponse.getExpiresIn());
|
||||
if (accessTokenListener != null) {
|
||||
accessTokenListener.notify((BasicOAuthToken) accessTokenResponse.getOAuthToken());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void registerAccessTokenListener(AccessTokenListener accessTokenListener) {
|
||||
this.accessTokenListener = accessTokenListener;
|
||||
}
|
||||
|
||||
public synchronized String getAccessToken() {
|
||||
return accessToken;
|
||||
}
|
||||
|
||||
public synchronized void setAccessToken(String accessToken, Long expiresIn) {
|
||||
this.accessToken = accessToken;
|
||||
this.expirationTimeMillis = System.currentTimeMillis() + expiresIn * MILLIS_PER_SECOND;
|
||||
}
|
||||
|
||||
public TokenRequestBuilder getTokenRequestBuilder() {
|
||||
return tokenRequestBuilder;
|
||||
}
|
||||
|
||||
public void setTokenRequestBuilder(TokenRequestBuilder tokenRequestBuilder) {
|
||||
this.tokenRequestBuilder = tokenRequestBuilder;
|
||||
}
|
||||
|
||||
public AuthenticationRequestBuilder getAuthenticationRequestBuilder() {
|
||||
return authenticationRequestBuilder;
|
||||
}
|
||||
|
||||
public void setAuthenticationRequestBuilder(AuthenticationRequestBuilder authenticationRequestBuilder) {
|
||||
this.authenticationRequestBuilder = authenticationRequestBuilder;
|
||||
}
|
||||
|
||||
public OAuthClient getOauthClient() {
|
||||
return oauthClient;
|
||||
}
|
||||
|
||||
public void setOauthClient(OAuthClient oauthClient) {
|
||||
this.oauthClient = oauthClient;
|
||||
}
|
||||
|
||||
public void setOauthClient(Client client) {
|
||||
this.oauthClient = new OAuthClient( new OAuthFeignClient(client));
|
||||
}
|
||||
|
||||
public static class OAuthFeignClient implements HttpClient {
|
||||
|
||||
private Client client;
|
||||
|
||||
public OAuthFeignClient() {
|
||||
this.client = new Client.Default(null, null);
|
||||
}
|
||||
|
||||
public OAuthFeignClient(Client client) {
|
||||
this.client = client;
|
||||
}
|
||||
|
||||
public <T extends OAuthClientResponse> T execute(OAuthClientRequest request, Map<String, String> headers,
|
||||
String requestMethod, Class<T> responseClass)
|
||||
throws OAuthSystemException, OAuthProblemException {
|
||||
|
||||
RequestTemplate req = new RequestTemplate()
|
||||
.append(request.getLocationUri())
|
||||
.method(requestMethod)
|
||||
.body(request.getBody());
|
||||
|
||||
for (Entry<String, String> entry : headers.entrySet()) {
|
||||
req.header(entry.getKey(), entry.getValue());
|
||||
}
|
||||
Response feignResponse;
|
||||
String body = "";
|
||||
try {
|
||||
feignResponse = client.execute(req.request(), new Options());
|
||||
body = Util.toString(feignResponse.body().asReader());
|
||||
} catch (IOException e) {
|
||||
throw new OAuthSystemException(e);
|
||||
}
|
||||
|
||||
String contentType = null;
|
||||
Collection<String> contentTypeHeader = feignResponse.headers().get("Content-Type");
|
||||
if(contentTypeHeader != null) {
|
||||
contentType = StringUtil.join(contentTypeHeader.toArray(new String[0]), ";");
|
||||
}
|
||||
|
||||
return OAuthClientResponseFactory.createCustomResponse(
|
||||
body,
|
||||
contentType,
|
||||
feignResponse.status(),
|
||||
responseClass
|
||||
);
|
||||
}
|
||||
|
||||
public void shutdown() {
|
||||
// Nothing to do here
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
package com.mowesta.android.feign.auth;
|
||||
|
||||
public enum OAuthFlow {
|
||||
accessCode, implicit, password, application
|
||||
}
|
||||
@@ -40,7 +40,7 @@ dependencies {
|
||||
implementation fileTree(dir: "libs", include: ["*.jar"])
|
||||
implementation project(":android-sdk")
|
||||
|
||||
implementation "javax.xml.bind:jaxb-api:${versionJaxb}"
|
||||
implementation "jakarta.xml.bind:jakarta.xml.bind-api:${versionJaxb}"
|
||||
implementation "androidx.appcompat:appcompat:${versionAndroidXAppcompat}"
|
||||
implementation "androidx.work:work-runtime:${versionAndroidXWork}"
|
||||
implementation "com.google.android.material:material:${versionGoogleMaterial}"
|
||||
@@ -100,7 +100,7 @@ android {
|
||||
applicationId "com.mowesta.android.app"
|
||||
minSdkVersion 19
|
||||
targetSdkVersion 33
|
||||
versionCode 29
|
||||
versionCode 30
|
||||
versionName "${versionApp}"
|
||||
buildConfigField "long", "BUILD_TIME", System.currentTimeMillis() + "L"
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
@@ -174,8 +174,14 @@ android {
|
||||
}
|
||||
namespace 'com.mowesta.android.app'
|
||||
|
||||
packagingOptions {
|
||||
resources {
|
||||
excludes += "META-INF/*.md"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// enable unchecked and deprecation warning during compilation
|
||||
gradle.projectsEvaluated {
|
||||
tasks.withType(JavaCompile) {
|
||||
|
||||
@@ -235,7 +235,7 @@ public class BindingAdapters {
|
||||
res = R.string.city_type_village;
|
||||
break;
|
||||
}
|
||||
if (city.isCapital()) {
|
||||
if (city.getCapital()) {
|
||||
res = R.string.city_type_capital;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -150,7 +150,7 @@ public class TermsFragment extends Fragment {
|
||||
*
|
||||
* @author Marcus
|
||||
*/
|
||||
public static class BrowserFragment extends CityFragment.ChildFragment {
|
||||
public static class BrowserFragment extends Fragment {
|
||||
|
||||
/**
|
||||
* The web view to show the contents.
|
||||
|
||||
@@ -57,7 +57,7 @@ public class DrawerViewModel extends AbstractNetworkViewModel {
|
||||
* The task to perform the search.
|
||||
*/
|
||||
private ApiTask<RequestParameter<String>, LocationHierarchyPage> searchTask = new ApiTask<>((input, client) -> {
|
||||
return client.searchLocations(getLanguage(), input.getValue(), null,0, 10);
|
||||
return client.searchLocations(getLanguage(), input.getValue(), 0, 10, null);
|
||||
}, (input, result) -> {
|
||||
completeRequest(input, () -> {
|
||||
results.setValue(result);
|
||||
|
||||
+1
-1
@@ -68,7 +68,7 @@ public class ForecastWidgetViewModel extends AbstractNetworkViewModel {
|
||||
|
||||
private ApiTask<RequestParameter<String>, CityPage> searchTask = new ApiTask<>(
|
||||
(input, client) -> {
|
||||
CityPage cities = client.searchCities(getApplication().getString(R.string.language_code), input.getValue(), null, 0, 20);
|
||||
CityPage cities = client.searchCities(getApplication().getString(R.string.language_code), input.getValue(), 0, 20, null);
|
||||
return cities;
|
||||
},
|
||||
(input, result) -> {
|
||||
|
||||
@@ -150,7 +150,7 @@ public class StationsViewModel extends AbstractNetworkViewModel {
|
||||
|
||||
@Override
|
||||
public void loadInitial(@NonNull LoadInitialParams params, @NonNull LoadInitialCallback<WeatherStation> callback) {
|
||||
ApiTask<Void, WeatherStationPage> task = new ApiTask<>((v, client) -> { return client.getStations(0, params.requestedLoadSize, term); },
|
||||
ApiTask<Void, WeatherStationPage> task = new ApiTask<>((v, client) -> { return client.getStations(term, 0, params.requestedLoadSize); },
|
||||
(v, page) -> { completeRequest(requestCode, () -> callback.onResult(page.getElements(), 0, page.getTotal())); },
|
||||
(v, status) -> { finishRequest(requestCode, true); });
|
||||
if (isCurrentRequest(requestCode)) {
|
||||
@@ -161,7 +161,7 @@ public class StationsViewModel extends AbstractNetworkViewModel {
|
||||
|
||||
@Override
|
||||
public void loadRange(@NonNull LoadRangeParams params, @NonNull LoadRangeCallback<WeatherStation> callback) {
|
||||
ApiTask<Void, WeatherStationPage> task = new ApiTask<>((v, client) -> { return client.getStations(params.startPosition, params.loadSize, term); },
|
||||
ApiTask<Void, WeatherStationPage> task = new ApiTask<>((v, client) -> { return client.getStations(term, params.startPosition, params.loadSize); },
|
||||
(v, page) -> { completeRequest(requestCode, () -> callback.onResult(page.getElements())); },
|
||||
(v, status) -> { finishRequest(requestCode, true);});
|
||||
if (isCurrentRequest(requestCode)) {
|
||||
|
||||
@@ -196,7 +196,7 @@ public class DeviceRepository extends Repository {
|
||||
d.setId(handle.getId());
|
||||
d.setDevice(handle.getDevice());
|
||||
d.setCreationTime(handle.getCreationTime());
|
||||
d.setDeleted(handle.isDeleted());
|
||||
d.setDeleted(handle.getDeleted());
|
||||
d.setManufacturer(handle.getManufacturer());
|
||||
d.setModificationTime(handle.getModificationTime());
|
||||
d.setModel(handle.getModel());
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -10,14 +10,12 @@
|
||||
#include "ArduinoJson.h"
|
||||
|
||||
// Hardware setup
|
||||
#define BUTTON_PIN D5
|
||||
#define VOLTAGE_PIN A0
|
||||
#define VOLTAGE_MULTIPLIER 11
|
||||
#define VOLTAGE_DIVIDER 255.0
|
||||
#define EEPROM_SIZE 512
|
||||
#define BUTTON_OUT D7
|
||||
#define BME_OUT D6
|
||||
#define VOLTAGE_OUT D8
|
||||
#define BUTTON_PIN D5
|
||||
|
||||
//Credentials for the Access Point
|
||||
#define WLAN_AP_SSID "MoWeSta - WiFi"
|
||||
@@ -124,12 +122,6 @@ void setup() {
|
||||
while (!Serial);
|
||||
Serial.println();
|
||||
|
||||
// power the voltage divider
|
||||
pinMode(VOLTAGE_OUT, OUTPUT);
|
||||
digitalWrite(VOLTAGE_OUT, LOW);
|
||||
// power the bme sensor
|
||||
pinMode(BME_OUT, OUTPUT);
|
||||
digitalWrite(BME_OUT, LOW);
|
||||
// power the button
|
||||
pinMode(BUTTON_OUT, OUTPUT);
|
||||
digitalWrite(BUTTON_OUT, LOW);
|
||||
|
||||
@@ -9,13 +9,12 @@
|
||||
#include "ArduinoJson.h"
|
||||
|
||||
// Hardware setup
|
||||
#define BUTTON_PIN D5
|
||||
#define VOLTAGE_PIN A0
|
||||
#define VOLTAGE_MULTIPLIER 11
|
||||
#define VOLTAGE_DIVIDER 255.0
|
||||
#define EEPROM_SIZE 512
|
||||
#define BUTTON_PIN D5
|
||||
#define BUTTON_OUT D7
|
||||
#define EXTERNAL_OUT D8
|
||||
|
||||
//Credentials for the Access Point
|
||||
#define WLAN_AP_SSID "MoWeSta - WiFi"
|
||||
@@ -124,8 +123,6 @@ void setup() {
|
||||
// power the button, voltage divider and sensor
|
||||
pinMode(BUTTON_OUT, OUTPUT);
|
||||
digitalWrite(BUTTON_OUT, LOW);
|
||||
// set out to in, since it is connected directly to GND
|
||||
pinMode(EXTERNAL_OUT, INPUT);
|
||||
// Initialize EEPROM with complete size
|
||||
// Configure the button to enter setup
|
||||
pinMode(BUTTON_PIN, INPUT_PULLUP);
|
||||
|
||||
Binary file not shown.
Binary file not shown.
|
After Width: | Height: | Size: 51 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 265 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 240 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 78 KiB |
+41
-69
@@ -1,14 +1,12 @@
|
||||
import java.util.concurrent.atomic.AtomicBoolean
|
||||
import java.util.concurrent.locks.ReentrantLock
|
||||
|
||||
apply plugin: 'maven-publish'
|
||||
|
||||
buildscript {
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:7.3.1'
|
||||
classpath 'com.google.android.gms:oss-licenses-plugin:0.10.4'
|
||||
classpath 'org.handte.gradle:gradle-android-eclipse:1.0.0'
|
||||
classpath "gradle.plugin.org.openbakery:plugin:0.21.0"
|
||||
classpath 'com.android.tools.build:gradle:7.3.1'
|
||||
classpath 'com.google.android.gms:oss-licenses-plugin:0.10.4'
|
||||
classpath 'org.handte.gradle:gradle-android-eclipse:1.0.0'
|
||||
classpath "gradle.plugin.org.openbakery:plugin:0.21.0"
|
||||
}
|
||||
repositories {
|
||||
maven {
|
||||
@@ -19,39 +17,47 @@ buildscript {
|
||||
}
|
||||
}
|
||||
|
||||
allprojects {
|
||||
apply plugin: 'maven-publish'
|
||||
plugins.withType(JavaPlugin) {
|
||||
afterEvaluate {
|
||||
java {
|
||||
toolchain {
|
||||
languageVersion = JavaLanguageVersion.of(17)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
allprojects {
|
||||
// set version for our project
|
||||
group = 'com.mowesta'
|
||||
version = '1.0.29'
|
||||
version = '1.1.2'
|
||||
|
||||
// set versions for our libraries
|
||||
ext {
|
||||
// api dependencies
|
||||
versionJavaee = '8.0.0'
|
||||
versionJaxb = '2.3.1'
|
||||
versionJavaee = '10.0.0'
|
||||
versionJaxb = '4.0.1'
|
||||
versionAnnotation = '1.3.2'
|
||||
versionSwagger = '1.5.22'
|
||||
versionSwagger = '2.2.16'
|
||||
versionGeojson = '1.8.1'
|
||||
// wildfly dependencies, keep in sync
|
||||
versionJackson = '2.10.5'
|
||||
versionResteasy = '3.13.2.Final'
|
||||
versionWildfly = '21.0.0.Final'
|
||||
versionPicketbox = '5.0.3.Final'
|
||||
versionHibernate = '5.3.18.Final'
|
||||
versionHibernateSearch = '5.10.7.Final'
|
||||
// built-in infinispan dependency
|
||||
versionInfinispan = '9.4.20.Final'
|
||||
// testing dependencies
|
||||
versionJackson = '2.14.3'
|
||||
versionResteasy = '6.2.7.Final'
|
||||
versionWildfly = '31.0.1.Final'
|
||||
versionHibernate = '6.4.4.Final'
|
||||
versionHibernateSearch = '7.0.0.Final'
|
||||
versionLucene = '9.8.0'
|
||||
// other frameworks and libraries
|
||||
versionGalleon = '5.2.2.Final'
|
||||
versionMapDB = '3.1.0'
|
||||
versionCommonsNet = '3.5'
|
||||
versionCommonsCompress = '1.20'
|
||||
versionJunit = '4.13.2'
|
||||
versionArquillianContainer = '2.2.0.Final'
|
||||
versionArquillianJunit = '1.5.0.Final'
|
||||
// thorntail dependencies
|
||||
versionH2database = '1.4.196'
|
||||
versionThorntail = '2.6.0.Final'
|
||||
// other frameworks
|
||||
mapstructVersion = '1.3.1.Final'
|
||||
versionArquillianContainer = '5.0.1.Final'
|
||||
versionArquillianJunit = '1.8.0.Final'
|
||||
versionArquillianProtocol = '1.7.2.Final'
|
||||
versionPostgres = '42.7.1'
|
||||
versionMapstruct = '1.5.5.Final'
|
||||
// shared android dependencies
|
||||
versionAndroidXTest = '1.4.0'
|
||||
versionAndroidXAppcompat = '1.5.1'
|
||||
@@ -59,16 +65,17 @@ allprojects {
|
||||
versionAndroidXPreference = '1.2.0'
|
||||
versionRobolectric = '4.9'
|
||||
// locoslab libraries and code
|
||||
versionGeometry = '1.1.4'
|
||||
versionCarta = '1.1.4'
|
||||
versionGeometry = '1.4.0'
|
||||
versionCarta = '1.3.0'
|
||||
versionGrib2 = '1.0.0'
|
||||
versionAuth = '1.1.0'
|
||||
// tools
|
||||
versionCli = '1.4'
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
subprojects {
|
||||
apply plugin: 'maven-publish'
|
||||
apply plugin: 'eclipse'
|
||||
|
||||
if (name.equals('android-app')) {
|
||||
@@ -77,7 +84,7 @@ subprojects {
|
||||
publications {
|
||||
maven(MavenPublication) {
|
||||
groupId = 'com.mowesta'
|
||||
version = project.version
|
||||
version = project.version
|
||||
artifact file('build/outputs/apk/prod/release/android-app-prod-release.apk')
|
||||
}
|
||||
}
|
||||
@@ -87,7 +94,7 @@ subprojects {
|
||||
publishing {
|
||||
publications {
|
||||
maven(MavenPublication) {
|
||||
groupId = 'com.mowesta'
|
||||
groupId = 'com.mowesta'
|
||||
artifact file('build/outputs/aar/android-sdk-release.aar')
|
||||
version = project.version
|
||||
}
|
||||
@@ -105,7 +112,6 @@ subprojects {
|
||||
} else {
|
||||
// standard java configration
|
||||
apply plugin: 'java-library'
|
||||
sourceCompatibility = '1.8'
|
||||
|
||||
task sourcesJar(type: Jar) {
|
||||
classifier = 'sources'
|
||||
@@ -149,40 +155,6 @@ subprojects {
|
||||
|
||||
// rename subprojects in eclipse to avoid collisions with other projects
|
||||
eclipse.project.name = 'mowesta-' + project.name
|
||||
|
||||
}
|
||||
|
||||
tasks.register("generatePomFileForMavenPublication") { }
|
||||
|
||||
tasks.register("build") { }
|
||||
|
||||
|
||||
// aquire locks to ensure that service-ejb and service-war are not running tests in parallel
|
||||
def lock = new ReentrantLock()
|
||||
def available = lock.newCondition()
|
||||
def busy = new AtomicBoolean()
|
||||
def serializedTasks = []
|
||||
def sequentialProjects = [ 'service-ejb', 'service-war' ]
|
||||
|
||||
gradle.taskGraph.beforeTask {
|
||||
if (it.name == 'test' && it.project.name in sequentialProjects) {
|
||||
serializedTasks << it
|
||||
it.doFirst {
|
||||
lock.lock()
|
||||
while (busy.get()) {
|
||||
available.await()
|
||||
}
|
||||
busy.set(true)
|
||||
lock.unlock()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
gradle.taskGraph.afterTask {
|
||||
if (it in serializedTasks) {
|
||||
lock.lock()
|
||||
busy.set(false)
|
||||
available.signal()
|
||||
lock.unlock()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,89 +0,0 @@
|
||||
plugins {
|
||||
id 'com.benjaminsproule.swagger' version '1.0.14'
|
||||
}
|
||||
|
||||
description = 'MoWeSta Common Api'
|
||||
|
||||
dependencies {
|
||||
api "javax.xml.bind:jaxb-api:${versionJaxb}"
|
||||
api "de.grundid.opendatalab:geojson-jackson:${versionGeojson}"
|
||||
|
||||
testImplementation "junit:junit:${versionJunit}"
|
||||
testImplementation "org.glassfish.jaxb:jaxb-runtime:${versionJaxb}"
|
||||
|
||||
compileClasspath "jakarta.platform:jakarta.jakartaee-api:${versionJavaee}"
|
||||
compileClasspath "io.swagger:swagger-annotations:${versionSwagger}"
|
||||
compileClasspath "com.fasterxml.jackson.core:jackson-annotations:${versionJackson}"
|
||||
}
|
||||
|
||||
// add compile only dependencies to testCompile without duplicating them
|
||||
sourceSets {
|
||||
//test.compileClasspath += configurations.compileOnly
|
||||
}
|
||||
|
||||
// generate swagger documenation from api using a plugin
|
||||
swagger {
|
||||
apiSource {
|
||||
attachSwaggerArtifact = true
|
||||
locations = [
|
||||
'com.mowesta.api.device.IDeviceService',
|
||||
'com.mowesta.api.location.ILocationService',
|
||||
'com.mowesta.api.log.ILogService',
|
||||
'com.mowesta.api.measurement.IMeasurementService',
|
||||
'com.mowesta.api.settings.ISettingsService',
|
||||
'com.mowesta.api.user.IUserService',
|
||||
'com.mowesta.api.version.IVersionService',
|
||||
'com.mowesta.api.weather.IWeatherService',
|
||||
]
|
||||
schemes = ['https']
|
||||
host = 'www.mowesta.com'
|
||||
basePath = '/api'
|
||||
info {
|
||||
title = 'Mowesta Service'
|
||||
version = project.version
|
||||
description = 'The application programming '
|
||||
termsOfService = 'https://mowesta.com/terms-of-service'
|
||||
contact {
|
||||
email = 'nes-admin@uni-due.de'
|
||||
name = 'Networked Embedded Systems'
|
||||
url = 'https://www.nes.uni-due.de'
|
||||
}
|
||||
license {
|
||||
url = 'https://www.mowesta.com/license'
|
||||
name = 'Mowesta License'
|
||||
}
|
||||
}
|
||||
swaggerFileName = 'mowesta'
|
||||
swaggerDirectory = "${project.buildDir}/swagger"
|
||||
securityDefinition {
|
||||
name = 'device'
|
||||
description = 'Operations requiring device privileges.'
|
||||
type = 'apiKey'
|
||||
keyLocation = 'header'
|
||||
keyName = 'Authorization'
|
||||
}
|
||||
securityDefinition {
|
||||
name = 'user'
|
||||
description = 'Operations requiring a valid user.'
|
||||
type = 'basic'
|
||||
}
|
||||
securityDefinition {
|
||||
name = 'admin'
|
||||
description = 'Operations requiring admin privileges.'
|
||||
type = 'basic'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
build.dependsOn("generateSwaggerDocumentation")
|
||||
publish.dependsOn("generateSwaggerDocumentation")
|
||||
|
||||
// add the swagger defintion to the artifacts published by this module
|
||||
publishing {
|
||||
publications {
|
||||
maven(MavenPublication) {
|
||||
artifact source: "${project.buildDir}/swagger/mowesta.json", extension: "swagger"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,19 +0,0 @@
|
||||
package com.mowesta.api.device;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
import javax.xml.bind.annotation.XmlSeeAlso;
|
||||
|
||||
import com.mowesta.api.Page;
|
||||
|
||||
/**
|
||||
* A page containing devices.
|
||||
*
|
||||
* @author Ole
|
||||
*/
|
||||
@XmlRootElement
|
||||
@XmlSeeAlso(Device.class)
|
||||
@ApiModel(description = "Represents a page of devices.", parent = Page.class)
|
||||
public class DevicePage extends Page<Device> {
|
||||
}
|
||||
@@ -1,214 +0,0 @@
|
||||
package com.mowesta.api.device;
|
||||
|
||||
import javax.annotation.security.PermitAll;
|
||||
import javax.annotation.security.RolesAllowed;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.validation.Valid;
|
||||
import javax.validation.constraints.Min;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import javax.ws.rs.BeanParam;
|
||||
import javax.ws.rs.Consumes;
|
||||
import javax.ws.rs.DELETE;
|
||||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.POST;
|
||||
import javax.ws.rs.PUT;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.PathParam;
|
||||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import javax.ws.rs.core.Response;
|
||||
|
||||
import com.mowesta.api.PageConfig;
|
||||
import com.mowesta.api.Tags;
|
||||
import com.mowesta.api.access.Authorizations;
|
||||
import com.mowesta.api.access.Roles;
|
||||
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import io.swagger.annotations.ApiParam;
|
||||
import io.swagger.annotations.ApiResponse;
|
||||
import io.swagger.annotations.ApiResponses;
|
||||
import io.swagger.annotations.Authorization;
|
||||
|
||||
/**
|
||||
* A service to manage devices.
|
||||
*
|
||||
* @author Ole
|
||||
*/
|
||||
@Api
|
||||
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
|
||||
@Consumes({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
|
||||
@Path("/")
|
||||
public interface IDeviceService {
|
||||
|
||||
// device functions (for the mobile app)
|
||||
|
||||
/**
|
||||
* Creates and returns a new device.
|
||||
*
|
||||
* @param info The device info to create the device.
|
||||
* @return The newly created device.
|
||||
*/
|
||||
@POST
|
||||
@Path("devices")
|
||||
@ApiOperation(value = "Creates a new device and returns its handle.",
|
||||
notes = "The response will include the auth token to be stored on the device and supplied as authentication " +
|
||||
"on all subsequent api calls. Note that the auth token can not be requested after creation, " +
|
||||
"so when losing the auth token you may lose access to the device data.",
|
||||
tags = {Tags.DEFAULT, Tags.DEVICE})
|
||||
@ApiResponses({
|
||||
@ApiResponse(code = HttpServletResponse.SC_CREATED, message = "The device was created successfully.", response = DeviceHandle.class)
|
||||
})
|
||||
@PermitAll
|
||||
Response createDevice(@ApiParam(value = "Necessary data from to create a device.", required = true) @NotNull @Valid DeviceInfo info);
|
||||
|
||||
|
||||
/**
|
||||
* Sets the user account for a previously registered device.
|
||||
*
|
||||
* @param device The device to associate with the user.
|
||||
* @return A response.
|
||||
*/
|
||||
@POST
|
||||
@Path("devices/current/user")
|
||||
@ApiOperation(value = "Connects a device created without user account with a user account.",
|
||||
notes = "Executing this is operation requires a valid device and a valid user authentication to be transmitted simultaneously. ",
|
||||
tags = {Tags.DEFAULT, Tags.DEVICE})
|
||||
@ApiResponses({
|
||||
@ApiResponse(code = HttpServletResponse.SC_FORBIDDEN, message = "The device or user credentials are missing or incorrect."),
|
||||
@ApiResponse(code = HttpServletResponse.SC_CONFLICT, message = "The device is already connected to a user account.", response=Device.class),
|
||||
@ApiResponse(code = HttpServletResponse.SC_OK, message = "The device has been connected to the user account.", response=Device.class),
|
||||
})
|
||||
@PermitAll
|
||||
@RolesAllowed({Roles.DEVICE, Roles.USER})
|
||||
Response setCurrentDeviceUser(@ApiParam(value = "The device data.", required = true)@NotNull @Valid Device device);
|
||||
|
||||
/**
|
||||
* Returns the current device.
|
||||
*
|
||||
* @return The current device.
|
||||
*/
|
||||
@GET
|
||||
@Path("devices/current")
|
||||
@ApiOperation(value = "Returns the current device.", authorizations = {@Authorization(Authorizations.DEVICE)}, tags = {Tags.DEFAULT, Tags.DEVICE})
|
||||
@ApiResponses({
|
||||
@ApiResponse(code = HttpServletResponse.SC_OK, message = "The operation was successful.", response= Device.class),
|
||||
@ApiResponse(code = HttpServletResponse.SC_NOT_FOUND, message = "The device was not found."),
|
||||
@ApiResponse(code = HttpServletResponse.SC_FORBIDDEN, message = "Insufficient privileges for executing this method.")
|
||||
})
|
||||
@RolesAllowed({Roles.DEVICE})
|
||||
Response getCurrentDevice();
|
||||
|
||||
/**
|
||||
* Deletes the current device.
|
||||
*
|
||||
* @return A response code to indicate the success.
|
||||
*/
|
||||
@DELETE
|
||||
@Path("devices/current")
|
||||
@ApiOperation(value = "Deletes the current device.", authorizations = {@Authorization(Authorizations.DEVICE)}, tags = {Tags.DEFAULT, Tags.DEVICE})
|
||||
@ApiResponses({
|
||||
@ApiResponse(code = HttpServletResponse.SC_OK, message = "The device was deleted successfully."),
|
||||
@ApiResponse(code = HttpServletResponse.SC_NOT_FOUND, message = "The device was not found."),
|
||||
@ApiResponse(code = HttpServletResponse.SC_FORBIDDEN, message = "Insufficient privileges for executing this method.")
|
||||
})
|
||||
@RolesAllowed({Roles.DEVICE})
|
||||
Response deleteCurrentDevice();
|
||||
|
||||
// user functions (for the web app)
|
||||
|
||||
/**
|
||||
* Returns a page of devices of the current user.
|
||||
*
|
||||
* @param config The page configuration.
|
||||
* @return The list of devices.
|
||||
*/
|
||||
@GET
|
||||
@Path("users/current/devices")
|
||||
@ApiOperation(value = "Returns the list of devices for the current user.", authorizations = {@Authorization(Authorizations.USER)}, tags = {Tags.DEFAULT, Tags.DEVICE})
|
||||
@ApiResponses({
|
||||
@ApiResponse(code = HttpServletResponse.SC_OK, message = "The list of devices of the current user", response=DevicePage.class),
|
||||
@ApiResponse(code = HttpServletResponse.SC_NOT_FOUND, message = "The device was not found."),
|
||||
@ApiResponse(code = HttpServletResponse.SC_FORBIDDEN, message = "Insufficient privileges for executing this method.")
|
||||
})
|
||||
@RolesAllowed({Roles.USER})
|
||||
Response getCurrentUserDevices(@BeanParam @Valid PageConfig config);
|
||||
|
||||
// mixed admin and user functions
|
||||
|
||||
/**
|
||||
* This method deletes a specific device, including all visits made by the device.
|
||||
*
|
||||
* @param id The id of the device.
|
||||
* @return A response code to indicate the success.
|
||||
*/
|
||||
@DELETE
|
||||
@Path("devices/{id: [0-9]+}")
|
||||
@ApiOperation(value = "Deletes a device and it's visits.", authorizations = {@Authorization(Authorizations.USER), @Authorization(Authorizations.ADMIN)}, tags = {Tags.DEFAULT, Tags.DEVICE})
|
||||
@ApiResponses({
|
||||
@ApiResponse(code = HttpServletResponse.SC_OK, message = "The device was deleted successfully."),
|
||||
@ApiResponse(code = HttpServletResponse.SC_NOT_FOUND, message = "The device does not exists."),
|
||||
@ApiResponse(code = HttpServletResponse.SC_FORBIDDEN, message = "Insufficient privileges for executing this method.")
|
||||
})
|
||||
@RolesAllowed({Roles.USER, Roles.ADMIN})
|
||||
Response deleteDevice(@ApiParam(value = "The device id.", required = true) @PathParam("id") @Valid @Min(0) long id);
|
||||
|
||||
|
||||
/**
|
||||
* Returns a particular device.
|
||||
*
|
||||
* @param id The id of the device.
|
||||
* @return The device, if allowed and available.
|
||||
*/
|
||||
@GET
|
||||
@Path("devices/{id: [0-9]+}")
|
||||
@ApiOperation(value = "Gets a device.", authorizations = {@Authorization(Authorizations.ADMIN), @Authorization(Authorizations.USER)}, tags = {Tags.DEFAULT, Tags.DEVICE})
|
||||
@ApiResponses({
|
||||
@ApiResponse(code = HttpServletResponse.SC_OK, message = "The device returned successfully.", response=Device.class),
|
||||
@ApiResponse(code = HttpServletResponse.SC_NOT_FOUND, message = "The device does not exists."),
|
||||
@ApiResponse(code = HttpServletResponse.SC_FORBIDDEN, message = "Insufficient privileges for executing this method.")
|
||||
})
|
||||
@RolesAllowed({Roles.USER, Roles.ADMIN})
|
||||
Response getDevice(@ApiParam(value = "The device id.", required = true) @PathParam("id") @Valid @Min(0) long id);
|
||||
|
||||
|
||||
// admin functions
|
||||
|
||||
/**
|
||||
* Returns all currently registered devices
|
||||
*
|
||||
* @param pageConfig The page configuration.
|
||||
* @return A list of devices.
|
||||
*/
|
||||
@GET
|
||||
@Path("devices")
|
||||
@ApiOperation(value = "Returns all devices.", authorizations = @Authorization(Authorizations.ADMIN), tags = {Tags.DEFAULT, Tags.DEVICE})
|
||||
@ApiResponses({
|
||||
@ApiResponse(code = HttpServletResponse.SC_OK, message = "The request was successful.", response = DevicePage.class),
|
||||
@ApiResponse(code = HttpServletResponse.SC_FORBIDDEN, message = "Insufficient privileges for retrieval."),
|
||||
@ApiResponse(code = HttpServletResponse.SC_BAD_REQUEST, message = "Invalid request parameter.")
|
||||
})
|
||||
@RolesAllowed({Roles.ADMIN})
|
||||
Response getDevices(@BeanParam @Valid PageConfig pageConfig);
|
||||
|
||||
|
||||
/**
|
||||
* Sets the values of a particular device.
|
||||
*
|
||||
* @param id The id of the device.
|
||||
* @param device The device data.
|
||||
* @return The modified device.
|
||||
*/
|
||||
@PUT
|
||||
@Path("devices/{id: [0-9]+}")
|
||||
@ApiOperation(value = "Sets the values of a device.", authorizations = {@Authorization(Authorizations.ADMIN)}, tags = {Tags.DEFAULT, Tags.DEVICE})
|
||||
@ApiResponses({
|
||||
@ApiResponse(code = HttpServletResponse.SC_OK, message = "The device returned successfully.", response=Device.class),
|
||||
@ApiResponse(code = HttpServletResponse.SC_NOT_FOUND, message = "The device does not exists."),
|
||||
@ApiResponse(code = HttpServletResponse.SC_CONFLICT, message = "The device has been updated in parallel."),
|
||||
@ApiResponse(code = HttpServletResponse.SC_FORBIDDEN, message = "Insufficient privileges for executing this method.")
|
||||
})
|
||||
@RolesAllowed({Roles.ADMIN})
|
||||
Response setDevice(@ApiParam(value = "The device id.", required = true) @PathParam("id") @Valid @Min(0) long id, @ApiParam("The device values.") @Valid @NotNull Device device);
|
||||
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
package com.mowesta.api.location;
|
||||
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
import javax.xml.bind.annotation.XmlSeeAlso;
|
||||
|
||||
import com.mowesta.api.Page;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
|
||||
/**
|
||||
* A page of cities.
|
||||
*
|
||||
* @author Marcus
|
||||
*/
|
||||
@XmlRootElement
|
||||
@XmlSeeAlso(City.class)
|
||||
@ApiModel(description = "Represents a page of cities.", parent = Page.class)
|
||||
public class CityPage extends Page<City> {
|
||||
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
package com.mowesta.api.location;
|
||||
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
|
||||
/**
|
||||
* Represents a country.
|
||||
*
|
||||
* @author Marcus
|
||||
*/
|
||||
@XmlRootElement
|
||||
@ApiModel(description = "Represents a country with all details.", parent = Location.class)
|
||||
public class Country extends Location {
|
||||
|
||||
}
|
||||
@@ -1,312 +0,0 @@
|
||||
package com.mowesta.api.location;
|
||||
|
||||
import javax.annotation.security.PermitAll;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.validation.Valid;
|
||||
import javax.validation.constraints.Min;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import javax.ws.rs.BeanParam;
|
||||
import javax.ws.rs.Consumes;
|
||||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.PathParam;
|
||||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.QueryParam;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import javax.ws.rs.core.Response;
|
||||
|
||||
import org.geojson.Geometry;
|
||||
|
||||
import com.mowesta.api.PageConfig;
|
||||
import com.mowesta.api.SearchContext;
|
||||
import com.mowesta.api.Tags;
|
||||
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import io.swagger.annotations.ApiParam;
|
||||
import io.swagger.annotations.ApiResponse;
|
||||
import io.swagger.annotations.ApiResponses;
|
||||
|
||||
/**
|
||||
* The api to query and fetch locations.
|
||||
*
|
||||
* @author Marcus
|
||||
*/
|
||||
@Api
|
||||
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
|
||||
@Consumes({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
|
||||
@Path("/")
|
||||
public interface ILocationService {
|
||||
|
||||
/**
|
||||
* Returns a page of locations that match the query.
|
||||
*
|
||||
* @param pageConfig The page configuration.
|
||||
* @param context The search context.
|
||||
* @param term The search term.
|
||||
* @return A page of hierarchically organized locations that match
|
||||
* the query.
|
||||
*/
|
||||
@GET
|
||||
@Path("locations/search")
|
||||
@ApiOperation(value = "Returns a page of locations whose name matches the term.", tags = { Tags.DEFAULT, Tags.LOCATION })
|
||||
@ApiResponses({
|
||||
@ApiResponse(code=HttpServletResponse.SC_OK, message="Location hierarchy page retrieved successfully.", response=LocationHierarchyPage.class),
|
||||
@ApiResponse(code=HttpServletResponse.SC_BAD_REQUEST, message="Invalid request parameter.")
|
||||
})
|
||||
@PermitAll
|
||||
Response searchLocations(@BeanParam @Valid PageConfig pageConfig, @BeanParam @Valid SearchContext context,
|
||||
@ApiParam(value="The search term.", required=true) @QueryParam("term") @NotNull @Valid String term);
|
||||
|
||||
/**
|
||||
* Searches for a particular city by name.
|
||||
*
|
||||
* @param pageConfig The page configuration.
|
||||
* @param context The search context.
|
||||
* @param term The search term.
|
||||
* @return The page of cities.
|
||||
*/
|
||||
@GET
|
||||
@Path("cities/search")
|
||||
@ApiOperation(value = "Returns a page of cities that match the specified search term.", tags = { Tags.DEFAULT, Tags.LOCATION })
|
||||
@ApiResponses({
|
||||
@ApiResponse(code=HttpServletResponse.SC_OK, message="The page of cities.", response=CityPage.class),
|
||||
@ApiResponse(code=HttpServletResponse.SC_BAD_REQUEST, message="Invalid request parameter.")
|
||||
})
|
||||
@PermitAll
|
||||
Response searchCities(@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 cities that are inside a particular area defined by two coordinates.
|
||||
*
|
||||
* @param pageConfig The page configuration.
|
||||
* @param longitude1 The longitude of the first coordinate.
|
||||
* @param latitude1 The latitude of the first coordinate.
|
||||
* @param longitude2 The longitude of the second coordinate.
|
||||
* @param latitude2 The latitude of the second coordinate.
|
||||
* @return The page of cities.
|
||||
*/
|
||||
@GET
|
||||
@Path("cities/resolve")
|
||||
@ApiOperation(value = "Returns a page of cities within a certain area defined by two coordiantes.", tags = { Tags.DEFAULT, Tags.LOCATION })
|
||||
@ApiResponses({
|
||||
@ApiResponse(code=HttpServletResponse.SC_OK, message="The page of cities.", response=CityPage.class),
|
||||
@ApiResponse(code=HttpServletResponse.SC_BAD_REQUEST, message="Invalid request parameter.")
|
||||
})
|
||||
@PermitAll
|
||||
Response resolveCities(@BeanParam @Valid PageConfig pageConfig,
|
||||
@ApiParam(value = "The longitude of the first coordinate.", required = true) @QueryParam("longitude1") double longitude1,
|
||||
@ApiParam(value = "The latitude of the first coordinate.", required = true) @QueryParam("latitude1") double latitude1,
|
||||
@ApiParam(value = "The longitude of the second coordinate.", required = true) @QueryParam("longitude2") double longitude2,
|
||||
@ApiParam(value = "The latitude of the second coordinate.", required = true) @QueryParam("latitude2") double latitude2);
|
||||
|
||||
/**
|
||||
* Returns a page of cities.
|
||||
*
|
||||
* @param pageConfig The page configuration.
|
||||
* @return A page of cities.
|
||||
*/
|
||||
@GET
|
||||
@Path("cities")
|
||||
@ApiOperation(value = "Returns a page of cities.", tags = { Tags.DEFAULT, Tags.LOCATION })
|
||||
@ApiResponses({
|
||||
@ApiResponse(code=HttpServletResponse.SC_OK, message="City page retrieved successfully.", response=CityPage.class),
|
||||
@ApiResponse(code=HttpServletResponse.SC_BAD_REQUEST, message="Invalid request parameter.")
|
||||
})
|
||||
@PermitAll
|
||||
Response getCities(@BeanParam @Valid PageConfig pageConfig);
|
||||
|
||||
/**
|
||||
* Returns a particular city.
|
||||
*
|
||||
* @param id The id of the city.
|
||||
* @return The city, if exits.
|
||||
*/
|
||||
@GET
|
||||
@Path("cities/{id: [0-9]+}")
|
||||
@ApiOperation(value = "Gets a city with a particular id.", tags = {Tags.DEFAULT, Tags.LOCATION})
|
||||
@ApiResponses({
|
||||
@ApiResponse(code = HttpServletResponse.SC_OK, message = "City retrieved successfully.", response=City.class),
|
||||
@ApiResponse(code = HttpServletResponse.SC_NOT_FOUND, message = "The city does not exists."),
|
||||
})
|
||||
@PermitAll
|
||||
Response getCity(@ApiParam(value = "The city id.", required = true) @PathParam("id") @Valid @Min(0) long id);
|
||||
|
||||
/**
|
||||
* Returns a geojson representation of the city boundaries.
|
||||
*
|
||||
* @param id The id of the city.
|
||||
* @return The boundaries of geojson or an error code.
|
||||
*/
|
||||
@GET
|
||||
@Path("cities/{id: [0-9]+}/boundary")
|
||||
@ApiOperation(value = "Gets the city boundary for a city with a particular id.", tags = {Tags.DEFAULT, Tags.LOCATION})
|
||||
@ApiResponses({
|
||||
@ApiResponse(code = HttpServletResponse.SC_OK, message = "City boundary retrieved successfully.", response=Geometry.class),
|
||||
@ApiResponse(code = HttpServletResponse.SC_NO_CONTENT, message = "The city boundary are not available."),
|
||||
@ApiResponse(code = HttpServletResponse.SC_NOT_FOUND, message = "The city does not exist."),
|
||||
})
|
||||
@PermitAll
|
||||
@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.
|
||||
*
|
||||
* @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 as geojson or an error code.
|
||||
*/
|
||||
@GET
|
||||
@Path("states/{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);
|
||||
|
||||
/**
|
||||
* The deprecated version of the method that has a typo in the path name (state instead of states).
|
||||
* To be removed, if Android Apps < V14 are no longer present.
|
||||
*
|
||||
* @param id The id of the state.
|
||||
* @return The boundaries as geojson or an error code.
|
||||
*/
|
||||
@GET
|
||||
@Path("state/{id: [0-9]+}/boundary")
|
||||
@ApiOperation(value = "Deprecated: 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})
|
||||
@Deprecated
|
||||
Response getStateBoundaryDeprecated(@ApiParam(value = "The state id.", required = true) @PathParam("id") @Valid @Min(0) long id);
|
||||
|
||||
|
||||
/**
|
||||
* Returns a page of cities for a state ordered by importance.
|
||||
*
|
||||
* @param id The id of the state.
|
||||
* @param pageConfig The page configuration.
|
||||
* @return The page of cities.
|
||||
*/
|
||||
@GET
|
||||
@Path("states/{id: [0-9]+}/cities")
|
||||
@ApiOperation(value = "Gets a page of cities for a particular state ordered by importance.", tags = {Tags.DEFAULT, Tags.LOCATION})
|
||||
@ApiResponses({
|
||||
@ApiResponse(code = HttpServletResponse.SC_OK, message = "Cities retrieved successfully.", response=CityPage.class),
|
||||
@ApiResponse(code = HttpServletResponse.SC_NOT_FOUND, message = "The state does not exists."),
|
||||
})
|
||||
@PermitAll
|
||||
Response getStateCities(@ApiParam(value = "The state id.", required = true) @PathParam("id") @Valid @Min(0) long id, @BeanParam @Valid PageConfig pageConfig);
|
||||
|
||||
/**
|
||||
* Returns a page of countries.
|
||||
*
|
||||
* @param pageConfig The page configuration.
|
||||
* @return A page of countries.
|
||||
*/
|
||||
@GET
|
||||
@Path("countries")
|
||||
@ApiOperation(value = "Returns a page of countries.", tags = { Tags.DEFAULT, Tags.LOCATION })
|
||||
@ApiResponses({
|
||||
@ApiResponse(code=HttpServletResponse.SC_OK, message="Country page retrieved successfully.", response=CountryPage.class),
|
||||
@ApiResponse(code=HttpServletResponse.SC_BAD_REQUEST, message="Invalid request parameter.")
|
||||
})
|
||||
@PermitAll
|
||||
Response getCountries(@BeanParam @Valid PageConfig pageConfig);
|
||||
|
||||
/**
|
||||
* Returns a particular country.
|
||||
*
|
||||
* @param id The id of the country.
|
||||
* @return The country, if exits.
|
||||
*/
|
||||
@GET
|
||||
@Path("countries/{id: [0-9]+}")
|
||||
@ApiOperation(value = "Gets a country with a particular id.", tags = {Tags.DEFAULT, Tags.LOCATION})
|
||||
@ApiResponses({
|
||||
@ApiResponse(code = HttpServletResponse.SC_OK, message = "Country retrieved successfully.", response=Country.class),
|
||||
@ApiResponse(code = HttpServletResponse.SC_NOT_FOUND, message = "The country does not exists."),
|
||||
})
|
||||
@PermitAll
|
||||
Response getCountry(@ApiParam(value = "The country id.", required = true) @PathParam("id") @Valid @Min(0) long id);
|
||||
|
||||
/**
|
||||
* Returns a geojson representation of the country boundaries.
|
||||
*
|
||||
* @param id The id of the country.
|
||||
* @return The boundaries of geojson or an error code.
|
||||
*/
|
||||
@GET
|
||||
@Path("countries/{id: [0-9]+}/boundary")
|
||||
@ApiOperation(value = "Gets the country boundary for a country with a particular id.", tags = {Tags.DEFAULT, Tags.LOCATION})
|
||||
@ApiResponses({
|
||||
@ApiResponse(code = HttpServletResponse.SC_OK, message = "Country boundary retrieved successfully.", response=Geometry.class),
|
||||
@ApiResponse(code = HttpServletResponse.SC_NO_CONTENT, message = "The country boundary are not available."),
|
||||
@ApiResponse(code = HttpServletResponse.SC_NOT_FOUND, message = "The country does not exist."),
|
||||
})
|
||||
@PermitAll
|
||||
@Produces({MediaType.APPLICATION_JSON})
|
||||
Response getCountryBoundary(@ApiParam(value = "The country id.", required = true) @PathParam("id") @Valid @Min(0) long id);
|
||||
|
||||
/**
|
||||
* Returns a page of cities for a country ordered by importance.
|
||||
*
|
||||
* @param id The id of the country.
|
||||
* @param pageConfig The page configuration.
|
||||
* @return The page of cities.
|
||||
*/
|
||||
@GET
|
||||
@Path("countries/{id: [0-9]+}/cities")
|
||||
@ApiOperation(value = "Gets a page of cities for a particular country ordered by importance.", tags = {Tags.DEFAULT, Tags.LOCATION})
|
||||
@ApiResponses({
|
||||
@ApiResponse(code = HttpServletResponse.SC_OK, message = "Cities retrieved successfully.", response=CityPage.class),
|
||||
@ApiResponse(code = HttpServletResponse.SC_NOT_FOUND, message = "The country does not exists."),
|
||||
})
|
||||
@PermitAll
|
||||
Response getCountryCities(@ApiParam(value = "The country id.", required = true) @PathParam("id") @Valid @Min(0) long id, @BeanParam @Valid PageConfig pageConfig);
|
||||
|
||||
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
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> {
|
||||
|
||||
}
|
||||
@@ -1,101 +0,0 @@
|
||||
package com.mowesta.api.log;
|
||||
|
||||
import javax.annotation.security.RolesAllowed;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.validation.Valid;
|
||||
import javax.validation.constraints.Min;
|
||||
import javax.ws.rs.DefaultValue;
|
||||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.QueryParam;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import javax.ws.rs.core.Response;
|
||||
|
||||
import com.mowesta.api.Tags;
|
||||
import com.mowesta.api.access.Authorizations;
|
||||
import com.mowesta.api.access.Roles;
|
||||
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import io.swagger.annotations.ApiParam;
|
||||
import io.swagger.annotations.ApiResponse;
|
||||
import io.swagger.annotations.ApiResponses;
|
||||
import io.swagger.annotations.Authorization;
|
||||
|
||||
/**
|
||||
* A service that allows polling for log messages. A more
|
||||
* efficient implementation based on websockets is provided
|
||||
* via the "/log/stream" endpoint.
|
||||
*
|
||||
* @author Marcus
|
||||
*/
|
||||
@Api
|
||||
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
|
||||
@Path("/")
|
||||
public interface ILogService {
|
||||
|
||||
/**
|
||||
* Returns a list of log messages starting from a particular id.
|
||||
*
|
||||
* @param from The id to start from.
|
||||
* @return The list of log messages, which might be empty.
|
||||
*/
|
||||
@GET
|
||||
@Path("log/messages")
|
||||
@ApiOperation(value = "Returns a list of log messages starting from a particular id.", authorizations= { @Authorization(value=Authorizations.ADMIN) }, tags = { Tags.DEFAULT, Tags.SERVICE })
|
||||
@RolesAllowed({Roles.ADMIN})
|
||||
@ApiResponses({
|
||||
@ApiResponse(code=HttpServletResponse.SC_OK, message="Log messages retrieved successfully.", response=LogMessage.class, responseContainer="List"),
|
||||
@ApiResponse(code=HttpServletResponse.SC_FORBIDDEN, message="Insufficient privileges for retrieval."),
|
||||
@ApiResponse(code=HttpServletResponse.SC_BAD_REQUEST, message="Invalid request parameter.")
|
||||
})
|
||||
Response getLogMessages(@QueryParam("from") @DefaultValue("0")
|
||||
@ApiParam(value="The id of the first message to retrieve.") @Valid @Min(0) long from);
|
||||
|
||||
/**
|
||||
* Returns a list of entity statistics for all entities.
|
||||
*
|
||||
* @return The list of entity statistics.
|
||||
*/
|
||||
@GET
|
||||
@Path("log/entities")
|
||||
@ApiOperation(value = "Returns a list of entity statistics.", authorizations= { @Authorization(value=Authorizations.ADMIN) }, tags = { Tags.DEFAULT, Tags.SERVICE })
|
||||
@RolesAllowed({Roles.ADMIN})
|
||||
@ApiResponses({
|
||||
@ApiResponse(code=HttpServletResponse.SC_OK, message="Entity statistics retrieved successfully.", response=EntityStatistic.class, responseContainer="List"),
|
||||
@ApiResponse(code=HttpServletResponse.SC_FORBIDDEN, message="Insufficient privileges for retrieval.")
|
||||
})
|
||||
Response getEntityStatistics();
|
||||
|
||||
|
||||
/**
|
||||
* Returns the current load statistic.
|
||||
*
|
||||
* @return The load statistic.
|
||||
*/
|
||||
@GET
|
||||
@Path("log/load")
|
||||
@ApiOperation(value = "Returns the current load statistic.", authorizations= { @Authorization(value=Authorizations.ADMIN) }, tags = { Tags.DEFAULT, Tags.SERVICE })
|
||||
@RolesAllowed({Roles.ADMIN})
|
||||
@ApiResponses({
|
||||
@ApiResponse(code=HttpServletResponse.SC_OK, message="Load statistic retrieved successfully.", response=LoadStatistic.class),
|
||||
@ApiResponse(code=HttpServletResponse.SC_FORBIDDEN, message="Insufficient privileges for retrieval.")
|
||||
})
|
||||
Response getLoadStatistic();
|
||||
|
||||
/**
|
||||
* Returns the system statistic.
|
||||
*
|
||||
* @return The system statistic.
|
||||
*/
|
||||
@GET
|
||||
@Path("log/system")
|
||||
@ApiOperation(value = "Returns the system statistic.", authorizations= { @Authorization(value=Authorizations.ADMIN) }, tags = { Tags.DEFAULT, Tags.SERVICE }) @RolesAllowed({Roles.ADMIN})
|
||||
@ApiResponses({
|
||||
@ApiResponse(code=HttpServletResponse.SC_OK, message="System statistic retrieved successfully.", response=SystemStatistic.class),
|
||||
@ApiResponse(code=HttpServletResponse.SC_FORBIDDEN, message="Insufficient privileges for retrieval.")
|
||||
})
|
||||
Response getSystemStatistic();
|
||||
|
||||
}
|
||||
@@ -1,133 +0,0 @@
|
||||
package com.mowesta.api.measurement;
|
||||
|
||||
import javax.annotation.security.RolesAllowed;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.validation.Valid;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import javax.ws.rs.BeanParam;
|
||||
import javax.ws.rs.Consumes;
|
||||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.POST;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.PathParam;
|
||||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import javax.ws.rs.core.Response;
|
||||
|
||||
import com.mowesta.api.PageConfig;
|
||||
import com.mowesta.api.Tags;
|
||||
import com.mowesta.api.TimeRange;
|
||||
import com.mowesta.api.access.Authorizations;
|
||||
import com.mowesta.api.access.Roles;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import io.swagger.annotations.ApiParam;
|
||||
import io.swagger.annotations.ApiResponse;
|
||||
import io.swagger.annotations.ApiResponses;
|
||||
import io.swagger.annotations.Authorization;
|
||||
|
||||
/**
|
||||
* A service to manage measurements.
|
||||
*
|
||||
* @author Sebastian
|
||||
*/
|
||||
@Api
|
||||
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
|
||||
@Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
|
||||
@Path("/")
|
||||
public interface IMeasurementService {
|
||||
|
||||
/**
|
||||
* Adds one or more measurement for device. By supporting multiple
|
||||
* measurements, we can allow batch processing which reduces the
|
||||
* communication overhead when supporting offline synchronization.
|
||||
*
|
||||
* @param measurements The list of measurements to add.
|
||||
* @return An batch with the measurements that has been accepted.
|
||||
*/
|
||||
@POST
|
||||
@Path("devices/current/measurements")
|
||||
@ApiOperation(value = "Adds a number of measurements for the current device.", authorizations = {
|
||||
@Authorization(Authorizations.DEVICE) }, tags = { Tags.DEFAULT, Tags.DEVICE })
|
||||
@ApiResponses({
|
||||
@ApiResponse(code = HttpServletResponse.SC_OK, message = "Measurements added successfully."),
|
||||
@ApiResponse(code = HttpServletResponse.SC_FORBIDDEN, message = "No valid authorization found.") })
|
||||
@RolesAllowed({ Roles.DEVICE })
|
||||
Response addCurrentDeviceMeasurements(@ApiParam(value = "The new measurements to add.", required = true) @Valid @NotNull List<Measurement> measurements);
|
||||
|
||||
/**
|
||||
* Adds a single measurement for a device that has been captured now. In contrast
|
||||
* to the batch method, this method will automatically set the measurement's time
|
||||
* stamp to the server time.
|
||||
*
|
||||
* @param measurement The measurement to add.
|
||||
* @return The measurement, if successful.
|
||||
*/
|
||||
@POST
|
||||
@Path("devices/current/measurements/now")
|
||||
@ApiOperation(value = "Adds a single measurement for the device that has been captured recently.", authorizations = {
|
||||
@Authorization(Authorizations.DEVICE) }, tags = { Tags.DEFAULT, Tags.DEVICE })
|
||||
@ApiResponses({
|
||||
@ApiResponse(code = HttpServletResponse.SC_OK, message = "Measurement added successfully.", response = Measurement.class),
|
||||
@ApiResponse(code = HttpServletResponse.SC_FORBIDDEN, message = "No valid authorization found.") })
|
||||
@RolesAllowed({ Roles.DEVICE })
|
||||
Response addCurrentDeviceMeasurement(@ApiParam(value = "The new measurement to add.", required = true) @Valid @NotNull Measurement measurement);
|
||||
|
||||
|
||||
/**
|
||||
* Returns a page with measurements of the current device from a certain time range.
|
||||
*
|
||||
* @param pageConfig The page configuration.
|
||||
* @param timeRange The time range.
|
||||
* @return The page of measurements.
|
||||
*/
|
||||
@GET
|
||||
@Path("devices/current/measurements")
|
||||
@ApiOperation(value = "Returns a page of measurements of the current device from a certain time range.", authorizations = {
|
||||
@Authorization(Authorizations.DEVICE) }, tags = { Tags.DEFAULT, Tags.DEVICE })
|
||||
@ApiResponses({
|
||||
@ApiResponse(code = HttpServletResponse.SC_OK, message = "Measurements retrieved successfully.", response = MeasurementPage.class),
|
||||
@ApiResponse(code = HttpServletResponse.SC_FORBIDDEN, message = "Insufficient privileges to retrieve the measurements.") })
|
||||
@RolesAllowed({ Roles.DEVICE })
|
||||
Response getCurrentDeviceMeasurements(@BeanParam @Valid TimeRange timeRange, @BeanParam @Valid PageConfig pageConfig);
|
||||
|
||||
/**
|
||||
* Returns a page of measurements of the specified device from a certain time range.
|
||||
*
|
||||
* @param id The id of the device.
|
||||
* @param timeRange The time range.
|
||||
* @param pageConfig The page config.
|
||||
* @return The page of measurements.
|
||||
*/
|
||||
@GET
|
||||
@Path("devices/{id: ([0-9])+}/measurements")
|
||||
@ApiOperation(value = "Returns a page of measurements of a specific device from a certain time range.",authorizations = {
|
||||
@Authorization(Authorizations.USER), @Authorization(Authorizations.ADMIN) }, tags = { Tags.DEFAULT, Tags.DEVICE })
|
||||
@ApiResponses({
|
||||
@ApiResponse(code = HttpServletResponse.SC_OK, message = "Measurements retrieved successfully.", response = MeasurementPage.class),
|
||||
@ApiResponse(code = HttpServletResponse.SC_NOT_FOUND, message = "The measurements were not found."),
|
||||
@ApiResponse(code = HttpServletResponse.SC_FORBIDDEN, message = "Insufficient privileges to retrieve the measurements.") })
|
||||
@RolesAllowed({ Roles.USER, Roles.ADMIN })
|
||||
Response getDeviceMeasurements(@ApiParam(value = "The device id.", required = true) @PathParam("id") long id, @BeanParam @Valid TimeRange timeRange, @BeanParam @Valid PageConfig pageConfig);
|
||||
|
||||
|
||||
/**
|
||||
* Returns a page of measurements of all devices within a certain time range.
|
||||
*
|
||||
* @param timeRange The time range.
|
||||
* @param pageConfig The page config.
|
||||
* @return The page of measurements.
|
||||
*/
|
||||
@GET
|
||||
@Path("devices/measurements")
|
||||
@ApiOperation(value = "Returns a page of measurements of all devices within a certain time range.",
|
||||
authorizations = { @Authorization(Authorizations.ADMIN) }, tags = { Tags.DEFAULT, Tags.DEVICE })
|
||||
@ApiResponses({
|
||||
@ApiResponse(code = HttpServletResponse.SC_OK, message = "Measurements retrieved successfully.", response = MeasurementPage.class),
|
||||
@ApiResponse(code = HttpServletResponse.SC_FORBIDDEN, message = "Insufficient privileges to retrieve the measurements.") })
|
||||
@RolesAllowed({ Roles.ADMIN })
|
||||
Response getAllMeasurementsByRange(@BeanParam @Valid TimeRange timeRange, @BeanParam @Valid PageConfig pageConfig);
|
||||
}
|
||||
@@ -1,93 +0,0 @@
|
||||
package com.mowesta.api.settings;
|
||||
|
||||
import javax.annotation.security.RolesAllowed;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.validation.Valid;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import javax.ws.rs.Consumes;
|
||||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.PUT;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import javax.ws.rs.core.Response;
|
||||
|
||||
import com.mowesta.api.Tags;
|
||||
import com.mowesta.api.access.Authorizations;
|
||||
import com.mowesta.api.access.Roles;
|
||||
import com.mowesta.api.location.LocationHierarchy;
|
||||
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import io.swagger.annotations.ApiParam;
|
||||
import io.swagger.annotations.ApiResponse;
|
||||
import io.swagger.annotations.ApiResponses;
|
||||
import io.swagger.annotations.Authorization;
|
||||
|
||||
/**
|
||||
* A service to manage shared settings.
|
||||
*
|
||||
* @author Marcus
|
||||
*/
|
||||
@Api
|
||||
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
|
||||
@Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
|
||||
@Path("/")
|
||||
public interface ISettingsService {
|
||||
|
||||
|
||||
/**
|
||||
* Returns the settings of the user.
|
||||
*
|
||||
* @return The settings of the user.
|
||||
*/
|
||||
@GET
|
||||
@Path("users/current/settings")
|
||||
@ApiOperation(value = "Returns the setting of the current user.", authorizations = { @Authorization(Authorizations.USER) }, tags = { Tags.DEFAULT, Tags.SETTINGS })
|
||||
@ApiResponses({
|
||||
@ApiResponse(code = HttpServletResponse.SC_OK, message = "The request was successful.", response = Settings.class),
|
||||
@ApiResponse(code = HttpServletResponse.SC_FORBIDDEN, message = "Insufficient privileges to access the user's settings."),
|
||||
})
|
||||
@RolesAllowed({Roles.USER})
|
||||
Response getCurrentUserSettings();
|
||||
|
||||
/**
|
||||
* Returns the favorite locations of the user.
|
||||
*
|
||||
* @return The favorite locations of the user.
|
||||
*/
|
||||
@GET
|
||||
@Path("users/current/locations")
|
||||
@ApiOperation(value = "Returns the favorite locations of the current user.", authorizations = { @Authorization(Authorizations.USER) }, tags = { Tags.DEFAULT, Tags.SETTINGS })
|
||||
@ApiResponses({
|
||||
@ApiResponse(code = HttpServletResponse.SC_OK, message = "The request was successful.", response = LocationHierarchy.class, responseContainer = "List"),
|
||||
@ApiResponse(code = HttpServletResponse.SC_FORBIDDEN, message = "Insufficient privileges to access the user's locations."),
|
||||
})
|
||||
@RolesAllowed({Roles.USER})
|
||||
Response getCurrentUserLocations();
|
||||
|
||||
/**
|
||||
* Sets a user's settings.
|
||||
*
|
||||
* @param settings The settings to set.
|
||||
* @return The updated settings.
|
||||
*/
|
||||
@PUT
|
||||
@Path("users/current/settings")
|
||||
@ApiOperation(value = "Updates the settings of the current user.", authorizations = { @Authorization(Authorizations.USER) }, tags = { Tags.DEFAULT, Tags.SETTINGS })
|
||||
@ApiResponses({
|
||||
@ApiResponse(code = HttpServletResponse.SC_OK, message = "User settings updated succesfully.", response=Settings.class),
|
||||
@ApiResponse(code = HttpServletResponse.SC_CONFLICT, message = "Conflict due to parallel update.", response=Settings.class),
|
||||
@ApiResponse(code = HttpServletResponse.SC_BAD_REQUEST, message = "Invalid request parameters."),
|
||||
@ApiResponse(code = HttpServletResponse.SC_FORBIDDEN, message = "Insufficient privileges to access the user's settings.")
|
||||
})
|
||||
@RolesAllowed({Roles.USER})
|
||||
Response setCurrentUserSettings(@Valid @NotNull @ApiParam(value = "The settings to set.") Settings settings);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,309 +0,0 @@
|
||||
package com.mowesta.api.user;
|
||||
|
||||
import javax.annotation.security.PermitAll;
|
||||
import javax.annotation.security.RolesAllowed;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.validation.Valid;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import javax.ws.rs.PathParam;
|
||||
import javax.ws.rs.BeanParam;
|
||||
import javax.ws.rs.Consumes;
|
||||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.POST;
|
||||
import javax.ws.rs.PUT;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.QueryParam;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import javax.ws.rs.core.Response;
|
||||
|
||||
import com.mowesta.api.PageConfig;
|
||||
import com.mowesta.api.Tags;
|
||||
import com.mowesta.api.access.Authorizations;
|
||||
import com.mowesta.api.access.Roles;
|
||||
import com.mowesta.api.validation.EmailGroup;
|
||||
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import io.swagger.annotations.ApiParam;
|
||||
import io.swagger.annotations.ApiResponse;
|
||||
import io.swagger.annotations.ApiResponses;
|
||||
import io.swagger.annotations.Authorization;
|
||||
|
||||
/**
|
||||
* A service to manage users.
|
||||
*
|
||||
* @author Marcus
|
||||
*/
|
||||
@Api
|
||||
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
|
||||
@Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
|
||||
@Path("/")
|
||||
public interface IUserService {
|
||||
|
||||
// login functions
|
||||
|
||||
/**
|
||||
* Returns the user that is associated with a device.
|
||||
*
|
||||
* @return The user that is associated with a device.
|
||||
*/
|
||||
@GET
|
||||
@Path("devices/current/user")
|
||||
@ApiOperation(value = "Returns the user that is associated with a device.", authorizations= { @Authorization(Authorizations.USER) }, tags = { Tags.DEFAULT, Tags.USER })
|
||||
@ApiResponses({
|
||||
@ApiResponse(code=HttpServletResponse.SC_OK, message="User retrieved successfully.", response=User.class),
|
||||
@ApiResponse(code=HttpServletResponse.SC_NO_CONTENT, message="Device is not associated with a user."),
|
||||
@ApiResponse(code=HttpServletResponse.SC_FORBIDDEN, message="No valid authorization found.")
|
||||
})
|
||||
@RolesAllowed({Roles.DEVICE})
|
||||
Response getCurrentDeviceUser();
|
||||
|
||||
/**
|
||||
* Returns the user that is authorized.
|
||||
*
|
||||
* @return The user that is currently authorized.
|
||||
*/
|
||||
@GET
|
||||
@Path("users/current")
|
||||
@ApiOperation(value = "Returns the user currently authorized.", authorizations= { @Authorization(Authorizations.USER) }, tags = { Tags.DEFAULT, Tags.USER })
|
||||
@ApiResponses({
|
||||
@ApiResponse(code=HttpServletResponse.SC_OK, message="User retrieved successfully.", response=User.class),
|
||||
@ApiResponse(code=HttpServletResponse.SC_FORBIDDEN, message="No valid authorization found.")
|
||||
})
|
||||
@RolesAllowed({Roles.USER})
|
||||
Response getCurrentUser();
|
||||
|
||||
/**
|
||||
* Updates the current user. A regular user can add and delete an email, change the
|
||||
* correspondence email to any of the verified emails and change the name.
|
||||
*
|
||||
* @param user The user to modify.
|
||||
* @return The updated user, if successful.
|
||||
*/
|
||||
@PUT
|
||||
@Path("users/current")
|
||||
@ApiOperation(value = "Updates the currently authorized user.", authorizations= { @Authorization(Authorizations.USER) }, tags = { Tags.DEFAULT, Tags.USER })
|
||||
@ApiResponses({
|
||||
@ApiResponse(code=HttpServletResponse.SC_OK, message="User updated successfully.", response=User.class),
|
||||
@ApiResponse(code=HttpServletResponse.SC_CONFLICT, message="User modified in parallel.", response=User.class),
|
||||
@ApiResponse(code=HttpServletResponse.SC_FORBIDDEN, message="No valid authorization found."),
|
||||
@ApiResponse(code=HttpServletResponse.SC_BAD_REQUEST, message="Invalid user.")
|
||||
})
|
||||
@RolesAllowed({Roles.USER})
|
||||
Response setCurrentUser(@ApiParam(value="The new user values to set.", required=true) @Valid @EmailGroup(requireVerifiedCorrespondence=true) User user);
|
||||
|
||||
/**
|
||||
* Changes the password of the user that is currently
|
||||
* logged in.
|
||||
*
|
||||
* @param password The password.
|
||||
* @return The user if successful, an error code otherwise.
|
||||
*/
|
||||
@PUT
|
||||
@Path("users/current/password")
|
||||
@ApiOperation(value="Sets the password of the currently authorized user.", authorizations= { @Authorization(Authorizations.USER) }, tags = { Tags.DEFAULT, Tags.USER })
|
||||
@RolesAllowed({Roles.USER})
|
||||
@ApiResponses({
|
||||
@ApiResponse(code=HttpServletResponse.SC_OK, message="Password updated successfully.", response=User.class),
|
||||
@ApiResponse(code=HttpServletResponse.SC_FORBIDDEN, message="No valid authorization found."),
|
||||
@ApiResponse(code=HttpServletResponse.SC_BAD_REQUEST, message="Invalid password.")
|
||||
})
|
||||
Response setCurrentPassword(@ApiParam(value="The new password to set.", required=true) @Valid UserPassword password);
|
||||
|
||||
|
||||
// admin functions
|
||||
|
||||
/**
|
||||
* Adds a particular user.
|
||||
*
|
||||
* @param user The new data of the user.
|
||||
* @return The updated user, if successful.
|
||||
*/
|
||||
@POST
|
||||
@Path("users")
|
||||
@ApiOperation(value = "Adds a user account with the specified roles and emails.", authorizations= { @Authorization(Authorizations.ADMIN) }, tags = { Tags.DEFAULT, Tags.USER })
|
||||
@RolesAllowed({Roles.ADMIN})
|
||||
@ApiResponses({
|
||||
@ApiResponse(code=HttpServletResponse.SC_CREATED, message="User added successfully.", response=User.class),
|
||||
@ApiResponse(code=HttpServletResponse.SC_CONFLICT, message="User login exists already."),
|
||||
@ApiResponse(code=HttpServletResponse.SC_BAD_REQUEST, message="Invalid user."),
|
||||
@ApiResponse(code=HttpServletResponse.SC_FORBIDDEN, message="Insufficient privileges to add the user.")
|
||||
})
|
||||
Response addUser(@ApiParam(value="The data for the new user.", required=true) @Valid @EmailGroup User user);
|
||||
|
||||
|
||||
/**
|
||||
* Returns the user with the specified id. This method requires admin
|
||||
* privileges.
|
||||
*
|
||||
* @param id The id to retrieve.
|
||||
* @return The user with the specified id.
|
||||
*/
|
||||
@GET
|
||||
@Path("users/{id: ([0-9])+}")
|
||||
@ApiOperation(value = "Returns the user account with the specified id.", authorizations= { @Authorization(Authorizations.ADMIN) }, tags = { Tags.DEFAULT, Tags.USER })
|
||||
@RolesAllowed({Roles.ADMIN})
|
||||
@ApiResponses({
|
||||
@ApiResponse(code=HttpServletResponse.SC_OK, message="User retrieved successfully.", response=User.class),
|
||||
@ApiResponse(code=HttpServletResponse.SC_FORBIDDEN, message="Insufficient privileges to retrieve the user.")
|
||||
})
|
||||
Response getUser(@ApiParam(value="The id of the user to retrieve.", required=true) @PathParam("id") long id);
|
||||
|
||||
/**
|
||||
* Updates a user. This method is only accessible to admins.
|
||||
* In addition to the modifications allowed by setCurrentUser,
|
||||
* this method will also allow the manual verification of
|
||||
* emails.
|
||||
*
|
||||
* @param id The id of the user.
|
||||
* @param user The new data of the user.
|
||||
* @return The updated user, if successful.
|
||||
*/
|
||||
@PUT
|
||||
@Path("users/{id: ([0-9])+}")
|
||||
@ApiOperation(value = "Updates the values of a particular user account.", authorizations= { @Authorization(Authorizations.ADMIN) }, tags = { Tags.DEFAULT, Tags.USER })
|
||||
@RolesAllowed({Roles.ADMIN})
|
||||
@ApiResponses({
|
||||
@ApiResponse(code=HttpServletResponse.SC_OK, message="User updated successfully.", response=User.class),
|
||||
@ApiResponse(code=HttpServletResponse.SC_CONFLICT, message="User modified in parallel.", response=User.class),
|
||||
@ApiResponse(code=HttpServletResponse.SC_FORBIDDEN, message="Insufficient privileges to retrieve the user."),
|
||||
@ApiResponse(code=HttpServletResponse.SC_BAD_REQUEST, message="Invalid user.")
|
||||
})
|
||||
Response setUser(@ApiParam(value="The id of the user to set.", required=true) @PathParam("id") long id, @ApiParam(value="The new user data to set.", required=true) @Valid @EmailGroup User user);
|
||||
|
||||
/**
|
||||
* Changes the password of a user. The accessible users
|
||||
* depend on the role of the user. This method is only
|
||||
* accessible to admins.
|
||||
*
|
||||
* @param id The user id.
|
||||
* @param password The credentials.
|
||||
* @return The user if successful, an error code otherwise.
|
||||
*/
|
||||
@PUT
|
||||
@Path("users/{id: ([0-9])+}/password")
|
||||
@ApiOperation(value="Sets the password of a user.", authorizations= { @Authorization(Authorizations.ADMIN) }, tags = { Tags.DEFAULT, Tags.USER })
|
||||
@RolesAllowed({Roles.ADMIN})
|
||||
@ApiResponses({
|
||||
@ApiResponse(code=HttpServletResponse.SC_OK, message="Password updated successfully.", response=User.class),
|
||||
@ApiResponse(code=HttpServletResponse.SC_FORBIDDEN, message="Password modification not allowed."),
|
||||
@ApiResponse(code=HttpServletResponse.SC_BAD_REQUEST, message="Invalid password.")
|
||||
})
|
||||
Response setUserPassword(@ApiParam(value="The id of the user to change.", required=true) @PathParam("id") long id, @ApiParam(value="The new password.", required=true) @Valid UserPassword password);
|
||||
|
||||
|
||||
/**
|
||||
* Returns a list of users as a page.
|
||||
*
|
||||
* @param pageConfig The page configuration.
|
||||
* @return The list of users as page.
|
||||
*/
|
||||
@GET
|
||||
@Path("users")
|
||||
@ApiOperation(value = "Returns a list of users.", authorizations= { @Authorization(Authorizations.ADMIN) }, tags = { Tags.DEFAULT, Tags.USER })
|
||||
@RolesAllowed({Roles.ADMIN})
|
||||
@ApiResponses({
|
||||
@ApiResponse(code=HttpServletResponse.SC_OK, message="User page retrieved successfully.", response=UserPage.class),
|
||||
@ApiResponse(code=HttpServletResponse.SC_FORBIDDEN, message="Insufficient privileges for retrieval."),
|
||||
@ApiResponse(code=HttpServletResponse.SC_BAD_REQUEST, message="Invalid request parameter.")
|
||||
})
|
||||
Response getUsers(@BeanParam @Valid PageConfig pageConfig);
|
||||
|
||||
/**
|
||||
* Returns a list of users whose name or login contains the search term.
|
||||
*
|
||||
* @param pageConfig The page configuration.
|
||||
* @param term The search term.
|
||||
* @return A page of users whose name or login contains the search term.
|
||||
*/
|
||||
@GET
|
||||
@Path("users/search")
|
||||
@ApiOperation(value = "Returns a list of users whose login name or name contains the term.", authorizations= { @Authorization(Authorizations.ADMIN) }, tags = { Tags.DEFAULT, Tags.USER })
|
||||
@RolesAllowed({Roles.ADMIN})
|
||||
@ApiResponses({
|
||||
@ApiResponse(code=HttpServletResponse.SC_OK, message="User page retrieved successfully.", response=UserPage.class),
|
||||
@ApiResponse(code=HttpServletResponse.SC_FORBIDDEN, message="Insufficient privileges for retrieval."),
|
||||
@ApiResponse(code=HttpServletResponse.SC_BAD_REQUEST, message="Invalid request parameter.")
|
||||
})
|
||||
Response searchUsers(@BeanParam @Valid PageConfig pageConfig, @ApiParam(value="The search term.", required=true) @QueryParam("term") @NotNull @Valid String term);
|
||||
|
||||
// registration work-flow
|
||||
|
||||
/**
|
||||
* Registers a new user and sends an email to verify the account.
|
||||
*
|
||||
* @param user The new user to register.
|
||||
* @return Success or failure, if login is taken already.
|
||||
*/
|
||||
@POST
|
||||
@Path("users/register")
|
||||
@ApiOperation(value = "Registers a new user and sends an email account verification.", tags = { Tags.DEFAULT, Tags.USER })
|
||||
@ApiResponses({
|
||||
@ApiResponse(code=HttpServletResponse.SC_OK, message="User registered successfully.", response=User.class),
|
||||
@ApiResponse(code=HttpServletResponse.SC_CONFLICT, message="User login already registered."),
|
||||
@ApiResponse(code=HttpServletResponse.SC_BAD_REQUEST, message="Invalid user registration.")
|
||||
})
|
||||
@PermitAll
|
||||
// TODO consider using 201 CREATED response with no body and location header.
|
||||
Response registerUser(@ApiParam(value="The data of the new user.", required=true) @Valid UserRegistration user);
|
||||
|
||||
/**
|
||||
* Sends an email with a password to the user.
|
||||
*
|
||||
* @param login The login to reset the password.
|
||||
* @return A success or error code with an empty body.
|
||||
*/
|
||||
@POST
|
||||
@Path("users/reset")
|
||||
@ApiOperation(value = "Sends a password reset email to the correspondence email account of a user.", tags = { Tags.DEFAULT, Tags.USER })
|
||||
@ApiResponses({
|
||||
@ApiResponse(code = HttpServletResponse.SC_NO_CONTENT, message = "Reset email sent successfully."),
|
||||
@ApiResponse(code = HttpServletResponse.SC_NOT_FOUND, message = "Login does not exist."),
|
||||
@ApiResponse(code = HttpServletResponse.SC_BAD_REQUEST, message = "User email has not been verified.")
|
||||
})
|
||||
@PermitAll
|
||||
// TODO consider returning error response when sending email has been ignored because minimum time between mails has not passed. + add test
|
||||
Response resetUser(@ApiParam(value="The login of the user to reset.", required=true) @QueryParam("login") @Valid @NotNull String login);
|
||||
|
||||
|
||||
/**
|
||||
* Sets the password of the user account using the secret token
|
||||
* received via email as part of the password reset.
|
||||
*
|
||||
* @param token The secret token received via email.
|
||||
* @param password The new password to set.
|
||||
* @return The account, if successful. An error otherwise.
|
||||
*/
|
||||
@PUT
|
||||
@Path("users/password/{token}")
|
||||
@ApiOperation(value = "Sets the password of a user account using a token received via email.", tags = { Tags.DEFAULT, Tags.USER })
|
||||
@ApiResponses({
|
||||
@ApiResponse(code=HttpServletResponse.SC_OK, message="Password updated successfully.", response=User.class),
|
||||
@ApiResponse(code=HttpServletResponse.SC_FORBIDDEN, message="Password modification not allowed."),
|
||||
@ApiResponse(code=HttpServletResponse.SC_BAD_REQUEST, message="Invalid token or password.")
|
||||
})
|
||||
@PermitAll
|
||||
// TODO return better status codes for: code expired, deleted, etc. Forbidden should be for authentication errors only.
|
||||
Response resetUserPassword(@ApiParam(value="The secret token received via email.", required=true) @PathParam("token") @Valid @NotNull String token,
|
||||
@ApiParam(value="The new user password.", required=true) @Valid UserPassword password);
|
||||
|
||||
|
||||
/**
|
||||
* Verifies an email address using a token sent via email.
|
||||
*
|
||||
* @param token The token received via email.
|
||||
* @return An error code to indicate success or failure.
|
||||
*/
|
||||
@PUT
|
||||
@Path("users/verify/{token}")
|
||||
@ApiOperation(value = "Verifies an email address using a token received via email.", tags = { Tags.DEFAULT, Tags.USER })
|
||||
@ApiResponses({
|
||||
@ApiResponse(code=HttpServletResponse.SC_NO_CONTENT, message="Email verified successfully."),
|
||||
@ApiResponse(code=HttpServletResponse.SC_FORBIDDEN, message="Email verification is not valid."),
|
||||
@ApiResponse(code=HttpServletResponse.SC_BAD_REQUEST, message="Invalid token.")
|
||||
})
|
||||
@PermitAll
|
||||
Response verifyUserEmail(@ApiParam(value="The secret token received via email.", required=true) @PathParam("token") @Valid @NotNull String token);
|
||||
|
||||
}
|
||||
@@ -1,44 +0,0 @@
|
||||
package com.mowesta.api.version;
|
||||
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import io.swagger.annotations.ApiResponse;
|
||||
import io.swagger.annotations.ApiResponses;
|
||||
|
||||
import javax.annotation.security.PermitAll;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import javax.ws.rs.core.Response;
|
||||
|
||||
import com.mowesta.api.Tags;
|
||||
|
||||
/**
|
||||
* An api to retrieve the build version.
|
||||
*
|
||||
* @author Marcus
|
||||
*
|
||||
*/
|
||||
@Api
|
||||
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
|
||||
@Path("/")
|
||||
public interface IVersionService {
|
||||
|
||||
|
||||
/**
|
||||
* Returns the build version of the service.
|
||||
*
|
||||
* @return The build version of the service.
|
||||
*/
|
||||
@GET
|
||||
@Path("versions/build")
|
||||
@ApiOperation(value = "Returns the build version.", tags = { Tags.DEFAULT, Tags.SERVICE })
|
||||
@ApiResponses({
|
||||
@ApiResponse(code=HttpServletResponse.SC_OK, message="Build version retrieved successfully.", response=BuildVersion.class)
|
||||
})
|
||||
@PermitAll
|
||||
Response getBuildVersion();
|
||||
|
||||
}
|
||||
@@ -1,304 +0,0 @@
|
||||
package com.mowesta.api.weather;
|
||||
|
||||
import javax.annotation.security.PermitAll;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.validation.Valid;
|
||||
import javax.validation.constraints.Min;
|
||||
import javax.ws.rs.BeanParam;
|
||||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.PathParam;
|
||||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.QueryParam;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import javax.ws.rs.core.Response;
|
||||
|
||||
import com.mowesta.api.PageConfig;
|
||||
import com.mowesta.api.Tags;
|
||||
import com.mowesta.api.TimeRange;
|
||||
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import io.swagger.annotations.ApiParam;
|
||||
import io.swagger.annotations.ApiResponse;
|
||||
import io.swagger.annotations.ApiResponses;
|
||||
|
||||
/**
|
||||
* An api to access weather information.
|
||||
*
|
||||
* @author Marcus
|
||||
*
|
||||
*/
|
||||
@Api
|
||||
@Path("/")
|
||||
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
|
||||
public interface IWeatherService {
|
||||
|
||||
|
||||
/**
|
||||
* Returns the weather forecast for a particular city.
|
||||
*
|
||||
* @param id The id of the city.
|
||||
* @return The weather forecast for the city.
|
||||
*/
|
||||
@GET
|
||||
@Path("cities/{id: [0-9]+}/forecast")
|
||||
@ApiOperation(value = "Gets the weather forecast for a city with a particular id.", tags = {Tags.DEFAULT, Tags.WEATHER})
|
||||
@ApiResponses({
|
||||
@ApiResponse(code = HttpServletResponse.SC_OK, message = "Weather forecast retrieved successfully.", response=WeatherForecast.class),
|
||||
@ApiResponse(code = HttpServletResponse.SC_NO_CONTENT, message = "Weather forecast not available."),
|
||||
@ApiResponse(code = HttpServletResponse.SC_NOT_FOUND, message = "City does not exist.")
|
||||
})
|
||||
@PermitAll
|
||||
Response getCityForecast(@ApiParam(value = "The city id.", required = true) @PathParam("id") @Valid @Min(0) long id);
|
||||
|
||||
|
||||
/**
|
||||
* Returns the forecast with a particular id.
|
||||
*
|
||||
* @param id The id of the forecast.
|
||||
* @return The forecast with the id, if it exists.
|
||||
*/
|
||||
@GET
|
||||
@Path("forecasts/{id: [0-9]+}")
|
||||
@ApiOperation(value = "Gets the weather forecast with a particular id.", tags = {Tags.DEFAULT, Tags.WEATHER})
|
||||
@ApiResponses({
|
||||
@ApiResponse(code = HttpServletResponse.SC_OK, message = "Weather forecast retrieved successfully.", response=WeatherForecast.class),
|
||||
@ApiResponse(code = HttpServletResponse.SC_NOT_FOUND, message = "Weather forecast does not exist.")
|
||||
})
|
||||
@PermitAll
|
||||
Response getForecast(@ApiParam(value = "The forecast id.", required = true) @PathParam("id") @Valid @Min(0) long id);
|
||||
|
||||
|
||||
/**
|
||||
* Returns the weather forecast for a particular location.
|
||||
*
|
||||
* @param longitude The longitude of the location.
|
||||
* @param latitude The latitude of the location.
|
||||
* @return The weather forecast for the location.
|
||||
*/
|
||||
@GET
|
||||
@Path("forecasts/resolve")
|
||||
@ApiOperation(value = "Searches the (closest) weather forecast for a particular location.", tags = {Tags.DEFAULT, Tags.WEATHER})
|
||||
@ApiResponses({
|
||||
@ApiResponse(code = HttpServletResponse.SC_OK, message = "Weather forecast retrieved successfully.", response=WeatherForecast.class),
|
||||
@ApiResponse(code = HttpServletResponse.SC_NO_CONTENT, message = "Weather forecast not available.")
|
||||
})
|
||||
@PermitAll
|
||||
Response resolveForecast(@ApiParam(value = "The longitude.", required = true) @QueryParam("longitude") double longitude, @ApiParam(value = "The latitude.", required = true) @QueryParam("latitude") double latitude);
|
||||
|
||||
/**
|
||||
* Returns a page of weather reports of the specified station from a certain time range.
|
||||
*
|
||||
* @param id The id of the station.
|
||||
* @param timeRange The time range.
|
||||
* @param pageConfig The page config.
|
||||
* @return The page of reports.
|
||||
*/
|
||||
@GET
|
||||
@Path("stations/{id}/reports")
|
||||
@ApiOperation(value = "Returns a page of weather reports of a particular staton in a certain time range.", tags = { Tags.DEFAULT, Tags.WEATHER })
|
||||
@ApiResponses({
|
||||
@ApiResponse(code = HttpServletResponse.SC_OK, message = "Weather reports retrieved successfully.", response = WeatherReportPage.class),
|
||||
@ApiResponse(code = HttpServletResponse.SC_NOT_FOUND, message = "Weather station not found.")
|
||||
})
|
||||
@PermitAll
|
||||
Response getStationReports(@ApiParam(value = "The station id.", required = true) @PathParam("id") long id, @BeanParam @Valid TimeRange timeRange, @BeanParam @Valid PageConfig pageConfig);
|
||||
|
||||
|
||||
/**
|
||||
* Returns the latest report of the station.
|
||||
*
|
||||
* @param id The id of the station.
|
||||
* @return The page of reports.
|
||||
*/
|
||||
@GET
|
||||
@Path("stations/{id}/reports/latest")
|
||||
@ApiOperation(value = "Returns the latest weather report of a particular station.", tags = { Tags.DEFAULT, Tags.WEATHER })
|
||||
@ApiResponses({
|
||||
@ApiResponse(code = HttpServletResponse.SC_OK, message = "Weather report retrieved successfully.", response = WeatherReport.class),
|
||||
@ApiResponse(code = HttpServletResponse.SC_NO_CONTENT, message = "No weather report for station available."),
|
||||
@ApiResponse(code = HttpServletResponse.SC_NOT_FOUND, message = "Weather station not found.")
|
||||
})
|
||||
@PermitAll
|
||||
Response getLatestStationReport(@ApiParam(value = "The station id.", required = true) @PathParam("id") long id);
|
||||
|
||||
/**
|
||||
* Returns the closest weather station for a particular location.
|
||||
*
|
||||
* @param longitude The longitude of the location.
|
||||
* @param latitude The latitude of the location.
|
||||
* @return The weather station for the location.
|
||||
*/
|
||||
@GET
|
||||
@Path("stations/resolve")
|
||||
@ApiOperation(value = "Searches the (closest) weather station for a particular location.", tags = {Tags.DEFAULT, Tags.WEATHER})
|
||||
@ApiResponses({
|
||||
@ApiResponse(code = HttpServletResponse.SC_OK, message = "Weather station retrieved successfully.", response=WeatherStation.class),
|
||||
@ApiResponse(code = HttpServletResponse.SC_NO_CONTENT, message = "Weather station not available.")
|
||||
})
|
||||
@PermitAll
|
||||
Response resolveStation(@ApiParam(value = "The longitude.", required = true) @QueryParam("longitude") double longitude, @ApiParam(value = "The latitude.", required = true) @QueryParam("latitude") double latitude);
|
||||
|
||||
|
||||
/**
|
||||
* Returns the weather station for a particular city.
|
||||
*
|
||||
* @param id The id of the city.
|
||||
* @return The weather station for the city.
|
||||
*/
|
||||
@GET
|
||||
@Path("cities/{id: [0-9]+}/station")
|
||||
@ApiOperation(value = "Gets the weather station for a city with a particular id.", tags = {Tags.DEFAULT, Tags.WEATHER})
|
||||
@ApiResponses({
|
||||
@ApiResponse(code = HttpServletResponse.SC_OK, message = "Weather station retrieved successfully.", response=WeatherStation.class),
|
||||
@ApiResponse(code = HttpServletResponse.SC_NO_CONTENT, message = "Weather station not available."),
|
||||
@ApiResponse(code = HttpServletResponse.SC_NOT_FOUND, message = "City does not exist.")
|
||||
})
|
||||
@PermitAll
|
||||
Response getCityStation(@ApiParam(value = "The city id.", required = true) @PathParam("id") @Valid @Min(0) long id);
|
||||
|
||||
|
||||
/**
|
||||
* Returns a page of stations whose name matches the specified search term. If the
|
||||
* search term is null or an empty string, all stations will be returned.
|
||||
*
|
||||
* @param pageConfig The page configuration.
|
||||
* @param term An optional search term to filter the list by station name.
|
||||
* @return A page of weather stations matching the search term.
|
||||
*/
|
||||
@GET
|
||||
@Path("stations")
|
||||
@ApiOperation(value = "Returns a page of weather stations, possibly filtered by name.", tags = { Tags.DEFAULT, Tags.WEATHER })
|
||||
@ApiResponses({
|
||||
@ApiResponse(code=HttpServletResponse.SC_OK, message="Weather station page retrieved successfully.", response=WeatherStationPage.class),
|
||||
@ApiResponse(code=HttpServletResponse.SC_BAD_REQUEST, message="Invalid request parameter.")
|
||||
})
|
||||
@PermitAll
|
||||
Response getStations(@ApiParam(value = "An optional search term to filter the result by name.", required = false) @QueryParam("term") String term, @BeanParam @Valid PageConfig pageConfig);
|
||||
|
||||
/**
|
||||
* Returns a particular station.
|
||||
*
|
||||
* @param id The id of the station.
|
||||
* @return The station, if exits.
|
||||
*/
|
||||
@GET
|
||||
@Path("stations/{id: [0-9]+}")
|
||||
@ApiOperation(value = "Gets a weather station with a particular id.", tags = {Tags.DEFAULT, Tags.WEATHER})
|
||||
@ApiResponses({
|
||||
@ApiResponse(code = HttpServletResponse.SC_OK, message = "Weather station retrieved successfully.", response=WeatherStation.class),
|
||||
@ApiResponse(code = HttpServletResponse.SC_NOT_FOUND, message = "Weather station does not exist."),
|
||||
})
|
||||
@PermitAll
|
||||
Response getStation(@ApiParam(value = "The station id.", required = true) @PathParam("id") @Valid @Min(0) long id);
|
||||
|
||||
|
||||
/**
|
||||
* Returns the weather condition for a particular city.
|
||||
*
|
||||
* @param id The id of the city.
|
||||
* @return The weather condition for the city.
|
||||
*/
|
||||
@GET
|
||||
@Path("cities/{id: [0-9]+}/condition")
|
||||
@ApiOperation(value = "Gets the current weather condition for a city with a particular id.", tags = {Tags.DEFAULT, Tags.WEATHER})
|
||||
@ApiResponses({
|
||||
@ApiResponse(code = HttpServletResponse.SC_OK, message = "Weather condition retrieved successfully.", response=WeatherCondition.class),
|
||||
@ApiResponse(code = HttpServletResponse.SC_NO_CONTENT, message = "Weather condition not available."),
|
||||
@ApiResponse(code = HttpServletResponse.SC_NOT_FOUND, message = "City does not exist.")
|
||||
})
|
||||
@PermitAll
|
||||
Response getCityCondition(@ApiParam(value = "The city id.", required = true) @PathParam("id") @Valid @Min(0) long id);
|
||||
|
||||
|
||||
/**
|
||||
* Retrieves a page of weather videos.
|
||||
*
|
||||
* @param pageConfig The page configuration.
|
||||
* @return The weather video page.
|
||||
*/
|
||||
@GET
|
||||
@Path("videos")
|
||||
@ApiOperation(value = "Returns a page of weather videos.", tags = {Tags.DEFAULT, Tags.WEATHER})
|
||||
@ApiResponses({
|
||||
@ApiResponse(code = HttpServletResponse.SC_OK, message = "Weather video page retrieved successfully.", response=WeatherVideoPage.class),
|
||||
@ApiResponse(code=HttpServletResponse.SC_BAD_REQUEST, message="Invalid request parameter.")
|
||||
})
|
||||
@PermitAll
|
||||
Response getVideos(@BeanParam @Valid PageConfig pageConfig);
|
||||
|
||||
/**
|
||||
* Retrieves a page of weather videos for a particular location.
|
||||
*
|
||||
* @param longitude The longitude.
|
||||
* @param latitude The latitude.
|
||||
* @param pageConfig The page configuration.
|
||||
* @return The weather video page.
|
||||
*/
|
||||
@GET
|
||||
@Path("videos/resolve")
|
||||
@ApiOperation(value = "Returns a page of weather videos relevant for a location.", tags = {Tags.DEFAULT, Tags.WEATHER})
|
||||
@ApiResponses({
|
||||
@ApiResponse(code = HttpServletResponse.SC_OK, message = "Weather video page retrieved successfully.", response=WeatherVideoPage.class),
|
||||
@ApiResponse(code=HttpServletResponse.SC_BAD_REQUEST, message="Invalid request parameter.")
|
||||
})
|
||||
@PermitAll
|
||||
Response resolveVideos(@ApiParam(value = "The longitude.", required = true) @QueryParam("longitude") double longitude, @ApiParam(value = "The latitude.", required = true) @QueryParam("latitude") double latitude, @BeanParam @Valid PageConfig pageConfig);
|
||||
|
||||
|
||||
/**
|
||||
* Returns a list of the latest weather videos.
|
||||
*
|
||||
* @return The list of the latest weather videos.
|
||||
*/
|
||||
@GET
|
||||
@Path("videos/latest")
|
||||
@ApiOperation(value = "Returns the latest of weather videos.", tags = {Tags.DEFAULT, Tags.WEATHER})
|
||||
@ApiResponses({
|
||||
@ApiResponse(code = HttpServletResponse.SC_OK, message = "Weather video list retrieved successfully.", response=WeatherVideo.class, responseContainer = "List"),
|
||||
})
|
||||
@PermitAll
|
||||
Response getLatestVideos();
|
||||
|
||||
|
||||
/**
|
||||
* Returns a page of videos that is relevant for a city.
|
||||
*
|
||||
* @param id The id of the city.
|
||||
* @param pageConfig The page configuration.
|
||||
* @return A page of videos for the city.
|
||||
*/
|
||||
@GET
|
||||
@Path("cities/{id: [0-9]+}/videos")
|
||||
@ApiOperation(value = "Returns the all videos for the city.", tags = {Tags.DEFAULT, Tags.WEATHER})
|
||||
@ApiResponses({
|
||||
@ApiResponse(code = HttpServletResponse.SC_OK, message = "Weather videos retrieved successfully.", response=WeatherVideoPage.class),
|
||||
@ApiResponse(code = HttpServletResponse.SC_NO_CONTENT, message = "Weather videos not available."),
|
||||
@ApiResponse(code = HttpServletResponse.SC_NOT_FOUND, message = "City does not exist.")
|
||||
})
|
||||
@PermitAll
|
||||
Response getCityVideos(@ApiParam(value = "The city id.", required = true) @PathParam("id") @Valid @Min(0) long id, @BeanParam @Valid PageConfig pageConfig);
|
||||
|
||||
|
||||
/**
|
||||
* Returns a list of the latest videos that is relevant for a city.
|
||||
*
|
||||
* @param id The id of the city.
|
||||
* @return The list of videos for the city.
|
||||
*/
|
||||
@GET
|
||||
@Path("cities/{id: [0-9]+}/videos/latest")
|
||||
@ApiOperation(value = "Returns the latest videos for the city.", tags = {Tags.DEFAULT, Tags.WEATHER})
|
||||
@ApiResponses({
|
||||
@ApiResponse(code = HttpServletResponse.SC_OK, message = "Weather videos retrieved successfully.", response=WeatherVideo.class, responseContainer = "List"),
|
||||
@ApiResponse(code = HttpServletResponse.SC_NO_CONTENT, message = "Weather videos not available."),
|
||||
@ApiResponse(code = HttpServletResponse.SC_NOT_FOUND, message = "City does not exist.")
|
||||
})
|
||||
@PermitAll
|
||||
Response getLatestCityVideos(@ApiParam(value = "The city id.", required = true) @PathParam("id") @Valid @Min(0) long id);
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
{
|
||||
"admin" : {
|
||||
"description" : "Operations requiring admin privileges.",
|
||||
"type" : "basic"
|
||||
}
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
{
|
||||
"device" : {
|
||||
"description" : "Operations requiring device privileges.",
|
||||
"type" : "apiKey",
|
||||
"in": "header",
|
||||
"name": "Authorization"
|
||||
}
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
{
|
||||
"user" : {
|
||||
"description" : "Operations requiring a valid user.",
|
||||
"type" : "basic"
|
||||
}
|
||||
}
|
||||
@@ -6,7 +6,7 @@ description = "MoWeSta iOS Api"
|
||||
|
||||
openApiGenerate {
|
||||
generatorName = "swift5"
|
||||
inputSpec = project(':common-api:').buildDir.path + '/swagger/mowesta.json'
|
||||
inputSpec = project(':service-api:').buildDir.path + '/swagger/mowesta.json'
|
||||
outputDir = "${project.buildDir}/swagger"
|
||||
configOptions = [
|
||||
removeMigrationProjectNameClass: "true",
|
||||
@@ -36,7 +36,7 @@ task fixApiClient() {
|
||||
|
||||
// require api build to access swagger definition
|
||||
tasks.register("build") { }
|
||||
tasks['openApiGenerate'].dependsOn(project(':common-api').tasks['build'])
|
||||
tasks['openApiGenerate'].dependsOn(project(':service-api').tasks['build'])
|
||||
// require swagger code gen before compilation
|
||||
build.dependsOn('openApiGenerate')
|
||||
fixApiClient.dependsOn('openApiGenerate')
|
||||
|
||||
@@ -744,7 +744,7 @@
|
||||
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
|
||||
CODE_SIGN_ENTITLEMENTS = App/App.entitlements;
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
CURRENT_PROJECT_VERSION = 4;
|
||||
CURRENT_PROJECT_VERSION = 5;
|
||||
DEVELOPMENT_ASSET_PATHS = "\"App/Preview Content\"";
|
||||
DEVELOPMENT_TEAM = 2KS4Z77UGE;
|
||||
ENABLE_PREVIEWS = YES;
|
||||
@@ -764,7 +764,7 @@
|
||||
"$(inherited)",
|
||||
"@executable_path/Frameworks",
|
||||
);
|
||||
MARKETING_VERSION = 1.2;
|
||||
MARKETING_VERSION = 1.3;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.mowesta.app;
|
||||
PRODUCT_NAME = MoWeSta;
|
||||
SWIFT_EMIT_LOC_STRINGS = YES;
|
||||
@@ -780,7 +780,7 @@
|
||||
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
|
||||
CODE_SIGN_ENTITLEMENTS = App/App.entitlements;
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
CURRENT_PROJECT_VERSION = 4;
|
||||
CURRENT_PROJECT_VERSION = 5;
|
||||
DEVELOPMENT_ASSET_PATHS = "\"App/Preview Content\"";
|
||||
DEVELOPMENT_TEAM = 2KS4Z77UGE;
|
||||
ENABLE_PREVIEWS = YES;
|
||||
@@ -800,7 +800,7 @@
|
||||
"$(inherited)",
|
||||
"@executable_path/Frameworks",
|
||||
);
|
||||
MARKETING_VERSION = 1.2;
|
||||
MARKETING_VERSION = 1.3;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.mowesta.app;
|
||||
PRODUCT_NAME = MoWeSta;
|
||||
SWIFT_EMIT_LOC_STRINGS = YES;
|
||||
|
||||
@@ -223,10 +223,10 @@ class ArduinoCreator {
|
||||
|
||||
public func createDevice() -> DeviceHandle? {
|
||||
print("Creating device handle.")
|
||||
let info = DeviceInfo(device: "Arduino", manufacturer: "MoWeSta", model: model, os: .arduino)
|
||||
let info = DeviceInfo(os: .arduino, manufacturer: "MoWeSta", device: "Arduino", model: model)
|
||||
let group = DispatchGroup()
|
||||
group.enter()
|
||||
let rb = DefaultAPI.createDeviceWithRequestBuilder(body: info)
|
||||
let rb = DefaultAPI.createDeviceWithRequestBuilder(deviceInfo: info)
|
||||
rb.addHeaders(ApiHeader.create(credential))
|
||||
rb.execute() { result in
|
||||
switch result {
|
||||
|
||||
@@ -2,6 +2,9 @@ body {
|
||||
font-family: -apple-system, BlinkMacSystemFont, sans-serif;
|
||||
font-size: 10pt;
|
||||
padding: 16px;
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
max-width: 700px;
|
||||
}
|
||||
|
||||
p {
|
||||
@@ -32,7 +35,7 @@ a, a:any-link {
|
||||
|
||||
@media (prefers-color-scheme: dark) {
|
||||
body {
|
||||
background: black;
|
||||
background: #040404;
|
||||
color: white;
|
||||
}
|
||||
|
||||
|
||||
@@ -184,7 +184,7 @@ struct WeatherSummary: Identifiable {
|
||||
|
||||
extension WeatherCondition {
|
||||
func copy() -> WeatherCondition {
|
||||
return WeatherCondition(cloudCoverage: cloudCoverage, cloudDepth: cloudDepth, duration: duration, hour: hour, humidity: humidity, precipitation: precipitation, pressure: pressure, snowDepth: snowDepth, source: source, temperature: temperature, time: time, type: type, windDirection: windDirection, windSpeed: windSpeed)
|
||||
return WeatherCondition(source: source, time: time, hour: hour, duration: duration, type: type, temperature: temperature, windDirection: windDirection, windSpeed: windSpeed, cloudCoverage: cloudCoverage, cloudDepth: cloudDepth, pressure: pressure, precipitation: precipitation, snowDepth: snowDepth, humidity: humidity)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ public class SyncTask: BaseTask {
|
||||
print("Performing favorite synchronization.")
|
||||
if let cs = credential {
|
||||
if let settings = SettingDownloader(cs).getSettings() {
|
||||
context.performAndWait {
|
||||
context.performAndWait { [context] in
|
||||
let fetch = Favorite.fetchRequest()
|
||||
if let favorites = try? fetch.execute() {
|
||||
/// create a diff
|
||||
@@ -70,7 +70,7 @@ public class SyncTask: BaseTask {
|
||||
let fav = Favorite(context: context)
|
||||
fav.setLocationReferenceType(type: ref.type)
|
||||
fav.added = true
|
||||
fav.identifier = ref.id!
|
||||
fav.identifier = ref.id
|
||||
fav.position = Int16(i)
|
||||
context.insert(fav)
|
||||
newFavorties.append(fav)
|
||||
@@ -82,7 +82,7 @@ public class SyncTask: BaseTask {
|
||||
context.delete(fav)
|
||||
deletedFavorites.append(fav)
|
||||
} else {
|
||||
let ref = LocationReference(id: fav.identifier, type: fav.getLocationReferenceType())
|
||||
let ref = LocationReference(type: fav.getLocationReferenceType(), id: fav.identifier)
|
||||
fav.position = Int16(newState.count)
|
||||
fav.added = true
|
||||
newState.append(ref)
|
||||
@@ -90,7 +90,7 @@ public class SyncTask: BaseTask {
|
||||
}
|
||||
}
|
||||
/// apply the state to the server
|
||||
let newSettings = Settings(creationTime: settings.creationTime, deleted: false, id: settings.id, locations: newState, modificationTime: settings.modificationTime)
|
||||
let newSettings = Settings(id: settings.id, creationTime: settings.creationTime, modificationTime: settings.modificationTime, deleted: false, locations: newState)
|
||||
if SettingUploader(cs, newSettings).setSettings() {
|
||||
print("Saving local favorite changes since upload completed.")
|
||||
try? context.save()
|
||||
@@ -164,7 +164,7 @@ class SettingUploader {
|
||||
print("Uploading user settings.")
|
||||
let group = DispatchGroup()
|
||||
group.enter()
|
||||
let rb = DefaultAPI.setCurrentUserSettingsWithRequestBuilder(body: settings)
|
||||
let rb = DefaultAPI.setCurrentUserSettingsWithRequestBuilder(settings: settings)
|
||||
rb.addHeaders(ApiHeader.create(credential))
|
||||
rb.execute() { result in
|
||||
switch result {
|
||||
|
||||
@@ -106,6 +106,7 @@ struct HideableTabView: View {
|
||||
.lineLimit(1)
|
||||
}
|
||||
.frame(minWidth: 0, maxWidth: 120)
|
||||
.contentShape(Rectangle())
|
||||
}.buttonStyle(NullButtonStyle())
|
||||
}
|
||||
Spacer()
|
||||
|
||||
@@ -33,21 +33,22 @@ struct PageView: View {
|
||||
Button(action: {
|
||||
current = page.id
|
||||
}) {
|
||||
let t = Text(page.text)
|
||||
.frame(alignment: .center)
|
||||
.frame(maxWidth: .infinity)
|
||||
.frame(minHeight: 40)
|
||||
.lineLimit(1)
|
||||
if page.id == current {
|
||||
t
|
||||
.font(.caption.bold())
|
||||
.background(
|
||||
RoundedRectangle(cornerRadius: 4)
|
||||
.foregroundColor(Color("PrimaryColor")))
|
||||
.foregroundColor(Color.accentColor)
|
||||
} else {
|
||||
t.font(.caption)
|
||||
}
|
||||
let t = Text(page.text)
|
||||
.frame(alignment: .center)
|
||||
.frame(maxWidth: .infinity)
|
||||
.frame(minHeight: 40)
|
||||
.contentShape(Rectangle())
|
||||
.lineLimit(1)
|
||||
if page.id == current {
|
||||
t
|
||||
.font(.caption.bold())
|
||||
.background(
|
||||
RoundedRectangle(cornerRadius: 4)
|
||||
.foregroundColor(Color("PrimaryColor")))
|
||||
.foregroundColor(Color.accentColor)
|
||||
} else {
|
||||
t.font(.caption)
|
||||
}
|
||||
}
|
||||
.frame(minHeight: 44)
|
||||
.buttonStyle(NullButtonStyle())
|
||||
|
||||
@@ -24,20 +24,30 @@ struct CityForecastView: View {
|
||||
},
|
||||
PageItem(id: 1, text: "city_info_day") {
|
||||
AnyView(List(aggregate.days) { summary in
|
||||
WeatherSummaryView(title: summary.title, subtitle: summary.subtitle, summary: summary)
|
||||
VStack {
|
||||
WeatherSummaryView(title: summary.title, subtitle: summary.subtitle, summary: summary)
|
||||
}.frame(maxWidth:.infinity)
|
||||
}
|
||||
.listStyle(.plain)
|
||||
)
|
||||
},
|
||||
PageItem(id: 2, text: "city_info_time") {
|
||||
AnyView(List(aggregate.times) { summary in
|
||||
WeatherSummaryView(title: summary.title, subtitle: summary.subtitle, summary: summary)
|
||||
}.listStyle(.plain))
|
||||
VStack {
|
||||
WeatherSummaryView(title: summary.title, subtitle: summary.subtitle, summary: summary)
|
||||
}.frame(maxWidth:.infinity)
|
||||
}.listStyle(.plain)
|
||||
.frame(maxWidth: .infinity)
|
||||
)
|
||||
},
|
||||
PageItem(id: 3, text: "city_info_hour") {
|
||||
AnyView(List(aggregate.hours) { entry in
|
||||
WeatherConditionView(title: entry.title, subtitle: entry.subtitle, condition: entry.condition)
|
||||
}.listStyle(.plain))
|
||||
VStack {
|
||||
WeatherConditionView(title: entry.title, subtitle: entry.subtitle, condition: entry.condition)
|
||||
}.frame(maxWidth:.infinity)
|
||||
}.listStyle(.plain)
|
||||
.frame(maxWidth: .infinity)
|
||||
)
|
||||
}
|
||||
], current: page)
|
||||
}
|
||||
|
||||
@@ -110,6 +110,7 @@ struct CityGradientView: View {
|
||||
GradientView(data: [data.cloudCoverage, data.cloudDepth], colorScheme: [schemes.whiteCloud, schemes.cloudDepth], background: .blue, orientation: orientation, selection: $selection)
|
||||
.frame(maxWidth: .infinity, maxHeight: .infinity)
|
||||
TimeView(data: data.hours, timezone: city.timezone, orientation: orientation, selection: $selection)
|
||||
.contentShape(Rectangle())
|
||||
.frame(maxWidth: .infinity, maxHeight: .infinity)
|
||||
GradientView(data: data.humidity, colorScheme: schemes.humidity, background: .clear, orientation: orientation, selection: $selection)
|
||||
.frame(maxWidth: .infinity, maxHeight: .infinity)
|
||||
|
||||
@@ -28,7 +28,10 @@ struct CityVideoView: View {
|
||||
pages.append(PageItem(id: id, text: "video_source_cosmo_europe") {
|
||||
AnyView(
|
||||
List(videos.cosmoEurope, id: \WeatherVideo.type) { video in
|
||||
WeatherVideoImageView(city: city, video: video)
|
||||
VStack {
|
||||
WeatherVideoImageView(city: city, video: video)
|
||||
.frame(maxWidth: 800)
|
||||
}.frame(maxWidth: .infinity)
|
||||
}.listStyle(.plain)
|
||||
)
|
||||
})
|
||||
@@ -38,7 +41,10 @@ struct CityVideoView: View {
|
||||
pages.append(PageItem(id: id, text: "video_source_icon_europe") {
|
||||
AnyView(
|
||||
List(videos.iconEurope, id: \WeatherVideo.type) { video in
|
||||
WeatherVideoImageView(city: city, video: video)
|
||||
VStack {
|
||||
WeatherVideoImageView(city: city, video: video)
|
||||
.frame(maxWidth: 800)
|
||||
}.frame(maxWidth: .infinity)
|
||||
}.listStyle(.plain)
|
||||
)
|
||||
})
|
||||
@@ -48,7 +54,10 @@ struct CityVideoView: View {
|
||||
pages.append(PageItem(id: id, text: "video_source_icon_global") {
|
||||
AnyView(
|
||||
List(videos.iconGlobal, id: \WeatherVideo.type) { video in
|
||||
WeatherVideoImageView(city: city, video: video)
|
||||
VStack {
|
||||
WeatherVideoImageView(city: city, video: video)
|
||||
.frame(maxWidth: 800)
|
||||
}.frame(maxWidth: .infinity)
|
||||
}.listStyle(.plain)
|
||||
)
|
||||
})
|
||||
@@ -149,7 +158,7 @@ struct WeatherVideoPlayerView: View {
|
||||
let labelWidth = size.width * 0.50
|
||||
let labelHeight = labelWidth / 10
|
||||
|
||||
if videoHeight + labelHeight + 10 < size.height {
|
||||
if videoHeight + (labelHeight + 10) * 2 < size.height {
|
||||
return (videoWidth / 2, videoHeight + labelHeight / 2 + 8, labelWidth, labelHeight)
|
||||
} else {
|
||||
return (videoWidth / 2, videoHeight - 4 - labelHeight / 2, labelWidth, labelHeight)
|
||||
@@ -164,7 +173,7 @@ struct WeatherVideoPlayerView: View {
|
||||
let labelWidth = CGFloat(100)
|
||||
let labelHeight = CGFloat(50)
|
||||
|
||||
if videoHeight + labelHeight + 4 < size.height {
|
||||
if videoHeight + (labelHeight + 4) * 2 < size.height {
|
||||
return (videoWidth - labelWidth / 2 - 4, -labelHeight / 2 - 4, labelWidth, labelHeight)
|
||||
} else {
|
||||
return (videoWidth - labelWidth / 2 - 4, labelHeight / 2 + 4, labelWidth, labelHeight)
|
||||
@@ -250,7 +259,7 @@ struct WeatherVideoPlayerView: View {
|
||||
}
|
||||
}
|
||||
}
|
||||
.navigationBarHidden(true)
|
||||
.navigationBarBackButtonHidden(false)
|
||||
.navigationBarTitleDisplayMode(.inline)
|
||||
.ignoresSafeArea()
|
||||
}
|
||||
|
||||
@@ -200,7 +200,6 @@ struct CityView: View {
|
||||
VStack(spacing: 0) {
|
||||
if let ct = city, let a = aggregate, let g = gradient {
|
||||
CityForecastView(city: ct, aggregate: a, gradient: g, page: $forecastPage)
|
||||
.frame(maxWidth: 800)
|
||||
} else if loading > 0 {
|
||||
ProgressSpinnerView()
|
||||
}
|
||||
@@ -217,7 +216,6 @@ struct CityView: View {
|
||||
VStack(spacing: 0) {
|
||||
if let ct = city, let vids = videos {
|
||||
CityVideoView(city: ct, videos: vids, page: $videoPage)
|
||||
.frame(maxWidth: 800)
|
||||
} else if loading > 0 {
|
||||
ProgressSpinnerView()
|
||||
}
|
||||
|
||||
@@ -147,7 +147,7 @@ struct DeviceView: View {
|
||||
if let credentials = state.credentials {
|
||||
failure = false
|
||||
loading = true
|
||||
let rb = DefaultAPI.getDeviceMeasurementsWithRequestBuilder(duration: time, id: device.id!, start: 0, pageOffset: offset, pageSize: 150)
|
||||
let rb = DefaultAPI.getDeviceMeasurementsWithRequestBuilder(id: device.id!, start: 0, duration: time, pageOffset: offset, pageSize: 150)
|
||||
rb.addHeaders(ApiHeader.create(credentials))
|
||||
rb.execute() {
|
||||
result in
|
||||
|
||||
@@ -224,7 +224,7 @@ struct LoginView: View {
|
||||
userRequest.execute() { userResult in
|
||||
switch userResult {
|
||||
case let .success(userResponse):
|
||||
let linkRequest = DefaultAPI.setCurrentUserWithRequestBuilder(body: userResponse.body)
|
||||
let linkRequest = DefaultAPI.setCurrentUserWithRequestBuilder(user: userResponse.body)
|
||||
linkRequest.addHeaders(ApiHeader.create(credential, appState.token))
|
||||
linkRequest.execute() { linkResult in
|
||||
switch linkResult {
|
||||
@@ -289,8 +289,8 @@ struct LoginView: View {
|
||||
func createDevice(_ login: Bool) -> Void {
|
||||
let model = UIDevice.current.localizedModel
|
||||
let os = UIDevice.current.systemName
|
||||
let info = DeviceInfo(device: os, manufacturer: "Apple", model: model, os: .ios)
|
||||
let request = DefaultAPI.createDeviceWithRequestBuilder(body: info)
|
||||
let info = DeviceInfo(os: DeviceInfo.Os.ios, manufacturer: "Apple", device: os, model: model)
|
||||
let request = DefaultAPI.createDeviceWithRequestBuilder(deviceInfo: info)
|
||||
let credential = UserCredentials(username, password)
|
||||
if login {
|
||||
request.addHeaders(ApiHeader.create(credential))
|
||||
@@ -302,7 +302,7 @@ struct LoginView: View {
|
||||
case let .success(response):
|
||||
let d = response.body
|
||||
appState.token = d.token
|
||||
appState.device = Device(creationTime: d.creationTime, deleted: d.deleted, device: d.device, id: d.id, manufacturer: d.manufacturer, model: d.model, modificationTime: d.modificationTime, os: .ios, user: d.user)
|
||||
appState.device = Device(id: d.id, creationTime: d.creationTime, modificationTime: d.modificationTime, deleted: d.deleted, user: d.user, os: .ios, manufacturer: d.manufacturer, device: d.device, model: d.model)
|
||||
if (login) {
|
||||
appState.credentials = credential
|
||||
BaseTask.execute(all: [ SyncTask(), RefreshTask()], completion: { _ in })
|
||||
|
||||
@@ -28,13 +28,13 @@ struct SettingsView: View {
|
||||
armReset = true
|
||||
}
|
||||
Divider()
|
||||
|
||||
|
||||
SettingsCategory(title: "setting_category_about")
|
||||
NavigationLink(destination: TermsView(), isActive: $showTerms) {
|
||||
EmptyView()
|
||||
EmptyView()
|
||||
}
|
||||
SettingsEntry(icon: "doc.plaintext", title: "setting_about_terms_title", summary: "setting_about_terms_summary") {
|
||||
showTerms = true
|
||||
showTerms = true
|
||||
}
|
||||
SettingsEntry(icon: "info.circle", title: "setting_about_build_title", summary: "setting_about_build_summary \(AppInfo.getBuild()) \(AppInfo.getVersion()) \(AppInfo.getTime())") {
|
||||
if (developmentClicks == 0) {
|
||||
@@ -60,12 +60,14 @@ struct SettingsView: View {
|
||||
SettingsEntry(icon: "iphone", title: "setting_development_device_title",
|
||||
summary: "\(appState.device != nil ? String(appState.device!.id!) : "")") { }
|
||||
SettingsEntry(icon: "shield", title: "setting_development_token_title",
|
||||
summary: "\(appState.token)") { }
|
||||
summary: "\(appState.token)") { }
|
||||
}
|
||||
Spacer()
|
||||
}
|
||||
.frame(maxWidth: 800)
|
||||
.padding()
|
||||
}
|
||||
.frame(maxWidth: .infinity)
|
||||
.alert(isPresented: $armReset) {
|
||||
Alert(title: Text("setting_privacy_reset_title"), message: Text("setting_privacy_reset_message"),
|
||||
primaryButton: .destructive(Text("button_yes").bold()) {
|
||||
@@ -165,7 +167,7 @@ struct SettingsEntry: View {
|
||||
|
||||
var body: some View {
|
||||
Button(action: action) {
|
||||
HStack {
|
||||
HStack() {
|
||||
Image(systemName: icon)
|
||||
.frame(width: 30, height: 30, alignment: .top)
|
||||
.font(.title)
|
||||
@@ -173,14 +175,18 @@ struct SettingsEntry: View {
|
||||
VStack(alignment: .leading, spacing: 4) {
|
||||
Text(title)
|
||||
.font(.body)
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
Text(summary)
|
||||
.font(.caption)
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
}
|
||||
if let check = checked {
|
||||
Image(systemName: check ? "checkmark.square" : "square")
|
||||
.font(.headline)
|
||||
}
|
||||
}
|
||||
.frame(maxWidth: .infinity)
|
||||
.contentShape(Rectangle())
|
||||
.padding()
|
||||
}.buttonStyle(NullButtonStyle())
|
||||
|
||||
|
||||
@@ -144,7 +144,7 @@ struct StationView: View {
|
||||
}
|
||||
failure = false
|
||||
loading = true
|
||||
DefaultAPI.getStationReports(duration: time, id: station.id!, start: 0, pageOffset: offset, pageSize: 100) {
|
||||
DefaultAPI.getStationReports(id: station.id!, start: 0, duration: time, pageOffset: offset, pageSize: 100) {
|
||||
response, error in
|
||||
if let r = response {
|
||||
if measurements == nil {
|
||||
|
||||
@@ -87,7 +87,7 @@ struct StationsView: View {
|
||||
state.requestId += 1
|
||||
state.loading = true
|
||||
let request = state.requestId
|
||||
DefaultAPI.getStations(pageOffset: state.offset, pageSize: 40, term: state.term) {
|
||||
DefaultAPI.getStations(term: state.term, pageOffset: state.offset, pageSize: 40) {
|
||||
result, error in
|
||||
if (request == state.requestId) {
|
||||
if let r = result {
|
||||
@@ -104,7 +104,7 @@ struct StationsView: View {
|
||||
}
|
||||
|
||||
func executeSearch(request: Int, term: String) {
|
||||
DefaultAPI.getStations(pageOffset: 0, pageSize: 40, term: term) {
|
||||
DefaultAPI.getStations(term: term, pageOffset: 0, pageSize: 40) {
|
||||
result, error in
|
||||
if (request == state.requestId) {
|
||||
if let r = result {
|
||||
|
||||
@@ -57,7 +57,6 @@ struct AcceptableWebView: View {
|
||||
var body: some View {
|
||||
VStack {
|
||||
WebView(url: url)
|
||||
.frame(maxWidth: 700)
|
||||
VStack {
|
||||
if acceptable {
|
||||
HStack {
|
||||
|
||||
@@ -61,6 +61,7 @@ struct WeatherConditionView: View {
|
||||
WeatherDataView("icon_barometer", "label_pressure", DataBindings.getPressure(condition.pressure, state.unitSystem))
|
||||
}
|
||||
}.padding([.top, .bottom], 4)
|
||||
.frame(maxWidth: 800)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -162,6 +163,7 @@ struct WeatherSummaryView: View {
|
||||
WeatherDualView("icon_barometer", "label_pressure", DataBindings.getPressure(summary.min.pressure, state.unitSystem), DataBindings.getPressure(summary.max.pressure, state.unitSystem))
|
||||
}
|
||||
}.padding([.top, .bottom], 4)
|
||||
.frame(maxWidth: 800)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,24 +0,0 @@
|
||||
plugins {
|
||||
id 'war'
|
||||
}
|
||||
|
||||
description = 'MoWeSta Service Alexa'
|
||||
|
||||
dependencies {
|
||||
|
||||
compileOnly project(':common-api')
|
||||
compileOnly project(':service-ejb')
|
||||
api "com.amazon.alexa:ask-sdk:2.37.1"
|
||||
|
||||
testCompileOnly project(':service-ejb')
|
||||
testImplementation "junit:junit:${versionJunit}"
|
||||
testImplementation "org.jboss.arquillian.junit:arquillian-junit-container:${versionArquillianJunit}"
|
||||
testImplementation "org.wildfly.arquillian:wildfly-arquillian-container-managed:${versionArquillianContainer}"
|
||||
|
||||
compileOnly "jakarta.platform:jakarta.jakartaee-api:${versionJavaee}"
|
||||
compileOnly "com.fasterxml.jackson.core:jackson-databind:${versionJackson}"
|
||||
}
|
||||
|
||||
jar {
|
||||
enabled = true
|
||||
}
|
||||
@@ -1,72 +0,0 @@
|
||||
package com.mowesta.service.alexa;
|
||||
|
||||
import com.amazon.ask.Skills;
|
||||
import com.amazon.ask.servlet.SkillServlet;
|
||||
import com.mowesta.service.alexa.impl.CancelandStopIntentHandler;
|
||||
import com.mowesta.service.alexa.impl.ClothingRecommendationIntentHandler;
|
||||
import com.mowesta.service.alexa.impl.CurrentWeatherIntentHandler;
|
||||
import com.mowesta.service.alexa.impl.HelpIntentHandler;
|
||||
import com.mowesta.service.alexa.impl.LaunchRequestHandler;
|
||||
import com.mowesta.service.alexa.impl.SessionEndedRequestHandler;
|
||||
import com.mowesta.service.alexa.impl.WeatherForecastIntentHandler;
|
||||
import com.mowesta.service.session.LocationSessionBean;
|
||||
import com.mowesta.service.session.WeatherSessionBean;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import javax.enterprise.context.RequestScoped;
|
||||
import javax.inject.Inject;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.ServletRequest;
|
||||
import javax.servlet.ServletResponse;
|
||||
import javax.servlet.http.HttpServlet;
|
||||
|
||||
@RequestScoped
|
||||
public class AlexaServlet extends HttpServlet {
|
||||
|
||||
private HttpServlet servlet;
|
||||
|
||||
|
||||
@Inject
|
||||
LocationSessionBean locationSessionBean;
|
||||
|
||||
@Inject
|
||||
WeatherSessionBean weatherSessionBean;
|
||||
|
||||
Logger log = Logger.getLogger(getClass().getName());
|
||||
|
||||
@Override
|
||||
public void service(ServletRequest req, ServletResponse res) throws ServletException, IOException {
|
||||
getServlet().service(req, res);
|
||||
}
|
||||
|
||||
public HttpServlet getServlet() {
|
||||
if (servlet == null) {
|
||||
servlet = createServlet();
|
||||
try {
|
||||
servlet.init(getServletConfig());
|
||||
} catch (ServletException e) {
|
||||
throw new RuntimeException("Failed to initialize skill servlet.", e);
|
||||
}
|
||||
}
|
||||
return servlet;
|
||||
}
|
||||
|
||||
public SkillServlet createServlet() {
|
||||
log.log(Level.INFO,"Servlet created " + locationSessionBean + " " + weatherSessionBean);
|
||||
return new SkillServlet(Skills.standard()
|
||||
.addRequestHandlers(
|
||||
new CancelandStopIntentHandler(),
|
||||
new HelpIntentHandler(),
|
||||
new LaunchRequestHandler(),
|
||||
new SessionEndedRequestHandler(),
|
||||
new CurrentWeatherIntentHandler(locationSessionBean, weatherSessionBean),
|
||||
new WeatherForecastIntentHandler(locationSessionBean, weatherSessionBean),
|
||||
new ClothingRecommendationIntentHandler(locationSessionBean, weatherSessionBean))
|
||||
.withSkillId("amzn1.ask.skill.208278db-dd0c-477e-9946-5ebe634831aa")
|
||||
.build());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,240 +0,0 @@
|
||||
package com.mowesta.service.alexa.impl;
|
||||
|
||||
import com.amazon.ask.dispatcher.request.handler.HandlerInput;
|
||||
import com.amazon.ask.model.IntentRequest;
|
||||
import com.amazon.ask.model.PermissionStatus;
|
||||
import com.amazon.ask.model.Permissions;
|
||||
import com.amazon.ask.model.interfaces.geolocation.GeolocationState;
|
||||
import com.mowesta.api.Coordinate;
|
||||
import com.mowesta.api.Language;
|
||||
import com.mowesta.api.PageConfig;
|
||||
import com.mowesta.api.SearchContext;
|
||||
import com.mowesta.api.location.CityPage;
|
||||
import com.mowesta.api.location.Country;
|
||||
import com.mowesta.api.location.Location;
|
||||
import com.mowesta.api.location.LocationHierarchy;
|
||||
import com.mowesta.api.location.LocationHierarchyPage;
|
||||
import com.mowesta.api.location.State;
|
||||
import com.mowesta.service.entity.EntityNotFoundException;
|
||||
import com.mowesta.service.session.LocationSessionBean;
|
||||
import com.mowesta.service.session.WeatherSessionBean;
|
||||
|
||||
import org.joda.time.LocalDateTime;
|
||||
|
||||
import java.util.Locale;
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
/**
|
||||
* Service that provides an intent with the location the user is looking for.
|
||||
*
|
||||
* @author Katharina
|
||||
*/
|
||||
public class AlexaIntentService {
|
||||
LocationSessionBean locationSessionBean;
|
||||
|
||||
WeatherSessionBean weatherSessionBean;
|
||||
|
||||
private static final String GEO_PERMISSION = "alexa::devices:all:geolocation:read";
|
||||
|
||||
public AlexaIntentService(LocationSessionBean locationSessionBean, WeatherSessionBean weatherSessionBean) {
|
||||
this.locationSessionBean = locationSessionBean;
|
||||
this.weatherSessionBean = weatherSessionBean;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the requested location or the geo location of the user.
|
||||
* @param input The HandlerInput.
|
||||
* @param intentRequest The IntentRequest.
|
||||
* @param language The language.
|
||||
* @param city The city.
|
||||
* @return The location.
|
||||
*/
|
||||
public Location getRequestedLocation(HandlerInput input, IntentRequest intentRequest, Language language, String city) {
|
||||
Location location = null;
|
||||
if (city == null) {
|
||||
location = getGeoLocation(input);
|
||||
} else {
|
||||
LocationHierarchyPage locationHierarchyPage = locationSessionBean.searchLocations(new PageConfig(0, 60), new SearchContext(language), city);
|
||||
location = getLocation(intentRequest, locationHierarchyPage);
|
||||
}
|
||||
return location;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the location of the user.
|
||||
*
|
||||
* @param input The HandlerInput.
|
||||
* @return The Location of the user.
|
||||
*/
|
||||
public Location getGeoLocation(HandlerInput input) {
|
||||
Location geoLocation = null;
|
||||
Permissions permissions = input.getRequestEnvelope().getSession().getUser().getPermissions();
|
||||
|
||||
if (input.getRequestEnvelope().getContext().getSystem().getDevice().getSupportedInterfaces()
|
||||
.getGeolocation() != null && permissions != null && permissions.getScopes() != null
|
||||
&& permissions.getScopes().get(GEO_PERMISSION).getStatus() == PermissionStatus.GRANTED) {
|
||||
|
||||
GeolocationState geo = input.getRequestEnvelope().getContext().getGeolocation();
|
||||
|
||||
|
||||
Coordinate userPosition = new Coordinate(geo.getCoordinate().getLongitudeInDegrees(), geo.getCoordinate().getLatitudeInDegrees());
|
||||
Coordinate secondUserPosition = new Coordinate(geo.getCoordinate().getLongitudeInDegrees() + 0.01, geo.getCoordinate().getLatitudeInDegrees() + 0.01);
|
||||
|
||||
CityPage cities = locationSessionBean.resolveCities(new PageConfig(0, 1), userPosition, secondUserPosition);
|
||||
geoLocation = cities.getElements().get(0);
|
||||
|
||||
return geoLocation;
|
||||
|
||||
} else return null;
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the requested location.
|
||||
*
|
||||
* @param intentRequest The IntentRequest.
|
||||
* @param locationHierarchyPage All locations found by the requested name of the location.
|
||||
* @return The requested location found with specified region/country or the first found location.
|
||||
*/
|
||||
public Location getLocation(IntentRequest intentRequest, LocationHierarchyPage locationHierarchyPage) {
|
||||
|
||||
if (locationHierarchyPage.getElements().isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (intentRequest.getIntent().getSlots().get("Region").getValue() != null) {
|
||||
return getByRegion(intentRequest.getIntent().getSlots().get("Region").getValue(), intentRequest.getIntent().getSlots().get("Stadt").getValue(), locationHierarchyPage);
|
||||
} else if (intentRequest.getIntent().getSlots().get("Land").getValue() != null) {
|
||||
return getByCountry(intentRequest.getIntent().getSlots().get("Land").getValue(), intentRequest.getIntent().getSlots().get("Stadt").getValue(), locationHierarchyPage);
|
||||
} else return locationHierarchyPage.getElements().get(0);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the requested location with specified region.
|
||||
*
|
||||
* @param regionName The specified region.
|
||||
* @param cityName The specified city.
|
||||
* @param locationHierarchyPage All found locations.
|
||||
* @return The requested location or null if not found.
|
||||
*/
|
||||
private Location getByRegion(String regionName, String cityName, LocationHierarchyPage locationHierarchyPage) {
|
||||
for (LocationHierarchy element : locationHierarchyPage.getElements()) {
|
||||
|
||||
if (!locationContainsName(cityName, element)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
State state = null;
|
||||
try {
|
||||
state = locationSessionBean.getCity(element.getId(), true).getState();
|
||||
} catch (EntityNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
if (state == null) continue;
|
||||
|
||||
if (locationContainsName(regionName, state)) {
|
||||
return element;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the requested location with specified country.
|
||||
*
|
||||
* @param name The specified country.
|
||||
* @param cityName The specified city.
|
||||
* @param locationHierarchyPage All found locations.
|
||||
* @return The requested location or null if not found.
|
||||
*/
|
||||
private Location getByCountry(String name, String cityName, LocationHierarchyPage locationHierarchyPage) {
|
||||
|
||||
for (LocationHierarchy element : locationHierarchyPage.getElements()) {
|
||||
|
||||
if (!locationContainsName(cityName, element)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Country country = null;
|
||||
try {
|
||||
country = locationSessionBean.getCity(element.getId(), true).getCountry();
|
||||
} catch (EntityNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
if (country == null) continue;
|
||||
|
||||
if (locationContainsName(name, country)) {
|
||||
return element;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether the specified city is equals the found location name.
|
||||
*
|
||||
* @param name The name of the city.
|
||||
* @param location The location.
|
||||
* @return True/False
|
||||
*/
|
||||
private boolean locationContainsName(String name, Location location) {
|
||||
return location.getNames().values().stream()
|
||||
.map(locationName -> locationName.toLowerCase().replaceAll("-", " "))
|
||||
.anyMatch(locationName -> locationName.equals(name));
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Returns the ResourceBundle for specified language.
|
||||
*
|
||||
* @param intentRequest The IntentRequest.
|
||||
* @return The ResourceBundle.
|
||||
*/
|
||||
public ResourceBundle getResourceBundle(IntentRequest intentRequest) {
|
||||
String[] requestLocale = intentRequest.getLocale().split("-");
|
||||
Locale locale = new Locale(requestLocale[0], requestLocale[1]);
|
||||
return ResourceBundle.getBundle("Language", locale);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the language.
|
||||
*
|
||||
* @param intentRequest The IntentRequest.
|
||||
* @return The language.
|
||||
*/
|
||||
public Language getLanguage(IntentRequest intentRequest) {
|
||||
String[] requestLocale = intentRequest.getLocale().split("-");
|
||||
if (requestLocale[0].equals("de")) {
|
||||
return Language.GERMAN;
|
||||
} else if (requestLocale[0].equals("en")) {
|
||||
return Language.ENGLISH;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of hours depending on the specified time slot.
|
||||
*
|
||||
* @param timeslot The specified times slot.
|
||||
* @param bundle The resource bundle.
|
||||
* @return The number of hours.
|
||||
*/
|
||||
public int getTime(String timeslot, ResourceBundle bundle) {
|
||||
LocalDateTime localDateTime = LocalDateTime.now();
|
||||
if (timeslot.equals(bundle.getString("TODAY"))) {
|
||||
return localDateTime.getHourOfDay();
|
||||
} else if (timeslot.equals(bundle.getString("TOMORROW"))) {
|
||||
return 24;
|
||||
} else if (timeslot.equals(bundle.getString("DAY_AFTER_TOMORROW"))) {
|
||||
return 48;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
-47
@@ -1,47 +0,0 @@
|
||||
/*
|
||||
Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file
|
||||
except in compliance with the License. A copy of the License is located at
|
||||
|
||||
http://aws.amazon.com/apache2.0/
|
||||
|
||||
or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for
|
||||
the specific language governing permissions and limitations under the License.
|
||||
*/
|
||||
|
||||
package com.mowesta.service.alexa.impl;
|
||||
|
||||
import com.amazon.ask.dispatcher.request.handler.HandlerInput;
|
||||
import com.amazon.ask.dispatcher.request.handler.RequestHandler;
|
||||
import com.amazon.ask.dispatcher.request.handler.impl.IntentRequestHandler;
|
||||
import com.amazon.ask.model.IntentRequest;
|
||||
import com.amazon.ask.model.Response;
|
||||
|
||||
import java.util.Locale;
|
||||
import java.util.Optional;
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
import javax.persistence.criteria.CriteriaBuilder;
|
||||
|
||||
import static com.amazon.ask.request.Predicates.intentName;
|
||||
|
||||
public class CancelandStopIntentHandler implements IntentRequestHandler {
|
||||
@Override
|
||||
public boolean canHandle(HandlerInput input, IntentRequest intentRequest) {
|
||||
return input.matches(intentName("AMAZON.StopIntent").or(intentName("AMAZON.CancelIntent")));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<Response> handle(HandlerInput input, IntentRequest intentRequest) {
|
||||
String[] requestLocale = intentRequest.getLocale().split("-");
|
||||
Locale locale = new Locale(requestLocale[0], requestLocale[1]);
|
||||
ResourceBundle bundle = ResourceBundle.getBundle("Language", locale);
|
||||
|
||||
return input.getResponseBuilder()
|
||||
.withSpeech(bundle.getString("STOP"))
|
||||
.withSimpleCard(bundle.getString("STOPINTENT_NAME"), bundle.getString("STOP"))
|
||||
.build();
|
||||
}
|
||||
}
|
||||
-106
@@ -1,106 +0,0 @@
|
||||
package com.mowesta.service.alexa.impl;
|
||||
|
||||
import com.amazon.ask.dispatcher.request.handler.HandlerInput;
|
||||
import com.amazon.ask.dispatcher.request.handler.impl.IntentRequestHandler;
|
||||
import com.amazon.ask.model.IntentRequest;
|
||||
import com.amazon.ask.model.Response;
|
||||
import com.mowesta.api.Language;
|
||||
import com.mowesta.api.location.Location;
|
||||
import com.mowesta.api.weather.WeatherForecast;
|
||||
import com.mowesta.service.session.LocationSessionBean;
|
||||
import com.mowesta.service.session.WeatherSessionBean;
|
||||
|
||||
import java.text.MessageFormat;
|
||||
import java.util.Optional;
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
import static com.amazon.ask.request.Predicates.intentName;
|
||||
|
||||
/**
|
||||
* Recommends clothing to the user for today / tomorrow / the day after for a location.
|
||||
*
|
||||
* @author Katharina
|
||||
*/
|
||||
public class ClothingRecommendationIntentHandler implements IntentRequestHandler {
|
||||
|
||||
LocationSessionBean locationSessionBean;
|
||||
|
||||
WeatherSessionBean weatherSessionBean;
|
||||
|
||||
AlexaIntentService alexaIntentService;
|
||||
|
||||
|
||||
public ClothingRecommendationIntentHandler(LocationSessionBean locationSessionBean, WeatherSessionBean weatherSessionBean) {
|
||||
this.locationSessionBean = locationSessionBean;
|
||||
this.weatherSessionBean = weatherSessionBean;
|
||||
alexaIntentService = new AlexaIntentService(this.locationSessionBean, this.weatherSessionBean);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canHandle(HandlerInput input, IntentRequest intentRequest) {
|
||||
return input.matches(intentName("ClothingRecommendationIntent"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<Response> handle(HandlerInput input, IntentRequest intentRequest) {
|
||||
ResourceBundle bundle = alexaIntentService.getResourceBundle(intentRequest);
|
||||
Language language = alexaIntentService.getLanguage(intentRequest);
|
||||
|
||||
String speechText = "";
|
||||
String city = intentRequest.getIntent().getSlots().get("Stadt").getValue();
|
||||
|
||||
String uppercaseCity = "";
|
||||
if (city != null) uppercaseCity = city.substring(0, 1).toUpperCase() + city.substring(1);
|
||||
|
||||
String timeslot = intentRequest.getIntent().getSlots().get("Zeitpunkt").getValue();
|
||||
TimespanService timespanService = new TimespanService(alexaIntentService.getTime(timeslot, bundle));
|
||||
|
||||
Location location = alexaIntentService.getRequestedLocation(input, intentRequest, language, city);
|
||||
|
||||
|
||||
if (location == null && city != null) {
|
||||
return input.getResponseBuilder()
|
||||
.withSpeech(MessageFormat.format(bundle.getString("ERROR_CITY"), uppercaseCity))
|
||||
.withSimpleCard("Error", MessageFormat.format(bundle.getString("ERROR_CITY"), uppercaseCity))
|
||||
.build();
|
||||
} else if (location == null && city == null) {
|
||||
return input.getResponseBuilder()
|
||||
.withSpeech(bundle.getString("ERROR_LOCATION"))
|
||||
.withSimpleCard("Error", bundle.getString("ERROR_LOCATION"))
|
||||
.build();
|
||||
}
|
||||
|
||||
WeatherForecast weatherForecast = weatherSessionBean.getForecast(location.getCoordinate());
|
||||
|
||||
if (weatherForecast == null) {
|
||||
return input.getResponseBuilder()
|
||||
.withSpeech(bundle.getString("ERROR_CLOTHING"))
|
||||
.withSimpleCard(bundle.getString("RECOMMENDATION_NAME"), bundle.getString("ERROR_CLOTHING"))
|
||||
.build();
|
||||
}
|
||||
|
||||
WeatherConditionService weatherConditionService = new WeatherConditionService(weatherForecast, timespanService);
|
||||
|
||||
if (weatherConditionService.getMaxTemperature() == null) {
|
||||
return input.getResponseBuilder()
|
||||
.withSpeech(bundle.getString("ERROR_CLOTHING"))
|
||||
.withSimpleCard(bundle.getString("RECOMMENDATION_NAME"), bundle.getString("ERROR_CLOTHING"))
|
||||
.build();
|
||||
}
|
||||
|
||||
if (city != null) {
|
||||
speechText += MessageFormat.format(bundle.getString("RECOMMENDATION_WITH_LOCATION"), uppercaseCity, timeslot);
|
||||
} else {
|
||||
speechText += MessageFormat.format(bundle.getString("RECOMMENDATION_WITHOUT_LOCATION"), timeslot);
|
||||
}
|
||||
|
||||
speechText += weatherConditionService.getClothingRecommendation(bundle);
|
||||
|
||||
|
||||
return input.getResponseBuilder()
|
||||
.withSpeech(speechText)
|
||||
.withSimpleCard(bundle.getString("RECOMMENDATION_NAME"), speechText)
|
||||
.build();
|
||||
}
|
||||
|
||||
}
|
||||
-116
@@ -1,116 +0,0 @@
|
||||
package com.mowesta.service.alexa.impl;
|
||||
|
||||
import com.mowesta.api.weather.WeatherType;
|
||||
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
/**
|
||||
* Converts each weather type to a specific string or gives it a specific priority.
|
||||
*
|
||||
* @author Katharina
|
||||
*/
|
||||
public class ClothingWeatherToStringConverter {
|
||||
/**
|
||||
* Returns a recommendation depending on the most common weather type.
|
||||
*
|
||||
* @param weatherType The most common weather type.
|
||||
* @param bundle The resource bundle.
|
||||
* @return Recommendation.
|
||||
*/
|
||||
public static String convertToString(WeatherType weatherType, ResourceBundle bundle) {
|
||||
String weathercondition = "";
|
||||
|
||||
switch (weatherType) {
|
||||
|
||||
case UNKNOWN:
|
||||
break;
|
||||
case FOG:
|
||||
case FOG_DEPOSITING_RIME:
|
||||
case CLOUDY:
|
||||
case PARTLY_CLOUDY:
|
||||
weathercondition = "";
|
||||
break;
|
||||
case CLEAR_SKY:
|
||||
case MAINLY_CLEAR:
|
||||
weathercondition = bundle.getString("CLEAR");
|
||||
break;
|
||||
case SNOW_GRAINS:
|
||||
case HEAVY_DRIZZLE:
|
||||
case SLIGHT_DRIZZLE:
|
||||
case MODERATE_DRIZZLE:
|
||||
case RAIN_SHOWER_SLIGHT:
|
||||
case SLIGHT_RAIN_NOT_FREEZING:
|
||||
case SNOW_SHOWER_SLIGHT:
|
||||
case SLIGHT_FALL_OF_SNOWFLAKES:
|
||||
case RAIN_SHOWER_MODERATE_HEAVY:
|
||||
case RAIN_SHOWER_VIOLENT:
|
||||
case HEAVY_RAIN_NOT_FREEZING:
|
||||
case RAIN_FREEZING_SLIGHT:
|
||||
case DRIZZLE_FREEZING_SLIGHT:
|
||||
case THUNDERSTORM_HAIL_HEAVY:
|
||||
case HEAVY_FALL_OF_SNOWFLAKES:
|
||||
case SNOW_SHOWER_MODERATE_HEAVY:
|
||||
case MODERATE_RAIN_NOT_FREEZING:
|
||||
case MODERATE_FALL_OF_SNOWFLAKES:
|
||||
case RAIN_FREEZING_MODERATE_HEAVY:
|
||||
case THUNDERSTORM_SLIGHT_MODERATE:
|
||||
case DRIZZLE_FREEZING_MODERATE_HEAVY:
|
||||
weathercondition = bundle.getString("WET");
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
return weathercondition;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prioritizes the weather types.
|
||||
*
|
||||
* @param weatherType The weather type.
|
||||
* @return The priority (1,2 or 3).
|
||||
*/
|
||||
public int setPriorityOfWeather(WeatherType weatherType) {
|
||||
int priority = 0;
|
||||
switch (weatherType) {
|
||||
|
||||
case UNKNOWN:
|
||||
break;
|
||||
case FOG:
|
||||
case FOG_DEPOSITING_RIME:
|
||||
case CLOUDY:
|
||||
case PARTLY_CLOUDY:
|
||||
priority = 1;
|
||||
break;
|
||||
case CLEAR_SKY:
|
||||
case MAINLY_CLEAR:
|
||||
priority = 2;
|
||||
break;
|
||||
case SNOW_GRAINS:
|
||||
case HEAVY_DRIZZLE:
|
||||
case SLIGHT_DRIZZLE:
|
||||
case MODERATE_DRIZZLE:
|
||||
case RAIN_SHOWER_SLIGHT:
|
||||
case SLIGHT_RAIN_NOT_FREEZING:
|
||||
case SNOW_SHOWER_SLIGHT:
|
||||
case SLIGHT_FALL_OF_SNOWFLAKES:
|
||||
case RAIN_SHOWER_MODERATE_HEAVY:
|
||||
case RAIN_SHOWER_VIOLENT:
|
||||
case HEAVY_RAIN_NOT_FREEZING:
|
||||
case RAIN_FREEZING_SLIGHT:
|
||||
case DRIZZLE_FREEZING_SLIGHT:
|
||||
case THUNDERSTORM_HAIL_HEAVY:
|
||||
case HEAVY_FALL_OF_SNOWFLAKES:
|
||||
case SNOW_SHOWER_MODERATE_HEAVY:
|
||||
case MODERATE_RAIN_NOT_FREEZING:
|
||||
case MODERATE_FALL_OF_SNOWFLAKES:
|
||||
case RAIN_FREEZING_MODERATE_HEAVY:
|
||||
case THUNDERSTORM_SLIGHT_MODERATE:
|
||||
case DRIZZLE_FREEZING_MODERATE_HEAVY:
|
||||
priority = 3;
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
return priority;
|
||||
}
|
||||
}
|
||||
-104
@@ -1,104 +0,0 @@
|
||||
package com.mowesta.service.alexa.impl;
|
||||
|
||||
import com.amazon.ask.dispatcher.request.handler.HandlerInput;
|
||||
import com.amazon.ask.dispatcher.request.handler.impl.IntentRequestHandler;
|
||||
import com.amazon.ask.model.IntentRequest;
|
||||
import com.amazon.ask.model.Response;
|
||||
import com.mowesta.api.Language;
|
||||
import com.mowesta.api.location.Location;
|
||||
import com.mowesta.api.weather.WeatherCondition;
|
||||
import com.mowesta.service.session.LocationSessionBean;
|
||||
import com.mowesta.service.session.WeatherSessionBean;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
import java.text.MessageFormat;
|
||||
import java.util.Optional;
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
import static com.amazon.ask.request.Predicates.intentName;
|
||||
|
||||
/**
|
||||
* Tells the user the current weather for a location.
|
||||
*
|
||||
* @author Katharina
|
||||
*/
|
||||
public class CurrentWeatherIntentHandler implements IntentRequestHandler {
|
||||
|
||||
|
||||
LocationSessionBean locationSessionBean;
|
||||
|
||||
WeatherSessionBean weatherSessionBean;
|
||||
|
||||
WeatherTypeToStringConverter weatherTypeToStringConverter = new WeatherTypeToStringConverter();
|
||||
|
||||
AlexaIntentService alexaIntentService;
|
||||
|
||||
|
||||
public CurrentWeatherIntentHandler(LocationSessionBean locationSessionBean, WeatherSessionBean weatherSessionBean) {
|
||||
this.locationSessionBean = locationSessionBean;
|
||||
this.weatherSessionBean = weatherSessionBean;
|
||||
alexaIntentService = new AlexaIntentService(this.locationSessionBean, this.weatherSessionBean);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canHandle(HandlerInput input, IntentRequest intentRequest) {
|
||||
return input.matches(intentName("CurrentWeatherIntent"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<Response> handle(HandlerInput input, IntentRequest intentRequest) {
|
||||
ResourceBundle bundle = alexaIntentService.getResourceBundle(intentRequest);
|
||||
Language language = alexaIntentService.getLanguage(intentRequest);
|
||||
|
||||
String speechText = "";
|
||||
String city = intentRequest.getIntent().getSlots().get("Stadt").getValue();
|
||||
String uppercaseCity = "";
|
||||
if (city != null) uppercaseCity = city.substring(0, 1).toUpperCase() + city.substring(1);
|
||||
|
||||
|
||||
Location location = alexaIntentService.getRequestedLocation(input, intentRequest, language, city);
|
||||
|
||||
if (location == null && city != null) {
|
||||
return input.getResponseBuilder()
|
||||
.withSpeech(MessageFormat.format(bundle.getString("ERROR_CITY"), uppercaseCity))
|
||||
.withSimpleCard("Error", MessageFormat.format(bundle.getString("ERROR_CITY"), uppercaseCity))
|
||||
.build();
|
||||
} else if (location == null && city == null) {
|
||||
return input.getResponseBuilder()
|
||||
.withSpeech(bundle.getString("ERROR_LOCATION"))
|
||||
.withSimpleCard("Error", bundle.getString("ERROR_LOCATION"))
|
||||
.build();
|
||||
}
|
||||
|
||||
WeatherCondition currentWeatherOfLocation = weatherSessionBean.getCondition(location.getCoordinate());
|
||||
|
||||
if (currentWeatherOfLocation != null) {
|
||||
DecimalFormat decimalFormat = new DecimalFormat("#.#");
|
||||
String temperature = String.valueOf(decimalFormat.format(currentWeatherOfLocation.getTemperature())).replaceAll("\\.", ",");
|
||||
String[] splitTemperature = temperature.split(",");
|
||||
if (splitTemperature.length > 1 && splitTemperature[1].equals("0"))
|
||||
temperature = splitTemperature[0];
|
||||
|
||||
String weatherType = weatherTypeToStringConverter.convertToString(currentWeatherOfLocation.getType(), bundle);
|
||||
|
||||
if (city != null) {
|
||||
speechText += MessageFormat.format(bundle.getString("CURRENTWEATHER_WITH_LOCATION"), uppercaseCity, temperature, weatherType);
|
||||
} else {
|
||||
speechText += MessageFormat.format(bundle.getString("CURRENTWEATHER_WITHOUT_LOCATION"), temperature, weatherType);
|
||||
}
|
||||
|
||||
|
||||
WeatherConditionService weatherConditionService = new WeatherConditionService(currentWeatherOfLocation.getTemperature(), currentWeatherOfLocation.getTemperature(), currentWeatherOfLocation.getWindSpeed());
|
||||
weatherConditionService.getWarningString(bundle);
|
||||
|
||||
} else {
|
||||
speechText += bundle.getString("ERROR_CURRENTWEATHER");
|
||||
}
|
||||
|
||||
return input.getResponseBuilder()
|
||||
.withSpeech(speechText)
|
||||
.withSimpleCard(bundle.getString("CURRENTWEATHERHANDLER_NAME"), speechText)
|
||||
.build();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
package com.mowesta.service.alexa.impl;
|
||||
|
||||
|
||||
import com.amazon.ask.dispatcher.request.handler.HandlerInput;
|
||||
import com.amazon.ask.dispatcher.request.handler.RequestHandler;
|
||||
import com.amazon.ask.model.Response;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import static com.amazon.ask.request.Predicates.intentName;
|
||||
|
||||
// 2018-July-09: AMAZON.FallackIntent is only currently available in en-US locale.
|
||||
// This handler will not be triggered except in that locale, so it can be
|
||||
// safely deployed for any locale.
|
||||
public class FallbackIntentHandler implements RequestHandler {
|
||||
|
||||
@Override
|
||||
public boolean canHandle(HandlerInput input) {
|
||||
return input.matches(intentName("AMAZON.FallbackIntent"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<Response> handle(HandlerInput input) {
|
||||
String speechText = "Sorry, I don't know that. You can say try saying help!";
|
||||
return input.getResponseBuilder()
|
||||
.withSpeech(speechText)
|
||||
.withSimpleCard("Fallback", speechText)
|
||||
.withReprompt(speechText)
|
||||
.build();
|
||||
}
|
||||
}
|
||||
-98
@@ -1,98 +0,0 @@
|
||||
package com.mowesta.service.alexa.impl;
|
||||
|
||||
import com.mowesta.api.weather.WeatherType;
|
||||
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
/**
|
||||
* Converts each weather type to a specific string for the weather forecast.
|
||||
*
|
||||
* @author Katharina
|
||||
*/
|
||||
public class ForecastWeatherToStringConverter {
|
||||
/**
|
||||
* Returns the weather forecast as String depending on the most common weather type.
|
||||
*
|
||||
* @param weatherType The most common weather type.
|
||||
* @param bundle The resource bundle.
|
||||
* @return The weather.
|
||||
*/
|
||||
public static String convertToString(WeatherType weatherType, ResourceBundle bundle) {
|
||||
String weathercondition = "";
|
||||
|
||||
switch (weatherType) {
|
||||
|
||||
case UNKNOWN:
|
||||
break;
|
||||
case FOG:
|
||||
case FOG_DEPOSITING_RIME:
|
||||
weathercondition = bundle.getString("FOG");
|
||||
break;
|
||||
case CLOUDY:
|
||||
case PARTLY_CLOUDY:
|
||||
weathercondition = bundle.getString("CLOUDY");
|
||||
break;
|
||||
case CLEAR_SKY:
|
||||
case MAINLY_CLEAR:
|
||||
weathercondition = bundle.getString("CLEAR_SKY");
|
||||
break;
|
||||
case SNOW_GRAINS:
|
||||
weathercondition = bundle.getString("SNOW_GRAINS");
|
||||
break;
|
||||
case HEAVY_DRIZZLE:
|
||||
weathercondition = bundle.getString("HEAVY_DRIZZLE");
|
||||
break;
|
||||
case SLIGHT_DRIZZLE:
|
||||
weathercondition = bundle.getString("SLIGHT_DRIZZLE");
|
||||
break;
|
||||
case MODERATE_DRIZZLE:
|
||||
weathercondition = bundle.getString("MODERATE_DRIZZLE");
|
||||
break;
|
||||
case RAIN_SHOWER_SLIGHT:
|
||||
case SLIGHT_RAIN_NOT_FREEZING:
|
||||
weathercondition = bundle.getString("SLIGHT_RAIN");
|
||||
break;
|
||||
case SNOW_SHOWER_SLIGHT:
|
||||
case SLIGHT_FALL_OF_SNOWFLAKES:
|
||||
weathercondition = bundle.getString("SLIGHT_SNOW");
|
||||
break;
|
||||
case RAIN_SHOWER_MODERATE_HEAVY:
|
||||
case RAIN_SHOWER_VIOLENT:
|
||||
case HEAVY_RAIN_NOT_FREEZING:
|
||||
weathercondition = bundle.getString("HEAVY_RAIN");
|
||||
break;
|
||||
case RAIN_FREEZING_SLIGHT:
|
||||
weathercondition = bundle.getString("RAIN_FREEZING_SLIGHT");
|
||||
break;
|
||||
case DRIZZLE_FREEZING_SLIGHT:
|
||||
weathercondition = bundle.getString("DRIZZLE_FREEZING_SLIGHT");
|
||||
break;
|
||||
case THUNDERSTORM_HAIL_HEAVY:
|
||||
weathercondition = bundle.getString("THUNDERSTORM_HAIL_HEAVY");
|
||||
break;
|
||||
case HEAVY_FALL_OF_SNOWFLAKES:
|
||||
case SNOW_SHOWER_MODERATE_HEAVY:
|
||||
weathercondition = bundle.getString("HEAVY_SNOW");
|
||||
break;
|
||||
case MODERATE_RAIN_NOT_FREEZING:
|
||||
weathercondition = bundle.getString("RAIN");
|
||||
break;
|
||||
case MODERATE_FALL_OF_SNOWFLAKES:
|
||||
weathercondition = bundle.getString("SNOW");
|
||||
break;
|
||||
case RAIN_FREEZING_MODERATE_HEAVY:
|
||||
weathercondition = bundle.getString("RAIN_FREEZING_MODERATE_HEAVY");
|
||||
break;
|
||||
case THUNDERSTORM_SLIGHT_MODERATE:
|
||||
weathercondition = bundle.getString("THUNDERSTORM_SLIGHT_MODERATE");
|
||||
break;
|
||||
case DRIZZLE_FREEZING_MODERATE_HEAVY:
|
||||
weathercondition = bundle.getString("DRIZZLE_FREEZING_MODERATE_HEAVY");
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
|
||||
return weathercondition;
|
||||
}
|
||||
}
|
||||
@@ -1,47 +0,0 @@
|
||||
/*
|
||||
Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file
|
||||
except in compliance with the License. A copy of the License is located at
|
||||
|
||||
http://aws.amazon.com/apache2.0/
|
||||
|
||||
or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for
|
||||
the specific language governing permissions and limitations under the License.
|
||||
*/
|
||||
|
||||
package com.mowesta.service.alexa.impl;
|
||||
|
||||
import com.amazon.ask.dispatcher.request.handler.HandlerInput;
|
||||
import com.amazon.ask.dispatcher.request.handler.RequestHandler;
|
||||
import com.amazon.ask.dispatcher.request.handler.impl.IntentRequestHandler;
|
||||
import com.amazon.ask.model.IntentRequest;
|
||||
import com.amazon.ask.model.Response;
|
||||
|
||||
import java.util.Locale;
|
||||
import java.util.Optional;
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
import static com.amazon.ask.request.Predicates.intentName;
|
||||
|
||||
public class HelpIntentHandler implements IntentRequestHandler {
|
||||
|
||||
@Override
|
||||
public boolean canHandle(HandlerInput input, IntentRequest intentRequest) {
|
||||
return input.matches(intentName("AMAZON.HelpIntent"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<Response> handle(HandlerInput input, IntentRequest intentRequest) {
|
||||
String[] requestLocale = intentRequest.getLocale().split("-");
|
||||
Locale locale = new Locale(requestLocale[0], requestLocale[1]);
|
||||
ResourceBundle bundle = ResourceBundle.getBundle("Language", locale);
|
||||
|
||||
return input.getResponseBuilder()
|
||||
.withSpeech(bundle.getString("HELP"))
|
||||
.withSimpleCard(bundle.getString("HELPINTENT_NAME"), bundle.getString("HELP"))
|
||||
.withReprompt(bundle.getString("HELP"))
|
||||
.build();
|
||||
}
|
||||
}
|
||||
@@ -1,48 +0,0 @@
|
||||
/*
|
||||
Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file
|
||||
except in compliance with the License. A copy of the License is located at
|
||||
|
||||
http://aws.amazon.com/apache2.0/
|
||||
|
||||
or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for
|
||||
the specific language governing permissions and limitations under the License.
|
||||
*/
|
||||
|
||||
package com.mowesta.service.alexa.impl;
|
||||
|
||||
import com.amazon.ask.dispatcher.request.handler.HandlerInput;
|
||||
import com.amazon.ask.dispatcher.request.handler.impl.IntentRequestHandler;
|
||||
import com.amazon.ask.model.IntentRequest;
|
||||
import com.amazon.ask.model.LaunchRequest;
|
||||
import com.amazon.ask.model.Response;
|
||||
|
||||
import java.util.Locale;
|
||||
import java.util.Optional;
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
import static com.amazon.ask.request.Predicates.requestType;
|
||||
|
||||
public class LaunchRequestHandler implements IntentRequestHandler {
|
||||
|
||||
@Override
|
||||
public boolean canHandle(HandlerInput input, IntentRequest intentRequest) {
|
||||
return input.matches(requestType(LaunchRequest.class));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<Response> handle(HandlerInput input, IntentRequest intentRequest) {
|
||||
String[] requestLocale = intentRequest.getLocale().split("-");
|
||||
Locale locale = new Locale(requestLocale[0], requestLocale[1]);
|
||||
ResourceBundle bundle = ResourceBundle.getBundle("Language", locale);
|
||||
|
||||
return input.getResponseBuilder()
|
||||
.withSpeech(bundle.getString("LAUNCH"))
|
||||
.withSimpleCard(bundle.getString("LAUNCH_NAME"), bundle.getString("LAUNCH"))
|
||||
.withReprompt(bundle.getString("LAUNCH"))
|
||||
.build();
|
||||
}
|
||||
|
||||
}
|
||||
-38
@@ -1,38 +0,0 @@
|
||||
/*
|
||||
Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file
|
||||
except in compliance with the License. A copy of the License is located at
|
||||
|
||||
http://aws.amazon.com/apache2.0/
|
||||
|
||||
or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for
|
||||
the specific language governing permissions and limitations under the License.
|
||||
*/
|
||||
|
||||
package com.mowesta.service.alexa.impl;
|
||||
|
||||
import com.amazon.ask.dispatcher.request.handler.HandlerInput;
|
||||
import com.amazon.ask.dispatcher.request.handler.RequestHandler;
|
||||
import com.amazon.ask.model.Response;
|
||||
import com.amazon.ask.model.SessionEndedRequest;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import static com.amazon.ask.request.Predicates.requestType;
|
||||
|
||||
public class SessionEndedRequestHandler implements RequestHandler {
|
||||
|
||||
@Override
|
||||
public boolean canHandle(HandlerInput input) {
|
||||
return input.matches(requestType(SessionEndedRequest.class));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<Response> handle(HandlerInput input) {
|
||||
// any cleanup logic goes here
|
||||
return input.getResponseBuilder().build();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,46 +0,0 @@
|
||||
package com.mowesta.service.alexa.impl;
|
||||
|
||||
/**
|
||||
* Service that provides the time span for the weatherforecast.
|
||||
*
|
||||
* @author Katharina
|
||||
*/
|
||||
public class TimespanService {
|
||||
|
||||
private int start;
|
||||
|
||||
private int end;
|
||||
|
||||
/**
|
||||
* Constructor that sets the start time and end time.
|
||||
*
|
||||
* @param start The start time.
|
||||
*/
|
||||
public TimespanService(int start) {
|
||||
this.start = start;
|
||||
if (start >= 24) {
|
||||
this.end = start + 24;
|
||||
} else {
|
||||
this.end = 24;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the start time.
|
||||
*
|
||||
* @return The start time.
|
||||
*/
|
||||
public int getStart() {
|
||||
return start;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the end time.
|
||||
*
|
||||
* @return The end time.
|
||||
*/
|
||||
public int getEnd() {
|
||||
return end;
|
||||
}
|
||||
|
||||
}
|
||||
-337
@@ -1,337 +0,0 @@
|
||||
package com.mowesta.service.alexa.impl;
|
||||
|
||||
import com.mowesta.api.weather.WeatherCondition;
|
||||
import com.mowesta.api.weather.WeatherForecast;
|
||||
import com.mowesta.api.weather.WeatherType;
|
||||
|
||||
import org.apache.logging.log4j.util.Strings;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
import java.text.MessageFormat;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
/**
|
||||
* Service that provides the maximum/minimum Temperature, the maximum Windspeed, a map with the WeatherTypes and the weather warnings.
|
||||
*
|
||||
* @author Katharina
|
||||
*/
|
||||
public class WeatherConditionService {
|
||||
|
||||
private Double minTemperature;
|
||||
private Double maxTemperature;
|
||||
private Double maxWindspeed;
|
||||
|
||||
private Map<WeatherType, Integer> weatherTypeMap = new HashMap<>();
|
||||
|
||||
/**
|
||||
* Constructor that sets the minimum/maximum temperature, the maximum wind speed and the map with the WeatherTypes.
|
||||
*
|
||||
* @param weatherForecast The weather forecast.
|
||||
* @param timespanService The time span for the forecast (today, tomorrow, the day after tomorrow).
|
||||
*/
|
||||
public WeatherConditionService(final WeatherForecast weatherForecast, TimespanService timespanService) {
|
||||
|
||||
if (weatherForecast == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = 0; i < weatherForecast.getConditions().size(); i++) {
|
||||
|
||||
WeatherCondition condition = weatherForecast.getConditions().get(i);
|
||||
|
||||
if (timespanService.getStart() != -1 && condition.getHour() >= timespanService.getStart() && condition.getHour() < timespanService.getEnd()) {
|
||||
if (minTemperature == null || condition.getTemperature() < minTemperature) {
|
||||
minTemperature = weatherForecast.getConditions().get(i).getTemperature();
|
||||
}
|
||||
|
||||
if (maxTemperature == null || condition.getTemperature() > maxTemperature) {
|
||||
maxTemperature = weatherForecast.getConditions().get(i).getTemperature();
|
||||
}
|
||||
|
||||
if (maxWindspeed == null || condition.getWindSpeed() > maxWindspeed) {
|
||||
maxWindspeed = weatherForecast.getConditions().get(i).getWindSpeed();
|
||||
}
|
||||
|
||||
if (weatherTypeMap.isEmpty()) {
|
||||
weatherTypeMap.put(condition.getType(), 1);
|
||||
} else if (weatherTypeMap.containsKey(condition.getType())) {
|
||||
weatherTypeMap.put(condition.getType(), weatherTypeMap.get(condition.getType()) + 1);
|
||||
} else {
|
||||
weatherTypeMap.put(condition.getType(), 1);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor that sets the minimum/maximum temperature and the maximum wind speed.
|
||||
*
|
||||
* @param minTemperature The minimum temperature.
|
||||
* @param maxTemperature The maximum temperature.
|
||||
* @param maxWindspeed The maximum wind speed.
|
||||
*/
|
||||
public WeatherConditionService(Double minTemperature, Double maxTemperature, Double maxWindspeed) {
|
||||
this.minTemperature = minTemperature;
|
||||
this.maxTemperature = maxTemperature;
|
||||
this.maxWindspeed = maxWindspeed;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the weather forecast as String.
|
||||
*
|
||||
* @param bundle The ResourceBundle.
|
||||
* @return The weather forecast.
|
||||
*/
|
||||
public String getForecast(ResourceBundle bundle) {
|
||||
return getTempForecast(bundle) + getDominantWeatherForecastTypes(bundle) + getWarningString(bundle);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the clothing recommendation as String.
|
||||
*
|
||||
* @param bundle The ResourceBundle.
|
||||
* @return The clothing recommendation.
|
||||
*/
|
||||
public String getClothingRecommendation(ResourceBundle bundle) {
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
if (maxTemperature != null) {
|
||||
sb.append(getMaxTempClothingRecommendation(bundle));
|
||||
}
|
||||
|
||||
sb.append(getWeathertypeClothingRecommendation(bundle));
|
||||
sb.append(getWarningString(bundle));
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the maximum/minimum temperature as String for weather forecast.
|
||||
*
|
||||
* @param bundle The ResourceBundle.
|
||||
* @return The maximum/minimum temperature.
|
||||
*/
|
||||
private String getTempForecast(ResourceBundle bundle) {
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
if (maxTemperature != null) {
|
||||
String maxTemp = formatTemperature(maxTemperature);
|
||||
sb.append(MessageFormat.format(bundle.getString("MAXTEMP"), maxTemp));
|
||||
}
|
||||
|
||||
if (maxTemperature != null && minTemperature != null) {
|
||||
sb.append(bundle.getString("MIN_AND_MAX"));
|
||||
}
|
||||
|
||||
if (minTemperature != null) {
|
||||
String minTemp = formatTemperature(minTemperature);
|
||||
sb.append(MessageFormat.format(bundle.getString("MINTEMP"), minTemp));
|
||||
}
|
||||
|
||||
sb.append(".");
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the two most common weather types as String.
|
||||
*
|
||||
* @param bundle The ResourceBundle.
|
||||
* @return The two most common weather types.
|
||||
*/
|
||||
private String getDominantWeatherForecastTypes(ResourceBundle bundle) {
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
if (!weatherTypeMap.isEmpty()) {
|
||||
Map.Entry<WeatherType, Integer> maxWeather = Collections.max(weatherTypeMap.entrySet(), Comparator.comparingInt(Map.Entry::getValue));
|
||||
weatherTypeMap.remove(maxWeather.getKey());
|
||||
String maxWeatherString = ForecastWeatherToStringConverter.convertToString(maxWeather.getKey(), bundle);
|
||||
String secMaxWeatherString = "";
|
||||
if (!weatherTypeMap.isEmpty()) {
|
||||
Map.Entry<WeatherType, Integer> secMaxWeather = Collections.max(weatherTypeMap.entrySet(), Comparator.comparingInt(Map.Entry::getValue));
|
||||
secMaxWeatherString = ForecastWeatherToStringConverter.convertToString(secMaxWeather.getKey(), bundle);
|
||||
}
|
||||
|
||||
sb.append(MessageFormat.format(bundle.getString("ADD_MAXWEATHER"), maxWeatherString));
|
||||
if (!Strings.isBlank(secMaxWeatherString) && !maxWeatherString.equals(secMaxWeatherString)) {
|
||||
sb.append(MessageFormat.format(bundle.getString("ADD_SEC_MAXWEATHER"), secMaxWeatherString));
|
||||
}
|
||||
sb.append(".");
|
||||
}
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the clothing recommendation based on the weather type.
|
||||
*
|
||||
* @param bundle The ResourceBundle.
|
||||
* @return The clothing recommendation based on the weather type.
|
||||
*/
|
||||
private String getWeathertypeClothingRecommendation(ResourceBundle bundle) {
|
||||
if (!weatherTypeMap.isEmpty()) {
|
||||
|
||||
Map.Entry<WeatherType, Integer> maxWeather = Collections.max(weatherTypeMap.entrySet(), Comparator.comparingInt(Map.Entry::getValue));
|
||||
|
||||
return ClothingWeatherToStringConverter.convertToString(maxWeather.getKey(), bundle) + ".";
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks and returns the possible weather warnings as String.
|
||||
*
|
||||
* @param bundle The resource bundle.
|
||||
* @return The weather warning.
|
||||
*/
|
||||
public String getWarningString(ResourceBundle bundle) {
|
||||
if (maxWindspeed != null && minTemperature != null && maxTemperature != null) {
|
||||
String warning = getWindwarning(maxWindspeed, bundle) +
|
||||
getHeatWarning(maxTemperature, bundle) +
|
||||
getFrostWarning(minTemperature, bundle);
|
||||
if (!Strings.isBlank(warning))
|
||||
return MessageFormat.format(bundle.getString("WARNING"), warning);
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the wind warning.
|
||||
*
|
||||
* @param windspeed The maximum windspeed of the day.
|
||||
* @param bundle The resource bundle.
|
||||
* @return The wind warning.
|
||||
*/
|
||||
private String getWindwarning(double windspeed, ResourceBundle bundle) {
|
||||
|
||||
if (windspeed >= 14) {
|
||||
if (windspeed <= 17) {
|
||||
return bundle.getString("WARNING_WIND1");
|
||||
}
|
||||
if (windspeed <= 20) {
|
||||
return bundle.getString("WARNING_WIND2");
|
||||
}
|
||||
if (windspeed <= 24) {
|
||||
return bundle.getString("WARNING_WIND3");
|
||||
}
|
||||
if (windspeed <= 28) {
|
||||
return bundle.getString("WARNING_WIND4");
|
||||
}
|
||||
if (windspeed <= 33) {
|
||||
return bundle.getString("WARNING_WIND5");
|
||||
}
|
||||
if (windspeed > 33) {
|
||||
return bundle.getString("WARNING_WIND6");
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the heat warning.
|
||||
*
|
||||
* @param maxTemperature The maximum temperature of the day.
|
||||
* @param bundle The resource bundle.
|
||||
* @return The heat warning.
|
||||
*/
|
||||
private String getHeatWarning(double maxTemperature, ResourceBundle bundle) {
|
||||
if (maxTemperature >= 32) {
|
||||
return bundle.getString("WARNING_HEAT");
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the frost warning.
|
||||
*
|
||||
* @param minTemperature The minimum temperature of the day.
|
||||
* @param bundle The resource bundle.
|
||||
* @return The frost warning.
|
||||
*/
|
||||
private String getFrostWarning(double minTemperature, ResourceBundle bundle) {
|
||||
|
||||
if (minTemperature < 0) {
|
||||
if (minTemperature >= -2) {
|
||||
return bundle.getString("WARNING_FROST1");
|
||||
}
|
||||
if (minTemperature >= -5) {
|
||||
return bundle.getString("WARNING_FROST2");
|
||||
}
|
||||
if (minTemperature >= -10) {
|
||||
return bundle.getString("WARNING_FROST3");
|
||||
}
|
||||
if (minTemperature >= -15) {
|
||||
return bundle.getString("WARNING_FROST4");
|
||||
}
|
||||
if (minTemperature < -15) {
|
||||
return bundle.getString("WARNING_FROST5");
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the minimum temperature.
|
||||
*
|
||||
* @return The minimum temperature.
|
||||
*/
|
||||
public Double getMinTemperature() {
|
||||
return minTemperature;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the maximum temperature.
|
||||
*
|
||||
* @return The maximum temperature.
|
||||
*/
|
||||
public Double getMaxTemperature() {
|
||||
return maxTemperature;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the temperature as String.
|
||||
*
|
||||
* @param temperature The temperature (double).
|
||||
* @return The temperature.
|
||||
*/
|
||||
private String formatTemperature(Double temperature) {
|
||||
DecimalFormat decimalFormat = new DecimalFormat("#.#");
|
||||
String maxTemp = decimalFormat.format(temperature).replaceAll("\\.", ",");
|
||||
String[] splitMaxTemp = maxTemp.split(",");
|
||||
if (splitMaxTemp.length > 1 && splitMaxTemp[1].equals("0")) maxTemp = splitMaxTemp[0];
|
||||
return maxTemp;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a clothing recommendation.
|
||||
*
|
||||
* @param bundle The resource bundle.
|
||||
* @return The clothing recommendation.
|
||||
*/
|
||||
private String getMaxTempClothingRecommendation(ResourceBundle bundle) {
|
||||
if (maxTemperature <= 10) {
|
||||
return bundle.getString("WARM_CLOTHING");
|
||||
}
|
||||
if (maxTemperature <= 20) {
|
||||
return bundle.getString("JACKET_VEST");
|
||||
}
|
||||
if (maxTemperature <= 30) {
|
||||
return bundle.getString("LIGHT_JACKET");
|
||||
}
|
||||
if (maxTemperature > 30) {
|
||||
return bundle.getString("LIGHT_CLOTHIHG");
|
||||
}
|
||||
return "";
|
||||
}
|
||||
}
|
||||
-102
@@ -1,102 +0,0 @@
|
||||
package com.mowesta.service.alexa.impl;
|
||||
|
||||
import com.amazon.ask.dispatcher.request.handler.HandlerInput;
|
||||
import com.amazon.ask.dispatcher.request.handler.impl.IntentRequestHandler;
|
||||
import com.amazon.ask.model.IntentRequest;
|
||||
import com.amazon.ask.model.Response;
|
||||
import com.mowesta.api.Language;
|
||||
import com.mowesta.api.location.Location;
|
||||
import com.mowesta.api.weather.WeatherForecast;
|
||||
import com.mowesta.service.session.LocationSessionBean;
|
||||
import com.mowesta.service.session.WeatherSessionBean;
|
||||
|
||||
import java.text.MessageFormat;
|
||||
import java.util.Optional;
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
import static com.amazon.ask.request.Predicates.intentName;
|
||||
|
||||
/**
|
||||
* Tells the user the weather for today / tomorrow / the day after for a location.
|
||||
*
|
||||
* @author Katharina
|
||||
*/
|
||||
public class WeatherForecastIntentHandler implements IntentRequestHandler {
|
||||
|
||||
|
||||
LocationSessionBean locationSessionBean;
|
||||
|
||||
WeatherSessionBean weatherSessionBean;
|
||||
|
||||
AlexaIntentService alexaIntentService;
|
||||
|
||||
|
||||
public WeatherForecastIntentHandler(LocationSessionBean locationSessionBean, WeatherSessionBean weatherSessionBean) {
|
||||
this.locationSessionBean = locationSessionBean;
|
||||
this.weatherSessionBean = weatherSessionBean;
|
||||
alexaIntentService = new AlexaIntentService(this.locationSessionBean, this.weatherSessionBean);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canHandle(HandlerInput input, IntentRequest intentRequest) {
|
||||
return input.matches(intentName("WeatherForecastIntent"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<Response> handle(HandlerInput input, IntentRequest intentRequest) {
|
||||
ResourceBundle bundle = alexaIntentService.getResourceBundle(intentRequest);
|
||||
Language language = alexaIntentService.getLanguage(intentRequest);
|
||||
|
||||
String speechText = "";
|
||||
String city = intentRequest.getIntent().getSlots().get("Stadt").getValue();
|
||||
|
||||
String uppercaseCity = "";
|
||||
if (city != null) uppercaseCity = city.substring(0, 1).toUpperCase() + city.substring(1);
|
||||
|
||||
String timeslot = intentRequest.getIntent().getSlots().get("Zeitpunkt").getValue();
|
||||
TimespanService timespanService = new TimespanService(alexaIntentService.getTime(timeslot, bundle));
|
||||
|
||||
Location location = alexaIntentService.getRequestedLocation(input, intentRequest, language, city);
|
||||
|
||||
|
||||
if (location == null && city != null) {
|
||||
return input.getResponseBuilder()
|
||||
.withSpeech(MessageFormat.format(bundle.getString("ERROR_CITY"), uppercaseCity))
|
||||
.withSimpleCard("Error", MessageFormat.format(bundle.getString("ERROR_CITY"), uppercaseCity))
|
||||
.build();
|
||||
} else if (location == null && city == null) {
|
||||
String errorText = bundle.getString("ERROR_LOCATION");
|
||||
return input.getResponseBuilder()
|
||||
.withSpeech(errorText)
|
||||
.withSimpleCard("Error", bundle.getString("ERROR_LOCATION"))
|
||||
.build();
|
||||
}
|
||||
|
||||
|
||||
WeatherForecast weatherForecast = weatherSessionBean.getForecast(location.getCoordinate());
|
||||
|
||||
final WeatherConditionService weatherConditionService = new WeatherConditionService(weatherForecast, timespanService);
|
||||
|
||||
if (weatherForecast == null || weatherConditionService.getMinTemperature() == null && weatherConditionService.getMaxTemperature() == null) {
|
||||
input.getResponseBuilder()
|
||||
.withSpeech(bundle.getString("ERROR_WEATHERFORECAST"))
|
||||
.withSimpleCard(bundle.getString("WEATHERFORECAST_NAME"), bundle.getString("ERROR_WEATHERFORECAST"))
|
||||
.build();
|
||||
}
|
||||
|
||||
if (city != null) {
|
||||
speechText += MessageFormat.format(bundle.getString("WEATHERFORECAST_WITH_LOCATION"), uppercaseCity, timeslot);
|
||||
} else
|
||||
speechText += MessageFormat.format(bundle.getString("WEATHERFORECAST_WITHOUT_LOCATION"), timeslot.substring(0, 1).toUpperCase(), timeslot.substring(1));
|
||||
|
||||
|
||||
speechText += weatherConditionService.getForecast(bundle);
|
||||
|
||||
return input.getResponseBuilder()
|
||||
.withSpeech(speechText)
|
||||
.withSimpleCard(bundle.getString("WEATHERFORECAST_NAME"), speechText)
|
||||
.build();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
-107
@@ -1,107 +0,0 @@
|
||||
package com.mowesta.service.alexa.impl;
|
||||
|
||||
import com.mowesta.api.weather.WeatherType;
|
||||
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
/**
|
||||
* Converts each weather type to a specific string for the current weather.
|
||||
*
|
||||
* @author Katharina
|
||||
*/
|
||||
public class WeatherTypeToStringConverter {
|
||||
/**
|
||||
* Returns the weather as String depending on the most common weather type.
|
||||
*
|
||||
* @param weatherType The most common weather type.
|
||||
* @param bundle The resource bundle.
|
||||
* @return The weather.
|
||||
*/
|
||||
public String convertToString(WeatherType weatherType, ResourceBundle bundle) {
|
||||
String weathercondition = "";
|
||||
|
||||
switch (weatherType) {
|
||||
|
||||
case UNKNOWN:
|
||||
break;
|
||||
case FOG_DEPOSITING_RIME:
|
||||
case FOG:
|
||||
weathercondition = bundle.getString("W_FOG");
|
||||
break;
|
||||
case CLOUDY:
|
||||
weathercondition = bundle.getString("W_CLOUDY");
|
||||
break;
|
||||
case CLEAR_SKY:
|
||||
weathercondition = bundle.getString("W_CLEAR");
|
||||
break;
|
||||
case SNOW_GRAINS:
|
||||
weathercondition = bundle.getString("W_SNOW_GRAINS");
|
||||
break;
|
||||
case MAINLY_CLEAR:
|
||||
weathercondition = bundle.getString("W_MAINLY_CLEAR");
|
||||
break;
|
||||
case HEAVY_DRIZZLE:
|
||||
weathercondition = bundle.getString("W_HEAVY_DRIZZLE");
|
||||
break;
|
||||
case PARTLY_CLOUDY:
|
||||
weathercondition = bundle.getString("W_PARTLY_CLOUDY");
|
||||
break;
|
||||
case SLIGHT_DRIZZLE:
|
||||
weathercondition = bundle.getString("W_SLIGHT_DRIZZLE");
|
||||
break;
|
||||
case MODERATE_DRIZZLE:
|
||||
weathercondition = bundle.getString("W_MODERATE_DRIZZLE");
|
||||
break;
|
||||
case RAIN_SHOWER_SLIGHT:
|
||||
case SLIGHT_RAIN_NOT_FREEZING:
|
||||
weathercondition = bundle.getString("W_SLIGHT_RAIN");
|
||||
break;
|
||||
case SNOW_SHOWER_SLIGHT:
|
||||
case SLIGHT_FALL_OF_SNOWFLAKES:
|
||||
weathercondition = bundle.getString("W_SLIGHT_SNOW");
|
||||
break;
|
||||
case RAIN_SHOWER_VIOLENT:
|
||||
case HEAVY_RAIN_NOT_FREEZING:
|
||||
weathercondition = bundle.getString("W_HEAVY_RAIN");
|
||||
break;
|
||||
case RAIN_FREEZING_SLIGHT:
|
||||
weathercondition = bundle.getString("W_FREEZ_RAIN");
|
||||
break;
|
||||
case DRIZZLE_FREEZING_SLIGHT:
|
||||
weathercondition = bundle.getString("W_FREEZ_DRIZZLE");
|
||||
break;
|
||||
case THUNDERSTORM_HAIL_HEAVY:
|
||||
weathercondition = bundle.getString("W_THUNDERSTORM_HAIL");
|
||||
break;
|
||||
case HEAVY_FALL_OF_SNOWFLAKES:
|
||||
weathercondition = bundle.getString("W_HEAVY_SNOW");
|
||||
break;
|
||||
case MODERATE_RAIN_NOT_FREEZING:
|
||||
weathercondition = bundle.getString("W_RAIN");
|
||||
break;
|
||||
case RAIN_SHOWER_MODERATE_HEAVY:
|
||||
weathercondition = bundle.getString("W_MODHEAV_RAIN");
|
||||
break;
|
||||
case SNOW_SHOWER_MODERATE_HEAVY:
|
||||
weathercondition = bundle.getString("W_MODHEAV_SNOW");
|
||||
break;
|
||||
case MODERATE_FALL_OF_SNOWFLAKES:
|
||||
weathercondition = bundle.getString("W_SNOW");
|
||||
break;
|
||||
case RAIN_FREEZING_MODERATE_HEAVY:
|
||||
weathercondition = bundle.getString("W_FREEZHEAV_RAIN");
|
||||
break;
|
||||
case THUNDERSTORM_SLIGHT_MODERATE:
|
||||
weathercondition = bundle.getString("W_THUNDER");
|
||||
break;
|
||||
case DRIZZLE_FREEZING_MODERATE_HEAVY:
|
||||
weathercondition = bundle.getString("W_DRIZZLE_FREEZ");
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
|
||||
return weathercondition;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,110 +0,0 @@
|
||||
#General
|
||||
ERROR_LOCATION = Dein aktueller Ort konnte nicht gefunden werden.
|
||||
ERROR_CITY = Die Stadt {0} wurde nicht gefunden.
|
||||
WARNING = Vorsicht! {0}
|
||||
TODAY = heute
|
||||
TOMORROW = morgen
|
||||
DAY_AFTER_TOMORROW = übermorgen
|
||||
|
||||
#ClothingRecommendation
|
||||
RECOMMENDATION_NAME = Kleidungsempfehlung
|
||||
RECOMMENDATION_WITH_LOCATION = In {0} empfehle ich dir {1}
|
||||
RECOMMENDATION_WITHOUT_LOCATION = Ich empfehle ich dir {0}
|
||||
WARM_CLOTHING = \ warme Kleidung
|
||||
JACKET_VEST = \ eine Jacke oder Weste
|
||||
LIGHT_JACKET = \ eine leichte Jacke
|
||||
LIGHT_CLOTHIHG = \ leichte Kleidung
|
||||
ERROR_CLOTHING = Es wurde zurzeit keine Kleidungsempfehlung gefunden.
|
||||
|
||||
#ClothingWeatherToStringConverter
|
||||
CLEAR = \ und einen Schutz gegen die Sonne
|
||||
WET = \ und einen Regenschirm oder wasserfeste Kleidung
|
||||
|
||||
#CurrentWeather
|
||||
CURRENTWEATHERHANDLER_NAME = Aktuelles Wetter
|
||||
CURRENTWEATHER_WITH_LOCATION = In {0} sind zurzeit {1} Grad {2}.
|
||||
CURRENTWEATHER_WITHOUT_LOCATION = Es sind zurzeit {0} Grad {1}.
|
||||
ERROR_CURRENTWEATHER = Es wurde zurzeit kein aktuelles Wetter gefunden.
|
||||
|
||||
#Weather warning
|
||||
WARNING_FROST1 = \ Warnung vor geringem Frost.
|
||||
WARNING_FROST2 = \ Warnung vor leichten Frost.
|
||||
WARNING_FROST3 = \ Warnung vor mäßigen Frost.
|
||||
WARNING_FROST4 = \ Warnung vor strengem Frost.
|
||||
WARNING_FROST5 = \ Warnung vor sehr strengem Frost.
|
||||
WARNING_HEAT = \ Warnung vor Hitze.
|
||||
WARNING_WIND1 = Warnung vor starken Windböen.
|
||||
WARNING_WIND2 = Warnung vor stürmischen Wind.
|
||||
WARNING_WIND3 = Warnung vor Sturm.
|
||||
WARNING_WIND4 = Warnung vor schwerem Sturm.
|
||||
WARNING_WIND5 = Warnung vor orkanartigen Sturm.
|
||||
WARNING_WIND6 = Warnung vor einem Orkan.
|
||||
|
||||
#WeatherForecast
|
||||
WEATHERFORECAST_NAME = Wettervorhersage
|
||||
WEATHERFORECAST_WITH_LOCATION = In {0} beträgt {1} die
|
||||
WEATHERFORECAST_WITHOUT_LOCATION = {0}{1} beträgt die
|
||||
MAXTEMP = \ Maximaltemperatur {0} Grad
|
||||
MIN_AND_MAX = \ und die
|
||||
MINTEMP = \ Minimaltemperatur {0} Grad
|
||||
ADD_MAXWEATHER = \ Zudem wird es {0}
|
||||
ADD_SEC_MAXWEATHER = \ und teilweise wird es {0}
|
||||
ERROR_WEATHERFORECAST = Es wurde zurzeit keine Wettervorhersage gefunden.
|
||||
|
||||
#ForecastWeatherToStringConverter
|
||||
FOG = \ nebelig
|
||||
CLOUDY = \ bewölkt
|
||||
CLEAR_SKY = \ klar am Himmel
|
||||
SNOW_GRAINS = \ Graupelschauer geben
|
||||
HEAVY_DRIZZLE = \ starken Nieselregen geben
|
||||
SLIGHT_DRIZZLE = \ leichten Nieselregen geben
|
||||
MODERATE_DRIZZLE = \ Nieselregen geben
|
||||
SLIGHT_RAIN = \ leicht regnen
|
||||
SLIGHT_SNOW = \ leichten Schneefall geben
|
||||
HEAVY_RAIN = \ Starkregen geben
|
||||
RAIN_FREEZING_SLIGHT = \ gefrierenden leichten Regen geben
|
||||
DRIZZLE_FREEZING_SLIGHT = \ gefrierenden leichten Nieselregen geben
|
||||
THUNDERSTORM_HAIL_HEAVY = \ Hagelschauer und Gewitter geben
|
||||
HEAVY_SNOW = \ starken Schneefall geben
|
||||
RAIN = \ regnen
|
||||
SNOW = \ schneien
|
||||
RAIN_FREEZING_MODERATE_HEAVY = \ gefrierenden Regen geben
|
||||
THUNDERSTORM_SLIGHT_MODERATE = \ mitunter gewittern
|
||||
DRIZZLE_FREEZING_MODERATE_HEAVY = \ gefrierenden Sprühregen geben
|
||||
|
||||
#WeatherTypeToStringConverter
|
||||
W_FOG = und es ist nebelig
|
||||
W_CLOUDY = und es ist bewölkt
|
||||
W_CLEAR = und der Himmel ist klar
|
||||
W_SNOW_GRAINS = und es gibt Graupelschauer
|
||||
W_MAINLY_CLEAR = und der Himmel ist hauptsächlich klar
|
||||
W_HEAVY_DRIZZLE = und es gibt einen starken Nieselregen
|
||||
W_PARTLY_CLOUDY = und es ist teilweise bewölkt
|
||||
W_SLIGHT_DRIZZLE = und es gibt leichten Nieselregen
|
||||
W_MODERATE_DRIZZLE = und es gibt Nieselregen
|
||||
W_SLIGHT_RAIN = und es regnet leicht
|
||||
W_SLIGHT_SNOW = und es gibt leichten Schneefall
|
||||
W_HEAVY_RAIN = und es gibt Starkregen
|
||||
W_FREEZ_RAIN = und es gibt gefrierenden leichten Regen
|
||||
W_FREEZ_DRIZZLE = und es gibt gefrierenden leichten Nieselregen
|
||||
W_THUNDERSTORM_HAIL = und es kann zu Hagelschauern und Gewitter kommen
|
||||
W_HEAVY_SNOW = und es gibt starken Schneefall
|
||||
W_RAIN = und es regnet
|
||||
W_MODHEAV_RAIN = und es regnet teilweise schwer
|
||||
W_MODHEAV_SNOW = und es schneit teilweise stark
|
||||
W_SNOW = und es schneit
|
||||
W_FREEZHEAV_RAIN = und es gibt gefrierenden Regen
|
||||
W_THUNDER = und es gewittert teilweise
|
||||
W_DRIZZLE_FREEZ = und es kommt zu gefrierenden Sprühregen
|
||||
|
||||
#CancelAndStopIntentHandler
|
||||
STOPINTENT_NAME = Stop
|
||||
STOP = Auf Wiedersehen!
|
||||
|
||||
#HelpIntentHandler
|
||||
HELPINTENT_NAME = Hilfe
|
||||
HELP = Du kannst mich nach dem Wetter fragen!
|
||||
|
||||
#LaunchRequestHandler
|
||||
LAUNCH_NAME = Willkommen
|
||||
LAUNCH = Willkommen zu Mowesta! Du kannst mich nach dem Wetter fragen.
|
||||
@@ -1,110 +0,0 @@
|
||||
#General
|
||||
ERROR_LOCATION = Your current location could not be found.
|
||||
ERROR_CITY = The city {0} was not found.
|
||||
WARNING = Caution! {0}
|
||||
TODAY = today
|
||||
TOMORROW = tomorrow
|
||||
DAY_AFTER_TOMORROW = the day after tomorrow
|
||||
|
||||
#ClothingRecommendation
|
||||
RECOMMENDATION_NAME = Clothing recommendation
|
||||
RECOMMENDATION_WITH_LOCATION = In {0} I recommend you {1}
|
||||
RECOMMENDATION_WITHOUT_LOCATION = I recommend you {0}
|
||||
WARM_CLOTHING = \ warm clothing
|
||||
JACKET_VEST = \ a jacket or vest
|
||||
LIGHT_JACKET = \ a light jacket
|
||||
LIGHT_CLOTHIHG = \ light clothing
|
||||
ERROR_CLOTHING = No clothing recommendation was found at the moment.
|
||||
|
||||
#ClothingWeatherToStringConverter
|
||||
CLEAR = \ and protection against the sun
|
||||
WET = \ and an umbrella or waterproof clothing
|
||||
|
||||
#CurrentWeather
|
||||
CURRENTWEATHERHANDLER_NAME = Current weather
|
||||
CURRENTWEATHER_WITH_LOCATION = In {0} there are currently {1} degrees {2}.
|
||||
CURRENTWEATHER_WITHOUT_LOCATION = It is currently {0} degrees {1}.
|
||||
ERROR_CURRENTWEATHER = No current weather was found at the moment.
|
||||
|
||||
#Weather warning
|
||||
WARNING_FROST1 = \ Warning of slight frost.
|
||||
WARNING_FROST2 = \ Warning of light frost.
|
||||
WARNING_FROST3 = \ Warning of moderate frost.
|
||||
WARNING_FROST4 = \ Warning of severe frost.
|
||||
WARNING_FROST5 = \ Warning of very severe frost.
|
||||
WARNING_HEAT = \ Warning of heat.
|
||||
WARNING_WIND1 = Warning of strong gusts of wind.
|
||||
WARNING_WIND2 = Warning of stormy winds.
|
||||
WARNING_WIND3 = Warning of storm.
|
||||
WARNING_WIND4 = Warning of a heavy storm.
|
||||
WARNING_WIND5 = Warning of a hurricane storm.
|
||||
WARNING_WIND6 = Warning of a hurricane.
|
||||
|
||||
#WeatherForecast
|
||||
WEATHERFORECAST_NAME = Weather forecast
|
||||
WEATHERFORECAST_WITH_LOCATION = In {0} {1} is the
|
||||
WEATHERFORECAST_WITHOUT_LOCATION = {0}{1} is the
|
||||
MAXTEMP = \ maximum temperature {0} degrees
|
||||
MIN_AND_MAX = \ and the
|
||||
MINTEMP = \ minimal temperature {0} degrees
|
||||
ADD_MAXWEATHER = \ In addition, it will be {0}
|
||||
ADD_SEC_MAXWEATHER = \ and partly {0}
|
||||
ERROR_WEATHERFORECAST = No weather forecast has been found at the moment.
|
||||
|
||||
#ForecastWeatherToStringConverter
|
||||
FOG = \ foggy
|
||||
CLOUDY = \ cloudy
|
||||
CLEAR_SKY = \ clear in the sky
|
||||
SNOW_GRAINS = \ sleet showers
|
||||
HEAVY_DRIZZLE = \ heavy drizzle
|
||||
SLIGHT_DRIZZLE = \ slight drizzle
|
||||
MODERATE_DRIZZLE = \ moderate drizzle
|
||||
SLIGHT_RAIN = \ rain lightly
|
||||
SLIGHT_SNOW = \ light snowfall
|
||||
HEAVY_RAIN = \ heavy rain
|
||||
RAIN_FREEZING_SLIGHT = \ freezing light rain
|
||||
DRIZZLE_FREEZING_SLIGHT = \ freezing, light drizzle
|
||||
THUNDERSTORM_HAIL_HEAVY = \ hail showers and thunderstorms
|
||||
HEAVY_SNOW = \ heavy snowfall
|
||||
RAIN = \ rain
|
||||
SNOW = \ snow
|
||||
RAIN_FREEZING_MODERATE_HEAVY = \ freezing rain
|
||||
THUNDERSTORM_SLIGHT_MODERATE = \ a thunderstorm
|
||||
DRIZZLE_FREEZING_MODERATE_HEAVY = \ freezing drizzle
|
||||
|
||||
#WeatherTypeToStringConverter
|
||||
W_FOG = and it's foggy
|
||||
W_CLOUDY = and it's cloudy
|
||||
W_CLEAR = and the sky is clear
|
||||
W_SNOW_GRAINS = and there are sleet showers
|
||||
W_MAINLY_CLEAR = and the sky is mostly clear
|
||||
W_HEAVY_DRIZZLE = and there is a heavy drizzle
|
||||
W_PARTLY_CLOUDY = and it is partly cloudy
|
||||
W_SLIGHT_DRIZZLE = and there is light drizzle
|
||||
W_MODERATE_DRIZZLE = and there is drizzle
|
||||
W_SLIGHT_RAIN = and it's raining lightly
|
||||
W_SLIGHT_SNOW = and there is light snowfall
|
||||
W_HEAVY_RAIN = and there is heavy rain
|
||||
W_FREEZ_RAIN = and there is freezing light rain
|
||||
W_FREEZ_DRIZZLE = and there is freezing light drizzle
|
||||
W_THUNDERSTORM_HAIL = and there can be hail showers and thunderstorms
|
||||
W_HEAVY_SNOW = and there is heavy snowfall
|
||||
W_RAIN = and it's raining
|
||||
W_MODHEAV_RAIN = and it's raining heavily at times
|
||||
W_MODHEAV_SNOW = und es schneit teilweise stark
|
||||
W_SNOW = and it's snowing
|
||||
W_FREEZHEAV_RAIN = and there is freezing rain
|
||||
W_THUNDER = and there is some thunderstorm
|
||||
W_DRIZZLE_FREEZ = and there is freezing drizzle
|
||||
|
||||
#CancelAndStopIntentHandler
|
||||
STOPINTENT_NAME = Stop
|
||||
STOP = Goodbye!
|
||||
|
||||
#HelpIntentHandler
|
||||
HELPINTENT_NAME = Help
|
||||
HELP = You can ask me about the weather!
|
||||
|
||||
#LaunchRequestHandler
|
||||
LAUNCH_NAME = Welcome
|
||||
LAUNCH = Welcome to Mowesta! You can ask me about the weather.
|
||||
@@ -1,5 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE xml>
|
||||
<jboss-web>
|
||||
<context-root>alexa</context-root>
|
||||
</jboss-web>
|
||||
@@ -1,22 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<web-app xmlns = "http://xmlns.jcp.org/xml/ns/javaee"
|
||||
xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation = "http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd "
|
||||
version = "4.0">
|
||||
|
||||
<display-name>alexaservlet</display-name>
|
||||
<servlet>
|
||||
<servlet-name>alexaservlet</servlet-name>
|
||||
<servlet-class>com.mowesta.service.alexa.AlexaServlet</servlet-class>
|
||||
</servlet>
|
||||
|
||||
<servlet-mapping>
|
||||
<servlet-name>alexaservlet</servlet-name>
|
||||
<url-pattern>/alexa</url-pattern>
|
||||
</servlet-mapping>
|
||||
|
||||
<!--<welcome-file-list>
|
||||
<welcome-file>index.html</welcome-file>
|
||||
</welcome-file-list>-->
|
||||
|
||||
</web-app>
|
||||
@@ -1,8 +0,0 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>Alexa Context Root</title>
|
||||
</head>
|
||||
<body>
|
||||
Web context Alexa has been loaded successfully.
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,51 @@
|
||||
plugins {
|
||||
id 'io.swagger.core.v3.swagger-gradle-plugin' version '2.2.19'
|
||||
}
|
||||
|
||||
description = 'MoWeSta Service Api'
|
||||
|
||||
configurations {
|
||||
// add a configuration to support swagger generation for jakarta namespace
|
||||
swagger { transitive = true }
|
||||
}
|
||||
|
||||
dependencies {
|
||||
api "jakarta.xml.bind:jakarta.xml.bind-api:${versionJaxb}"
|
||||
api "io.swagger.core.v3:swagger-annotations-jakarta:${versionSwagger}"
|
||||
api "de.grundid.opendatalab:geojson-jackson:${versionGeojson}"
|
||||
api "com.fasterxml.jackson.core:jackson-annotations:${versionJackson}"
|
||||
|
||||
testImplementation "junit:junit:${versionJunit}"
|
||||
testImplementation "org.glassfish.jaxb:jaxb-runtime:${versionJaxb}"
|
||||
|
||||
compileClasspath "jakarta.platform:jakarta.jakartaee-api:${versionJavaee}"
|
||||
|
||||
// explicity require jakarta jaxrs integration for swagger
|
||||
swagger "io.swagger.core.v3:swagger-jaxrs2-jakarta:${versionSwagger}"
|
||||
|
||||
}
|
||||
|
||||
tasks.resolve {
|
||||
outputFileName = 'mowesta'
|
||||
outputFormat = 'JSON'
|
||||
prettyPrint = 'TRUE'
|
||||
resourcePackages = [ 'com.mowesta.api' ]
|
||||
outputDir = file("${project.buildDir}/swagger")
|
||||
classpath = sourceSets.main.runtimeClasspath + sourceSets.main.compileClasspath
|
||||
buildClasspath = configurations.swagger // use jakarta swagger artifacts for processing
|
||||
openApiFile = file("${project.projectDir}/src/main/resources/openapi.json")
|
||||
}
|
||||
|
||||
build {
|
||||
dependsOn 'resolve'
|
||||
}
|
||||
|
||||
// add the swagger defintion to the artifacts published by this module
|
||||
publishing {
|
||||
publications {
|
||||
maven(MavenPublication) {
|
||||
artifact source: "${project.buildDir}/swagger/mowesta.json", extension: "swagger"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+11
-9
@@ -3,18 +3,19 @@ package com.mowesta.api;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlElementWrapper;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
import jakarta.validation.Valid;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import jakarta.xml.bind.annotation.XmlAccessType;
|
||||
import jakarta.xml.bind.annotation.XmlAccessorType;
|
||||
import jakarta.xml.bind.annotation.XmlElement;
|
||||
import jakarta.xml.bind.annotation.XmlElementWrapper;
|
||||
import jakarta.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonAutoDetect;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
|
||||
|
||||
/**
|
||||
* A wrapper class that technically represents an array of
|
||||
@@ -32,7 +33,7 @@ import io.swagger.annotations.ApiModel;
|
||||
getterVisibility = JsonAutoDetect.Visibility.NONE,
|
||||
setterVisibility = JsonAutoDetect.Visibility.NONE,
|
||||
isGetterVisibility = JsonAutoDetect.Visibility.NONE)
|
||||
@ApiModel(description = "Represents a list of elements.")
|
||||
@Schema(description = "Represents a list of elements.")
|
||||
public class Batch<T> {
|
||||
|
||||
/**
|
||||
@@ -43,6 +44,7 @@ public class Batch<T> {
|
||||
@XmlElementWrapper
|
||||
@XmlElement(name="element")
|
||||
@JsonProperty(value="elements")
|
||||
@Schema(description = "The elements contained in this batch.")
|
||||
private List<T> elements = new ArrayList<>();
|
||||
|
||||
/**
|
||||
+9
-9
@@ -1,14 +1,14 @@
|
||||
package com.mowesta.api;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlAttribute;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
import jakarta.xml.bind.annotation.XmlAccessType;
|
||||
import jakarta.xml.bind.annotation.XmlAccessorType;
|
||||
import jakarta.xml.bind.annotation.XmlAttribute;
|
||||
import jakarta.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonAutoDetect;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import io.swagger.v3.oas.annotations.media.Schema.RequiredMode;
|
||||
|
||||
/**
|
||||
* A WGS84 coordinate.
|
||||
@@ -22,21 +22,21 @@ import io.swagger.annotations.ApiModelProperty;
|
||||
getterVisibility = JsonAutoDetect.Visibility.NONE,
|
||||
setterVisibility = JsonAutoDetect.Visibility.NONE,
|
||||
isGetterVisibility = JsonAutoDetect.Visibility.NONE)
|
||||
@ApiModel(description = "Represents a wgs84 coordinate.")
|
||||
@Schema(description = "Represents a wgs84 coordinate.")
|
||||
public class Coordinate {
|
||||
|
||||
/**
|
||||
* The latitude.
|
||||
*/
|
||||
@XmlAttribute(required = true)
|
||||
@ApiModelProperty(value = "The latitude of the coordinate.", required = true)
|
||||
@Schema(description = "The latitude of the coordinate.", requiredMode = RequiredMode.REQUIRED)
|
||||
private double latitude;
|
||||
|
||||
/**
|
||||
* The longitude.
|
||||
*/
|
||||
@XmlAttribute(required = true)
|
||||
@ApiModelProperty(value = "The longitude of the coordinate.", required = true)
|
||||
@Schema(description = "The longitude of the coordinate.", requiredMode = RequiredMode.REQUIRED)
|
||||
private double longitude;
|
||||
|
||||
/**
|
||||
+10
-11
@@ -2,15 +2,14 @@ package com.mowesta.api;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlAttribute;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
import jakarta.xml.bind.annotation.XmlAccessType;
|
||||
import jakarta.xml.bind.annotation.XmlAccessorType;
|
||||
import jakarta.xml.bind.annotation.XmlAttribute;
|
||||
import jakarta.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonAutoDetect;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
|
||||
|
||||
/**
|
||||
@@ -27,35 +26,35 @@ import io.swagger.annotations.ApiModelProperty;
|
||||
getterVisibility = JsonAutoDetect.Visibility.NONE,
|
||||
setterVisibility = JsonAutoDetect.Visibility.NONE,
|
||||
isGetterVisibility = JsonAutoDetect.Visibility.NONE)
|
||||
@ApiModel(description="Represents an entity.")
|
||||
@Schema(description="Represents an entity.")
|
||||
public class Entity {
|
||||
|
||||
/**
|
||||
* The unique identifier of the data.
|
||||
*/
|
||||
@XmlAttribute
|
||||
@ApiModelProperty(value="The unique identifier of the data.")
|
||||
@Schema(description="The unique identifier of the data.")
|
||||
private long id;
|
||||
|
||||
/**
|
||||
* The time stamp when the data was created.
|
||||
*/
|
||||
@XmlAttribute
|
||||
@ApiModelProperty(value="The time stamp when the data was created.")
|
||||
@Schema(description="The time stamp when the data was created.")
|
||||
private long creationTime;
|
||||
|
||||
/**
|
||||
* The time stamp when the data was last modified.
|
||||
*/
|
||||
@XmlAttribute
|
||||
@ApiModelProperty(value="The time stamp when the data was last modified.")
|
||||
@Schema(description="The time stamp when the data was last modified.")
|
||||
private long modificationTime;
|
||||
|
||||
/**
|
||||
* A flag to indicate whether the data was deleted.
|
||||
*/
|
||||
@XmlAttribute
|
||||
@ApiModelProperty(value="A flag to indicate whether the data was deleted.")
|
||||
@Schema(description="A flag to indicate whether the data was deleted.")
|
||||
private boolean deleted;
|
||||
|
||||
/**
|
||||
@@ -0,0 +1,239 @@
|
||||
package com.mowesta.api;
|
||||
|
||||
/**
|
||||
* A stringified list of http status codes to simplfy the use of swagger. These
|
||||
* are the status codes that are defined as integer in HttpServletResponse.
|
||||
*
|
||||
* @author marcus
|
||||
*/
|
||||
public interface HttpStatus {
|
||||
|
||||
/**
|
||||
* Status code (100) indicating the client can continue.
|
||||
*/
|
||||
public static final String CONTINUE = "100";
|
||||
|
||||
/**
|
||||
* Status code (101) indicating the server is switching protocols according to Upgrade header.
|
||||
*/
|
||||
public static final String SWITCHING_PROTOCOLS = "101";
|
||||
|
||||
/**
|
||||
* Status code (200) indicating the request succeeded normally.
|
||||
*/
|
||||
public static final String OK = "200";
|
||||
|
||||
/**
|
||||
* Status code (201) indicating the request succeeded and created a new resource on the server.
|
||||
*/
|
||||
public static final String CREATED = "201";
|
||||
|
||||
/**
|
||||
* Status code (202) indicating that a request was accepted for processing, but was not completed.
|
||||
*/
|
||||
public static final String ACCEPTED = "202";
|
||||
|
||||
/**
|
||||
* Status code (203) indicating that the meta information presented by the client did not originate from the server.
|
||||
*/
|
||||
public static final String NON_AUTHORITATIVE_INFORMATION = "203";
|
||||
|
||||
/**
|
||||
* Status code (204) indicating that the request succeeded but that there was no new information to return.
|
||||
*/
|
||||
public static final String NO_CONTENT = "204";
|
||||
|
||||
/**
|
||||
* Status code (205) indicating that the agent <em>SHOULD</em> reset the document view which caused the request to be
|
||||
* sent.
|
||||
*/
|
||||
public static final String RESET_CONTENT = "205";
|
||||
|
||||
/**
|
||||
* Status code (206) indicating that the server has fulfilled the partial GET request for the resource.
|
||||
*/
|
||||
public static final String PARTIAL_CONTENT = "206";
|
||||
|
||||
/**
|
||||
* Status code (300) indicating that the requested resource corresponds to any one of a set of representations, each
|
||||
* with its own specific location.
|
||||
*/
|
||||
public static final String MULTIPLE_CHOICES = "300";
|
||||
|
||||
/**
|
||||
* Status code (301) indicating that the resource has permanently moved to a new location, and that future references
|
||||
* should use a new URI with their requests.
|
||||
*/
|
||||
public static final String MOVED_PERMANENTLY = "301";
|
||||
|
||||
/**
|
||||
* Status code (302) indicating that the resource has temporarily moved to another location, but that future references
|
||||
* should still use the original URI to access the resource.
|
||||
*
|
||||
* This definition is being retained for backwards compatibility. FOUND is now the preferred definition.
|
||||
*/
|
||||
public static final String MOVED_TEMPORARILY = "302";
|
||||
|
||||
/**
|
||||
* Status code (302) indicating that the resource reside temporarily under a different URI. Since the redirection might
|
||||
* be altered on occasion, the client should continue to use the Request-URI for future requests.(HTTP/1.1) To represent
|
||||
* the status code (302), it is recommended to use this variable.
|
||||
*/
|
||||
public static final String FOUND = "302";
|
||||
|
||||
/**
|
||||
* Status code (303) indicating that the response to the request can be found under a different URI.
|
||||
*/
|
||||
public static final String SEE_OTHER = "303";
|
||||
|
||||
/**
|
||||
* Status code (304) indicating that a conditional GET operation found that the resource was available and not modified.
|
||||
*/
|
||||
public static final String NOT_MODIFIED = "304";
|
||||
|
||||
/**
|
||||
* Status code (305) indicating that the requested resource <em>MUST</em> be accessed through the proxy given by the
|
||||
* <code><em>Location</em></code> field.
|
||||
*/
|
||||
public static final String USE_PROXY = "305";
|
||||
|
||||
/**
|
||||
* Status code (307) indicating that the requested resource resides temporarily under a different URI. The temporary URI
|
||||
* <em>SHOULD</em> be given by the <code><em>Location</em></code> field in the response.
|
||||
*/
|
||||
public static final String TEMPORARY_REDIRECT = "307";
|
||||
|
||||
/**
|
||||
* Status code (400) indicating the request sent by the client was syntactically incorrect.
|
||||
*/
|
||||
public static final String BAD_REQUEST = "400";
|
||||
|
||||
/**
|
||||
* Status code (401) indicating that the request requires HTTP authentication.
|
||||
*/
|
||||
public static final String UNAUTHORIZED = "401";
|
||||
|
||||
/**
|
||||
* Status code (402) reserved for future use.
|
||||
*/
|
||||
public static final String PAYMENT_REQUIRED = "402";
|
||||
|
||||
/**
|
||||
* Status code (403) indicating the server understood the request but refused to fulfill it.
|
||||
*/
|
||||
public static final String FORBIDDEN = "403";
|
||||
|
||||
/**
|
||||
* Status code (404) indicating that the requested resource is not available.
|
||||
*/
|
||||
public static final String NOT_FOUND = "404";
|
||||
|
||||
/**
|
||||
* Status code (405) indicating that the method specified in the <code><em>Request-Line</em></code> is not allowed for
|
||||
* the resource identified by the <code><em>Request-URI</em></code>.
|
||||
*/
|
||||
public static final String METHOD_NOT_ALLOWED = "405";
|
||||
|
||||
/**
|
||||
* Status code (406) indicating that the resource identified by the request is only capable of generating response
|
||||
* entities which have content characteristics not acceptable according to the accept headers sent in the request.
|
||||
*/
|
||||
public static final String NOT_ACCEPTABLE = "406";
|
||||
|
||||
/**
|
||||
* Status code (407) indicating that the client <em>MUST</em> first authenticate itself with the proxy.
|
||||
*/
|
||||
public static final String PROXY_AUTHENTICATION_REQUIRED = "407";
|
||||
|
||||
/**
|
||||
* Status code (408) indicating that the client did not produce a request within the time that the server was prepared
|
||||
* to wait.
|
||||
*/
|
||||
public static final String REQUEST_TIMEOUT = "408";
|
||||
|
||||
/**
|
||||
* Status code (409) indicating that the request could not be completed due to a conflict with the current state of the
|
||||
* resource.
|
||||
*/
|
||||
public static final String CONFLICT = "409";
|
||||
|
||||
/**
|
||||
* Status code (410) indicating that the resource is no longer available at the server and no forwarding address is
|
||||
* known. This condition <em>SHOULD</em> be considered permanent.
|
||||
*/
|
||||
public static final String GONE = "410";
|
||||
|
||||
/**
|
||||
* Status code (411) indicating that the request cannot be handled without a defined
|
||||
* <code><em>Content-Length</em></code>.
|
||||
*/
|
||||
public static final String LENGTH_REQUIRED = "411";
|
||||
|
||||
/**
|
||||
* Status code (412) indicating that the precondition given in one or more of the request-header fields evaluated to
|
||||
* false when it was tested on the server.
|
||||
*/
|
||||
public static final String PRECONDITION_FAILED = "412";
|
||||
|
||||
/**
|
||||
* Status code (413) indicating that the server is refusing to process the request because the request entity is larger
|
||||
* than the server is willing or able to process.
|
||||
*/
|
||||
public static final String REQUEST_ENTITY_TOO_LARGE = "413";
|
||||
|
||||
/**
|
||||
* Status code (414) indicating that the server is refusing to service the request because the
|
||||
* <code><em>Request-URI</em></code> is longer than the server is willing to interpret.
|
||||
*/
|
||||
public static final String REQUEST_URI_TOO_LONG = "414";
|
||||
|
||||
/**
|
||||
* Status code (415) indicating that the server is refusing to service the request because the entity of the request is
|
||||
* in a format not supported by the requested resource for the requested method.
|
||||
*/
|
||||
public static final String UNSUPPORTED_MEDIA_TYPE = "415";
|
||||
|
||||
/**
|
||||
* Status code (416) indicating that the server cannot serve the requested byte range.
|
||||
*/
|
||||
public static final String REQUESTED_RANGE_NOT_SATISFIABLE = "416";
|
||||
|
||||
/**
|
||||
* Status code (417) indicating that the server could not meet the expectation given in the Expect request header.
|
||||
*/
|
||||
public static final String EXPECTATION_FAILED = "417";
|
||||
|
||||
/**
|
||||
* Status code (500) indicating an error inside the HTTP server which prevented it from fulfilling the request.
|
||||
*/
|
||||
public static final String INTERNAL_SERVER_ERROR = "500";
|
||||
|
||||
/**
|
||||
* Status code (501) indicating the HTTP server does not support the functionality needed to fulfill the request.
|
||||
*/
|
||||
public static final String NOT_IMPLEMENTED = "501";
|
||||
|
||||
/**
|
||||
* Status code (502) indicating that the HTTP server received an invalid response from a server it consulted when acting
|
||||
* as a proxy or gateway.
|
||||
*/
|
||||
public static final String BAD_GATEWAY = "502";
|
||||
|
||||
/**
|
||||
* Status code (503) indicating that the HTTP server is temporarily overloaded, and unable to handle the request.
|
||||
*/
|
||||
public static final String SERVICE_UNAVAILABLE = "503";
|
||||
|
||||
/**
|
||||
* Status code (504) indicating that the server did not receive a timely response from the upstream server while acting
|
||||
* as a gateway or proxy.
|
||||
*/
|
||||
public static final String GATEWAY_TIMEOUT = "504";
|
||||
|
||||
/**
|
||||
* Status code (505) indicating that the server does not support or refuses to support the HTTP protocol version that
|
||||
* was used in the request message.
|
||||
*/
|
||||
public static final String HTTP_VERSION_NOT_SUPPORTED = "505";
|
||||
|
||||
}
|
||||
+11
@@ -3,40 +3,51 @@ package com.mowesta.api;
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
import com.fasterxml.jackson.annotation.JsonValue;
|
||||
|
||||
import jakarta.xml.bind.annotation.XmlEnum;
|
||||
import jakarta.xml.bind.annotation.XmlEnumValue;
|
||||
|
||||
/**
|
||||
* An enumeration with possible language tags for location names.
|
||||
*
|
||||
* @author Marcus
|
||||
*/
|
||||
@XmlEnum
|
||||
public enum Language {
|
||||
|
||||
/**
|
||||
* The local name.
|
||||
*/
|
||||
@XmlEnumValue("local")
|
||||
LOCAL("local"),
|
||||
/**
|
||||
* An acronym (e.g. USA, NRW, etc.).
|
||||
*/
|
||||
@XmlEnumValue("acronym")
|
||||
ACRONYM("acronym"),
|
||||
/**
|
||||
* German.
|
||||
*/
|
||||
@XmlEnumValue("de")
|
||||
GERMAN("de"),
|
||||
/**
|
||||
* English.
|
||||
*/
|
||||
@XmlEnumValue("en")
|
||||
ENGLISH("en"),
|
||||
/**
|
||||
* French.
|
||||
*/
|
||||
@XmlEnumValue("fr")
|
||||
FRENCH("fr"),
|
||||
/**
|
||||
* Italian.
|
||||
*/
|
||||
@XmlEnumValue("it")
|
||||
ITALIAN("it"),
|
||||
/**
|
||||
* Spanish.
|
||||
*/
|
||||
@XmlEnumValue("es")
|
||||
SPANISH("es");
|
||||
|
||||
/**
|
||||
+15
-15
@@ -3,20 +3,20 @@ package com.mowesta.api;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlAttribute;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlElementWrapper;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
import jakarta.validation.Valid;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import jakarta.xml.bind.annotation.XmlAccessType;
|
||||
import jakarta.xml.bind.annotation.XmlAccessorType;
|
||||
import jakarta.xml.bind.annotation.XmlAttribute;
|
||||
import jakarta.xml.bind.annotation.XmlElement;
|
||||
import jakarta.xml.bind.annotation.XmlElementWrapper;
|
||||
import jakarta.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonAutoDetect;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import io.swagger.v3.oas.annotations.media.Schema.RequiredMode;
|
||||
|
||||
/**
|
||||
* An abstract base class for pages.
|
||||
@@ -32,28 +32,28 @@ import io.swagger.annotations.ApiModelProperty;
|
||||
getterVisibility = JsonAutoDetect.Visibility.NONE,
|
||||
setterVisibility = JsonAutoDetect.Visibility.NONE,
|
||||
isGetterVisibility = JsonAutoDetect.Visibility.NONE)
|
||||
@ApiModel(description="Represents a page.")
|
||||
@Schema(description="Represents a page.")
|
||||
public abstract class Page<T> {
|
||||
|
||||
/**
|
||||
* The size of the page, i.e. the maximum number of elements.
|
||||
*/
|
||||
@XmlAttribute(required=true)
|
||||
@ApiModelProperty(value="The maximum number of elements on the page.", required=true)
|
||||
@Schema(description="The maximum number of elements on the page.", requiredMode = RequiredMode.REQUIRED)
|
||||
private int size;
|
||||
|
||||
/**
|
||||
* The offset of the elements (0-based).
|
||||
*/
|
||||
@XmlAttribute(required=true)
|
||||
@ApiModelProperty(value="The page offset (0-based) in number of elements.", required=true)
|
||||
@Schema(description="The page offset (0-based) in number of elements.", requiredMode = RequiredMode.REQUIRED)
|
||||
private int offset;
|
||||
|
||||
/**
|
||||
* The total number of elements available.
|
||||
*/
|
||||
@XmlAttribute(required=true)
|
||||
@ApiModelProperty(value="The total number of elements available.", required=true)
|
||||
@Schema(description="The total number of elements available.", requiredMode = RequiredMode.REQUIRED)
|
||||
private int total;
|
||||
|
||||
/**
|
||||
@@ -64,7 +64,7 @@ public abstract class Page<T> {
|
||||
@XmlElementWrapper
|
||||
@XmlElement(name="element")
|
||||
@JsonProperty(value="elements") // force jackson to keep the name
|
||||
@ApiModelProperty(value="The elements of the page.", required=true)
|
||||
@Schema(description="The elements of the page.", requiredMode = RequiredMode.REQUIRED)
|
||||
private List<T> elements = new ArrayList<>();
|
||||
|
||||
/**
|
||||
+7
-8
@@ -1,11 +1,10 @@
|
||||
package com.mowesta.api;
|
||||
|
||||
import javax.validation.constraints.Max;
|
||||
import javax.validation.constraints.Min;
|
||||
import javax.ws.rs.DefaultValue;
|
||||
import javax.ws.rs.QueryParam;
|
||||
|
||||
import io.swagger.annotations.ApiParam;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import jakarta.validation.constraints.Max;
|
||||
import jakarta.validation.constraints.Min;
|
||||
import jakarta.ws.rs.DefaultValue;
|
||||
import jakarta.ws.rs.QueryParam;
|
||||
|
||||
/**
|
||||
* A bean parameter to configure a page.
|
||||
@@ -37,7 +36,7 @@ public class PageConfig {
|
||||
/**
|
||||
* The page offset in terms of elements.
|
||||
*/
|
||||
@ApiParam(name="pageOffset", value="The offset in terms of elements.", defaultValue="0")
|
||||
@Parameter(name="pageOffset", description = "The offset in terms of elements.")
|
||||
@Min(0)
|
||||
@QueryParam("pageOffset")
|
||||
@DefaultValue("0")
|
||||
@@ -46,7 +45,7 @@ public class PageConfig {
|
||||
/**
|
||||
* The maximum number of elements on the page.
|
||||
*/
|
||||
@ApiParam(name="pageSize", value="The maximum number of elements on the page.", defaultValue="20", allowableValues="range[1,1000]")
|
||||
@Parameter(name="pageSize", description="The maximum number of elements on the page.")
|
||||
@Min(1)
|
||||
@Max(1000)
|
||||
@QueryParam("pageSize")
|
||||
+5
-5
@@ -1,9 +1,9 @@
|
||||
package com.mowesta.api;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import javax.ws.rs.QueryParam;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import jakarta.ws.rs.QueryParam;
|
||||
|
||||
import io.swagger.annotations.ApiParam;
|
||||
|
||||
/**
|
||||
* The context of a search.
|
||||
@@ -17,14 +17,14 @@ public class SearchContext {
|
||||
*/
|
||||
@NotNull
|
||||
@QueryParam("language")
|
||||
@ApiParam(value="The language of the user interface.", allowableValues = "de, en, es, fr, it", example = "de", required = true)
|
||||
@Parameter(description="The language of the user interface.", example = "de", required = true)
|
||||
private Language language;
|
||||
|
||||
/**
|
||||
* The (optional) location of the user.
|
||||
*/
|
||||
@QueryParam("location")
|
||||
@ApiParam(value="The optional position of the user specified as longitude,latitude.", example = "7.065991,50.779012", required = false)
|
||||
@Parameter(description="The optional position of the user specified as longitude,latitude.", example = "7.065991,50.779012", required = false)
|
||||
private Coordinate location;
|
||||
|
||||
/**
|
||||
+5
-5
@@ -1,9 +1,9 @@
|
||||
package com.mowesta.api;
|
||||
|
||||
import javax.validation.constraints.Min;
|
||||
import javax.ws.rs.QueryParam;
|
||||
import jakarta.validation.constraints.Min;
|
||||
import jakarta.ws.rs.QueryParam;
|
||||
|
||||
import io.swagger.annotations.ApiParam;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
|
||||
/**
|
||||
* A bean parameter to avoid repeated definition of time ranges. This simplifies
|
||||
@@ -17,14 +17,14 @@ public class TimeRange {
|
||||
/**
|
||||
* The start time of the time range in Epoch milliseconds.
|
||||
*/
|
||||
@ApiParam(value = "The start time in Epoch milliseconds.", example="1576921935000", required = true)
|
||||
@Parameter(description = "The start time in Epoch milliseconds.", example="1576921935000", required = true)
|
||||
@QueryParam("start") long start;
|
||||
|
||||
/**
|
||||
* The duration of the time range in milliseconds.
|
||||
*/
|
||||
@Min(value = 0)
|
||||
@ApiParam(value = "The duration in milliseconds.", example = "60000", allowableValues = "range[0, infinity]", required = true)
|
||||
@Parameter(description = "The duration in milliseconds.", example = "60000", required = true)
|
||||
@QueryParam("duration") long duration;
|
||||
|
||||
/**
|
||||
+11
-11
@@ -1,13 +1,13 @@
|
||||
package com.mowesta.api.device;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import javax.xml.bind.annotation.XmlAttribute;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import jakarta.xml.bind.annotation.XmlAttribute;
|
||||
import jakarta.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
import com.mowesta.api.Entity;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import io.swagger.v3.oas.annotations.media.Schema.RequiredMode;
|
||||
|
||||
/**
|
||||
* * A data transfer object for a device with associated swagger and jaxb
|
||||
@@ -16,14 +16,14 @@ import io.swagger.annotations.ApiModelProperty;
|
||||
* @author Ole
|
||||
*/
|
||||
@XmlRootElement
|
||||
@ApiModel(description = "Represents a device.", parent = Entity.class)
|
||||
@Schema(description = "Represents a device.", allOf = Entity.class)
|
||||
public class Device extends Entity {
|
||||
|
||||
/**
|
||||
* The owning user or null.
|
||||
*/
|
||||
@XmlAttribute
|
||||
@ApiModelProperty(value="The id of the owning user or null, if there is none.")
|
||||
@Schema(description="The id of the owning user or null, if there is none.")
|
||||
private Long user;
|
||||
|
||||
/**
|
||||
@@ -31,28 +31,28 @@ public class Device extends Entity {
|
||||
*/
|
||||
@NotNull
|
||||
@XmlAttribute(required=true)
|
||||
@ApiModelProperty(value="The operating system.", required=true)
|
||||
@Schema(description="The operating system.", requiredMode = RequiredMode.REQUIRED)
|
||||
private OperatingSystem os;
|
||||
|
||||
/**
|
||||
* The manufacturer name.
|
||||
*/
|
||||
@XmlAttribute(required=true)
|
||||
@ApiModelProperty(value="The manufacturer name, see android.os.Build.MANUFACTURER.", required=true)
|
||||
@Schema(description="The manufacturer name, see android.os.Build.MANUFACTURER.", requiredMode = RequiredMode.REQUIRED)
|
||||
private String manufacturer;
|
||||
|
||||
/**
|
||||
* The device name (industrial design).
|
||||
*/
|
||||
@XmlAttribute(required=true)
|
||||
@ApiModelProperty(value="The device name, see android.os.Build.DEVICE.", required=true)
|
||||
@Schema(description="The device name, see android.os.Build.DEVICE.", requiredMode = RequiredMode.REQUIRED)
|
||||
private String device;
|
||||
|
||||
/**
|
||||
* The model name.
|
||||
*/
|
||||
@XmlAttribute(required=true)
|
||||
@ApiModelProperty(value="The model name, see android.os.Build.MODEL.", required=true)
|
||||
@Schema(description="The model name, see android.os.Build.MODEL.", requiredMode = RequiredMode.REQUIRED)
|
||||
private String model;
|
||||
|
||||
/**
|
||||
+6
-6
@@ -1,10 +1,10 @@
|
||||
package com.mowesta.api.device;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAttribute;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
import jakarta.xml.bind.annotation.XmlAttribute;
|
||||
import jakarta.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import io.swagger.v3.oas.annotations.media.Schema.RequiredMode;
|
||||
|
||||
/**
|
||||
* Represents a device with it's secret auth token assigned by the server
|
||||
@@ -13,14 +13,14 @@ import io.swagger.annotations.ApiModelProperty;
|
||||
* @author Marcus
|
||||
*/
|
||||
@XmlRootElement
|
||||
@ApiModel(description = "Represents a device with a secret token.", parent = Device.class)
|
||||
@Schema(description = "Represents a device with a secret token.", allOf = Device.class)
|
||||
public class DeviceHandle extends Device {
|
||||
|
||||
/**
|
||||
* The secret token used for authenticating the device.
|
||||
*/
|
||||
@XmlAttribute(required=true)
|
||||
@ApiModelProperty(value = "The secret token used for authenticating the device.", required = true)
|
||||
@Schema(description = "The secret token used for authenticating the device.", requiredMode = RequiredMode.REQUIRED)
|
||||
private String token;
|
||||
|
||||
/**
|
||||
+12
-12
@@ -1,15 +1,15 @@
|
||||
package com.mowesta.api.device;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlAttribute;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import jakarta.xml.bind.annotation.XmlAccessType;
|
||||
import jakarta.xml.bind.annotation.XmlAccessorType;
|
||||
import jakarta.xml.bind.annotation.XmlAttribute;
|
||||
import jakarta.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonAutoDetect;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import io.swagger.v3.oas.annotations.media.Schema.RequiredMode;
|
||||
|
||||
/**
|
||||
* A device registration is used to register a device.
|
||||
@@ -23,7 +23,7 @@ import io.swagger.annotations.ApiModelProperty;
|
||||
setterVisibility = JsonAutoDetect.Visibility.NONE,
|
||||
isGetterVisibility = JsonAutoDetect.Visibility.NONE)
|
||||
@XmlRootElement
|
||||
@ApiModel(description = "Represents information about a device.")
|
||||
@Schema(description = "Represents information about a device.")
|
||||
public class DeviceInfo {
|
||||
|
||||
/**
|
||||
@@ -31,28 +31,28 @@ public class DeviceInfo {
|
||||
*/
|
||||
@NotNull
|
||||
@XmlAttribute(required=true)
|
||||
@ApiModelProperty(value="The operating system.", required=true)
|
||||
@Schema(description="The operating system.", requiredMode = RequiredMode.REQUIRED)
|
||||
private OperatingSystem os;
|
||||
|
||||
/**
|
||||
* The manufacturer name.
|
||||
*/
|
||||
@XmlAttribute(required=true)
|
||||
@ApiModelProperty(value="The manufacturer name, see android.os.Build.MANUFACTURER.", required=true)
|
||||
@Schema(description="The manufacturer name, see android.os.Build.MANUFACTURER.", requiredMode = RequiredMode.REQUIRED)
|
||||
private String manufacturer;
|
||||
|
||||
/**
|
||||
* The device name (industrial design).
|
||||
*/
|
||||
@XmlAttribute(required=true)
|
||||
@ApiModelProperty(value="The device name, see android.os.Build.DEVICE.", required=true)
|
||||
@Schema(description="The device name, see android.os.Build.DEVICE.", requiredMode = RequiredMode.REQUIRED)
|
||||
private String device;
|
||||
|
||||
/**
|
||||
* The model name.
|
||||
*/
|
||||
@XmlAttribute(required=true)
|
||||
@ApiModelProperty(value="The model name, see android.os.Build.MODEL.", required=true)
|
||||
@Schema(description="The model name, see android.os.Build.MODEL.", requiredMode = RequiredMode.REQUIRED)
|
||||
private String model;
|
||||
|
||||
/**
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user