Beispiel #1
0
    List<DCValue> get(Context c, int resourceId, int resourceTypeId, Logger log)
        throws SQLException {
      if (metadata == null) {
        metadata = new ArrayList<DCValue>();

        // Get Dublin Core metadata
        TableRowIterator tri = retrieveMetadata(resourceId, resourceTypeId);

        if (tri != null) {
          try {
            while (tri.hasNext()) {
              TableRow resultRow = tri.next();

              // Get the associated metadata field and schema information
              int fieldID = resultRow.getIntColumn("metadata_field_id");
              MetadataField field = MetadataField.find(c, fieldID);

              if (field == null) {
                log.error("Loading item - cannot find metadata field " + fieldID);
              } else {
                MetadataSchema schema = MetadataSchema.find(c, field.getSchemaID());
                if (schema == null) {
                  log.error(
                      "Loading item - cannot find metadata schema "
                          + field.getSchemaID()
                          + ", field "
                          + fieldID);
                } else {
                  // Make a DCValue object
                  DCValue dcv = new DCValue();
                  dcv.element = field.getElement();
                  dcv.qualifier = field.getQualifier();
                  dcv.value = resultRow.getStringColumn("text_value");
                  dcv.language = resultRow.getStringColumn("text_lang");
                  // dcv.namespace = schema.getNamespace();
                  dcv.schema = schema.getName();
                  dcv.authority = resultRow.getStringColumn("authority");
                  dcv.confidence = resultRow.getIntColumn("confidence");

                  // Add it to the list
                  metadata.add(dcv);
                }
              }
            }
          } finally {
            // close the TableRowIterator to free up resources
            if (tri != null) {
              tri.close();
            }
          }
        }
      }

      return metadata;
    }
Beispiel #2
0
  protected MetadataField getMetadataField(DCValue dcv) throws SQLException, AuthorizeException {
    if (allMetadataFields == null) {
      allMetadataFields = MetadataField.findAll(ourContext);
    }

    if (allMetadataFields != null) {
      int schemaID = getMetadataSchemaID(dcv);
      for (MetadataField field : allMetadataFields) {
        if (field.getSchemaID() == schemaID
            && StringUtils.equals(field.getElement(), dcv.element)
            && StringUtils.equals(field.getQualifier(), dcv.qualifier)) {
          return field;
        }
      }
    }

    return null;
  }