forked from Social-Projects/calibration-devices-system
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'Lv157Final' of https://github.com/Nazariii/calibration-…
…devices-system into Lv157Final
- Loading branch information
Showing
29 changed files
with
1,188 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -305,7 +305,7 @@ INSERT INTO `VERIFICATION` | |
|
||
USE measurement_devices; | ||
INSERT INTO `CALIBRATION_MODULE` | ||
(`id`,`condDesignation`, `deviceType`,`email`,`employeeFullName`,`moduleType`,`organizationCode`,`serialNumber`,`telephone`,`workDate`,`calibratorId`) | ||
(`moduleId`,`condDesignation`, `deviceType`,`email`,`employeeFullName`,`moduleType`,`organizationCode`,`serialNumber`,`telephone`,`workDate`,`calibratorId`) | ||
VALUES | ||
(1,'АС-П', 'WATER', '[email protected]', 'Пупкін Євген Вікторович', 'mobile_station', '569859878', '895678', '0634524378', '2015-10-25', '11'), | ||
(2,'АС-К', 'WATER', '[email protected]', 'Мупкін Орест Вікторович', 'mobile_station', '569859333', '111678', '0634524888', '2015-10-25', '11'), | ||
|
@@ -330,9 +330,21 @@ INSERT INTO `CALIBRATION_TEST` VALUES (2, 'В зоні', '2015-07-24 11:49:42', | |
INSERT INTO `CALIBRATION_TEST` VALUES (3, 'В зоні', '2015-09-15 12:40:30', 76, 77, 'Державна система забезпечення єдності вимірювань', 'ДСТУ 2681-94', 'Successful Test', NULL, 8, 30, 'SUCCESS', 'bbae737e-d7fe-4fff-a4c1-bca0ab5ec706'); | ||
INSERT INTO `CALIBRATION_TEST` VALUES (4, 'Придатний', '2015-07-24 11:57:42', 75, 77, 'Державна система забезпечення єдності вимірювань', 'ДСТУ 2681-94', 'Тест №7', NULL, 7, 77, 'SUCCESS', '44479022-k720-5524-ab71-eed574d1b48d'); | ||
INSERT INTO `CALIBRATION_TEST` VALUES (5, 'Придатний', '2015-07-24 12:41:42', 72, 75, 'Державна система забезпечення єдності вимірювань', 'ДСТУ 2681-94', 'Тест №7', NULL, 7, 77, 'FAILED', '44479022-k720-5524-ab71-eed574d1b48d'); | ||
UPDATE `CALIBRATION_TEST` | ||
/*UPDATE `CALIBRATION_TEST` | ||
SET | ||
`consumptionStatus` = 'IN_THE_AREA'; | ||
`consumptionStatus` = 'IN_THE_AREA' | ||
*/ | ||
|
||
|
||
USE measurement_devices; | ||
-- ------------------------------- СALIBRATION DISASSEMBLY TEAM ---------------------------- -- | ||
INSERT INTO `DISASSEMBLY_TEAM` (`id`, `name`, `effectiveTo`, `specialization`, `leaderFullName`, `leaderPhone`, `leaderEmail`, `calibratorId`) | ||
VALUES | ||
('1', 'Dart Vader', '2015-10-20', 'WATER', 'Nazarkevych V.T.', '957000105', '[email protected]', '11'), | ||
('2', 'Dart', '2015-10-24', 'WATER', 'Nazarkevych V.T.', '957000105', '[email protected]', '11'), | ||
('3', 'Dart Vader 1', '2015-10-24', 'WATER', 'Nazarkevych V.T.', '957000105', '[email protected]', '11'), | ||
('4', 'Dart Vader 2', '2015-11-24', 'WATER', 'Nazarkevych V.T.', '957000105', '[email protected]', '11'); | ||
|
||
|
||
|
||
UPDATE `VERIFICATION` | ||
|
67 changes: 67 additions & 0 deletions
67
repository/src/main/java/com/softserve/edu/entity/catalogue/Team/DisassemblyTeam.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
package com.softserve.edu.entity.catalogue.Team; | ||
|
||
|
||
import com.softserve.edu.entity.device.Device; | ||
import com.softserve.edu.entity.organization.Organization; | ||
import lombok.*; | ||
|
||
import javax.persistence.*; | ||
import java.util.Date; | ||
|
||
/** | ||
* Disassembly team entity. Contain information about teams. | ||
*/ | ||
@Entity | ||
@Getter | ||
@Setter | ||
@EqualsAndHashCode(of = "id") | ||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
@Table(name = "DISASSEMBLY_TEAM") | ||
public class DisassemblyTeam { | ||
|
||
@Setter(AccessLevel.PRIVATE) | ||
@Id | ||
private String id; | ||
|
||
private String name; | ||
|
||
@Temporal(TemporalType.DATE) | ||
private Date effectiveTo; | ||
|
||
@Enumerated(EnumType.STRING) | ||
private Device.DeviceType specialization; | ||
|
||
private String leaderFullName; | ||
|
||
private String leaderPhone; | ||
|
||
private String leaderEmail; | ||
|
||
@ManyToOne(fetch = FetchType.EAGER) | ||
@JoinColumn(name = "calibratorId") | ||
private Organization organization; | ||
|
||
public DisassemblyTeam(String id, String name, Date effectiveTo, Device.DeviceType specialization, String leaderFullName, | ||
String leaderPhone, String leaderEmail) { | ||
this.id = id; | ||
this.name = name; | ||
this.effectiveTo = effectiveTo; | ||
this.specialization = specialization; | ||
this.leaderFullName = leaderFullName; | ||
this.leaderPhone = leaderPhone; | ||
this.leaderEmail = leaderEmail; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "DisassemblyTeam{" + | ||
"id='" + id + '\'' + | ||
", name='" + name + '\'' + | ||
", effectiveTo=" + effectiveTo + | ||
", specialization=" + specialization + | ||
", leaderFullName='" + leaderFullName + '\'' + | ||
", leaderPhone='" + leaderPhone + '\'' + | ||
", leaderEmail='" + leaderEmail + '\'' + | ||
'}'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
...tory/src/main/java/com/softserve/edu/repository/CalibrationDisassemblyTeamRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package com.softserve.edu.repository; | ||
|
||
import com.softserve.edu.entity.catalogue.Team.DisassemblyTeam; | ||
import org.springframework.data.domain.Page; | ||
import org.springframework.data.domain.Pageable; | ||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor; | ||
import org.springframework.data.repository.PagingAndSortingRepository; | ||
|
||
|
||
public interface CalibrationDisassemblyTeamRepository extends | ||
PagingAndSortingRepository<DisassemblyTeam, String>, JpaSpecificationExecutor { | ||
|
||
Page<DisassemblyTeam> findAll(Pageable pageable); | ||
|
||
//Page<DisassemblyTeam> findByCalibratorId(Long calibratorId, Pageable pageable); | ||
|
||
Page<DisassemblyTeam> findByNameLikeIgnoreCase(String name, Pageable pageable); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
.../src/main/java/com/softserve/edu/service/calibrator/CalibratorDisassemblyTeamService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package com.softserve.edu.service.calibrator; | ||
|
||
|
||
import com.softserve.edu.entity.catalogue.Team.DisassemblyTeam; | ||
import com.softserve.edu.entity.device.Device; | ||
import com.softserve.edu.service.exceptions.DuplicateRecordException; | ||
import org.springframework.data.domain.Page; | ||
|
||
import java.util.Date; | ||
import java.util.List; | ||
|
||
public interface CalibratorDisassemblyTeamService { | ||
|
||
List<DisassemblyTeam> getAll(); | ||
|
||
Page<DisassemblyTeam> getDisassemblyTeamBySearchAndPagination(int pageNumber,int itemsPerPage, String search); | ||
|
||
void addDisassemblyTeam(DisassemblyTeam disassemblyTeam) throws DuplicateRecordException; | ||
|
||
DisassemblyTeam getDisassemblyTeamById(String teamId); | ||
|
||
void editDisassemblyTeam(String id, String name, Date effectiveTo, Device.DeviceType specialization, String leaderFullName, | ||
String leaderPhone, String leaderEmail); | ||
|
||
void deleteDisassemblyTeam(String teamId); | ||
|
||
} |
73 changes: 73 additions & 0 deletions
73
...java/com/softserve/edu/service/calibrator/impl/CalibrationDisassemblyTeamServiceImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
package com.softserve.edu.service.calibrator.impl; | ||
|
||
import com.softserve.edu.entity.catalogue.Team.DisassemblyTeam; | ||
import com.softserve.edu.entity.device.Device; | ||
import com.softserve.edu.repository.CalibrationDisassemblyTeamRepository; | ||
import com.softserve.edu.service.calibrator.CalibratorDisassemblyTeamService; | ||
import com.softserve.edu.service.exceptions.DuplicateRecordException; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.data.domain.Page; | ||
import org.springframework.data.domain.PageRequest; | ||
import org.springframework.stereotype.Service; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
import java.util.Date; | ||
import java.util.List; | ||
|
||
|
||
@Service | ||
public class CalibrationDisassemblyTeamServiceImpl implements CalibratorDisassemblyTeamService { | ||
|
||
@Autowired | ||
private CalibrationDisassemblyTeamRepository teamRepository; | ||
|
||
@Override | ||
@Transactional | ||
public List<DisassemblyTeam> getAll() { | ||
return (List<DisassemblyTeam>) teamRepository.findAll(); | ||
} | ||
|
||
@Override | ||
@Transactional | ||
public Page<DisassemblyTeam> getDisassemblyTeamBySearchAndPagination(int pageNumber, int itemsPerPage, String search) { | ||
PageRequest pageRequest = new PageRequest(pageNumber - 1, itemsPerPage); | ||
return search == null ? teamRepository.findAll(pageRequest) : | ||
teamRepository.findByNameLikeIgnoreCase("%" + search + "%", pageRequest); | ||
} | ||
|
||
@Override | ||
@Transactional | ||
public void addDisassemblyTeam(DisassemblyTeam disassemblyTeam) throws DuplicateRecordException { | ||
try { | ||
teamRepository.save(disassemblyTeam); | ||
} catch (Exception e) { | ||
throw new DuplicateRecordException(String.format("Team %s already exists.", disassemblyTeam.getId())); | ||
} | ||
} | ||
|
||
@Override | ||
@Transactional | ||
public DisassemblyTeam getDisassemblyTeamById(String teamId) { | ||
return teamRepository.findOne(teamId); | ||
} | ||
|
||
@Override | ||
@Transactional | ||
public void editDisassemblyTeam(String id, String name, Date effectiveTo, Device.DeviceType specialization, | ||
String leaderFullName, String leaderPhone, String leaderEmail) { | ||
DisassemblyTeam team = teamRepository.findOne(id); | ||
team.setName(name); | ||
team.setEffectiveTo(effectiveTo); | ||
team.setSpecialization(specialization); | ||
team.setLeaderFullName(leaderFullName); | ||
team.setLeaderPhone(leaderPhone); | ||
team.setLeaderEmail(leaderEmail); | ||
teamRepository.save(team); | ||
} | ||
|
||
@Override | ||
@Transactional | ||
public void deleteDisassemblyTeam(String teamId) { | ||
teamRepository.delete(teamRepository.findOne(teamId)); | ||
} | ||
} |
84 changes: 84 additions & 0 deletions
84
...serve/edu/service/calibrator/specifications/CalibrationDisassenblyTeamSpecifications.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
package com.softserve.edu.service.calibrator.specifications; | ||
|
||
import com.softserve.edu.entity.catalogue.Team.DisassemblyTeam; | ||
import com.softserve.edu.entity.device.Device; | ||
import org.springframework.data.jpa.domain.Specification; | ||
|
||
import java.util.Date; | ||
|
||
/** | ||
* Created for filtering data using PagingAndSortingRepository | ||
*/ | ||
public class CalibrationDisassenblyTeamSpecifications { | ||
|
||
/** | ||
* build query for id, filtering by id | ||
* @param id | ||
* @return query, for searching | ||
*/ | ||
public static Specification<DisassemblyTeam> disassemblyTeamHasId(String id) { | ||
return (root, criteriaQuery, criteriaBuilder) -> criteriaBuilder.equal(root.get("id"), id); | ||
} | ||
|
||
/** | ||
* build query for name, filtering by name | ||
* @param name | ||
* @return query, for searching | ||
*/ | ||
public static Specification<DisassemblyTeam> disassemblyTeamHasName(String name) { | ||
return (root, criteriaQuery, criteriaBuilder) -> criteriaBuilder.equal(root.get("name"), name); | ||
} | ||
|
||
/** | ||
* build query for effectiveTo, filtering by effective | ||
* @param effectiveTo | ||
* @return query, for searching | ||
*/ | ||
public static Specification<DisassemblyTeam> disassemblyTeamHasEffectiveTo(Date effectiveTo) { | ||
return (root, criteriaQuery, criteriaBuilder) -> criteriaBuilder.lessThan(root.get("effectiveTo"), effectiveTo); | ||
} | ||
|
||
/** | ||
* build query for disassemblyTeamType, filtering by disassemblyTeamType | ||
* @param disassemblyTeamType | ||
* @return query, for searching | ||
*/ | ||
public static Specification<DisassemblyTeam> disassemblyTeamHasType(Device.DeviceType disassemblyTeamType){ | ||
return (root, criteriaQuery, criteriaBuilder) -> | ||
criteriaBuilder.equal(root.get("specialization"), disassemblyTeamType); | ||
} | ||
|
||
/** | ||
* build query for leaderFullName, filtering by leaderFullName | ||
* @param leaderFullName | ||
* @return query, for searching | ||
*/ | ||
public static Specification<DisassemblyTeam> disassemblyTeamHasLeaderFullName(String leaderFullName) { | ||
return (root, criteriaQuery, criteriaBuilder) -> | ||
criteriaBuilder.equal(root.get("leaderFullName"), leaderFullName); | ||
} | ||
|
||
/** | ||
* build query for leaderPhone, filtering by leaderPhone | ||
* @param leaderPhone | ||
* @return query, for searching | ||
*/ | ||
public static Specification<DisassemblyTeam> disassemblyTeamHasLeaderPhone(String leaderPhone) { | ||
return (root, criteriaQuery, criteriaBuilder) -> criteriaBuilder.equal(root.get("leaderPhone"), leaderPhone); | ||
} | ||
|
||
/** | ||
* build query for leaderEmail, filtering by leaderEmail | ||
* @param leaderEmail | ||
* @return query, for searching | ||
*/ | ||
public static Specification<DisassemblyTeam> disassemblyTeamHasLeaderEmail(String leaderEmail) { | ||
return (root, criteriaQuery, criteriaBuilder) -> criteriaBuilder.equal(root.get("leaderEmail"), leaderEmail); | ||
} | ||
|
||
public static Specification<DisassemblyTeam> disassemblyTeamHasCalibratorId(Long calibratorId){ | ||
return (root, criteriaQuery, criteriaBuilder) -> | ||
criteriaBuilder.equal(root.get("organization").get("id"), calibratorId); | ||
} | ||
|
||
} |
10 changes: 10 additions & 0 deletions
10
service/src/main/java/com/softserve/edu/service/exceptions/DuplicateRecordException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package com.softserve.edu.service.exceptions; | ||
|
||
import lombok.NoArgsConstructor; | ||
|
||
@NoArgsConstructor | ||
public class DuplicateRecordException extends Exception { | ||
public DuplicateRecordException(String format) { | ||
super(format); | ||
} | ||
} |
Oops, something went wrong.