docs: More comments

pull/1/head
Lunix-420 2024-11-11 20:33:56 +01:00
parent 181fa0b24e
commit df27bfd5b0
23 changed files with 817 additions and 8 deletions

View File

@ -8,100 +8,230 @@ import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* Represents an employee.
*
* An employee is a person who works for the company. Each employee has a unique
* employee number, a first name, a last name, a form of address, a start time,
* an end time, a list of secondary skills, and a list of projects.
*/
@Entity
@Data
public class Employee {
/**
* The unique identifier of the employee.
*
* This is the primary key of the employee entity.
*/
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long eid;
/**
* The employee number of the employee.
*
* This is a number from the Inter system.
*/
private Integer employeeNr;
/**
* The first name of the employee.
*/
@Column(length = 100)
private String firstName;
/**
* The last name of the employee.
*/
@Column(length = 100)
private String lastName;
/**
* The form of address of the employee.
*
* This is a reference to the form of address entity.
*/
@ManyToOne
@JoinColumn(name = "form_of_address_fid")
private FormOfAddress formOfAddress;
/**
* The start time of the employee's daylie business.
*/
private LocalTime dStart;
/**
* The end time of the employee's daylie business.
*/
private LocalTime dEnd;
/**
* The secondary skills of the employee.
*
* This is a list of secondary skill entities.
*/
@OneToMany(mappedBy = "employee", cascade = CascadeType.ALL, orphanRemoval = true)
@JsonManagedReference
private List<EmployeeSecondarySkill> secondarySkills;
/**
* The projects of the employee.
*
* This is a list of project entities.
*/
@ManyToMany
@JoinTable(name = "employee_project", joinColumns = @JoinColumn(name = "employee_eid"), inverseJoinColumns = @JoinColumn(name = "project_pid"))
private List<Project> projects;
/**
* Sets the unique identifier of the employee.
*
* @param eid The unique identifier of the employee.
*/
public void setEid(Long eid) {
this.eid = eid;
}
/**
* Returns the unique identifier of the employee.
*
* @return The unique identifier of the employee.
*/
public Long getEid() {
return eid;
}
/**
* Sets the employee number of the employee.
*
* @param employeeNr The employee number of the employee.
*/
public void setEmployeeNr(Integer employeeNr) {
this.employeeNr = employeeNr;
}
/**
* Returns the employee number of the employee.
*
* @return The employee number of the employee.
*/
public Integer getEmployeeNr() {
return employeeNr;
}
/**
* Sets the first name of the employee.
*
* @param firstName The first name of the employee.
*/
public void setFirstName(String firstName) {
this.firstName = firstName;
}
/**
* Returns the first name of the employee.
*
* @return The first name of the employee.
*/
public String getFirstName() {
return firstName;
}
/**
* Sets the last name of the employee.
*
* @param lastName The last name of the employee.
*/
public void setLastName(String lastName) {
this.lastName = lastName;
}
/**
* Returns the last name of the employee.
*
* @return The last name of the employee.
*/
public String getLastName() {
return lastName;
}
/**
* Sets the form of address of the employee.
*
* @param formOfAddress The form of address of the employee.
*/
public void setFormOfAddress(FormOfAddress formOfAddress) {
this.formOfAddress = formOfAddress;
}
/**
* Returns the form of address of the employee.
*
* @return The form of address of the employee.
*/
public FormOfAddress getFormOfAddress() {
return formOfAddress;
}
/**
* Sets the start time of the employee's daylie business.
*
* @param dStart The start time of the employee's daylie business.
*/
public void setDStart(LocalTime dStart) {
this.dStart = dStart;
}
/**
* Returns the start time of the employee's daylie business.
*
* @return The start time of the employee's daylie business.
*/
public LocalTime getDStart() {
return dStart;
}
/**
* Sets the end time of the employee's daylie business.
*
* @param dEnd The end time of the employee's daylie business.
*/
public void setDEnd(LocalTime dEnd) {
this.dEnd = dEnd;
}
/**
* Returns the end time of the employee's daylie business.
*
* @return The end time of the employee's daylie business.
*/
public LocalTime getDEnd() {
return dEnd;
}
/**
* Sets the secondary skills of the employee.
*
* @param secondarySkills The secondary skills of the employee.
*/
public void setSecondarySkills(List<EmployeeSecondarySkill> secondarySkills) {
this.secondarySkills = secondarySkills;
}
/**
* Returns the secondary skills of the employee.
*
* @return The secondary skills of the employee.
*/
public List<EmployeeSecondarySkill> getSecondarySkills() {
return secondarySkills;
}
/**
* Sets the projects of the employee.
*
* @param projects The projects of the employee.
*/
public Map<SecondarySkill, Integer> getSecondarySkillLevels() {
return secondarySkills.stream()
.collect(Collectors.toMap(EmployeeSecondarySkill::getSecondarySkill, EmployeeSecondarySkill::getLevel));

View File

@ -4,53 +4,120 @@ import jakarta.persistence.*;
import lombok.Data;
import com.fasterxml.jackson.annotation.JsonBackReference;
/**
* Represents an employee's secondary skill.
*
* An employee's secondary skill is a specific skill that the employee has in
* comparison to the primary skills, which is just the category of the skill.
*/
@Entity
@Data
public class EmployeeSecondarySkill {
/**
* The unique identifier of the employee's secondary skill.
*
* This is the primary key of the employee's secondary skill entity.
*/
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long essid;
/**
* The employee that has the secondary skill.
*
* This is a reference to the employee entity.
*/
@ManyToOne
@JoinColumn(name = "employee_eid", nullable = false)
@JsonBackReference
private Employee employee;
/**
* The secondary skill that the employee has.
*
* This is a reference to the secondary skill entity.
*/
@ManyToOne
@JoinColumn(name = "secondary_skill_id", nullable = false)
private SecondarySkill secondarySkill;
/**
* The level of the secondary skill that the employee has.
*
* This is a number from 1 to 5, where 1 is the lowest and 5 is the highest
* level.
*/
@Column(nullable = false)
private Integer level;
/**
* Sets the unique identifier of the employee's secondary skill.
*
* @param essid The unique identifier of the employee's secondary skill.
*/
public void setEssid(Long essid) {
this.essid = essid;
}
/**
* Returns the unique identifier of the employee's secondary skill.
*
* @return The unique identifier of the employee's secondary skill.
*/
public Long getEssid() {
return essid;
}
/**
* Sets the employee that has the secondary skill.
*
* @param employee The employee that has the secondary skill.
*/
public void setEmployee(Employee employee) {
this.employee = employee;
}
/**
* Returns the employee that has the secondary skill.
*
* @return The employee that has the secondary skill.
*/
public Employee getEmployee() {
return employee;
}
/**
* Sets the secondary skill that the employee has.
*
* @param secondarySkill The secondary skill that the employee has.
*/
public void setSecondarySkill(SecondarySkill secondarySkill) {
this.secondarySkill = secondarySkill;
}
/**
* Returns the secondary skill that the employee has.
*
* @return The secondary skill that the employee has.
*/
public SecondarySkill getSecondarySkill() {
return secondarySkill;
}
/**
* Sets the level of the secondary skill that the employee has.
*
* @param level The level of the secondary skill that the employee has.
*/
public void setLevel(Integer level) {
this.level = level;
}
/**
* Returns the level of the secondary skill that the employee has.
*
* @return The level of the secondary skill that the employee has.
*/
public Integer getLevel() {
return level;
}

View File

@ -5,40 +5,91 @@ import java.util.List;
import jakarta.persistence.*;
import lombok.Data;
/**
* Represents a form of address.
*
* A form of address is a specific way to address a person, like "Herr", "Frau",
* "Dr.", "Prof.", etc.
*/
@Entity
@Data
public class FormOfAddress {
/**
* The unique identifier of the form of address.
*
* This is the primary key of the form of address entity.
*/
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long fid;
/**
* The description of the form of address.
*
* This is the actual form of address, like "Herr", "Frau", "Dr.", "Prof.",
* etc.
*/
@Column(nullable = false, length = 50)
private String description;
/**
* The employees that have this form of address.
*
* This is a list of references to the employee entity.
*/
@OneToMany(mappedBy = "formOfAddress")
private List<Employee> employees;
/**
* Sets the unique identifier of the form of address.
*
* @param fid The unique identifier of the form of address.
*/
public void setFid(Long fid) {
this.fid = fid;
}
/**
* Gets the unique identifier of the form of address.
*
* @return The unique identifier of the form of address.
*/
public Long getFid() {
return fid;
}
/**
* Sets the description of the form of address.
*
* @param description The description of the form of address.
*/
public void setDescription(String description) {
this.description = description;
}
/**
* Gets the description of the form of address.
*
* @return The description of the form of address.
*/
public String getDescription() {
return description;
}
/**
* Sets the employees that have this form of address.
*
* @param employees The employees that have this form of address.
*/
public void setEmployees(List<Employee> employees) {
this.employees = employees;
}
/**
* Gets the employees that have this form of address.
*
* @return The employees that have this form of address.
*/
public List<Employee> getEmployees() {
return employees;
}

View File

@ -5,40 +5,92 @@ import com.fasterxml.jackson.annotation.JsonManagedReference;
import lombok.Data;
import java.util.List;
/**
* Represents a primary skill.
*
* A primary skill is a category of skills, like "Programming", "Design",
* "Testing",
* etc. Each primary skill has a description and a list of secondary skills.
*/
@Entity
@Data
public class PrimarySkill {
/**
* The unique identifier of the primary skill.
*
* This is the primary key of the primary skill entity.
*/
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long psid;
/**
* The description of the primary skill.
*
* This is the name of the primary skill, like "Programming", "Design",
*/
@Column(nullable = false, length = 255)
private String description;
/**
* The secondary skills that belong to the primary skill.
*
* This is a list of references to the secondary skill entity.
*/
@OneToMany(mappedBy = "primarySkill", cascade = CascadeType.ALL, orphanRemoval = true)
@JsonManagedReference
private List<SecondarySkill> secondarySkills;
/**
* Sets the unique identifier of the primary skill.
*
* @param psid The unique identifier of the primary skill.
*/
public void setPsid(Long psid) {
this.psid = psid;
}
/**
* Gets the unique identifier of the primary skill.
*
* @return The unique identifier of the primary skill.
*/
public Long getPsid() {
return psid;
}
/**
* Sets the description of the primary skill.
*
* @param description The description of the primary skill.
*/
public void setDescription(String description) {
this.description = description;
}
/**
* Gets the description of the primary skill.
*
* @return The description of the primary skill.
*/
public String getDescription() {
return description;
}
/**
* Sets the secondary skills that belong to the primary skill.
*
* @param secondarySkills The secondary skills that belong to the primary skill.
*/
public void setSecondarySkills(List<SecondarySkill> secondarySkills) {
this.secondarySkills = secondarySkills;
}
/**
* Gets the secondary skills that belong to the primary skill.
*
* @return The secondary skills that belong to the primary skill.
*/
public List<SecondarySkill> getSecondarySkills() {
return secondarySkills;
}

View File

@ -5,80 +5,184 @@ import lombok.Data;
import java.time.LocalDate;
import java.util.List;
/**
* Represents a project.
*
* A project is a task that has to be done by a group of employees. Each project
* has a unique project number, a name, a start date, an end date, a workload, a
* description, and a list of employees.
*/
@Entity
@Data
public class Project {
/**
* The unique identifier of the project.
*
* This is the primary key of the project entity.
*/
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long pid;
/**
* The name of the project.
*/
@Column(nullable = false, length = 255)
private String name;
/**
* The employees that work on the project.
*
* This is a list of references to the employee entity.
*/
@ManyToMany(mappedBy = "projects")
private List<Employee> employees;
/**
* The start date of the project.
*/
private LocalDate startDate;
/**
* The end date of the project.
*/
private LocalDate endDate;
/**
* The workload of the project.
*
* This is the number of hours that have to be worked on the project.
*/
private Integer workload;
/**
* The description of the project.
*/
@Column(columnDefinition = "TEXT")
private String description;
/**
* Sets the unique identifier of the project.
*
* @param pid The unique identifier of the project.
*/
public void setPid(Long pid) {
this.pid = pid;
}
/**
* Gets the unique identifier of the project.
*
* @return The unique identifier of the project.
*/
public Long getPid() {
return pid;
}
/**
* Sets the name of the project.
*
* @param name The name of the project.
*/
public void setName(String name) {
this.name = name;
}
/**
* Gets the name of the project.
*
* @return The name of the project.
*/
public String getName() {
return name;
}
/**
* Sets the employees that work on the project.
*
* @param employees The employees that work on the project.
*/
public void setEmployees(List<Employee> employees) {
this.employees = employees;
}
/**
* Gets the employees that work on the project.
*
* @return The employees that work on the project.
*/
public Iterable<Employee> getEmployees() {
return employees;
}
/**
* Sets the start date of the project.
*
* @param startDate The start date of the project.
*/
public void setStartDate(LocalDate startDate) {
this.startDate = startDate;
}
/**
* Gets the start date of the project.
*
* @return The start date of the project.
*/
public LocalDate getStartDate() {
return startDate;
}
/**
* Sets the end date of the project.
*
* @param endDate The end date of the project.
*/
public void setEndDate(LocalDate endDate) {
this.endDate = endDate;
}
/**
* Gets the end date of the project.
*
* @return The end date of the project.
*/
public LocalDate getEndDate() {
return endDate;
}
/**
* Sets the workload of the project.
*
* @param workload The workload of the project.
*/
public void setWorkload(Integer workload) {
this.workload = workload;
}
/**
* Gets the workload of the project.
*
* @return The workload of the project.
*/
public Integer getWorkload() {
return workload;
}
/**
* Sets the description of the project.
*
* @param description The description of the project.
*/
public void setDescription(String description) {
this.description = description;
}
/**
* Gets the description of the project.
*
* @return The description of the project.
*/
public String getDescription() {
return description;
}

View File

@ -6,53 +6,120 @@ import com.fasterxml.jackson.annotation.JsonManagedReference;
import lombok.Data;
import java.util.List;
/**
* Represents a secondary skill.
*
* A secondary skill is a specific skill that an employee has in comparison to
* the primary skills, which is just the category of the skill.
*/
@Entity
@Data
public class SecondarySkill {
/**
* The unique identifier of the secondary skill.
*
* This is the primary key of the secondary skill entity.
*/
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long ssid;
/**
* The description of the secondary skill.
*
* This is the name of the secondary skill, like "Java", "C++", "Python",
* etc.
*/
@Column(nullable = false, length = 255)
private String description;
/**
* The primary skill that the secondary skill belongs to.
*
* This is a reference to the primary skill entity.
*/
@ManyToOne
@JoinColumn(name = "psid", nullable = false)
@JsonBackReference
private PrimarySkill primarySkill;
/**
* The employees that have the secondary skill.
*
* This is a list of references to the employee's secondary skill entity.
*/
@OneToMany(mappedBy = "secondarySkill", cascade = CascadeType.ALL, orphanRemoval = true)
@JsonManagedReference
private List<EmployeeSecondarySkill> employeeSecondarySkills;
/**
* Sets the unique identifier of the secondary skill.
*
* @param ssid The unique identifier of the secondary skill.
*/
public void setSsid(Long ssid) {
this.ssid = ssid;
}
/**
* Gets the unique identifier of the secondary skill.
*
* @return The unique identifier of the secondary skill.
*/
public Long getSsid() {
return ssid;
}
/**
* Sets the description of the secondary skill.
*
* @param description The description of the secondary skill.
*/
public void setDescription(String description) {
this.description = description;
}
/**
* Gets the description of the secondary skill.
*
* @return The description of the secondary skill.
*/
public String getDescription() {
return description;
}
/**
* Sets the primary skill that the secondary skill belongs to.
*
* @param primarySkill The primary skill that the secondary skill belongs to.
*/
public void setPrimarySkill(PrimarySkill primarySkill) {
this.primarySkill = primarySkill;
}
/**
* Gets the primary skill that the secondary skill belongs to.
*
* @return The primary skill that the secondary skill belongs to.
*/
public PrimarySkill getPrimarySkill() {
return primarySkill;
}
/**
* Sets the employees that have the secondary skill.
*
* @param employeeSecondarySkills The employees that have the secondary skill.
*/
public void setEmployeeSecondarySkills(List<EmployeeSecondarySkill> employeeSecondarySkills) {
this.employeeSecondarySkills = employeeSecondarySkills;
}
/**
* Gets the employees that have the secondary skill.
*
* @return The employees that have the secondary skill.
*/
public List<EmployeeSecondarySkill> getEmployeeSecondarySkills() {
return employeeSecondarySkills;
}

View File

@ -3,5 +3,11 @@ package com.maradona.backend.repositories;
import org.springframework.data.repository.CrudRepository;
import com.maradona.backend.entities.Employee;
/**
* EmployeeRepository
*
* This interface is a repository for the Employee entity.
* It automatically generates the CRUD operations for the Employee entity.
*/
public interface EmployeeRepository extends CrudRepository<Employee, Long> {
}

View File

@ -3,5 +3,12 @@ package com.maradona.backend.repositories;
import org.springframework.data.repository.CrudRepository;
import com.maradona.backend.entities.EmployeeSecondarySkill;
/**
* EmployeeSecondarySkillRepository
*
* This interface is a repository for the EmployeeSecondarySkill entity.
* It automatically generates the CRUD operations for the EmployeeSecondarySkill
* entity.
*/
public interface EmployeeSecondarySkillRepository extends CrudRepository<EmployeeSecondarySkill, Long> {
}

View File

@ -3,5 +3,11 @@ package com.maradona.backend.repositories;
import org.springframework.data.repository.CrudRepository;
import com.maradona.backend.entities.FormOfAddress;
/**
* FormOfAddressRepository
*
* This interface is a repository for the FormOfAddress entity.
* It automatically generates the CRUD operations for the FormOfAddress entity.
*/
public interface FormOfAddressRepository extends CrudRepository<FormOfAddress, Long> {
}

View File

@ -3,5 +3,11 @@ package com.maradona.backend.repositories;
import org.springframework.data.repository.CrudRepository;
import com.maradona.backend.entities.PrimarySkill;
/**
* PrimarySkillRepository
*
* This interface is a repository for the PrimarySkill entity.
* It automatically generates the CRUD operations for the PrimarySkill entity.
*/
public interface PrimarySkillRepository extends CrudRepository<PrimarySkill, Long> {
}

View File

@ -3,5 +3,11 @@ package com.maradona.backend.repositories;
import org.springframework.data.repository.CrudRepository;
import com.maradona.backend.entities.Project;
/**
* ProjectRepository
*
* This interface is a repository for the Project entity.
* It automatically generates the CRUD operations for the Project entity.
*/
public interface ProjectRepository extends CrudRepository<Project, Long> {
}

View File

@ -3,5 +3,11 @@ package com.maradona.backend.repositories;
import org.springframework.data.repository.CrudRepository;
import com.maradona.backend.entities.SecondarySkill;
/**
* SecondarySkillRepository
*
* This interface is a repository for the SecondarySkill entity.
* It automatically generates the CRUD operations for the SecondarySkill entity.
*/
public interface SecondarySkillRepository extends CrudRepository<SecondarySkill, Long> {
}

View File

@ -9,21 +9,46 @@ import com.maradona.backend.services.details.EmployeeDetails;
import com.maradona.backend.services.details.SecondarySkillDetails;
import com.maradona.backend.dto.SkillPrototype;
/**
* EmployeeActions
*
* This class contains the business logic for the Employee entity.
*/
@Service
public class EmployeeActions {
/**
* The EmployeeRepository instance.
*/
@Autowired
private EmployeeRepository employeeRepository;
/**
* The EmployeeDetails instance.
*/
@Autowired
private EmployeeDetails employeeDetails;
/**
* The SecondarySkillDetails instance.
*/
@Autowired
private SecondarySkillDetails secondarySkillDetails;
public Employee saveEmployee(Employee employee) {
return employeeRepository.save(employee);
/**
* This method saves an Employee entity.
*
* @param employee The Employee entity to save.
*/
public void saveEmployee(Employee employee) {
employeeRepository.save(employee);
}
/**
* This method deletes an Employee entity.
*
* @param eid The Employee ID.
*/
public void deleteEmployee(Long eid) {
for (Employee employee : employeeRepository.findAll()) {
if (employee.getEid().equals(eid)) {
@ -33,6 +58,12 @@ public class EmployeeActions {
}
}
/**
* This method adds a secondary skill to an Employee entity.
*
* @param eid The Employee ID.
* @param skillPrototype The SkillPrototype instance.
*/
public void addSecondarySkillToEmployee(Long eid, SkillPrototype skillPrototype) {
var employee = employeeDetails.getEmployeeByEid(eid).orElseThrow(() -> new RuntimeException("Employee not found"));
var secondarySkill = secondarySkillDetails.getSecondarySkillBySsid(skillPrototype.getSsid())
@ -52,6 +83,13 @@ public class EmployeeActions {
saveEmployee(employee);
}
/**
* This method updates the level of a secondary skill of an Employee entity.
*
* @param eid The Employee ID.
* @param ssid The Secondary Skill ID.
* @param level The new level.
*/
public void updateSecondarySkillLevel(Long eid, Long ssid, Integer level) {
var employee = employeeDetails.getEmployeeByEid(eid).orElseThrow(() -> new RuntimeException("Employee not found"));
secondarySkillDetails.getSecondarySkillBySsid(
@ -68,6 +106,12 @@ public class EmployeeActions {
saveEmployee(employee);
}
/**
* This method deletes a secondary skill from an Employee entity.
*
* @param eid The Employee ID.
* @param ssid The Secondary Skill ID.
*/
public void deleteSecondarySkillFromEmployee(Long eid, Long ssid) {
var employee = employeeDetails.getEmployeeByEid(eid).orElseThrow(() -> new RuntimeException("Employee not found"));
secondarySkillDetails.getSecondarySkillBySsid(

View File

@ -6,19 +6,40 @@ import com.maradona.backend.entities.FormOfAddress;
import com.maradona.backend.repositories.FormOfAddressRepository;
import com.maradona.backend.services.details.FormOfAddressDetails;
/**
* FormOfAddressActions
*
* This class contains the business logic for the FormOfAddress entity.
*/
@Service
public class FormOfAddressActions {
/**
* The FormOfAddressRepository instance.
*/
@Autowired
private FormOfAddressRepository formOfAddressRepository;
/**
* The FormOfAddressDetails instance.
*/
@Autowired
private FormOfAddressDetails formOfAddressDetails;
/**
* This method saves a FormOfAddress entity.
*
* @param formOfAddress The FormOfAddress entity to save.
* @return The saved FormOfAddress entity.
*/
public FormOfAddress saveFormOfAddress(FormOfAddress formOfAddress) {
return formOfAddressRepository.save(formOfAddress);
}
/**
* This method deletes a FormOfAddress entity.
*
* @param fid The FormOfAddress ID.
*/
public void deleteFormOfAddress(Long fid) {
for (FormOfAddress formOfAddress : formOfAddressRepository.findAll()) {
if (formOfAddress.getFid().equals(fid)) {
@ -28,6 +49,12 @@ public class FormOfAddressActions {
}
}
/**
* This method updates the description of a FormOfAddress entity.
*
* @param fid The FormOfAddress ID.
* @param description The new description.
*/
public void updateFormOfAddress(Long fid, String description) {
var formOfAddress = formOfAddressDetails.getFormOfAddressByFid(fid)
.orElseThrow(() -> new RuntimeException("Form of Address not found"));

View File

@ -8,22 +8,47 @@ import com.maradona.backend.repositories.PrimarySkillRepository;
import com.maradona.backend.repositories.SecondarySkillRepository;
import com.maradona.backend.services.details.SecondarySkillDetails;
/**
* PrimarySkillActions
*
* This class contains the business logic for the PrimarySkill entity.
*/
@Service
public class PrimarySkillActions {
/**
* The PrimarySkillRepository instance.
*/
@Autowired
private PrimarySkillRepository primarySkillRepository;
/**
* The SecondarySkillDetails instance.
*/
@Autowired
private SecondarySkillDetails secondarySkillDetails;
/**
* The SecondarySkillRepository instance.
*/
@Autowired
private SecondarySkillRepository secondarySkillRepository;
/**
* This method saves a PrimarySkill entity.
*
* @param primarySkill The PrimarySkill entity to save.
* @return The saved PrimarySkill entity.
*/
public PrimarySkill savePrimarySkill(PrimarySkill primarySkill) {
return primarySkillRepository.save(primarySkill);
}
/**
* This method deletes a PrimarySkill entity.
*
* @param psid The PrimarySkill ID.
*/
public void deletePrimarySkill(Long psid) {
var primarySkills = primarySkillRepository.findAll();
var secondarySkills = secondarySkillDetails.getAllSecondarySkills();

View File

@ -11,22 +11,47 @@ import com.maradona.backend.repositories.ProjectRepository;
import com.maradona.backend.services.details.EmployeeDetails;
import com.maradona.backend.services.details.ProjectDetails;
/**
* ProjectActions
*
* This class contains the business logic for the Project entity.
*/
@Service
public class ProjectActions {
/**
* The ProjectRepository instance.
*/
@Autowired
private ProjectRepository projectRepository;
/**
* The ProjectDetails instance.
*/
@Autowired
private ProjectDetails projectDetails;
/**
* The EmployeeDetails instance.
*/
@Autowired
private EmployeeDetails employeeDetails;
/**
* This method saves a Project entity.
*
* @param project The Project entity to save.
* @return The saved Project entity.
*/
public Project saveProject(Project project) {
return projectRepository.save(project);
}
/**
* This method deletes a Project entity.
*
* @param pid The Project ID.
*/
public void deleteProject(Long pid) {
var projects = projectRepository.findAll();
for (Project project : projects) {
@ -36,6 +61,12 @@ public class ProjectActions {
}
}
/**
* This method adds an Employee to a Project.
*
* @param pid The Project ID.
* @param eid The Employee ID.
*/
public void addEmployeeToProject(Long pid, Long eid) {
var project = projectDetails.getProjectByPid(pid).orElse(null);
var newEmployee = employeeDetails.getEmployeeByEid(eid).orElse(null);
@ -48,6 +79,12 @@ public class ProjectActions {
project.setEmployees(employeeList);
}
/**
* This method removes an Employee from a Project.
*
* @param pid The Project ID.
* @param eid The Employee ID.
*/
public void removeEmployeeFromProject(Long pid, Long eid) {
var project = projectDetails.getProjectByPid(pid).orElse(null);
var oldEmployees = project.getEmployees();

View File

@ -7,17 +7,37 @@ import com.maradona.backend.repositories.PrimarySkillRepository;
import com.maradona.backend.repositories.SecondarySkillRepository;
import com.maradona.backend.services.details.PrimarySkillDetails;
/**
* SecondarySkillActions
*
* This class contains the business logic for the SecondarySkill entity.
*/
@Service
public class SecondarySkillActions {
/**
* The SecondarySkillRepository instance.
*/
@Autowired
private SecondarySkillRepository secondarySkillRepository;
/**
* The PrimarySkillDetails instance.
*/
@Autowired
private PrimarySkillDetails primarySkillDetails;
/**
* The PrimarySkillRepository instance.
*/
@Autowired
private PrimarySkillRepository primarySkillrRepository;
/**
* This method saves a SecondarySkill entity.
*
* @param secondarySkill The SecondarySkill entity to save.
* @return The saved SecondarySkill entity.
*/
public SecondarySkill saveSecondarySkill(SecondarySkill secondarySkill) {
var primarySkillDescription = secondarySkill.getPrimarySkill().getDescription();
var existingPrimarySkill = primarySkillDetails.findByDescription(primarySkillDescription);
@ -31,6 +51,11 @@ public class SecondarySkillActions {
return secondarySkillRepository.save(secondarySkill);
}
/**
* This method deletes a SecondarySkill entity.
*
* @param ssid The SecondarySkill ID.
*/
public void deleteSecondarySkill(Long ssid) {
var secondarySkills = secondarySkillRepository.findAll();
for (SecondarySkill secondarySkill : secondarySkills) {

View File

@ -7,11 +7,24 @@ import com.maradona.backend.repositories.EmployeeRepository;
import java.util.Optional;
/**
* EmployeeDetails
*
* This class contains the business logic for the Employee entity.
*/
@Service
public class EmployeeDetails {
/**
* The EmployeeRepository instance.
*/
@Autowired
private EmployeeRepository employeeRepository;
/**
* This method saves an Employee entity.
*
* @param employee The Employee entity to save.
*/
public Optional<Employee> getEmployeeByEid(Long eid) {
var employees = employeeRepository.findAll();
for (Employee employee : employees) {
@ -22,10 +35,21 @@ public class EmployeeDetails {
return Optional.empty();
}
/**
* This method returns all Employee entities.
*
* @return All Employee entities.
*/
public Iterable<Employee> getAllEmployees() {
return employeeRepository.findAll();
}
/**
* This method returns all Employee entities with a specific primary skill.
*
* @param psid The primary skill ID.
* @return All Employee entities with the specified primary skill.
*/
public Iterable<Employee> getEmployeesBySecondarySkill(Long ssid, Integer level) {
// Implement logic to fetch employees by secondary skill and level
// TODO: This is a placeholder implementation

View File

@ -7,12 +7,24 @@ import com.maradona.backend.repositories.FormOfAddressRepository;
import java.util.Optional;
/**
* FormOfAddressDetails
*
* This class contains the business logic for the FormOfAddress entity.
*/
@Service
public class FormOfAddressDetails {
/**
* The FormOfAddressRepository instance.
*/
@Autowired
private FormOfAddressRepository formOfAddressRepository;
/**
* This method saves a FormOfAddress entity.
*
* @param formOfAddress The FormOfAddress entity to save.
*/
public Optional<FormOfAddress> getFormOfAddressByFid(Long fid) {
var formOfAddresses = formOfAddressRepository.findAll();
for (FormOfAddress formOfAddress : formOfAddresses) {
@ -23,6 +35,11 @@ public class FormOfAddressDetails {
return Optional.empty();
}
/**
* This method returns all FormOfAddress entities.
*
* @return All FormOfAddress entities.
*/
public Iterable<FormOfAddress> getAllFormOfAddresses() {
return formOfAddressRepository.findAll();
}

View File

@ -7,12 +7,25 @@ import com.maradona.backend.repositories.PrimarySkillRepository;
import java.util.Optional;
/**
* PrimarySkillDetails
*
* This class contains the business logic for the PrimarySkill entity.
*/
@Service
public class PrimarySkillDetails {
/**
* The PrimarySkillRepository instance.
*/
@Autowired
private PrimarySkillRepository primarySkillRepository;
/**
* This method saves a PrimarySkill entity.
*
* @param primarySkill The PrimarySkill entity to save.
* @return The saved PrimarySkill entity.
*/
public Optional<PrimarySkill> getPrimarySkillByPsid(Long psid) {
var primarySkills = primarySkillRepository.findAll();
for (PrimarySkill primarySkill : primarySkills) {
@ -23,10 +36,20 @@ public class PrimarySkillDetails {
return Optional.empty();
}
/**
* This method returns all PrimarySkill entities.
*
* @return All PrimarySkill entities.
*/
public Iterable<PrimarySkill> getAllPrimarySkills() {
return primarySkillRepository.findAll();
}
/**
* This method deletes a PrimarySkill entity.
*
* @param psid The PrimarySkill ID.
*/
public Optional<PrimarySkill> findByDescription(String description) {
var allPrimarySkills = primarySkillRepository.findAll();
for (PrimarySkill primarySkill : allPrimarySkills) {

View File

@ -10,12 +10,26 @@ import com.maradona.backend.repositories.ProjectRepository;
import java.util.ArrayList;
import java.util.Optional;
/**
* ProjectDetails
*
* This class contains the business logic for the Project entity.
*/
@Service
public class ProjectDetails {
/**
* The ProjectRepository instance.
*/
@Autowired
private ProjectRepository projectRepository;
/**
* This method saves a Project entity.
*
* @param project The Project entity to save.
* @return The saved Project entity.
*/
public Optional<Project> getProjectByPid(Long pid) {
var projects = projectRepository.findAll();
for (Project project : projects) {
@ -26,16 +40,33 @@ public class ProjectDetails {
return Optional.empty();
}
/**
* This method returns all Project entities.
*
* @return All Project entities.
*/
public Iterable<Project> getAllProjects() {
return projectRepository.findAll();
}
/**
* This method returns all Employee entities for a specific Project.
*
* @param pid The Project ID.
* @return All Employee entities for the specified Project.
*/
public Iterable<Employee> getProjectEmployees(Long pid) {
var project = getProjectByPid(pid).orElse(null);
var employees = project.getEmployees();
return employees;
}
/**
* This method returns all Project entities for a specific Employee.
*
* @param eid The Employee ID.
* @return All Project entities for the specified Employee.
*/
public Iterable<Project> getProjectsByEid(Long eid) {
var projects = projectRepository.findAll();
var employeeProjects = new ArrayList<Project>();

View File

@ -7,11 +7,25 @@ import com.maradona.backend.repositories.SecondarySkillRepository;
import java.util.Optional;
/**
* SecondarySkillDetails
*
* This class contains the business logic for the SecondarySkill entity.
*/
@Service
public class SecondarySkillDetails {
/**
* The SecondarySkillRepository instance.
*/
@Autowired
private SecondarySkillRepository secondarySkillRepository;
/**
* This method saves a SecondarySkill entity.
*
* @param secondarySkill The SecondarySkill entity to save.
* @return The saved SecondarySkill entity.
*/
public Optional<SecondarySkill> getSecondarySkillBySsid(Long ssid) {
var secondarySkills = secondarySkillRepository.findAll();
for (SecondarySkill secondarySkill : secondarySkills) {
@ -22,6 +36,11 @@ public class SecondarySkillDetails {
return Optional.empty();
}
/**
* This method returns all SecondarySkill entities.
*
* @return All SecondarySkill entities.
*/
public Iterable<SecondarySkill> getSecondarySkillsByPrimarySkillId(Long psid) {
var skills = secondarySkillRepository.findAll();
var result = new java.util.ArrayList<SecondarySkill>();
@ -33,6 +52,11 @@ public class SecondarySkillDetails {
return result;
}
/**
* This method returns all SecondarySkill entities.
*
* @return All SecondarySkill entities.
*/
public Iterable<SecondarySkill> getAllSecondarySkills() {
return secondarySkillRepository.findAll();
}

View File

@ -16,18 +16,36 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
* SkillService
*
* This class contains the business logic for the Skill entity.
*/
@Service
public class SkillService {
/**
* The PrimarySkillDetails instance.
*/
@Autowired
private PrimarySkillDetails primarySkillDetails;
/**
* The SecondarySkillDetails instance.
*/
@Autowired
private SecondarySkillDetails secondarySkillDetails;
/**
* The EmployeeDetails instance.
*/
@Autowired
private EmployeeDetails employeeDetails;
/**
* This method returns all Skill entities.
*
* @return All Skill entities.
*/
public Iterable<SkillList> getAllSkills() {
Iterable<PrimarySkill> primarySkills = primarySkillDetails.getAllPrimarySkills();
Iterable<SecondarySkill> secondarySkills = secondarySkillDetails.getAllSecondarySkills();
@ -45,6 +63,12 @@ public class SkillService {
return skills;
}
/**
* This method returns all Skill entities for a given employee.
*
* @param eid The employee ID.
* @return All Skill entities for the given employee.
*/
public Iterable<SkillList> getUserSkills(Long eid) {
if (eid == null) {
return new ArrayList<>();