-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1147 from libris/feature/handle-linked-works
Feature/handle linked works
- Loading branch information
Showing
11 changed files
with
179 additions
and
77 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
whelktool/src/main/groovy/datatool/scripts/mergeworks/MergedWork.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package datatool.scripts.mergeworks | ||
|
||
import whelk.Document | ||
|
||
interface MergedWork { | ||
Document doc | ||
Collection<Doc> derivedFrom | ||
File reportDir | ||
} |
44 changes: 44 additions & 0 deletions
44
whelktool/src/main/groovy/datatool/scripts/mergeworks/NewWork.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package datatool.scripts.mergeworks | ||
|
||
import whelk.Document | ||
import whelk.IdGenerator | ||
|
||
class NewWork implements MergedWork { | ||
Document doc | ||
Collection<Doc> derivedFrom | ||
File reportDir | ||
|
||
NewWork(Map data, Collection<Doc> derivedFrom, File reportDir) { | ||
this.derivedFrom = derivedFrom | ||
this.reportDir = new File(reportDir, 'new') | ||
this.doc = buildWorkDocument(data) | ||
} | ||
|
||
private Document buildWorkDocument(Map workData) { | ||
String workId = IdGenerator.generate() | ||
def reportUri = "http://xlbuild.libris.kb.se/works/${reportDir.getPath().replace('report/', '')}/${workId}.html" | ||
|
||
workData['@id'] = "TEMPID#it" | ||
Document d = new Document([ | ||
"@graph": [ | ||
[ | ||
"@id" : "TEMPID", | ||
"@type" : "Record", | ||
"mainEntity" : ["@id": "TEMPID#it"], | ||
"technicalNote": [[ | ||
"@type" : "TechnicalNote", | ||
"hasNote": [[ | ||
"@type": "Note", | ||
"label": ["Maskinellt utbrutet verk... TODO"] | ||
]], | ||
"uri" : [reportUri] | ||
] | ||
]], | ||
workData | ||
] | ||
]) | ||
|
||
d.deepReplaceId(Document.BASE_URI.toString() + workId) | ||
return d | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
whelktool/src/main/groovy/datatool/scripts/mergeworks/UpdatedWork.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package datatool.scripts.mergeworks | ||
|
||
import whelk.Document | ||
|
||
class UpdatedWork implements MergedWork { | ||
Document doc | ||
Collection<Doc> derivedFrom | ||
File reportDir | ||
String checksum | ||
|
||
UpdatedWork(Document doc, Collection<Doc> derivedFrom, File reportDir, String checksum) { | ||
this.doc = doc | ||
this.derivedFrom = derivedFrom | ||
this.reportDir = new File(reportDir, 'updated') | ||
this.checksum = checksum | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.