Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Back development #12

Open
wants to merge 28 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
090287c
blank project
FK12344321 Jun 14, 2022
473ebb0
Basic functionality
FK12344321 Jun 15, 2022
eef3467
Implemented Mailing list
FK12344321 Jun 16, 2022
3765740
Backend implementation
FK12344321 Jun 18, 2022
dafea19
Delete src/backend/TimetableAPI directory
FK12344321 Jun 21, 2022
62d37c8
Finished the implementation of the project
FK12344321 Jun 22, 2022
e682f7e
Merge branch 'back_development' of https://github.com/InnoSWP/Crossli…
FK12344321 Jun 22, 2022
db76a30
Implemented view controller in backend
FK12344321 Jun 23, 2022
6aa34be
dockerize the project
FK12344321 Jun 23, 2022
9c91ab7
Dockerize the whole project
FK12344321 Jun 23, 2022
e8efbbc
merged with main
FK12344321 Jun 23, 2022
855615e
Finished dockerization
FK12344321 Jun 23, 2022
cfa59ee
fixed some bugs in docker-compose
FK12344321 Jun 25, 2022
19dd181
add tests
FK12344321 Jun 25, 2022
09526e3
update linter
FK12344321 Jun 25, 2022
2060698
fixed tests
FK12344321 Jun 25, 2022
62ec261
Update linter.yml
FK12344321 Jun 25, 2022
5507c2f
Update linter.yml
FK12344321 Jun 25, 2022
52bbe4a
Merge branch 'back_development' of https://github.com/InnoSWP/Crossli…
FK12344321 Jun 25, 2022
ffeac97
Delete MailingListMySQLRepositoryTest.java
FK12344321 Jun 25, 2022
1b0bd18
Create mvn
FK12344321 Jun 25, 2022
8219810
Update and rename mvn to mvn.yml
FK12344321 Jun 25, 2022
4874089
Update TimetableLinkApiApplicationTests.java
FK12344321 Jun 25, 2022
b1f7c44
Update mvn.yml
FK12344321 Jun 25, 2022
676bba6
normal tests
FK12344321 Jun 28, 2022
719cc9c
pulled changes
FK12344321 Jun 28, 2022
af36a33
new tests
FK12344321 Jun 29, 2022
4d83def
eventId is returned as Json
FK12344321 Jun 30, 2022
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
18 changes: 17 additions & 1 deletion .github/workflows/linter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ name: Lint Code Base
#############################
on:
push:
branches-ignore: [master, main]
branches-ignore: [master, main, back_development]
# Remove the line above to run when pushing to master
pull_request:
branches: [master, main]
Expand All @@ -35,6 +35,22 @@ jobs:
# Load all steps #
##################
steps:
- uses: actions/checkout@v3
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'adopt'
- name: Build with Maven
run: |
cd src/backend/TimetableLinkAPI
mvn --batch-mode --update-snapshots package
- name: Run the Maven verify phase
run: |
#cd src/backend/TimetableLinkAPI
mvn --batch-mode --update-snapshots verify


##########################
# Checkout the code base #
##########################
Expand Down
28 changes: 28 additions & 0 deletions .github/workflows/mvn.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Java CI

on:
push:
branches-ignore: [master, main, back_development]
# Remove the line above to run when pushing to master
pull_request:
branches: [master, main]

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'adopt'
- name: Build with Maven
run: |
cd src/backend/TimetableLinkAPI
mvn --batch-mode --update-snapshots package
- name: Run the Maven verify phase
run: |
cd src/backend/TimetableLinkAPI
mvn --batch-mode --update-snapshots verify
Binary file modified src/backend/TimetableLinkAPI/.DS_Store
Binary file not shown.
22 changes: 22 additions & 0 deletions src/backend/TimetableLinkAPI/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
FROM maven as builder
WORKDIR /usr/src/app
COPY pom.xml .
RUN mvn -B -e -C -T 1C org.apache.maven.plugins:maven-dependency-plugin:3.1.2:go-offline
COPY . .
RUN mvn package

