uri_service 0.5.0 → 0.5.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f5dfd4b23cd1ac5fd404ce7a52833497fcec6f17
4
- data.tar.gz: cd29ef22f63ee376810d514be0a27c0e7210e866
3
+ metadata.gz: 125d8d44449e4c7132efa4e2f29cd44ae9a88fff
4
+ data.tar.gz: d3e72a5e1687b2d7f794689586a28b0750df52cf
5
5
  SHA512:
6
- metadata.gz: 6fc35d8cd790eeebc46e670fad05890bc570522473bc9beaa25dd3b6f77d143f7d0765972a94f572f4029bd1aa7244896e96a9ca299d801d904df2f9ec39ea22
7
- data.tar.gz: 5538858d331a40fa7ef8985068a4ff0c9c48586be93667830cfa1670b65b87205613d9471e66c7eae584373dd32b208786a8b8b6e6e77547a2c0dcd37e2f4f5c
6
+ metadata.gz: 4da2d67e2b91a38373fb672d9e012feb8e0ef722e8a72d324ff07ae10a19e10f2cf78d0d3d8d983e950ad34dd677d4a6397a1bc5c78c0ca0418391507a86402e
7
+ data.tar.gz: b8b1f5ec96d395c7109a34809a218f90c9f901f8511adead76c1731461c824fb9729a9998cb9f5caefeb52bf5eb3a371ea6d79b3dc201535d541aa4a9b312460
@@ -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 this is a new TEMPORARY term and we ran into a Sequel::UniqueConstraintViolation,
561
- # that mean that the term already exists. We should return that existing term.
562
- # don't create a new one. Instead, return the existing one.
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
- return self.find_term_by_uri(uri)
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
@@ -1,6 +1,6 @@
1
1
  module UriService
2
2
 
3
- VERSION = '0.5.0'
3
+ VERSION = '0.5.1'
4
4
 
5
5
  def self.version
6
6
  VERSION
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: uri_service
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eric O'Hanlon