Skip to content
This repository has been archived by the owner on Sep 9, 2024. It is now read-only.

Commit

Permalink
avoid boxing/unboxing in medicalinventory manager
Browse files Browse the repository at this point in the history
  • Loading branch information
ArnaudFonzam committed Aug 14, 2024
1 parent 84e317e commit 2f1f089
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ public Page<MedicalInventory> getMedicalInventoryByParamsPageable(LocalDateTime
* @return {@link MedicalInventory}. It could be {@code null}.
* @throws OHServiceException
*/
public MedicalInventory getInventoryById(Integer inventoryId) throws OHServiceException {
public MedicalInventory getInventoryById(int inventoryId) throws OHServiceException {
return ioOperations.getInventoryById(inventoryId);
}

Expand Down Expand Up @@ -229,8 +229,6 @@ private void validateMedicalInventory(MedicalInventory medInventory) throws OHDa

@Transactional(rollbackFor = OHServiceException.class)
public void validateInventory(MedicalInventory inventory, List<MedicalInventoryRow> inventoryRowSearchList) throws OHDataValidationException, OHServiceException {
List<OHExceptionMessage> errors = new ArrayList<>();
boolean updated = false;
LocalDateTime movFrom = inventory.getLastModifiedDate();
LocalDateTime movTo = TimeTools.getNow();
List<Movement> movements = movBrowserManager.getMovements(null, null, null, null, movFrom, movTo, null, null, null, null);
Expand Down Expand Up @@ -271,11 +269,5 @@ public void validateInventory(MedicalInventory inventory, List<MedicalInventoryR
}
}
}
/*if (updated) {
errors.add(new OHExceptionMessage(MessageBundle.getMessage("angal.inventory.theoreticalqtyhavebeenupdatedforsomemedical.msg")));
}
if (!errors.isEmpty()) {
throw new OHDataValidationException(errors);
}*/
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -124,14 +124,11 @@ public void deleteMedicalInventoryRows(List<MedicalInventoryRow> inventoryRowsTo
* @return the {@link MedicalInventoryRow} object.
* @throws OHServiceException
*/
public MedicalInventoryRow getMedicalInventoryRowById(Integer invRowId) throws OHServiceException {
if (invRowId != null) {
Optional<MedicalInventoryRow> medInvRow = ioOperation.getMedicalInventoryRowById(invRowId);
if (medInvRow.isPresent()) {
return medInvRow.get();
}
public MedicalInventoryRow getMedicalInventoryRowById(int invRowId) throws OHServiceException {
Optional<MedicalInventoryRow> medInvRow = ioOperation.getMedicalInventoryRowById(invRowId);
if (medInvRow.isPresent()) {
return medInvRow.get();
}

return null;
}

Expand Down Expand Up @@ -164,7 +161,7 @@ private void validateMedicalInventoryRow(MedicalInventoryRow medicalInventoryRow
* @return the {@link MedicalInventoryRow} object.
* @throws OHServiceException
*/
public MedicalInventoryRow getMedicalInventoryRowByMedicalCodeAndLotCode(Integer medicalCode, String lotCode) throws OHServiceException {
public MedicalInventoryRow getMedicalInventoryRowByMedicalCodeAndLotCode(int medicalCode, String lotCode) throws OHServiceException {
return ioOperation.getMedicalInventoryRowByMedicalCodeAndLotCode(medicalCode, lotCode);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ public Page<MedicalInventory> getMedicalInventoryByParamsPageable(LocalDateTime
* @return {@code true} if the code is already in use, {@code false} otherwise.
* @throws OHServiceException
*/
public boolean isCodePresent(Integer id) throws OHServiceException {
public boolean isCodePresent(int id) throws OHServiceException {
return repository.existsById(id);
}

Expand All @@ -191,7 +191,7 @@ public MedicalInventory getInventoryByReference(String reference) throws OHServ
* @return {@link MedicalInventory}. It could be {@code null}.
* @throws OHServiceException
*/
public MedicalInventory getInventoryById(Integer inventoryId) throws OHServiceException {
public MedicalInventory getInventoryById(int inventoryId) throws OHServiceException {
Optional<MedicalInventory> inventory = repository.findById(inventoryId);
if (inventory.isPresent()) {
return inventory.get();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public List<MedicalInventoryRow> getMedicalInventoryRowByInventoryId(int invento
* @return {@link MedicalInventoryRow} with the specified id, {@code null} otherwise.
* @throws OHServiceException
*/
public Optional<MedicalInventoryRow> getMedicalInventoryRowById(Integer id) throws OHServiceException {
public Optional<MedicalInventoryRow> getMedicalInventoryRowById(int id) throws OHServiceException {
return repository.findById(id);
}

Expand All @@ -102,7 +102,7 @@ public Optional<MedicalInventoryRow> getMedicalInventoryRowById(Integer id) thro
* @return the {@link MedicalInventoryRow} object.
* @throws OHServiceException
*/
public MedicalInventoryRow getMedicalInventoryRowByMedicalCodeAndLotCode(Integer medicalCode, String lotCode) throws OHServiceException {
public MedicalInventoryRow getMedicalInventoryRowByMedicalCodeAndLotCode(int medicalCode, String lotCode) throws OHServiceException {
return repository.findByMedicalCodeAndLotCode(medicalCode, lotCode);
}
}
1 change: 0 additions & 1 deletion src/test/java/org/isf/medicalsinventory/Tests.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import static org.assertj.core.api.Assertions.assertThat;

import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;

import org.isf.OHCoreTestCase;
Expand Down

0 comments on commit 2f1f089

Please sign in to comment.