Skip to content

Commit

Permalink
Cleaning up and upgrading code
Browse files Browse the repository at this point in the history
rh-pre-commit.version: 2.0.3
rh-pre-commit.check-secrets: ENABLED
  • Loading branch information
computate committed Mar 10, 2024
1 parent 27150a5 commit 9604be5
Show file tree
Hide file tree
Showing 23 changed files with 211 additions and 496 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ ansible/inventories/**
*.iml
vault/**
.flattened-pom.xml
**/.ipynb_checkpoints

# Avoid ignoring Maven wrapper jar file (.jar files are usually ignored)
!/.mvn/wrapper/maven-wrapper.jar
90 changes: 10 additions & 80 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,24 +19,18 @@ oc -n postgres get secret/postgres-cluster-pguser-smartvillage -o jsonpath='{.da
```bash

# Get KAFKA_SSL_KEYSTORE_LOCATION:
oc extract -n smart-village-view secret/smartvillage-kafka --to=$HOME/.local/src/smartvillage-platform/config/ --keys=user.p12 --confirm
oc extract -n smart-village-view secret/smartvillage-kafka --to=$HOME/.local/src/smartabyar-smartvillage/config/ --keys=user.p12 --confirm

# Get KAFKA_SSL_KEYSTORE_PASSWORD:
oc -n smart-village-view get secret/smartvillage-kafka -o jsonpath='{.data.user\.password}' | base64 -d; echo

# Get KAFKA_SSL_TRUSTSTORE_LOCATION:
oc extract -n smart-village-view secret/smartvillage-kafka-cluster-ca-cert --to=$HOME/.local/src/smartvillage-platform/config/ --keys=ca.p12 --confirm
oc extract -n smart-village-view secret/smartvillage-kafka-cluster-ca-cert --to=$HOME/.local/src/smartabyar-smartvillage/config/ --keys=ca.p12 --confirm

# Get KAFKA_SSL_TRUSTSTORE_PASSWORD:
oc -n smart-village-view get secret/smartvillage-kafka-cluster-ca-cert -o jsonpath='{.data.ca\.password}' | base64 -d; echo
```

# Create or update database table schema

```
psql -h psql-postgres.apps-crc.testing -p 30432 -U smartvillage smartvillage < ~/.local/src/smartvillage-platform/src/main/resources/sql/db-create.sql
```

# Setup smartvillage-platform development environment on MacOSX or Linux (Fedora, RHEL, CentOS, Ubuntu)

## Install Ansible dependencies on Linux
Expand Down Expand Up @@ -106,7 +100,7 @@ git clone [email protected]:computate-org/computate_project.git ~/.ansible/roles/co
## Run the Ansible Galaxy roles to install the complete project locally.

```bash
ansible-playbook ~/.ansible/roles/computate.computate_project/install.yaml -e SITE_NAME=smartvillage-platform -e ENABLE_CODE_GENERATION_SERVICE=true
ansible-playbook ~/.ansible/roles/computate.computate_project/install.yml -e SITE_NAME=smartvillage-platform -e ENABLE_CODE_GENERATION_SERVICE=true
```

## Running the project build and test suite
Expand Down Expand Up @@ -140,7 +134,7 @@ ansible-vault edit ~/.local/src/smartvillage-platform-ansible/vault/$USER-local
You can then run the project install automation again with the secrets in the vault, it will ask for the password.

```bash
ansible-playbook ~/.ansible/roles/computate.computate_project/install.yaml -e SITE_NAME=smartvillage-platform -e ENABLE_CODE_GENERATION_SERVICE=true -e @~/.local/src/smartvillage-platform-ansible/vault/$USER-local --vault-id @prompt
ansible-playbook ~/.ansible/roles/computate.computate_project/install.yml -e SITE_NAME=smartvillage-platform -e ENABLE_CODE_GENERATION_SERVICE=true -e @~/.local/src/smartvillage-platform-ansible/vault/$USER-local --vault-id @prompt
```

# Configure Eclipse IDE
Expand Down Expand Up @@ -212,7 +206,7 @@ Add these update sites and install these useful plugins:

