/**
   * This method to check whether 'lookupreturn' is specified if lookupclass is selected.
   *
   * @param maintenanceDocument
   * @return
   */
  private boolean checkLookupReturn(MaintenanceDocument maintenanceDocument) {
    if (LOG.isDebugEnabled()) {
      LOG.debug(
          "New maintainable is: " + maintenanceDocument.getNewMaintainableObject().getClass());
    }
    ProposalColumnsToAlter newEditableProposalField =
        (ProposalColumnsToAlter) maintenanceDocument.getNewMaintainableObject().getDataObject();

    if (StringUtils.isNotBlank(newEditableProposalField.getLookupClass())) {
      GlobalVariables.getUserSession()
          .addObject(
              Constants.LOOKUP_CLASS_NAME, (Object) newEditableProposalField.getLookupClass());
    }
    if (StringUtils.isNotBlank(newEditableProposalField.getLookupClass())
        && StringUtils.isBlank(newEditableProposalField.getLookupReturn())) {
      GlobalVariables.getMessageMap()
          .putError(
              Constants.PROPOSAL_EDITABLECOLUMN_LOOKUPRETURN,
              RiceKeyConstants.ERROR_REQUIRED,
              new String[] {"Lookup Return"});
      return false;
    }

    return true;
  }
  /**
   * This method will create a maintenance document for CG account create, set its description and
   * then sets the account business object in it. The document will then be tried to route, save or
   * blanket approve automatically based on the system parameter. If successful, the method returns
   * the newly created document number to the caller.
   *
   * @return documentNumber returns the documentNumber
   * @see
   *     org.kuali.kfs.coa.document.service.CreateAccountService#createAutomaticCGAccountMaintenanceDocument()
   */
  protected void createAutomaticCGAccountMaintenanceDocument(
      Account account, AccountCreationStatusDTO accountCreationStatus) {

    // create a new maintenance document
    MaintenanceDocument maintenanceAccountDocument =
        (MaintenanceDocument) createCGAccountMaintenanceDocument(accountCreationStatus);

    if (ObjectUtils.isNotNull(maintenanceAccountDocument)) {
      // set document header description...
      maintenanceAccountDocument
          .getDocumentHeader()
          .setDocumentDescription(
              KcConstants.AccountCreationService
                  .AUTOMATCICG_ACCOUNT_MAINTENANCE_DOCUMENT_DESCRIPTION);

      // set the account object in the maintenance document.
      maintenanceAccountDocument.getNewMaintainableObject().setBusinessObject(account);
      maintenanceAccountDocument
          .getNewMaintainableObject()
          .setMaintenanceAction(KRADConstants.MAINTENANCE_NEW_ACTION);
      // the maintenance document will now be routed based on the system parameter value for
      // routing.
      createRouteAutomaticCGAccountDocument(maintenanceAccountDocument, accountCreationStatus);
    }
  }
  /*
   * check if custom attribute id is valid
   */
  private boolean checkCustomAttributeExist(MaintenanceDocument maintenanceDocument) {

    if (LOG.isDebugEnabled()) {
      LOG.debug(
          "new maintainable is: " + maintenanceDocument.getNewMaintainableObject().getClass());
    }
    CustomAttributeDocument newCustomAttributeDocument =
        (CustomAttributeDocument) maintenanceDocument.getNewMaintainableObject().getDataObject();

    if (newCustomAttributeDocument.getCustomAttributeId() != null) {
      Map<String, String> queryMap = new HashMap<String, String>();
      queryMap.put("id", newCustomAttributeDocument.getCustomAttributeId().toString());

      if (getBoService().countMatching(CustomAttribute.class, queryMap) == 0) {
        GlobalVariables.getMessageMap()
            .putError(
                Constants.DOCUMENT_NEWMAINTAINABLEOBJECT_CUSTOM_ATTRIBUTE_ID,
                KeyConstants.ERROR_INVALID_CUSTOM_ATT_ID,
                new String[] {newCustomAttributeDocument.getCustomAttributeId().toString()});
        return false;
      }
    }

    return true;
  }
  /**
   * @see
   *     org.kuali.rice.kns.maintenance.KualiMaintainableImpl#processAfterEdit(org.kuali.rice.kns.document.MaintenanceDocument,
   *     java.util.Map)
   */
  @Override
  public void processAfterEdit(MaintenanceDocument document, Map<String, String[]> parameters) {
    List<ErrorMessage> errorMessages = null;
    AgencyStagingData agency =
        (AgencyStagingData) document.getNewMaintainableObject().getBusinessObject();

    if (TemConstants.ExpenseImportTypes.IMPORT_BY_TRIP.equals(agency.getImportBy())) {
      errorMessages = getExpenseImportByTripService().validateAgencyData(agency);
    } else if (TemConstants.ExpenseImportTypes.IMPORT_BY_TRAVELLER.equals(agency.getImportBy())) {
      errorMessages = getExpenseImportByTravelerService().validateAgencyData(agency);
    }

    if (errorMessages.isEmpty()) {
      agency.setErrorCode(AgencyStagingDataErrorCodes.AGENCY_NO_ERROR);
    }

    MessageMap messageMap = GlobalVariables.getMessageMap();
    for (ErrorMessage message : errorMessages) {
      messageMap.putError(
          KFSConstants.GLOBAL_ERRORS, message.getErrorKey(), message.getMessageParameters());
    }

    updateCreditCardAgency(
        (AgencyStagingData) document.getNewMaintainableObject().getBusinessObject());

    super.processAfterEdit(document, parameters);
  }
  /**
   * This method is to check the existence of budgetcategorycode in table.
   *
   * @param maintenanceDocument
   * @return
   */
  private boolean checkExistence(MaintenanceDocument maintenanceDocument) {

    boolean valid = true;
    if (LOG.isDebugEnabled()) {
      LOG.debug(
          "new maintainable is: " + maintenanceDocument.getNewMaintainableObject().getClass());
    }
    // shared by budgetcategorymapping & costelement
    // TODO : refactoring this - must have a better way to handle this sharing
    String budgetCategoryCode;
    if (maintenanceDocument.getNewMaintainableObject().getDataObject()
        instanceof BudgetCategoryMapping) {
      BudgetCategoryMapping budgetCategoryMapping =
          (BudgetCategoryMapping) maintenanceDocument.getNewMaintainableObject().getDataObject();
      budgetCategoryCode = budgetCategoryMapping.getBudgetCategoryCode();
    } else {
      CostElement costElement =
          (CostElement) maintenanceDocument.getNewMaintainableObject().getDataObject();
      budgetCategoryCode = costElement.getBudgetCategoryCode();
    }
    Map pkMap = new HashMap();
    pkMap.put("code", budgetCategoryCode);
    valid = checkExistenceFromTable(BudgetCategory.class, pkMap, "code", "Budget Category");

    return valid;
  }
  /**
   * This method to check whether it is ok to inactivate a custom attribute document.
   *
   * @param maintenanceDocument
   * @return
   */
  private boolean checkOkToInActivate(MaintenanceDocument maintenanceDocument) {

    if (LOG.isDebugEnabled()) {
      LOG.debug(
          "new maintainable is: " + maintenanceDocument.getNewMaintainableObject().getClass());
    }
    CustomAttributeDocument newCustomAttributeDocument =
        (CustomAttributeDocument) maintenanceDocument.getNewMaintainableObject().getDataObject();

    return true;
  }
  /**
   * @see
   *     org.kuali.rice.kns.maintenance.rules.MaintenanceDocumentRuleBase#processCustomRouteDocumentBusinessRules(org.kuali.rice.kns.document.MaintenanceDocument)
   */
  public boolean processCustomRouteDocumentBusinessRules(MaintenanceDocument document) {
    final ValidAwardBasisPayment validAwardBasisPayment =
        (ValidAwardBasisPayment) document.getNewMaintainableObject().getDataObject();

    if (!document
        .getNewMaintainableObject()
        .getMaintenanceAction()
        .equals(KRADConstants.MAINTENANCE_DELETE_ACTION)) {
      return validateUniqueueCodes(
          validAwardBasisPayment.getAwardType(), validAwardBasisPayment.getBasisOfPayment());
    } else {
      return true;
    }
  }
  /**
   * Set value for newACIModel.
   *
   * @param document the newACIModel Maintenance document
   */
  private void setupConvenienceObjects(MaintenanceDocument document) {

    // setup newACIModel convenience objects, make sure all possible sub-objects are populated
    newACIModel =
        (AutomatedCashInvestmentModel) document.getNewMaintainableObject().getBusinessObject();
    newACIModel.refreshNonUpdateableReferences();
  }
  /**
   * Update Traveler information (name, id, network id) after looking up the Profile
   *
   * @param refreshCaller
   * @param fieldValues
   * @param document
   */
  protected void updateFieldsFromProfileRefresh(
      String refreshCaller, Map fieldValues, MaintenanceDocument document) {

    if (StringUtils.isNotEmpty(refreshCaller)
        && refreshCaller.equals(TemConstants.TEM_PROFILE_LOOKUPABLE)) {

      AgencyStagingDataMaintainable newMaintainable =
          (AgencyStagingDataMaintainable) document.getNewMaintainableObject();
      AgencyStagingData agencyData = (AgencyStagingData) newMaintainable.getBusinessObject();

      TemProfile profile = agencyData.getProfile();
      if (ObjectUtils.isNotNull(profile)) {
        if (StringUtils.isNotEmpty(profile.getEmployeeId())) {
          agencyData.setTravelerId(profile.getEmployeeId());
        } else if (StringUtils.isNotEmpty(profile.getCustomerNumber())) {
          agencyData.setTravelerId(profile.getCustomerNumber());
        } else {
          agencyData.setTravelerId("");
        }

        agencyData.setTravelerName(profile.getFirstName() + " " + profile.getLastName());

        if (ObjectUtils.isNotNull(profile.getPrincipal())) {
          agencyData.setTravelerNetworkId(profile.getPrincipal().getPrincipalName());
        } else {
          agencyData.setTravelerNetworkId("");
        }
      }
    }
  }
Example #10
0
  @SuppressWarnings("deprecation")
  public void testApplyGlobalChanges1() throws WorkflowException {

    MaintenanceDocument document;
    document =
        (MaintenanceDocument)
            SpringContext.getBean(DocumentService.class).getNewDocument(GLOBAL_DELEGATE_TYPENAME);
    document.getDocumentHeader().setDocumentDescription("blah");

    // get local references to the Maintainable and the BO
    Maintainable newMaintainable = document.getNewMaintainableObject();
    AccountDelegateGlobal bo = (AccountDelegateGlobal) newMaintainable.getBusinessObject();
    String finDocNumber = document.getDocumentHeader().getDocumentNumber();

    // create the lists
    List<AccountDelegateGlobalDetail> changeDocuments = new ArrayList();
    List<AccountGlobalDetail> accountDetails = new ArrayList();

    // add a delegate change document
    AccountDelegateGlobalDetail change = new AccountDelegateGlobalDetail();
    change.setDocumentNumber(finDocNumber);
    change.setAccountDelegatePrimaryRoutingIndicator(true);
    change.setAccountDelegateStartDate(START_DATE_1);
    change.setAccountDelegateUniversalId(DELEGATE_ID_1);
    change.setApprovalFromThisAmount(FROM_AMOUNT_1);
    change.setApprovalToThisAmount(TO_AMOUNT_1);
    change.setFinancialDocumentTypeCode(DOC_TYPE_ALL);
    changeDocuments.add(change);

    bo.setDelegateGlobals(changeDocuments);

    // add account change detail records
    AccountGlobalDetail account;
    account = new AccountGlobalDetail();
    account.setDocumentNumber(finDocNumber);
    account.setChartOfAccountsCode(COA1);
    account.setAccountNumber(ACCOUNT1);
    accountDetails.add(account);

    account = new AccountGlobalDetail();
    account.setDocumentNumber(finDocNumber);
    account.setChartOfAccountsCode(COA1);
    account.setAccountNumber(ACCOUNT2);
    accountDetails.add(account);

    account = new AccountGlobalDetail();
    account.setDocumentNumber(finDocNumber);
    account.setChartOfAccountsCode(COA1);
    account.setAccountNumber(ACCOUNT3);
    accountDetails.add(account);

    bo.setAccountGlobalDetails(accountDetails);

    GlobalBusinessObject gbo = (GlobalBusinessObject) bo;
    List<PersistableBusinessObject> persistables = gbo.generateGlobalChangesToPersist();

    assertFalse("The list should not be empty.", persistables.isEmpty());
    assertEquals("There should be three output records.", 3, persistables.size());
  }
  private boolean checkUniqueness(MaintenanceDocument document) {
    boolean isValid = true;

    CoiNoteType newCoiNoteType = (CoiNoteType) document.getNewMaintainableObject().getDataObject();

    isValid &= checkSortIdUniqueness(newCoiNoteType);
    isValid &= checkDescriptionUniqueness(newCoiNoteType);

    return isValid;
  }
  /**
   * This calls the {@link
   * OrganizationReversionPreRules#copyKeyAttributesToDetail(OrganizationReversion)}
   *
   * @see
   *     org.kuali.ole.coa.document.validation.impl.MaintenancePreRulesBase#doCustomPreRules(org.kuali.rice.kns.document.MaintenanceDocument)
   */
  @Override
  protected boolean doCustomPreRules(MaintenanceDocument document) {

    OrganizationReversion orgRev =
        (OrganizationReversion) document.getNewMaintainableObject().getBusinessObject();
    // copy year and chart to detail records
    copyKeyAttributesToDetail(orgRev);
    copyDefaultObjectcodeIfNoCarryForwardByObjectCode(orgRev);
    return true;
  }
 @SuppressWarnings("deprecation")
 private boolean isSignatureIdValid(MaintenanceDocument document) {
   boolean isValid = true;
   PersonSignatureModule personSignatureModule =
       (PersonSignatureModule) document.getNewMaintainableObject().getDataObject();
   Map<String, Long> keyMap = new HashMap<String, Long>();
   keyMap.put("personSignatureId", personSignatureModule.getPersonSignatureId());
   isValid =
       checkExistenceFromTable(
           PersonSignature.class, keyMap, "personSignatureId", "Person Signature Id");
   return isValid;
 }
  /**
   * This method validates the question status. The status can not be inactive when a questionnaire
   * is using the question.
   *
   * @param maintenanceDocument - the maintenance document of the question to be validated
   * @return true if all validation has passed, false otherwise
   */
  private boolean validateQuestionUsage(MaintenanceDocument maintenanceDocument) {
    Question question = (Question) maintenanceDocument.getNewMaintainableObject().getDataObject();

    if (!"A".equals(question.getStatus())
        && getQuestionService().isQuestionUsed(question.getQuestionId())) {
      GlobalVariables.getMessageMap()
          .putError(
              Constants.QUESTION_DOCUMENT_FIELD_STATUS, KeyConstants.ERROR_QUESTION_STATUS_IN_USE);
      return false;
    } else {
      return true;
    }
  }
  /**
   * @see
   *     org.kuali.rice.krad.document.authorization.MaintenanceDocumentPresentationControllerBase#getConditionallyReadOnlyPropertyNames(org.kuali.rice.kns.document.MaintenanceDocument)
   */
  @Override
  public Set<String> getConditionallyReadOnlyPropertyNames(MaintenanceDocument document) {

    Set<String> fields = super.getConditionallyReadOnlyPropertyNames(document);

    if (KRADConstants.MAINTENANCE_EDIT_ACTION.equals(
        document.getNewMaintainableObject().getMaintenanceAction())) {
      // a class code, once established as a certain class code type cannot change to a different
      // class code type
      fields.add(EndowPropertyConstants.CLASS_CODE_TYPE);
    }
    return fields;
  }
  /**
   * Override the getSections method on this maintainable so that the active field can be set to
   * read-only when a CINV doc has been created with this Milestone Schedule and Milestones
   */
  @Override
  public List getSections(MaintenanceDocument document, Maintainable oldMaintainable) {
    List<Section> sections = super.getSections(document, oldMaintainable);
    MilestoneSchedule milestoneSchedule =
        (MilestoneSchedule) document.getNewMaintainableObject().getBusinessObject();
    Long proposalNumber = milestoneSchedule.getProposalNumber();

    for (Section section : sections) {
      String sectionId = section.getSectionId();
      if (sectionId.equalsIgnoreCase(ArPropertyConstants.MILESTONES_SECTION)) {
        prepareMilestonesTab(section, proposalNumber);
      }
    }

    return sections;
  }
  /**
   * Creates a searchable attribute value for the given property name out of the document XML
   *
   * @param propertyName the name of the property to return
   * @param businessObjectClass the class of the business object maintained
   * @param document the document XML
   * @return a generated SearchableAttributeValue, or null if a value could not be created
   */
  protected DocumentAttribute parseSearchableAttributeValueForPrimaryKey(
      String propertyName,
      Class<? extends BusinessObject> businessObjectClass,
      MaintenanceDocument document) {

    Maintainable maintainable = document.getNewMaintainableObject();
    PersistableBusinessObject bo = maintainable.getBusinessObject();

    final Object propertyValue = ObjectUtils.getPropertyValue(bo, propertyName);
    if (propertyValue == null) return null;

    final WorkflowAttributePropertyResolutionService propertyResolutionService =
        KNSServiceLocator.getWorkflowAttributePropertyResolutionService();
    DocumentAttribute value =
        propertyResolutionService.buildSearchableAttribute(
            businessObjectClass, propertyName, propertyValue);
    return value;
  }
  /**
   * This method validates the question response type and any additional properties related to the
   * response type.
   *
   * @param maintenanceDocument - the maintenance document of the question to be validated
   * @return true if all validation has passed, false otherwise
   */
  private boolean validateQuestionResponseType(MaintenanceDocument maintenanceDocument) {
    boolean isValid = true;

    Question question = (Question) maintenanceDocument.getNewMaintainableObject().getDataObject();

    if (question.getQuestionTypeId() == null) {
      isValid &= false;
      GlobalVariables.getMessageMap()
          .putError(
              Constants.QUESTION_DOCUMENT_FIELD_QUESTION_TYPE_ID,
              KeyConstants.ERROR_QUESTION_RESPONSE_TYPE_NOT_SPECIFIED);
    } else {
      switch (question.getQuestionTypeId()) {
        case Constants.QUESTION_RESPONSE_TYPE_YES_NO:
          isValid &= validateResponseTypeYesNo(question);
          break;
        case Constants.QUESTION_RESPONSE_TYPE_YES_NO_NA:
          isValid &= validateResponseTypeYesNoNa(question);
          break;
        case Constants.QUESTION_RESPONSE_TYPE_NUMBER:
          isValid &= validateResponseTypeNumber(question);
          break;
        case Constants.QUESTION_RESPONSE_TYPE_DATE:
          isValid &= validateResponseTypeDate(question);
          break;
        case Constants.QUESTION_RESPONSE_TYPE_TEXT:
          isValid &= validateResponseTypeText(question);
          break;
        case Constants.QUESTION_RESPONSE_TYPE_LOOKUP:
          isValid &= validateResponseTypeLookup(question);
          break;
        default:
          isValid &= false;
          GlobalVariables.getMessageMap()
              .putError(
                  Constants.QUESTION_DOCUMENT_FIELD_QUESTION_TYPE_ID,
                  KeyConstants.ERROR_QUESTION_RESPONSE_TYPE_INVALID);
          break;
      }
    }

    return isValid;
  }
  /**
   * This method executes the DataDictionary Validation against the document. It's an exact replica
   * of MaintenanceDocumentRuleBase with the exception of the error path being
   * "document.newMaintainableObject.businessObject" instead of "document.newMaintainableObject".
   * TODO: Find a better solution as this duplicates code and is prone to failure if the rice
   * framework changes, specifically its dataDictionaryValidate method.
   *
   * @param document
   * @return true if it passes DD validation, false otherwise
   */
  @Override
  protected boolean dataDictionaryValidate(MaintenanceDocument document) {
    LOG.debug("MaintenanceDocument validation beginning");

    // explicitly put the errorPath that the dictionaryValidationService requires
    GlobalVariables.getMessageMap().addToErrorPath("document.newMaintainableObject.businessObject");

    // document must have a newMaintainable object
    Maintainable newMaintainable = document.getNewMaintainableObject();
    if (newMaintainable == null) {
      GlobalVariables.getMessageMap().removeFromErrorPath("document.newMaintainableObject");
      throw new ValidationException(
          "Maintainable object from Maintenance Document '"
              + document.getDocumentTitle()
              + "' is null, unable to proceed.");
    }

    // document's newMaintainable must contain an object (ie, not null)
    PersistableBusinessObject businessObject = newMaintainable.getBusinessObject();
    if (businessObject == null) {
      GlobalVariables.getMessageMap().removeFromErrorPath("document.newMaintainableObject.");
      throw new ValidationException("Maintainable's component business object is null.");
    }

    // run required check from maintenance data dictionary
    maintDocDictionaryService.validateMaintenanceRequiredFields(document);

    // check for duplicate entries in collections if necessary
    maintDocDictionaryService.validateMaintainableCollectionsForDuplicateEntries(document);

    // run the DD DictionaryValidation (non-recursive)
    dictionaryValidationService.validateBusinessObject(businessObject, false);

    // do default (ie, mandatory) existence checks
    dictionaryValidationService.validateDefaultExistenceChecks(businessObject);

    // explicitly remove the errorPath we've added
    GlobalVariables.getMessageMap()
        .removeFromErrorPath("document.newMaintainableObject.businessObject");

    LOG.debug("MaintenanceDocument validation ending");
    return true;
  }
  @Override
  public void refresh(String refreshCaller, Map fieldValues, MaintenanceDocument document) {

    super.refresh(refreshCaller, fieldValues, document);

    if (StringUtils.isNotEmpty(refreshCaller)
        && refreshCaller.equalsIgnoreCase("achPayeeLookupable")) {
      PayeeACHAccount payeeAchAccount =
          (PayeeACHAccount) document.getNewMaintainableObject().getBusinessObject();
      String payeeIdNumber = payeeAchAccount.getPayeeIdNumber();
      String payeeIdentifierTypeCode = payeeAchAccount.getPayeeIdentifierTypeCode();

      if (StringUtils.isNotEmpty(payeeAchAccount.getPayeeIdNumber())) {
        // for Employee, retrieve from Person table by employee ID
        if (StringUtils.equalsIgnoreCase(payeeIdentifierTypeCode, PayeeIdTypeCodes.EMPLOYEE)) {
          Person person =
              SpringContext.getBean(PersonService.class).getPersonByEmployeeId(payeeIdNumber);
          if (ObjectUtils.isNotNull(person)) {
            payeeAchAccount.setPayeeEmailAddress(person.getEmailAddress());
          }
        }
        // for Entity, retrieve from Entity table by entity ID then from Person table
        else if (StringUtils.equalsIgnoreCase(payeeIdentifierTypeCode, PayeeIdTypeCodes.ENTITY)) {
          if (ObjectUtils.isNotNull(payeeIdNumber)) {
            EntityDefault entity =
                KimApiServiceLocator.getIdentityService().getEntityDefault(payeeIdNumber);
            if (ObjectUtils.isNotNull(entity)) {
              List<Principal> principals = entity.getPrincipals();
              if (principals.size() > 0 && ObjectUtils.isNotNull(principals.get(0))) {
                String principalId = principals.get(0).getPrincipalId();
                Person person = SpringContext.getBean(PersonService.class).getPerson(principalId);
                if (ObjectUtils.isNotNull(person)) {
                  payeeAchAccount.setPayeeEmailAddress(person.getEmailAddress());
                }
              }
            }
          }
        }
      }
    }
  }
  /**
   * Units cannot be moved to its own descendants. This method returns false if it is moving to its
   * own descendants.
   *
   * @param maintenanceDocument
   * @return
   */
  private boolean moveUnit(MaintenanceDocument maintenanceDocument) {

    boolean valid = true;
    Unit unit = (Unit) maintenanceDocument.getNewMaintainableObject().getDataObject();
    String unitNumber = unit.getUnitNumber();
    String parentUnitNumber = unit.getParentUnitNumber();
    List<Unit> allSubUnits =
        KcServiceLocator.getService(UnitService.class).getAllSubUnits(unitNumber);
    for (Unit subunits : allSubUnits) {
      if (subunits.getUnitNumber().equals(parentUnitNumber)) {
        GlobalVariables.getMessageMap()
            .putError(
                "document.newMaintainableObject.parentUnitNumber",
                KeyConstants.MOVE_UNIT_OWN_DESCENDANTS,
                new String[] {unit.getParentUnitNumber(), unit.getParentUnitNumber()});
        valid = false;
      }
    }

    return valid;
  }
 @SuppressWarnings("deprecation")
 private boolean isNotDuplicateSignatureId(MaintenanceDocument document) {
   boolean isValid = true;
   PersonSignatureModule personSignatureModule =
       (PersonSignatureModule) document.getNewMaintainableObject().getDataObject();
   Map<String, Object> fieldValues = new HashMap<String, Object>();
   fieldValues.put("personSignatureId", personSignatureModule.getPersonSignatureId());
   fieldValues.put("moduleCode", personSignatureModule.getModuleCode());
   if (document.isNew()) {
     isValid = getBoService().countMatching(PersonSignatureModule.class, fieldValues) == 0;
   } else if (document.isEdit()) {
     isValid = isRecordUpdateValid(fieldValues, personSignatureModule);
   }
   if (!isValid) {
     ErrorReporter errorReporter = KcServiceLocator.getService(ErrorReporter.class);
     errorReporter.reportError(
         "document.newMaintainableObject.personSignatureId",
         PERSON_SIGNATURE_ID_INVALID_ERROR_KEY,
         new String[] {});
   }
   return isValid;
 }
Example #23
0
  public void testApplyGlobalChanges_Empty() throws WorkflowException {

    MaintenanceDocument document;
    document =
        (MaintenanceDocument)
            SpringContext.getBean(DocumentService.class).getNewDocument(GLOBAL_DELEGATE_TYPENAME);
    document.getDocumentHeader().setDocumentDescription("blah");

    // get local references to the Maintainable and the BO
    Maintainable newMaintainable = document.getNewMaintainableObject();
    AccountDelegateGlobal bo = (AccountDelegateGlobal) newMaintainable.getBusinessObject();

    List<AccountDelegateGlobalDetail> changeDocuments = new ArrayList();
    bo.setDelegateGlobals(changeDocuments);

    List<AccountGlobalDetail> accountDetails = new ArrayList();
    bo.setAccountGlobalDetails(accountDetails);

    GlobalBusinessObject gbo = (GlobalBusinessObject) bo;
    List<PersistableBusinessObject> persistables = gbo.generateGlobalChangesToPersist();

    assertTrue("Global Changes returned should be an empty list.", persistables.isEmpty());
  }
  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;
  }
 /**
  * @see
  *     org.kuali.rice.kns.maintenance.KualiMaintainableImpl#processAfterEdit(org.kuali.rice.kns.document.MaintenanceDocument,
  *     java.util.Map)
  */
 @Override
 public void processAfterPost(MaintenanceDocument document, Map<String, String[]> parameters) {
   updateCreditCardAgency(
       (AgencyStagingData) document.getNewMaintainableObject().getBusinessObject());
   super.processAfterPost(document, parameters);
 }