示例#1
0
  public void replaceMetadataValue(DCValue oldValue, DCValue newValue) {
    // check both dcvalues are for the same field
    if (oldValue.hasSameFieldAs(newValue)) {

      String schema = oldValue.schema;
      String element = oldValue.element;
      String qualifier = oldValue.qualifier;

      // Save all metadata for this field
      DCValue[] dcvalues = getMetadata(schema, element, qualifier, Item.ANY);
      clearMetadata(schema, element, qualifier, Item.ANY);
      for (DCValue dcvalue : dcvalues) {
        if (dcvalue.equals(oldValue)) {
          addMetadata(
              schema,
              element,
              qualifier,
              newValue.language,
              newValue.value,
              newValue.authority,
              newValue.confidence);
        } else {
          addMetadata(
              schema,
              element,
              qualifier,
              dcvalue.language,
              dcvalue.value,
              dcvalue.authority,
              dcvalue.confidence);
        }
      }
    }
  }
示例#2
0
 /**
  * Add metadata fields. These are appended to existing values. Use <code>clearDC</code> to remove
  * values. The ordering of values passed in is maintained.
  *
  * <p>If metadata authority control is available, try to get authority values. The authority
  * confidence depends on whether authority is <em>required</em> or not.
  *
  * @param schema the schema for the metadata field. <em>Must</em> match the <code>name</code> of
  *     an existing metadata schema.
  * @param element the metadata element name
  * @param qualifier the metadata qualifier name, or <code>null</code> for unqualified
  * @param lang the ISO639 language code, optionally followed by an underscore and the ISO3166
  *     country code. <code>null</code> means the value has no language (for example, a date).
  * @param values the values to add.
  */
 public void addMetadata(
     String schema, String element, String qualifier, String lang, String[] values) {
   MetadataAuthorityManager mam = MetadataAuthorityManager.getManager();
   String fieldKey = MetadataAuthorityManager.makeFieldKey(schema, element, qualifier);
   if (mam.isAuthorityControlled(fieldKey)) {
     String authorities[] = new String[values.length];
     int confidences[] = new int[values.length];
     for (int i = 0; i < values.length; ++i) {
       getAuthoritiesAndConfidences(fieldKey, values, authorities, confidences, i);
     }
     addMetadata(schema, element, qualifier, lang, values, authorities, confidences);
   } else {
     addMetadata(schema, element, qualifier, lang, values, null, null);
   }
 }
示例#3
0
  /**
   * Add a single metadata field. This is appended to existing values. Use <code>clearDC</code> to
   * remove values.
   *
   * @param schema the schema for the metadata field. <em>Must</em> match the <code>name</code> of
   *     an existing metadata schema.
   * @param element the metadata element name
   * @param qualifier the metadata qualifier, or <code>null</code> for unqualified
   * @param lang the ISO639 language code, optionally followed by an underscore and the ISO3166
   *     country code. <code>null</code> means the value has no language (for example, a date).
   * @param value the value to add.
   */
  public void addMetadata(
      String schema, String element, String qualifier, String lang, String value) {
    String[] valArray = new String[1];
    valArray[0] = value;

    addMetadata(schema, element, qualifier, lang, valArray);
  }
示例#4
0
 /** Set first metadata field value */
 protected void setMetadataSingleValue(
     String schema, String element, String qualifier, String language, String value) {
   if (value != null) {
     clearMetadata(schema, element, qualifier, language);
     addMetadata(schema, element, qualifier, language, value);
     modifiedMetadata = true;
   }
 }
示例#5
0
  /**
   * Add a single metadata field. This is appended to existing values. Use <code>clearDC</code> to
   * remove values.
   *
   * @param schema the schema for the metadata field. <em>Must</em> match the <code>name</code> of
   *     an existing metadata schema.
   * @param element the metadata element name
   * @param qualifier the metadata qualifier, or <code>null</code> for unqualified
   * @param lang the ISO639 language code, optionally followed by an underscore and the ISO3166
   *     country code. <code>null</code> means the value has no language (for example, a date).
   * @param value the value to add.
   * @param authority the external authority key for this value (or null)
   * @param confidence the authority confidence (default 0)
   */
  public void addMetadata(
      String schema,
      String element,
      String qualifier,
      String lang,
      String value,
      String authority,
      int confidence) {
    String[] valArray = new String[1];
    String[] authArray = new String[1];
    int[] confArray = new int[1];
    valArray[0] = value;
    authArray[0] = authority;
    confArray[0] = confidence;

    addMetadata(schema, element, qualifier, lang, valArray, authArray, confArray);
  }
示例#6
0
 /**
  * Add a single Dublin Core metadata field. This is appended to existing values. Use <code>clearDC
  * </code> to remove values.
  *
  * @param element the Dublin Core element
  * @param qualifier the Dublin Core qualifier, or <code>null</code> for unqualified
  * @param lang the ISO639 language code, optionally followed by an underscore and the ISO3166
  *     country code. <code>null</code> means the value has no language (for example, a date).
  * @param value the value to add.
  */
 @Deprecated
 public void addDC(String element, String qualifier, String lang, String value) {
   addMetadata(MetadataSchema.DC_SCHEMA, element, qualifier, lang, value);
 }