@Override public String getBarcodeExtraInfo() { return getDescription(); }
@Override public int getFreeCount() { return getPositionCount() - getTubeCount(); }
/** * Construct new Box using Security Profile owned by a given User * * @param User user */ public BoxImpl(User user) { setSecurityProfile(new SecurityProfile(user)); }
@Override public boolean isFreePosition(String position) { validate(position); return boxPositions.get(position) == null; }
public static Box to(@Nonnull BoxDto from) { Box to = new BoxImpl(); if (from.getId() != null) to.setId(from.getId()); to.setAlias(from.getAlias()); to.setDescription(from.getDescription()); to.setIdentificationBarcode(from.getIdentificationBarcode()); to.setLocationBarcode(from.getLocationBarcode() == null ? "" : from.getLocationBarcode()); if (from.getUseId() != null) { BoxUse use = new BoxUse(); use.setId(from.getUseId()); to.setUse(use); } if (from.getSizeId() != null) { BoxSize size = new BoxSize(); size.setId(from.getSizeId()); to.setSize(size); } if (from.getStorageLocationId() != null) { to.setStorageLocation(new StorageLocation()); to.getStorageLocation().setId(from.getStorageLocationId()); } if (!isStringEmptyOrNull(from.getStorageLocationBarcode())) { if (to.getStorageLocation() == null) { to.setStorageLocation(new StorageLocation()); } to.getStorageLocation().setIdentificationBarcode(from.getStorageLocationBarcode()); } return to; }
@Override public String getBarcodeSizeInfo() { return getSize().getRowsByColumns(); }
/** * Construct new Box with defaults, and an empty SecurityProfile */ public BoxImpl() { setSecurityProfile(new SecurityProfile()); }
private void validate(String position) { if (!position.matches("[A-Z][0-9][0-9]")) throw new IllegalArgumentException("Position " + position + " does not match [A-Z][0-9][0-9]"); if (BoxUtils.fromRowChar(position.charAt(0)) >= getSize().getRows()) throw new IndexOutOfBoundsException("Row letter too large!" + position); int col = BoxUtils.tryParseInt(position.substring(1, 3)); if (col <= 0 || col > getSize().getColumns()) throw new IndexOutOfBoundsException("Column value too large!"); }
@Override public boolean isValidPosition(String position) { if (!position.matches("[A-Z][0-9][0-9]")) return false; if (BoxUtils.fromRowChar(position.charAt(0)) >= getSize().getRows()) return false; int col = BoxUtils.tryParseInt(position.substring(1, 3)); if (col < 0 || col > getSize().getColumns()) return false; // columns are zero-indexed in database return true; }