/**
   * Validates that the existance of the building code is consistent with the asset type
   * requirements.
   *
   * @param buildingCode
   * @param detail
   * @prarm asset
   * @return boolean
   * @deprecated this method is replaced by
   *     validateBuildingCodeAndRoomNumber(BarcodeInventoryErrorDetail, Asset)
   */
  @Deprecated
  protected boolean validateBuildingCode(
      String buildingCode, BarcodeInventoryErrorDetail detail, Asset asset) {
    boolean result = true;
    String label =
        SpringContext.getBean(DataDictionaryService.class)
            .getDataDictionary()
            .getBusinessObjectEntry(BarcodeInventoryErrorDetail.class.getName())
            .getAttributeDefinition(CamsPropertyConstants.BarcodeInventory.BUILDING_CODE)
            .getLabel();
    // String description = asset.getCapitalAssetType().getCapitalAssetTypeDescription();
    String description = asset.getCapitalAssetTypeCode();

    // if the asset has empty building code, then the BCIE should too
    if (StringUtils.isBlank(asset.getBuildingCode())) {
      if (StringUtils.isNotBlank(buildingCode)) {
        GlobalVariables.getMessageMap()
            .putError(
                CamsPropertyConstants.BarcodeInventory.BUILDING_CODE,
                CamsKeyConstants.BarcodeInventory.ERROR_NOT_ALLOWED_FIELD,
                label,
                description);
        result &= false;
      }
    }
    // otherwise the BCIE should have a non-empty and existing active building code
    else {
      HashMap<String, Object> fields = new HashMap<String, Object>();
      fields.put(KFSPropertyConstants.CAMPUS_CODE, detail.getCampusCode());
      fields.put(KFSPropertyConstants.BUILDING_CODE, detail.getBuildingCode());
      Building building = getBusinessObjectService().findByPrimaryKey(Building.class, fields);

      if (StringUtils.isBlank(buildingCode)) {
        GlobalVariables.getMessageMap()
            .putError(
                CamsPropertyConstants.BarcodeInventory.BUILDING_CODE,
                CamsKeyConstants.BarcodeInventory.ERROR_REQUIRED_FIELD,
                label,
                description);
        result &= false;
      } else if (ObjectUtils.isNull(building)) {
        GlobalVariables.getMessageMap()
            .putError(
                CamsPropertyConstants.BarcodeInventory.BUILDING_CODE,
                CamsKeyConstants.BarcodeInventory.ERROR_INVALID_FIELD,
                label);
        result &= false;
      } else if (!building.isActive()) {
        GlobalVariables.getMessageMap()
            .putError(
                CamsPropertyConstants.BarcodeInventory.BUILDING_CODE,
                CamsKeyConstants.BarcodeInventory.ERROR_INACTIVE_FIELD,
                label);
        result &= false;
      }
    }

    return result;
  }
