Skip to content

Commit

Permalink
add file exist check for adaptation sql. Remove 3 adapt templates. Up…
Browse files Browse the repository at this point in the history
…date README
  • Loading branch information
voxparcxls committed Jan 22, 2024
1 parent 928fbb9 commit 2f6d507
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 5 deletions.
54 changes: 54 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,60 @@ Start `test.sh` script by running:

This will produce jacoco reports with code coverage measurements.

## Adaptation Setup Guide

CWS can be adapted and tailored for a mission. This can be done by modifying certain resources and source code of CWS-CORE.

Create new functionalities by adding:

* External Database Config
* Custom Java code
* Custom Rest Service API
* Custom Initiators
* etc...

### Adaptation Database

Adaptation Database feature lets you connect to a external database separate from that of the main `cws_dev` database.

**(1)** You must first include the following SQL Template files to the `install/sql/` directory:
* `install/sql/adaptation.sql.template` **(Core Database: `cws_dev`)**
* `install/sql/adaptation_core.sql.template` **(Core Database: `cws_dev`)**
* `install/sql/adaptation_external.sql.template` **(Adaptation Database: `cws_external_db`)**

**(2)** Create your schema/tables within the added Adaptation SQL Template files.
* Example (`adaptation_external.sql.template`):
```
CREATE TABLE IF NOT EXISTS `cws_external_table` (
...
...
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
```

**(3)** Write Custom Java Code.

By referencing your adaptation tables, you can connect and communicate with your external database.

Write Java custom code that extends from DbService and use the `jdbcTemplate` or `jdbcAdaptationTemplate` JDBC source to query the core and external databases.
```
jdbcAdaptationTemplate (adaptation external database)
jdbcTemplate (core database)
```

### Adaptation Workers Modal

Custom your Deployment page Workers view with add-ons and filters.

The UI for the Worker listview is customizable with through the javascript `addAdaptationWorkersInfo` function.

File: `cws-ui/src/main/webapp/js/adaptation-workers-modal.js`

Write your custom code here:
```
function addAdaptationWorkersInfo(dataProcKey, listWorkers) {
return;
}
```
# Contributing

Please see our [contribution guidelines](https://github.com/NASA-AMMOS/common-workflow-service/blob/main/CONTRIBUTING.md).
Expand Down
14 changes: 11 additions & 3 deletions create_server_dist.sh
Original file line number Diff line number Diff line change
Expand Up @@ -186,9 +186,17 @@ awk 'NR==FNR { a[n++]=$0; next }
/__CUSTOM_METHODS_JAVA__/ { for (i=0;i<n;++i) print a[i]; next }1' ${DIST}/snippets.java ${INSTALL_DIR}/sql/core.sql.template > ${CWS}/sql/cws/core.sql

cp ${INSTALL_DIR}/sql/core.afterstartup.sql.template ${CWS}/sql/cws/core.afterstartup.sql
cp ${INSTALL_DIR}/sql/adaptation.sql.template ${CWS}/sql/cws/adaptation.sql
cp ${INSTALL_DIR}/sql/adaptation_core.sql.template ${CWS}/sql/cws/adaptation_core.sql
cp ${INSTALL_DIR}/sql/adaptation_external.sql.template ${CWS}/sql/cws/adaptation_external.sql

if [[ -f ${INSTALL_DIR}/sql/adaptation.sql.template && -f ${INSTALL_DIR}/sql/adaptation_core.sql.template && -f ${INSTALL_DIR}/sql/adaptation_external.sql.template ]]; then
print "Building adaptation (external) sql..."
awk 'NR==FNR { a[n++]=$0; next }
/__CUSTOM_METHODS_JAVA__/ { for (i=0;i<n;++i) print a[i]; next }1' ${DIST}/snippets.java ${INSTALL_DIR}/sql/adaptation.sql.template > ${CWS}/sql/cws/adaptation.sql
awk 'NR==FNR { a[n++]=$0; next }
/__CUSTOM_METHODS_JAVA__/ { for (i=0;i<n;++i) print a[i]; next }1' ${DIST}/snippets.java ${INSTALL_DIR}/sql/adaptation_core.sql.template > ${CWS}/sql/cws/adaptation_core.sql
awk 'NR==FNR { a[n++]=$0; next }
/__CUSTOM_METHODS_JAVA__/ { for (i=0;i<n;++i) print a[i]; next }1' ${DIST}/snippets.java ${INSTALL_DIR}/sql/adaptation_external.sql.template > ${CWS}/sql/cws/adaptation_external.sql
fi


rm ${DIST}/snippets.java
rm ${DIST}/snippets.java.bak
Expand Down
6 changes: 4 additions & 2 deletions cws-installer/src/main/java/jpl/cws/task/CwsInstaller.java
Original file line number Diff line number Diff line change
Expand Up @@ -1693,9 +1693,9 @@ private static void showInstallationInfo() {
print(" Database Driver = " + cws_adapt_db_driver);
print(" Database User = " + cws_adapt_db_username);
print(" Database Password = ****** (hidden) ");
print("....................................................................................");
}
}
print("....................................................................................");

if (cws_auth_scheme.equals("LDAP")) {
print("LDAP User = " + cws_user);
Expand All @@ -1708,6 +1708,7 @@ private static void showInstallationInfo() {
print("Admin Last Name = " + cws_user_lastname);
print("Admin Email = " + cws_user_email);
}
print("....................................................................................");
print("CWS web port = " + cws_tomcat_connector_port);
print("CWS SSL port = " + cws_tomcat_ssl_port);
print("CWS AJP port = " + cws_tomcat_ajp_port);
Expand Down Expand Up @@ -2598,6 +2599,7 @@ private static void updateFiles() throws IOException {
String serverAdaptationContent = getFileContents(
Paths.get(config_work_dir + SEP + "tomcat_conf" + SEP + "server_adaptation.xml"));
content = content.replace("<Resource name=\"jdbc/cws\"", serverAdaptationContent);
content = content.replace("__ADAPTATION_SERVER_RESOURCE__", "");

content = content.replace("__CWS_ADAPT_DB_URL__", cws_adapt_db_url);
content = content.replace("__CWS_ADAPT_DB_DRIVER__", cws_adapt_db_driver);
Expand Down Expand Up @@ -3334,4 +3336,4 @@ private static void setPreset(String key, String value) {
}
}

}
}

0 comments on commit 2f6d507

Please sign in to comment.