Skip to content

Commit

Permalink
Merge pull request #22 from NLNZDigitalPreservation/issued-field
Browse files Browse the repository at this point in the history
Issued field
  • Loading branch information
jeremy-liss authored Jun 5, 2023
2 parents e8ad262 + a676d75 commit 71e6e1c
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 9 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ subprojects {
project.ext {
vendor = "National Library of New Zealand"

versionNumber = "1.0.2-SNAPSHOT"
versionNumber = "1.0.3-SNAPSHOT"
}

apply plugin: 'maven'
Expand Down
3 changes: 3 additions & 0 deletions core/src/main/groovy/nz/govt/natlib/tools/sip/Sip.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ class Sip {
Integer dayOfMonth
String dcCoverage

// Optional issue number
String issued

// Type and policy
IEEntityType ieEntityType
String objectIdentifierType
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ class SipXmlExtractor {
sip.dayOfMonth = extractDayOfMonth()
sip.updateFromDateFields()

sip.issued = extractIssueNumber()

sip.ieEntityType = extractIEEntityType()
sip.objectIdentifierType = extractObjectIdentifierType()
sip.objectIdentifierValue = extractObjectIdentifierValue()
Expand Down Expand Up @@ -194,6 +196,11 @@ class SipXmlExtractor {
return extractFirstNodeWithAttribute("id", "usageType") as String
}

String extractIssueNumber() {
String dcTermsIssuedString = extractIeDmdRecord().'dcterms:issued' as String
return dcTermsIssuedString != null ? dcTermsIssuedString : null
}

Integer extractRevisionNumber() {
String revisionString = extractFirstNodeWithAttribute("id", "RevisionNumber") as String
return Integer.parseInt(revisionString)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package nz.govt.natlib.tools.sip.generation

import groovy.json.JsonBuilder
import groovy.json.JsonGenerator

//import groovy.json.JsonGenerator
//import groovy.json.JsonGenerator.Converter
Expand All @@ -15,7 +16,11 @@ class SipJsonGenerator {

static String toJson(Sip sip, boolean prettyPrint = false) {
// groovy 2.5.x u
JsonBuilder jsonBuilder = new JsonBuilder()
def generator = new JsonGenerator.Options()
.excludeNulls()
.build()

JsonBuilder jsonBuilder = new JsonBuilder(generator)
Map<String, Object> jsonRoot = jsonBuilder {
title sip.title

Expand All @@ -28,6 +33,8 @@ class SipJsonGenerator {
dayOfMonth sip.dayOfMonth
dcCoverage sip.dcCoverage

issued sip.issued

ieEntityType sip.ieEntityType.getFieldValue()
objectIdentifierType sip.objectIdentifierType
objectIdentifierValue sip.objectIdentifierValue
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ class SipXmlGenerator {
dublinCore.addElement("dc:date", sip.dcDate)
dublinCore.addElement("dcterms:available", sip.dcTermsAvailable)
dublinCore.addElement("dc:coverage", sip.dcCoverage)
if (sip.issued != null && sip.issued != "") {
dublinCore.addElement("dcterms:issued", sip.issued)
}

ieParser.setIEDublinCore(dublinCore)

Expand Down
10 changes: 4 additions & 6 deletions docs/source/guides/release-notes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,17 @@ Contents of this document

Following this introduction, the Release Notes includes the following sections:

- **Changes since 1.0.0** - Changes since the last official release *1.0.0*.
- **1.0.3-SNAPSHOT**.

- **1.0.0** - Release 1.0.0.

- **1.0.0-SNAPSHOT** - Current 1.0.0 development.


Changes since 1.0.0
===================

This is a placeholder for changes since the official *2.0.1* release. Please add notes here for changes and fixes as
they are released into the master branch.
1.0.3-SNAPSHOT
==============

Adds an optional 'issued' field to sips

1.0.0
=====
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-5.0-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

0 comments on commit 71e6e1c

Please sign in to comment.