Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add documentation #104

Merged
merged 17 commits into from
Nov 28, 2019
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
182 changes: 180 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,182 @@
# RADAR Manual data upload Kafka connector
# RADAR-base Data Uploader

RADAR-base Data Uploader is a web-application that enables uploading data to RADAR-Base. It has a Kafka Connect source connector that processes the uploaded data, parse it in appropriate format and send them to Kafka.

This can be used to
1. Upload data from devices and other sources using a web-interface.
2. Monitor status of the records created

# Components
The project contains three components:
1. A web-application where user can upload data [radar-upload-frontend](radar-upload-frontend)
2. A back-end webservice application that stores the uploaded data with metadata. [radar-upload-backend](radar-upload-backend)
3. A Kafka Connect source-connector that loads data from backend connector and sends it to Kafka. [kafka-connect-upload-source](kafka-connect-upload-source)


# Screenshots
![login using managementportal credentials](https://raw.githubusercontent.com/RADAR-base/radar-upload-source-connector/add-documentation/docs/assets/Selection_003.bmp)

![create and upload files](https://raw.githubusercontent.com/RADAR-base/radar-upload-source-connector/add-documentation/docs/assets/Selection_010.bmp)

![view records and status](https://raw.githubusercontent.com/RADAR-base/radar-upload-source-connector/add-documentation/docs/assets/Selection_011.bmp)

![view participants and records](https://raw.githubusercontent.com/RADAR-base/radar-upload-source-connector/add-documentation/docs/assets/Selection_012.bmp)

# Usage
If you are a user who would like to upload data to RADAR-base, you require an account on ManagementPortal application of your environment. Please request an account from your System administer if you do not have done.

1. Please login to the uploader application using your account credentials from ManagementPortal.
2. Authorize the uploading application to to perform mentioned operations by clicking on `"Approve"`.
3. Select the project you want to work with.
4. Click on the `"UPLOAD"` button to upload files.
5. Select the participant and type of the file data source, then click on `"CREATE RECORD"`.
6. Once the record is created, upload the relevant file(s), then click on `"UPLOAD"`.
7. Once you are done with uploading files, click on `"DONE"` to finalise the process.
8. You will see a new record created for the corresponding participant with `READY`
9. You can switch to `RECORD` tab and monitor the status of the record.

Please see the (step-by-step guide)[] with screenshots if you like more information.

# Installation

To install fully functional RADAR-base data uploader from source, please use the `docker-compose.yml` under the root directory

```bash
docker-compose up -d --build
```


# Usage

## Configuring RADAR-base Data Uploader

**Disclaimer:** This section does not cover how to install or configure the complete RADAR-Base stack. Please visit [RADAR-Docker](https://github.com/RADAR-base/RADAR-Docker) or [RADAR-Kubernetes](https://github.com/RADAR-base/RADAR-Kubernetes) for complete installation guidelines.

**Note:** Some configuration values are specified under the assumption that the docker containers will have the same name on deployment as well.

Configuring Data Uploader involves configuring the three components mentioned above.

### 1. Configuring radar-upload-backend
Please copy `etc/upload.yml.template` to `etc/upload.yml` and modify the database credentials and the oauth client credentials. The following tables shows the possible properties and explanation.

```yaml

baseUri: "http://0.0.0.0:8085/upload/api/"
managementPortalUrl: "http://managementportal-app:8080/managementportal/"
jdbcDriver: "org.postgresql.Driver"
jdbcUrl: "jdbc:postgresql://radarbase-postgresql:5432/uploadconnector"
jdbcUser: "username" # change this to your database username
jdbcPassword: "password" # change this to your database password
additionalPersistenceConfig:
"hibernate.dialect": "org.hibernate.dialect.PostgreSQL95Dialect"
enableCors: yes # if you want to enable cors filter to this component specify yes
clientId: "radar_upload_backend" # configure your oauth client id
clientSecret: "secret" # configure the client-secret
sourceTypes: # these are the data source types that are supported to upload data
- name: "phone-acceleration"
topics:
- "android_phone_acceleration"
contentTypes:
- "text/csv"
timeRequired: false
sourceIdRequired: false
configuration:
"setting1": "value1"
"setting2": "value2"
- name: "acceleration-zip"
topics:
- "android_phone_acceleration"
contentTypes:
- "application/zip"
timeRequired: false
sourceIdRequired: false
- name: "altoida-zip"
topics:
- "connect_upload_altoida_acceleration"
contentTypes:
- "application/zip"
timeRequired: false
sourceIdRequired: false

```

#### Adding support to new device type
To add support to additional device types, add a new entry of sourceType to the `sourceTypes` list.
A single sourceType entry is defined as below.

```yaml

- name: "acceleration-zip" # unique identifier of the data source or device (*required)
topics: # list of topics to send data
- "android_phone_acceleration"
contentTypes: # content types of the data
- "application/zip"
timeRequired: false # if the data is large or if uploading data would require a lot of time mention this to true.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This field was meant to indicate whether the user should supply a date-time for the upload, that is, that the uploaded content does not contain the relevant timestamp.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh I see. That makes sense. I will change it

sourceIdRequired: false # if source-id is compulsory to upload data, specify true.
```

If the `upload.yml` file has been modified after starting the serve, restart the service

```bash
docker-compose restart radar-upload-backend
```

### 2. Configuring Kafka Source Connector

Please copy `etc/source-upload.properties.template` to `etc/source-upload.properties` and modify the oauth client credentials and supported converter classes. The following tables shows the possible properties and explanation.


<table class="data-table"><tbody>
<tr>
<th>Name</th>
<th>Description</th>
<th>Type</th>
<th>Default</th>
<th>Valid Values</th>
<th>Importance</th>
</tr>
<tr>
<td>upload.source.poll.interval.ms</td></td><td>How often to poll the records to process.</td></td><td>long</td></td><td>60000</td></td><td></td></td><td>low</td></td></tr>
<tr>
<td>upload.source.client.id</td></td><td>OAuth Client-id of the upload kafka connector.</td></td><td>string</td></td><td>radar-upload-connector-client</td></td><td></td></td><td>high</td></td></tr>
<tr>
<td>upload.source.client.secret</td></td><td>OAuth client-secret of the upload kafka connector.</td></td><td>string</td></td><td></td></td><td></td></td><td>high</td></td></tr>
<tr>
<td>upload.source.client.tokenUrl</td></td><td>Token URL of ManagementPortal to get access token.</td></td><td>string</td></td><td></td></td><td></td></td><td>high</td></td></tr>
<tr>
<td>upload.source.backend.baseUrl</td></td><td>URL of the radar-upload-backend where uploaded files are stored.</td></td><td>string</td></td><td>http://radar-upload-connect-backend:8085/radar-upload/</td></td><td></td></td><td>high</td></td></tr>
<tr>
<td>upload.source.record.converter.classes</td></td><td>List of classes to be used to convert a record.</td></td><td>list</td></td><td>org.radarbase.connect.upload.converter.phone.AccelerometerConverterFactory</td></td><td>Class extending org.radarbase.connect.upload.converter.ConverterFactory</td></td><td>high</td></td></tr>
</tbody></table>

#### Adding support to new device type
To add processing data from new device type, please implement a ConverterFactory that can process the data from corresponding device and add the name of the class to the list of `upload.source.record.converter.classes`.

### 3. Configuring radar-upload-frontend

Configuring radar-upload-frontend requires configuring the right environment variables for the docker container.

<table class="data-table"><tbody>
<tr>
<th>Name</th>
<th>Description</th>
<th>Values</th>
</tr>
<tr>
<td>VUE_APP_BASE_URL</td><td>Base URL of the web-application.</td><td>/upload</td>
<tr>
<tr>
<td>VUE_APP_API_BASE_URL</td><td>Advertised URL of the radar-upload-backend.</td><td>http://localhost:8080/upload/api/ or https://radarbase-test.domain.com/upload/api/</td>
<tr>
<tr>
<td>VUE_APP_AUTH_API</td><td>Advertised URL of ManagementPortal Authorization.</td><td>http://localhost:8080/managementportal/oauth or https://radarbase-test.domain.com/managementportal/oauth</td>
<tr>
<tr>
<td>VUE_APP_AUTH_CALLBACK</td><td>Callback URL to send the `authorization_code`. This should be correctly configured on ManagementPortal.</td><td>http://localhost:8080/upload/login or https://radarbase-test.domain.com/upload/login</td>
<tr>
<tr>
<td>VUE_APP_CLIENT_ID</td><td>OAuth Client Id of the web application configured on ManagementPortal. </td><td>radar_upload_frontend</td>
<tr>
</tbody></table>

Work in progress to enable direct data uploads to Kafka. Architecture plans are described in the [docs](https://github.com/RADAR-base/radar-upload-source-connector/tree/master/docs).

Binary file added docs/assets/Selection_001.bmp
Binary file not shown.
Binary file added docs/assets/Selection_002.bmp
Binary file not shown.
Binary file added docs/assets/Selection_003.bmp
Binary file not shown.
Binary file added docs/assets/Selection_004.bmp
Binary file not shown.
Binary file added docs/assets/Selection_005.bmp
Binary file not shown.
Binary file added docs/assets/Selection_006.bmp
Binary file not shown.
Binary file added docs/assets/Selection_007.bmp
Binary file not shown.
Binary file added docs/assets/Selection_008.bmp
Binary file not shown.
Binary file added docs/assets/Selection_009.bmp
Binary file not shown.
Binary file added docs/assets/Selection_010.bmp
Binary file not shown.
Binary file added docs/assets/Selection_011.bmp
Binary file not shown.
Binary file added docs/assets/Selection_012.bmp
Binary file not shown.
9 changes: 9 additions & 0 deletions etc/source-upload.properties.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
name=radar-upload-source
connector.class=org.radarbase.connect.upload.UploadSourceConnector
tasks.max=4
upload.source.client.id=radar_upload_connect
upload.source.client.secret=upload_secret
upload.source.client.tokenUrl=http://managementportal-app:8080/managementportal/oauth/token
upload.source.backend.baseUrl=http://radar-upload-connect-backend:8085/radar-upload/
upload.source.poll.interval.ms=1800000
upload.source.record.converter.classes=org.radarbase.connect.upload.converter.phone.AccelerometerConverterFactory,org.radarbase.connect.upload.converter.altoida.AltoidaZipConverterFactory
37 changes: 37 additions & 0 deletions etc/upload.yml.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
baseUri: "http://0.0.0.0:8085/upload/api/"
managementPortalUrl: "http://managementportal-app:8080/managementportal/"
jdbcDriver: "org.postgresql.Driver"
jdbcUrl: "jdbc:postgresql://radarbase-postgresql:5432/uploadconnector"
jdbcUser: "username"
jdbcPassword: "password"
additionalPersistenceConfig:
"hibernate.dialect": "org.hibernate.dialect.PostgreSQL95Dialect"
sourceTypes:
- name: "phone-acceleration"
topics:
- "android_phone_acceleration"
contentTypes:
- "text/csv"
timeRequired: false
sourceIdRequired: false
configuration:
"setting1": "value1"
"setting2": "value2"
- name: "acceleration-zip"
topics:
- "android_phone_acceleration"
contentTypes:
- "application/zip"
timeRequired: false
sourceIdRequired: false
- name: "altoida-zip"
topics:
- "connect_upload_altoida_acceleration"
contentTypes:
- "application/zip"
timeRequired: false
sourceIdRequired: false
enableCors: yes
clientSecret: "secret"
clientId: "radar_upload_backend"

Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ class UploadSourceConnectorConfig(config: ConfigDef, parsedConfig: Map<String, S
const val UPLOAD_SOURCE_SERVER_BASE_URL_CONFIG = "upload.source.backend.baseUrl"
private const val UPLOAD_SOURCE_SERVER_BASE_URL_DOC = "Base URL of the file upload backend"
private const val UPLOAD_SOURCE_SERVER_BASE_URL_DISPLAY = "Base URL of the file upload backend"
private const val UPLOAD_SOURCE_SERVER_BASE_URL_DEFAULT = "http://radar-upload-backend:8080/"
private const val UPLOAD_SOURCE_SERVER_BASE_URL_DEFAULT = "http://radar-upload-connect-backend:8085/radar-upload/"

const val SOURCE_POLL_INTERVAL_CONFIG = "upload.source.poll.interval.ms"
private const val SOURCE_POLL_INTERVAL_DOC = "How often to poll the source URL."
Expand All @@ -102,7 +102,7 @@ class UploadSourceConnectorConfig(config: ConfigDef, parsedConfig: Map<String, S

const val UPLOAD_SOURCE_CONVERTERS_CONFIG = "upload.source.record.converter.classes"
private const val UPLOAD_SOURCE_CONVERTERS_DOC = "List record converter classes that are in class-path"
private const val UPLOAD_SOURCE_CONVERTERS_DISPLAY = "List of record converter class"
private const val UPLOAD_SOURCE_CONVERTERS_DISPLAY = "List of record converter factory class"
private val UPLOAD_SOURCE_CONVERTERS_DEFAULT: List<String> = listOf(
AccelerometerConverterFactory()::class.java.name,
AcceleratometerZipConverterFactory()::class.java.name,
Expand All @@ -125,7 +125,7 @@ class UploadSourceConnectorConfig(config: ConfigDef, parsedConfig: Map<String, S
.define(SOURCE_POLL_INTERVAL_CONFIG,
ConfigDef.Type.LONG,
SOURCE_POLL_INTERVAL_DEFAULT,
ConfigDef.Importance.LOW,
ConfigDef.Importance.HIGH,
SOURCE_POLL_INTERVAL_DOC,
groupName,
++orderInGroup,
Expand All @@ -135,7 +135,7 @@ class UploadSourceConnectorConfig(config: ConfigDef, parsedConfig: Map<String, S
.define(UPLOAD_SOURCE_CLIENT_CONFIG,
ConfigDef.Type.STRING,
UPLOAD_SOURCE_MP_CLIENT_DEFAULT,
ConfigDef.Importance.LOW,
ConfigDef.Importance.HIGH,
UPLOAD_SOURCE_CLIENT_DOC,
groupName,
++orderInGroup,
Expand All @@ -155,7 +155,7 @@ class UploadSourceConnectorConfig(config: ConfigDef, parsedConfig: Map<String, S
.define(UPLOAD_SOURCE_SERVER_BASE_URL_CONFIG,
ConfigDef.Type.STRING,
UPLOAD_SOURCE_SERVER_BASE_URL_DEFAULT,
ConfigDef.Importance.HIGH,
ConfigDef.Importance.LOW,
UPLOAD_SOURCE_SERVER_BASE_URL_DOC,
groupName,
++orderInGroup,
Expand All @@ -165,7 +165,7 @@ class UploadSourceConnectorConfig(config: ConfigDef, parsedConfig: Map<String, S
.define(UPLOAD_SOURCE_CLIENT_TOKEN_URL_CONFIG,
ConfigDef.Type.STRING,
UPLOAD_SOURCE_CLIENT_TOKEN_URL_DEFAULT,
ConfigDef.Importance.HIGH,
ConfigDef.Importance.LOW,
UPLOAD_SOURCE_CLIENT_TOKEN_URL_DOC,
groupName,
++orderInGroup,
Expand Down
2 changes: 1 addition & 1 deletion radar-upload-backend/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ application {

project.extra.apply {
set("okhttpVersion", "4.2.0")
set("radarJerseyVersion", "0.2.2")
set("radarJerseyVersion", "0.2.2.2")
set("radarCommonsVersion", "0.12.2")
set("radarSchemasVersion", "0.5.2")
set("jacksonVersion", "2.9.10")
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,17 @@ class UploadResourceEnhancer(private val config: Config): JerseyResourceEnhancer
.readTimeout(30, TimeUnit.SECONDS)
.build()

override val classes: Array<Class<*>> = arrayOf(
ConfigLoader.Filters.logResponse,
ConfigLoader.Filters.cors)
override val classes: Array<Class<*>> get() {
return if (config.enableCors == true) {
arrayOf(
ConfigLoader.Filters.logResponse,
ConfigLoader.Filters.cors)
} else {
arrayOf(
ConfigLoader.Filters.logResponse
)
}
}

override val packages: Array<String> = arrayOf(
"org.radarbase.upload.exception",
Expand Down