示例#2
0
  public List getKeyValues() {

    Collection<Building> buildings =
        SpringContext.getBean(KeyValuesService.class).findAll(Building.class);
    List<KeyValue> labels = new ArrayList<KeyValue>();
    labels.add(new ConcreteKeyValue("", ""));
    for (Building building : buildings) {
      if (building.isActive()) {
        labels.add(
            new ConcreteKeyValue(
                building.getBuildingCode(),
                building.getBuildingCode() + " - " + building.getBuildingName()));
      }
    }
    return labels;
  }
 public void templateBuilding(Building building) {
   if (ObjectUtils.isNotNull(building)) {
     this.setOffCampusIndicator(false);
     this.setBuildingCode(building.getBuildingCode());
     this.setCampusCode(building.getCampusCode());
     this.setCapitalAssetLine1Address(building.getBuildingStreetAddress());
     this.setCapitalAssetCityName(building.getBuildingAddressCityName());
     this.setCapitalAssetStateCode(building.getBuildingAddressStateCode());
     this.setCapitalAssetPostalCode(building.getBuildingAddressZipCode());
     this.setCapitalAssetCountryCode(building.getBuildingAddressCountryCode());
   }
 }
  /**
   * Validates that the existance of the building code and room number is consistent with the asset
   * type requirements.
   *
   * @param detail
   * @prarm asset
   * @return boolean
   */
  protected boolean validateBuildingCodeAndRoomNumber(
      BarcodeInventoryErrorDetail detail, Asset asset) {
    boolean result = true;

    String campusCode = detail.getCampusCode();
    String buildingCode = detail.getBuildingCode();
    String roomNumber = detail.getBuildingRoomNumber();
    String labelBuilding =
        SpringContext.getBean(DataDictionaryService.class)
            .getDataDictionary()
            .getBusinessObjectEntry(BarcodeInventoryErrorDetail.class.getName())
            .getAttributeDefinition(CamsPropertyConstants.BarcodeInventory.BUILDING_CODE)
            .getLabel();
    String labelRoom =
        SpringContext.getBean(DataDictionaryService.class)
            .getDataDictionary()
            .getBusinessObjectEntry(BarcodeInventoryErrorDetail.class.getName())
            .getAttributeDefinition(CamsPropertyConstants.BarcodeInventory.BUILDING_ROOM_NUMBER)
            .getLabel();

    String assetTypeCode = asset.getCapitalAssetTypeCode();
    AssetType assetType = asset.getCapitalAssetType();

    // retrieve building
    HashMap<String, Object> fields = new HashMap<String, Object>();
    fields.put(KFSPropertyConstants.CAMPUS_CODE, campusCode);
    fields.put(KFSPropertyConstants.BUILDING_CODE, buildingCode);
    Building building = getBusinessObjectService().findByPrimaryKey(Building.class, fields);

    // retrieve room
    fields.put(KFSPropertyConstants.BUILDING_ROOM_NUMBER, roomNumber);
    Room room = getBusinessObjectService().findByPrimaryKey(Room.class, fields);

    // if movingIndicator is true and requiredBuildingIndicator is false, then both building and
    // room are required
    if (assetType.isMovingIndicator() && !assetType.isRequiredBuildingIndicator()) {
      // check building
      if (StringUtils.isBlank(buildingCode)) {
        GlobalVariables.getMessageMap()
            .putError(
                CamsPropertyConstants.BarcodeInventory.BUILDING_CODE,
                CamsKeyConstants.BarcodeInventory.ERROR_REQUIRED_FIELD,
                labelBuilding,
                assetTypeCode);
        result &= false;
      } else if (ObjectUtils.isNull(building)) {
        GlobalVariables.getMessageMap()
            .putError(
                CamsPropertyConstants.BarcodeInventory.BUILDING_CODE,
                CamsKeyConstants.BarcodeInventory.ERROR_INVALID_FIELD,
                labelBuilding);
        result &= false;
      } else if (!building.isActive()) {
        GlobalVariables.getMessageMap()
            .putError(
                CamsPropertyConstants.BarcodeInventory.BUILDING_CODE,
                CamsKeyConstants.BarcodeInventory.ERROR_INACTIVE_FIELD,
                labelBuilding);
        result &= false;
      }

      // check room
      if (StringUtils.isBlank(roomNumber)) {
        GlobalVariables.getMessageMap()
            .putError(
                CamsPropertyConstants.BarcodeInventory.BUILDING_ROOM_NUMBER,
                CamsKeyConstants.BarcodeInventory.ERROR_REQUIRED_FIELD,
                labelRoom,
                assetTypeCode);
        result &= false;
      } else if (ObjectUtils.isNull(room)) {
        GlobalVariables.getMessageMap()
            .putError(
                CamsPropertyConstants.BarcodeInventory.BUILDING_ROOM_NUMBER,
                CamsKeyConstants.BarcodeInventory.ERROR_INVALID_FIELD,
                labelRoom);
        result = false;
      } else if (!room.isActive()) {
        GlobalVariables.getMessageMap()
            .putError(
                CamsPropertyConstants.BarcodeInventory.BUILDING_ROOM_NUMBER,
                CamsKeyConstants.BarcodeInventory.ERROR_INACTIVE_FIELD,
                labelRoom);
        result &= false;
      }
    }

    // if movingIndicator is false and requiredBuildingIndicator is true, then building is required
    // while room is not allowed
    else if (!assetType.isMovingIndicator() && assetType.isRequiredBuildingIndicator()) {
      // check building
      if (StringUtils.isBlank(buildingCode)) {
        GlobalVariables.getMessageMap()
            .putError(
                CamsPropertyConstants.BarcodeInventory.BUILDING_CODE,
                CamsKeyConstants.BarcodeInventory.ERROR_REQUIRED_FIELD,
                labelBuilding,
                assetTypeCode);
        result &= false;
      } else if (ObjectUtils.isNull(building)) {
        GlobalVariables.getMessageMap()
            .putError(
                CamsPropertyConstants.BarcodeInventory.BUILDING_CODE,
                CamsKeyConstants.BarcodeInventory.ERROR_INVALID_FIELD,
                labelBuilding);
        result &= false;
      } else if (!building.isActive()) {
        GlobalVariables.getMessageMap()
            .putError(
                CamsPropertyConstants.BarcodeInventory.BUILDING_CODE,
                CamsKeyConstants.BarcodeInventory.ERROR_INACTIVE_FIELD,
                labelBuilding);
        result &= false;
      }

      // check room
      if (StringUtils.isNotBlank(roomNumber)) {
        GlobalVariables.getMessageMap()
            .putError(
                CamsPropertyConstants.BarcodeInventory.BUILDING_ROOM_NUMBER,
                CamsKeyConstants.BarcodeInventory.ERROR_NOT_ALLOWED_FIELD,
                labelRoom,
                assetTypeCode);
        result &= false;
      }
    }

    // if both movingIndicator and requiredBuildingIndicator are false, then neither building nor
    // room is allowed
    else if (!assetType.isMovingIndicator() && !assetType.isRequiredBuildingIndicator()) {
      // check building
      if (StringUtils.isNotBlank(buildingCode)) {
        GlobalVariables.getMessageMap()
            .putError(
                CamsPropertyConstants.BarcodeInventory.BUILDING_CODE,
                CamsKeyConstants.BarcodeInventory.ERROR_NOT_ALLOWED_FIELD,
                labelBuilding,
                assetTypeCode);
        result &= false;
      }

      // check room
      if (StringUtils.isNotBlank(roomNumber)) {
        GlobalVariables.getMessageMap()
            .putError(
                CamsPropertyConstants.BarcodeInventory.BUILDING_ROOM_NUMBER,
                CamsKeyConstants.BarcodeInventory.ERROR_NOT_ALLOWED_FIELD,
                labelRoom,
                assetTypeCode);
        result &= false;
      }
    }

    return result;
  }