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

merge #23

Closed
wants to merge 63 commits into from
Closed
Changes from 2 commits
Commits
Show all changes
63 commits
Select commit Hold shift + click to select a range
576805d
temp
PierpaoloSpadafora Dec 3, 2024
e57598e
[RSJ-80] Export job
Marco-Maker Dec 4, 2024
ee58150
[RSJ-80] Machine types export
Marco-Maker Dec 4, 2024
e17ab21
[RSJ-80] Machine export
Marco-Maker Dec 4, 2024
24f87aa
Merge pull request #19 from PierpaoloSpadafora/RSJ-80
Marco-Maker Dec 4, 2024
c192041
[RSJ-84] Sto provando ad usare OptaPlanner, ma sembra ignorare alcuni…
PierpaoloSpadafora Dec 3, 2024
95ceed7
mio dio pare funzionare ora piango
PierpaoloSpadafora Dec 5, 2024
b531f63
PARE FUNZIONARE TUTTO YAY - ditemi se trovate problemi con lo scheduling
PierpaoloSpadafora Dec 5, 2024
f63d0c0
Merge branch 'dev' of https://github.com/PierpaoloSpadafora/sti-jobs …
PierpaoloSpadafora Dec 6, 2024
d405e0b
avevo dimenticato i test :D
PierpaoloSpadafora Dec 6, 2024
0fcea2e
Merge branch 'RSJ-84' into dev
PierpaoloSpadafora Dec 6, 2024
8eb3db1
temp
PierpaoloSpadafora Dec 6, 2024
cceba0b
RSJ-75 finito, stato dei job aggiornato in base a ora corrente
ila13-code Dec 6, 2024
98aeb39
temp
PierpaoloSpadafora Dec 6, 2024
9ad4422
fix
PierpaoloSpadafora Dec 6, 2024
08631e0
Merge branch 'RSJ-84' into dev
PierpaoloSpadafora Dec 6, 2024
1fbf91c
test
ila13-code Dec 6, 2024
b10a746
Update ci.yml
ila13-code Dec 6, 2024
a0b6295
Sistemati file Json e fix
PierpaoloSpadafora Dec 6, 2024
346658f
Merge remote-tracking branch 'origin/RSJ-84' into dev
PierpaoloSpadafora Dec 6, 2024
b5ae173
Merge remote-tracking branch 'origin/RSJ-75' into dev
PierpaoloSpadafora Dec 6, 2024
7930bfc
solito fix dei test
PierpaoloSpadafora Dec 6, 2024
3ed9f75
[RSJ-78] aggiunto export degli schedules
Francesco-Campagna Dec 6, 2024
8a0bc80
fix
PierpaoloSpadafora Dec 6, 2024
1ccd41c
fix
PierpaoloSpadafora Dec 6, 2024
8d31ac4
Merge remote-tracking branch 'origin/RSJ-78' into dev
PierpaoloSpadafora Dec 6, 2024
4668a2f
Aggiustato mapping di typeId
Marco-Maker Dec 10, 2024
61ea673
[RSJ-79] Aggiunto grafico lineare per machine specifiche
Marco-Maker Dec 10, 2024
2d3fa55
[RSJ-57] Aggiunta Dark Mode + Modifiche UI
fefe202 Dec 10, 2024
f085a51
fix
fefe202 Dec 10, 2024
d2575d7
[RSJ-81] Aggiunta Dark Mode + Modifiche UI
fefe202 Dec 10, 2024
82640a7
fix
fefe202 Dec 10, 2024
b6a9ed6
Merge remote-tracking branch 'origin/dev' into dev
fefe202 Dec 10, 2024
da6bfaf
Revert "fix"
fefe202 Dec 10, 2024
08ce663
fix UI
fefe202 Dec 10, 2024
8d9560f
aggiunti test allo Scheduler (alcune cose da fixare)
fefe202 Dec 10, 2024
7755a6e
Merge branch 'RSJ-Fix-To-Check' into dev
PierpaoloSpadafora Dec 11, 2024
dc53f8f
modificato metodo download scheduling
Francesco-Campagna Dec 11, 2024
63605f0
[RSJ-79] Aggiunto combo box per tipo schedule e modifca dei nomi
Marco-Maker Dec 11, 2024
ff187fe
Update graphs.component.ts
Marco-Maker Dec 11, 2024
a7981b4
Merge pull request #21 from PierpaoloSpadafora/RSJ-76
Francesco-Campagna Dec 11, 2024
a2d5e08
[RSJ-76] aggiunto import degli scheduling esterni in json
Francesco-Campagna Dec 11, 2024
0db7ce0
OptaPlanner da le bizze, impossibile capire come funziona senza dare …
PierpaoloSpadafora Dec 11, 2024
e0fe3b3
OptaPlanner da le bizze, impossibile capire come funziona senza dare …
PierpaoloSpadafora Dec 11, 2024
65af977
NON CAPISCO, PERCHE' STO SCHEDULER FUNZIONA A CAZZO?
PierpaoloSpadafora Dec 11, 2024
c931f82
spero che un giorno così non ritorni mai più, tra poco optaplanner lo…
PierpaoloSpadafora Dec 11, 2024
71833a9
popipopi po popi po
PierpaoloSpadafora Dec 11, 2024
cb25e3a
non ho pushato il merge, sorry
PierpaoloSpadafora Dec 11, 2024
553d67a
modificata UI così Pierpalo non si lamenta
fefe202 Dec 11, 2024
651ae95
merge
PierpaoloSpadafora Dec 11, 2024
f6159f3
fix
PierpaoloSpadafora Dec 12, 2024
ca8f11b
fix
PierpaoloSpadafora Dec 12, 2024
c8e015f
aggiunto scheduler First Come First Served
fefe202 Dec 14, 2024
d40a32d
aggiunto scheduler Round Robin
fefe202 Dec 15, 2024
6ed64bb
aggiunti test
fefe202 Dec 15, 2024
e76b8a2
fix
fefe202 Dec 15, 2024
2362bb2
fix UI
fefe202 Dec 15, 2024
30abfac
fix UI
fefe202 Dec 15, 2024
6bf0da9
fix
PierpaoloSpadafora Dec 16, 2024
3d68f7b
fix
PierpaoloSpadafora Dec 16, 2024
1569033
fix (ho voglia di pasta con i tonghi)
fefe202 Dec 16, 2024
0752195
test
ila13-code Dec 16, 2024
bbaa2a1
Update ci.yml
ila13-code Dec 16, 2024
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
Original file line number Diff line number Diff line change
@@ -6,21 +6,15 @@
import org.springframework.http.*;
import org.springframework.web.bind.annotation.*;
import unical.demacs.rdm.config.ModelMapperExtended;
import unical.demacs.rdm.persistence.dto.JobDTO;
import unical.demacs.rdm.persistence.dto.MachineDTO;
import unical.demacs.rdm.persistence.dto.MachineTypeDTO;
import unical.demacs.rdm.persistence.dto.ScheduleWithMachineDTO;
import unical.demacs.rdm.persistence.dto.*;
import unical.demacs.rdm.persistence.entities.Job;
import unical.demacs.rdm.persistence.entities.Machine;
import unical.demacs.rdm.persistence.entities.MachineType;
import unical.demacs.rdm.persistence.service.interfaces.IJobService;
import unical.demacs.rdm.persistence.service.interfaces.IJsonService;
import unical.demacs.rdm.persistence.service.interfaces.IMachineService;
import unical.demacs.rdm.persistence.service.interfaces.IMachineTypeService;
import unical.demacs.rdm.persistence.entities.Schedule;
import unical.demacs.rdm.persistence.service.interfaces.*;

