Skip to content
Open
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
40 changes: 40 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# CHANGELOG

## version [1.0.0] - 2026-05-24
### Added
- Initial release of OracleQuant Package Measurement Conversion API.
- Core algorithm for parsing measurement strings (MeasurementParser.java).
- GET /api/convert-measurements endpoint for converting input strings.
- Support for multi-character z-prefix number encoding (e.g. "zza" = 53).
- Support for zero-sentinel '_' character (value = 0, terminates number).
- Persist all conversion requests to Oracle XE Database automatically.
- GET /history endpoint to fetch all history records.
- GET /history/{id} endpoint to fetch a specific history record.
- PUT /history/{id} endpoint for full update of a history record.
- PATCH /history/{id} endpoint for partial update of a history record.
- DELETE /history endpoint to clear all history records.
- HistoryRecord JPA entity with id, timestamp, sourceIpAddress, input, output.
- Spring Boot 3.2.0 with Oracle OpenJDK 17.
- Maven build system producing pkc-api.jar.
- Oracle JDBC driver (ojdbc11) for Oracle XE connection.
- Hibernate ORM with GenerationType.SEQUENCE for Oracle compatibility.
- Logging to console and logs/ directory with 7-day rolling files via Logback.
- README.md with setup, database config, and API documentation.
- CHANGELOG.md file to track project versions and changes.
- Deployed and running on Oracle Linux via SSH.
- Firewall port 8080 opened on Oracle Linux.
- Application configured as a background service via systemd.

### Fixed
- Fixed jakarta.persistence import (lowercase j) in HistoryRecord.java.
- Fixed GenerationType from IDENTITY to SEQUENCE for Oracle XE compatibility.
- Fixed MeasurementParser — added full parse() method with z-accumulation.
- Fixed ConversionController — removed HistoryRepository direct injection.
- Fixed return type from List<Integer> to List<Long> in ConversionService.
- Fixed HistoryService — added sourceIpAddress field to update method.
- Fixed HistoryController — added proper 404 response for missing records.
- Fixed application.properties — corrected Oracle dialect configuration.
- Fixed project JDK from OpenJDK 25 to OpenJDK 17 in IntelliJ.
- Fixed pom.xml — merged duplicate build sections, added finalName pkc-api.
- Fixed deployment — corrected application.properties path on Oracle Linux.
- Fixed datasource driver-class-name typo (deiver → driver) on Oracle Linux.
221 changes: 160 additions & 61 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,61 +1,160 @@
## Submission Instructions

To submit your Oracle JAVA Spring Boot Maven project as a solution, please follow these steps:

