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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules
.env
22 changes: 22 additions & 0 deletions DigiCertGlobalRootCA.crt.pem
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
-----BEGIN CERTIFICATE-----
MIIDrzCCApegAwIBAgIQCDvgVpBCRrGhdWrJWZHHSjANBgkqhkiG9w0BAQUFADBh
MQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3
d3cuZGlnaWNlcnQuY29tMSAwHgYDVQQDExdEaWdpQ2VydCBHbG9iYWwgUm9vdCBD
QTAeFw0wNjExMTAwMDAwMDBaFw0zMTExMTAwMDAwMDBaMGExCzAJBgNVBAYTAlVT
MRUwEwYDVQQKEwxEaWdpQ2VydCBJbmMxGTAXBgNVBAsTEHd3dy5kaWdpY2VydC5j
b20xIDAeBgNVBAMTF0RpZ2lDZXJ0IEdsb2JhbCBSb290IENBMIIBIjANBgkqhkiG
9w0BAQEFAAOCAQ8AMIIBCgKCAQEA4jvhEXLeqKTTo1eqUKKPC3eQyaKl7hLOllsB
CSDMAZOnTjC3U/dDxGkAV53ijSLdhwZAAIEJzs4bg7/fzTtxRuLWZscFs3YnFo97
nh6Vfe63SKMI2tavegw5BmV/Sl0fvBf4q77uKNd0f3p4mVmFaG5cIzJLv07A6Fpt
43C/dxC//AH2hdmoRBBYMql1GNXRor5H4idq9Joz+EkIYIvUX7Q6hL+hqkpMfT7P
T19sdl6gSzeRntwi5m3OFBqOasv+zbMUZBfHWymeMr/y7vrTC0LUq7dBMtoM1O/4
gdW7jVg/tRvoSSiicNoxBN33shbyTApOB6jtSj1etX+jkMOvJwIDAQABo2MwYTAO
BgNVHQ8BAf8EBAMCAYYwDwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQUA95QNVbR
TLtm8KPiGxvDl7I90VUwHwYDVR0jBBgwFoAUA95QNVbRTLtm8KPiGxvDl7I90VUw
DQYJKoZIhvcNAQEFBQADggEBAMucN6pIExIK+t1EnE9SsPTfrgT1eXkIoyQY/Esr
hMAtudXH/vTBH1jLuG2cenTnmCmrEbXjcKChzUyImZOMkXDiqw8cvpOp/2PV5Adg
06O/nVsJ8dWO41P0jmP6P6fbtGbfYmbW0W5BjfIttep3Sp+dWOIrWcBAI+0tKIJF
PnlUkiaY4IBIqDfv8NZ5YBberOgOzW6sRBc4L0na4UU+Krk2U886UAb3LujEV0ls
YSEY1QSteDwsOoBrp+uvFRTp2InBuThs4pFsiv9kuXclVzDAGySj4dzp30d8tbQk
CAUw7C29C79Fv1C5qfPrmAESrciIxpg0X40KPMbp1ZWVbd4=
-----END CERTIFICATE-----
52 changes: 51 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,52 @@
# ProjectHub_SE
This GitHub repository contains the Software Engineering Lab projects for educational purposes. It includes comprehensive project documentation, source code, and testing frameworks to help students learn and contribute. Explore, learn, and contribute to help improve your software engineering skills.

## Description
This repository contains the source code for Edi2XML Convertor

## Getting Started
To get started, follow these steps:

1. Clone the repository:

git clone https://github.com/cipherKT/ProjectHub_SE.git

2. Switch to the "ediToXML" branch:

git checkout -b ediToXML

3. Navigate to the backend directory and Install backend dependencies:

npm i

4. Example Configuration:
```properties
DB_HOST=[Your Azure Database server hostname]
DB_USER=[Your database username]
DB_PASSWORD=[Your database password]
DB_DATABASE=[Name of the database you created]
DB_SSL_CA_PATH=[Path to SSL certificate (if applicable)]
```
5. Start the backend server:

node app.js

6. Navigate to the frontend directory:

cd frontend

7. Install frontend dependencies:

npm i

8. Start the frontend development server:

npm run start

9. Return to the root directory:

cd ..

10. Run Python script "test1.py":

python -u test1.py

