Class MetadataUtilities


  • public class MetadataUtilities
    extends Object
    Miscellaneous methods for metadata handling that build on the API which might have general utility outside of the specific use in context in ItemUpdate. The XML methods were based on those in ItemImport
    • Field Detail

      • itemService

        protected static final ItemService itemService
    • Method Detail

      • deleteMetadataByValue

        public static boolean deleteMetadataByValue​(Context context,
                                                    Item item,
                                                    org.dspace.app.itemupdate.DtoMetadata dtom,
                                                    boolean isLanguageStrict)
                                             throws SQLException
        Working around Item API to delete a value-specific Metadatum For a given element/qualifier/lang: get all DCValues clear (i.e. delete) all of these DCValues add them back, minus the one to actually delete
        Parameters:
        context - DSpace Context
        item - Item Object
        dtom - metadata field
        isLanguageStrict - whether strict or not
        Returns:
        true if metadata field is found with matching value and was deleted
        Throws:
        SQLException - if database error
      • appendMetadata

        public static void appendMetadata​(Context context,
                                          Item item,
                                          org.dspace.app.itemupdate.DtoMetadata dtom,
                                          boolean isLanguageStrict,
                                          String textToAppend)
                                   throws IllegalArgumentException,
                                          SQLException
        Append text to value metadata field to item
        Parameters:
        context - DSpace Context
        item - DSpace Item
        dtom - metadata field
        isLanguageStrict - if strict
        textToAppend - text to append
        Throws:
        IllegalArgumentException - - When target metadata field is not found
        SQLException - if database error
      • getDCValueString

        public static String getDCValueString​(MetadataValue dcv)
        Get display of Metadatum
        Parameters:
        dcv - MetadataValue
        Returns:
        string displaying elements of the Metadatum
      • getCompoundForm

        public static String getCompoundForm​(String schema,
                                             String element,
                                             String qualifier)
        Return compound form of a metadata field (i.e. schema.element.qualifier)
        Parameters:
        schema - schema
        element - element
        qualifier - qualifier
        Returns:
        a String representation of the two- or three-part form of a metadata element e.g. dc.identifier.uri
      • parseCompoundForm

        public static String[] parseCompoundForm​(String compoundForm)
                                          throws ParseException
        Parses metadata field given in the form <schema>.<element>[.<qualifier>|.*] checks for correct number of elements (2 or 3) and for empty strings
        Parameters:
        compoundForm - compound form of metadata field
        Returns:
        String Array
        Throws:
        ParseException - if validity checks fail