Skip to content
This repository has been archived by the owner on Oct 24, 2022. It is now read-only.

Commit

Permalink
Merge pull request #377 from MITLibraries/371_optionally_exclude_authors
Browse files Browse the repository at this point in the history
METS author limits, date created, and TopicHub as agent
  • Loading branch information
JPrevost committed Oct 20, 2015
2 parents 0d5c9f9 + be01049 commit 1deffa7
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 6 deletions.
20 changes: 17 additions & 3 deletions app/models/Item.scala
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ case class Item(id: Int, // DB key
}

private def metsHdr = {
<metsHdr CREATEDATE={metadataValue("title")}>
<metsHdr CREATEDATE={ HubUtils.fmtDate(created) }>
<agent ROLE="CREATOR" TYPE="ORGANIZATION">
<name>TopicHub</name>
</agent>
Expand All @@ -158,15 +158,15 @@ case class Item(id: Int, // DB key
</epdcx:statement>
}

{ if( hasMetadata("author") )
{ if( hasMetadata("author") && include_authors)
{ for ( author <- metadataValues("author") ) yield
<epdcx:statement epdcx:propertyURI="http://purl.org/dc/elements/1.1/creator">
<epdcx:valueString>{ author }</epdcx:valueString>
</epdcx:statement>
}
}

{ if( hasMetadata("additional_author") )
{ if( hasMetadata("additional_author") && include_authors)
{ for ( author <- metadataValues("additional_author") ) yield
<epdcx:statement epdcx:propertyURI="http://purl.org/dc/elements/1.1/creator">
<epdcx:valueString>{ author }</epdcx:valueString>
Expand Down Expand Up @@ -214,6 +214,10 @@ case class Item(id: Int, // DB key
</epdcx:statement>
}

<epdcx:statement epdcx:propertyURI="http://purl.org/dc/elements/1.1/source">
<epdcx:valueString>TopicHub SCOAP3</epdcx:valueString>
</epdcx:statement>

</epdcx:description>
</epdcx:descriptionSet>
</xmlData>
Expand Down Expand Up @@ -252,6 +256,16 @@ case class Item(id: Int, // DB key
</div>
</structMap>
}

private def include_authors: Boolean = {
val restrict_at = current.configuration.getInt("mets.restrict_maximum_authors").getOrElse(0)
val author_size = metadataValues("author").size + metadataValues("additional_author").size
if (restrict_at == 0 || author_size < restrict_at) {
true
} else {
false
}
}
}

object Item {
Expand Down
4 changes: 4 additions & 0 deletions conf/application.conf
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@ include "authentication"
auth.harvest.key = ""
auth.harvest.key = ${?HARVEST_KEY}

# restrict excessive authors in METS?
# to restrict add an Integer to METS_RESTRICT_MAXIMUM_AUTHORS
mets.restrict_maximum_authors = ${?METS_RESTRICT_MAXIMUM_AUTHORS}

# Branding changes should be made using Environment Variables
# Developers should access values via the HubUtils model rather than directly.
brand.name=${?SITE_NAME}
Expand Down
6 changes: 3 additions & 3 deletions test/unit/ItemSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -490,11 +490,11 @@ class ItemSpec extends Specification {
(mets \\ "dmdSec").size must equalTo(1)
(mets \\ "fileSec").size must equalTo(1)
(mets \\ "structMap").size must equalTo(1)
(mets \\ "valueString").size must equalTo(3)
(mets \\ "valueString").size must equalTo(4)

item.addMetadata("abstract", "More stuff!!!")
val mets_abstract = item.toMets
(mets_abstract \\ "valueString").size must equalTo(4)
(mets_abstract \\ "valueString").size must equalTo(5)

item.addMetadata("doi", "asdf//popcorn.123.456")
item.addMetadata("additional_author", "Anonymoys Coward")
Expand All @@ -505,7 +505,7 @@ class ItemSpec extends Specification {
item.addMetadata("accessUri", "http://example.com/a.pdf?pdfa")
item.addMetadata("accessUri", "http://example.com/a.xml")
val mets_moar = item.toMets
(mets_moar \\ "valueString").size must equalTo(9)
(mets_moar \\ "valueString").size must equalTo(10)
(mets_moar \\ "FLocat").size must equalTo(3)
(mets_moar \\ "fptr").size must equalTo(3)
}
Expand Down

0 comments on commit 1deffa7

Please sign in to comment.