import java.util.List;
import java.util.Map;
import java.util.Optional;

@RestController
@RequestMapping(value = "/api/v1/json", produces = "application/json")
@@ -33,6 +27,7 @@ public class JsonController {
private final IMachineService machineService;
private final IMachineTypeService machineTypeService;
private final IJsonService jsonService;
private final IScheduleService scheduleService;
private final ModelMapperExtended modelMapperExtended;

@Operation(summary = "Import Job data from JSON", description = "Import Job data into the system from JSON content.",
@@ -144,15 +139,9 @@ public ResponseEntity<List<ScheduleWithMachineDTO>> exportJobScheduledRO() {
@Operation(summary = "Download all Schedules as JSON", description = "Download all Schedules as a JSON file.",
tags = {"json-controller"})
@GetMapping(value = "/download-schedules", produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<byte[]> downloadSchedules() {
try {
byte[] jsonContent = jsonService.exportSchedulesToJson();
HttpHeaders headers = new HttpHeaders();
headers.setContentDisposition(ContentDisposition.builder("attachment").filename("schedules.json").build());
headers.setContentType(MediaType.APPLICATION_JSON);
return new ResponseEntity<>(jsonContent, headers, HttpStatus.OK);
} catch (Exception e) {
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("Error exporting schedules: ".getBytes());
}
public ResponseEntity<List<ScheduleDTO>> downloadSchedules() {
List<Schedule> schedules = scheduleService.getAllSchedules();
return ResponseEntity.ok(modelMapperExtended.mapList(schedules, ScheduleDTO.class));
}

}
Original file line number Diff line number Diff line change
@@ -4,14 +4,12 @@
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;
import unical.demacs.rdm.persistence.dto.*;
import unical.demacs.rdm.persistence.entities.Schedule;
import unical.demacs.rdm.persistence.repository.ScheduleRepository;
import unical.demacs.rdm.persistence.service.interfaces.IJsonService;

import java.io.File;
import java.io.IOException;
import java.util.List;
import java.util.stream.Collectors;

@Service
@AllArgsConstructor
@@ -30,30 +28,4 @@ public List<ScheduleWithMachineDTO> readScheduleFile(String fileName) {
}
}

public List<ScheduleDTO> getAllSchedules() {
List<Schedule> schedules = scheduleRepository.findAll();
return schedules.stream()
.map(schedule -> new ScheduleDTO(
schedule.getId(),
schedule.getJob().getId(),
schedule.getMachineType().getId(),
schedule.getDueDate(),
schedule.getStartTime(),
schedule.getDuration(),
schedule.getStatus(),
schedule.getMachine() != null ? schedule.getMachine().getId() : null,
schedule.getMachine() != null ? schedule.getMachine().getName() : null
))
.collect(Collectors.toList());
}

public byte[] exportSchedulesToJson() {
try {
List<ScheduleDTO> schedules = getAllSchedules();
return objectMapper.writeValueAsBytes(schedules);
} catch (IOException e) {
throw new RuntimeException("Errore durante l'esportazione degli schedule in JSON", e);
}
}

}
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
package unical.demacs.rdm.persistence.service.interfaces;

import unical.demacs.rdm.persistence.dto.ScheduleDTO;

import unical.demacs.rdm.persistence.dto.ScheduleWithMachineDTO;

import java.util.List;

public interface IJsonService {
public List<ScheduleWithMachineDTO> readScheduleFile(String fileName);
public List<ScheduleDTO> getAllSchedules();
public byte[] exportSchedulesToJson();
}
1 change: 0 additions & 1 deletion Frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 13 additions & 4 deletions Frontend/src/app/components/schedule/schedule.component.ts
Original file line number Diff line number Diff line change
@@ -431,13 +431,22 @@ export class ScheduleComponent implements OnInit {
protected readonly Number = Number;

downloadSchedules() {
this.jsonService.downloadSchedules().subscribe(response => {
const blob = new Blob([response], { type: 'application/json' });
this.jsonService.downloadSchedules('body').subscribe(response => {
const jsonResponse = JSON.stringify(response);
const blob = new Blob([jsonResponse], { type: 'application/json' });
const link = document.createElement('a');
link.href = URL.createObjectURL(blob);
link.download = 'schedules.json';
link.click();
});
}

this.jsonService.exportMachine('body').subscribe(machineResponse => {
const machineJsonResponse = JSON.stringify(machineResponse);
const machineBlob = new Blob([machineJsonResponse], { type: 'application/json' });
const machineLink = document.createElement('a');
machineLink.href = URL.createObjectURL(machineBlob);
machineLink.download = 'machines.json';
machineLink.click();
});
}

}
111 changes: 88 additions & 23 deletions Frontend/src/app/generated-api/api/jsonController.service.ts
Original file line number Diff line number Diff line change
@@ -20,6 +20,7 @@ import { Observable } from 'rxjs';
import { JobDTO } from '../model/jobDTO';
import { MachineDTO } from '../model/machineDTO';
import { MachineTypeDTO } from '../model/machineTypeDTO';
import { ScheduleDTO } from '../model/scheduleDTO';
import { ScheduleWithMachineDTO } from '../model/scheduleWithMachineDTO';

import { BASE_PATH, COLLECTION_FORMATS } from '../variables';
@@ -59,15 +60,15 @@ export class JsonControllerService {


/**
* Export Job data to JSON
* Export all Job data to JSON.
* Download all Schedules as JSON
* Download all Schedules as a JSON file.
* @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 exportJob(observe?: 'body', reportProgress?: boolean): Observable<Array<JobDTO>>;
public exportJob(observe?: 'response', reportProgress?: boolean): Observable<HttpResponse<Array<JobDTO>>>;
public exportJob(observe?: 'events', reportProgress?: boolean): Observable<HttpEvent<Array<JobDTO>>>;
public exportJob(observe: any = 'body', reportProgress: boolean = false ): Observable<any> {
public downloadSchedules(observe?: 'body', reportProgress?: boolean): Observable<Array<ScheduleDTO>>;
public downloadSchedules(observe?: 'response', reportProgress?: boolean): Observable<HttpResponse<Array<ScheduleDTO>>>;
public downloadSchedules(observe?: 'events', reportProgress?: boolean): Observable<HttpEvent<Array<ScheduleDTO>>>;
public downloadSchedules(observe: any = 'body', reportProgress: boolean = false ): Observable<any> {

let headers = this.defaultHeaders;

@@ -84,7 +85,7 @@ export class JsonControllerService {
const consumes: string[] = [
];

return this.httpClient.request<Array<JobDTO>>('get',`${this.basePath}/api/v1/json/exportJob`,
return this.httpClient.request<Array<ScheduleDTO>>('get',`${this.basePath}/api/v1/json/download-schedules`,
{
withCredentials: this.configuration.withCredentials,
headers: headers,
@@ -95,18 +96,19 @@ export class JsonControllerService {
}

/**
* Download schedules as a JSON file
* This method triggers the download of the schedules JSON file.
* @param observe set whether or not to return the data Observable as the body, response or events.
* Export Job data to JSON
* Export all Job data to JSON.
* @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 downloadSchedules(observe?: 'body', reportProgress?: boolean): Observable<any>;
public downloadSchedules(observe?: 'response', reportProgress?: boolean): Observable<HttpResponse<any>>;
public downloadSchedules(observe?: 'events', reportProgress?: boolean): Observable<HttpEvent<any>>;
public downloadSchedules(observe: any = 'body', reportProgress: boolean = false ): Observable<any> {
public exportJob(observe?: 'body', reportProgress?: boolean): Observable<Array<JobDTO>>;
public exportJob(observe?: 'response', reportProgress?: boolean): Observable<HttpResponse<Array<JobDTO>>>;
public exportJob(observe?: 'events', reportProgress?: boolean): Observable<HttpEvent<Array<JobDTO>>>;
public exportJob(observe: any = 'body', reportProgress: boolean = false ): Observable<any> {

let headers = this.defaultHeaders;

// to determine the Accept header
let httpHeaderAccepts: string[] = [
'application/json'
];
@@ -115,13 +117,18 @@ export class JsonControllerService {
headers = headers.set('Accept', httpHeaderAcceptSelected);
}

return this.httpClient.request('get', `${this.basePath}/api/v1/json/download-schedules`, {
withCredentials: this.configuration.withCredentials,
headers: headers,
observe: observe,
responseType: 'blob',
reportProgress: reportProgress
});
// to determine the Content-Type header
const consumes: string[] = [
];

return this.httpClient.request<Array<JobDTO>>('get',`${this.basePath}/api/v1/json/exportJob`,
{
withCredentials: this.configuration.withCredentials,
headers: headers,
observe: observe,
reportProgress: reportProgress
}
);
}

/**
@@ -233,8 +240,8 @@ export class JsonControllerService {
}

/**
* Export Job data to JSON
* Export all Job data to JSON.
* Export RO scheduled jobs
* Export all RO scheduled jobs to JSON.
* @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.
*/
@@ -492,4 +499,62 @@ export class JsonControllerService {
);
}

/**
* Import Schedules from JSON
* Upload and import Schedules from a JSON file.
* @param file
* @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 importSchedulesForm(file?: Blob, observe?: 'body', reportProgress?: boolean): Observable<{ [key: string]: string; }>;
public importSchedulesForm(file?: Blob, observe?: 'response', reportProgress?: boolean): Observable<HttpResponse<{ [key: string]: string; }>>;
public importSchedulesForm(file?: Blob, observe?: 'events', reportProgress?: boolean): Observable<HttpEvent<{ [key: string]: string; }>>;
public importSchedulesForm(file?: Blob, observe: any = 'body', reportProgress: boolean = false ): Observable<any> {


let headers = this.defaultHeaders;

// to determine the Accept header
let httpHeaderAccepts: string[] = [
'application/json'
];
const httpHeaderAcceptSelected: string | undefined = this.configuration.selectHeaderAccept(httpHeaderAccepts);
if (httpHeaderAcceptSelected != undefined) {
headers = headers.set('Accept', httpHeaderAcceptSelected);
}

// to determine the Content-Type header
const consumes: string[] = [
'multipart/form-data'
];

const canConsumeForm = this.canConsumeForm(consumes);

let formParams: { append(param: string, value: any): void; };
let useForm = false;
let convertFormParamsToString = false;
// use FormData to transmit files using content-type "multipart/form-data"
// see https://stackoverflow.com/questions/4007969/application-x-www-form-urlencoded-or-multipart-form-data
useForm = canConsumeForm;
if (useForm) {
formParams = new FormData();
} else {
formParams = new HttpParams({encoder: new CustomHttpUrlEncodingCodec()});
}

if (file !== undefined) {
formParams = formParams.append('file', <any>file) as any || formParams;
}

return this.httpClient.request<{ [key: string]: string; }>('post',`${this.basePath}/api/v1/json/upload-schedules`,
{
body: convertFormParamsToString ? formParams.toString() : formParams,
withCredentials: this.configuration.withCredentials,
headers: headers,
observe: observe,
reportProgress: reportProgress
}
);
}

}
15 changes: 15 additions & 0 deletions Frontend/src/app/generated-api/model/jsonUploadschedulesBody.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/**
* OpenAPI definition
* No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
*
* OpenAPI spec version: v0
*
*
* NOTE: This class is auto generated by the swagger code generator program.
* https://github.com/swagger-api/swagger-codegen.git
* Do not edit the class manually.
*/

export interface JsonUploadschedulesBody {
file: Blob;
}
1 change: 1 addition & 0 deletions Frontend/src/app/generated-api/model/models.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
export * from './job';
export * from './jobDTO';
export * from './jsonUploadschedulesBody';
export * from './machine';
export * from './machineDTO';
export * from './machineType';