diff --git a/backend/.idea/workspace.xml b/backend/.idea/workspace.xml
index fc7a90a..cf60247 100644
--- a/backend/.idea/workspace.xml
+++ b/backend/.idea/workspace.xml
@@ -4,9 +4,11 @@
-
+
-
+
+
+
@@ -85,81 +87,82 @@
-
-
+
+
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
-
+
-
+
-
-
-
+
+
+
-
+
-
+
-
-
-
+
+
+
-
+
-
+
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -174,11 +177,11 @@
-
-
-
-
-
+
+
+
+
+
@@ -482,17 +485,45 @@
1699695051881
-
+
+
+ 1699705458914
+
+
+
+ 1699705458914
+
+
+
+ 1699708881009
+
+
+
+ 1699708881009
+
+
+
+ 1699711238266
+
+
+
+ 1699711238266
+
+
+
+ 1699714216432
+
+
+
+ 1699714216432
+
+
-
-
-
-
@@ -514,31 +545,25 @@
-
+
+
+
+
+
-
- file://$PROJECT_DIR$/src/main/java/core/services/TaskScheduleService.java
- 87
-
-
-
- file://$PROJECT_DIR$/src/main/java/core/services/TaskScheduleService.java
- 94
-
-
-
- file://$PROJECT_DIR$/src/main/java/core/services/TaskScheduleService.java
- 202
-
-
file://$PROJECT_DIR$/src/main/java/core/entities/User.java
57
+
+ file://$PROJECT_DIR$/src/main/java/core/services/TaskScheduleService.java
+ 50
+
+
diff --git a/backend/src/main/java/core/api/controller/ScheduleController.java b/backend/src/main/java/core/api/controller/ScheduleController.java
index e6e1528..9d62300 100644
--- a/backend/src/main/java/core/api/controller/ScheduleController.java
+++ b/backend/src/main/java/core/api/controller/ScheduleController.java
@@ -90,4 +90,19 @@ public class ScheduleController {
return ResponseEntity.status(400).body(new SimpleStatusResponse("failed"));
}
+
+ @DeleteMapping("/schedules/{scheduleID}")
+ public ResponseEntity> deleteSchedule(@PathVariable long scheduleID) {
+ PermissionResult permissionResult = taskScheduleService.getSchedulePermissions(scheduleID, SecurityContextHolder.getContext().getAuthentication().getName());
+ if(permissionResult.isHasPermissions()) {
+ return ResponseEntity.status(403).body(new SimpleStatusResponse("failed"));
+ }
+
+ if(permissionResult.getExitCode() == ServiceExitCode.MISSING_ENTITY) {
+ return ResponseEntity.status(404).body(new SimpleStatusResponse("failed"));
+ }
+
+ taskScheduleService.deleteSchedule(permissionResult.getResult());
+ return ResponseEntity.ok(new SimpleStatusResponse("success"));
+ }
}
diff --git a/backend/src/main/java/core/services/TaskScheduleService.java b/backend/src/main/java/core/services/TaskScheduleService.java
index 1f11bd6..4f4b550 100644
--- a/backend/src/main/java/core/services/TaskScheduleService.java
+++ b/backend/src/main/java/core/services/TaskScheduleService.java
@@ -51,4 +51,8 @@ public class TaskScheduleService {
scheduleRepository.save(schedule);
return new ServiceResult<>(schedule);
}
+
+ public void deleteSchedule(AbstractSchedule schedule) {
+ scheduleRepository.delete(schedule);
+ }
}
diff --git a/backend/src/test/java/core/schedules/ScheduleServiceTest.java b/backend/src/test/java/core/schedules/ScheduleServiceTest.java
index edc4ef7..9e25f2b 100644
--- a/backend/src/test/java/core/schedules/ScheduleServiceTest.java
+++ b/backend/src/test/java/core/schedules/ScheduleServiceTest.java
@@ -95,4 +95,17 @@ public class ScheduleServiceTest {
assertEquals(ServiceExitCode.OK, result_3.getExitCode());
assertNotEquals(((BasicTaskSchedule) result_3.getResult()).getScheduleDate(), oldDate);
}
+
+ @Test
+ @SqlGroup({
+ @Sql("classpath:taskgroupRepositoryTestEntries.sql"),
+ @Sql("classpath:taskRepositoryEntries.sql"),
+ @Sql("classpath:basicScheduleEntries.sql")
+ })
+ void deleteSchedule() {
+ for(long i=1; i<=2; i++) {
+ taskScheduleService.deleteSchedule(entityManager.find(BasicTaskSchedule.class, i));
+ assertThat(entityManager.find(BasicTaskSchedule.class, i)).isNull();
+ }
+ }
}
diff --git a/frontend/src/api/api/schedule.service.ts b/frontend/src/api/api/schedule.service.ts
index 66a5dc3..80e9dbf 100644
--- a/frontend/src/api/api/schedule.service.ts
+++ b/frontend/src/api/api/schedule.service.ts
@@ -316,6 +316,65 @@ export class ScheduleService {
);
}
+ /**
+ * deletes schedule
+ * deletes a schedule
+ * @param scheduleID internal id of schedule
+ * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
+ * @param reportProgress flag to report request and response progress.
+ */
+ public schedulesScheduleIDDelete(scheduleID: number, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable;
+ public schedulesScheduleIDDelete(scheduleID: number, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable>;
+ public schedulesScheduleIDDelete(scheduleID: number, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable>;
+ public schedulesScheduleIDDelete(scheduleID: number, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable {
+ if (scheduleID === null || scheduleID === undefined) {
+ throw new Error('Required parameter scheduleID was null or undefined when calling schedulesScheduleIDDelete.');
+ }
+
+ let localVarHeaders = this.defaultHeaders;
+
+ let localVarCredential: string | undefined;
+ // authentication (API_TOKEN) required
+ localVarCredential = this.configuration.lookupCredential('API_TOKEN');
+ if (localVarCredential) {
+ localVarHeaders = localVarHeaders.set('Authorization', 'Bearer ' + localVarCredential);
+ }
+
+ let localVarHttpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept;
+ if (localVarHttpHeaderAcceptSelected === undefined) {
+ // to determine the Accept header
+ const httpHeaderAccepts: string[] = [
+ 'application/json'
+ ];
+ localVarHttpHeaderAcceptSelected = this.configuration.selectHeaderAccept(httpHeaderAccepts);
+ }
+ if (localVarHttpHeaderAcceptSelected !== undefined) {
+ localVarHeaders = localVarHeaders.set('Accept', localVarHttpHeaderAcceptSelected);
+ }
+
+ let localVarHttpContext: HttpContext | undefined = options && options.context;
+ if (localVarHttpContext === undefined) {
+ localVarHttpContext = new HttpContext();
+ }
+
+
+ let responseType_: 'text' | 'json' = 'json';
+ if(localVarHttpHeaderAcceptSelected && localVarHttpHeaderAcceptSelected.startsWith('text')) {
+ responseType_ = 'text';
+ }
+
+ return this.httpClient.delete(`${this.configuration.basePath}/schedules/${encodeURIComponent(String(scheduleID))}`,
+ {
+ context: localVarHttpContext,
+ responseType: responseType_,
+ withCredentials: this.configuration.withCredentials,
+ headers: localVarHeaders,
+ observe: observe,
+ reportProgress: reportProgress
+ }
+ );
+ }
+
/**
* reschedules task
* reschedules a task
@@ -386,69 +445,6 @@ export class ScheduleService {
);
}
- /**
- * deletes schedule
- * deletes a schedule
- * @param scheduleID internal id of schedule
- * @param scheduleType internal id of task
- * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
- * @param reportProgress flag to report request and response progress.
- */
- public schedulesScheduleIDScheduleTypeDelete(scheduleID: number, scheduleType: 'BASIC' | 'MODERATE' | 'ADVANCED', observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable;
- public schedulesScheduleIDScheduleTypeDelete(scheduleID: number, scheduleType: 'BASIC' | 'MODERATE' | 'ADVANCED', observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable>;
- public schedulesScheduleIDScheduleTypeDelete(scheduleID: number, scheduleType: 'BASIC' | 'MODERATE' | 'ADVANCED', observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable>;
- public schedulesScheduleIDScheduleTypeDelete(scheduleID: number, scheduleType: 'BASIC' | 'MODERATE' | 'ADVANCED', observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable {
- if (scheduleID === null || scheduleID === undefined) {
- throw new Error('Required parameter scheduleID was null or undefined when calling schedulesScheduleIDScheduleTypeDelete.');
- }
- if (scheduleType === null || scheduleType === undefined) {
- throw new Error('Required parameter scheduleType was null or undefined when calling schedulesScheduleIDScheduleTypeDelete.');
- }
-
- let localVarHeaders = this.defaultHeaders;
-
- let localVarCredential: string | undefined;
- // authentication (API_TOKEN) required
- localVarCredential = this.configuration.lookupCredential('API_TOKEN');
- if (localVarCredential) {
- localVarHeaders = localVarHeaders.set('Authorization', 'Bearer ' + localVarCredential);
- }
-
- let localVarHttpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept;
- if (localVarHttpHeaderAcceptSelected === undefined) {
- // to determine the Accept header
- const httpHeaderAccepts: string[] = [
- 'application/json'
- ];
- localVarHttpHeaderAcceptSelected = this.configuration.selectHeaderAccept(httpHeaderAccepts);
- }
- if (localVarHttpHeaderAcceptSelected !== undefined) {
- localVarHeaders = localVarHeaders.set('Accept', localVarHttpHeaderAcceptSelected);
- }
-
- let localVarHttpContext: HttpContext | undefined = options && options.context;
- if (localVarHttpContext === undefined) {
- localVarHttpContext = new HttpContext();
- }
-
-
- let responseType_: 'text' | 'json' = 'json';
- if(localVarHttpHeaderAcceptSelected && localVarHttpHeaderAcceptSelected.startsWith('text')) {
- responseType_ = 'text';
- }
-
- return this.httpClient.delete(`${this.configuration.basePath}/schedules/${encodeURIComponent(String(scheduleID))}/${encodeURIComponent(String(scheduleType))}`,
- {
- context: localVarHttpContext,
- responseType: responseType_,
- withCredentials: this.configuration.withCredentials,
- headers: localVarHeaders,
- observe: observe,
- reportProgress: reportProgress
- }
- );
- }
-
/**
* @param scheduleID internal id of schedule
* @param finish internal id of schedule
diff --git a/frontend/src/app/schedules/schedule-dashboard/schedule-dashboard.component.ts b/frontend/src/app/schedules/schedule-dashboard/schedule-dashboard.component.ts
index 6ce456a..67583f9 100644
--- a/frontend/src/app/schedules/schedule-dashboard/schedule-dashboard.component.ts
+++ b/frontend/src/app/schedules/schedule-dashboard/schedule-dashboard.component.ts
@@ -38,7 +38,7 @@ export class ScheduleDashboardComponent implements OnInit{
}
deleteSchedule(deletedSchedule: ScheduleInfo) {
- this.scheduleService.schedulesScheduleIDScheduleTypeDelete(deletedSchedule.scheduleID, 'BASIC').subscribe({
+ this.scheduleService.schedulesScheduleIDDelete(deletedSchedule.scheduleID).subscribe({
next: resp => {
this.schedules = this.schedules.filter(schedule => schedule.scheduleID !== deletedSchedule.scheduleID);
},
diff --git a/openapi.yaml b/openapi.yaml
index f481fad..4b240f0 100644
--- a/openapi.yaml
+++ b/openapi.yaml
@@ -1394,7 +1394,6 @@ paths:
schema:
type: object
$ref: "#/components/schemas/SimpleStatusResponse"
- /schedules/{scheduleID}/{scheduleType}:
delete:
security:
- API_TOKEN: []
@@ -1410,16 +1409,6 @@ paths:
schema:
type: number
example: 1
- - name: scheduleType
- in: path
- description: internal id of task
- required: true
- schema:
- type: string
- enum:
- - BASIC
- - MODERATE
- - ADVANCED
responses:
200:
description: operation successfull