Merge pull request 'chore: Update branch' (#9) from Maradona/Backend:restfull into restfull

Reviewed-on: #9
pull/1/head
Piotr Jakubiak 2024-11-12 11:55:04 +01:00
commit 82732f24dc
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.Map;
import java.util.stream.Collectors; 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 @Entity
@Data @Data
public class Employee { public class Employee {
/**
* The unique identifier of the employee.
*
* This is the primary key of the employee entity.
*/
@Id @Id
@GeneratedValue(strategy = GenerationType.IDENTITY) @GeneratedValue(strategy = GenerationType.IDENTITY)
private Long eid; private Long eid;
/**
* The employee number of the employee.
*
* This is a number from the Inter system.
*/
private Integer employeeNr; private Integer employeeNr;
/**
* The first name of the employee.
*/
@Column(length = 100) @Column(length = 100)
private String firstName; private String firstName;
/**
* The last name of the employee.
*/
@Column(length = 100) @Column(length = 100)
private String lastName; private String lastName;
/**
* The form of address of the employee.
*
* This is a reference to the form of address entity.
*/
@ManyToOne @ManyToOne
@JoinColumn(name = "form_of_address_fid") @JoinColumn(name = "form_of_address_fid")
private FormOfAddress formOfAddress; private FormOfAddress formOfAddress;
/**
* The start time of the employee's daylie business.
*/
private LocalTime dStart; private LocalTime dStart;
/**
* The end time of the employee's daylie business.
*/
private LocalTime dEnd; 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) @OneToMany(mappedBy = "employee", cascade = CascadeType.ALL, orphanRemoval = true)
@JsonManagedReference @JsonManagedReference
private List<EmployeeSecondarySkill> secondarySkills; private List<EmployeeSecondarySkill> secondarySkills;
/**
* The projects of the employee.
*
* This is a list of project entities.
*/
@ManyToMany @ManyToMany
@JoinTable(name = "employee_project", joinColumns = @JoinColumn(name = "employee_eid"), inverseJoinColumns = @JoinColumn(name = "project_pid")) @JoinTable(name = "employee_project", joinColumns = @JoinColumn(name = "employee_eid"), inverseJoinColumns = @JoinColumn(name = "project_pid"))
private List<Project> projects; private List<Project> projects;
/**
* Sets the unique identifier of the employee.
*
* @param eid The unique identifier of the employee.
*/
public void setEid(Long eid) { public void setEid(Long eid) {
this.eid = eid; this.eid = eid;
} }
/**
* Returns the unique identifier of the employee.
*
* @return The unique identifier of the employee.
*/
public Long getEid() { public Long getEid() {
return eid; return eid;
} }
/**
* Sets the employee number of the employee.
*
* @param employeeNr The employee number of the employee.
*/
public void setEmployeeNr(Integer employeeNr) { public void setEmployeeNr(Integer employeeNr) {
this.employeeNr = employeeNr; this.employeeNr = employeeNr;
} }
/**
* Returns the employee number of the employee.
*
* @return The employee number of the employee.
*/
public Integer getEmployeeNr() { public Integer getEmployeeNr() {
return employeeNr; return employeeNr;
} }
/**
* Sets the first name of the employee.
*
* @param firstName The first name of the employee.
*/
public void setFirstName(String firstName) { public void setFirstName(String firstName) {
this.firstName = firstName; this.firstName = firstName;
} }
/**
* Returns the first name of the employee.
*
* @return The first name of the employee.
*/
public String getFirstName() { public String getFirstName() {
return firstName; return firstName;
} }
/**
* Sets the last name of the employee.
*
* @param lastName The last name of the employee.
*/
public void setLastName(String lastName) { public void setLastName(String lastName) {
this.lastName = lastName; this.lastName = lastName;
} }
/**
* Returns the last name of the employee.
*
* @return The last name of the employee.
*/
public String getLastName() { public String getLastName() {
return lastName; return lastName;
} }
/**
* Sets the form of address of the employee.
*
* @param formOfAddress The form of address of the employee.
*/
public void setFormOfAddress(FormOfAddress formOfAddress) { public void setFormOfAddress(FormOfAddress formOfAddress) {
this.formOfAddress = formOfAddress; this.formOfAddress = formOfAddress;
} }
/**
* Returns the form of address of the employee.
*
* @return The form of address of the employee.
*/
public FormOfAddress getFormOfAddress() { public FormOfAddress getFormOfAddress() {
return formOfAddress; 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) { public void setDStart(LocalTime dStart) {
this.dStart = 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() { public LocalTime getDStart() {
return dStart; 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) { public void setDEnd(LocalTime dEnd) {
this.dEnd = 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() { public LocalTime getDEnd() {
return dEnd; return dEnd;
} }
/**
* Sets the secondary skills of the employee.
*
* @param secondarySkills The secondary skills of the employee.
*/
public void setSecondarySkills(List<EmployeeSecondarySkill> secondarySkills) { public void setSecondarySkills(List<EmployeeSecondarySkill> secondarySkills) {
this.secondarySkills = secondarySkills; this.secondarySkills = secondarySkills;
} }
/**
* Returns the secondary skills of the employee.
*
* @return The secondary skills of the employee.
*/
public List<EmployeeSecondarySkill> getSecondarySkills() { public List<EmployeeSecondarySkill> getSecondarySkills() {
return secondarySkills; return secondarySkills;
} }
/**
* Sets the projects of the employee.
*
* @param projects The projects of the employee.
*/
public Map<SecondarySkill, Integer> getSecondarySkillLevels() { public Map<SecondarySkill, Integer> getSecondarySkillLevels() {
return secondarySkills.stream() return secondarySkills.stream()
.collect(Collectors.toMap(EmployeeSecondarySkill::getSecondarySkill, EmployeeSecondarySkill::getLevel)); .collect(Collectors.toMap(EmployeeSecondarySkill::getSecondarySkill, EmployeeSecondarySkill::getLevel));

View File

@ -4,53 +4,120 @@ import jakarta.persistence.*;
import lombok.Data; import lombok.Data;
import com.fasterxml.jackson.annotation.JsonBackReference; 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 @Entity
@Data @Data
public class EmployeeSecondarySkill { 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 @Id
@GeneratedValue(strategy = GenerationType.IDENTITY) @GeneratedValue(strategy = GenerationType.IDENTITY)
private Long essid; private Long essid;
/**
* The employee that has the secondary skill.
*
* This is a reference to the employee entity.
*/
@ManyToOne @ManyToOne
@JoinColumn(name = "employee_eid", nullable = false) @JoinColumn(name = "employee_eid", nullable = false)
@JsonBackReference @JsonBackReference
private Employee employee; private Employee employee;
/**
* The secondary skill that the employee has.
*
* This is a reference to the secondary skill entity.
*/
@ManyToOne @ManyToOne
@JoinColumn(name = "secondary_skill_id", nullable = false) @JoinColumn(name = "secondary_skill_id", nullable = false)
private SecondarySkill secondarySkill; 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) @Column(nullable = false)
private Integer level; 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) { public void setEssid(Long essid) {
this.essid = 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() { public Long getEssid() {
return essid; return essid;
} }
/**
* Sets the employee that has the secondary skill.
*
* @param employee The employee that has the secondary skill.
*/
public void setEmployee(Employee employee) { public void setEmployee(Employee employee) {
this.employee = employee; this.employee = employee;
} }
/**
* Returns the employee that has the secondary skill.
*
* @return The employee that has the secondary skill.
*/
public Employee getEmployee() { public Employee getEmployee() {
return employee; return employee;
} }
/**
* Sets the secondary skill that the employee has.
*
* @param secondarySkill The secondary skill that the employee has.
*/
public void setSecondarySkill(SecondarySkill secondarySkill) { public void setSecondarySkill(SecondarySkill secondarySkill) {
this.secondarySkill = secondarySkill; this.secondarySkill = secondarySkill;
} }
/**
* Returns the secondary skill that the employee has.
*
* @return The secondary skill that the employee has.
*/
public SecondarySkill getSecondarySkill() { public SecondarySkill getSecondarySkill() {
return secondarySkill; 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) { public void setLevel(Integer level) {
this.level = 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() { public Integer getLevel() {
return level; return level;
} }

View File

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

View File

@ -5,40 +5,92 @@ import com.fasterxml.jackson.annotation.JsonManagedReference;
import lombok.Data; import lombok.Data;
import java.util.List; 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 @Entity
@Data @Data
public class PrimarySkill { public class PrimarySkill {
/**
* The unique identifier of the primary skill.
*
* This is the primary key of the primary skill entity.
*/
@Id @Id
@GeneratedValue(strategy = GenerationType.IDENTITY) @GeneratedValue(strategy = GenerationType.IDENTITY)
private Long psid; 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) @Column(nullable = false, length = 255)
private String description; 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) @OneToMany(mappedBy = "primarySkill", cascade = CascadeType.ALL, orphanRemoval = true)
@JsonManagedReference @JsonManagedReference
private List<SecondarySkill> secondarySkills; 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) { public void setPsid(Long psid) {
this.psid = psid; this.psid = psid;
} }
/**
* Gets the unique identifier of the primary skill.
*
* @return The unique identifier of the primary skill.
*/
public Long getPsid() { public Long getPsid() {
return psid; return psid;
} }
/**
* Sets the description of the primary skill.
*
* @param description The description of the primary skill.
*/
public void setDescription(String description) { public void setDescription(String description) {
this.description = description; this.description = description;
} }
/**
* Gets the description of the primary skill.
*
* @return The description of the primary skill.
*/
public String getDescription() { public String getDescription() {
return description; 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) { public void setSecondarySkills(List<SecondarySkill> secondarySkills) {
this.secondarySkills = 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() { public List<SecondarySkill> getSecondarySkills() {
return secondarySkills; return secondarySkills;
} }

View File

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

View File

@ -6,53 +6,120 @@ import com.fasterxml.jackson.annotation.JsonManagedReference;
import lombok.Data; import lombok.Data;
import java.util.List; 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 @Entity
@Data @Data
public class SecondarySkill { public class SecondarySkill {
/**
* The unique identifier of the secondary skill.
*
* This is the primary key of the secondary skill entity.
*/
@Id @Id
@GeneratedValue(strategy = GenerationType.IDENTITY) @GeneratedValue(strategy = GenerationType.IDENTITY)
private Long ssid; 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) @Column(nullable = false, length = 255)
private String description; private String description;
/**
* The primary skill that the secondary skill belongs to.
*
* This is a reference to the primary skill entity.
*/
@ManyToOne @ManyToOne
@JoinColumn(name = "psid", nullable = false) @JoinColumn(name = "psid", nullable = false)
@JsonBackReference @JsonBackReference
private PrimarySkill primarySkill; 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) @OneToMany(mappedBy = "secondarySkill", cascade = CascadeType.ALL, orphanRemoval = true)
@JsonManagedReference @JsonManagedReference
private List<EmployeeSecondarySkill> employeeSecondarySkills; 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) { public void setSsid(Long ssid) {
this.ssid = ssid; this.ssid = ssid;
} }
/**
* Gets the unique identifier of the secondary skill.
*
* @return The unique identifier of the secondary skill.
*/
public Long getSsid() { public Long getSsid() {
return ssid; return ssid;
} }
/**
* Sets the description of the secondary skill.
*
* @param description The description of the secondary skill.
*/
public void setDescription(String description) { public void setDescription(String description) {
this.description = description; this.description = description;
} }
/**
* Gets the description of the secondary skill.
*
* @return The description of the secondary skill.
*/
public String getDescription() { public String getDescription() {
return description; 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) { public void setPrimarySkill(PrimarySkill primarySkill) {
this.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() { public PrimarySkill getPrimarySkill() {
return primarySkill; 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) { public void setEmployeeSecondarySkills(List<EmployeeSecondarySkill> employeeSecondarySkills) {
this.employeeSecondarySkills = employeeSecondarySkills; this.employeeSecondarySkills = employeeSecondarySkills;
} }
/**
* Gets the employees that have the secondary skill.
*
* @return The employees that have the secondary skill.
*/
public List<EmployeeSecondarySkill> getEmployeeSecondarySkills() { public List<EmployeeSecondarySkill> getEmployeeSecondarySkills() {
return employeeSecondarySkills; return employeeSecondarySkills;
} }

View File

@ -3,5 +3,11 @@ package com.maradona.backend.repositories;
import org.springframework.data.repository.CrudRepository; import org.springframework.data.repository.CrudRepository;
import com.maradona.backend.entities.Employee; 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> { 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 org.springframework.data.repository.CrudRepository;
import com.maradona.backend.entities.EmployeeSecondarySkill; 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> { 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 org.springframework.data.repository.CrudRepository;
import com.maradona.backend.entities.FormOfAddress; 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> { 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 org.springframework.data.repository.CrudRepository;
import com.maradona.backend.entities.PrimarySkill; 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> { 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 org.springframework.data.repository.CrudRepository;
import com.maradona.backend.entities.Project; 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> { 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 org.springframework.data.repository.CrudRepository;
import com.maradona.backend.entities.SecondarySkill; 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> { 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.services.details.SecondarySkillDetails;
import com.maradona.backend.dto.SkillPrototype; import com.maradona.backend.dto.SkillPrototype;
/**
* EmployeeActions
*
* This class contains the business logic for the Employee entity.
*/
@Service @Service
public class EmployeeActions { public class EmployeeActions {
/**
* The EmployeeRepository instance.
*/
@Autowired @Autowired
private EmployeeRepository employeeRepository; private EmployeeRepository employeeRepository;
/**
* The EmployeeDetails instance.
*/
@Autowired @Autowired
private EmployeeDetails employeeDetails; private EmployeeDetails employeeDetails;
/**
* The SecondarySkillDetails instance.
*/
@Autowired @Autowired
private SecondarySkillDetails secondarySkillDetails; 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) { public void deleteEmployee(Long eid) {
for (Employee employee : employeeRepository.findAll()) { for (Employee employee : employeeRepository.findAll()) {
if (employee.getEid().equals(eid)) { 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) { public void addSecondarySkillToEmployee(Long eid, SkillPrototype skillPrototype) {
var employee = employeeDetails.getEmployeeByEid(eid).orElseThrow(() -> new RuntimeException("Employee not found")); var employee = employeeDetails.getEmployeeByEid(eid).orElseThrow(() -> new RuntimeException("Employee not found"));
var secondarySkill = secondarySkillDetails.getSecondarySkillBySsid(skillPrototype.getSsid()) var secondarySkill = secondarySkillDetails.getSecondarySkillBySsid(skillPrototype.getSsid())
@ -52,6 +83,13 @@ public class EmployeeActions {
saveEmployee(employee); 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) { public void updateSecondarySkillLevel(Long eid, Long ssid, Integer level) {
var employee = employeeDetails.getEmployeeByEid(eid).orElseThrow(() -> new RuntimeException("Employee not found")); var employee = employeeDetails.getEmployeeByEid(eid).orElseThrow(() -> new RuntimeException("Employee not found"));
secondarySkillDetails.getSecondarySkillBySsid( secondarySkillDetails.getSecondarySkillBySsid(
@ -68,6 +106,12 @@ public class EmployeeActions {
saveEmployee(employee); 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) { public void deleteSecondarySkillFromEmployee(Long eid, Long ssid) {
var employee = employeeDetails.getEmployeeByEid(eid).orElseThrow(() -> new RuntimeException("Employee not found")); var employee = employeeDetails.getEmployeeByEid(eid).orElseThrow(() -> new RuntimeException("Employee not found"));
secondarySkillDetails.getSecondarySkillBySsid( secondarySkillDetails.getSecondarySkillBySsid(

View File

@ -6,19 +6,40 @@ import com.maradona.backend.entities.FormOfAddress;
import com.maradona.backend.repositories.FormOfAddressRepository; import com.maradona.backend.repositories.FormOfAddressRepository;
import com.maradona.backend.services.details.FormOfAddressDetails; import com.maradona.backend.services.details.FormOfAddressDetails;
/**
* FormOfAddressActions
*
* This class contains the business logic for the FormOfAddress entity.
*/
@Service @Service
public class FormOfAddressActions { public class FormOfAddressActions {
/**
* The FormOfAddressRepository instance.
*/
@Autowired @Autowired
private FormOfAddressRepository formOfAddressRepository; private FormOfAddressRepository formOfAddressRepository;
/**
* The FormOfAddressDetails instance.
*/
@Autowired @Autowired
private FormOfAddressDetails formOfAddressDetails; 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) { public FormOfAddress saveFormOfAddress(FormOfAddress formOfAddress) {
return formOfAddressRepository.save(formOfAddress); return formOfAddressRepository.save(formOfAddress);
} }
/**
* This method deletes a FormOfAddress entity.
*
* @param fid The FormOfAddress ID.
*/
public void deleteFormOfAddress(Long fid) { public void deleteFormOfAddress(Long fid) {
for (FormOfAddress formOfAddress : formOfAddressRepository.findAll()) { for (FormOfAddress formOfAddress : formOfAddressRepository.findAll()) {
if (formOfAddress.getFid().equals(fid)) { 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) { public void updateFormOfAddress(Long fid, String description) {
var formOfAddress = formOfAddressDetails.getFormOfAddressByFid(fid) var formOfAddress = formOfAddressDetails.getFormOfAddressByFid(fid)
.orElseThrow(() -> new RuntimeException("Form of Address not found")); .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.repositories.SecondarySkillRepository;
import com.maradona.backend.services.details.SecondarySkillDetails; import com.maradona.backend.services.details.SecondarySkillDetails;
/**
* PrimarySkillActions
*
* This class contains the business logic for the PrimarySkill entity.
*/
@Service @Service
public class PrimarySkillActions { public class PrimarySkillActions {
/**
* The PrimarySkillRepository instance.
*/
@Autowired @Autowired
private PrimarySkillRepository primarySkillRepository; private PrimarySkillRepository primarySkillRepository;
/**
* The SecondarySkillDetails instance.
*/
@Autowired @Autowired
private SecondarySkillDetails secondarySkillDetails; private SecondarySkillDetails secondarySkillDetails;
/**
* The SecondarySkillRepository instance.
*/
@Autowired @Autowired
private SecondarySkillRepository secondarySkillRepository; 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) { public PrimarySkill savePrimarySkill(PrimarySkill primarySkill) {
return primarySkillRepository.save(primarySkill); return primarySkillRepository.save(primarySkill);
} }
/**
* This method deletes a PrimarySkill entity.
*
* @param psid The PrimarySkill ID.
*/
public void deletePrimarySkill(Long psid) { public void deletePrimarySkill(Long psid) {
var primarySkills = primarySkillRepository.findAll(); var primarySkills = primarySkillRepository.findAll();
var secondarySkills = secondarySkillDetails.getAllSecondarySkills(); 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.EmployeeDetails;
import com.maradona.backend.services.details.ProjectDetails; import com.maradona.backend.services.details.ProjectDetails;
/**
* ProjectActions
*
* This class contains the business logic for the Project entity.
*/
@Service @Service
public class ProjectActions { public class ProjectActions {
/**
* The ProjectRepository instance.
*/
@Autowired @Autowired
private ProjectRepository projectRepository; private ProjectRepository projectRepository;
/**
* The ProjectDetails instance.
*/
@Autowired @Autowired
private ProjectDetails projectDetails; private ProjectDetails projectDetails;
/**
* The EmployeeDetails instance.
*/
@Autowired @Autowired
private EmployeeDetails employeeDetails; 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) { public Project saveProject(Project project) {
return projectRepository.save(project); return projectRepository.save(project);
} }
/**
* This method deletes a Project entity.
*
* @param pid The Project ID.
*/
public void deleteProject(Long pid) { public void deleteProject(Long pid) {
var projects = projectRepository.findAll(); var projects = projectRepository.findAll();
for (Project project : projects) { 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) { public void addEmployeeToProject(Long pid, Long eid) {
var project = projectDetails.getProjectByPid(pid).orElse(null); var project = projectDetails.getProjectByPid(pid).orElse(null);
var newEmployee = employeeDetails.getEmployeeByEid(eid).orElse(null); var newEmployee = employeeDetails.getEmployeeByEid(eid).orElse(null);
@ -48,6 +79,12 @@ public class ProjectActions {
project.setEmployees(employeeList); 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) { public void removeEmployeeFromProject(Long pid, Long eid) {
var project = projectDetails.getProjectByPid(pid).orElse(null); var project = projectDetails.getProjectByPid(pid).orElse(null);
var oldEmployees = project.getEmployees(); 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.repositories.SecondarySkillRepository;
import com.maradona.backend.services.details.PrimarySkillDetails; import com.maradona.backend.services.details.PrimarySkillDetails;
/**
* SecondarySkillActions
*
* This class contains the business logic for the SecondarySkill entity.
*/
@Service @Service
public class SecondarySkillActions { public class SecondarySkillActions {
/**
* The SecondarySkillRepository instance.
*/
@Autowired @Autowired
private SecondarySkillRepository secondarySkillRepository; private SecondarySkillRepository secondarySkillRepository;
/**
* The PrimarySkillDetails instance.
*/
@Autowired @Autowired
private PrimarySkillDetails primarySkillDetails; private PrimarySkillDetails primarySkillDetails;
/**
* The PrimarySkillRepository instance.
*/
@Autowired @Autowired
private PrimarySkillRepository primarySkillrRepository; 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) { public SecondarySkill saveSecondarySkill(SecondarySkill secondarySkill) {
var primarySkillDescription = secondarySkill.getPrimarySkill().getDescription(); var primarySkillDescription = secondarySkill.getPrimarySkill().getDescription();
var existingPrimarySkill = primarySkillDetails.findByDescription(primarySkillDescription); var existingPrimarySkill = primarySkillDetails.findByDescription(primarySkillDescription);
@ -31,6 +51,11 @@ public class SecondarySkillActions {
return secondarySkillRepository.save(secondarySkill); return secondarySkillRepository.save(secondarySkill);
} }
/**
* This method deletes a SecondarySkill entity.
*
* @param ssid The SecondarySkill ID.
*/
public void deleteSecondarySkill(Long ssid) { public void deleteSecondarySkill(Long ssid) {
var secondarySkills = secondarySkillRepository.findAll(); var secondarySkills = secondarySkillRepository.findAll();
for (SecondarySkill secondarySkill : secondarySkills) { for (SecondarySkill secondarySkill : secondarySkills) {

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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