Ejemplo n.º 1
0
 private int getMetadataSchemaID(DCValue dcv) throws SQLException {
   int schemaID;
   MetadataSchema schema = MetadataSchema.find(ourContext, dcv.schema);
   if (schema == null) {
     schemaID = MetadataSchema.DC_SCHEMA_ID;
   } else {
     schemaID = schema.getSchemaID();
   }
   return schemaID;
 }
Ejemplo n.º 2
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;
    }