/**
   * Calculates a map with the field length of all of the attributes of the class given by the
   * getBusinessObjectClass method
   */
  protected void initializeFieldLengthMap() {
    fieldLengthMap = new HashMap<String, Integer>();
    DataDictionaryService dataDictionaryService =
        SpringContext.getBean(DataDictionaryService.class);
    List<AttributeDefinition> attributes =
        dataDictionaryService
            .getDataDictionary()
            .getBusinessObjectEntry(getBusinessObjectClass().getName())
            .getAttributes();

    for (AttributeDefinition attributeDefinition : attributes) {
      Integer fieldLength;
      fieldLength =
          dataDictionaryService.getAttributeMaxLength(
              getBusinessObjectClass(), attributeDefinition.getName());
      fieldLengthMap.put(attributeDefinition.getName(), fieldLength);
    }
  }
  private boolean verifyProposaEditableColumnsDataType(MaintenanceDocument maintenanceDocument) {
    ProposalColumnsToAlter newEditableProposalField =
        (ProposalColumnsToAlter) maintenanceDocument.getNewMaintainableObject().getDataObject();
    KcPersistenceStructureService kraPersistenceStructureService =
        KcServiceLocator.getService(KcPersistenceStructureService.class);
    DataDictionaryService dataDictionaryService =
        (DataDictionaryService) KNSServiceLocator.getDataDictionaryService();
    Map<String, String> fieldMap =
        kraPersistenceStructureService.getDBColumnToObjectAttributeMap(ProposalOverview.class);
    DataDictionaryEntry entry =
        dataDictionaryService
            .getDataDictionary()
            .getDictionaryObjectEntry(ProposalDevelopmentDocument.class.getName());

    boolean returnFlag = true;
    String editableProposalField = "";
    Integer fieldMaxLength = -1;
    Integer inputDataLength = -1;
    String proposalFieldDataType = "";
    String inputDataType = "";
    ValidationPattern validatingPattern = null;

    if (newEditableProposalField != null
        && StringUtils.isNotEmpty(newEditableProposalField.getColumnName())) {
      editableProposalField = fieldMap.get(newEditableProposalField.getColumnName());
      if (StringUtils.isNotEmpty(editableProposalField)) {
        if (entry != null) {
          AttributeDefinition attributeDefinition =
              entry.getAttributeDefinition(editableProposalField);
          if (attributeDefinition != null && attributeDefinition.hasValidationPattern()) {
            validatingPattern = attributeDefinition.getValidationPattern();
            if (validatingPattern != null) {
              proposalFieldDataType =
                  validationClassesMap.get(validatingPattern.getClass().getName());
              inputDataType = newEditableProposalField.getDataType();
              if (!proposalFieldDataType.equalsIgnoreCase(inputDataType)) {
                // throw error
                GlobalVariables.getMessageMap()
                    .putError(
                        Constants.PROPOSAL_EDITABLECOLUMN_DATATYPE,
                        KeyConstants.PROPOSAL_EDITABLECOLUMN_DATATYPE_MISMATCH);
                returnFlag = false;
              }
            }
          }
        }

        inputDataLength = newEditableProposalField.getDataLength();
        fieldMaxLength =
            dataDictionaryService.getAttributeMaxLength(
                DevelopmentProposal.class, editableProposalField);
        if (fieldMaxLength > inputDataLength) {
          // throw error
          GlobalVariables.getMessageMap()
              .putError(
                  Constants.PROPOSAL_EDITABLECOLUMN_DATALENGTH,
                  KeyConstants.PROPOSAL_EDITABLECOLUMN_DATALENGTH_MISMATCH);
          returnFlag = false;
        }
      }
    }

    return returnFlag;
  }