183 changes: 183 additions & 0 deletions SE.side
Original file line number Diff line number Diff line change
@@ -0,0 +1,183 @@
{
"id": "4bea1fdf-a365-4c53-91a1-7d2546d1333c",
"version": "2.0",
"name": "SE",
"url": "http://localhost:3000/",
"tests": [{
"id": "9c314570-ea5d-4472-9112-006a58824e85",
"name": "",
"commands": []
}, {
"id": "736a3ea7-e76f-4e48-964f-a110e9d5c928",
"name": "test",
"commands": [{
"id": "0b8581fe-f849-4f63-a69c-42f85d349856",
"comment": "",
"command": "open",
"target": "http://localhost:3000/",
"targets": [],
"value": ""
}, {
"id": "703431f1-481f-4597-b276-f3db43ff5961",
"comment": "",
"command": "setWindowSize",
"target": "1552x832",
"targets": [],
"value": ""
}, {
"id": "1ed247a1-4114-43f9-9116-911616de2908",
"comment": "",
"command": "click",
"target": "css=.whitespace-nowrap",
"targets": [
["css=.whitespace-nowrap", "css:finder"],
["xpath=//button", "xpath:position"],
["xpath=//button[contains(.,'Login')]", "xpath:innerText"]
],
"value": ""
}, {
"id": "5871cf0c-19ae-40a3-bbc0-92035dfa5f4f",
"comment": "",
"command": "click",
"target": "css=.whitespace-nowrap",
"targets": [
["css=.whitespace-nowrap", "css:finder"],
["xpath=//button", "xpath:position"],
["xpath=//button[contains(.,'Login')]", "xpath:innerText"]
],
"value": ""
}, {
"id": "cb74ef18-48ac-4670-a3e9-0fad8f4b96e1",
"comment": "",
"command": "doubleClick",
"target": "css=.whitespace-nowrap",
"targets": [
["css=.whitespace-nowrap", "css:finder"],
["xpath=//button", "xpath:position"],
["xpath=//button[contains(.,'Login')]", "xpath:innerText"]
],
"value": ""
}, {
"id": "1906aa1d-0658-45ef-b5f6-f97f59780437",
"comment": "",
"command": "click",
"target": "linkText=Convert Bill",
"targets": [
["linkText=Convert Bill", "linkText"],
["css=.flex:nth-child(3)", "css:finder"],
["xpath=//a[contains(text(),'Convert Bill')]", "xpath:link"],
["xpath=//a[contains(@href, '/upload')]", "xpath:href"],
["xpath=//a[3]", "xpath:position"],
["xpath=//a[contains(.,'Convert Bill')]", "xpath:innerText"]
],
"value": ""
}, {
"id": "eded12e1-cd2d-4649-be85-674f0000eed5",
"comment": "",
"command": "click",
"target": "linkText=Home",
"targets": [
["linkText=Home", "linkText"],
["css=.gap-3:nth-child(1)", "css:finder"],
["xpath=//a[contains(text(),'Home')]", "xpath:link"],
["xpath=//a[contains(@href, '/bills')]", "xpath:href"],
["xpath=//nav/a", "xpath:position"],
["xpath=//a[contains(.,'Home')]", "xpath:innerText"]
],
"value": ""
}, {
"id": "6771950c-4915-4451-86f4-9021fb5dc032",
"comment": "",
"command": "click",
"target": "linkText=Logout",
"targets": [
["linkText=Logout", "linkText"],
["css=.flex:nth-child(4)", "css:finder"],
["xpath=//a[contains(text(),'Logout')]", "xpath:link"],
["xpath=(//a[contains(@href, '/')])[3]", "xpath:href"],
["xpath=//a[4]", "xpath:position"],
["xpath=//a[contains(.,'Logout')]", "xpath:innerText"]
],
"value": ""
}]
}, {
"id": "c2d4a929-0061-4d66-bad4-8ebbece123bf",
"name": "test2",
"commands": [{
"id": "60de5076-3406-4c7e-a9ee-662ef9457330",
"comment": "",
"command": "open",
"target": "http://localhost:3000/",
"targets": [],
"value": ""
}, {
"id": "f16844f1-fb1d-4436-8bed-cf86d24db611",
"comment": "",
"command": "setWindowSize",
"target": "1552x832",
"targets": [],
"value": ""
}, {
"id": "420ef4b8-7484-45e4-911c-59a0091c7bc0",
"comment": "",
"command": "click",
"target": "css=input",
"targets": [
["css=input", "css:finder"],
["xpath=//input[@type='file']", "xpath:attributes"],
["xpath=//div[@id='root']/div/div/form/input", "xpath:idRelative"],
["xpath=//input", "xpath:position"]
],
"value": ""
}, {
"id": "c4768a5f-ac56-4c15-ac84-529428014cd2",
"comment": "",
"command": "type",
"target": "css=input",
"targets": [
["css=input", "css:finder"],
["xpath=//input[@type='file']", "xpath:attributes"],
["xpath=//div[@id='root']/div/div/form/input", "xpath:idRelative"],
["xpath=//input", "xpath:position"]
],
"value": "C:\\fakepath\\ediText.txt"
}, {
"id": "4d9574e1-ebf8-47e0-8f28-728f92134fe8",
"comment": "",
"command": "click",
"target": "css=button",
"targets": [
["css=button", "css:finder"],
["xpath=//button[@type='submit']", "xpath:attributes"],
["xpath=//div[@id='root']/div/div/form/button", "xpath:idRelative"],
["xpath=//button", "xpath:position"],
["xpath=//button[contains(.,'Upload and Convert')]", "xpath:innerText"]
],
"value": ""
}, {
"id": "1513027d-46e1-47d5-a593-2bf62fb1cd9e",
"comment": "",
"command": "close",
"target": "",
"targets": [],
"value": ""
}, {
"id": "8a61695e-34b4-4c73-bf7e-8a40707e04fe",
"comment": "",
"command": "close",
"target": "",
"targets": [],
"value": ""
}]
}],
"suites": [{
"id": "229175e5-cebc-4a30-b03d-0a4050f1f0e9",
"name": "",
"persistSession": false,
"parallel": false,
"timeout": 300,
"tests": ["9c314570-ea5d-4472-9112-006a58824e85"]
}],
"urls": ["http://localhost:3000/"],
"plugins": []
}
112 changes: 112 additions & 0 deletions app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
const express = require('express');
const bodyParser = require('body-parser');
const multer = require('multer');
const mysql = require('mysql2');
const fs = require('fs');
const { transformToXml } = require('./converter.js');
const {parseEdiText } = require('./converter.js');
const cors = require('cors');


