Package org.dspace.app.util
Class GoogleMetadata
- java.lang.Object
-
- org.dspace.app.util.GoogleMetadata
-
public class GoogleMetadata extends Object
Configuration and mapping for Google Scholar output metadata- Author:
- Sands Fish
-
-
Field Summary
-
Constructor Summary
Constructors Constructor Description GoogleMetadata(Context context, Item item)Wrap the item, parse all configured fields and generate metadata field values.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidaddAggregateValues(String field, String delimiter)protected voidaddMultipleValues(String FIELD)If metadata field contains multiple values, then add each value to the map separatelyprotected booleanaddSingleField(String fieldName)Add a single metadata value to the Google field, defaulting to the first-encountered instance of the field for this Item.protected StringbuildFieldName(MetadataValue v)Construct metadata field name out of Metadatum componentsList<org.jdom.Element>disseminateList()Produce meta elements that can easily be put into the head.protected BitstreamfindLinkableFulltext(Item item)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.List<String>getAbstractHTMLURL()List<String>getAuthors()List<String>getConference()List<String>getDate()List<String>getDissertationInstitution()List<String>getDissertationName()List<String>getDOI()List<String>getFirstpage()List<String>getFulltextHTMLURL()List<String>getISBN()List<String>getISSN()List<String>getIssue()List<String>getJournalTitle()List<String>getKeywords()List<String>getLanguage()List<String>getLastpage()Collection<Map.Entry<String,String>>getMappings()Fetch retaining the order of the values for any given key in which they where added (like authors).List<String>getPatentCountry()List<String>getPatentNumber()protected StringgetPDFSimpleUrl(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.List<String>getPDFURL()List<String>getPmid()List<String>getPublisher()List<String>getTechnicalReportInstitution()List<String>getTechnicalReportNumber()List<String>getTitle()List<String>getVolume()protected booleanidentifyItemType(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.protected booleanisPublic(Bitstream bitstream)Find out whether bitstream is readable by the public.protected booleanitemIsDissertation()Determine, based on config values, if this item is a dissertation.protected booleanitemIsPatent()Determine, based on config values, if this item is a patent.protected booleanitemIsTechReport()Determine, based on config values, if this item is a tech report.static voidlogConfiguration()Dump Metadata field mapping to logprotected String[]parseComponents(String field)Pull apart an individual field structure.protected ArrayList<String>parseFields(String configString)Build a Vector of fields that can be added to when expanding wildcards.protected voidparseItem()Using metadata field mappings contained in the loaded configuration, parse through configured metadata fields, building valid Google metadata value strings.protected ArrayList<ArrayList<String>>parseOptions(String configFilter)Parse first-match path of metadata field-group options for the given configuration.protected ArrayList<String>parseWildcard(String field)Expand any wildcard characters to an array of all matching fields for this item.protected ArrayList<MetadataValue>resolveMetadata(String configFilter, int returnType)Aggregate an array of DCValues present on the current item that pass the configuration filter.protected MetadataValueresolveMetadataField(String configFilter)A singular version of resolveMetadata to return only one field value instead of an aggregate.protected ArrayList<MetadataValue>resolveMetadataFields(String configFilter)A plural version of resolveMetadata for aggregate fields.
-
-
-
Field Detail
-
GOOGLE_PREFIX
protected static final String GOOGLE_PREFIX
- See Also:
- Constant Field Values
-
itemService
protected ItemService itemService
-
item
protected Item item
-
itemURL
protected String itemURL
-
TITLE
protected final String TITLE
- See Also:
- Constant Field Values
-
JOURNAL_TITLE
protected final String JOURNAL_TITLE
- See Also:
- Constant Field Values
-
PUBLISHER
protected final String PUBLISHER
- See Also:
- Constant Field Values
-
AUTHORS
protected final String AUTHORS
- See Also:
- Constant Field Values
-
DATE
protected final String DATE
- See Also:
- Constant Field Values
-
VOLUME
protected final String VOLUME
- See Also:
- Constant Field Values
-
ISSUE
protected final String ISSUE
- See Also:
- Constant Field Values
-
FIRSTPAGE
protected final String FIRSTPAGE
- See Also:
- Constant Field Values
-
LASTPAGE
protected final String LASTPAGE
- See Also:
- Constant Field Values
-
DOI
protected final String DOI
- See Also:
- Constant Field Values
-
PMID
protected final String PMID
- See Also:
- Constant Field Values
-
ABSTRACT
protected final String ABSTRACT
- See Also:
- Constant Field Values
-
FULLTEXT
protected final String FULLTEXT
- See Also:
- Constant Field Values
-
PDF
protected final String PDF
- See Also:
- Constant Field Values
-
ISSN
protected final String ISSN
- See Also:
- Constant Field Values
-
ISBN
protected final String ISBN
- See Also:
- Constant Field Values
-
LANGUAGE
protected final String LANGUAGE
- See Also:
- Constant Field Values
-
KEYWORDS
protected final String KEYWORDS
- See Also:
- Constant Field Values
-
CONFERENCE
protected final String CONFERENCE
- See Also:
- Constant Field Values
-
DISSERTATION_ID
protected final String DISSERTATION_ID
- See Also:
- Constant Field Values
-
DISSERTATION_NAME
protected final String DISSERTATION_NAME
- See Also:
- Constant Field Values
-
DISSERTATION_INSTITUTION
protected final String DISSERTATION_INSTITUTION
- See Also:
- Constant Field Values
-
PATENT_ID
protected final String PATENT_ID
- See Also:
- Constant Field Values
-
PATENT_NUMBER
protected final String PATENT_NUMBER
- See Also:
- Constant Field Values
-
PATENT_COUNTRY
protected final String PATENT_COUNTRY
- See Also:
- Constant Field Values
-
TECH_REPORT_ID
protected final String TECH_REPORT_ID
- See Also:
- Constant Field Values
-
TECH_REPORT_NUMBER
protected final String TECH_REPORT_NUMBER
- See Also:
- Constant Field Values
-
TECH_REPORT_INSTITUTION
protected final String TECH_REPORT_INSTITUTION
- See Also:
- Constant Field Values
-
SINGLE
protected final int SINGLE
- See Also:
- Constant Field Values
-
MULTI
protected final int MULTI
- See Also:
- Constant Field Values
-
ALL_FIELDS_IN_OPTION
protected final int ALL_FIELDS_IN_OPTION
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
GoogleMetadata
public GoogleMetadata(Context context, Item item) throws SQLException
Wrap the item, parse all configured fields and generate metadata field values.- Parameters:
context- contextitem- The item being viewed to extract metadata from- Throws:
SQLException- if database error
-
-
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 "|" charactersreturnType- 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.jdom.Element> disseminateList()
Produce meta elements that can easily be put into the head.- Returns:
- List of elements
-
getDissertationName
public List<String> getDissertationName()
- Returns:
- the citation_dissertation_name
-
getDissertationInstitution
public List<String> getDissertationInstitution()
- Returns:
- the citation_dissertation_institution
-
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
- 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 optiondelimiter- 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
-
-