/**
   * Perform a database query to obtain the string array of values corresponding to the passed
   * parameters. This is only really called from <code>
   * getMetadata(schema, element, qualifier, lang);
   * </code> which will obtain the value from cache if available first.
   *
   * @param schema
   * @param element
   * @param qualifier
   * @param lang
   */
  @Override
  public List<DCValue> getMetadata(
      Item item, String schema, String element, String qualifier, String lang) {
    List<DCValue> metadata = new ArrayList<DCValue>();
    try {
      TableRowIterator tri;

      if (qualifier == null) {
        Object[] params = {item.getID(), element, schema};
        tri = DatabaseManager.query(context, getByMetadataElement, params);
      } else if (Item.ANY.equals(qualifier)) {
        Object[] params = {item.getID(), element, schema};
        tri = DatabaseManager.query(context, getByMetadataAnyQualifier, params);
      } else {
        Object[] params = {item.getID(), element, qualifier, schema};
        tri = DatabaseManager.query(context, getByMetadata, params);
      }

      while (tri.hasNext()) {
        TableRow tr = tri.next();
        DCValue dcv = new DCValue();
        dcv.schema = schema;
        dcv.element = element;
        dcv.qualifier = qualifier;
        dcv.language = lang;
        dcv.value = tr.getStringColumn("text_value");
        metadata.add(dcv);
      }
    } catch (SQLException sqle) {
      throw new RuntimeException(sqle);
    }
    return metadata;
  }
  private List<List<MetadataField>> getMetadataFieldsList(
      org.dspace.core.Context context, List<String> query_field) throws SQLException {
    List<List<MetadataField>> listFieldList = new ArrayList<List<MetadataField>>();
    for (String s : query_field) {
      ArrayList<MetadataField> fields = new ArrayList<MetadataField>();
      listFieldList.add(fields);
      if (s.equals("*")) {
        continue;
      }
      String schema = "";
      String element = "";
      String qualifier = null;
      String[] parts = s.split("\\.");
      if (parts.length > 0) {
        schema = parts[0];
      }
      if (parts.length > 1) {
        element = parts[1];
      }
      if (parts.length > 2) {
        qualifier = parts[2];
      }

      if (Item.ANY.equals(qualifier)) {
        for (MetadataField mf :
            metadataFieldService.findFieldsByElementNameUnqualified(context, schema, element)) {
          fields.add(mf);
        }
      } else {
        MetadataField mf = metadataFieldService.findByElement(context, schema, element, qualifier);
        if (mf != null) {
          fields.add(mf);
        }
      }
    }
    return listFieldList;
  }