const app = express();
app.use(cors());
app.use(cors({
origin: 'http://localhost:3000', // The origin you want to allow
methods: ['GET', 'POST'], // HTTP methods you want to allow
allowedHeaders: ['Content-Type'], // Headers you want to allow
}));
// Set up body parser
app.use(bodyParser.json());
app.use(bodyParser.text({ type: 'text/plain' }));

// Configure multer for file uploads
const upload = multer({ storage: multer.memoryStorage() });
require('dotenv').config();
// Create a connection to the MySQL database
const connection = mysql.createConnection({
host: process.env.DB_HOST,
user: process.env.DB_USER,
password: process.env.DB_PASSWORD,
database: process.env.DB_DATABASE,
ssl: {
ca: fs.readFileSync(process.env.DB_SSL_CA_PATH),
rejectUnauthorized: false
}
});

connection.connect((err) => {
if (err) {
console.error('Error connecting to MySQL:', err);
return;
}
console.log('Connected to MySQL');
});

// Route to handle file uploads and store them in MySQL
app.post('/upload', upload.single('file'), (req, res) => {
if (!req.file) {
return res.status(400).json({ error: 'No file uploaded' });
}

// File metadata and content
const fileName = req.file.originalname;
const fileContent = req.file.buffer.toString('utf8');

// Insert the file into the database
const query = 'INSERT INTO files (file_name, file_content) VALUES (?, ?)';
connection.query(query, [fileName, fileContent], (err, results) => {
if (err) {
console.error('Error inserting file:', err);
return res.status(500).json({ error: 'Database error' });
}

res.json({ message: 'File uploaded and stored in database' });
});
});

// Route to process files from the MySQL database and convert them to XML
// Route to process files from the MySQL database and convert them to XML
app.get('/convert', (req, res) => {
const query = 'SELECT * FROM files';
connection.query(query, (err, results) => {
if (err) {
console.error('Error retrieving files from database:', err);
return res.status(500).json({ error: 'Database error' });
}

// Process each file and convert it to XML
results.forEach((file) => {
const parsedData = parseEdiText(file.file_content);
const xml = transformToXml(parsedData);

// Store the converted XML data in a new table
const xmlQuery = 'INSERT INTO converted_files (file_id, file_name, xml_content) VALUES (?, ?, ?)';
connection.query(xmlQuery, [file.id, file.file_name, xml], (err) => {
if (err) {
console.error('Error inserting converted file:', err);
return;
}
});
});

res.json({ message: 'Files converted and stored in database' });
});
});
// Route to fetch converted XML data from the database
app.get('/converted-xml', (req, res) => {
const query = 'SELECT * FROM converted_files';
connection.query(query, (err, results) => {
if (err) {
console.error('Error retrieving converted XML data:', err);
return res.status(500).json({ error: 'Database error' });
}
res.json(results);
});
});


// Start the server on port 3000
const port = 5000;
app.listen(port, () => {
console.log(`Server is running on http://localhost:${port}`);
});
Loading