Setup the following variables to setup the Vert.x verticle.

* CONFIG_PATH: ~/.local/src/smartvillage-platform/config/smartvillage-platform.yaml
* CONFIG_PATH: ~/.local/src/smartvillage-platform/config/smartvillage-platform.yml
* RUN_OPENAPI3_GENERATOR: true
* RUN_SQL_GENERATOR: true
* RUN_FIWARE_GENERATOR: true
Expand All @@ -239,7 +233,7 @@ Setup the following VM arguments to disable caching for easier web development:

Setup the following variables to setup the Vert.x verticle.

* CONFIG_PATH: ~/.local/src/smartvillage-platform/config/smartvillage-platform.yaml
* CONFIG_PATH: ~/.local/src/smartvillage-platform/config/smartvillage-platform.yml
* VERTXWEB_ENVIRONMENT: dev

Click [ Apply ] and [ Debug ] to debug the application.
Expand Down Expand Up @@ -315,13 +309,13 @@ AUTH_TOKEN_URI: "/auth/realms/SMARTVILLAGE/protocol/openid-connect/token"
```bash

ansible-playbook --vault-id @prompt -e @~/.local/src/smartvillage-platform-ansible/vault/$USER-staging/vault ~/.ansible/roles/computate.computate_postgres_openshift/install.yaml -e SITE_NAME=smartvillage-platform
ansible-playbook --vault-id @prompt -e @~/.local/src/smartvillage-platform-ansible/vault/$USER-staging/vault ~/.ansible/roles/computate.computate_postgres_openshift/install.yml -e SITE_NAME=smartvillage-platform

ansible-playbook --vault-id @prompt -e @~/.local/src/smartvillage-platform-ansible/vault/$USER-staging/vault ~/.ansible/roles/computate.computate_zookeeper_openshift/install.yaml -e SITE_NAME=smartvillage-platform
ansible-playbook --vault-id @prompt -e @~/.local/src/smartvillage-platform-ansible/vault/$USER-staging/vault ~/.ansible/roles/computate.computate_zookeeper_openshift/install.yml -e SITE_NAME=smartvillage-platform

ansible-playbook --vault-id @prompt -e @~/.local/src/smartvillage-platform-ansible/vault/$USER-staging/vault ~/.ansible/roles/computate.computate_solr_openshift/install.yaml -e SITE_NAME=smartvillage-platform
ansible-playbook --vault-id @prompt -e @~/.local/src/smartvillage-platform-ansible/vault/$USER-staging/vault ~/.ansible/roles/computate.computate_solr_openshift/install.yml -e SITE_NAME=smartvillage-platform

ansible-playbook --vault-id @prompt -e @~/.local/src/smartvillage-platform-ansible/vault/$USER-staging/vault ~/.ansible/roles/computate.computate_project_openshift/install.yaml -e SITE_NAME=smartvillage-platform
ansible-playbook --vault-id @prompt -e @~/.local/src/smartvillage-platform-ansible/vault/$USER-staging/vault ~/.ansible/roles/computate.computate_project_openshift/install.yml -e SITE_NAME=smartvillage-platform
```