FROM openjdk
EXPOSE 8080
COPY --from=builder /usr/src/app/target/*.jar ./
ENTRYPOINT ["java", "-jar", "/spring-boot-docker.jar"]

#FROM maven as build
#WORKDIR ./
#COPY . .
#RUN mvn package
#COPY . .
#
#FROM openjdk:17
#EXPOSE 8080
#ADD target/spring-boot-docker.jar spring-boot-docker.jar
#ENTRYPOINT ["java", "-jar", "/spring-boot-docker.jar"]
Binary file not shown.
64 changes: 64 additions & 0 deletions src/backend/TimetableLinkAPI/data/demo #jdbc:h2:/mem:db.trace.db
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
2022-06-25 19:27:31 jdbc[3]: exception
org.h2.jdbc.JdbcSQLSyntaxErrorException: Table "MAILINGLIST" not found (this database is empty); SQL statement:
INSERT INTO mailingList (textIdentifier) values (?) [42104-212]
2022-06-25 19:27:31 jdbc[5]: exception
org.h2.jdbc.JdbcSQLSyntaxErrorException: Table "MAILINGLIST" not found (this database is empty); SQL statement:
SELECT id FROM mailingList WHERE textIdentifier = ? [42104-212]
2022-06-25 20:26:43 jdbc[3]: exception
org.h2.jdbc.JdbcSQLSyntaxErrorException: Syntax error in SQL statement "CREATE [*]DATABASE IF NOT EXISTS timetable;\000aUSE timetable;\000a\000aSET SQL_SAFE_UPDATES = 0;\000a\000aCREATE TABLE IF NOT EXISTS mailingList (\000a id BIGINT PRIMARY KEY AUTO_INCREMENT,\000a textIdentifier VARCHAR(40) UNIQUE\000a);\000a\000aCREATE TABLE IF NOT EXISTS email(\000a id BIGINT PRIMARY KEY AUTO_INCREMENT,\000a emailAddress VARCHAR(60) UNIQUE\000a);\000a\000aCREATE TABLE IF NOT EXISTS emailBelonging(\000a id BIGINT PRIMARY KEY AUTO_INCREMENT,\000a emailId BIGINT,\000a mailingListId BIGINT,\000a FOREIGN KEY (emailId) REFERENCES email (id) ON DELETE CASCADE,\000a FOREIGN KEY (mailingListId) references mailingList (id) ON DELETE CASCADE\000a);\000a\000aCREATE TABLE IF NOT EXISTS event(\000a outlookAppointmentId varchar(400) PRIMARY KEY\000a);\000a"; expected "OR, FORCE, VIEW, ALIAS, SEQUENCE, USER, TRIGGER, ROLE, SCHEMA, CONSTANT, DOMAIN, TYPE, DATATYPE, AGGREGATE, LINKED, MEMORY, CACHED, LOCAL, GLOBAL, TEMP, TEMPORARY, TABLE, SYNONYM, UNIQUE, HASH, SPATIAL, INDEX"; SQL statement:
CREATE DATABASE IF NOT EXISTS timetable;
USE timetable;

SET SQL_SAFE_UPDATES = 0;

CREATE TABLE IF NOT EXISTS mailingList (
id BIGINT PRIMARY KEY AUTO_INCREMENT,
textIdentifier VARCHAR(40) UNIQUE
);

CREATE TABLE IF NOT EXISTS email(
id BIGINT PRIMARY KEY AUTO_INCREMENT,
emailAddress VARCHAR(60) UNIQUE
);

CREATE TABLE IF NOT EXISTS emailBelonging(
id BIGINT PRIMARY KEY AUTO_INCREMENT,
emailId BIGINT,
mailingListId BIGINT,
FOREIGN KEY (emailId) REFERENCES email (id) ON DELETE CASCADE,
FOREIGN KEY (mailingListId) references mailingList (id) ON DELETE CASCADE
);

CREATE TABLE IF NOT EXISTS event(
outlookAppointmentId varchar(400) PRIMARY KEY
);
[42001-212]
2022-06-25 20:30:44 jdbc[3]: exception
org.h2.jdbc.JdbcSQLSyntaxErrorException: Syntax error in SQL statement "CREATE [*]DATABASE IF NOT EXISTS timetable;\000aUSE timetable;\000a\000aSET SQL_SAFE_UPDATES = 0;\000a\000aCREATE TABLE IF NOT EXISTS mailingList (\000a id BIGINT PRIMARY KEY AUTO_INCREMENT,\000a textIdentifier VARCHAR(40) UNIQUE\000a);\000a\000aCREATE TABLE IF NOT EXISTS email(\000a id BIGINT PRIMARY KEY AUTO_INCREMENT,\000a emailAddress VARCHAR(60) UNIQUE\000a);\000a\000aCREATE TABLE IF NOT EXISTS emailBelonging(\000a id BIGINT PRIMARY KEY AUTO_INCREMENT,\000a emailId BIGINT,\000a mailingListId BIGINT,\000a FOREIGN KEY (emailId) REFERENCES email (id) ON DELETE CASCADE,\000a FOREIGN KEY (mailingListId) references mailingList (id) ON DELETE CASCADE\000a);\000a\000aCREATE TABLE IF NOT EXISTS event(\000a outlookAppointmentId varchar(400) PRIMARY KEY\000a);\000a"; expected "OR, FORCE, VIEW, ALIAS, SEQUENCE, USER, TRIGGER, ROLE, SCHEMA, CONSTANT, DOMAIN, TYPE, DATATYPE, AGGREGATE, LINKED, MEMORY, CACHED, LOCAL, GLOBAL, TEMP, TEMPORARY, TABLE, SYNONYM, UNIQUE, HASH, SPATIAL, INDEX"; SQL statement:
CREATE DATABASE IF NOT EXISTS timetable;
USE timetable;

SET SQL_SAFE_UPDATES = 0;

CREATE TABLE IF NOT EXISTS mailingList (
id BIGINT PRIMARY KEY AUTO_INCREMENT,
textIdentifier VARCHAR(40) UNIQUE
);

CREATE TABLE IF NOT EXISTS email(
id BIGINT PRIMARY KEY AUTO_INCREMENT,
emailAddress VARCHAR(60) UNIQUE
);

CREATE TABLE IF NOT EXISTS emailBelonging(
id BIGINT PRIMARY KEY AUTO_INCREMENT,
emailId BIGINT,
mailingListId BIGINT,
FOREIGN KEY (emailId) REFERENCES email (id) ON DELETE CASCADE,
FOREIGN KEY (mailingListId) references mailingList (id) ON DELETE CASCADE
);

CREATE TABLE IF NOT EXISTS event(
outlookAppointmentId varchar(400) PRIMARY KEY
);
[42001-212]
19 changes: 18 additions & 1 deletion src/backend/TimetableLinkAPI/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,22 @@
version: '3'

services:
server:
container_name: timetable_server
build: .
environment:
SPRING_APPLICATION_JSON: '{
"spring.datasource.url" : "jdbc:mysql://db:3306/timetable"
}'
ports:
- "8080:8080"
depends_on:
- db
restart: on-failure


db:
container_name: timetable_db
image: mysql:8.0
platform: linux/x86_64
restart: always
Expand All @@ -12,5 +27,7 @@ services:
- MYSQL_DATABASE=timetable
- MYSQL_ROOT_PASSWORD=pass
ports:
- '3306:3306'
- "3306:3306"



13 changes: 0 additions & 13 deletions src/backend/TimetableLinkAPI/index.html

This file was deleted.

12 changes: 11 additions & 1 deletion src/backend/TimetableLinkAPI/init.sql
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
CREATE DATABASE IF NOT EXISTS timetable;
USE timetable;

SET SQL_SAFE_UPDATES = 0;

CREATE TABLE IF NOT EXISTS mailingList (
id BIGINT PRIMARY KEY AUTO_INCREMENT,
textIdentifier VARCHAR(40) UNIQUE
Expand All @@ -21,4 +23,12 @@ CREATE TABLE IF NOT EXISTS emailBelonging(

CREATE TABLE IF NOT EXISTS event(
outlookAppointmentId varchar(400) PRIMARY KEY
);
);

-- CREATE DATABASE IF NOT EXISTS test;
-- USE test;
--
-- CREATE TABLE LIKE timetable.mailingList;
-- CREATE TABLE LIKE timetable.email;
-- CREATE TABLE LIKE timetable.emailBelonging;
-- CREATE TABLE LIKE timetable.event;
44 changes: 38 additions & 6 deletions src/backend/TimetableLinkAPI/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -53,24 +53,56 @@
<version>5.3.20</version>
</dependency>

<!-- https://mvnrepository.com/artifact/junit/junit -->
<!-- https://mvnrepository.com/artifact/org.junit.jupiter/junit-jupiter-api -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.2</version>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>5.9.0-M1</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<scope>test</scope>
</dependency>

</dependencies>
<!-- https://mvnrepository.com/artifact/org.assertj/assertj-core -->
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<version>3.23.1</version>
<scope>test</scope>
</dependency>

<!-- https://mvnrepository.com/artifact/org.mockito/mockito-core -->
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>4.6.1</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jdbc</artifactId>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>${project.parent.version}</version>
</plugin>
</plugins>
<finalName>spring-boot-docker</finalName>
</build>

</project>
Binary file modified src/backend/TimetableLinkAPI/src/main/.DS_Store
Binary file not shown.
21 changes: 2 additions & 19 deletions src/backend/TimetableLinkAPI/src/main/java/com/timetable/App.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,31 +11,14 @@
import org.springframework.context.annotation.PropertySource;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.datasource.DriverManagerDataSource;
import org.springframework.web.servlet.config.annotation.*;


import javax.sql.DataSource;

@SpringBootApplication
@Import({SpringJdbcConfig.class})
//@EnableWebMvc
public class App {
public class App {
public static void main(String[] args) {
SpringApplication.run(App.class, args);
}

// @Override
// public void addViewControllers(ViewControllerRegistry registry) {
// registry.addViewController("/").setViewName("forward:/index.html");
// }
//
// @Bean
// public WebMvcConfigurer corsConfigurer() {
// return new WebMvcConfigurerAdapter() {
// @Override
// public void addCorsMappings(CorsRegistry registry) {
// registry.addMapping("/**")
// .allowedMethods("HEAD", "GET", "PUT", "POST", "DELETE", "PATCH");
// }
// };
// }
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@

import org.apache.tomcat.util.buf.UDecoder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.util.UriUtils;

import java.net.URLDecoder;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.util.Base64;
import java.util.Date;
import java.util.List;
import java.util.*;

@RestController
@RequestMapping(path = "/events")
Expand All @@ -23,17 +22,17 @@ public EventController(EventService eventService) {
}

@PostMapping
@CrossOrigin(origins = "http://localhost:63342")
public String createEvent(@RequestBody Event event) {
public Map<String, String> createEvent(@RequestBody Event event) {
//System.out.println(event.getEndDate());
String eventId = null;
Map<String, String> eventIdMap = new HashMap<>();
try {
eventId = eventService.createEvent(event);
String eventId = eventService.createEvent(event);
eventIdMap.put("eventId", eventId);
}
catch (Exception ex) {
ex.printStackTrace();
}
return eventId;
return eventIdMap;
}

@GetMapping ("/{eventId}")
Expand Down Expand Up @@ -100,6 +99,15 @@ public List<Event> getAllEvents() {
return events;
}

@GetMapping("/names")
public List<String> getAllNames() {
List<String> names = null;
try {
names = getAllEvents().stream().map(Event::getName).toList();
} catch (Exception ex) {}
return names;
}

@PatchMapping ("/{eventId}/invite/{mailingListTextIdentifier}")
public void inviteAllFromMailingList(@PathVariable String eventId,
@PathVariable String mailingListTextIdentifier) {
Expand Down
Loading