private void appendDataRow(PrintWriter out, ValidationExternalType validationExternalType) {
   DataRowBuilder row = new DataRowBuilder(out);
   row.begin();
   row.append(validationExternalType.getSearchField());
   row.append(validationExternalType.getDisplayField());
   List formattedResultFields = mapToKeyValues(validationExternalType.getResultFields());
   row.append(formattedResultFields);
   row.end();
 }
Exemplo n.º 2
0
  /**
   * Intended to be called by doValidationExternal.
   *
   * @param rSession the rets session
   * @param hSession the hibernate session
   * @exception HibernateException if an error occurs
   */
  private void doValidationExternalType(Session hSession) throws HibernateException {
    MetadataTable tValidationExternalTypes =
        getMetadataTable(MetadataTable.VALIDATION_EXTERNAL_TYPE);

    Iterator i = mValidationExternals.values().iterator();
    while (i.hasNext()) {
      ValidationExternal ve = (ValidationExternal) i.next();
      Set hValdationExternalTypes = new HashSet();
      List validationExternalTypes = tValidationExternalTypes.getDataRows(ve.getPath());
      if (validationExternalTypes != null) {
        Iterator j = validationExternalTypes.iterator();
        while (j.hasNext()) {
          Metadata md = (Metadata) j.next();
          ValidationExternalType vet = new ValidationExternalType();

          vet.setValidationExternal(ve);

          String joinedSearchField = md.getAttribute("SearchField");
          String searchField[] = StringUtils.split(joinedSearchField, ",");
          Set searchFieldSet = new HashSet();
          for (int c = 0; c < searchField.length; c++) {
            searchFieldSet.add(StringUtils.trimToEmpty(searchField[c]));
          }
          vet.setSearchField(searchFieldSet);

          String joinedDisplayField = md.getAttribute("DisplayField");
          String displayFields[] = StringUtils.split(joinedDisplayField, ",");
          Set displayFieldSet = new HashSet();
          for (int c = 0; c < displayFields.length; c++) {
            displayFieldSet.add(StringUtils.trimToEmpty(displayFields[c]));
          }
          vet.setDisplayField(displayFieldSet);

          String joinedResultField = md.getAttribute("ResultFields");
          String resultFields[] = StringUtils.split(joinedResultField, ",");
          Map resultFieldMap = new HashMap();
          for (int c = 0; c < resultFields.length; c++) {
            String split[] = StringUtils.split(resultFields[c], "=", 2);
            resultFieldMap.put(
                StringUtils.trimToEmpty(split[0]), StringUtils.trimToEmpty(split[1]));
          }
          vet.setResultFields(resultFieldMap);

          vet.updateLevel();
          hSession.save(vet);
        }
        ve.setValidationExternalTypes(hValdationExternalTypes);
      }
    }
  }