org.dspace.app.itemupdate
Class MetadataUtilities

java.lang.Object
  extended by org.dspace.app.itemupdate.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


Constructor Summary
MetadataUtilities()
           
 
Method Summary
static void appendMetadata(Item item, org.dspace.app.itemupdate.DtoMetadata dtom, boolean isLanguageStrict, String textToAppend)
          Append text to value metadata field to item
static boolean deleteMetadataByValue(Item item, org.dspace.app.itemupdate.DtoMetadata dtom, boolean isLanguageStrict)
          Working around Item API to delete a value-specific DCValue For a given element/qualifier/lang: get all DCValues clear (i.e.
static String getCompoundForm(String schema, String element, String qualifier)
           
static String getDCValueString(DCValue dcv)
          Get display of DCValue
static List<org.dspace.app.itemupdate.DtoMetadata> loadDublinCore(DocumentBuilder docBuilder, InputStream is)
          Modification of method from ItemImporter.loadDublinCore as a Factory method
static String[] parseCompoundForm(String compoundForm)
          Parses metadata field given in the form .[.|.*] checks for correct number of elements (2 or 3) and for empty strings
static List<ContentsEntry> readContentsFile(File f)
          rewrite of ItemImport's functionality but just the parsing of the file, not the processing of its elements
static List<Integer> readDeleteContentsFile(File f)
           
static void writeDocument(Document doc, Transformer transformer, OutputStream out)
          write xml document to output stream
static Document writeDublinCore(DocumentBuilder docBuilder, List<org.dspace.app.itemupdate.DtoMetadata> dtomList)
          Write dublin_core.xml
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MetadataUtilities

public MetadataUtilities()
Method Detail

deleteMetadataByValue

public static boolean deleteMetadataByValue(Item item,
                                            org.dspace.app.itemupdate.DtoMetadata dtom,
                                            boolean isLanguageStrict)
Working around Item API to delete a value-specific DCValue 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:
item -
dtom -
isLanguageStrict - -
Returns:
true if metadata field is found with matching value and was deleted

appendMetadata

public static void appendMetadata(Item item,
                                  org.dspace.app.itemupdate.DtoMetadata dtom,
                                  boolean isLanguageStrict,
                                  String textToAppend)
                           throws IllegalArgumentException
Append text to value metadata field to item

Parameters:
item -
dtom -
isLanguageStrict -
textToAppend -
Throws:
IllegalArgumentException - - When target metadata field is not found

loadDublinCore

public static List<org.dspace.app.itemupdate.DtoMetadata> loadDublinCore(DocumentBuilder docBuilder,
                                                                         InputStream is)
                                                                  throws SQLException,
                                                                         IOException,
                                                                         ParserConfigurationException,
                                                                         SAXException,
                                                                         TransformerException,
                                                                         AuthorizeException
Modification of method from ItemImporter.loadDublinCore as a Factory method

Parameters:
docBuilder - -
is - - InputStream of dublin_core.xml
Returns:
list of DtoMetadata representing the metadata fields relating to an Item
Throws:
SQLException
IOException
ParserConfigurationException
SAXException
TransformerException
AuthorizeException

writeDublinCore

public static Document writeDublinCore(DocumentBuilder docBuilder,
                                       List<org.dspace.app.itemupdate.DtoMetadata> dtomList)
                                throws ParserConfigurationException,
                                       TransformerConfigurationException,
                                       TransformerException
Write dublin_core.xml

Parameters:
docBuilder -
dtomList -
Returns:
xml document
Throws:
ParserConfigurationException
TransformerConfigurationException
TransformerException

writeDocument

public static void writeDocument(Document doc,
                                 Transformer transformer,
                                 OutputStream out)
                          throws IOException,
                                 TransformerException
write xml document to output stream

Parameters:
doc -
transformer -
out -
Throws:
IOException
TransformerException

readContentsFile

public static List<ContentsEntry> readContentsFile(File f)
                                            throws FileNotFoundException,
                                                   IOException,
                                                   ParseException
rewrite of ItemImport's functionality but just the parsing of the file, not the processing of its elements

Returns:
Throws:
FileNotFoundException
IOException
ParseException

readDeleteContentsFile

public static List<Integer> readDeleteContentsFile(File f)
                                            throws FileNotFoundException,
                                                   IOException
Parameters:
f -
Returns:
Throws:
FileNotFoundException
IOException

getDCValueString

public static String getDCValueString(DCValue dcv)
Get display of DCValue

Parameters:
dcv -
Returns:
string displaying elements of the DCValue

getCompoundForm

public static String getCompoundForm(String schema,
                                     String element,
                                     String 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 .[.|.*] checks for correct number of elements (2 or 3) and for empty strings

Returns:
String Array
Throws:
ParseException - if validity checks fail


Copyright © 2010 DuraSpace. All Rights Reserved.