Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public Pair<IotPermission, Boolean> getValidPermissionPair(String qrCode, Entrance entrance) {
- List<IotPermission> allPermissions = permissionRepository.findAllByQrCode(qrCode);
- List<IotPermission> permissions = entrance.getEntranceLabel().contains("IN")
- ? Utils.validateEntrancePossibility(allPermissions) : allPermissions;
- IotPermission permission = null;
- boolean isCarparkFound = false;
- boolean ifCountShouldBeIncremented = true;
- // check valid permission
- Integer carparkId = entrance.getGatewayRef().getCarParkRef().getId();
- for (IotPermission perm : permissions) {
- if (perm.isCarparkValid(carparkId)) {
- log.debug("CARPARK_FOUND");
- isCarparkFound = true;
- permission = perm;
- break;
- }
- }
- // check permission for parent carpark -> don't increment counter here
- if (!isCarparkFound) {
- Integer parentCarpark = entrance.getGatewayRef().getCarParkRef().getParentCarParkRef();
- for (IotPermission perm : permissions) {
- if (perm.isCarparkValid(parentCarpark)) {
- log.debug("PARENT_CARPARK_FOUND");
- ifCountShouldBeIncremented = false;
- permission = perm;
- break;
- }
- }
- }
- Pair<IotPermission, Boolean> result = new Pair<>(permission, ifCountShouldBeIncremented);
- log.debug("COUNTER_UPDATE_STATUS: {}; PERMISSION: {}", ifCountShouldBeIncremented, permission);
- return result;
- }
- @Data
- @Builder
- @NoArgsConstructor
- @AllArgsConstructor
- public final class Pair<K, V> {
- private K key;
- private V value;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement