private void assertFieldProperties(Field field, String keyName, String className) {
   assertEquals(field.getFieldConversions(), keyName + Constants.COLON + field.getPropertyName());
   assertTrue(field.isFieldDirectInquiryEnabled());
   assertEquals(field.getLookupParameters(), field.getPropertyName() + Constants.COLON + keyName);
   assertEquals(field.getInquiryParameters(), field.getPropertyName() + Constants.COLON + keyName);
   assertEquals(field.getQuickFinderClassNameImpl(), className);
 }
  /**
   * To disable the search icon for 'title' & 'scheduleddate' fields. These fields are referencing
   * to reference objects' fields.
   *
   * @see org.kuali.rice.kns.lookup.AbstractLookupableHelperServiceImpl#getRows()
   */
  @Override
  public List<Row> getRows() {
    List<Row> rows = super.getRows();
    for (Row row : rows) {
      for (Field field : row.getFields()) {
        if (PROTOCOL_TITLE.equals(field.getPropertyName())
            || COMMITTEE_SCHEDULE_SCHEDULE_DATE.equals(field.getPropertyName())) {

          field.setQuickFinderClassNameImpl(KRADConstants.EMPTY_STRING);
        }
      }
    }
    return rows;
  }
  /**
   * Sets the Milestone in the passed in section to be readonly if it has been copied to a CG
   * Invoice doc.
   *
   * @param section Milestone section to review and possibly set readonly
   * @param proposalNumber used to look for CG Invoice docs
   */
  private void prepareMilestonesTab(Section section, Long proposalNumber) {
    ContractsGrantsInvoiceDocumentService cgInvDocService =
        SpringContext.getBean(ContractsGrantsInvoiceDocumentService.class);

    for (Row row : section.getRows()) {
      for (Field field : row.getFields()) {
        if (field.getCONTAINER().equalsIgnoreCase(field.getFieldType())) {
          for (Row containerRow : field.getContainerRows()) {
            for (Field containerRowfield : containerRow.getFields()) {
              // a record is no longer editable if the bill has been copied to a CINV doc
              if (ObjectUtils.getNestedAttributePrimitive(containerRowfield.getPropertyName())
                  .matches(ArPropertyConstants.MilestoneFields.MILESTONE_IDENTIFIER)) {
                String milestoneId = containerRowfield.getPropertyValue();
                if (StringUtils.isNotEmpty(milestoneId)) {
                  if (cgInvDocService.hasMilestoneBeenCopiedToInvoice(
                      proposalNumber, milestoneId)) {
                    for (Field rowfield : row.getFields()) {
                      if (rowfield.getCONTAINER().equalsIgnoreCase(rowfield.getFieldType())) {
                        for (Row fieldContainerRow : rowfield.getContainerRows()) {
                          for (Field fieldContainerRowField : fieldContainerRow.getFields()) {
                            fieldContainerRowField.setReadOnly(true);
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  }
  @Override
  public List<Row> getRows() {

    List<Row> rows = super.getRows();
    for (Row row : rows) {
      for (Field field : row.getFields()) {
        if (field.getPropertyName().equals(USERNAME_FIELD)) {
          field.setFieldConversions(FIELD_CONVERSIONS);
        }
        if (field.getPropertyName().equals(LOG_STATUS) && isLookupToCreateProposal()) {
          field.setPropertyValue(STATUS_PENDING);
        }
      }
    }
    return rows;
  }
 /**
  * This method recurses through all the fields of the list of rows and adds each field's property
  * name to the set if it starts with Constants.MAINTENANCE_NEW_MAINTAINABLE
  *
  * @param listOfRows
  * @param errorKeys
  * @see KRADConstants#MAINTENANCE_NEW_MAINTAINABLE
  */
 protected static void addRowsToErrorKeySet(List<Row> listOfRows, Set<String> errorKeys) {
   if (listOfRows == null) {
     return;
   }
   for (Row row : listOfRows) {
     List<Field> fields = row.getFields();
     if (fields == null) {
       continue;
     }
     for (Field field : fields) {
       String fieldPropertyName = field.getPropertyName();
       if (fieldPropertyName != null
           && fieldPropertyName.startsWith(KRADConstants.MAINTENANCE_NEW_MAINTAINABLE)) {
         errorKeys.add(field.getPropertyName());
       }
       addRowsToErrorKeySet(field.getContainerRows(), errorKeys);
     }
   }
 }
 /**
  * @see
  *     org.kuali.kfs.module.ld.service.LaborInquiryOptionsService#getConsolidationField(java.util.Collection)
  */
 @Override
 public Field getConsolidationField(Collection<Row> rows) {
   for (Row row : rows) {
     for (Field field : (row.getFields())) {
       if (field.getPropertyName().equals(getConsolidationFieldName())) {
         return field;
       }
     }
   }
   return null;
 }
 /**
  * This override is reset field definitions
  *
  * @see org.kuali.core.lookup.AbstractLookupableHelperServiceImpl#getRows()
  */
 @Override
 public List<Row> getRows() {
   List<Row> rows = super.getRows();
   for (Row row : rows) {
     for (Field field : row.getFields()) {
       if (field.getPropertyName().equals(PI_NAME)) {
         super.updateLookupField(field, PI_NAME, AwardPerson.class.getName());
       }
     }
   }
   return rows;
 }
 /** @see org.kuali.rice.kns.lookup.AbstractLookupableHelperServiceImpl#getRows() */
 @Override
 public List<Row> getRows() {
   List<Row> rows = super.getRows();
   for (Row row : rows) {
     for (Field field : row.getFields()) {
       if (field.getPropertyName().equals("person.userName")) {
         field.setFieldConversions("principalName:person.userName,principalId:personId");
       }
     }
   }
   return rows;
 }
  /**
   * This method is to test getrows. The lookup fields will be updated and make sure a few of the
   * drop down fields are set as dropdown_refresh
   */
  @Test
  public void testGetRows() {

    List<Row> rows = protocolLookupableHelperServiceImpl.getRows();
    assertEquals(NUMBER_LOOKUP_CRITERIA_FIELDS, rows.size());
    for (Row row : rows) {
      for (Field field : row.getFields()) {
        if (field.getPropertyName().equals("researchAreaCode")) {
          assertDropDownField(field, "researchAreaCode", "org.kuali.kra.irb.ResearchArea");
        }
      }
    }
  }
  /**
   * Sets up the field for rendering by setting the right property name and zeroing out amounts
   * which aren't needed
   *
   * @param field the field to prepare
   * @param accountingLine the accounting line being rendered
   * @param count the count of the current line in the source lines, or null if it's a new line
   *     <p>KRAD Conversion: Customization of preparing the fields for rendering - No use of data
   *     dictionary
   */
  protected void prepareFieldForRendering(Field field, VoucherForm form, Integer count) {
    getDebitOrCreditField().setPropertyPrefix(null);

    // set the right property name
    if (count == null) {
      field.setPropertyName(getNewLineProperty());
    } else {
      final String subPropertyName = isDebit ? "debit" : "credit";
      field.setPropertyName(
          getCollectionProperty() + "[" + count.toString() + "]." + subPropertyName);
    }

    // get the value from the form
    field.setPropertyValue(ObjectUtils.getPropertyValue(form, field.getPropertyName()));
  }
 /**
  * Goes through all the rows, making sure that problematic field conversions are fixed
  *
  * <p>KRAD Conversion: Performs customization of the fields.
  */
 protected void convertOrganizationOwnerAccountField() {
   boolean foundField = false;
   int i = 0;
   while (!foundField && i < super.getRows().size()) {
     final Row r = super.getRows().get(i);
     int j = 0;
     while (!foundField && j < r.getFields().size()) {
       Field f = r.getField(j);
       if (f.getPropertyName().equals(CamsPropertyConstants.Asset.ORGANIZATION_CODE)) {
         f.setFieldConversions(fixProblematicField(f.getFieldConversions()));
         f.setLookupParameters(fixProblematicField(f.getLookupParameters()));
         foundField = true;
       }
       j += 1;
     }
     i += 1;
   }
 }
  @Test
  public void testMultiCampusRows() {
    service.setBusinessObjectClass(Unit.class);
    service.setParameterService(getMockParameterService(true));
    GlobalVariables.getUserSession()
        .addObject(MultiCampusConstants.USER_CAMPUS_CODE_KEY, (Object) CAMPUS_CODE);

    List<Row> rows = service.getRows();
    assertEquals(LOOKUP_CRITERIA_FIELD_COUNT, rows.size());
    for (Row row : rows) {
      for (Field field : row.getFields()) {
        if (field.getPropertyName().equals(CAMPUS_CODE_FIELD)) {
          assertFieldProperties(field, CAMPUS_CODE_FIELD, CAMPUS_LOOKUPABLE_CLASS_NAME);
          assertEquals(CAMPUS_CODE, field.getPropertyValue());
        }
      }
    }
  }
 /**
  * @see
  *     org.kuali.kfs.sys.document.web.RenderableElement#renderElement(javax.servlet.jsp.PageContext,
  *     javax.servlet.jsp.tagext.Tag,
  *     org.kuali.kfs.sys.document.web.AccountingLineRenderingContext)
  */
 public void renderElement(
     PageContext pageContext, Tag parentTag, AccountingLineRenderingContext renderingContext)
     throws JspException {
   if (!renderingContext.isFieldModifyable(debitOrCreditField.getPropertyName())) {
     debitOrCreditField.setReadOnly(true);
   }
   FieldRenderer renderer =
       SpringContext.getBean(AccountingLineRenderingService.class)
           .getFieldRendererForField(
               getDebitOrCreditField(), renderingContext.getAccountingLine());
   if (renderer != null) {
     prepareFieldForRendering(
         getDebitOrCreditField(),
         (VoucherForm) renderingContext.getForm(),
         renderingContext.getCurrentLineCount());
     renderer.setField(getDebitOrCreditField());
     renderer.render(pageContext, parentTag);
     renderer.clear();
   }
 }
 /** @see org.kuali.rice.kns.lookup.AbstractLookupableHelperServiceImpl#getRows() */
 @Override
 public List<Row> getRows() {
   List<Row> superResults = super.getRows();
   if (superResults != null) {
     for (Row row : superResults) {
       for (Field field : row.getFields()) {
         if (KFSPropertyConstants.ACCOUNT_NUMBER.equals(field.getPropertyName())) {
           // because of limitations in BO Metadata service, the account quickfinder was going to
           // prior year account instead of account, therefore
           // need to force it to go to Account (or whatever's mapped to the "account" reference in
           // OJB
           Class clazz =
               getPersistenceStructureService()
                   .getBusinessObjectAttributeClass(
                       businessObjectClass, KFSPropertyConstants.ACCOUNT);
           field.setQuickFinderClassNameImpl(clazz.getName());
           return superResults;
         }
       }
     }
   }
   return superResults;
 }
 /*
  *
  * This method is to make sure the looks fields are set up properly.
  * @param field
  * @param keyName
  * @param className
  */
 private void assertDropDownField(Field field, String keyName, String className) {
   assertEquals(field.getFieldConversions(), keyName + ":" + field.getPropertyName());
   assertEquals(field.getLookupParameters(), field.getPropertyName() + ":" + keyName);
   assertEquals(field.getInquiryParameters(), field.getPropertyName() + ":" + keyName);
   assertEquals(field.getQuickFinderClassNameImpl(), className);
 }