Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
9 changes: 7 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,12 @@ repos:
- id: mixed-line-ending
args: ['--fix=auto']
- repo: https://github.com/macisamuele/language-formatters-pre-commit-hooks
rev: v2.0.0
rev: v2.15.0
hooks:
- id: pretty-format-java
args: [--autofix, --google-java-formatter-version=1.7]
args: [--autofix, --google-java-formatter-version=1.28.0]
- repo: https://github.com/commitizen-tools/commitizen
rev: v3.10.0
hooks:
- id: commitizen
stages: [commit-msg]
Binary file renamed BlankCanvasDB.zip → AnimalDB.zip
Binary file not shown.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SEMOSS Blank Canvas Template App
# SEMOSS Template App

## Overview

Expand Down Expand Up @@ -76,8 +76,8 @@ To make changes visible to users:
2. Rename `assets` to `old-assets`.
3. Open a terminal at this location.
4. Clone this repository:
`git clone git@github.com:Deloitte-US/SemossBlankCanvas.git`, if using SSH keys
5. Rename the cloned `SemossBlankCanvas` folder to `assets`.
`git clone git@github.com:Deloitte-US/Template.git`, if using SSH keys
5. Rename the cloned `Template` folder to `assets`.
6. Open `assets` in your code editor (VS Code recommended).

