Package org.dspace.app.util
Class GoogleMetadata
java.lang.Object
org.dspace.app.util.GoogleMetadata
Configuration and mapping for Google Scholar output metadata
- Author:
- Sands Fish
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final Stringprotected final intprotected final Stringprotected final Stringprotected final Stringprotected final Stringprotected final Stringprotected final Stringprotected final Stringprotected final Stringprotected final Stringprotected static final Stringprotected final Stringprotected final Stringprotected final Stringprotected Itemprotected ItemServiceprotected Stringprotected final Stringprotected final Stringprotected final Stringprotected final Stringprotected final intprotected final Stringprotected final Stringprotected final Stringprotected final Stringprotected final Stringprotected final Stringprotected final intprotected final Stringprotected final Stringprotected final Stringprotected final Stringprotected final String -
Constructor Summary
ConstructorsConstructorDescriptionGoogleMetadata(Context context, Item item) Wrap the item, parse all configured fields and generate metadata field values. -
Method Summary
Modifier and TypeMethodDescriptionprotected 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 StringConstruct metadata field name out of Metadatum componentsList<org.jdom2.Element>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.getDate()getDOI()getISBN()getISSN()getIssue()Fetch retaining the order of the values for any given key in which they where added (like authors).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.getPmid()getTitle()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 booleanFind out whether bitstream is readable by the public.protected booleanDetermine, based on config values, if this item is a dissertation.protected booleanDetermine, based on config values, if this item is a patent.protected booleanDetermine, based on config values, if this item is a tech report.static voidDump Metadata field mapping to logprotected String[]parseComponents(String field) Pull apart an individual field structure.parseFields(String configString) Build a Vector of fields that can be added to when expanding wildcards.protected voidUsing metadata field mappings contained in the loaded configuration, parse through configured metadata fields, building valid Google metadata value strings.parseOptions(String configFilter) Parse first-match path of metadata field-group options for the given configuration.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 Details
-
GOOGLE_PREFIX
- See Also:
-
itemService
-
item
-
itemURL
-
googleScholarSettings
-
metadataMappings
-
TITLE
- See Also:
-
JOURNAL_TITLE
- See Also:
-
PUBLISHER
- See Also:
-
AUTHORS
- See Also:
-
DATE
- See Also:
-
VOLUME
- See Also:
-
ISSUE
- See Also:
-
FIRSTPAGE
- See Also:
-
LASTPAGE
- See Also:
-
DOI
- See Also:
-
PMID
- See Also:
-
ABSTRACT
- See Also:
-
FULLTEXT
- See Also:
-
PDF
- See Also:
-
ISSN
- See Also:
-
ISBN
- See Also:
-
LANGUAGE
- See Also:
-
KEYWORDS
- See Also:
-
CONFERENCE
- See Also:
-
DISSERTATION_ID
- See Also:
-
DISSERTATION_NAME
- See Also:
-
DISSERTATION_INSTITUTION
- See Also:
-
PATENT_ID
- See Also:
-
PATENT_NUMBER
- See Also:
-
PATENT_COUNTRY
- See Also:
-
TECH_REPORT_ID
- See Also:
-
TECH_REPORT_NUMBER
- See Also:
-
TECH_REPORT_INSTITUTION
- See Also:
-
SINGLE
protected final int SINGLE- See Also:
-
MULTI
protected final int MULTI- See Also:
-
ALL_FIELDS_IN_OPTION
protected final int ALL_FIELDS_IN_OPTION- See Also:
-
-
Constructor Details
-
GoogleMetadata
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.IOException- passed through.
-
-
Method Details
-
logConfiguration
public static void logConfiguration()Dump Metadata field mapping to log -
addSingleField
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
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
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
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
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
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
Pull apart an individual field structure.- Parameters:
field- The configured field for one metadata field map- Returns:
- Schema, Element, Qualifier of metadata field
-
parseWildcard
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
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
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
Produce meta elements that can easily be put into the head.- Returns:
- List of elements
-
getTitle
- Returns:
- the citation_title
-
getJournalTitle
- Returns:
- the citation_journal_title
-
getPublisher
- Returns:
- the citation_publisher
-
getAuthors
- Returns:
- the citation_authors
-
getDate
- Returns:
- the citation_date
-
getVolume
- Returns:
- the citation_volume
-
getIssue
- Returns:
- the citation_issue
-
getFirstpage
- Returns:
- the citation_firstpage
-
getLastpage
- Returns:
- the citation_lastpage
-
getDOI
- Returns:
- the citation_doi
-
getPmid
- Returns:
- the citation_pmid
-
getAbstractHTMLURL
- Returns:
- the citation_abstract_html_url
-
getFulltextHTMLURL
- Returns:
- the citation_fulltext_html_url
-
getPDFURL
- Returns:
- the citation_pdf_url
-
getISSN
- Returns:
- the citation_issn
-
getISBN
- Returns:
- the citation_isbn
-
getLanguage
- Returns:
- the citation_language
-
getKeywords
- Returns:
- the citation_keywords
-
getConference
- Returns:
- the citation_conference
-
getDissertationName
- Returns:
- the citation_dissertation_name
-
getDissertationInstitution
- Returns:
- the citation_dissertation_institution
-
getPatentNumber
- Returns:
- the citation_patent_number
-
getPatentCountry
- Returns:
- the citation_patent_country
-
getTechnicalReportNumber
- Returns:
- the citation_technical_report_number
-
getTechnicalReportInstitution
- Returns:
- the citation_technical_report_institution
-
getPDFSimpleUrl
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
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
Find out whether bitstream is readable by the public.- Parameters:
bitstream- the target bitstream- Returns:
- whether bitstream is readable by the Anonymous group
-
addAggregateValues
- Parameters:
field- to aggregate all values of in a matching optiondelimiter- to delimit field values with
-
addMultipleValues
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
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
-