Skip to content

Commit

Permalink
Revert "Merge pull request #1515 from libris/feature/bulk-merge-uris-…
Browse files Browse the repository at this point in the history
…as-strings"

This reverts commit 89c697a, reversing
changes made to 49b735d.
  • Loading branch information
kwahlin committed Nov 14, 2024
1 parent a3d0609 commit 975cafe
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,8 @@ public Specification getSpecification() {
get(spec, TARGET_FORM_KEY, Collections.emptyMap())
);
case SpecType.Merge -> new Specification.Merge(
get(spec, List.of(DEPRECATE_KEY, "*", RDF_VALUE), Collections.emptyList()),
get(spec, List.of(KEEP_KEY, RDF_VALUE), "")
get(spec, List.of(DEPRECATE_KEY, "*", ID_KEY), Collections.emptyList()),
get(spec, List.of(KEEP_KEY, ID_KEY), "")
);
case SpecType.Other -> new Specification.Other(
get(spec, SCRIPT_KEY, null),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,12 @@ import whelk.util.DocumentUtil
import static whelk.JsonLd.ID_KEY
import static whelk.datatool.bulkchange.BulkJobDocument.DEPRECATE_KEY
import static whelk.datatool.bulkchange.BulkJobDocument.KEEP_KEY
import static whelk.datatool.bulkchange.BulkJobDocument.RDF_VALUE

List<Map> deprecateUris = asList(parameters.get(DEPRECATE_KEY))
Map keepUri = parameters.get(KEEP_KEY)
List deprecateLinks = asList(parameters.get(DEPRECATE_KEY))
Map keepLink = parameters.get(KEEP_KEY)

deprecateUris.each { deprecate ->
if (!deprecate.containsKey(RDF_VALUE)) return
Map deprecateLink = [(ID_KEY): deprecate[RDF_VALUE]]
selectByIds([deprecateLink[ID_KEY]]) { obsoleteSubdivision ->
deprecateLinks.each { deprecate ->
selectByIds([deprecate[ID_KEY]]) { obsoleteSubdivision ->
selectByIds(obsoleteSubdivision.getDependers()) { depender ->
Map thing = depender.graph[1] as Map

Expand All @@ -32,17 +29,16 @@ deprecateUris.each { deprecate ->
def modified = DocumentUtil.traverse(thing) { value, path ->
if (value instanceof Map && value[JsonLd.TYPE_KEY] == 'ComplexSubject') {
var t = asList(value.get('termComponentList'))
if (deprecateLink in t) {
if (deprecate in t) {
// TODO? add way to do this with an op? SplitReplace? [Replace, Insert]?
if (keepUri && keepUri.containsKey(RDF_VALUE) && path.size() > 1) {
var keepLink = [(ID_KEY): keepUri[RDF_VALUE]]
if (keepLink && path.size() > 1) {
var parent = DocumentUtil.getAtPath(thing, path.dropRight(1))
if (parent instanceof List && !parent.contains(keepLink)) {
parent.add(keepLink)
}
}

return mapSubject(value, t, deprecateLink)
return mapSubject(value, t, deprecate)
}
}
return DocumentUtil.NOP
Expand Down

0 comments on commit 975cafe

Please sign in to comment.