### Step 1: Install git on your PC
- Install "git" as shown in this tutorial: [How to install git](https://youtu.be/iYkLrXobBbA?si=_l0haibv_X9NpIjJ)
- Open command prompt and run
```bash
git version
```
- If you see the version, then git is successfully installed.

### Step 2: Fork the Repository
- Navigate to [this repository](https://github.com/CodelineAtyab/oraclequantapi) provided by Codeline.
- Click on the "Fork" button at the top-right corner of the page to create a copy of the repository under your own GitHub account.

### Step 3: Clone the Forked Repository
- Open your terminal or command prompt.
- Clone the forked repository to your local machine using the following command:
```bash
git clone https://github.com/your-username/repo-name.git
```

### Step 4: Create a new branch
- Navigate to the cloned repository directory
```bash
cd repo-name
```
- Create a new branch for your code submissions (Replace your-name with your name in your-name-submission-branch):
```bash
git checkout -b your-name-submission-branch
```


### Step 5: Add Your Code
- Implement the API

### Step 6: Commit your changes
- Run the following commands in order to commit your changes:
```bash
git add *
git commit -m "Meaningful commit message here"
```

### Step 7: Push Your Branch to GitHub
- Run the following commands to upload the changes to the forked github repository (Replace your-name with your name in your-name-submission-branch):
```bash
git push origin your-name-submission-branch
```

### Step 8: Create a Pull Request
- Go to your forked repository on GitHub.
- You should see a prompt to create a pull request. Click on "Compare & pull request".
- Provide a title and description for your pull request, then click "Create pull request".

### Step 9: Notify Codeline
- Notify on slack that you have created a PR for your solution.

## Note: If you face any issues in the process above, Please do the following:
- Watch [this youtube tutorial](https://www.youtube.com/watch?v=a_FLqX3vGR4)
- Contact Ikhlas or Atyab.
# Package Measurement Conversion API

## Features
- Convert measurement strings to numeric package totals.
- Persist conversion history in Oracle XE Database.
- Built with Spring Boot and Oracle OpenJDK 17.
- Logging to `logs/` directory.

## Prerequisites
- Oracle OpenJDK 17 installed.
- Oracle XE 21c Database running.
- Apache Maven 3.8+ installed.

---

## Running the Application

### Build the JAR
```bash
.\mvnw clean package -DskipTests
```

### Run the JAR
```bash
java -jar target/pkc-api.jar
```

### API available at

http://localhost:8080/
---

## Configuring the Database

Edit `src/main/resources/application.properties`:

```properties
spring.datasource.url=jdbc:oracle:thin:@//localhost:1521/XEPDB1
spring.datasource.username=system
spring.datasource.password=yourpassword
spring.datasource.driver-class-name=oracle.jdbc.OracleDriver
spring.jpa.hibernate.ddl-auto=update
server.port=8080
```

---

## API Endpoints

### Convert Measurements

GET/http://192.168.100.7:8080/history/2

{
"id": 2,
"timestamp": "2026-05-24T08:59:18.375786",
"sourceIpAddress": "0:0:0:0:0:0:0:1",
"input": "aa",
"output": "[1]"
}

POST/http://192.168.100.7:8080/history/2

"timestamp": "2026-05-24T12:18:33.642+00:00",
"status": 405,
"error": "Method Not Allowed",
"path": "/history/2"
}

PATCH/http://192.168.100.7:8080/history/

{
"timestamp": "2026-05-24T12:19:48.149+00:00",
"status": 404,
"error": "Not Found",
"path": "/history/"
}

PUT/http://localhost:8080/history/1
{
"id": 1,
"timestamp": "2026-05-24T08:58:56.620227",
"sourceIpAddress": "0:0:0:0:0:0:0:1",
"input": "abbcc",
"output": "[2, 6]"
}

http://192.168.100.7:8080/api/convert-measurements?input=abbcc
[2,6]

DELETE/history

--- Example Response:
```json
[
{
"id": 1,
"timestamp": "2024-05-24T10:30:00",
"sourceIpAddress": "127.0.0.1",
"input": "abbcc",
"output": "[2, 6]"
}
]
```

---

## Deploy on Oracle Linux via SSH

### 1. Copy JAR to Oracle Linux
```bash
scp target/pkc-api.jar razan@192.168.100.7:/home/razan/
```

### 2. SSH into server
```bash
ssh razan@192.168.100.7
```

### 3. Install Java 17
```bash
sudo dnf install -y java-17-openjdk-headless
```

### 4. Create app folder and move JAR
```bash
sudo mkdir -p /opt/pkc-api
sudo cp /home/razan/pkc-api.jar /opt/pkc-api/
```

### 5. Create configuration file
```bash
sudo tee /opt/pkc-api/application.properties << 'EOF'
spring.datasource.url=jdbc:oracle:thin:@//192.168.100.11:1521/XEPDB1
spring.datasource.username=system
spring.datasource.password=yourpassword
spring.datasource.driver-class-name=oracle.jdbc.OracleDriver
spring.jpa.hibernate.ddl-auto=update
server.port=8080
EOF
```

### 6. Open firewall port
```bash
sudo firewall-cmd --permanent --add-port=8080/tcp
sudo firewall-cmd --reload
```

### 7. Run the application
```bash
java -jar /opt/pkc-api/pkc-api.jar \
--spring.config.location=file:/opt/pkc-api/application.properties
```

### 8. Test the deployment
```bash
curl "http://http://192.168.100.7:8080/api/convert-measurements?input=abcdabcdab"
```

--- Response:[2,7,7]
65 changes: 45 additions & 20 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -1,54 +1,79 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.5.14</version>
<relativePath/> <!-- lookup parent from repository -->
<version>3.2.0</version>
<relativePath/>
</parent>

<groupId>com.oraclequantapi</groupId>
<artifactId>oraclequantapi</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name/>
<description/>
<url/>
<licenses>
<license/>
</licenses>
<developers>
<developer/>
</developers>
<scm>
<connection/>
<developerConnection/>
<tag/>
<url/>
</scm>
<name>oraclequantapi</name>
<description>OracleQuant PKC API</description>

<properties>
<java.version>17</java.version>
</properties>

<dependencies>

<!-- Spring Boot Web -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>

<!-- Spring Data JPA — includes jakarta.persistence -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>

<!-- Oracle JDBC Driver -->
<dependency>
<groupId>com.oracle.database.jdbc</groupId>
<artifactId>ojdbc11</artifactId>
<version>23.3.0.23.09</version>
</dependency>

<!-- Lombok -->
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>

<!-- Spring Boot Test -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>

</dependencies>

<build>
<finalName>pkc-api</finalName>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<excludes>
<exclude>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>

</project>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
public class OraclequantapiApplication {

public static void main(String[] args) {
SpringApplication.run(OraclequantapiApplication.class, args);
SpringApplication.run
(OraclequantapiApplication.class, args);
}

}
Loading