---
Expand Down
Binary file modified client/.DS_Store
Binary file not shown.
14 changes: 7 additions & 7 deletions client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,22 @@
"dependencies": {
"@emotion/react": "^11.14.0",
"@emotion/styled": "^11.14.1",
"@mui/icons-material": "^7.3.1",
"@mui/material": "^7.3.1",
"@mui/x-data-grid": "^8.10.2",
"@mui/x-date-pickers": "^8.10.2",
"@mui/icons-material": "^7.3.2",
"@mui/material": "^7.3.2",
"@mui/x-data-grid": "^8.11.2",
"@mui/x-date-pickers": "^8.11.2",
"@semoss/sdk": "1.0.0-beta.29",
"@semoss/sdk-react": "1.0.0-beta.20",
"css-loader": "^7.1.2",
"dayjs": "^1.11.15",
"dayjs": "^1.11.18",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"react-router": "^7.8.2"
},
"devDependencies": {
"@types/node": "^24.3.0",
"@types/node": "^24.3.1",
"@types/react": "^19.1.12",
"dotenv": "^17.2.1",
"dotenv": "^17.2.2",
"html-webpack-plugin": "^5.6.4",
"ts-loader": "^9.5.4",
"typescript": "^5.9.2",
Expand Down
371 changes: 191 additions & 180 deletions client/pnpm-lock.yaml

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion client/src/components/base/MainNavigation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ export const MainNavigation = () => {
fontWeight="bold"
whiteSpace="nowrap"
>
SEMOSS Blank Canvas
SEMOSS Template
</Typography>
</CursorStack>

Expand Down
2 changes: 1 addition & 1 deletion client/src/components/examples/AddAnimalModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export const AddAnimalModal = ({ open, onClose }: AddAnimalModalProps) => {
*/
const handleSubmitClick = async () => {
addAnimal(
`AddAnimal(animal_name=${JSON.stringify(animalName)}, animal_type=${JSON.stringify(animalType)}, date_of_birth=${JSON.stringify(dateOfBirth)})`,
`AddAnimal(animalName=${JSON.stringify(animalName)}, animalType=${JSON.stringify(animalType)}, dateOfBirth=${JSON.stringify(dateOfBirth)})`,
() => handleClose(true),
);
};
Expand Down
3 changes: 1 addition & 2 deletions client/src/pages/Router.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ import {
ROUTE_PATH_LOGIN_PAGE,
ROUTE_PATH_ANIMAL_PAGE,
} from './routes.constants';
import { InitializedLayout } from './InitializedLayout';
import { AuthorizedLayout } from './AuthorizedLayout';
import { AuthorizedLayout, InitializedLayout } from './layouts';
import { HomePage } from './HomePage';
import { LoginPage } from './LoginPage';
import { AnimalPage } from './AnimalPage';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useInsight } from '@semoss/sdk-react';
import { Navigate, Outlet, useLocation } from 'react-router';
import { ROUTE_PATH_LOGIN_PAGE } from './routes.constants';
import { ROUTE_PATH_LOGIN_PAGE } from '../routes.constants';
import { useAppContext } from '@/contexts';
import { LoadingScreen } from '@/components';

Expand Down
2 changes: 2 additions & 0 deletions client/src/pages/layouts/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * from './AuthorizedLayout';
export * from './InitializedLayout';
2 changes: 1 addition & 1 deletion client/src/template.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
rel="stylesheet"
/>
<meta charset="UTF-8" />
<title>SEMOSS Blank Canvas</title>
<title>SEMOSS Template</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
</head>

Expand Down
4 changes: 2 additions & 2 deletions java/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ Following the core SEMOSS install instructions, we will focus on using Eclipse a

### Project Import

Install the project with `File > Import > Existing Maven Projects > Browse`. Navigate to the the SEMOSS project directory where you installed these files (e.g., `C:\workspace\Semoss\project\SemossBlankCanvas__[APP_ID]\app_root\version\assets`), and click `Select Folder`. Click `Finish`.
Install the project with `File > Import > Existing Maven Projects > Browse`. Navigate to the the SEMOSS project directory where you installed these files (e.g., `C:\workspace\Semoss\project\SemossTemplate__[APP_ID]\app_root\version\assets`), and click `Select Folder`. Click `Finish`.

This should import the reactor files into your workspace. You may not see the project appear in your `Project Explorer` panel by default since it is nested in the `Semoss` project from the SEMOSS install instructions. You can click the vertical triple dots button to the top right of your project explorer and check that `Projects Presentation` shows as `Flat` instead of `Hierarchical` to get it to appear non-nested.

### Code Style

The Blank Canvas repository enforces the Google Java Style Guide as a pre-commit hook to enforce code style. Code changes will be performed automatically at commit time to align with the guide, but you may want to update Eclipse's Java formatter to make these changes before commit time. You can install Google's formatter plugin by following the instructions [here](https://github.com/google/google-java-format?tab=readme-ov-file#eclipse). In short: download the (plugin)[https://github.com/google/google-java-format/releases/download/v1.23.0/google-java-format-eclipse-plugin-1.23.0.jar], and copy to `C:\Users\<youruser>\eclipse\dropins` (or wherever you installed Eclipse). Once there you can right click your TQMC project, choose `Properties > Java Code Style > Formatter`, click the checkbox to `Enable project specific settings` and choose `google-java-format` in the dropdown for `Formatter implementation:`. After applying, you should be able to format a given source file to the new style guide with `Ctrl+Shift+F` or via `Source > Format` as per usual.
The Template repository enforces the Google Java Style Guide as a pre-commit hook to enforce code style. Code changes will be performed automatically at commit time to align with the guide, but you may want to update Eclipse's Java formatter to make these changes before commit time. You can install Google's formatter plugin by following the instructions [here](https://github.com/google/google-java-format?tab=readme-ov-file#eclipse). In short: download the (plugin)[https://github.com/google/google-java-format/releases/download/v1.23.0/google-java-format-eclipse-plugin-1.23.0.jar], and copy to `C:\Users\<youruser>\eclipse\dropins` (or wherever you installed Eclipse). Once there you can right click your TQMC project, choose `Properties > Java Code Style > Formatter`, click the checkbox to `Enable project specific settings` and choose `google-java-format` in the dropdown for `Formatter implementation:`. After applying, you should be able to format a given source file to the new style guide with `Ctrl+Shift+F` or via `Source > Format` as per usual.
46 changes: 23 additions & 23 deletions java/src/domain/examples/AnimalData.java
Original file line number Diff line number Diff line change
@@ -1,47 +1,47 @@
package domain.examples;

public class AnimalData {
private int animal_id;
private String animal_type;
private String animal_name;
private String date_of_birth;
private String animalId;
private String animalType;
private String animalName;
private String dateOfBirth;

public AnimalData(int animal_id, String animal_type, String animal_name, String date_of_birth) {
this.animal_id = animal_id;
this.animal_type = animal_type;
this.animal_name = animal_name;
this.date_of_birth = date_of_birth;
public AnimalData(String animalId, String animalType, String animalName, String dateOfBirth) {
this.animalId = animalId;
this.animalType = animalType;
this.animalName = animalName;
this.dateOfBirth = dateOfBirth;
}

public String getName() {
return animal_name;
public String getAnimalName() {
return animalName;
}

public void setName(String name) {
this.animal_name = name;
public void setAnimalName(String animalName) {
this.animalName = animalName;
}

public int getId() {
return animal_id;
public String getAnimalId() {
return animalId;
}

public void setId(int id) {
this.animal_id = id;
public void setAnimalId(String animalId) {
this.animalId = animalId;
}

public String getDateOfBirth() {
return date_of_birth;
return dateOfBirth;
}

public void setDateOfBirth(String dateOfBirth) {
this.date_of_birth = dateOfBirth;
this.dateOfBirth = dateOfBirth;
}

public String getType() {
return animal_type;
public String getAnimalType() {
return animalType;
}

public void setType(String type) {
this.animal_type = type;
public void setAnimalType(String animalType) {
this.animalType = animalType;
}
}
69 changes: 12 additions & 57 deletions java/src/reactors/AbstractProjectReactor.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,10 @@

import domain.base.ErrorCode;
import domain.base.ProjectException;
import java.sql.Connection;
import java.sql.SQLException;
import org.apache.commons.lang.exception.ExceptionUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import prerna.auth.User;
import prerna.engine.api.IRDBMSEngine;
import prerna.engine.impl.rdbms.RDBMSNativeEngine;
import prerna.reactor.AbstractReactor;
import prerna.sablecc2.om.PixelDataType;
import prerna.sablecc2.om.PixelOperationType;
Expand All @@ -21,54 +18,20 @@ public abstract class AbstractProjectReactor extends AbstractReactor {
private static final Logger LOGGER = LogManager.getLogger(AbstractProjectReactor.class);

protected User user;

protected String projectId;
protected ProjectProperties projectProperties;

protected String engineId;
// intialize protected variables you would like your reactors to have access to
protected String databaseId;
protected RDBMSNativeEngine database;

protected NounMetadata result = null;

@Override
public NounMetadata execute() {
try {
preExecute();

IRDBMSEngine engine = (IRDBMSEngine) Utility.getEngine(engineId);
if (engine == null) {
throw new ProjectException(ErrorCode.INTERNAL_SERVER_ERROR, "Unable to find database");
}
Connection con = null;
try {
con = engine.makeConnection();

if (isReadOnly()) {
result = doExecute(con);
} else {
boolean isAutoCommit = con.getAutoCommit();
con.setAutoCommit(false);
try {
result = doExecute(con);
con.commit();
} catch (Exception e) {
con.rollback();
ProjectException ex = null;
if (e instanceof ProjectException) {
ex = (ProjectException) e;
} else {
ex = new ProjectException(ErrorCode.INTERNAL_SERVER_ERROR, e);
}
throw ex;
} finally {
con.setAutoCommit(isAutoCommit);
}
}
} finally {
if (engine.isConnectionPooling() && con != null) {
con.close();
}
}
return result;
return doExecute();
} catch (Exception e) {
ProjectException ex = null;
if (e instanceof ProjectException) {
Expand All @@ -78,15 +41,6 @@ public NounMetadata execute() {
}
LOGGER.error(String.format("Reactor %s threw an error", this.getClass().getSimpleName()), e);

NounMetadata result =
new NounMetadata(ex.getAsMap(), PixelDataType.MAP, PixelOperationType.ERROR);
if (projectProperties != null && projectProperties.getDebuggingEnabled()) {
result.addAdditionalReturn(
new NounMetadata(
ExceptionUtils.getFullStackTrace(e),
PixelDataType.CONST_STRING,
PixelOperationType.ERROR));
}
return new NounMetadata(ex.getAsMap(), PixelDataType.MAP, PixelOperationType.ERROR);
}
}
Expand All @@ -98,16 +52,17 @@ protected void preExecute() {
}

projectProperties = ProjectProperties.getInstance(projectId);
engineId = projectProperties.getEngineId();

// Update protected variables
databaseId = projectProperties.getDatabaseId();
if (databaseId != null) {
database = (RDBMSNativeEngine) Utility.getDatabase(databaseId);
}

user = this.insight.getUser();

organizeKeys();
}

protected abstract NounMetadata doExecute(Connection con) throws SQLException;

protected boolean isReadOnly() {
return false;
}
protected abstract NounMetadata doExecute();
}
19 changes: 19 additions & 0 deletions java/src/reactors/HelloWorldReactor.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package reactors;

import prerna.sablecc2.om.PixelDataType;
import prerna.sablecc2.om.nounmeta.NounMetadata;
import util.Constants;

public class HelloWorldReactor extends AbstractProjectReactor {

// Note: Has access to protected variables defined in AbstractProjectReactor

@Override
protected NounMetadata doExecute() {

// grabbing user from AbstractProjectReactor
String response = Constants.HELLO_WORLD + " " + user.getPrimaryLoginToken().getId();

return new NounMetadata(response, PixelDataType.CONST_STRING);
}
}
45 changes: 14 additions & 31 deletions java/src/reactors/examples/AddAnimalReactor.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,52 +2,35 @@

import domain.base.ErrorCode;
import domain.base.ProjectException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import org.apache.commons.lang3.StringUtils;
import prerna.sablecc2.om.PixelDataType;
import prerna.sablecc2.om.nounmeta.NounMetadata;
import reactors.AbstractProjectReactor;
import util.Constants;
import util.HelperMethods;

public class AddAnimalReactor extends AbstractProjectReactor {

public static final String animalNameColumn = "animal_name";
public static final String animalTypeColumn = "animal_type";
public static final String dateOfBirthColumn = "date_of_birth";

public AddAnimalReactor() {
this.keysToGet = new String[] {animalNameColumn, animalTypeColumn, dateOfBirthColumn};
this.keysToGet =
new String[] {Constants.ANIMAL_NAME, Constants.ANIMAL_TYPE, Constants.DATE_OF_BIRTH};
this.keyRequired = new int[] {1, 1, 1};
}

@Override
protected NounMetadata doExecute(Connection con) {
String animalName = this.keyValue.get(animalNameColumn);
String animalType = this.keyValue.get(animalTypeColumn);
String dateOfBirth = this.keyValue.get(dateOfBirthColumn);

if (animalName == null
|| animalName.isEmpty()
|| animalType == null
|| animalType.isEmpty()
|| dateOfBirth == null
|| dateOfBirth.isEmpty()) {
protected NounMetadata doExecute() {
String animalName = this.keyValue.get(Constants.ANIMAL_NAME);
String animalType = this.keyValue.get(Constants.ANIMAL_TYPE);
String dateOfBirth = this.keyValue.get(Constants.DATE_OF_BIRTH);

if (StringUtils.trimToNull(animalName) == null
|| StringUtils.trimToNull(animalType) == null
|| StringUtils.trimToNull(dateOfBirth) == null) {
throw new ProjectException(
ErrorCode.BAD_REQUEST, "Animal name, type, and date of birth cannot be empty");
}

try (PreparedStatement ps =
con.prepareStatement(
"INSERT INTO animal (animal_name, animal_type, date_of_birth)\n"
+ "VALUES (?, ?, ?);")) {
int parameterIndex = 1;
ps.setString(parameterIndex++, animalName);
ps.setString(parameterIndex++, animalType);
ps.setString(parameterIndex++, dateOfBirth);
ps.execute();
} catch (SQLException e) {
throw new ProjectException(ErrorCode.INTERNAL_SERVER_ERROR, "Error adding animal");
}
HelperMethods.addAnimal(database, animalName, animalType, dateOfBirth);

return new NounMetadata(true, PixelDataType.BOOLEAN);
}
Expand Down
Loading