uri_service 0.5.0 → 0.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/uri_service/client.rb +25 -7
- data/lib/uri_service/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 125d8d44449e4c7132efa4e2f29cd44ae9a88fff
|
4
|
+
data.tar.gz: d3e72a5e1687b2d7f794689586a28b0750df52cf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4da2d67e2b91a38373fb672d9e012feb8e0ef722e8a72d324ff07ae10a19e10f2cf78d0d3d8d983e950ad34dd677d4a6397a1bc5c78c0ca0418391507a86402e
|
7
|
+
data.tar.gz: b8b1f5ec96d395c7109a34809a218f90c9f901f8511adead76c1731461c824fb9729a9998cb9f5caefeb52bf5eb3a371ea6d79b3dc201535d541aa4a9b312460
|
data/lib/uri_service/client.rb
CHANGED
@@ -509,7 +509,8 @@ class UriService::Client
|
|
509
509
|
# - Performs some data validations.
|
510
510
|
# - Ensures uniqueness of URIs in database.
|
511
511
|
# - Returns an existing TEMPORARY term if a user attempts to
|
512
|
-
# create a new TEMPORARY term with an existing value/vocabulary combo
|
512
|
+
# create a new TEMPORARY term with an existing value/vocabulary combo,
|
513
|
+
# also adding non-existent supplied additional_fields to the existing temporary term.
|
513
514
|
def create_term_impl(type, vocabulary_string_key, value, uri, authority, additional_fields)
|
514
515
|
|
515
516
|
raise UriService::InvalidTermTypeError, 'Invalid type: ' + type unless VALID_TYPES.include?(type)
|
@@ -557,19 +558,36 @@ class UriService::Client
|
|
557
558
|
send_term_to_solr(vocabulary_string_key, value, uri, authority, additional_fields, type, db_id)
|
558
559
|
rescue Sequel::UniqueConstraintViolation
|
559
560
|
|
560
|
-
# If
|
561
|
-
# that
|
562
|
-
#
|
561
|
+
# If the user is trying to create a new TEMPORARY term and we ran into a Sequel::UniqueConstraintViolation,
|
562
|
+
# that means that the term already exists. We will return that existing term, but also update the term with
|
563
|
+
# any non-existent additional_fields supplied by the user and during this create operation, and a supplied
|
564
|
+
# authority if the term did not already have an authority.
|
563
565
|
if type == UriService::TermType::TEMPORARY
|
564
|
-
|
566
|
+
temporary_term = self.find_term_by_uri(uri)
|
567
|
+
|
568
|
+
opts = {}
|
569
|
+
non_existent_additional_fields = additional_fields.keys - temporary_term.keys
|
570
|
+
|
571
|
+
if non_existent_additional_fields.length > 0
|
572
|
+
additional_fields_to_merge_in = additional_fields.select{|k, v| non_existent_additional_fields.include?(k)}
|
573
|
+
opts[:additional_fields] = additional_fields_to_merge_in
|
574
|
+
end
|
575
|
+
|
576
|
+
if temporary_term['authority'].nil? && authority.length > 0 && authority != temporary_term['authority']
|
577
|
+
opts[:authority] = authority
|
578
|
+
end
|
579
|
+
|
580
|
+
if opts.size > 0
|
581
|
+
temporary_term = UriService.client.update_term(temporary_term['uri'], opts, true)
|
582
|
+
end
|
583
|
+
|
584
|
+
return temporary_term
|
565
585
|
end
|
566
586
|
|
567
587
|
raise UriService::ExistingUriError, "A term already exists with uri: " + uri + " (conflict found via uri_hash check)"
|
568
|
-
|
569
588
|
end
|
570
589
|
|
571
590
|
return generate_frozen_term_hash(vocabulary_string_key, value, uri, authority, additional_fields, type, db_id)
|
572
|
-
|
573
591
|
end
|
574
592
|
end
|
575
593
|
end
|
data/lib/uri_service/version.rb
CHANGED