Class GoogleMetadata


  • public class GoogleMetadata
    extends Object
    Configuration and mapping for Google Scholar output metadata
    Author:
    Sands Fish
    • Constructor Detail

      • GoogleMetadata

        public GoogleMetadata​(Context context,
                              Item item)
                       throws SQLException,
                              IOException
        Wrap the item, parse all configured fields and generate metadata field values.
        Parameters:
        context - context
        item - The item being viewed to extract metadata from
        Throws:
        SQLException - if database error.
        IOException - passed through.
    • Method Detail

      • logConfiguration

        public static void logConfiguration()
        Dump Metadata field mapping to log
      • addSingleField

        protected boolean addSingleField​(String fieldName)
        Add a single metadata value to the Google field, defaulting to the first-encountered instance of the field for this Item.
        Parameters:
        fieldName - metadata field name
        Returns:
        successful?
      • resolveMetadataField

        protected MetadataValue resolveMetadataField​(String configFilter)
        A singular version of resolveMetadata to return only one field value instead of an aggregate.
        Parameters:
        configFilter - list of DC metadata fields separated by "|" characters
        Returns:
        The first configured match of metadata field for the item.
      • resolveMetadataFields

        protected ArrayList<MetadataValue> resolveMetadataFields​(String configFilter)
        A plural version of resolveMetadata for aggregate fields.
        Parameters:
        configFilter - list of DC metadata fields separated by "|" characters
        Returns:
        Aggregate of all matching metadata fields configured in the first option field-set to return any number of filter matches.
      • resolveMetadata

        protected ArrayList<MetadataValue> resolveMetadata​(String configFilter,
                                                           int returnType)
        Aggregate an array of DCValues present on the current item that pass the configuration filter.
        Parameters:
        configFilter - list of DC metadata fields separated by "|" characters
        returnType - GoogleMetadata.SINGLE / GoogleMetadata.MULTI / GoogleMetadata.ALL_FIELDS_IN_OPTION
        Returns:
        Array of configuration to item-field matches
      • parseOptions

        protected ArrayList<ArrayList<String>> parseOptions​(String configFilter)
        Parse first-match path of metadata field-group options for the given configuration.
        Parameters:
        configFilter - list of DC metadata fields separated by "|" characters
        Returns:
        array of parsed options or null
      • parseFields

        protected ArrayList<String> parseFields​(String configString)
        Build a Vector of fields that can be added to when expanding wildcards.
        Parameters:
        configString - - Value of one metadata field configuration
        Returns:
        A vector of raw field configurations.
      • parseComponents

        protected String[] parseComponents​(String field)
        Pull apart an individual field structure.
        Parameters:
        field - The configured field for one metadata field map
        Returns:
        Schema, Element, Qualifier of metadata field
      • parseWildcard

        protected ArrayList<String> parseWildcard​(String field)
        Expand any wildcard characters to an array of all matching fields for this item. No order consistency is implied.
        Parameters:
        field - The field identifier containing a wildcard character.
        Returns:
        Expanded field list.
      • buildFieldName

        protected String buildFieldName​(MetadataValue v)
        Construct metadata field name out of Metadatum components
        Parameters:
        v - The Metadatum to construct a name for.
        Returns:
        The complete metadata field name.
      • parseItem

        protected void parseItem()
        Using metadata field mappings contained in the loaded configuration, parse through configured metadata fields, building valid Google metadata value strings. Field names and values contained in metadataMappings.
      • getMappings

        public Collection<Map.Entry<String,​String>> getMappings()
        Fetch retaining the order of the values for any given key in which they where added (like authors). Usage: GoogleMetadata gmd = new GoogleMetadata(item); for(Entry<String, String> mapping : googlemd.getMappings()) ...
        Returns:
        Iterable of metadata fields mapped to Google-formatted values
      • disseminateList

        public List<org.jdom2.Element> disseminateList()
        Produce meta elements that can easily be put into the head.
        Returns:
        List of elements
      • getTitle

        public List<String> getTitle()
        Returns:
        the citation_title
      • getJournalTitle

        public List<String> getJournalTitle()
        Returns:
        the citation_journal_title
      • getPublisher

        public List<String> getPublisher()
        Returns:
        the citation_publisher
      • getAuthors

        public List<String> getAuthors()
        Returns:
        the citation_authors
      • getDate

        public List<String> getDate()
        Returns:
        the citation_date
      • getVolume

        public List<String> getVolume()
        Returns:
        the citation_volume
      • getIssue

        public List<String> getIssue()
        Returns:
        the citation_issue
      • getFirstpage

        public List<String> getFirstpage()
        Returns:
        the citation_firstpage
      • getLastpage

        public List<String> getLastpage()
        Returns:
        the citation_lastpage
      • getDOI

        public List<String> getDOI()
        Returns:
        the citation_doi
      • getPmid

        public List<String> getPmid()
        Returns:
        the citation_pmid
      • getAbstractHTMLURL

        public List<String> getAbstractHTMLURL()
        Returns:
        the citation_abstract_html_url
      • getFulltextHTMLURL

        public List<String> getFulltextHTMLURL()
        Returns:
        the citation_fulltext_html_url
      • getPDFURL

        public List<String> getPDFURL()
        Returns:
        the citation_pdf_url
      • getISSN

        public List<String> getISSN()
        Returns:
        the citation_issn
      • getISBN

        public List<String> getISBN()
        Returns:
        the citation_isbn
      • getLanguage

        public List<String> getLanguage()
        Returns:
        the citation_language
      • getKeywords

        public List<String> getKeywords()
        Returns:
        the citation_keywords
      • getConference

        public List<String> getConference()
        Returns:
        the citation_conference
      • getDissertationName

        public List<String> getDissertationName()
        Returns:
        the citation_dissertation_name
      • getDissertationInstitution

        public List<String> getDissertationInstitution()
        Returns:
        the citation_dissertation_institution
      • getPatentNumber

        public List<String> getPatentNumber()
        Returns:
        the citation_patent_number
      • getPatentCountry

        public List<String> getPatentCountry()
        Returns:
        the citation_patent_country
      • getTechnicalReportNumber

        public List<String> getTechnicalReportNumber()
        Returns:
        the citation_technical_report_number
      • getTechnicalReportInstitution

        public List<String> getTechnicalReportInstitution()
        Returns:
        the citation_technical_report_institution
      • getPDFSimpleUrl

        protected String getPDFSimpleUrl​(Item item)
        Gets the URL to a PDF using a very basic strategy by assuming that the PDF is in the default content bundle, and that the item only has one public bitstream and it is a PDF.
        Parameters:
        item - item to get PDF URL from
        Returns:
        URL that the PDF can be directly downloaded from
      • findLinkableFulltext

        protected Bitstream findLinkableFulltext​(Item item)
                                          throws SQLException
        A bitstream is considered linkable fulltext when it is either
        • the item's only bitstream (in the ORIGINAL bundle); or
        • the primary bitstream
        Additionally, this bitstream must be publicly viewable.
        Parameters:
        item - bitstream's parent item
        Returns:
        a linkable bitstream or null if none found
        Throws:
        SQLException - if database error
      • isPublic

        protected boolean isPublic​(Bitstream bitstream)
        Find out whether bitstream is readable by the public.
        Parameters:
        bitstream - the target bitstream
        Returns:
        whether bitstream is readable by the Anonymous group
      • addAggregateValues

        protected void addAggregateValues​(String field,
                                          String delimiter)
        Parameters:
        field - to aggregate all values of in a matching option
        delimiter - to delimit field values with
      • addMultipleValues

        protected void addMultipleValues​(String FIELD)
        If metadata field contains multiple values, then add each value to the map separately
        Parameters:
        FIELD - metadata field
      • itemIsDissertation

        protected boolean itemIsDissertation()
        Determine, based on config values, if this item is a dissertation.
        Returns:
        boolean
      • itemIsPatent

        protected boolean itemIsPatent()
        Determine, based on config values, if this item is a patent.
        Returns:
        boolean
      • itemIsTechReport

        protected boolean itemIsTechReport()
        Determine, based on config values, if this item is a tech report.
        Returns:
        boolean
      • identifyItemType

        protected boolean identifyItemType​(String dConfig)
        Identifies if this item matches a particular configuration of fields and values for those fields to identify the type based on a type- cataloging metadata practice.
        Parameters:
        dConfig - configured fields (from google-metadata.properties)
        Returns:
        item matches configuration