## How to run the application as a Podman container
Expand All @@ -345,67 +339,3 @@ podman build -t computateorg/smartvillage-platform:latest .
podman login quay.io
podman push computateorg/smartvillage-platform:latest quay.io/computateorg/smartvillage-platform:latest
```

## How the base classes for this project were created

```bash
ansible-playbook -e @~/.local/src/smartvillage-platform/local/ansible_install_vars.yaml ~/.local/src/computate-org/vertx_project.yaml
```

# Load a new map traffic data into SUMO

```bash
cd ~/.local/share/sumo/data
env LD_LIBRARY_PATH=~/.local/lib:~/.local/lib64 "SUMO_HOME=$HOME/.local/share/sumo" python ~/.local/share/sumo/tools/osmWebWizard.py
```

# Export SUMO vehicle coordinate data

```bash
env LD_LIBRARY_PATH=~/.local/lib:~/.local/lib64 "SUMO_HOME=$HOME/.local/share/sumo" SUMO_HOME=~/.local/share/sumo sumo --fcd-output ~/.local/share/sumo/data/veberod/veberod-fcd.xml -c ~/.local/share/sumo/data/veberod/veberod.sumocfg --fcd-output.geo -b 10 -e 360 --step-length 0.1
```

# Export SUMO full data

```bash
env LD_LIBRARY_PATH=~/.local/lib:~/.local/lib64 "SUMO_HOME=$HOME/.local/share/sumo" SUMO_HOME=~/.local/share/sumo sumo --full-output ~/.local/share/sumo/data/veberod/veberod-full.xml -c ~/.local/share/sumo/data/veberod/veberod.sumocfg --fcd-output.geo -b 10 -e 360 --step-length 0.1
```

# Convert X,Y coordinates to geo coordinates with python

The Veberod_intersection.net.xml contains data about traffic lights like the x/y position.

```xml
<junction id="267701936" type="traffic_light" x="220.61" y="853.48"
```

To convert the x/y position, use python:

```bash
pip install pyproj sumolib
python
>>> import sumolib
>>> net = sumolib.net.readNet('/home/ctate/.local/src/TLC/TLC_sumo/Veberod_intersection.net.xml')
>>> print(net.convertXY2LonLat(220.61,853.48))
(13.49260653795143, 55.633791753658265)
```

# Run SUMO with Traci TCP server

```bash
env SUMO_HOME=/home/ctate/.local/share/sumo LD_LIBRARY_PATH=/home/ctate/.local/lib:~/.local/lib64 /home/ctate/.local/bin/sumo-gui --remote-port 8813 --num-clients 1 --start
```

## Python interact with the Traci TCP server

```bash
cd ~/.local/share/sumo/tools
```

```python
import traci
conn = traci.connect()
conn.simulationStep()
conn.simulationStep()
conn.simulationStep()
```
27 changes: 0 additions & 27 deletions bin/touch.sh

This file was deleted.

17 changes: 12 additions & 5 deletions local/defaults.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ SITE_NAME: "smartvillage-platform"
SITE_POM_GROUP_ID: "org.computate"
SITE_POM_ARTIFACT_ID: "smartvillage-platform"
SITE_PUBLIC_URL: "https://smartabyarsmartvillage.org"
SITE_DISPLAY_NAME: "Smart Village Project"
SITE_DISPLAY_NAME: "Smart Village Platform"
SITE_SERVICES:
- SITE_NAME: "smartvillage-platform"
SITE_SRC: "{{ SITE_PREFIX }}/smartvillage-platform"
Expand All @@ -17,6 +17,8 @@ CLASS_SIMPLE_NAME_MainVerticle: "MainVerticle"
RUN_OPENAPI3_GENERATOR: true
RUN_SQL_GENERATOR: true
RUN_ARTICLE_GENERATOR: false
RUN_FIWARE_GENERATOR: false
RUN_PROJECT_GENERATOR: true
I18N_PATHS: ["{{ SITE_PREFIX }}/computate/src/main/resources/org/computate/i18n/i18n_enUS.yaml"]
DYNAMIC_PAGE_PATHS: ["{{ SITE_PREFIX }}/smartvillage-platform/page"]

Expand All @@ -32,6 +34,7 @@ API_COUNTER_FETCH: 50
API_COUNTER_RESUME: 10
COMPUTATE_SRC: "{{ SITE_PREFIX }}/computate"

SITE_INSTANCES: 2
SITE_HOST_NAME: "localhost"
SITE_BASE_URL: "http://localhost:12080"
SITE_PORT: 12080
Expand All @@ -43,8 +46,11 @@ TEMPLATE_PATH: "{{ SITE_PREFIX }}/smartvillage-platform/src/main/resources/templ
API_CONTACT_EMAIL: ""
FONTAWESOME_KIT: ""

JDBC_HOST: "localhost"
JDBC_PORT: 5432
ZOOKEEPER_HOST_NAME: "zookeeper.apps-crc.testing"
ZOOKEEPER_PORT: 30081

JDBC_HOST: "postgres.apps-crc.testing"
JDBC_PORT: 30432
JDBC_DATABASE: "smartvillage"
JDBC_USERNAME: "smartvillage"

Expand All @@ -60,6 +66,7 @@ AUTH_TOKEN_URI: "/auth/realms/SMARTVILLAGE/protocol/openid-connect/token"

SOLR_HOST_NAME: solr-smartvillage.apps-crc.testing
SOLR_PORT: 443
SOLR_SSL: true
SOLR_COLLECTION: "smartvillage"
SOLR_URL: "https://solr-solr.apps-crc.testing/solr/smartvillage"
SOLR_URL_COMPUTATE: "https://solr-solr.apps-crc.testing/solr/computate"
Expand Down Expand Up @@ -93,9 +100,9 @@ WRITE_API: true
WRITE_COMMENTS: true

# The Auth roles required to be an admin in the site.
AUTH_ROLE_ADMIN: 'SiteAdmin'
AUTH_ROLE_ADMIN: SiteAdmin
# The Auth roles required to be a super admin in the site.
AUTH_ROLE_SUPER_ADMIN: 'SuperAdmin'
AUTH_ROLE_SUPER_ADMIN: SuperAdmin

# Enable data import in the site.
ENABLE_IMPORT_DATA: true
33 changes: 32 additions & 1 deletion local/template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ SITE_NAME: "{{ SITE_NAME }}"
SITE_SRC: "{{ SITE_SRC }}"
SITE_DISPLAY_NAME: "{{ SITE_DISPLAY_NAME }}"
SITE_POM_GROUP_ID: "{{ SITE_POM_GROUP_ID }}"
SITE_POM_ARTIFACT_ID: "{{ SITE_POM_ARTIFACT_ID }}"
SITE_PUBLIC_URL: "{{ SITE_PUBLIC_URL }}"
GITHUB_ORG: "{{ GITHUB_ORG }}"
QUAYIO_ORG: "{{ QUAYIO_ORG }}"
Expand Down Expand Up @@ -31,6 +32,23 @@ DYNAMIC_PAGE_PATHS:
- "{{ SITE_SRC }}/page"
SSL_VERIFY: false

JDBC_HOST: "{{ JDBC_HOST }}"
JDBC_PORT: {{ JDBC_PORT }}
JDBC_DATABASE: "{{ JDBC_DATABASE }}"
JDBC_USERNAME: "{{ JDBC_USERNAME }}"
# oc get -n smartvillage secret/postgres-pguser-smartvillage -o 'jsonpath={.data.password}' | base64 -d && echo
JDBC_PASSWORD: "{{ JDBC_PASSWORD }}"

AUTH_HOST_NAME: "{{ AUTH_HOST_NAME | default('') }}"
AUTH_PORT: {{ AUTH_PORT }}
AUTH_SSL: {{ AUTH_SSL | lower }}
AUTH_SSL_REQUIRED: {{ AUTH_SSL_REQUIRED }}
AUTH_REALM: "{{ AUTH_REALM | default('') }}"
AUTH_CLIENT: "{{ AUTH_CLIENT | default('') }}"
AUTH_SECRET: "{{ AUTH_SECRET | default('') }}"
AUTH_URL: "{{ AUTH_URL }}"
AUTH_TOKEN_URI: "{{ AUTH_TOKEN_URI }}"

SOLR_HOST_NAME: "{{ SOLR_HOST_NAME }}"
SOLR_PORT: {{ SOLR_PORT }}
SOLR_COLLECTION: "{{ SOLR_COLLECTION }}"
Expand Down Expand Up @@ -62,9 +80,22 @@ WRITE_COMMENTS: true

# Enable data import in the site.
ENABLE_IMPORT_DATA: {{ ENABLE_IMPORT_DATA | lower }}
ENABLE_IMPORT_DATA_SitePage: true
ENABLE_IMPORT_DATA_SiteHtm: true
ENABLE_IMPORT_DATA_SitePage: true
ENABLE_IMPORT_DATA_SystemEvent: true
ENABLE_IMPORT_DATA_MapResult: true

# The Auth roles required to be a super admin in the site.
AUTH_ROLE_SUPER_ADMIN: {{ AUTH_ROLE_SUPER_ADMIN }}
# The Auth roles required to be an admin in the site.
AUTH_ROLE_ADMIN: {{ AUTH_ROLE_ADMIN }}
# The Auth roles required to add and modify site user records.
AUTH_ROLE_REQUIRED_SiteUser: 'SiteAdmin'
# The Auth roles required to add and modify HTML records.
AUTH_ROLE_REQUIRED_SiteHtm: 'SiteAdmin'
# The Auth roles required to add and modify article records.
AUTH_ROLE_REQUIRED_SitePage: 'SiteAdmin'
# The Auth roles required to add and modify system event records.
AUTH_ROLE_REQUIRED_SystemEvent: 'SiteAdmin'
# The Auth roles required to add and modify map result records.
AUTH_ROLE_REQUIRED_MapResult: 'SiteAdmin'
39 changes: 24 additions & 15 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<groupId>org.computate</groupId>
<artifactId>smartvillage-platform</artifactId>
<version>2.0.2</version>
<name>Smart Village Project</name>
<name>Smart Village Platform</name>
<description>Red Hat Global Social Innovation Program is partnering with Boston University and Smarta Byar in order to collaborate on creating a global and open research platform allowing researchers to study what social sustainability means by using a digital twin of Veberöd, Sweden as the test village, supported by Smarta Byar. The goal of this collaboration is to build the open source technological infrastructure so that researchers can collaborate on this platform effectively to study mobility, public health, sustainability among other study areas to ultimately help define better the link between well being and eco-smart cities.</description>
<url>https://smartabyarsmartvillage.org</url>
<packaging>jar</packaging>
Expand Down Expand Up @@ -85,6 +85,13 @@
<mockito.version>4.10.0</mockito.version>
<commonmark.version>0.21.0</commonmark.version>

<quarkus-base.version>2.7.6</quarkus-base.version>
<quarkus.version>${quarkus-base.version}.Final-redhat-00006</quarkus.version>
<quarkus-plugin.version>${quarkus.version}</quarkus-plugin.version>
<quarkus.platform.artifact-id>quarkus-bom</quarkus.platform.artifact-id>
<quarkus.platform.group-id>com.redhat.quarkus.platform</quarkus.platform.group-id>
<quarkus.platform.version>${quarkus.version}</quarkus.platform.version>

<vertx-base.version>4.4.4</vertx-base.version>
<vertx.version>${vertx-base.version}.redhat-00001</vertx.version>

Expand All @@ -108,7 +115,7 @@
<drools.version>8.32.0.Final</drools.version>
<cloudevents.version>2.4.0</cloudevents.version>

<computate.version>4.4.4.1</computate.version>
<computate.version>4.4.4.2</computate.version>
</properties>

<dependencyManagement>
Expand All @@ -122,6 +129,14 @@
<scope>import</scope>
</dependency>

<dependency>
<groupId>${quarkus.platform.group-id}</groupId>
<artifactId>${quarkus.platform.artifact-id}</artifactId>
<version>${quarkus.platform.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>

<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-bom</artifactId>
Expand Down Expand Up @@ -336,12 +351,6 @@
<groupId>io.vertx</groupId>
<artifactId>vertx-opentelemetry</artifactId>
</dependency>

<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>${slf4j.version}</version>
</dependency>

<!-- ########## -->
<!-- jfreechart -->
Expand Down Expand Up @@ -374,6 +383,12 @@
<version>${slf4j.version}</version>
</dependency>

<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>${slf4j.version}</version>
</dependency>

<!-- ############ -->
<!-- Unit Testing -->
<!-- ############ -->
Expand Down Expand Up @@ -429,12 +444,6 @@
<!-- Other -->
<!-- ##### -->

<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-exec</artifactId>
<version>1.3</version>
</dependency>

<!-- ##### -->
<!-- Camel -->
<!-- ##### -->
Expand Down Expand Up @@ -675,7 +684,7 @@
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.11</version>
<version>${jacoco-maven-plugin.version}</version>
<executions>
<execution>
<id>prepare-agent</id>
Expand Down
Loading

0 comments on commit 9604be5

Please sign in to comment.