From 33405d37850bbdccab765b6843af70eea257b1a4 Mon Sep 17 00:00:00 2001 From: Joris Borgdorff Date: Wed, 5 Apr 2017 13:45:25 +0200 Subject: [PATCH 1/4] Updated README --- README.md | 8 ++++++-- java-sdk/README.md | 21 +++++++++++++++++++++ 2 files changed, 27 insertions(+), 2 deletions(-) create mode 100644 java-sdk/README.md diff --git a/README.md b/README.md index 97aa4066..7ad2e56e 100644 --- a/README.md +++ b/README.md @@ -2,11 +2,15 @@ [![Build Status](https://travis-ci.org/RADAR-CNS/RADAR-Schemas.svg?branch=master)](https://travis-ci.org/RADAR-CNS/RADAR-Schemas) -[Avro schemas](https://avro.apache.org/docs/1.8.1/spec.html) used in RADAR-CNS. +[Avro schemas](https://avro.apache.org/docs/1.8.1/spec.html) used in RADAR-CNS. The schemas are divided into three parts: `commons` for the passive remote monitoring application and the backend, `restapi` for the REST API, and `questionnaire` for the active remote monitoring application. + +Java SDKs for each of the components are provided in the `java-sdk` folder, see installation instructions there. They are automatically generated from the Avro schemas using the Avro 1.8.1 specification. ## Contributing -The Avro schemas in the `common` directory adhere to the [Google JSON style](https://google.github.io/styleguide/jsoncstyleguide.xml). In addition: +The Avro schemas should follow the [Google JSON style guide](https://google.github.io/styleguide/jsoncstyleguide.xml). + +In addition, schemas in the `commons` directory should follow the following guidelines: - Try to avoid abbreviations in the field names and write out the field name instead. - There should be no need to add `value` at the end of a field name. diff --git a/java-sdk/README.md b/java-sdk/README.md new file mode 100644 index 00000000..60552550 --- /dev/null +++ b/java-sdk/README.md @@ -0,0 +1,21 @@ +# RADAR Schemas Java SDK + +The Java SDKs are published as JARs on bintray. To use them in Gradle, add the following code to your `build.gradle`: + +```gradle +repositories { + maven { url 'http://dl.bintray.com/radar-cns/org.radarcns' } +} + +dependencies { + // Commons schemas (backend, passive remote monitoring app) + compile 'org.radarcns:radar-schemas-commons:0.1' + + // REST API schemas (REST API, testing) + compile 'org.radarcns:radar-schemas-restapi:0.1' + + // Questionnaire schemas (active remote monitoring app) + compile 'org.radarcns:radar-schemas-questionnaire:0.1' +} +``` +Usually, you only need to include the schemas you actually need in your dependencies. From 8f994ef8fc94f3b892a08743546d8c4c4577c607 Mon Sep 17 00:00:00 2001 From: Joris Borgdorff Date: Wed, 5 Apr 2017 13:45:52 +0200 Subject: [PATCH 2/4] Updated release version number --- java-sdk/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/java-sdk/build.gradle b/java-sdk/build.gradle index 82799151..c11819ab 100644 --- a/java-sdk/build.gradle +++ b/java-sdk/build.gradle @@ -14,7 +14,7 @@ subprojects { apply plugin: 'com.commercehub.gradle.plugin.avro-base' apply plugin: 'maven-publish' - version = '0.1-SNAPSHOT' + version = '0.1' group = 'org.radarcns' ext.githubRepo = 'RADAR-CNS/RADAR-Schemas' From 4aca82f8e414269195962d6e19c43e91fdffac2c Mon Sep 17 00:00:00 2001 From: Joris Borgdorff Date: Wed, 5 Apr 2017 14:07:36 +0200 Subject: [PATCH 3/4] Added comments and usage information for the Java SDK --- java-sdk/README.md | 22 ++++++++++++++++++++++ java-sdk/build.gradle | 11 ++++------- 2 files changed, 26 insertions(+), 7 deletions(-) diff --git a/java-sdk/README.md b/java-sdk/README.md index 60552550..92b34160 100644 --- a/java-sdk/README.md +++ b/java-sdk/README.md @@ -19,3 +19,25 @@ dependencies { } ``` Usually, you only need to include the schemas you actually need in your dependencies. + +The generated code each refers to a single schema. The classes of Avro records will extend `org.apache.avro.specific.SpecificRecord`. They each have a static `getClassSchema()` function that returns the `Schema` that it was generated from. To read JSON serialized data for example, use the following code: + +```java +public class Deserialize { + public static void main(String args[]) throws Exception { + //Instantiating the Schema.Parser class. + DatumReader datumReader = new SpecificDatumReader<>(PhoneBatteryLevel.class); + DataFileReader dataFileReader = new DataFileReader<>(new File("/path/to/mydata.avro"), datumReader); + + System.out.println("Reading phone battery levels"); + PhoneBatteryLevel batteryLevel = null; + while (dataFileReader.hasNext()) { + batteryLevel = dataFileReader.next(batteryLevel); + System.out.println("Phone battery level: " + batteryLevel); + } + System.out.println("Done"); + } +} +``` + +Alternatively, use `org.radarcns.data.SpecificRecordEncoder` and `org.radarcns.data.SpecificRecordDecoder` from the `radar-commons` package. diff --git a/java-sdk/build.gradle b/java-sdk/build.gradle index c11819ab..e17f3c60 100644 --- a/java-sdk/build.gradle +++ b/java-sdk/build.gradle @@ -14,6 +14,7 @@ subprojects { apply plugin: 'com.commercehub.gradle.plugin.avro-base' apply plugin: 'maven-publish' + // Configuration version = '0.1' group = 'org.radarcns' ext.githubRepo = 'RADAR-CNS/RADAR-Schemas' @@ -27,15 +28,16 @@ subprojects { ext.issueUrl = 'https://github.com/' + githubRepo + '/issues' ext.website = 'http://radar-cns.org' + // dependencies repositories { jcenter() - maven { url 'http://dl.bintray.com/typesafe/maven-releases' } } dependencies { api group: 'org.apache.avro', name: 'avro', version: avroVersion } + // publishing ext.pomConfig = { licenses { license { @@ -103,6 +105,7 @@ subprojects { archives sourcesJar, javadocJar } + // Generated avro files ext.avroOutputDir = file('src/main/java') clean { @@ -110,12 +113,6 @@ subprojects { } } -//---------------------------------------------------------------------------// -// Testing // -//---------------------------------------------------------------------------// - - - task wrapper(type: Wrapper) { gradleVersion = '3.4.1' distributionUrl distributionUrl.replace("bin", "all") From 760325fefae2a73a2f77f07102ce598445793337 Mon Sep 17 00:00:00 2001 From: Joris Borgdorff Date: Wed, 5 Apr 2017 14:25:35 +0200 Subject: [PATCH 4/4] Fixed typo in server status name --- restapi/app/{server_satus.avsc => server_status.avsc} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename restapi/app/{server_satus.avsc => server_status.avsc} (100%) diff --git a/restapi/app/server_satus.avsc b/restapi/app/server_status.avsc similarity index 100% rename from restapi/app/server_satus.avsc rename to restapi/app/server_status.avsc