diff --git a/docs/api/Collection.html b/docs/api/Collection.html index 587f681c0..c2c8b3660 100644 --- a/docs/api/Collection.html +++ b/docs/api/Collection.html @@ -139,8 +139,7 @@

EMPTY =
-

definition of empty

- +
@@ -149,7 +148,7 @@

-
-1 # definition of empty
+
-1
@@ -998,6 +997,29 @@

Retrive a matrix of all parts.

+ + + +
  • + + + #parts ⇒ Array + + + + + + + + + + + + + +

    Return all parts for this collection.

    +
    +
  • @@ -1349,20 +1371,20 @@

     
     
    -326
    -327
    -328
    -329
    -330
    -331
    +309 +310 +311 +312 +313 +314 -
    # File 'app/models/collection.rb', line 326
    +      
    # File 'app/models/collection.rb', line 309
     
     def self.containing(s, ot = nil)
       return [] unless s
     
    -  cids = PartAssociation.joins(:part).where("sample_id = ?", to_sample_id(s)).map(&:collection_id)
    +  cids = PartAssociation.joins(:part).where('sample_id = ?', to_sample_id(s)).map(&:collection_id)
       Collection.where(id: cids).select { |c| !ot || c.object_type_id == ot.id }
     end
    @@ -1431,6 +1453,23 @@

     
     
    +376
    +377
    +378
    +379
    +380
    +381
    +382
    +383
    +384
    +385
    +386
    +387
    +388
    +389
    +390
    +391
    +392
     393
     394
     395
    @@ -1452,33 +1491,16 @@ 

    411 412 413 -414 -415 -416 -417 -418 -419 -420 -421 -422 -423 -424 -425 -426 -427 -428 -429 -430 -431

    +414

    -
    # File 'app/models/collection.rb', line 393
    +      
    # File 'app/models/collection.rb', line 376
     
     def self.new_collection(ctype)
     
    -  if ctype.class == String
    +  if ctype.is_a?(String)
         name = ctype
    -    o = ObjectType.find_by_name(name)
    +    o = ObjectType.find_by(name: name)
       else
         o = ctype
       end
    @@ -1492,7 +1514,7 @@ 

    if o i.object_type_id = o.id - wiz = Wizard.find_by_name(o.prefix) + wiz = Wizard.find_by(name: o.prefix) locator = wiz.next if wiz i.set_primitive_location locator.to_s if wiz end @@ -1585,16 +1607,16 @@

     
     
    -356
    -357
    -358
    -359
    -360
    -361
    -362
    +339 +340 +341 +342 +343 +344 +345

    -
    # File 'app/models/collection.rb', line 356
    +      
    # File 'app/models/collection.rb', line 339
     
     def self.parts(sample, object_type = nil)
       plist = []
    @@ -1689,23 +1711,23 @@ 

     
     
    -374
    -375
    -376
    -377
    -378
    -379
    -380
    -381
    -382
    -383
    -384
    -385
    -386
    -387
    +357 +358 +359 +360 +361 +362 +363 +364 +365 +366 +367 +368 +369 +370

    -
    # File 'app/models/collection.rb', line 374
    +      
    # File 'app/models/collection.rb', line 357
     
     def self.spread(samples, name, options = {})
       opts = { reverse: false }.merge(options)
    @@ -1753,49 +1775,37 @@ 

     
     
    -526
    -527
    -528
    -529
    -530
    -531
    -532
    -533
    -534
    -535
    -536
    -537
    -538
    -539
    -540
    -541
    -542
    -543
    -544
    -545
    +502 +503 +504 +505 +506 +507 +508 +509 +510 +511 +512 +513 +514 +515

    -
    # File 'app/models/collection.rb', line 526
    +      
    # File 'app/models/collection.rb', line 502
     
     def self.to_sample(x)
    -  if x.class == Integer || (x.class == Fixnum && x >= 0) # Not sure where "Integer" came from here ---ek
    -    r = Sample.find(x)
    -  elsif x.class == Item
    -    if x.sample
    -      r = x.sample
    -    else
    -      raise 'When the third argument to Collection.set is an item, it should be associated with a sample.'
    -    end
    -  elsif x.class == Sample
    -    r = x
    -  elsif x.class == String
    -    r = Sample.find(x.split(':')[0].to_i)
    -  elsif !x || x == -1
    -    r = nil
    -  else
    -    raise "Expecting item, a sample, or a sample id, but got '#{x}' which is a #{x.class}"
    +  return Sample.find(x) if x.is_a?(Integer) && x >= 0
    +
    +  if x.is_a?(Item)
    +    raise 'When the third argument to Collection.set is an item, it should be associated with a sample.' unless x.sample
    +
    +    return x.sample
       end
    -  r
    +  return x if x.is_a?(Sample)
    +  return Sample.find(x.split(':')[0].to_i) if x.is_a?(String)
    +  return nil if !x || x == -1
    +
    +  raise "Expecting item, a sample, or a sample id, but got '#{x}' which is a #{x.class}"
     end
    @@ -1827,51 +1837,37 @@

     
     
    -497
    -498
    -499
    -500
    -501
    -502
    -503
    -504
    -505
    -506
    -507
    -508
    -509
    -510
    -511
    -512
    -513
    -514
    -515
    -516
    -517
    +480 +481 +482 +483 +484 +485 +486 +487 +488 +489 +490 +491 +492 +493

    -
    # File 'app/models/collection.rb', line 497
    +      
    # File 'app/models/collection.rb', line 480
     
     def self.to_sample_id(x)
    -  r = EMPTY
    -  if x.class == Integer || x.class == Fixnum # Not sure where "Integer" came from here ---ek
    -    r = x
    -  elsif x.class == Item
    -    if x.sample
    -      r = x.sample.id
    -    else
    -      raise 'When the third argument to Collection.set is an item, it should be associated with a sample.'
    -    end
    -  elsif x.class == Sample
    -    r = x.id
    -  elsif x.class == String
    -    r = x.split(':')[0].to_i
    -  elsif !x
    -    r = EMPTY
    -  else
    -    raise "The third argument to Collection.set should be an item, a sample, or a sample id, but it was '#{x}' which is a #{x.class}"
    +  return x if x.is_a?(Integer)
    +
    +  if x.is_a?(Item)
    +    raise 'When the third argument to Collection.set is an item, it should be associated with a sample.' unless x.sample
    +
    +    return x.sample.id
       end
    -  r
    +  return x.id if x.is_a?(Sample)
    +  return x.split(':')[0].to_i if x.is_a?(String)
    +  return EMPTY unless x
    +
    +  raise "The third argument to Collection.set should be an item, a sample, or a sample id, but it was '#{x}' which is a #{x.class}"
     end
    @@ -1979,23 +1975,23 @@

     
     
    -565
    -566
    -567
    -568
    -569
    -570
    -571
    -572
    -573
    -574
    -575
    -576
    -577
    -578
    +535 +536 +537 +538 +539 +540 +541 +542 +543 +544 +545 +546 +547 +548

    -
    # File 'app/models/collection.rb', line 565
    +      
    # File 'app/models/collection.rb', line 535
     
     def add_one(x, options = {})
       opts = { reverse: false }.merge(options)
    @@ -2077,24 +2073,24 @@ 

     
     
    -658
    -659
    -660
    -661
    -662
    -663
    -664
    -665
    -666
    -667
    -668
    -669
    -670
    -671
    -672
    +626 +627 +628 +629 +630 +631 +632 +633 +634 +635 +636 +637 +638 +639 +640

    -
    # File 'app/models/collection.rb', line 658
    +      
    # File 'app/models/collection.rb', line 626
     
     def add_samples(samples, options = {})
       opts = { reverse: false }.merge(options)
    @@ -2176,12 +2172,12 @@ 

     
     
    -438
    -439
    -440
    +421 +422 +423

    -
    # File 'app/models/collection.rb', line 438
    +      
    # File 'app/models/collection.rb', line 421
     
     def apportion(r, c)
       ### self.matrix = Array.new(r, Array.new(c, EMPTY))
    @@ -2263,6 +2259,14 @@ 

     
     
    +252
    +253
    +254
    +255
    +256
    +257
    +258
    +259
     260
     261
     262
    @@ -2277,18 +2281,10 @@ 

    271 272 273 -274 -275 -276 -277 -278 -279 -280 -281 -282

    +274

    -
    # File 'app/models/collection.rb', line 260
    +      
    # File 'app/models/collection.rb', line 252
     
     def assign_sample_to_pairs(sample, pairs)
     
    @@ -2359,53 +2355,51 @@ 

     
     
    +672
    +673
    +674
    +675
    +676
    +677
    +678
    +679
    +680
    +681
    +682
    +683
    +684
    +685
    +686
    +687
    +688
    +689
    +690
    +691
    +692
    +693
    +694
    +695
    +696
    +697
    +698
    +699
    +700
    +701
    +702
    +703
    +704
    +705
    +706
     707
     708
     709
     710
     711
     712
    -713
    -714
    -715
    -716
    -717
    -718
    -719
    -720
    -721
    -722
    -723
    -724
    -725
    -726
    -727
    -728
    -729
    -730
    -731
    -732
    -733
    -734
    -735
    -736
    -737
    -738
    -739
    -740
    -741
    -742
    -743
    -744
    -745
    -746
    -747
    -748
    -749
    -750
    +713

    -
    # File 'app/models/collection.rb', line 707
    +      
    # File 'app/models/collection.rb', line 672
     
     def associate_matrix(sample_matrix)
     
    @@ -2423,9 +2417,7 @@ 

    collection_id_string = SecureRandom.hex # random string used to identify saved parts (0...dr).each do |r| (0...dc).each do |c| - if sample_matrix_aux[r][c] != nil - parts << Item.new(quantity: 1, inuse: 0, sample_id: sample_matrix_aux[r][c], object_type_id: part_type.id, data: collection_id_string) - end + parts << Item.new(quantity: 1, inuse: 0, sample_id: sample_matrix_aux[r][c], object_type_id: part_type.id, data: collection_id_string) unless sample_matrix_aux[r][c].nil? end end Item.import parts @@ -2440,7 +2432,7 @@

    pas = [] (0...dr).each do |r| (0...dc).each do |c| - if sample_matrix_aux[r][c] != nil + unless sample_matrix_aux[r][c].nil? pas << PartAssociation.new(collection_id: id, part_id: parts[index].id, row: r, column: c) index += 1 end @@ -2480,13 +2472,13 @@

     
     
    -610
    -611
    -612
    -613
    +580 +581 +582 +583

    -
    # File 'app/models/collection.rb', line 610
    +      
    # File 'app/models/collection.rb', line 580
     
     def capacity
       d = dimensions
    @@ -2521,12 +2513,12 @@ 

     
     
    -752
    -753
    -754
    +715 +716 +717

    -
    # File 'app/models/collection.rb', line 752
    +      
    # File 'app/models/collection.rb', line 715
     
     def clear
       part_association_list.map(&:destroy)
    @@ -2593,6 +2585,8 @@ 

     
     
    +193
    +194
     195
     196
     197
    @@ -2607,21 +2601,19 @@ 

    206 207 208 -209 -210 -211

    +209

    -
    # File 'app/models/collection.rb', line 195
    +      
    # File 'app/models/collection.rb', line 193
     
     def data_matrix(key)
     
       pas = part_association_list
       part_ids = pas.collect { |p| p.part_id }.uniq
     
    -  das = DataAssociation.where(parent_class: "Item", parent_id: part_ids, key: key)
    +  das = DataAssociation.where(parent_class: 'Item', parent_id: part_ids, key: key)
     
    -  r, c = self.dimensions
    +  r, c = dimensions
       m = Array.new(r) { Array.new(c) }
     
       pas.each do |pa|
    @@ -2693,12 +2685,12 @@ 

     
     
    -216
    -217
    -218
    +214 +215 +216

    -
    # File 'app/models/collection.rb', line 216
    +      
    # File 'app/models/collection.rb', line 214
     
     def data_matrix_values(key)
       (data_matrix(key).map { |row| row.map { |da| da ? da.value : nil } })
    @@ -2769,6 +2761,14 @@ 

     
     
    +279
    +280
    +281
    +282
    +283
    +284
    +285
    +286
     287
     288
     289
    @@ -2777,51 +2777,25 @@ 

    292 293 294 -295 -296 -297 -298 -299 -300 -301 -302 -303 -304 -305 -306 -307 -308 -309 -310 -311 -312

    +295

    -
    # File 'app/models/collection.rb', line 287
    +      
    # File 'app/models/collection.rb', line 279
     
     def delete_selection(pairs)
    -
       pairs.each do |r, c|
    -
         pas = PartAssociation.includes(:part).where(collection_id: id, row: r, column: c)
    -
    -    unless pas.empty?
    -
    -      pas[0].part.mark_as_deleted
    -      pas[0].destroy
    -
    -      associate(
    -        :"Part Deleted",
    -        "The sample at #{r}, #{c} was deleted. " +
    -        "It used to be sample #{pas[0].part.sample_id} via deleted part #{pas[0].part.id}.",
    -        nil,
    -        duplicates: true
    -      )
    -
    -      puts "DONE!!!!!!!!!!!"
    -
    -    end
    -
    +    next if pas.empty?
    +
    +    pas[0].part.mark_as_deleted
    +    pas[0].destroy
    +    associate(
    +      :"Part Deleted",
    +      "The sample at #{r}, #{c} was deleted. " \
    +      "It used to be sample #{pas[0].part.sample_id} via deleted part #{pas[0].part.id}.",
    +      nil,
    +      duplicates: true
    +    )
       end
     
     end
    @@ -2868,22 +2842,22 @@

     
     
    -815
    -816
    -817
    -818
    -819
    -820
    -821
    +778 +779 +780 +781 +782 +783 +784

    -
    # File 'app/models/collection.rb', line 815
    +      
    # File 'app/models/collection.rb', line 778
     
     def dimensions
       # Should look up object type dims instead
       dims = [object_type.rows, object_type.columns]
    -  dims[0] = 12 unless dims[0] != nil
    -  dims[1] = 1 unless dims[1] != nil
    +  dims[0] = 12 if dims[0].nil?
    +  dims[1] = 1 if dims[1].nil?
       dims
     end
    @@ -2948,14 +2922,14 @@

     
     
    -20
    -21
     22
     23
    -24
    +24 +25 +26

    -
    # File 'app/models/collection.rb', line 20
    +      
    # File 'app/models/collection.rb', line 22
     
     def drop_data_matrix(key)
       ids = data_matrix(key).flatten.compact.collect { |da| da.id }
    @@ -3006,22 +2980,20 @@ 

     
     
    +142
    +143
    +144
    +145
    +146
     147
     148
     149
     150
     151
    -152
    -153
    -154
    -155
    -156
    -157
    -158
    -159
    +152

    -
    # File 'app/models/collection.rb', line 147
    +      
    # File 'app/models/collection.rb', line 142
     
     def each_row_col(matrix, offset: [0, 0])
       dr, dc = dimensions
    @@ -3029,9 +3001,7 @@ 

    (0...matrix[r].length).each do |c| x = r + offset[0] y = c + offset[1] - if x < dr && y < dc - yield r, c, x, y - end + yield r, c, x, y if x < dr && y < dc end end @@ -3079,10 +3049,10 @@

     
     
    -625
    +595

    -
    # File 'app/models/collection.rb', line 625
    +      
    # File 'app/models/collection.rb', line 595
     
     delegate :empty?, to: :get_non_empty
    @@ -3147,20 +3117,20 @@

     
     
    -467
    -468
    -469
    -470
    -471
    -472
    +450 +451 +452 +453 +454 +455

    -
    # File 'app/models/collection.rb', line 467
    +      
    # File 'app/models/collection.rb', line 450
     
     def find(val)
       PartAssociation
         .joins(:part)
    -    .where("sample_id = ? AND collection_id = ?", to_sample_id(val), id)
    +    .where('sample_id = ? AND collection_id = ?', to_sample_id(val), id)
         .collect { |pa| [pa.row, pa.column] }
     end
    @@ -3206,12 +3176,12 @@

     
     
    -618
    -619
    -620
    +588 +589 +590

    -
    # File 'app/models/collection.rb', line 618
    +      
    # File 'app/models/collection.rb', line 588
     
     def full?
       get_empty.empty?
    @@ -3263,12 +3233,12 @@ 

     
     
    -477
    -478
    -479
    +460 +461 +462

    -
    # File 'app/models/collection.rb', line 477
    +      
    # File 'app/models/collection.rb', line 460
     
     def get_empty
       select { |x| x == EMPTY }
    @@ -3302,12 +3272,12 @@ 

     
     
    -761
    -762
    -763
    +724 +725 +726

    -
    # File 'app/models/collection.rb', line 761
    +      
    # File 'app/models/collection.rb', line 724
     
     def get_matrix
       matrix
    @@ -3359,12 +3329,12 @@ 

     
     
    -484
    -485
    -486
    +467 +468 +469

    -
    # File 'app/models/collection.rb', line 484
    +      
    # File 'app/models/collection.rb', line 467
     
     def get_non_empty
       select { |x| x != EMPTY }
    @@ -3460,29 +3430,17 @@ 

     
     
    -130
     131
     132
     133
    -134
    -135
    -136
    -137
    -138
    -139
    +134

    -
    # File 'app/models/collection.rb', line 130
    +      
    # File 'app/models/collection.rb', line 131
     
     def get_part_data(key, r, c)
    -
       pa = part_association(r, c)
    -  if pa && pa.part
    -    pa.part.get(key)
    -  else
    -    nil
    -  end
    -
    +  pa.part.get(key) if pa && pa.part
     end
    @@ -3542,13 +3500,13 @@

     
     
    -446
    -447
    -448
    -449
    +429 +430 +431 +432

    -
    # File 'app/models/collection.rb', line 446
    +      
    # File 'app/models/collection.rb', line 429
     
     def include?(x)
       sel = find x
    @@ -3597,28 +3555,28 @@ 

     
     
    -768
    -769
    -770
    -771
    -772
    -773
    -774
    -775
    -776
    -777
    -778
    -779
    -780
    +731 +732 +733 +734 +735 +736 +737 +738 +739 +740 +741 +742 +743

    -
    # File 'app/models/collection.rb', line 768
    +      
    # File 'app/models/collection.rb', line 731
     
     def matrix
       if @matrix_cache
         @matrix_cache
       else
    -    r, c = self.dimensions
    +    r, c = dimensions
         m = Array.new(r) { Array.new(c, EMPTY) }
         PartAssociation.includes(:part).where(collection_id: id).each do |pa|
           m[pa.row][pa.column] = pa.part.sample_id if pa.row < r && pa.column < c && pa.part.sample_id
    @@ -3657,12 +3615,12 @@ 

     
     
    -783
    -784
    -785
    +746 +747 +748

    -
    # File 'app/models/collection.rb', line 783
    +      
    # File 'app/models/collection.rb', line 746
     
     def matrix=(m)
       associate_matrix m
    @@ -3729,13 +3687,13 @@ 

     
     
    -89
     90
     91
    -92
    +92 +93

    -
    # File 'app/models/collection.rb', line 89
    +      
    # File 'app/models/collection.rb', line 90
     
     def new_data_matrix(key)
       r, c = dimensions
    @@ -3844,26 +3802,26 @@ 

     
     
    -794
    -795
    -796
    -797
    -798
    -799
    -800
    -801
    -802
    -803
    -804
    -805
    -806
    -807
    -808
    -809
    -810
    +757 +758 +759 +760 +761 +762 +763 +764 +765 +766 +767 +768 +769 +770 +771 +772 +773

    -
    # File 'app/models/collection.rb', line 794
    +      
    # File 'app/models/collection.rb', line 757
     
     def next(r, c, options = {})
     
    @@ -3927,27 +3885,27 @@ 

     
     
    -828
    -829
    -830
    -831
    -832
    -833
    -834
    -835
    -836
    -837
    -838
    -839
    -840
    -841
    -842
    -843
    -844
    -845
    +791 +792 +793 +794 +795 +796 +797 +798 +799 +800 +801 +802 +803 +804 +805 +806 +807 +808

    -
    # File 'app/models/collection.rb', line 828
    +      
    # File 'app/models/collection.rb', line 791
     
     def non_empty_string
     
    @@ -4010,12 +3968,12 @@ 

     
     
    -491
    -492
    -493
    +474 +475 +476

    -
    # File 'app/models/collection.rb', line 491
    +      
    # File 'app/models/collection.rb', line 474
     
     def num_samples
       get_non_empty.size
    @@ -4097,25 +4055,17 @@ 

     
     
    +222
    +223
     224
    -225
    -226
    -227
    -228
    -229
    -230
    -231
    +225

    -
    # File 'app/models/collection.rb', line 224
    +      
    # File 'app/models/collection.rb', line 222
     
     def part(r, c)
       pas = PartAssociation.includes(:part).where(collection_id: id, row: r, column: c)
    -  if pas.length == 1
    -    pas[0].part
    -  else
    -    nil
    -  end
    +  pas[0].part if pas.length == 1
     end
    @@ -4146,13 +4096,13 @@

     
     
    -12
    -13
     14
    -15
    +15 +16 +17

    -
    # File 'app/models/collection.rb', line 12
    +      
    # File 'app/models/collection.rb', line 14
     
     def part_association_list
       # this works but rails generated part_associations seems not to
    @@ -4205,28 +4155,25 @@ 

     
     
    +229
    +230
    +231
    +232
    +233
    +234
     235
     236
     237
     238
     239
     240
    -241
    -242
    -243
    -244
    -245
    -246
    -247
    -248
    -249
    +241

    -
    # File 'app/models/collection.rb', line 235
    +      
    # File 'app/models/collection.rb', line 229
     
     def part_matrix
    -
    -  r, c = self.dimensions
    +  r, c = dimensions
       m = Array.new(r) { Array.new(c) }
     
       PartAssociation
    @@ -4237,7 +4184,63 @@ 

    end m +end

    + + + + + +
    +

    + + #partsArray + + + + + +

    +
    +

    Return all parts for this collection

    + +
    +
    +
    + +

    Returns:

    +
      + +
    • + + + (Array) + + + +
    • + +
    + +
    + + + @@ -4276,12 +4279,12 @@

     
     
    -341
    -342
    -343
    +324 +325 +326

    +
    +
    +
    +184
    +185
    +186
    +187
    +188
    +
    +
    # File 'app/models/collection.rb', line 184
    +
    +def parts
    +  PartAssociation.where(collection_id: id).collect do |association|
    +    association.part
    +  end
     end
    -
    # File 'app/models/collection.rb', line 341
    +      
    # File 'app/models/collection.rb', line 324
     
     def position(s)
       find(s).first
    @@ -4315,13 +4318,13 @@ 

     
     
    -345
    -346
    -347
    -348
    +328 +329 +330 +331

    -
    # File 'app/models/collection.rb', line 345
    +      
    # File 'app/models/collection.rb', line 328
     
     def position_as_hash(s)
       pos = find to_sample_id(s)
    @@ -4363,12 +4366,12 @@ 

     
     
    -581
    -582
    -583
    +551 +552 +553

    -
    # File 'app/models/collection.rb', line 581
    +      
    # File 'app/models/collection.rb', line 551
     
     def remove_one(x = nil, options = {})
       subtract_one(x, options)
    @@ -4420,17 +4423,17 @@ 

     
     
    -454
    -455
    -456
    -457
    -458
    -459
    -460
    -461
    +437 +438 +439 +440 +441 +442 +443 +444

    -
    # File 'app/models/collection.rb', line 454
    +      
    # File 'app/models/collection.rb', line 437
     
     def select
       raise 'need selection block' unless block_given?
    @@ -4519,39 +4522,35 @@ 

     
     
    -632
    -633
    -634
    -635
    -636
    -637
    -638
    -639
    -640
    -641
    -642
    -643
    -644
    -645
    -646
    -647
    -648
    -649
    -650
    -651
    -652
    +602 +603 +604 +605 +606 +607 +608 +609 +610 +611 +612 +613 +614 +615 +616 +617 +618 +619 +620

    -
    # File 'app/models/collection.rb', line 632
    +      
    # File 'app/models/collection.rb', line 602
     
     def set(r, c, x)
       # TODO: Check dimensions
       @matrix_cache = nil
       if x == EMPTY
         pas = PartAssociation.where(collection_id: id, row: r, column: c)
    -    if pas.length == 1
    -      pas[0].destroy
    -    end
    +    pas[0].destroy if pas.length == 1
       else
         s = Collection.to_sample(x)
         part = Item.make({ quantity: 1, inuse: 0 }, sample: s, object_type: part_type)
    @@ -4657,8 +4656,6 @@ 

     
     
    -31
    -32
     33
     34
     35
    @@ -4710,16 +4707,16 @@ 

    81 82 83 -84

    +84 +85

    -
    # File 'app/models/collection.rb', line 31
    +      
    # File 'app/models/collection.rb', line 33
     
     def set_data_matrix(key, matrix, offset: [0, 0])
     
       pm = part_matrix
       dm = data_matrix(key)
    -  r, c = dimensions
       parts = []
       pas = []
       das = []
    @@ -4756,11 +4753,11 @@ 

    index = 0 each_row_col(matrix, offset: offset) do |x, y, ox, oy| - if !pm[ox][oy] - pas << PartAssociation.new(collection_id: id, part_id: parts[index].id, row: ox, column: oy) - das << parts[index].lazy_associate(key, matrix[x][y]) - index += 1 - end + next if pm[ox][oy] + + pas << PartAssociation.new(collection_id: id, part_id: parts[index].id, row: ox, column: oy) + das << parts[index].lazy_associate(key, matrix[x][y]) + index += 1 end PartAssociation.import pas unless pas.empty? @@ -4805,12 +4802,12 @@

     
     
    -757
    -758
    -759
    +720 +721 +722

    -
    # File 'app/models/collection.rb', line 757
    +      
    # File 'app/models/collection.rb', line 720
     
     def set_matrix(m)
       associate_matrix m
    @@ -4931,7 +4928,6 @@ 

     
     
    -110
     111
     112
     113
    @@ -4943,10 +4939,11 @@ 

    119 120 121 -122

    +122 +123

    -
    # File 'app/models/collection.rb', line 110
    +      
    # File 'app/models/collection.rb', line 111
     
     def set_part_data(key, r, c, value)
     
    @@ -5046,26 +5043,26 @@ 

     
     
    -592
    -593
    -594
    -595
    -596
    -597
    -598
    -599
    -600
    -601
    -602
    -603
    -604
    -605
    -606
    -607
    -608
    +562 +563 +564 +565 +566 +567 +568 +569 +570 +571 +572 +573 +574 +575 +576 +577 +578

    -
    # File 'app/models/collection.rb', line 592
    +      
    # File 'app/models/collection.rb', line 562
     
     def subtract_one(x = nil, options = {})
       opts = { reverse: true }.merge(options)
    @@ -5113,12 +5110,12 @@ 

     
     
    -519
    -520
    -521
    +495 +496 +497

    -
    # File 'app/models/collection.rb', line 519
    +      
    # File 'app/models/collection.rb', line 495
     
     def to_sample_id(x)
       Collection.to_sample_id(x)
    @@ -5153,35 +5150,32 @@ 

     
     
    -675
    -676
    -677
    -678
    -679
    -680
    -681
    -682
    -683
    -684
    -685
    -686
    -687
    -688
    -689
    -690
    -691
    -692
    -693
    -694
    -695
    -696
    -697
    -698
    -699
    -700
    +643 +644 +645 +646 +647 +648 +649 +650 +651 +652 +653 +654 +655 +656 +657 +658 +659 +660 +661 +662 +663 +664 +665

    -
    # File 'app/models/collection.rb', line 675
    +      
    # File 'app/models/collection.rb', line 643
     
     def to_sample_id_matrix(sample_matrix)
     
    @@ -5193,16 +5187,13 @@ 

    # convert sample matrix into ids (0...dr).each do |r| (0...dc).each do |c| - klass = sample_matrix[r][c].class - if klass == Sample - sample_matrix_aux[r][c] = sample_matrix[r][c].id - elsif klass == Item - sample_matrix_aux[r][c] = Item.sample_id - elsif klass == Fixnum && sample_matrix[r][c] > 0 - sample_matrix_aux[r][c] = sample_matrix[r][c] - else - sample_matrix_aux[r][c] = nil - end + sample_matrix_aux[r][c] = if sample_matrix[r][c].is_a?(Sample) + sample_matrix[r][c].id + elsif sample_matrix[r][c].is_a?(Item) + Item.sample_id + elsif sample_matrix[r][c].is_a?(Integer) && sample_matrix[r][c] > 0 + sample_matrix[r][c] + end end end @@ -5219,9 +5210,9 @@

    diff --git a/docs/api/DataAssociation.html b/docs/api/DataAssociation.html index 8cc5f905f..f5dafaf89 100644 --- a/docs/api/DataAssociation.html +++ b/docs/api/DataAssociation.html @@ -278,12 +278,12 @@

     
     
    -24
    -25
    -26
    +26 +27 +28

    -
    # File 'app/models/data_association.rb', line 24
    +      
    # File 'app/models/data_association.rb', line 26
     
     def self.find_parent(parent_class, parent_id)
       Object.const_get(parent_class).find(parent_id)
    @@ -323,14 +323,14 @@ 

     
     
    -18
    -19
     20
     21
    -22
    +22 +23 +24

    -
    # File 'app/models/data_association.rb', line 18
    +      
    # File 'app/models/data_association.rb', line 20
     
     def as_json(_options = {})
       result = super(include: :upload)
    @@ -366,14 +366,14 @@ 

     
     
    -7
    -8
     9
     10
    -11
    +11 +12 +13

    -
    # File 'app/models/data_association.rb', line 7
    +      
    # File 'app/models/data_association.rb', line 9
     
     def full_object
       HashWithIndifferentAccess.new(JSON.parse(object, symbolize_names: true))
    @@ -409,8 +409,6 @@ 

     
     
    -28
    -29
     30
     31
     32
    @@ -419,32 +417,20 @@ 

    35 36 37 -38 -39 -40 -41 -42 -43

    +38

    -
    # File 'app/models/data_association.rb', line 28
    +      
    # File 'app/models/data_association.rb', line 30
     
     def may_delete(user)
       parent = DataAssociation.find_parent(parent_class, parent_id)
       puts "Class = #{parent_class}"
    -  if parent_class == 'Item'
    -    return parent.sample && parent.sample.user_id = user.id
    -  elsif parent_class == 'Collection'
    -    return user.is_admin # since collections are managed by admins?
    -  elsif parent_class == 'Operation'
    -    return true # since operations don't yet have owners (actually they do now, so this should be fixed)
    -  elsif parent_class == 'Plan'
    -    return true # plans don't have owners yet either
    -  elsif parent_class == 'OperationType'
    -    return true # operation types don't have owners yet either
    -  end
    -
    -end
    + return parent.sample && parent.sample.user_id = user.id if parent_class == 'Item' + return user.is_admin if parent_class == 'Collection' # since collections are managed by admins? + return true if parent_class == 'Operation' # since operations don't yet have owners (actually they do now, so this should be fixed) + return true if parent_class == 'Plan' # plans don't have owners yet either + return true if parent_class == 'OperationType' # operation types don't have owners yet either +end
    @@ -474,13 +460,13 @@

     
     
    -13
    -14
     15
    -16
    +16 +17 +18

    -
    # File 'app/models/data_association.rb', line 13
    +      
    # File 'app/models/data_association.rb', line 15
     
     def value
       h = full_object
    @@ -496,9 +482,9 @@ 

    diff --git a/docs/api/DataAssociator.html b/docs/api/DataAssociator.html index ddacc284c..f775d6886 100644 --- a/docs/api/DataAssociator.html +++ b/docs/api/DataAssociator.html @@ -419,6 +419,9 @@

     
     
    +168
    +169
    +170
     171
     172
     173
    @@ -426,13 +429,10 @@ 

    175 176 177 -178 -179 -180 -181

    +178

    -
    # File 'app/helpers/data_associator.rb', line 171
    +      
    # File 'app/helpers/data_associator.rb', line 168
     
     def append_notes(text)
       da = get_association :notes
    @@ -541,7 +541,6 @@ 

     
     
    -93
     94
     95
     96
    @@ -562,7 +561,7 @@ 

    111

    -
    # File 'app/helpers/data_associator.rb', line 93
    +      
    # File 'app/helpers/data_associator.rb', line 94
     
     def associate(key, value, upload = nil, options = { duplicates: false })
     
    @@ -581,7 +580,6 @@ 

    end self - end

    @@ -630,16 +628,16 @@

     
     
    -31
     32
     33
     34
     35
     36
    -37
    +37 +38

    -
    # File 'app/helpers/data_associator.rb', line 31
    +      
    # File 'app/helpers/data_associator.rb', line 32
     
     def associations
       h = HashWithIndifferentAccess.new
    @@ -718,8 +716,6 @@ 

     
     
    -16
    -17
     18
     19
     20
    @@ -728,16 +724,16 @@ 

    23 24 25 -26

    +26 +27

    -
    # File 'app/helpers/data_associator.rb', line 16
    +      
    # File 'app/helpers/data_associator.rb', line 18
     
     def data_associations(key = nil)
       klass = self.class.to_s
    -  if klass == "Item" || klass == "Collection"
    -    klass = ["Item", "Collection"]
    -  end
    +  klass = %w[Item Collection] if is_a?(Item) || is_a?(Collection)
    +
       if key
         DataAssociation.includes(:upload).where(parent_id: id, parent_class: klass, key: key.to_s)
       else
    @@ -810,13 +806,13 @@ 

     
     
    -52
     53
     54
    -55
    +55 +56

    -
    # File 'app/helpers/data_associator.rb', line 52
    +      
    # File 'app/helpers/data_associator.rb', line 53
     
     def get(key)
       da = get_association key
    @@ -888,13 +884,13 @@ 

     
     
    -43
     44
     45
    -46
    +46 +47

    -
    # File 'app/helpers/data_associator.rb', line 43
    +      
    # File 'app/helpers/data_associator.rb', line 44
     
     def get_association(key)
       das = data_associations key
    @@ -1004,23 +1000,19 @@ 

    129 130 131 -132 -133 -134

    +132
    # File 'app/helpers/data_associator.rb', line 124
     
     def lazy_associate(key, value, upload = nil)
    -
    -  da = DataAssociation.new(
    +  DataAssociation.new(
         parent_id: id,
         parent_class: self.class.to_s,
         key: key.to_s,
         object: { key => value }.to_json,
         upload_id: upload ? upload.id : nil
       )
    -
     end
    @@ -1110,6 +1102,8 @@

     
     
    +140
    +141
     142
     143
     144
    @@ -1118,12 +1112,10 @@ 

    147 148 149 -150 -151 -152

    +150

    -
    # File 'app/helpers/data_associator.rb', line 142
    +      
    # File 'app/helpers/data_associator.rb', line 140
     
     def modify(key, value, upload = nil)
       da = get_association key
    @@ -1183,7 +1175,6 @@ 

     
     
    -69
     70
     71
     72
    @@ -1191,10 +1182,11 @@ 

    74 75 76 -77

    +77 +78

    -
    # File 'app/helpers/data_associator.rb', line 69
    +      
    # File 'app/helpers/data_associator.rb', line 70
     
     def notes
       da = get_association :notes
    @@ -1254,19 +1246,18 @@ 

     
     
    +155
    +156
     157
     158
     159
     160
     161
     162
    -163
    -164
    -165
    -166
    +163

    -
    # File 'app/helpers/data_associator.rb', line 157
    +      
    # File 'app/helpers/data_associator.rb', line 155
     
     def notes=(text)
       da = get_association :notes
    @@ -1276,7 +1267,6 @@ 

    else associate :notes, text.to_s end - text end

    @@ -1344,13 +1334,13 @@

     
     
    -61
     62
     63
    -64
    +64 +65

    -
    # File 'app/helpers/data_associator.rb', line 61
    +      
    # File 'app/helpers/data_associator.rb', line 62
     
     def upload(key)
       da = get_association key
    @@ -1366,9 +1356,9 @@ 

    diff --git a/docs/api/FieldType.html b/docs/api/FieldType.html index 099a0a4eb..61ad0bdd3 100644 --- a/docs/api/FieldType.html +++ b/docs/api/FieldType.html @@ -264,6 +264,29 @@

    + + + +
  • + + + #export ⇒ Object + + + + + + + + + + + + + +

    Creates a hash for this field_type.

    +
    +
  • @@ -284,6 +307,28 @@

    +
    + + + + +
  • + + + #has_type(typename) ⇒ Object + + + + + + + + + + + + +
  • @@ -306,6 +351,50 @@

    +
    + + + + +
  • + + + #item? ⇒ Boolean + + + + + + + + + + + + + +
    + +
  • + + +
  • + + + #json? ⇒ Boolean + + + + + + + + + + + + +
  • @@ -331,6 +420,28 @@

    Gets name of FieldType.

    + + + +
  • + + + #number? ⇒ Boolean + + + + + + + + + + + + + +
    +
  • @@ -377,6 +488,50 @@

    Gets the id of the object to which this FieldType belongs.

    + + + +
  • + + + #sample? ⇒ Boolean + + + + + + + + + + + + + +
    + +
  • + + +
  • + + + #string? ⇒ Boolean + + + + + + + + + + + + + +
    +
  • @@ -437,19 +592,19 @@

     
     
    -74
    -75
     76
     77
     78
     79
    -80
    +80 +81 +82

    -
    # File 'app/models/field_type.rb', line 74
    +      
    # File 'app/models/field_type.rb', line 76
     
     def allowable_object_types
    -  if ftype == 'item'
    +  if item?
         allowable_field_types.collect(&:object_type)
       else
         []
    @@ -484,19 +639,19 @@ 

     
     
    -61
    -62
     63
     64
     65
     66
    -67
    +67 +68 +69

    -
    # File 'app/models/field_type.rb', line 61
    +      
    # File 'app/models/field_type.rb', line 63
     
     def allowable_sample_types
    -  if ftype == 'sample'
    +  if sample?
         allowable_field_types.collect(&:sample_type)
       else
         []
    @@ -568,8 +723,6 @@ 

     
     
    -48
    -49
     50
     51
     52
    @@ -579,17 +732,19 @@ 

    56 57 58 -59

    +59 +60 +61

    -
    # File 'app/models/field_type.rb', line 48
    +      
    # File 'app/models/field_type.rb', line 50
     
     def allowed?(val)
       case ftype
       when 'string', 'url'
    -    return val.class == String
    +    val.is_a?(String)
       when 'number'
    -    val.class == Integer || val.class == Float
    +    val.is_a?(Integer) || val.is_a?(Float)
       when 'sample'
         allowable_field_types.collect { |aft| aft.sample_type.id }.member? val.sample_type_id
       when 'item'
    @@ -625,16 +780,16 @@ 

     
     
    -90
    -91
    -92
    -93
    -94
    -95
    -96
    +116 +117 +118 +119 +120 +121 +122

    -
    # File 'app/models/field_type.rb', line 90
    +      
    # File 'app/models/field_type.rb', line 116
     
     def as_json(options = {})
       if options[:plain]
    @@ -672,13 +827,13 @@ 

     
     
    -39
    -40
     41
    -42
    +42 +43 +44

    -
    # File 'app/models/field_type.rb', line 39
    +      
    # File 'app/models/field_type.rb', line 41
     
     def destroy
       allowable_field_types.each(&:destroy)
    @@ -726,12 +881,12 @@ 

     
     
    -86
    -87
    -88
    +112 +113 +114

    -
    # File 'app/models/field_type.rb', line 86
    +      
    # File 'app/models/field_type.rb', line 112
     
     def empty?
       allowable_sample_types.select { |ast| ast }.empty?
    @@ -739,6 +894,70 @@ 

    + + +
    +

    + + #exportObject + + + + + +

    +
    +

    Creates a hash for this field_type.

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +162
    +163
    +164
    +165
    +166
    +167
    +168
    +169
    +170
    +171
    +172
    +173
    +174
    +175
    +176
    +
    +
    # File 'app/models/field_type.rb', line 162
    +
    +def export
    +  {
    +    ftype: type,
    +    role: role,
    +    name: name,
    +    sample_types: allowable_field_types.collect { |aft| aft.sample_type ? aft.sample_type.name : nil },
    +    object_types: allowable_field_types.collect { |aft| aft.object_type ? aft.object_type.name : nil },
    +    part: part ? true : false,
    +    array: array ? true : false,
    +    routing: routing,
    +    preferred_operation_type_id: preferred_operation_type_id,
    +    preferred_field_type_id: preferred_field_type_id,
    +    choices: choices
    +  }
    +end
    +
    @@ -765,13 +984,13 @@

     
     
    -69
    -70
     71
    -72
    +72 +73 +74

    -
    # File 'app/models/field_type.rb', line 69
    +      
    # File 'app/models/field_type.rb', line 71
     
     def has_sample_type
       sample_types = allowable_sample_types.select { |st| st }
    @@ -780,6 +999,45 @@ 

    + + +
    +

    + + #has_type(typename) ⇒ Object + + + + + +

    +
    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +88
    +89
    +90
    +
    +
    # File 'app/models/field_type.rb', line 88
    +
    +def has_type(typename)
    +  ftype == typename
    +end
    +
    @@ -806,32 +1064,6 @@

     
     
    -98
    -99
    -100
    -101
    -102
    -103
    -104
    -105
    -106
    -107
    -108
    -109
    -110
    -111
    -112
    -113
    -114
    -115
    -116
    -117
    -118
    -119
    -120
    -121
    -122
    -123
     124
     125
     126
    @@ -841,10 +1073,36 @@ 

    130 131 132 -133

    +133 +134 +135 +136 +137 +138 +139 +140 +141 +142 +143 +144 +145 +146 +147 +148 +149 +150 +151 +152 +153 +154 +155 +156 +157 +158 +159

    -
    # File 'app/models/field_type.rb', line 98
    +      
    # File 'app/models/field_type.rb', line 124
     
     def inconsistencies(raw_field_type, parent_name)
     
    @@ -862,7 +1120,7 @@ 

    results << "#{parent_name} field '#{name}' has role is #{!!role} but imported field of the same name has role = #{!!raw_field_type[:role]}" unless raw_field_type[:role] == role results << "#{parent_name} field '#{name}' has routing symbol is #{!!routing} but imported field of the same name has routing symbol = #{!!raw_field_type[:routing]}." unless raw_field_type[:role] == role - if ftype == 'sample' + if sample? l1 = allowable_field_types.collect do |aft| [ @@ -885,6 +1143,110 @@

    + + +
    +

    + + #item?Boolean + + + + + +

    +
    + + +
    +
    +
    + +

    Returns:

    +
      + +
    • + + + (Boolean) + + + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +108
    +109
    +110
    +
    +
    # File 'app/models/field_type.rb', line 108
    +
    +def item?
    +  has_type('item')
    +end
    +
    +
    + +
    +

    + + #json?Boolean + + + + + +

    +
    + + +
    +
    +
    + +

    Returns:

    +
      + +
    • + + + (Boolean) + + + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +104
    +105
    +106
    +
    +
    # File 'app/models/field_type.rb', line 104
    +
    +def json?
    +  has_type('json')
    +end
    +
    @@ -929,15 +1291,67 @@

     
     
    -19
    +21

    -
    # File 'app/models/field_type.rb', line 19
    +      
    # File 'app/models/field_type.rb', line 21
     
     attr_accessible :name
    + + +
    +

    + + #number?Boolean + + + + + +

    +
    + + +
    +
    +
    + +

    Returns:

    +
      + +
    • + + + (Boolean) + + + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +100
    +101
    +102
    +
    +
    # File 'app/models/field_type.rb', line 100
    +
    +def number?
    +  has_type('number')
    +end
    +
    @@ -982,10 +1396,10 @@

     
     
    -29
    +31

    -
    # File 'app/models/field_type.rb', line 29
    +      
    # File 'app/models/field_type.rb', line 31
     
     attr_accessible :parent_class
    @@ -1035,15 +1449,119 @@

     
     
    -24
    +26

    -
    # File 'app/models/field_type.rb', line 24
    +      
    # File 'app/models/field_type.rb', line 26
     
     attr_accessible :parent_id
    + + +
    +

    + + #sample?Boolean + + + + + +

    +
    + + +
    +
    +
    + +

    Returns:

    +
      + +
    • + + + (Boolean) + + + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +96
    +97
    +98
    +
    +
    # File 'app/models/field_type.rb', line 96
    +
    +def sample?
    +  has_type('sample')
    +end
    +
    +
    + +
    +

    + + #string?Boolean + + + + + +

    +
    + + +
    +
    +
    + +

    Returns:

    +
      + +
    • + + + (Boolean) + + + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +92
    +93
    +94
    +
    +
    # File 'app/models/field_type.rb', line 92
    +
    +def string?
    +  has_type('string')
    +end
    +
    @@ -1070,12 +1588,12 @@

     
     
    -82
    -83
    -84
    +84 +85 +86

    -
    # File 'app/models/field_type.rb', line 82
    +      
    # File 'app/models/field_type.rb', line 84
     
     def type
       ftype
    @@ -1090,9 +1608,9 @@ 

    diff --git a/docs/api/FieldValue.html b/docs/api/FieldValue.html index 72168dcba..26b184d3f 100644 --- a/docs/api/FieldValue.html +++ b/docs/api/FieldValue.html @@ -138,28 +138,6 @@

  • - .create_item(sample, ft, values) ⇒ Object - - - - - - - - - - - - - -
    - -
  • - - -
  • - - .create_number(sample, ft, values) ⇒ Object @@ -174,7 +152,8 @@

    -
    +

    TODO: dead code.

    +

  • @@ -196,7 +175,8 @@

    -
    +

    TODO: dead code.

    +
    @@ -218,7 +198,8 @@

    -
    +

    TODO: dead code.

    +
    @@ -240,7 +221,8 @@

    -
    +

    TODO: dead code.

    +
    @@ -262,7 +244,7 @@

    -

    sample, field_type, raw_field_data.

    +

    TODO: dead code.

    @@ -633,7 +615,8 @@

    -
    +

    TODO: URLs belong elsewhere.

    +
    @@ -684,88 +667,7 @@

    Class Method Details

    -

    - - .create_item(sample, ft, values) ⇒ Object - - - - - -

    -
    - - -
    -
    -
    - - -
    - - - - -
    -
    -
    -
    -186
    -187
    -188
    -189
    -190
    -191
    -192
    -193
    -194
    -195
    -196
    -197
    -198
    -199
    -200
    -201
    -202
    -203
    -204
    -205
    -206
    -207
    -208
    -209
    -
    -
    # File 'app/models/field_value.rb', line 186
    -
    -def self.create_item(sample, ft, values)
    -  values.each do |v|
    -    if v.class == Item
    -      item = v
    -    elsif v.class == Integer
    -      item = Item.find(v)
    -      unless item
    -        sample.errors.add :item, "Could not find item with id #{v} for #{ft.name}"
    -        raise ActiveRecord::Rollback
    -      end
    -    else
    -      sample.errors.add :sample, "#{v} should be an item for #{ft.name}"
    -      raise ActiveRecord::Rollback
    -    end
    -
    -    unless ft.allowed? child
    -      sample.errors.add :sample, "#{v} is not an allowable sample_type for #{ft.name}"
    -      raise ActiveRecord::Rollback
    -    end
    -
    -    fv = sample.field_values.create name: ft.name, child_item_id: sid
    -    fv.save
    -  end
    -end
    -
    -
    - -
    -

    +

    .create_number(sample, ft, values) ⇒ Object @@ -775,7 +677,8 @@

    - +

    TODO: dead code

    +
    @@ -788,6 +691,10 @@

     
     
    +134
    +135
    +136
    +137
     138
     139
     140
    @@ -796,14 +703,10 @@ 

    143 144 145 -146 -147 -148 -149 -150

    +146

    -
    # File 'app/models/field_value.rb', line 138
    +      
    # File 'app/models/field_value.rb', line 134
     
     def self.create_number(sample, ft, values)
       values.each do |v|
    @@ -834,7 +737,8 @@ 

    - +

    TODO: dead code

    +
    @@ -847,6 +751,8 @@

     
     
    +157
    +158
     159
     160
     161
    @@ -868,23 +774,17 @@ 

    177 178 179 -180 -181 -182 -183 -184

    +180

    -
    # File 'app/models/field_value.rb', line 159
    +      
    # File 'app/models/field_value.rb', line 157
     
     def self.create_sample(sample, ft, values)
    -
       values.each do |v|
    -
         if v.class == Sample
           child = v
         elsif v.class == Integer
    -      child = Sample.find_by_id(v)
    +      child = Sample.find_by(id: v)
           unless sample
             sample.errors.add :sample, "Could not find sample with id #{v} for #{ft.name}"
             raise ActiveRecord::Rollback
    @@ -919,7 +819,8 @@ 

    - +

    TODO: dead code

    +
    @@ -932,6 +833,11 @@

     
     
    +119
    +120
    +121
    +122
    +123
     124
     125
     126
    @@ -939,15 +845,10 @@ 

    128 129 130 -131 -132 -133 -134 -135 -136

    +131

    -
    # File 'app/models/field_value.rb', line 124
    +      
    # File 'app/models/field_value.rb', line 119
     
     def self.create_string(sample, ft, values)
       values.each do |v|
    @@ -978,7 +879,8 @@ 

    - +

    TODO: dead code

    +
    @@ -991,15 +893,15 @@

     
     
    +149
    +150
    +151
     152
     153
    -154
    -155
    -156
    -157
    +154

    -
    # File 'app/models/field_value.rb', line 152
    +      
    # File 'app/models/field_value.rb', line 149
     
     def self.create_url(sample, ft, values)
       values.each do |v|
    @@ -1023,7 +925,7 @@ 

    -

    sample, field_type, raw_field_data

    +

    TODO: dead code

    @@ -1037,25 +939,24 @@

     
     
    -211
    -212
    -213
    -214
    -215
    -216
    -217
    -218
    -219
    -220
    -221
    -222
    -223
    -224
    -225
    -226
    +183 +184 +185 +186 +187 +188 +189 +190 +191 +192 +193 +194 +195 +196 +197

    -
    # File 'app/models/field_value.rb', line 211
    +      
    # File 'app/models/field_value.rb', line 183
     
     def self.creator(sample, field_type, raw) # sample, field_type, raw_field_data
     
    @@ -1070,8 +971,7 @@ 

    values = [raw] end - method('create_' + field_type.ftype).call(sample, field_type, values) - + method('create_' + field_type.type).call(sample, field_type, values) end

    @@ -1108,12 +1008,12 @@

     
     
    -256
    -257
    -258
    +227 +228 +229

    -
    # File 'app/models/field_value.rb', line 256
    +      
    # File 'app/models/field_value.rb', line 227
     
     def child_data(name)
       child_item.get(name) if child_item_id
    @@ -1161,12 +1061,12 @@ 

     
     
    -60
    -61
    -62
    +62 +63 +64

    -
    # File 'app/models/field_value.rb', line 60
    +      
    # File 'app/models/field_value.rb', line 62
     
     def collection
       Collection.find(child_item.id) if child_item
    @@ -1240,25 +1140,17 @@ 

     
     
    -76
    -77
     78
     79
     80
    -81
    -82
    -83
    +81

    -
    # File 'app/models/field_value.rb', line 76
    +      
    # File 'app/models/field_value.rb', line 78
     
    -def collection_part row, column
    +def collection_part(row, column)
       pas = PartAssociation.where(collection_id: child_item_id, row: row, column: column)
    -  if pas.length == 1
    -    pas[0].part
    -  else
    -    nil
    -  end
    +  pas.first.part if pas.length == 1
     end
    @@ -1289,15 +1181,15 @@

     
     
    -284
    -285
    -286
    -287
    -288
    -289
    +255 +256 +257 +258 +259 +260

    -
    # File 'app/models/field_value.rb', line 284
    +      
    # File 'app/models/field_value.rb', line 255
     
     def copy_inventory(fv)
       self.child_item_id = fv.child_item_id
    @@ -1334,15 +1226,15 @@ 

     
     
    -249
    -250
    -251
    -252
    -253
    -254
    +220 +221 +222 +223 +224 +225

    -
    # File 'app/models/field_value.rb', line 249
    +      
    # File 'app/models/field_value.rb', line 220
     
     def export
       attributes.merge(
    @@ -1397,10 +1289,10 @@ 

     
     
    -22
    +24

    -
    # File 'app/models/field_value.rb', line 22
    +      
    # File 'app/models/field_value.rb', line 24
     
     belongs_to :field_type
    @@ -1432,22 +1324,22 @@

     
     
    -296
    -297
    -298
    -299
    -300
    -301
    -302
    -303
    -304
    -305
    -306
    -307
    -308
    +267 +268 +269 +270 +271 +272 +273 +274 +275 +276 +277 +278 +279

    -
    # File 'app/models/field_value.rb', line 296
    +      
    # File 'app/models/field_value.rb', line 267
     
     def full_json(_options = {})
       as_json(include: [
    @@ -1505,12 +1397,12 @@ 

     
     
    -42
    -43
    -44
    +44 +45 +46

    -
    # File 'app/models/field_value.rb', line 42
    +      
    # File 'app/models/field_value.rb', line 44
     
     def item
       child_item
    @@ -1558,16 +1450,16 @@ 
    -
    # File 'app/models/field_value.rb', line 49
    +      
    # File 'app/models/field_value.rb', line 51
     
     def item_link
       if child_item_id
    @@ -1623,10 +1515,10 @@ 

     
     
    -27
    +29

    -
    # File 'app/models/field_value.rb', line 27
    +      
    # File 'app/models/field_value.rb', line 29
     
     attr_accessible :name
    @@ -1672,12 +1564,12 @@

     
     
    -67
    -68
    -69
    +69 +70 +71

    -
    # File 'app/models/field_value.rb', line 67
    +      
    # File 'app/models/field_value.rb', line 69
     
     def part
       collection_part row, column
    @@ -1711,13 +1603,13 @@ 

     
     
    -291
    -292
    -293
    -294
    +262 +263 +264 +265

    -
    # File 'app/models/field_value.rb', line 291
    +      
    # File 'app/models/field_value.rb', line 262
     
     def routing
       ft = field_type
    @@ -1766,12 +1658,12 @@ 

     
     
    -35
    -36
    -37
    +37 +38 +39

    -
    # File 'app/models/field_value.rb', line 35
    +      
    # File 'app/models/field_value.rb', line 37
     
     def sample
       child_sample
    @@ -1882,16 +1774,16 @@ 

     
     
    -276
    -277
    -278
    -279
    -280
    -281
    -282
    +247 +248 +249 +250 +251 +252 +253

    -
    # File 'app/models/field_value.rb', line 276
    +      
    # File 'app/models/field_value.rb', line 247
     
     def set(opts = {})
       self.child_item_id = opts[:item].id if opts[:item]
    @@ -1929,12 +1821,12 @@ 

     
     
    -260
    -261
    -262
    +231 +232 +233

    -
    # File 'app/models/field_value.rb', line 260
    +      
    # File 'app/models/field_value.rb', line 231
     
     def set_child_data(name, value)
       child_item.associate(name, value) if child_item_id
    @@ -1955,7 +1847,8 @@ 

    - +

    TODO: URLs belong elsewhere

    +
    @@ -1968,40 +1861,39 @@

     
     
    -228
    -229
    -230
    -231
    -232
    -233
    -234
    -235
    -236
    -237
    -238
    -239
    -240
    -241
    -242
    -243
    -244
    -245
    -246
    -247
    +200 +201 +202 +203 +204 +205 +206 +207 +208 +209 +210 +211 +212 +213 +214 +215 +216 +217 +218

    -
    # File 'app/models/field_value.rb', line 228
    +      
    # File 'app/models/field_value.rb', line 200
     
     def to_s
       if child_sample_id
    -    c = Sample.find_by_id(child_sample_id)
    +    c = Sample.find_by(id: child_sample_id)
         if c
           "<a href='/samples/#{c.id}'>#{c.name}</a>"
         else
           "? #{child_sample_id} not found ?"
         end
       elsif child_item_id
    -    c = Item.includes(:object_type).find_by_id(child_sample_id)
    +    c = Item.includes(:object_type).find_by(id: child_sample_id)
         if c
           "<a href='/items/#{c.id}'>#{c.object_type.name} #{c.id}</a>"
         else
    @@ -2010,7 +1902,6 @@ 

    else value end - end

    @@ -2061,6 +1952,8 @@

     
     
    +88
    +89
     90
     91
     92
    @@ -2087,39 +1980,30 @@ 

    113 114 115 -116 -117 -118 -119 -120 -121 -122

    +116

    -
    # File 'app/models/field_value.rb', line 90
    +      
    # File 'app/models/field_value.rb', line 88
     
     def val
    -
       if field_type
         ft = field_type
       elsif sample && sample_type
    -    fts = sample.sample_type.field_types.select { |ft| ft.name == name }
    -    if fts.length == 1
    -      ft = fts[0]
    -    else
    -      return nil
    -    end
    +    fts = sample.sample_type.field_types.select { |type| type.name == name }
    +    return nil unless fts.length == 1
    +
    +    ft = ft.first
       else
         return nil
       end
     
    -  case ft.ftype
    +  case ft.type
       when 'string', 'url'
         return value
       when 'json'
         begin
           return JSON.parse value, symbolize_names: true
    -    rescue Exception => e
    +    rescue JSON::ParserError => e
           return { error: e, original_value: value }
         end
       when 'number'
    @@ -2129,7 +2013,6 @@ 

    when 'item' return child_item end - end

    @@ -2141,9 +2024,9 @@

    diff --git a/docs/api/FieldValueKrill.html b/docs/api/FieldValueKrill.html index 7ef608a68..35a041277 100644 --- a/docs/api/FieldValueKrill.html +++ b/docs/api/FieldValueKrill.html @@ -277,6 +277,20 @@

     
     
    +75
    +76
    +77
    +78
    +79
    +80
    +81
    +82
    +83
    +84
    +85
    +86
    +87
    +88
     89
     90
     91
    @@ -286,34 +300,17 @@ 

    95 96 97 -98 -99 -100 -101 -102 -103 -104 -105 -106 -107 -108 -109 -110 -111 -112 -113 -114

    +98

    -
    # File 'app/krill/field_value_krill.rb', line 89
    +      
    # File 'app/krill/field_value_krill.rb', line 75
     
     def info
    -
       si = 'No sample'
       ii = 'No Item'
     
       if child_sample_id
    -    sample = Sample.find_by_id(child_sample_id)
    +    sample = Sample.find_by(id: child_sample_id)
         si = if sample
                "#{sample.sample_type.name} #{sample.id} (#{sample.name})"
              else
    @@ -322,7 +319,7 @@ 

    end if child_item_id - item = Item.includes(:object_type).find_by_id(child_item_id) + item = Item.includes(:object_type).find_by(id: child_item_id) ii = if item "#{item.object_type.name} #{item.id} at #{item.location}" else @@ -331,7 +328,6 @@

    end "#{name}: { sample: #{si}, item: #{ii}, array: #{field_type.array ? 'true' : 'false'}, part: #{field_type.part ? [row, column] : '-'} }" - end

    @@ -362,37 +358,33 @@

     
     
    +37
    +38
    +39
    +40
    +41
    +42
     43
     44
     45
     46
     47
    -48
    -49
    -50
    -51
    -52
    -53
    -54
    -55
    -56
    +48

    -
    # File 'app/krill/field_value_krill.rb', line 43
    +      
    # File 'app/krill/field_value_krill.rb', line 37
     
     def make
    -
    -  if object_type && !self.child_item_id
    +  if object_type && !child_item_id
         @item = Item.make({ quantity: 1, inuse: 0 }, sample: child_sample, object_type: object_type)
         @item.store if @item.location == 'Unknown'
         self.child_item_id = @item.id
         save
    -  elsif object_type && self.child_item_id
    -    Rails.logger.info "Item #{self.child_item_id} already assigned to field value"
    +  elsif object_type && child_item_id
    +    Rails.logger.info "Item #{child_item_id} already assigned to field value"
       end
     
       @item
    -
     end
    @@ -423,45 +415,37 @@

     
     
    +50
    +51
    +52
    +53
    +54
    +55
    +56
    +57
     58
     59
     60
     61
     62
    -63
    -64
    -65
    -66
    -67
    -68
    -69
    -70
    -71
    -72
    -73
    -74
    -75
    +63

    -
    # File 'app/krill/field_value_krill.rb', line 58
    +      
    # File 'app/krill/field_value_krill.rb', line 50
     
     def make_collection
    -
       ot = object_type
    +  raise "Could not find object type: #{object_type}" unless ot
     
    -  if ot && ot.handler == 'collection'
    -    c = Collection.new_collection(object_type.name)
    -    c.store if c.location == 'Unknown'
    -    self.child_item_id = c.id
    -    save
    -    c
    -  elsif ot && ot.handler != 'collection'
    -    raise "Could not make a new collection from the object type name '#{ot.name}', " \
    -          "because its handler is '#{ot.handler}', not 'collection'"
    -  else
    -    raise "Could not find object type: #{object_type}"
    -  end
    +  message = "Cannot make a new collection from object type '#{ot.name}' with handler '#{ot.handler}'"
    +  raise message if ot.handler != 'collection'
    +
    +  c = Collection.new_collection(object_type.name)
    +  c.store if c.location == 'Unknown'
    +  self.child_item_id = c.id
    +  save
     
    +  c
     end
    @@ -492,31 +476,27 @@

     
     
    -77
    -78
    -79
    -80
    -81
    -82
    -83
    -84
    -85
    -86
    -87
    +65 +66 +67 +68 +69 +70 +71 +72 +73

    -
    # File 'app/krill/field_value_krill.rb', line 77
    +      
    # File 'app/krill/field_value_krill.rb', line 65
     
     def make_part(collection, r, c)
    +  return unless collection
     
    -  if collection
    -    collection.set r, c, child_sample
    -    self.child_item_id = collection.id
    -    self.row = r
    -    self.column = c
    -    save
    -  end
    -
    +  collection.set(r, c, child_sample)
    +  self.child_item_id = collection.id
    +  self.row = r
    +  self.column = c
    +  save
     end
    @@ -560,12 +540,12 @@

     
     
    -116
    -117
    -118
    +100 +101 +102

    -
    # File 'app/krill/field_value_krill.rb', line 116
    +      
    # File 'app/krill/field_value_krill.rb', line 100
     
     def part?
       field_type && field_type.part
    @@ -599,8 +579,6 @@ 

     
     
    -4
    -5
     6
     7
     8
    @@ -630,31 +608,19 @@ 

    32 33 34 -35 -36 -37 -38 -39 -40 -41

    +35

    -
    # File 'app/krill/field_value_krill.rb', line 4
    +      
    # File 'app/krill/field_value_krill.rb', line 6
     
     def retrieve
    -
       if child_item_id
    -
    -    @item = Item.find_by_id(child_item_id)
    -
    +    @item = Item.find_by(id: child_item_id)
       elsif !predecessors.empty?
    -
         # TODO: THIS SHOULD USE THE ACTIVE PREDECESSOR, IN CASE THERE IS MORE THAN ONE
         #       FILTER BY STATUS (e.g. "done")?
         copy_inventory(predecessors[0])
    -
       else
    -
         items = if object_type && !field_type.part
                   Item.where(sample_id: child_sample_id, object_type_id: object_type.id).reject(&:deleted?)
                 elsif object_type && field_type.part
    @@ -673,11 +639,9 @@ 

    end save end - end @item - end

    @@ -689,9 +653,9 @@

    diff --git a/docs/api/Item.html b/docs/api/Item.html index 426ba1faa..8471d0934 100644 --- a/docs/api/Item.html +++ b/docs/api/Item.html @@ -956,65 +956,37 @@

     
     
    -445
    -446
    -447
    -448
    -449
    -450
    -451
    -452
    -453
    -454
    -455
    -456
    -457
    -458
    -459
    -460
    -461
    -462
    -463
    -464
    -465
    -466
    -467
    -468
    -469
    -470
    -471
    -472
    - - -
    # File 'app/models/item.rb', line 445
    +417
    +418
    +419
    +420
    +421
    +422
    +423
    +424
    +425
    +426
    +427
    +428
    +429
    +430
    + + +
    # File 'app/models/item.rb', line 417
     
     def self.items_for(sid, oid)
    +  sample = Sample.find_by(id: sid)
    +  ot = ObjectType.find_by(id: oid)
     
    -  sample = Sample.find_by_id(sid)
    -  ot = ObjectType.find_by_id(oid)
    -
    -  if sample && ot
    -
    -    if ot.handler == 'collection'
    -      return Collection.parts(sample, ot)
    -    else
    -      return sample.items.reject { |i| i.deleted? || i.object_type_id != ot.id }
    -    end
    -
    -  elsif sample && !ot
    -
    -    return []
    -
    -  elsif ot.handler != 'sample_container'
    -
    -    return ot.items.reject(&:deleted?)
    -
    -  else
    -
    -    return []
    +  if sample
    +    return [] unless ot
    +    return Collection.parts(sample, ot) if ot.handler == 'collection'
     
    +    return sample.items.reject { |i| i.deleted? || i.object_type_id != ot.id }
       end
    +  return ot.items.reject(&:deleted?) if ot.handler != 'sample_container'
     
    +  []
     end
    @@ -1045,6 +1017,12 @@

     
     
    +211
    +212
    +213
    +214
    +215
    +216
     217
     218
     219
    @@ -1078,17 +1056,10 @@ 

    247 248 249 -250 -251 -252 -253 -254 -255 -256 -257

    +250

    -
    # File 'app/models/item.rb', line 217
    +      
    # File 'app/models/item.rb', line 211
     
     def self.make(params, opts = {})
       o = { object_type: nil, sample: nil, location: nil }.merge opts
    @@ -1107,7 +1078,7 @@ 

    if o[:object_type] item.object_type_id = o[:object_type].id - wiz = Wizard.find_by_name(o[:object_type].prefix) + wiz = Wizard.find_by(name: o[:object_type].prefix) locator = wiz.next if wiz item.set_primitive_location locator.to_s if wiz end @@ -1129,7 +1100,6 @@

    logger.info "Made new item #{item.id} with location #{item.location} and primitive location #{item.primitive_location}" item - end

    @@ -1161,22 +1131,18 @@

     
     
    -396
    -397
    -398
    -399
    -400
    -401
    -402
    -403
    -404
    +372 +373 +374 +375 +376 +377 +378

    -
    # File 'app/models/item.rb', line 396
    +      
    # File 'app/models/item.rb', line 372
     
     def self.new_object(name)
    -
    -  i = new
       olist = ObjectType.where('name = ?', name)
       raise "Could not find object type named '#{spec[:object_type]}'." if olist.empty?
     
    @@ -1212,26 +1178,26 @@ 

     
     
    -406
    -407
    -408
    -409
    -410
    -411
    -412
    -413
    -414
    -415
    -416
    -417
    -418
    -419
    -420
    -421
    -422
    +380 +381 +382 +383 +384 +385 +386 +387 +388 +389 +390 +391 +392 +393 +394 +395 +396

    -
    # File 'app/models/item.rb', line 406
    +      
    # File 'app/models/item.rb', line 380
     
     def self.new_sample(name, spec)
     
    @@ -1241,7 +1207,7 @@ 

    olist = ObjectType.where('name = ?', spec[:as]) raise "Could not find container named '#{spec[:as]}'." if olist.empty? - sample_type_id = SampleType.find_by_name(spec[:of]) + sample_type_id = SampleType.find_by(name: spec[:of]) raise "Could not find sample type named '#{spec[:of]}'." unless sample_type_id slist = Sample.where('name = ? AND sample_type_id = ?', name, sample_type_id) @@ -1285,31 +1251,23 @@

     
     
    -354
    -355
    -356
    -357
    -358
    -359
    -360
    -361
    -362
    -363
    -364
    +340 +341 +342 +343 +344 +345 +346

    -
    # File 'app/models/item.rb', line 354
    +      
    # File 'app/models/item.rb', line 340
     
     def all_attributes
    -
       temp = attributes.symbolize_keys
    -
       temp[:object_type] = object_type.attributes.symbolize_keys
    -
       temp[:sample] = sample.attributes.symbolize_keys if sample_id
     
       temp
    -
     end
    @@ -1340,12 +1298,12 @@

     
     
    -344
    -345
    -346
    +330 +331 +332

    -
    # File 'app/models/item.rb', line 344
    +      
    # File 'app/models/item.rb', line 330
     
     def annotate(hash)
       set_data(datum.merge(hash))
    @@ -1397,12 +1355,12 @@ 

     
     
    -304
    -305
    -306
    +294 +295 +296

    -
    # File 'app/models/item.rb', line 304
    +      
    # File 'app/models/item.rb', line 294
     
     def collection?
       object_type && object_type.handler == 'collection'
    @@ -1450,25 +1408,17 @@ 

     
     
    -310
    -311
    -312
    -313
    -314
    -315
    -316
    -317
    +300 +301 +302 +303

    -
    # File 'app/models/item.rb', line 310
    +      
    # File 'app/models/item.rb', line 300
     
     def containing_collection
    -  pas = PartAssociation.where(part_id: self.id)
    -  if pas.length == 1
    -    pas[0].collection
    -  else
    -    nil
    -  end
    +  pas = PartAssociation.where(part_id: id)
    +  pas[0].collection if pas.length == 1
     end
    @@ -1501,23 +1451,19 @@

     
     
    -331
    -332
    -333
    -334
    -335
    -336
    -337
    +319 +320 +321 +322 +323

    -
    # File 'app/models/item.rb', line 331
    +      
    # File 'app/models/item.rb', line 319
     
     def datum
    -
    -  JSON.parse data, symbolize_names: true
    +  JSON.parse(data, symbolize_names: true)
     rescue StandardError
       {}
    -
     end
    @@ -1550,12 +1496,12 @@

     
     
    -340
    -341
    -342
    +326 +327 +328

    -
    # File 'app/models/item.rb', line 340
    +      
    # File 'app/models/item.rb', line 326
     
     def datum=(d)
       self.data = d.to_json
    @@ -1607,12 +1553,12 @@ 

     
     
    -297
    -298
    -299
    +287 +288 +289

    -
    # File 'app/models/item.rb', line 297
    +      
    # File 'app/models/item.rb', line 287
     
     def deleted?
       primitive_location == 'deleted'
    @@ -1646,30 +1592,26 @@ 

     
     
    -428
    -429
    -430
    -431
    -432
    -433
    -434
    -435
    -436
    -437
    -438
    -439
    +402 +403 +404 +405 +406 +407 +408 +409 +410 +411

    -
    # File 'app/models/item.rb', line 428
    +      
    # File 'app/models/item.rb', line 402
     
     def export
       a = attributes
       a.delete 'inuse'
       a.delete 'locator_id'
    -  begin
    -    a['data'] = get_data
    -  rescue StandardError
    -  end
    +  data = get_data
    +  a['data'] = data if data
       a[:sample] = sample.export if association(:sample).loaded?
       a[:object_type] = object_type.export if association(:object_type).loaded?
       a
    @@ -1703,14 +1645,14 @@ 

     
     
    -348
    -349
    -350
    -351
    -352
    +334 +335 +336 +337 +338

    -
    # File 'app/models/item.rb', line 348
    +      
    # File 'app/models/item.rb', line 334
     
     def features
       f = { id: id, location: location, name: object_type.name }
    @@ -1746,15 +1688,19 @@ 

     
     
    -326
    -327
    -328
    +312 +313 +314 +315 +316

    -
    # File 'app/models/item.rb', line 326
    +      
    # File 'app/models/item.rb', line 312
     
     def get_data
       JSON.parse data, symbolize_names: true
    +rescue JSON::ParserError
    +  nil
     end
    @@ -1785,13 +1731,13 @@

     
     
    -50
    -51
     52
    -53
    +53 +54 +55

    -
    # File 'app/models/item.rb', line 50
    +      
    # File 'app/models/item.rb', line 52
     
     def inuse_less_than_quantity
       errors.add(:inuse, 'must non-negative and not greater than the quantity.') unless
    @@ -1840,12 +1786,12 @@ 

     
     
    -68
    -69
    -70
    +70 +71 +72

    -
    # File 'app/models/item.rb', line 68
    +      
    # File 'app/models/item.rb', line 70
     
     def is_part
       object_type_id == part_type.id
    @@ -1897,8 +1843,6 @@ 

     
     
    -75
    -76
     77
     78
     79
    @@ -1912,19 +1856,17 @@ 

    87

    -
    # File 'app/models/item.rb', line 75
    +      
    # File 'app/models/item.rb', line 77
     
     def location
       if is_part
         'Part of Collection'
    +  elsif locator
    +    locator.to_s
    +  elsif primitive_location
    +    primitive_location
       else
    -    if locator
    -      locator.to_s
    -    elsif primitive_location
    -      primitive_location
    -    else
    -      'Unknown'
    -    end
    +    'Unknown'
       end
     end
    @@ -1986,7 +1928,7 @@

    def location=(x) move_to x - write_attribute(:location, x) # just for consistency + self[:location] = x # just for consistency end

    @@ -2035,29 +1977,29 @@

     
     
    +266
    +267
    +268
    +269
    +270
    +271
    +272
    +273
    +274
    +275
     276
     277
     278
     279
     280
     281
    -282
    -283
    -284
    -285
    -286
    -287
    -288
    -289
    -290
    -291
    -292
    +282

    -
    # File 'app/models/item.rb', line 276
    +      
    # File 'app/models/item.rb', line 266
     
     def mark_as_deleted
    -  write_attribute(:location, 'deleted')
    +  self[:location] = 'deleted'
       self.quantity = -1
       self.inuse = -1
       self.locator_id = nil
    @@ -2092,7 +2034,7 @@ 

    Note: -

    for backwards compatability

    +

    for backwards compatibility

    @@ -2146,12 +2088,12 @@

     
     
    -213
    -214
    -215
    +207 +208 +209

    -
    # File 'app/models/item.rb', line 213
    +      
    # File 'app/models/item.rb', line 207
     
     def move(locstr)
       move_to locstr
    @@ -2307,7 +2249,7 @@ 

    def move_to(locstr) - wiz = Wizard.find_by_name(object_type.prefix) if object_type + wiz = Wizard.find_by(name: object_type.prefix) if object_type if object_type && wiz && wiz.has_correct_form(locstr) # item and location managed by a wizard @@ -2335,10 +2277,10 @@

    if newloc.item_id.nil? - oldloc = Locator.find_by_id(locator_id) + oldloc = Locator.find_by(id: locator_id) oldloc.item_id = nil if oldloc self.locator_id = newloc.id - write_attribute(:location, locstr) + self[:location] = locstr self.quantity = 1 self.inuse = 0 newloc.item_id = id @@ -2364,10 +2306,10 @@

    else # location is not in the form managed by a wizard - loc = Locator.find_by_id(locator_id) + loc = Locator.find_by(id: locator_id) loc.item_id = nil if loc - write_attribute(:location, locstr) + self[:location] = locstr self.locator_id = nil transaction do @@ -2430,27 +2372,15 @@

    199 200 201 -202 -203 -204 -205 -206 -207 -208

    +202
    # File 'app/models/item.rb', line 198
     
     def non_wizard_location?
    +  wiz = Wizard.find_by(name: object_type.prefix)
     
    -  wiz = Wizard.find_by_name(object_type.prefix)
    -
    -  if wiz && locator.nil?
    -    return false
    -  else
    -    return true
    -  end
    -
    +  !(wiz && locator.nil?)
     end
    @@ -2481,12 +2411,12 @@

     
     
    -424
    -425
    -426
    +398 +399 +400

    -
    # File 'app/models/item.rb', line 424
    +      
    # File 'app/models/item.rb', line 398
     
     def num_posts
       post_associations.count
    @@ -2539,10 +2469,10 @@ 

     
     
    -35
    +37

    -
    # File 'app/models/item.rb', line 35
    +      
    # File 'app/models/item.rb', line 37
     
     accepts_nested_attributes_for :object_type
    @@ -2575,12 +2505,12 @@

     
     
    -57
    -58
    -59
    +59 +60 +61

    -
    # File 'app/models/item.rb', line 57
    +      
    # File 'app/models/item.rb', line 59
     
     def primitive_location
       self[:location]
    @@ -2614,35 +2544,29 @@ 

     
     
    +252
    +253
    +254
    +255
    +256
    +257
    +258
     259
     260
    -261
    -262
    -263
    -264
    -265
    -266
    -267
    -268
    -269
    -270
    -271
    +261

    -
    # File 'app/models/item.rb', line 259
    +      
    # File 'app/models/item.rb', line 252
     
     def put_at(locstr)
    -
       loc = Wizard.find_locator locstr
       return nil unless loc && loc.item_id.nil?
     
       loc.item_id = id
    -  item_id = loc.id
       transaction do
         loc.save
         save
       end
    -
     end
    @@ -2673,13 +2597,13 @@

     
     
    -45
    -46
     47
    -48
    +48 +49 +50

    -
    # File 'app/models/item.rb', line 45
    +      
    # File 'app/models/item.rb', line 47
     
     def quantity_nonneg
       errors.add(:quantity, 'Must be non-negative.') unless
    @@ -2736,10 +2660,10 @@ 

     
     
    -29
    +31

    -
    # File 'app/models/item.rb', line 29
    +      
    # File 'app/models/item.rb', line 31
     
     accepts_nested_attributes_for :sample
    @@ -2772,13 +2696,13 @@

     
     
    -321
    -322
    -323
    -324
    +307 +308 +309 +310

    -
    # File 'app/models/item.rb', line 321
    +      
    # File 'app/models/item.rb', line 307
     
     def set_data(d)
       self.data = d.to_json
    @@ -2821,7 +2745,7 @@ 

    # File 'app/models/item.rb', line 97
     
     def set_primitive_location(locstr)
    -  write_attribute(:location, locstr)
    +  self[:location] = locstr
     end
    @@ -2884,7 +2808,7 @@

    # File 'app/models/item.rb', line 104
     
     def store
    -  wiz = Wizard.find_by_name(object_type.prefix)
    +  wiz = Wizard.find_by(name: object_type.prefix)
       if wiz
         locator = wiz.next
         move_to(wiz.int_to_location(locator.number))
    @@ -2921,12 +2845,12 @@ 

     
     
    -366
    -367
    -368
    +348 +349 +350

    -
    # File 'app/models/item.rb', line 366
    +      
    # File 'app/models/item.rb', line 348
     
     def to_s
       "<a href='#' onclick='open_item_ui(#{id})'>#{id}</a>"
    @@ -2961,35 +2885,27 @@ 

     
     
    -370
    -371
    -372
    -373
    -374
    -375
    -376
    -377
    -378
    -379
    -380
    -381
    -382
    -383
    -384
    -385
    -386
    -387
    -388
    -389
    -390
    +352 +353 +354 +355 +356 +357 +358 +359 +360 +361 +362 +363 +364 +365 +366

    -
    # File 'app/models/item.rb', line 370
    +      
    # File 'app/models/item.rb', line 352
     
     def upgrade(force = false) # upgrades data field to data association (if no data associations exist)
    -
    -  if force || associations.empty?
    -
    +  if force || associations.empty?
         begin
           obj = JSON.parse data
     
    @@ -2999,13 +2915,9 @@ 

    rescue StandardError self.notes = data if data end - else - append_notes "\n#{Date.today}: Attempt to upgrade failed. Item already had associations." - end - end

    @@ -3036,12 +2948,12 @@

     
     
    -441
    -442
    -443
    +413 +414 +415

    -
    # File 'app/models/item.rb', line 441
    +      
    # File 'app/models/item.rb', line 413
     
     def week
       created_at.strftime('%W')
    @@ -3056,9 +2968,9 @@ 

    diff --git a/docs/api/Job.html b/docs/api/Job.html index 0ff334316..9eb981779 100644 --- a/docs/api/Job.html +++ b/docs/api/Job.html @@ -147,6 +147,29 @@

    + + + +
  • + + + .create_from(operations:, user:, group:) ⇒ Object + + + + + + + + + + + + + +

    Creates a Job with the list of operations for the user and group.

    +
    +
  • @@ -191,6 +214,29 @@

    + + + +
  • + + + .schedule(operations:, user:, group:) ⇒ Job + + + + + + + + + + + + + +

    Creates a Job from the list of operations.

    +
    +
  • @@ -509,6 +555,29 @@

    + + + +
  • + + + #job_state ⇒ Object + + + + + + + + + + + + + +

    hides the fact that state is stored as JSON.

    +
    +
  • @@ -597,6 +666,29 @@

    + + + +
  • + + + #operation_type ⇒ Object + + + + + + + + + + + + + +

    get the operation type for the operations of this job TODO: seems like this should be a delegate, but not clear if can do it.

    +
    +
  • @@ -885,12 +977,12 @@

     
     
    -26
     27
    -28
    +28 +29

    -
    # File 'app/models/job.rb', line 26
    +      
    # File 'app/models/job.rb', line 27
     
     def self.COMPLETED
       -2
    @@ -901,9 +993,9 @@ 

    -

    +

    - .NOT_STARTEDObject + .create_from(operations:, user:, group:) ⇒ Object @@ -911,12 +1003,62 @@

    - +

    Creates a Job with the list of operations for the user and group.

    +
    +

    Parameters:

    +
      + +
    • + + operations + + + (OperationsList) + + + + — +

      the list of operations

      +
      + +
    • + +
    • + + user + + + (User) + + + + — +

      the user scheduling the job

      +
      + +
    • +
    • + + group + + + (Group) + + + + — +

      the group for the user

      +
      + +
    • + +
    +
    @@ -924,15 +1066,47 @@

     
     
    -22
    -23
    -24
    - -

    + @@ -940,9 +1114,9 @@

    -

    +

    - .params_to_time(p) ⇒ Object + .NOT_STARTEDObject @@ -963,45 +1137,25 @@

     
     
    -41
    -42
    -43
    -44
    -45
    -46
    -47
    -48
    -49
    -50
    +23 +24 +25

    -
    # File 'app/models/job.rb', line 22
    +47
    +48
    +49
    +50
    +51
    +52
    +53
    +54
    +55
    +56
    +57
    +58
    +59
    +60
    +61
    +62
    +63
    +64
    +65
    +
    +
    # File 'app/models/job.rb', line 47
    +
    +def self.create_from(operations:, user:, group:)
    +  job = Job.new
    +  job.path = 'operation.rb'
    +  job.pc = Job.NOT_STARTED
    +  operation_type_id = operations.first.operation_type.id
    +  job.set_arguments(operation_type_id: operation_type_id)
    +  job.group_id = group.id
    +  job. = user.id
    +  job.desired_start_time = Time.now
    +  job.latest_start_time = Time.now + 1.hour
    +  job.save
    +
    +  operations.each do |operation|
    +    JobAssociation.create(job_id: job.id, operation_id: operation.id)
    +    operation.save
    +  end
     
    -def self.NOT_STARTED
    -  -1
    +  job
     end
    -
    # File 'app/models/job.rb', line 41
    -
    -def self.params_to_time(p)
    -
    -  DateTime.civil_from_format(:local,
    -                             p['dt(1i)'].to_i,
    -                             p['dt(2i)'].to_i,
    -                             p['dt(3i)'].to_i,
    -                             p['dt(4i)'].to_i,
    -                             p['dt(5i)'].to_i).to_time
    +      
    # File 'app/models/job.rb', line 23
     
    +def self.NOT_STARTED
    +  -1
     end
    - - -
    -

    Instance Method Details

    - - -
    -

    +
    +

    - #abort_krillObject + .params_to_time(p) ⇒ Object @@ -1022,43 +1176,25 @@

     
     
    -274
    -275
    -276
    -277
    -278
    -279
    -280
    -281
    -282
    -283
    -284
    -285
    -286
    -287
    -288
    -289
    -290
    +99 +100 +101 +102 +103 +104 +105 +106

    -
    # File 'app/models/job.rb', line 274
    -
    -def abort_krill
    -
    -  self.pc = Job.COMPLETED
    -
    -  state = JSON.parse self.state, symbolize_names: true
    -  if state.length.odd? # backtrace ends with a 'next'
    -    append_step operation: 'display', content: [
    -      { title: 'Interrupted' },
    -      { note: "This step was being prepared by the protocol when the 'abort' signal was received." }
    -    ]
    -  end
    -
    -  # add next and final
    -  append_step operation: 'next', time: Time.now, inputs: {}
    -  append_step operation: 'aborted', rval: {}
    +      
    # File 'app/models/job.rb', line 99
     
    +def self.params_to_time(p)
    +  DateTime.civil_from_format(:local,
    +                             p['dt(1i)'].to_i,
    +                             p['dt(2i)'].to_i,
    +                             p['dt(3i)'].to_i,
    +                             p['dt(4i)'].to_i,
    +                             p['dt(5i)'].to_i).to_time
     end
    @@ -1066,9 +1202,9 @@

    -

    +

    - #active?Boolean + .schedule(operations:, user:, group:) ⇒ Job @@ -1076,39 +1212,257 @@

    - +

    Creates a Job from the list of operations. +Defers an operation if it has a primed predecessor.

    +
    +

    Parameters:

    +
      -

      Returns:

      -
        +
      • + + operations + + + (OperationsList) + + + + — +

        the operations

        +
        + +
      • + user - (Boolean) + (User) + + + + — +

        the user scheduling the Job

        +
        + +
      • + +
      • + + group + (Group) + + + + — +

        the group of the user

        +
        +
      -
    - - - @@ -2175,29 +2604,25 @@

     
     
    -329
    -330
    -331
    -332
    -333
    -334
    -335
    -336
    -337
    -338
    +355 +356 +357 +358 +359 +360 +361 +362

    @@ -2246,53 +2671,37 @@

     
     
    -198
    -199
    -200
    -201
    -202
    -203
    -204
    -205
    -206
    -207
    -208
    -209
    -210
    -211
    -212
    -213
    -214
    -215
    -216
    -217
    -218
    -219
    +237 +238 +239 +240 +241 +242 +243 +244 +245 +246 +247 +248 +249 +250

    @@ -2323,27 +2732,19 @@

     
     
    -185
    -186
    -187
    -188
    -189
    -190
    -191
    -192
    -193
    +228 +229 +230 +231 +232

    @@ -2374,59 +2775,41 @@ @@ -2457,26 +2840,26 @@

     
     
    -68
    -69
    -70
    -71
    -72
    -73
    -74
    -75
    -76
    -77
    -78
    -79
    -80
    -81
    -82
    -83
    -84
    +124 +125 +126 +127 +128 +129 +130 +131 +132 +133 +134 +135 +136 +137 +138 +139 +140

    @@ -2601,20 +2982,20 @@

     
     
    -107
    -108
    -109
    -110
    -111
    -112
    -113
    -114
    +163 +164 +165 +166 +167 +168 +169 +170

    @@ -771,8 +769,6 @@

     
     
    -92
    -93
     94
     95
     96
    @@ -794,10 +790,12 @@ 

    112 113 114 -115

    +115 +116 +117

    @@ -2204,9 +2212,6 @@

     
     
    -125
    -126
    -127
     128
     129
     130
    @@ -2233,10 +2238,13 @@ 

    151 152 153 -154

    +154 +155 +156 +157

    @@ -1196,9 +1192,6 @@

     
     
    -38
    -39
    -40
     41
     42
     43
    @@ -1228,10 +1221,13 @@ 

    67 68 69 -70

    +70 +71 +72 +73

    -
    -
    -
    -64
    -65
    -66
    -
    -
    # File 'app/models/job.rb', line 64
    -
    +

    Returns:

    +
      + +
    • + + + (Job) + + + + — +

      the job of scheduled operations

      +
      + +
    • + +
    + + + + + + +
    +
    +
    +
    +74
    +75
    +76
    +77
    +78
    +79
    +80
    +81
    +82
    +83
    +84
    +85
    +86
    +87
    +88
    +89
    +90
    +91
    +92
    +93
    +94
    +95
    +96
    +97
    +
    +
    # File 'app/models/job.rb', line 74
    +
    +def self.schedule(operations:, user:, group:)
    +  ops_to_schedule = []
    +  ops_to_defer = []
    +
    +  operations.each do |op|
    +    pps = op.primed_predecessors
    +    if pps.empty?
    +      ops_to_schedule << op
    +    else
    +      ops_to_schedule += pps
    +      ops_to_defer << op
    +    end
    +  end
    +
    +  unless ops_to_defer.empty?
    +    Job.create_from(operations: ops_to_defer, user: user, group: group)
    +    ops_to_defer.each(&:defer)
    +  end
    +
    +  job = Job.create_from(operations: ops_to_schedule, user: user, group: group)
    +  ops_to_schedule.each(&:schedule)
    +
    +  job
    +end
    +
    + + + + +
    +

    Instance Method Details

    + + +
    +

    + + #abort_krillObject + + + + + +

    +
    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +303
    +304
    +305
    +306
    +307
    +308
    +309
    +310
    +311
    +312
    +313
    +314
    +315
    +316
    +317
    +
    +
    # File 'app/models/job.rb', line 303
    +
    +def abort_krill
    +  self.pc = Job.COMPLETED
    +
    +  state = job_state
    +  if state.length.odd? # backtrace ends with a 'next'
    +    append_step operation: 'display', content: [
    +      { title: 'Interrupted' },
    +      { note: "This step was being prepared by the protocol when the 'abort' signal was received." }
    +    ]
    +  end
    +
    +  # add next and final
    +  append_step operation: 'next', time: Time.now, inputs: {}
    +  append_step operation: 'aborted', rval: {}
    +end
    +
    +
    + +
    +

    + + #active?Boolean + + + + + +

    +
    + + +
    +
    +
    + +

    Returns:

    +
      + +
    • + + + (Boolean) + + + +
    • + +
    + +
    + + + @@ -1325,15 +1675,15 @@

     
     
    -86
    -87
    -88
    +142 +143 +144

    @@ -1364,31 +1714,31 @@

     
     
    -221
    -222
    -223
    -224
    -225
    -226
    -227
    -228
    -229
    -230
    -231
    +252 +253 +254 +255 +256 +257 +258 +259 +260 +261 +262

    @@ -1437,20 +1787,20 @@

     
     
    -119
    -120
    -121
    -122
    -123
    -124
    -125
    -126
    +175 +176 +177 +178 +179 +180 +181 +182

    @@ -1616,12 +1962,12 @@

     
     
    -270
    -271
    -272
    +299 +300 +301

    + + +
    +
    +
    +
    +120
    +121
    +122
    +
    +
    # File 'app/models/job.rb', line 120
    +
     def active?
       pc >= 0
     end
    @@ -1141,12 +1495,12 @@

     
     
    -325
    -326
    -327
    +351 +352 +353

    -
    # File 'app/models/job.rb', line 325
    +      
    # File 'app/models/job.rb', line 351
     
     def active_predecessors
       predecessors.reject(&:done?)
    @@ -1180,15 +1534,15 @@ 

     
     
    -97
    -98
    -99
    -100
    -101
    -102
    +153 +154 +155 +156 +157 +158

    -
    # File 'app/models/job.rb', line 97
    +      
    # File 'app/models/job.rb', line 153
     
     def append_step(step)
       bt = backtrace
    @@ -1225,15 +1579,15 @@ 

     
     
    -90
    -91
    -92
    -93
    -94
    -95
    +146 +147 +148 +149 +150 +151

    -
    # File 'app/models/job.rb', line 90
    +      
    # File 'app/models/job.rb', line 146
     
     def append_steps(steps)
       bt = backtrace
    @@ -1270,31 +1624,27 @@ 

     
     
    -128
    -129
    -130
    -131
    -132
    -133
    -134
    -135
    -136
    -137
    -138
    +184 +185 +186 +187 +188 +189 +190 +191 +192

    -
    # File 'app/models/job.rb', line 128
    +      
    # File 'app/models/job.rb', line 184
     
     def arguments
    -
    -  if /\.rb$/ =~ path
    +  if /\.rb$/.match?(path)
         JSON.parse(state).first['arguments']
       else
         JSON.parse(state)['stack'].first.reject { |k, _v| k == 'user_id' }
       end
    -rescue JSON::ParseError
    +rescue JSON::ParserError
       { error: 'unable to parse arguments' }
    -
     end
    -
    # File 'app/models/job.rb', line 86
    +      
    # File 'app/models/job.rb', line 142
     
     def backtrace
    -  JSON.parse state, symbolize_names: true
    +  job_state
     end
    -
    # File 'app/models/job.rb', line 221
    +      
    # File 'app/models/job.rb', line 252
     
     def cancel(user)
    -  if pc != Job.COMPLETED
    -    self.pc = Job.COMPLETED
    -    self.user_id = user.id
    -    if /\.rb$/ =~ path
    -      Krill::Client.new.abort id
    -      abort_krill
    -    end
    -    save
    +  return if pc == Job.COMPLETED
    +
    +  self.pc = Job.COMPLETED
    +  self.user_id = user.id
    +  if /\.rb$/.match?(path)
    +    Krill::Client.new.abort(id)
    +    abort_krill
       end
    +  save
     end
    -
    # File 'app/models/job.rb', line 119
    +      
    # File 'app/models/job.rb', line 175
     
     def doer
    -  u = User.find_by_id(user_id.to_i)
    +  u = User.find_by(id: user_id.to_i)
       if u
         u.
       else
    @@ -1499,12 +1849,12 @@ 

     
     
    -52
    -53
    -54
    +108 +109 +110

    -
    # File 'app/models/job.rb', line 52
    +      
    # File 'app/models/job.rb', line 108
     
     def done?
       pc == Job.COMPLETED
    @@ -1551,28 +1901,25 @@ 

     
     
    -249
    -250
    -251
    -252
    -253
    -254
    -255
    -256
    -257
    -258
    -259
    -260
    -261
    -262
    -263
    -264
    +280 +281 +282 +283 +284 +285 +286 +287 +288 +289 +290 +291 +292 +293

    -
    # File 'app/models/job.rb', line 249
    +      
    # File 'app/models/job.rb', line 280
     
     def error?
    -
       if krill?
         begin
           return done? && backtrace.last[:operation] != 'complete'
    @@ -1585,7 +1932,6 @@ 

    else false end - end

    -
    # File 'app/models/job.rb', line 270
    +      
    # File 'app/models/job.rb', line 299
     
     def error_backtrace
       backtrace[-3][:backtrace]
    @@ -1655,15 +2001,68 @@ 

     
     
    -266
    -267
    -268
    +295 +296 +297

    +
    +
    # File 'app/models/job.rb', line 295
    +
    +def error_message
    +  backtrace[-3][:message]
    +end
    +
    +
    + +
    +

    + + #exportObject + + + + + +

    +
    + + +
    +
    +
    + + +
    + + @@ -1671,9 +2070,9 @@

    -

    +

    - #exportObject + #job_stateObject @@ -1681,7 +2080,8 @@

    - +

    hides the fact that state is stored as JSON

    +
    @@ -1694,29 +2094,21 @@

     
     
    -296
    -297
    -298
    -299
    -300
    -301
    -302
    -303
    -304
    -305
    +365 +366 +367 +368 +369 +370

    @@ -1760,19 +2152,19 @@

     
     
    -233
    -234
    -235
    -236
    -237
    -238
    -239
    +264 +265 +266 +267 +268 +269 +270

    +
    +
    +
    +323
    +324
    +325
    +326
    +327
    +328
    +329
    +330
    +331
    +332
    -
    # File 'app/models/job.rb', line 266
    +      
    # File 'app/models/job.rb', line 323
     
    -def error_message
    -  backtrace[-3][:message]
    +def export
    +  a = attributes
    +  begin
    +    a['backtrace'] = JSON.parse a['state'], symbolize_names: true
    +  rescue StandardError
    +    a['backtrace'] = { error: 'Could not parse backtrace.' }
    +  end
    +  a.delete 'state'
    +  a
     end
    -
    # File 'app/models/job.rb', line 296
    +      
    # File 'app/models/job.rb', line 365
     
    -def export
    -  a = attributes
    -  begin
    -    a['backtrace'] = JSON.parse a['state'], symbolize_names: true
    -  rescue StandardError
    -    a['backtrace'] = { error: 'Could not parse backtrace.' }
    -  end
    -  a.delete 'state'
    -  a
    +def job_state
    +  JSON.parse(state, symbolize_names: true)
    +rescue JSON::ParserError
    +  # TODO: make this an exception object
    +  raise "Error: parse error reading state of job #{id}"
     end
    -
    # File 'app/models/job.rb', line 233
    +      
    # File 'app/models/job.rb', line 264
     
     def krill?
    -  if /\.rb$/ =~ path
    +  if /\.rb$/.match?(path)
         true
       else
         false
    @@ -1807,12 +2199,12 @@ 

     
     
    -321
    -322
    -323
    +347 +348 +349

    -
    # File 'app/models/job.rb', line 321
    +      
    # File 'app/models/job.rb', line 347
     
     def name
       path.split('/').last.split('.').first
    @@ -1859,12 +2251,12 @@ 

     
     
    -56
    -57
    -58
    +112 +113 +114

    -
    # File 'app/models/job.rb', line 56
    +      
    # File 'app/models/job.rb', line 112
     
     def not_started?
       pc == Job.NOT_STARTED
    @@ -1898,12 +2290,12 @@ 

     
     
    -292
    -293
    -294
    +319 +320 +321

    -
    # File 'app/models/job.rb', line 292
    +      
    # File 'app/models/job.rb', line 319
     
     def num_posts
       post_associations.count
    @@ -1911,6 +2303,47 @@ 

    +
    + +
    +

    + + #operation_typeObject + + + + + +

    +
    +

    get the operation type for the operations of this job +TODO: seems like this should be a delegate, but not clear if can do it

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +374
    +375
    +376
    +
    +
    # File 'app/models/job.rb', line 374
    +
    +def operation_type
    +  operations.first.operation_type
    +end
    +
    @@ -1955,12 +2388,12 @@

     
     
    -18
     19
    -20
    +20 +21

    -
    # File 'app/models/job.rb', line 18
    +      
    # File 'app/models/job.rb', line 19
     
     def operations
       job_associations.collect(&:operation)
    @@ -2007,12 +2440,12 @@ 

     
     
    -60
    -61
    -62
    +116 +117 +118

    -
    # File 'app/models/job.rb', line 60
    +      
    # File 'app/models/job.rb', line 116
     
     def pending?
       not_started?
    @@ -2059,19 +2492,19 @@ 

     
     
    -241
    -242
    -243
    -244
    -245
    -246
    -247
    +272 +273 +274 +275 +276 +277 +278

    -
    # File 'app/models/job.rb', line 241
    +      
    # File 'app/models/job.rb', line 272
     
     def plankton?
    -  if /\.pl$/ =~ path
    +  if /\.pl$/.match?(path)
         true
       else
         false
    @@ -2106,30 +2539,27 @@ 

     
     
    -166
    -167
    -168
    -169
    -170
    -171
    -172
    -173
    -174
    -175
    -176
    -177
    -178
    -179
    -180
    -181
    -182
    -183
    +211 +212 +213 +214 +215 +216 +217 +218 +219 +220 +221 +222 +223 +224 +225 +226

    -
    # File 'app/models/job.rb', line 166
    +      
    # File 'app/models/job.rb', line 211
     
     def remove_types(p)
    -
       case p
       when String, Integer, Float, TrueClass, FalseClass
         p
    @@ -2144,7 +2574,6 @@ 

    remove_types a end end - end

    -
    # File 'app/models/job.rb', line 329
    +      
    # File 'app/models/job.rb', line 355
     
     def reset
    -
    -  puts Krill::Client.new.abort id
    +  puts Krill::Client.new.abort(id)
       self.state = [{ 'operation' => 'initialize', 'arguments' => {}, 'time' => '2017-06-02T11:40:20-07:00' }].to_json
       self.pc = 0
       save
    -  puts Krill::Client.new.start id
    +  puts Krill::Client.new.start(id)
       reload
    -
     end
    -
    # File 'app/models/job.rb', line 198
    +      
    # File 'app/models/job.rb', line 237
     
     def return_value
    -
    -  if /\.rb$/ =~ path
    -
    +  if /\.rb$/.match?(path)
         begin
    -      @rval = JSON.parse(state, symbolize_names: true).last[:rval] || {}
    +      @rval = job_state.last[:rval] || {}
         rescue StandardError
           @rval = { error: 'Could not find return value.' }
         end
    -
       else
    -
         entries = logs.select { |l| l.entry_type == 'return' }
    -    if entries.empty?
    -      return nil
    -    else
    -      JSON.parse(entries.first.data, symbolize_names: true)
    -    end
    +    return nil if entries.empty?
     
    +    JSON.parse(entries.first.data, symbolize_names: true)
       end
    -
     end
    -
    # File 'app/models/job.rb', line 185
    +      
    # File 'app/models/job.rb', line 228
     
     def set_arguments(a)
    +  raise 'Could not set arguments of non-krill protocol' unless /\.rb$/.match?(path)
     
    -  if /\.rb$/ =~ path
    -    self.state = [{ operation: 'initialize', arguments: (remove_types a), time: Time.now }].to_json
    -  else
    -    raise 'Could not set arguments of non-krill protocol'
    -  end
    -
    +  self.state = [{ operation: 'initialize', arguments: (remove_types a), time: Time.now }].to_json
     end
    -
    # File 'app/models/job.rb', line 140
    +      
    # File 'app/models/job.rb', line 194
     
     def start_link(el, opts = {})
    -
       options = { confirm: false }.merge opts
    -
       confirm = options[:confirm] ? "class='confirm'" : ''
     
    -  if /\.rb$/ =~ path
    -
    +  if /\.rb$/.match?(path)
         if pc == Job.NOT_STARTED
           "<a #{confirm} target=_top href='/krill/start?job=#{id}'>#{el}</a>".html_safe
         else
           "<a #{confirm} target=_top href='/krill/ui?job=#{id}'>#{el}</a>".html_safe
         end
    -
    -  else
    -
    -    if pc == Job.NOT_STARTED
    -      "<a #{confirm} target=_top href='/interpreter/advance?job=#{id}'>#{el}</a>".html_safe
    -    elsif pc != Job.COMPLETED
    -      "<a #{confirm} target=_top href='/interpreter/current?job=#{id}'>#{el}</a>".html_safe
    -    end
    -
    +  elsif pc == Job.NOT_STARTED
    +    "<a #{confirm} target=_top href='/interpreter/advance?job=#{id}'>#{el}</a>".html_safe
    +  elsif pc != Job.COMPLETED
    +    "<a #{confirm} target=_top href='/interpreter/current?job=#{id}'>#{el}</a>".html_safe
       end
    -
     end
    -
    # File 'app/models/job.rb', line 68
    +      
    # File 'app/models/job.rb', line 124
     
     def status
       if pc >= 0
    @@ -2524,35 +2907,33 @@ 

     
     
    -307
    -308
    -309
    -310
    -311
    -312
    -313
    -314
    -315
    -316
    -317
    -318
    -319
    +334 +335 +336 +337 +338 +339 +340 +341 +342 +343 +344 +345

    -
    # File 'app/models/job.rb', line 307
    +      
    # File 'app/models/job.rb', line 334
     
     def step_workflow
    +  return unless workflow_process
     
    -  if workflow_process
    -    begin
    -      wp = WorkflowProcess.find(workflow_process.id)
    -      wp.record_result_of self
    -      wp.step
    -    rescue Exception => e
    -      Rails.logger.info 'Error trying to step workflow process ' + e.to_s
    -    end
    +  begin
    +    wp = WorkflowProcess.find(workflow_process.id)
    +    wp.record_result_of self
    +    wp.step
    +  rescue StandardError => e
    +    # TODO: not clear if this should rescue ActiveRecord::RecordNotFound
    +    Rails.logger.info 'Error trying to step workflow process ' + e.to_s
       end
    -
     end
    -
    # File 'app/models/job.rb', line 107
    +      
    # File 'app/models/job.rb', line 163
     
     def submitter
    -  u = User.find_by_id()
    +  u = User.find_by(id: )
       if u
         u.
       else
    @@ -2631,9 +3012,9 @@ 

    diff --git a/docs/api/Krill.html b/docs/api/Krill.html index 5e481c667..831a72609 100644 --- a/docs/api/Krill.html +++ b/docs/api/Krill.html @@ -79,7 +79,7 @@
    Defined in:
    lib/krill/operation_list.rb,
    - lib/krill/base.rb,
    lib/krill/find.rb,
    lib/krill/table.rb,
    lib/krill/inventory.rb,
    lib/krill/namespace.rb,
    lib/krill/transfers.rb,
    lib/krill/operations.rb,
    lib/krill/show_block.rb,
    lib/krill/show_response.rb,
    lib/krill/operation_list_table.rb,
    lib/krill/operation_list_input_table.rb
    + lib/krill/base.rb,
    lib/krill/find.rb,
    lib/krill/table.rb,
    lib/krill/inventory.rb,
    lib/krill/namespace.rb,
    lib/krill/transfers.rb,
    lib/krill/operations.rb,
    lib/krill/show_block.rb,
    lib/krill/debug_manager.rb,
    lib/krill/show_response.rb,
    lib/krill/protocol_sandbox.rb,
    lib/krill/threaded_manager.rb,
    lib/krill/operation_list_table.rb,
    lib/krill/operation_list_input_table.rb
    @@ -102,7 +102,7 @@ - Classes: ShowBlock, ShowResponse, Table + Classes: KrillBaseError, KrillError, KrillSyntaxError, ProtocolError, ProtocolSandbox, ShowBlock, ShowResponse, Table, ThreadStatus, ThreadedManager

    @@ -118,9 +118,9 @@ diff --git a/docs/api/Krill/Base.html b/docs/api/Krill/Base.html index ae3f8a5d6..392df1aae 100644 --- a/docs/api/Krill/Base.html +++ b/docs/api/Krill/Base.html @@ -589,7 +589,7 @@

  • - #transfer(sources, destinations, options = {}) {|block| ... } ⇒ Object + #transfer(sources, destinations, _options = {}) {|block| ... } ⇒ Object @@ -642,8 +642,6 @@

     
     
    -117
    -118
     119
     120
     121
    @@ -689,10 +687,11 @@ 

    161 162 163 -164

    +164 +165

  • -
    # File 'lib/krill/inventory.rb', line 117
    +      
    # File 'lib/krill/inventory.rb', line 119
     
     def box_interactive(items, method, user_shows)
     
    @@ -730,17 +729,16 @@ 

    end end - unless extras.empty? - takes = extras.collect(&:features) - show do - title extra_title - takes.each do |t| - item t - end - raw user_shows + return if extras.empty? + + takes = extras.collect(&:features) + show do + title extra_title + takes.each do |t| + item t end + raw user_shows end - end

    -
    # File 'lib/krill/inventory.rb', line 92
    +      
    # File 'lib/krill/inventory.rb', line 94
     
     def boxes_for(items)
     
    @@ -889,12 +887,12 @@ 

     
     
    -63
    -64
    -65
    +65 +66 +67

    -
    # File 'lib/krill/inventory.rb', line 63
    +      
    # File 'lib/krill/inventory.rb', line 65
     
     def collection_from(id)
       Collection.find id
    @@ -942,12 +940,12 @@ 

     
     
    -9
    -10
    -11
    +11 +12 +13

    -
    # File 'lib/krill/base.rb', line 9
    +      
    # File 'lib/krill/base.rb', line 11
     
     def debug
       false
    @@ -1113,7 +1111,7 @@ 

    opts = { except: [], interactive: false }.merge options - object_type = ObjectType.find_by_name(object_type_name) + object_type = ObjectType.find_by(name: object_type_name) raise "Could not find object type #{object_type_name} in distribute" unless object_type user_shows = if block_given? @@ -1178,12 +1176,12 @@

     
     
    -64
    -65
    -66
    +71 +72 +73

    -
    # File 'lib/krill/base.rb', line 64
    +      
    # File 'lib/krill/base.rb', line 71
     
     def error(e)
       Job.find(jid).reload.append_step operation: 'error', message: e.to_s, backtrace: e.backtrace[0, 10]
    @@ -1256,7 +1254,14 @@ 

    59 60 61 -62

    +62 +63 +64 +65 +66 +67 +68 +69
    # File 'lib/krill/base.rb', line 23
    @@ -1276,13 +1281,20 @@ 

    Thread.stop # get technician input - input = ShowResponse.new(JSON.parse(@job.reload.state, symbolize_names: true).last[:inputs]) + @job.reload + job_state = @job.job_state + input = ShowResponse.new(job_state.last[:inputs]) # populate operations with table input data - input[:table_inputs].each do |ti| - op = operations.find { |op| op.id == ti[:opid] } - op.temporary[ti[:key].to_sym] = ti[:value].to_f if op && ti[:type] == 'number' - op.temporary[ti[:key].to_sym] = ti[:value] if op && ti[:type] != 'number' + input[:table_inputs].each do |table_input| + operation = operations.find { |op| op.id == table_input[:opid] } + next unless operation + + operation.temporary[table_input[:key].to_sym] = if table_input[:type] == 'number' + table_input[:value].to_f + else + table_input[:value] + end end # return the technician input @@ -1291,7 +1303,7 @@

    else # figure out default technician response - i = ShowResponse.new(simulated_input_for page) + i = ShowResponse.new(simulated_input_for(page)) @job.append_step operation: 'next', time: Time.now, inputs: i raise "Job #{jid} executed too many steps (50) in debug mode. Could be an infinite loop." if @job.pc > 500 @@ -1330,18 +1342,18 @@

     
     
    -33
    -34
     35
     36
     37
     38
     39
     40
    -41
    +41 +42 +43

    -
    # File 'lib/krill/operations.rb', line 33
    +      
    # File 'lib/krill/operations.rb', line 35
     
     def insert_operation(index, element)
       before = @operations[0, index]
    @@ -1465,8 +1477,6 @@ 

     
     
    -19
    -20
     21
     22
     23
    @@ -1505,10 +1515,12 @@ 

    56 57 58 -59

    +59 +60 +61

    -
    # File 'lib/krill/transfers.rb', line 19
    +      
    # File 'lib/krill/transfers.rb', line 21
     
     def load_samples(headings, ingredients, collections) # needs a better name
     
    @@ -1536,7 +1548,7 @@ 

    else "#{r + 1},#{c + 1}" end - tab.push([col.id, loc] + ingredients.collect { |ing| { content: (ing[i].is_a? Item) ? ing[i].id : ing[i], check: true } }) + tab.push([col.id, loc] + ingredients.collect { |ing| { content: ing[i].is_a?(Item) ? ing[i].id : ing[i], check: true } }) end i += 1 end @@ -1588,12 +1600,12 @@

     
     
    -55
    -56
    -57
    +57 +58 +59

    -
    # File 'lib/krill/inventory.rb', line 55
    +      
    # File 'lib/krill/inventory.rb', line 57
     
     def new_collection(name)
       Collection.new_collection name
    @@ -1647,12 +1659,12 @@ 

     
     
    -35
    -36
    -37
    +37 +38 +39

    -
    # File 'lib/krill/inventory.rb', line 35
    +      
    # File 'lib/krill/inventory.rb', line 37
     
     def new_object(name)
       Item.new_object name
    @@ -1721,21 +1733,21 @@ 

     
     
    -43
    -44
     45
     46
     47
     48
     49
    -50
    +50 +51 +52

    -
    # File 'lib/krill/inventory.rb', line 43
    +      
    # File 'lib/krill/inventory.rb', line 45
     
     def new_sample(name, spec)
    -  s = Sample.find_by_name(name)
    -  ot = ObjectType.find_by_name(spec[:as])
    +  s = Sample.find_by(name: name)
    +  ot = ObjectType.find_by(name: spec[:as])
       raise "Unknown sample #{name}" unless s
       raise "Unknown container #{spec[:as]}" unless ot
     
    @@ -1784,16 +1796,16 @@ 

     
     
    -25
    -26
     27
     28
     29
     30
    -31
    +31 +32 +33

    -
    # File 'lib/krill/operations.rb', line 25
    +      
    # File 'lib/krill/operations.rb', line 27
     
     def operation_type
     
    @@ -1849,8 +1861,6 @@ 

     
     
    -8
    -9
     10
     11
     12
    @@ -1861,10 +1871,12 @@ 

    17 18 19 -20

    +20 +21 +22

    -
    # File 'lib/krill/operations.rb', line 8
    +      
    # File 'lib/krill/operations.rb', line 10
     
     def operations(opts = { force: false })
     
    @@ -1908,17 +1920,17 @@ 

     
     
    -262
     263
     264
     265
     266
     267
     268
    -269
    +269 +270

    -
    # File 'lib/krill/inventory.rb', line 262
    +      
    # File 'lib/krill/inventory.rb', line 263
     
     def produce(items)
       if items.class == Array
    @@ -2041,7 +2053,6 @@ 

     
     
    -224
     225
     226
     227
    @@ -2077,10 +2088,11 @@ 

    257 258 259 -260

    +260 +261

    -
    # File 'lib/krill/inventory.rb', line 224
    +      
    # File 'lib/krill/inventory.rb', line 225
     
     def release(items, args = {})
     
    @@ -2156,21 +2168,17 @@ 

     
     
    -16
    -17
     18
     19
     20
     21

    -
    # File 'lib/krill/base.rb', line 16
    +      
    # File 'lib/krill/base.rb', line 18
     
     def show
    -
       page = ShowBlock.new(self).run(&Proc.new)
       finish_show(page)
    -
     end
    -
    # File 'lib/krill/operation_list_input_table.rb', line 125
    +      
    # File 'lib/krill/operation_list_input_table.rb', line 128
     
     def show_with_input_table(ops, create_block, num_tries = 5)
       ops.extend(OperationList)
    @@ -2317,8 +2325,6 @@ 

     
     
    -78
    -79
     80
     81
     82
    @@ -2329,10 +2335,12 @@ 

    87 88 89 -90

    +90 +91 +92

    -
    # File 'lib/krill/inventory.rb', line 78
    +      
    # File 'lib/krill/inventory.rb', line 80
     
     def sort_by_location(items)
       return [] if items.empty?
    @@ -2384,13 +2392,13 @@ 

     
     
    -70
    -71
     72
    -73
    +73 +74 +75

    -
    # File 'lib/krill/inventory.rb', line 70
    +      
    # File 'lib/krill/inventory.rb', line 72
     
     def spread(samples, name, options = {})
       opts = { reverse: false }.merge(options)
    @@ -2510,7 +2518,6 @@ 

     
     
    -176
     177
     178
     179
    @@ -2547,10 +2554,11 @@ 

    210 211 212 -213

    +213 +214

    -
    # File 'lib/krill/inventory.rb', line 176
    +      
    # File 'lib/krill/inventory.rb', line 177
     
     def take(items, args = {})
     
    @@ -2598,7 +2606,7 @@ 

    - #transfer(sources, destinations, options = {}) {|block| ... } ⇒ Object + #transfer(sources, destinations, _options = {}) {|block| ... } ⇒ Object @@ -2688,8 +2696,6 @@

     
     
    -74
    -75
     76
     77
     78
    @@ -2782,16 +2788,14 @@ 

    165

    -
    # File 'lib/krill/transfers.rb', line 74
    +      
    # File 'lib/krill/transfers.rb', line 76
     
    -def transfer(sources, destinations, options = {})
    +def transfer(sources, destinations, _options = {})
     
       # go through each well of the sources and transfer it to the next empty well of
       # destinations. Every time a source or destination is used up, advance to
       # another step.
     
    -  opts = { skip_non_empty: true }.merge options
    -
       user_shows = if block_given?
                      ShowBlock.new.run(&Proc.new)
                    else
    @@ -2886,9 +2890,9 @@ 

    diff --git a/docs/api/Krill/KrillBaseError.html b/docs/api/Krill/KrillBaseError.html new file mode 100644 index 000000000..27b32f374 --- /dev/null +++ b/docs/api/Krill/KrillBaseError.html @@ -0,0 +1,744 @@ + + + + + + + Exception: Krill::KrillBaseError + + — Aquarium Documentation + + + + + + + + + + + + + + + + + + + +
    + + +

    Exception: Krill::KrillBaseError + + + +

    +
    + +
    +
    Inherits:
    +
    + StandardError + +
      +
    • Object
    • + + + + + +
    + show all + +
    +
    + + + + + + + + + + + +
    +
    Defined in:
    +
    lib/krill/protocol_sandbox.rb
    +
    + +
    + +
    +
    + + +
    +
    +
    + + +
    +

    Direct Known Subclasses

    +

    KrillError, KrillSyntaxError

    +
    + + + + +

    Instance Attribute Summary collapse

    + + + + + + +

    + Instance Method Summary + collapse +

    + + + + + +
    +

    Constructor Details

    + +
    +

    + + #initialize(operation_type:, error:, message:, namespace: '') ⇒ KrillBaseError + + + + + +

    +
    +

    Create a KrillBaseError object for the given operation type, error and message.

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + operation_type + + + (OperationType) + + + + — +

      the operation type

      +
      + +
    • + +
    • + + error + + + (Exception) + + + + — +

      the error object

      +
      + +
    • + +
    • + + message + + + (string) + + + + — +

      the message for this error

      +
      + +
    • + +
    + + +
    + + + + +
    +
    +
    +
    +151
    +152
    +153
    +154
    +155
    +156
    +
    +
    # File 'lib/krill/protocol_sandbox.rb', line 151
    +
    +def initialize(operation_type:, error:, message:, namespace: '')
    +  @operation_type = operation_type
    +  @error = error
    +  @namespace = namespace
    +  super(message)
    +end
    +
    +
    + +
    + +
    +

    Instance Attribute Details

    + + + +
    +

    + + #errorObject (readonly) + + + + + +

    +
    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +144
    +145
    +146
    +
    +
    # File 'lib/krill/protocol_sandbox.rb', line 144
    +
    +def error
    +  @error
    +end
    +
    +
    + + + +
    +

    + + #namespaceObject (readonly) + + + + + +

    +
    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +144
    +145
    +146
    +
    +
    # File 'lib/krill/protocol_sandbox.rb', line 144
    +
    +def namespace
    +  @namespace
    +end
    +
    +
    + + + +
    +

    + + #operation_typeObject (readonly) + + + + + +

    +
    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +144
    +145
    +146
    +
    +
    # File 'lib/krill/protocol_sandbox.rb', line 144
    +
    +def operation_type
    +  @operation_type
    +end
    +
    +
    + +
    + + +
    +

    Instance Method Details

    + + +
    +

    + + #error_backtraceObject + + + + + +

    +
    +

    Returns the backtrace of the associated error filtered to exclude +Aquarium context. +Replaces occurrences of '(eval)' path with operation type path.

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +196
    +197
    +198
    +199
    +200
    +201
    +202
    +203
    +204
    +205
    +
    +
    # File 'lib/krill/protocol_sandbox.rb', line 196
    +
    +def error_backtrace
    +  split = error.backtrace.collect { |msg| msg.match(/^([^:]+):(\d+):(.+)$/m).captures }
    +  filtered = split.reject { |c| c.first.match(%r{^(/[^/]+)+$}m) }
    +  filtered.collect do |captures|
    +    path, line_number, message = captures
    +    path = operation_path if path == '(eval)'
    +
    +    "#{path}: line #{line_number}: #{message.strip}".strip
    +  end
    +end
    +
    +
    + +
    +

    + + #error_messageObject + + + + + +

    +
    +

    Returns a transformed version of the message for the error of this object. +Replaces occurrences of "(eval)" with the operation type path, and +removes suffix referencing ExecutionNamespace enclosing the protocol +during execution.

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +167
    +168
    +169
    +170
    +171
    +172
    +173
    +174
    +175
    +176
    +177
    +178
    +179
    +180
    +181
    +182
    +183
    +184
    +185
    +186
    +187
    +188
    +189
    +190
    +191
    +
    +
    # File 'lib/krill/protocol_sandbox.rb', line 167
    +
    +def error_message
    +  messages = []
    +  @error.message.each_line do |line|
    +    # replaces occurrence of "(eval)" as file path
    +    match = line.match(/^\(eval\):(\d+):(.+)$/m)
    +    if match
    +      line_number, message = match.captures
    +      messages.append("#{operation_path}: line #{line_number}:#{message}")
    +      next
    +    end
    +
    +    # strips uninformative context from NameError message
    +    namespace_pattern = Regexp.new(" for (\#<)?#{@namespace}:(Module|0x[0-9a-f]+>)$")
    +    match = line.match(namespace_pattern)
    +    if match
    +      loc = match.begin(0) - 1
    +      messages.append(line[0..loc])
    +      next
    +    end
    +
    +    messages.append(line)
    +  end
    +
    +  messages.join('')
    +end
    +
    +
    + +
    +

    + + #operation_pathObject + + + + + +

    +
    +

    Returns the path of the operation type for this error.

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +159
    +160
    +161
    +
    +
    # File 'lib/krill/protocol_sandbox.rb', line 159
    +
    +def operation_path
    +  "#{@operation_type.category}/#{@operation_type.name}"
    +end
    +
    +
    + +
    + +
    + + + +
    + + \ No newline at end of file diff --git a/docs/api/Krill/KrillError.html b/docs/api/Krill/KrillError.html new file mode 100644 index 000000000..2fdcf43c3 --- /dev/null +++ b/docs/api/Krill/KrillError.html @@ -0,0 +1,372 @@ + + + + + + + Exception: Krill::KrillError + + — Aquarium Documentation + + + + + + + + + + + + + + + + + + + +
    + + +

    Exception: Krill::KrillError + + + +

    +
    + +
    +
    Inherits:
    +
    + KrillBaseError + +
      +
    • Object
    • + + + + + + + +
    + show all + +
    +
    + + + + + + + + + + + +
    +
    Defined in:
    +
    lib/krill/protocol_sandbox.rb
    +
    + +
    + +

    Overview

    +
    +

    Exception class for errors during execution of protocols

    + + +
    +
    +
    + + +
    + + + +

    Instance Attribute Summary collapse

    +
      + +
    • + + + #job ⇒ Object + + + + + + + + + readonly + + + + + + + + + +
      + +
    • + + +
    + + + + + +

    Attributes inherited from KrillBaseError

    +

    #error, #namespace, #operation_type

    + + + +

    + Instance Method Summary + collapse +

    + + + + + + + + + + + + + +

    Methods inherited from KrillBaseError

    +

    #error_backtrace, #error_message, #operation_path

    + +
    +

    Constructor Details

    + +
    +

    + + #initialize(job:, error:, message: 'Error executing protocol', namespace: '') ⇒ KrillError + + + + + +

    +
    +

    Create a KrillError object for the given job and exception with an +optional message.

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + job + + + (Job) + + + + — +

      the job where error occurred

      +
      + +
    • + +
    • + + error + + + (Exception) + + + + — +

      the error

      +
      + +
    • + +
    • + + message + + + (String) + + + + — +

      the error message

      +
      + +
    • + +
    + + +
    + + + + +
    +
    +
    +
    +218
    +219
    +220
    +221
    +222
    +223
    +224
    +225
    +226
    +
    +
    # File 'lib/krill/protocol_sandbox.rb', line 218
    +
    +def initialize(job:, error:, message: 'Error executing protocol', namespace: '')
    +  @job = job
    +  super(
    +    operation_type: @job.operation_type,
    +    error: error,
    +    message: message,
    +    namespace: namespace
    +  )
    +end
    +
    +
    + +
    + +
    +

    Instance Attribute Details

    + + + +
    +

    + + #jobObject (readonly) + + + + + +

    +
    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +210
    +211
    +212
    +
    +
    # File 'lib/krill/protocol_sandbox.rb', line 210
    +
    +def job
    +  @job
    +end
    +
    +
    + +
    + + +
    + + + +
    + + \ No newline at end of file diff --git a/docs/api/Krill/KrillSyntaxError.html b/docs/api/Krill/KrillSyntaxError.html new file mode 100644 index 000000000..0ad5abf87 --- /dev/null +++ b/docs/api/Krill/KrillSyntaxError.html @@ -0,0 +1,282 @@ + + + + + + + Exception: Krill::KrillSyntaxError + + — Aquarium Documentation + + + + + + + + + + + + + + + + + + + +
    + + +

    Exception: Krill::KrillSyntaxError + + + +

    +
    + +
    +
    Inherits:
    +
    + KrillBaseError + +
      +
    • Object
    • + + + + + + + +
    + show all + +
    +
    + + + + + + + + + + + +
    +
    Defined in:
    +
    lib/krill/protocol_sandbox.rb
    +
    + +
    + +

    Overview

    +
    +

    Exception class for protocol syntax errors

    + + +
    +
    +
    + + +
    + + + + + +

    Instance Attribute Summary

    + +

    Attributes inherited from KrillBaseError

    +

    #error, #namespace, #operation_type

    + + + +

    + Instance Method Summary + collapse +

    + + + + + + + + + + + + + +

    Methods inherited from KrillBaseError

    +

    #error_backtrace, #error_message, #operation_path

    + +
    +

    Constructor Details

    + +
    +

    + + #initialize(operation_type:, error:, message: 'Syntax error in operation type') ⇒ KrillSyntaxError + + + + + +

    +
    +

    Create a KrillSyntaxError object indicating an error in the given +operation type.

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + operation_type + + + (OperationType) + + + + — +

      the operation type

      +
      + +
    • + +
    • + + error + + + (Exception) + + + + — +

      the error object

      +
      + +
    • + +
    • + + message + + + (String) + + + + — +

      the error message

      +
      + +
    • + +
    + + +
    + + + + +
    +
    +
    +
    +239
    +240
    +241
    +
    +
    # File 'lib/krill/protocol_sandbox.rb', line 239
    +
    +def initialize(operation_type:, error:, message: 'Syntax error in operation type')
    +  super(operation_type: operation_type, error: error, message: message)
    +end
    +
    +
    + +
    + + +
    + + + +
    + + \ No newline at end of file diff --git a/docs/api/Krill/OperationList.html b/docs/api/Krill/OperationList.html index b631afd09..2923ab43a 100644 --- a/docs/api/Krill/OperationList.html +++ b/docs/api/Krill/OperationList.html @@ -269,7 +269,7 @@

  • - #custom_column(opts = { heading: "Custom Column", checkable: false }, &block) ⇒ Object + #custom_column(opts = { heading: 'Custom Column', checkable: false }, &block) ⇒ Object @@ -292,7 +292,7 @@

  • - #custom_input(key, opts = { heading: "Custom Input", checkable: false, type: "string", style_block: nil }, &default_block) ⇒ Object + #custom_input(key, opts = { heading: 'Custom Input', checkable: false, type: 'string', style_block: nil }) ⇒ Object @@ -1138,33 +1138,29 @@

     
     
    -274
    -275
    -276
    -277
    -278
    -279
    -280
    -281
    -282
    -283
    -284
    -285
    +262 +263 +264 +265 +266 +267 +268 +269 +270 +271

  • -
    # File 'lib/krill/operation_list.rb', line 274
    +      
    # File 'lib/krill/operation_list.rb', line 262
     
     def add_static_inputs(name, sample_name, container_name)
    -
       each do |op|
    -    sample = Sample.find_by_name(sample_name)
    -    container = ObjectType.find_by_name(container_name)
    -    op.add_input name, sample, container
    +    sample = Sample.find_by(name: sample_name)
    +    container = ObjectType.find_by(name: container_name)
    +    op.add_input(name, sample, container)
         op.input(name).set item: sample.in(container.name).first
       end
     
       self
    -
     end
    -
    # File 'lib/krill/operation_list_input_table.rb', line 38
    +      
    # File 'lib/krill/operation_list_input_table.rb', line 41
     
     def cleanup_input_table
       temp_op = first
    @@ -1295,15 +1291,15 @@ 

     
     
    -31
    -32
     33
     34
     35
    -36
    +36 +37 +38

    -
    # File 'lib/krill/operation_list.rb', line 31
    +      
    # File 'lib/krill/operation_list.rb', line 33
     
     def collect(&block)
       ops = super(&block)
    @@ -1435,17 +1431,17 @@ 

     
     
    -79
    -80
     81
     82
     83
     84
     85
    -86
    +86 +87 +88

    -
    # File 'lib/krill/operation_list_table.rb', line 79
    +      
    # File 'lib/krill/operation_list_table.rb', line 81
     
     def collection(name, role, opts = {})
       entries = running.collect do |op|
    @@ -1484,12 +1480,12 @@ 

     
     
    -213
    -214
    -215
    +215 +216 +217

    -
    # File 'lib/krill/operation_list.rb', line 213
    +      
    # File 'lib/krill/operation_list.rb', line 215
     
     def collection_column(fv)
       fv.name + ' Collection ID'
    @@ -1618,15 +1614,15 @@ 

     
     
    -111
    -112
     113
     114
     115
    -116
    +116 +117 +118

    -
    # File 'lib/krill/operation_list_table.rb', line 111
    +      
    # File 'lib/krill/operation_list_table.rb', line 113
     
     def column(name, role, opts = {})
       @table.add_column(opts[:heading] || "#{name} Column (#{role})", running.collect do |op|
    @@ -1663,12 +1659,12 @@ 

     
     
    -221
    -222
    -223
    +223 +224 +225

    -
    # File 'lib/krill/operation_list.rb', line 221
    +      
    # File 'lib/krill/operation_list.rb', line 223
     
     def column_column(fv)
       fv.name + ' Column'
    @@ -1681,7 +1677,7 @@ 

    - #custom_column(opts = { heading: "Custom Column", checkable: false }, &block) ⇒ Object + #custom_column(opts = { heading: 'Custom Column', checkable: false }, &block) ⇒ Object @@ -1706,7 +1702,7 @@

    (Hash) - (defaults to: { heading: "Custom Column", checkable: false }) + (defaults to: { heading: 'Custom Column', checkable: false }) @@ -1756,21 +1752,21 @@

     
     
    -122
    -123
     124
     125
     126
     127
     128
    -129
    +129 +130 +131

    -
    # File 'lib/krill/operation_list_table.rb', line 122
    +      
    # File 'lib/krill/operation_list_table.rb', line 124
     
    -def custom_column(opts = { heading: "Custom Column", checkable: false }, &block)
    +def custom_column(opts = { heading: 'Custom Column', checkable: false }, &block)
       entries = running.collect(&block).collect do |x|
    -    opts[:checkable] ? ({ content: x, check: true }) : x
    +    opts[:checkable] ? { content: x, check: true } : x
       end
       @table.add_column(opts[:heading], entries)
     
    @@ -1784,7 +1780,7 @@ 

    - #custom_input(key, opts = { heading: "Custom Input", checkable: false, type: "string", style_block: nil }, &default_block) ⇒ Object + #custom_input(key, opts = { heading: 'Custom Input', checkable: false, type: 'string', style_block: nil }) ⇒ Object @@ -1807,8 +1803,6 @@

     
     
    -7
    -8
     9
     10
     11
    @@ -1835,19 +1829,23 @@ 

    32 33 34 -35

    +35 +36 +37 +38

    -
    # File 'lib/krill/operation_list_input_table.rb', line 7
    +      
    # File 'lib/krill/operation_list_input_table.rb', line 9
     
    -def custom_input(key, opts = { heading: "Custom Input", checkable: false, type: "string", style_block: nil }, &default_block)
    -  self.each.with_index do |op, i|
    +def custom_input(key, opts = { heading: 'Custom Input', checkable: false, type: 'string', style_block: nil })
    +  each.with_index do |op, i|
         op.temporary[:uid] = i
       end
       temp_op = first
       default_values = map do |op|
         # d = op.temporary[key] # Prefer to default to last inputted value
    -    d ||= default_block.call(op)
    +    # TODO: what is this supposed to be doing?
    +    d || yield(op)
       end
       entries = zip(default_values).map do |op, d|
         # Save a list of temporary keys to be deleted later
    @@ -1906,12 +1904,12 @@ 

     
     
    -25
    -26
    -27
    +27 +28 +29

    -
    # File 'lib/krill/operation_list_table.rb', line 25
    +      
    # File 'lib/krill/operation_list_table.rb', line 27
     
     def end_table
       @table
    @@ -1963,12 +1961,12 @@ 

     
     
    -78
    -79
    -80
    +80 +81 +82

    -
    # File 'lib/krill/operation_list.rb', line 78
    +      
    # File 'lib/krill/operation_list.rb', line 80
     
     def errored
       select { |op| op.status == 'error' }
    @@ -2073,17 +2071,17 @@ 

     
     
    -229
    -230
    -231
    -232
    -233
    -234
    +251 +252 +253 +254 +255 +256

    -
    # File 'lib/krill/operation_list_table.rb', line 229
    +      
    # File 'lib/krill/operation_list_table.rb', line 251
     
    -def get key, opts
    +def get(key, opts)
       @table.add_column(opts[:heading] || key.to_s, running.collect do |op|
         { type: opts[:type] || 'number', operation_id: op.id, key: key, default: opts[:default] || 0 }
       end)
    @@ -2118,18 +2116,18 @@ 

     
     
    -59
    -60
     61
     62
     63
     64
     65
     66
    -67
    +67 +68 +69

    -
    # File 'lib/krill/operation_list.rb', line 59
    +      
    # File 'lib/krill/operation_list.rb', line 61
     
     def group_by(&block)
       grouped_ops = super(&block)
    @@ -2240,12 +2238,16 @@ 

     
     
    -176
    +186 +187 +188

    -
    # File 'lib/krill/operation_list_table.rb', line 176
    +      
    # File 'lib/krill/operation_list_table.rb', line 186
     
    -def input_collection  name, opts = {}; collection name, "input", opts;  end
    +def input_collection(name, opts = {}) + collection name, 'input', opts +end
    @@ -2346,12 +2348,16 @@

     
     
    -212
    +230 +231 +232

    -
    # File 'lib/krill/operation_list_table.rb', line 212
    +      
    # File 'lib/krill/operation_list_table.rb', line 230
     
    -def input_column      name, opts = {}; column name,     "input", opts;  end
    +def input_column(name, opts = {}) + column name, 'input', opts +end
    @@ -2450,12 +2456,16 @@

     
     
    -143
    +145 +146 +147

    -
    # File 'lib/krill/operation_list_table.rb', line 143
    +      
    # File 'lib/krill/operation_list_table.rb', line 145
     
    -def input_item        name, opts = {}; item name,       "input", opts;  end
    +def input_item(name, opts = {}) + item name, 'input', opts +end
    @@ -2556,12 +2566,16 @@

     
     
    -194
    +208 +209 +210

    -
    # File 'lib/krill/operation_list_table.rb', line 194
    +      
    # File 'lib/krill/operation_list_table.rb', line 208
     
    -def input_row         name, opts = {}; row name,        "input", opts;  end
    +def input_row(name, opts = {}) + row name, 'input', opts +end
    @@ -2660,12 +2674,16 @@

     
     
    -159
    +165 +166 +167

    -
    # File 'lib/krill/operation_list_table.rb', line 159
    +      
    # File 'lib/krill/operation_list_table.rb', line 165
     
    -def input_sample      name, opts = {}; sample name,     "input", opts;  end
    +def input_sample(name, opts = {}) + sample name, 'input', opts +end
    @@ -2695,8 +2713,6 @@

     
     
    -225
    -226
     227
     228
     229
    @@ -2730,70 +2746,44 @@ 

    257 258 259 -260 -261 -262 -263 -264 -265 -266 -267 -268 -269 -270 -271 -272

    +260

    -
    # File 'lib/krill/operation_list.rb', line 225
    +      
    # File 'lib/krill/operation_list.rb', line 227
     
     def io_table(role = 'input')
    -
       t = Table.new
     
       each_with_index do |op, _i|
    -
    -    op.field_values.select { |fv| fv.role == role }.each do |fv|
    -
    +    values = op.field_values.select { |fv| fv.role == role }
    +    values.each do |fv|
           if fv.part?
    -
             unless t.has_column? fv.name
               t.column(fv.name,               fv.name)
                .column(collection_column(fv), collection_column(fv))
                .column(row_column(fv),        row_column(fv))
                .column(column_column(fv),     column_column(fv))
             end
    -
             t.set(fv.name,               fv.child_sample ? fv.child_sample.name : 'NO SAMPLE')
    -         .set(collection_column(fv), fv.child_item_id ? fv.child_item_id : 'NO COLLECTION')
    +         .set(collection_column(fv), fv.child_item_id || 'NO COLLECTION')
              .set(row_column(fv),        fv.row)
              .set(column_column(fv),     fv.column)
    -
           elsif fv.value
    -
             t.column(fv.name, fv.name)
             t.set(fv.name, fv.value)
    -
           else
    -
             unless t.has_column? fv.name
               t.column(fv.name,         fv.name)
                .column(item_column(fv), item_column(fv))
             end
    -
             t.set(fv.name,         fv.child_sample ? fv.child_sample.name : 'NO SAMPLE')
    -         .set(item_column(fv), fv.child_item_id ? fv.child_item_id : 'NO ITEM')
    -
    +         .set(item_column(fv), fv.child_item_id || 'NO ITEM')
           end
    -
         end
    -
         t.append
    -
       end
     
       t
    -
     end
    @@ -2919,15 +2909,15 @@

     
     
    -49
    -50
     51
     52
     53
    -54
    +54 +55 +56

    -
    # File 'lib/krill/operation_list_table.rb', line 49
    +      
    # File 'lib/krill/operation_list_table.rb', line 51
     
     def item(name, role, opts = {})
       @table.add_column(opts[:heading] || "#{name} Item ID (#{role})", running.collect do |op|
    @@ -2964,12 +2954,12 @@ 

     
     
    -209
    -210
    -211
    +211 +212 +213

    -
    # File 'lib/krill/operation_list.rb', line 209
    +      
    # File 'lib/krill/operation_list.rb', line 211
     
     def item_column(fv)
       fv.name + ' Item ID'
    @@ -3083,8 +3073,6 @@ 

     
     
    -138
    -139
     140
     141
     142
    @@ -3125,10 +3113,12 @@ 

    177 178 179 -180

    +180 +181 +182

    -
    # File 'lib/krill/operation_list.rb', line 138
    +      
    # File 'lib/krill/operation_list.rb', line 140
     
     def make(custom_opts = {})
     
    @@ -3202,15 +3192,15 @@ 

     
     
    -38
    -39
     40
     41
     42
    -43
    +43 +44 +45

    -
    # File 'lib/krill/operation_list.rb', line 38
    +      
    # File 'lib/krill/operation_list.rb', line 40
     
     def map(&block)
       ops = super(&block)
    @@ -3247,14 +3237,14 @@ 

     
     
    -131
    -132
     133
     134
    -135
    +135 +136 +137

    -
    # File 'lib/krill/operation_list_table.rb', line 131
    +      
    # File 'lib/krill/operation_list_table.rb', line 133
     
     def operation_id(opts = { heading: 'Operation ID', checkable: false })
       @table.add_column(opts[:heading], running.collect(&:id))
    @@ -3361,12 +3351,16 @@ 

     
     
    -185
    +197 +198 +199

    -
    # File 'lib/krill/operation_list_table.rb', line 185
    +      
    # File 'lib/krill/operation_list_table.rb', line 197
     
    -def output_collection name, opts = {}; collection name, "output", opts; end
    +def output_collection(name, opts = {}) + collection name, 'output', opts +end
    @@ -3421,13 +3415,13 @@

     
     
    -126
    -127
     128
    -129
    +129 +130 +131

    -
    # File 'lib/krill/operation_list.rb', line 126
    +      
    # File 'lib/krill/operation_list.rb', line 128
     
     def output_collections
       @output_collections ||= {}
    @@ -3533,12 +3527,16 @@ 

     
     
    -221
    +241 +242 +243

    -
    # File 'lib/krill/operation_list_table.rb', line 221
    +      
    # File 'lib/krill/operation_list_table.rb', line 241
     
    -def output_column     name, opts = {}; column name,     "output", opts; end
    +def output_column(name, opts = {}) + column name, 'output', opts +end
    @@ -3637,12 +3635,16 @@

     
     
    -151
    +155 +156 +157

    -
    # File 'lib/krill/operation_list_table.rb', line 151
    +      
    # File 'lib/krill/operation_list_table.rb', line 155
     
    -def output_item       name, opts = {}; item name,       "output", opts; end
    +def output_item(name, opts = {}) + item name, 'output', opts +end
    @@ -3743,12 +3745,16 @@

     
     
    -203
    +219 +220 +221

    -
    # File 'lib/krill/operation_list_table.rb', line 203
    +      
    # File 'lib/krill/operation_list_table.rb', line 219
     
    -def output_row        name, opts = {}; row name,        "output", opts; end
    +def output_row(name, opts = {}) + row name, 'output', opts +end
    @@ -3847,12 +3853,16 @@

     
     
    -167
    +175 +176 +177

    -
    # File 'lib/krill/operation_list_table.rb', line 167
    +      
    # File 'lib/krill/operation_list_table.rb', line 175
     
    -def output_sample     name, opts = {}; sample name,     "output", opts; end
    +def output_sample(name, opts = {}) + sample name, 'output', opts +end
    @@ -3882,8 +3892,6 @@

     
     
    -29
    -30
     31
     32
     33
    @@ -3892,10 +3900,12 @@ 

    36 37 38 -39

    +39 +40 +41

    -
    # File 'lib/krill/operation_list_table.rb', line 29
    +      
    # File 'lib/krill/operation_list_table.rb', line 31
     
     def property(op, method_name, name, role, checkable)
     
    @@ -3937,12 +3947,12 @@ 

     
     
    -27
    -28
    -29
    +29 +30 +31

    -
    # File 'lib/krill/operation_list.rb', line 27
    +      
    # File 'lib/krill/operation_list.rb', line 29
     
     def protocol=(p)
       @protocol = p
    @@ -3976,15 +3986,15 @@ 

     
     
    -52
    -53
     54
     55
     56
    -57
    +57 +58 +59

    -
    # File 'lib/krill/operation_list.rb', line 52
    +      
    # File 'lib/krill/operation_list.rb', line 54
     
     def reject(&block)
       ops = super(&block)
    @@ -4021,15 +4031,15 @@ 

     
     
    -236
    -237
    -238
    -239
    -240
    -241
    +258 +259 +260 +261 +262 +263

    -
    # File 'lib/krill/operation_list_table.rb', line 236
    +      
    # File 'lib/krill/operation_list_table.rb', line 258
     
     def result(key, opts = {})
       @table.add_column(opts[:heading] || key.to_s, running.collect do |op|
    @@ -4151,8 +4161,6 @@ 

     
     
    -90
    -91
     92
     93
     94
    @@ -4181,10 +4189,12 @@ 

    117 118 119 -120

    +120 +121 +122

    -
    # File 'lib/krill/operation_list.rb', line 90
    +      
    # File 'lib/krill/operation_list.rb', line 92
     
     def retrieve(opts = {})
       opts = { interactive: true, method: 'boxes', only: [] }.merge opts
    @@ -4341,15 +4351,15 @@ 

     
     
    -96
    -97
     98
     99
     100
    -101
    +101 +102 +103

    -
    # File 'lib/krill/operation_list_table.rb', line 96
    +      
    # File 'lib/krill/operation_list_table.rb', line 98
     
     def row(name, role, opts = {})
       @table.add_column(opts[:heading] || "#{name} Row (#{role})", running.collect do |op|
    @@ -4386,12 +4396,12 @@ 

     
     
    -217
    -218
    -219
    +219 +220 +221

    -
    # File 'lib/krill/operation_list.rb', line 217
    +      
    # File 'lib/krill/operation_list.rb', line 219
     
     def row_column(fv)
       fv.name + ' Row'
    @@ -4425,15 +4435,15 @@ 

     
     
    -69
    -70
     71
     72
     73
    -74
    +74 +75 +76

    -
    # File 'lib/krill/operation_list.rb', line 69
    +      
    # File 'lib/krill/operation_list.rb', line 71
     
     def running
       result = select do |op|
    @@ -4565,15 +4575,15 @@ 

     
     
    -64
    -65
     66
     67
     68
    -69
    +69 +70 +71

    -
    # File 'lib/krill/operation_list_table.rb', line 64
    +      
    # File 'lib/krill/operation_list_table.rb', line 66
     
     def sample(name, role, opts = {})
       @table.add_column(opts[:heading] || "#{name} Sample ID (#{role})", running.collect do |op|
    @@ -4610,15 +4620,15 @@ 

     
     
    -45
    -46
     47
     48
     49
    -50
    +50 +51 +52

    -
    # File 'lib/krill/operation_list.rb', line 45
    +      
    # File 'lib/krill/operation_list.rb', line 47
     
     def select(&block)
       ops = super(&block)
    @@ -4712,13 +4722,13 @@ 

     
     
    -18
    -19
     20
    -21
    +21 +22 +23

    -
    # File 'lib/krill/operation_list_table.rb', line 18
    +      
    # File 'lib/krill/operation_list_table.rb', line 20
     
     def start_table(_opts = { errored: false })
       @table = Table.new
    @@ -4851,8 +4861,6 @@ 

     
     
    -189
    -190
     191
     192
     193
    @@ -4869,17 +4877,19 @@ 

    204 205 206 -207

    +207 +208 +209

    -
    # File 'lib/krill/operation_list.rb', line 189
    +      
    # File 'lib/krill/operation_list.rb', line 191
     
     def store(opts = { interactive: true, method: 'boxes', errored: false, io: 'all' })
     
       items = []
     
       select { |op| opts[:errored] || op.status != 'error' }.each_with_index do |op, _i|
    -    op.field_values.select { |fv| fv.field_type.ftype == 'sample' && (opts[:io] == 'all' || fv.role == opts[:io]) }.each do |input|
    +    op.field_values.select { |fv| fv.field_type.sample? && (opts[:io] == 'all' || fv.role == opts[:io]) }.each do |input|
           items << input.child_item if input.child_item.location != 'deleted'
         end
       end
    @@ -4938,21 +4948,21 @@ 

     
     
    -80
    -81
    -82
     83
     84
     85
     86
    -87
    +87 +88 +89 +90

    -
    # File 'lib/krill/operation_list_input_table.rb', line 80
    +      
    # File 'lib/krill/operation_list_input_table.rb', line 83
     
    -def validate key, &validation_block
    -  self.each do |op|
    -    validation = op.temporary[:validation] || Hash.new
    +def validate(key, &validation_block)
    +  each do |op|
    +    validation = op.temporary[:validation] || {}
         validation[key] = validation_block
         op.temporary[:validation] = validation
       end
    @@ -5006,21 +5016,21 @@ 

     
     
    -100
    -101
    -102
     103
     104
     105
     106
    -107
    +107 +108 +109 +110

    -
    # File 'lib/krill/operation_list_input_table.rb', line 100
    +      
    # File 'lib/krill/operation_list_input_table.rb', line 103
     
    -def validation_message key, &message_block
    -  self.each do |op|
    -    message_hash = op.temporary[:validation_messages] || Hash.new
    +def validation_message(key, &message_block)
    +  each do |op|
    +    message_hash = op.temporary[:validation_messages] || {}
         message_hash[key] = message_block
         op.temporary[:validation_messages] = message_hash
       end
    @@ -5036,9 +5046,9 @@ 

    diff --git a/docs/api/Krill/ProtocolError.html b/docs/api/Krill/ProtocolError.html new file mode 100644 index 000000000..dae638eb3 --- /dev/null +++ b/docs/api/Krill/ProtocolError.html @@ -0,0 +1,214 @@ + + + + + + + Exception: Krill::ProtocolError + + — Aquarium Documentation + + + + + + + + + + + + + + + + + + + +
    + + +

    Exception: Krill::ProtocolError + + + +

    +
    + +
    +
    Inherits:
    +
    + StandardError + +
      +
    • Object
    • + + + + + +
    + show all + +
    +
    + + + + + + + + + + + +
    +
    Defined in:
    +
    lib/krill/protocol_sandbox.rb
    +
    + +
    + +

    Overview

    +
    +

    Exception class for protocol errors

    + + +
    +
    +
    + + +
    + + + + + + + +

    + Instance Method Summary + collapse +

    + + + + + +
    +

    Constructor Details

    + +
    +

    + + #initialize(message) ⇒ ProtocolError + + + + + +

    +
    +

    Returns a new instance of ProtocolError

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +138
    +139
    +140
    +
    +
    # File 'lib/krill/protocol_sandbox.rb', line 138
    +
    +def initialize(message)
    +  super(message)
    +end
    +
    +
    + +
    + + +
    + + + +
    + + \ No newline at end of file diff --git a/docs/api/Krill/ProtocolSandbox.html b/docs/api/Krill/ProtocolSandbox.html new file mode 100644 index 000000000..2f3684095 --- /dev/null +++ b/docs/api/Krill/ProtocolSandbox.html @@ -0,0 +1,715 @@ + + + + + + + Class: Krill::ProtocolSandbox + + — Aquarium Documentation + + + + + + + + + + + + + + + + + + + +
    + + +

    Class: Krill::ProtocolSandbox + + + +

    +
    + +
    +
    Inherits:
    +
    + Object + +
      +
    • Object
    • + + + +
    + show all + +
    +
    + + + + + + + + + + + +
    +
    Defined in:
    +
    lib/krill/protocol_sandbox.rb
    +
    + +
    + +

    Overview

    +
    +

    Defines an execution environment for the protocol of a job. +Loads the protocol into a unique namespace module, and extends the class +with protocol base methods.

    + +

    Despite the name, this is not yet a sandbox, so protocols may still +do bad, bad things to the server environment.

    + + +
    +
    +
    + + +
    + + + +

    Instance Attribute Summary collapse

    +
      + +
    • + + + #job ⇒ Object + + + + + + + + + readonly + + + + + + + + + +

      these are here for observability in tests.

      +
      + +
    • + + +
    • + + + #protocol ⇒ Object + + + + + + + + + readonly + + + + + + + + + +

      these are here for observability in tests.

      +
      + +
    • + + +
    + + + + + +

    + Instance Method Summary + collapse +

    + + + + +
    +

    Constructor Details

    + +
    +

    + + #initialize(job:, debug: false, mutex: nil, thread_status: nil) ⇒ ProtocolSandbox + + + + + +

    +
    +

    Initializes a new Krill::ProtocolSandbox object.

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + job + + + (Job) + + + + — +

      the job

      +
      + +
    • + +
    • + + debug + + + (TrueClass, FalseClass) + + + + — +

      whether protocol runs in debug mode

      +
      + +
    • + +
    • + + mutex + + + (Mutex) + + + + — +

      lock object for synchronization (nil)

      +
      + +
    • + +
    • + + thread_status + + + (ThreadStatus) + + + + — +

      status for manager thread (nil)

      +
      + +
    • + +
    + +

    Raises:

    +
      + +
    • + + + (KrillSyntaxError) + + + + — +

      if the protocol has a syntax error

      +
      + +
    • + +
    • + + + (KrillError) + + + + — +

      if loading the protocol has an execution error

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +27
    +28
    +29
    +30
    +31
    +32
    +33
    +34
    +35
    +36
    +37
    +38
    +39
    +40
    +41
    +42
    +43
    +44
    +45
    +46
    +47
    +48
    +49
    +
    +
    # File 'lib/krill/protocol_sandbox.rb', line 27
    +
    +def initialize(job:, debug: false, mutex: nil, thread_status: nil)
    +  @job = job
    +  operation_type = @job.operation_type
    +  base_class_prefix = 'KrillProtocolBase'
    +  namespace_prefix = 'ExecutionNamespace'
    +  suffix = generate_suffix(length: 32, prefix: base_class_prefix)
    +  base_class_name = "#{base_class_prefix}#{suffix}"
    +  base_class = make_base(
    +    name: base_class_name,
    +    debug: debug,
    +    mutex: mutex,
    +    thread_status: thread_status
    +  )
    +  @namespace_name = "#{namespace_prefix}#{suffix}"
    +  namespace = Krill.make_namespace(name: @namespace_name)
    +  namespace.add(code: operation_type.protocol)
    +  namespace::Protocol.include(base_class)
    +  @protocol = namespace::Protocol.new
    +rescue SyntaxError => e
    +  raise KrillSyntaxError.new(operation_type: operation_type, error: e)
    +rescue StandardError, NoMemoryError, ScriptError, SecurityError, SystemExit, SystemStackError => e
    +  raise KrillError.new(job: job, error: e, namespace: @namespace_name)
    +end
    +
    +
    + +
    + +
    +

    Instance Attribute Details

    + + + +
    +

    + + #jobObject (readonly) + + + + + +

    +
    +

    these are here for observability in tests

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +14
    +15
    +16
    +
    +
    # File 'lib/krill/protocol_sandbox.rb', line 14
    +
    +def job
    +  @job
    +end
    +
    +
    + + + +
    +

    + + #protocolObject (readonly) + + + + + +

    +
    +

    these are here for observability in tests

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +14
    +15
    +16
    +
    +
    # File 'lib/krill/protocol_sandbox.rb', line 14
    +
    +def protocol
    +  @protocol
    +end
    +
    +
    + +
    + + +
    +

    Instance Method Details

    + + +
    +

    + + #done?TrueClass, FalseClass + + + + + +

    +
    +

    Indicates whether the job has completed.

    + + +
    +
    +
    + +

    Returns:

    +
      + +
    • + + + (TrueClass, FalseClass) + + + + — +

      true if the job is complete, otherwise false

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +88
    +89
    +90
    +
    +
    # File 'lib/krill/protocol_sandbox.rb', line 88
    +
    +def done?
    +  @job.pc == Job.COMPLETED
    +end
    +
    +
    + +
    +

    + + #executeObject + + + + + +

    +
    +

    Executes protocol.main for the job.

    + +

    Captures the return value, and the following exceptions:

    + +
      +
    • NoMemoryError occurs if allocation exceeds allowed storage (e.g., string larger than max capacity)
    • +
    • ScriptError
    • +
    • SecurityError
    • +
    • StandardError
    • +
    • SystemExit
    • +
    • SystemStackError
    • +
    + + +
    +
    +
    + +

    Raises:

    +
      + +
    • + + + (KrillError) + + + + — +

      if one of the exceptions above is caught

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +62
    +63
    +64
    +65
    +66
    +67
    +68
    +69
    +70
    +71
    +72
    +73
    +74
    +75
    +76
    +77
    +78
    +79
    +80
    +81
    +82
    +83
    +
    +
    # File 'lib/krill/protocol_sandbox.rb', line 62
    +
    +def execute
    +  @job.start
    +  begin
    +    return_value = @protocol.main
    +    @job.reload
    +    @job.append_step(operation: 'complete', rval: return_value)
    +    @job.stop('done')
    +  rescue StandardError, NoMemoryError, ScriptError, SecurityError, SystemExit, SystemStackError => e
    +    puts "#{@job.id}: EXCEPTION #{e}"
    +    puts e.backtrace[0, 10]
    +    @job.reload
    +    @job.stop('error')
    +    @job.append_step(operation: 'error', message: e.to_s, backtrace: e.backtrace[0, 10])
    +    @job.append_step(operation: 'next', time: Time.zone.now, inputs: {})
    +    @job.append_step(operation: 'aborted', rval: {})
    +    raise e if e.is_a?(ProtocolError)
    +
    +    raise KrillError.new(job: @job, error: e, namespace: @namespace_name)
    +  ensure
    +    @job.save
    +  end
    +end
    +
    +
    + +
    + +
    + + + +
    + + \ No newline at end of file diff --git a/docs/api/Krill/ShowBlock.html b/docs/api/Krill/ShowBlock.html index f278728b5..0a0d1f923 100644 --- a/docs/api/Krill/ShowBlock.html +++ b/docs/api/Krill/ShowBlock.html @@ -491,27 +491,27 @@

     
     
    +299
    +300
     301
     302
     303
     304
     305
     306
    -307
    -308
    -309
    +307

    -
    # File 'lib/krill/show_block.rb', line 301
    +      
    # File 'lib/krill/show_block.rb', line 299
     
     def method_missing(m, *args, &block)
    +  raise "Cannot call 'show' within a show block." if m == :show
     
    -  if m == :show
    -    raise "Cannot call 'show' within a show block."
    -  else
    +  if @base.methods.include?(m)
         @base.send(m, *args, &block)
    +  else
    +    super
       end
    -
     end
    @@ -565,12 +565,12 @@

     
     
    -85
    -86
    -87
    +87 +88 +89

    -
    # File 'lib/krill/show_block.rb', line 85
    +      
    # File 'lib/krill/show_block.rb', line 87
     
     def bullet(str)
       @parts.push(bullet: str)
    @@ -621,12 +621,12 @@ 

     
     
    -78
    -79
    -80
    +80 +81 +82

    -
    # File 'lib/krill/show_block.rb', line 78
    +      
    # File 'lib/krill/show_block.rb', line 80
     
     def check(str)
       @parts.push(check: str)
    @@ -775,8 +775,6 @@ 

     
     
    -237
    -238
     239
     240
     241
    @@ -784,10 +782,12 @@ 

    243 244 245 -246

    +246 +247 +248

    -
    # File 'lib/krill/show_block.rb', line 237
    +      
    # File 'lib/krill/show_block.rb', line 239
     
     def get(type, opts = {})
       raise "First argument to get should be either 'number' or 'text'" unless type == 'number' || type == 'text'
    @@ -854,12 +854,12 @@ 

     
     
    -151
    -152
    -153
    +153 +154 +155

    -
    # File 'lib/krill/show_block.rb', line 151
    +      
    # File 'lib/krill/show_block.rb', line 153
     
     def image(name)
       @parts.push(image: "#{Bioturk::Application.config.image_server_interface}#{name}")
    @@ -910,12 +910,12 @@ 

     
     
    -127
    -128
    -129
    +129 +130 +131

    -
    # File 'lib/krill/show_block.rb', line 127
    +      
    # File 'lib/krill/show_block.rb', line 129
     
     def item(i)
       @parts.push(take: i)
    @@ -965,12 +965,12 @@ 

     
     
    -55
    -56
    -57
    +57 +58 +59

    -
    # File 'lib/krill/show_block.rb', line 55
    +      
    # File 'lib/krill/show_block.rb', line 57
     
     def note(str)
       @parts.push(note: str)
    @@ -1100,6 +1100,9 @@ 

     
     
    +279
    +280
    +281
     282
     283
     284
    @@ -1108,14 +1111,13 @@ 

    287 288 289 -290 -291 -292

    +290

    -
    # File 'lib/krill/show_block.rb', line 282
    +      
    # File 'lib/krill/show_block.rb', line 279
     
     def select(choices, opts = {})
    +  choices = choices.uniq
       raise 'First argument to select should be an array of numbers or strings' unless is_proper_array choices
     
       options = {
    @@ -1156,12 +1158,12 @@ 

     
     
    -140
    -141
    -142
    +142 +143 +144

    -
    # File 'lib/krill/show_block.rb', line 140
    +      
    # File 'lib/krill/show_block.rb', line 142
     
     def separator
       @parts.push(separator: true)
    @@ -1240,16 +1242,16 @@ 

     
     
    -115
    -116
     117
     118
     119
     120
    -121
    +121 +122 +123

    -
    # File 'lib/krill/show_block.rb', line 115
    +      
    # File 'lib/krill/show_block.rb', line 117
     
     def table(m)
       if m.class == Table
    @@ -1339,17 +1341,17 @@ 

     
     
    -165
    -166
     167
     168
     169
     170
     171
    -172
    +172 +173 +174

    -
    # File 'lib/krill/show_block.rb', line 165
    +      
    # File 'lib/krill/show_block.rb', line 167
     
     def timer(opts = {})
       options = {
    @@ -1404,12 +1406,12 @@ 

     
     
    -48
    -49
    -50
    +50 +51 +52

    -
    # File 'lib/krill/show_block.rb', line 48
    +      
    # File 'lib/krill/show_block.rb', line 50
     
     def title(str)
       @parts.push(title: str)
    @@ -1495,16 +1497,16 @@ 

     
     
    -183
    -184
     185
     186
     187
     188
    -189
    +189 +190 +191

    -
    # File 'lib/krill/show_block.rb', line 183
    +      
    # File 'lib/krill/show_block.rb', line 185
     
     def upload(opts = {})
       options = {
    @@ -1559,12 +1561,12 @@ 

     
     
    -70
    -71
    -72
    +72 +73 +74

    -
    # File 'lib/krill/show_block.rb', line 70
    +      
    # File 'lib/krill/show_block.rb', line 72
     
     def warning(str)
       @parts.push(warning: str)
    @@ -1579,9 +1581,9 @@ 

    diff --git a/docs/api/Krill/ShowResponse.html b/docs/api/Krill/ShowResponse.html index 9be7e7dbf..7a747f278 100644 --- a/docs/api/Krill/ShowResponse.html +++ b/docs/api/Krill/ShowResponse.html @@ -281,14 +281,14 @@

     
     
    -22
    -23
    -24
    +24 +25 +26

    -
    # File 'lib/krill/show_response.rb', line 22
    +      
    # File 'lib/krill/show_response.rb', line 24
     
    -def get_response var
    +def get_response(var)
       responses[var.to_sym]
     end
    @@ -427,8 +427,6 @@

     
     
    -38
    -39
     40
     41
     42
    @@ -445,20 +443,22 @@ 

    53 54 55 -56

    +56 +57 +58

    -
    # File 'lib/krill/show_response.rb', line 38
    +      
    # File 'lib/krill/show_response.rb', line 40
     
    -def get_table_response var, opts = {}
    -  raise TableCellUndefined, "Invalid parameters for get_table_response - specify one of op or row, not both" if (opts[:op] && opts[:row]) || (!opts[:op] && !opts[:row])
    +def get_table_response(var, opts = {})
    +  raise TableCellUndefined.new('Invalid parameters for get_table_response - specify one of op or row, not both') if (opts[:op] && opts[:row]) || (!opts[:op] && !opts[:row])
       return nil if self[:table_inputs].nil?
     
       target_table = self[:table_inputs].select { |ti| (ti[:key].to_sym == var.to_sym) }
       return nil if target_table.empty?
     
       if opts[:op]
    -    raise TableCellUndefined, "Invalid parameters for get_table_response - an :op option cannot be specified for a table that doesn't have operations corresponding to its rows" if target_table.first[:opid] < 0
    +    raise TableCellUndefined.new("Invalid parameters for get_table_response - an :op option cannot be specified for a table that doesn't have operations corresponding to its rows") if target_table.first[:opid] < 0
     
         opid = Operation.find(opts[:op]).id # return op.id if passed an operation or the id itself
         target_input_cell = target_table.find { |ti| ti[:opid] == opid }
    @@ -467,7 +467,7 @@ 

    end raise TableCellUndefined if target_input_cell.nil? - return (target_input_cell[:type] == 'number' ? target_input_cell[:value].to_f : target_input_cell[:value]) + (target_input_cell[:type] == 'number' ? target_input_cell[:value].to_f : target_input_cell[:value]) end

    @@ -518,8 +518,6 @@

     
     
    -63
    -64
     65
     66
     67
    @@ -534,22 +532,24 @@ 

    76 77 78 -79

    +79 +80 +81

    -
    # File 'lib/krill/show_response.rb', line 63
    +      
    # File 'lib/krill/show_response.rb', line 65
     
     def responses
    -  inline_responses = self.select { |key, value| key != :table_inputs && key != :timestamp && !is_upload?(key) }
    +  inline_responses = select { |key, value| key != :table_inputs && key != :timestamp && !is_upload?(key) }
     
    -  upload_response_keys = self.select { |key, value| is_upload?(key) }.keys
    -  upload_responses = Hash.new
    +  upload_response_keys = select { |key, value| is_upload?(key) }.keys
    +  upload_responses = {}
       upload_response_keys.each do |key|
         upload_responses[key] = get_upload_response(key)
       end
     
       table_response_keys = self[:table_inputs] ? self[:table_inputs].map { |ti| ti[:key] }.uniq : []
    -  table_responses = Hash.new
    +  table_responses = {}
       table_response_keys.each do |key|
         table_responses[key.to_sym] = get_table_responses_column(key)
       end
    @@ -604,12 +604,12 @@ 

     
     
    -85
    -86
    -87
    +87 +88 +89

    -
    # File 'lib/krill/show_response.rb', line 85
    +      
    # File 'lib/krill/show_response.rb', line 87
     
     def timestamp
       self[:timestamp]
    @@ -624,9 +624,9 @@ 

    diff --git a/docs/api/Krill/Table.html b/docs/api/Krill/Table.html index 532071e53..863ecc01d 100644 --- a/docs/api/Krill/Table.html +++ b/docs/api/Krill/Table.html @@ -520,17 +520,17 @@

     
     
    -26
    -27
     28
     29
     30
     31
     32
    -33
    +33 +34 +35

    -
    # File 'lib/krill/table.rb', line 26
    +      
    # File 'lib/krill/table.rb', line 28
     
     def initialize(columns = {})
       @columns = columns
    @@ -589,18 +589,18 @@ 

     
     
    -171
    -172
     173
     174
     175
     176
     177
     178
    -179
    +179 +180 +181

    -
    # File 'lib/krill/table.rb', line 171
    +      
    # File 'lib/krill/table.rb', line 173
     
     def method_missing(m, *args, &block)
     
    @@ -682,19 +682,19 @@ 

     
     
    -130
    -131
     132
     133
     134
     135
     136
    -137
    +137 +138 +139

    -
    # File 'lib/krill/table.rb', line 130
    +      
    # File 'lib/krill/table.rb', line 132
     
    -def add_column name, values
    +def add_column(name, values)
       column(name.to_sym, name)
       values.each_with_index do |v, i|
         @rows[i] ||= {}
    @@ -839,8 +839,6 @@ 

     
     
    -149
    -150
     151
     152
     153
    @@ -852,10 +850,12 @@ 

    159 160 161 -162

    +162 +163 +164

    -
    # File 'lib/krill/table.rb', line 149
    +      
    # File 'lib/krill/table.rb', line 151
     
     def add_response_column(name, defaults, opts = {})
       default_opts = { key: name, type: 'number' }
    @@ -918,13 +918,13 @@ 

     
     
    -81
    -82
     83
    -84
    +84 +85 +86

    -
    # File 'lib/krill/table.rb', line 81
    +      
    # File 'lib/krill/table.rb', line 83
     
     def all
       @choice = @columns.keys
    @@ -977,14 +977,14 @@ 

     
     
    -73
    -74
     75
     76
    -77
    +77 +78 +79

    -
    # File 'lib/krill/table.rb', line 73
    +      
    # File 'lib/krill/table.rb', line 75
     
     def append
       @rows << @selection
    @@ -1057,13 +1057,13 @@ 

     
     
    -89
    -90
     91
    -92
    +92 +93 +94

    -
    # File 'lib/krill/table.rb', line 89
    +      
    # File 'lib/krill/table.rb', line 91
     
     def choose(columns)
       @choice = columns
    @@ -1116,15 +1116,15 @@ 

     
     
    -64
    -65
     66
     67
     68
    -69
    +69 +70 +71

    -
    # File 'lib/krill/table.rb', line 64
    +      
    # File 'lib/krill/table.rb', line 66
     
     def clear
       @selection = {}
    @@ -1213,13 +1213,13 @@ 

     
     
    -40
    -41
     42
    -43
    +43 +44 +45

    -
    # File 'lib/krill/table.rb', line 40
    +      
    # File 'lib/krill/table.rb', line 42
     
     def column(name, heading)
       @columns[name] = heading
    @@ -1291,15 +1291,15 @@ 

     
     
    -97
    -98
     99
     100
     101
    -102
    +102 +103 +104

    -
    # File 'lib/krill/table.rb', line 97
    +      
    # File 'lib/krill/table.rb', line 99
     
     def from(i)
       raise "Table: from(#{i}) is out of range" unless i < @rows.length
    @@ -1349,12 +1349,12 @@ 

     
     
    -49
    -50
    -51
    +51 +52 +53

    -
    # File 'lib/krill/table.rb', line 49
    +      
    # File 'lib/krill/table.rb', line 51
     
     def has_column?(key)
       @columns[key] != nil
    @@ -1401,12 +1401,12 @@ 

     
     
    -45
    -46
    -47
    +47 +48 +49

    -
    # File 'lib/krill/table.rb', line 45
    +      
    # File 'lib/krill/table.rb', line 47
     
     def has_columns?
       !@columns.keys.empty?
    @@ -1458,8 +1458,6 @@ 

     
     
    -114
    -115
     116
     117
     118
    @@ -1468,10 +1466,12 @@ 

    121 122 123 -124

    +124 +125 +126

    -
    # File 'lib/krill/table.rb', line 114
    +      
    # File 'lib/krill/table.rb', line 116
     
     def render
     
    @@ -1548,15 +1548,15 @@ 

     
     
    -57
    -58
     59
    -60
    +60 +61 +62

    -
    # File 'lib/krill/table.rb', line 57
    +      
    # File 'lib/krill/table.rb', line 59
     
    -def set name, value
    +def set(name, value)
       @selection[name] = value
       self
     end
    @@ -1626,13 +1626,13 @@

     
     
    -107
    -108
     109
    -110
    +110 +111 +112

    -
    # File 'lib/krill/table.rb', line 107
    +      
    # File 'lib/krill/table.rb', line 109
     
     def to(i)
       @to = i
    @@ -1648,9 +1648,9 @@ 

    diff --git a/docs/api/Krill/ThreadStatus.html b/docs/api/Krill/ThreadStatus.html new file mode 100644 index 000000000..4b7b856cd --- /dev/null +++ b/docs/api/Krill/ThreadStatus.html @@ -0,0 +1,206 @@ + + + + + + + Class: Krill::ThreadStatus + + — Aquarium Documentation + + + + + + + + + + + + + + + + + + + +
    + + +

    Class: Krill::ThreadStatus + + + +

    +
    + +
    +
    Inherits:
    +
    + Object + +
      +
    • Object
    • + + + +
    + show all + +
    +
    + + + + + + + + + + + +
    +
    Defined in:
    +
    lib/krill/threaded_manager.rb
    +
    + +
    + +
    +
    + + +
    +
    +
    + + +
    + + + +

    Instance Attribute Summary collapse

    + + + + + + +
    +

    Instance Attribute Details

    + + + +
    +

    + + #runningObject + + + + + +

    +
    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +6
    +7
    +8
    +
    +
    # File 'lib/krill/threaded_manager.rb', line 6
    +
    +def running
    +  @running
    +end
    +
    +
    + +
    + + +
    + + + +
    + + \ No newline at end of file diff --git a/docs/api/Krill/ThreadedManager.html b/docs/api/Krill/ThreadedManager.html new file mode 100644 index 000000000..e3ee62bb8 --- /dev/null +++ b/docs/api/Krill/ThreadedManager.html @@ -0,0 +1,1043 @@ + + + + + + + Class: Krill::ThreadedManager + + — Aquarium Documentation + + + + + + + + + + + + + + + + + + + +
    + + +

    Class: Krill::ThreadedManager + + + +

    +
    + +
    +
    Inherits:
    +
    + Object + +
      +
    • Object
    • + + + +
    + show all + +
    +
    + + + + + + + + + + + +
    +
    Defined in:
    +
    lib/krill/threaded_manager.rb
    +
    + +
    + +

    Overview

    +
    +

    Manages threaded execution of a job in technician interface. +Provides methods called by Client via Server.

    + +

    See DebugManager for manager used in test and debug modes.

    + + +
    +
    +
    + + +
    + + + +

    Instance Attribute Summary collapse

    +
      + +
    • + + + #sandbox ⇒ Object + + + + + + + + + readonly + + + + + + + + + +

      accessible for testing.

      +
      + +
    • + + +
    • + + + #thread ⇒ Object + + + + + + + + + readonly + + + + + + + + + +

      accessible for testing.

      +
      + +
    • + + +
    + + + + + +

    + Instance Method Summary + collapse +

    + + + + +
    +

    Constructor Details

    + +
    +

    + + #initialize(job) ⇒ ThreadedManager + + + + + +

    +
    +

    Initializes a Krill::ThreadedManager object with the given job.

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + job + + + (Job) + + + + — +

      the job

      +
      + +
    • + +
    + +

    Raises:

    +
      + +
    • + + + (StandardError) + + + + — +

      if the job has no operations

      +
      + +
    • + +
    • + + + (KrillSyntaxError) + + + + — +

      if the job's protocol has a syntax error

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +22
    +23
    +24
    +25
    +26
    +27
    +28
    +29
    +30
    +
    +
    # File 'lib/krill/threaded_manager.rb', line 22
    +
    +def initialize(job)
    +  raise "Error: job #{job.id} has no operations" if job.operations.empty?
    +
    +  @mutex = Mutex.new
    +  @thread_status = ThreadStatus.new
    +  @thread_status.running = false
    +
    +  @sandbox = ProtocolSandbox.new(job: job, mutex: @mutex, thread_status: @thread_status)
    +end
    +
    +
    + +
    + +
    +

    Instance Attribute Details

    + + + +
    +

    + + #sandboxObject (readonly) + + + + + +

    +
    +

    accessible for testing

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +15
    +16
    +17
    +
    +
    # File 'lib/krill/threaded_manager.rb', line 15
    +
    +def sandbox
    +  @sandbox
    +end
    +
    +
    + + + +
    +

    + + #threadObject (readonly) + + + + + +

    +
    +

    accessible for testing

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +15
    +16
    +17
    +
    +
    # File 'lib/krill/threaded_manager.rb', line 15
    +
    +def thread
    +  @thread
    +end
    +
    +
    + +
    + + +
    +

    Instance Method Details

    + + +
    +

    + + #check_againObject + + + + + +

    +
    +

    Checks status of the job.

    + +

    Method called by client via server.

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +89
    +90
    +91
    +92
    +93
    +94
    +95
    +
    +
    # File 'lib/krill/threaded_manager.rb', line 89
    +
    +def check_again
    +  if @thread.alive?
    +    wait 20
    +  else
    +    'done'
    +  end
    +end
    +
    +
    + +
    +

    + + #continueObject + + + + + +

    +
    +

    Continues the job.

    + +

    Method called by client via server.

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +100
    +101
    +102
    +103
    +104
    +105
    +106
    +107
    +108
    +109
    +110
    +111
    +112
    +
    +
    # File 'lib/krill/threaded_manager.rb', line 100
    +
    +def continue
    +  if @thread.alive?
    +    @mutex.synchronize do
    +      unless @thread_status.running
    +        @thread_status.running = true
    +        @thread.wakeup
    +      end
    +    end
    +    wait 20
    +  else
    +    'done'
    +  end
    +end
    +
    +
    + +
    +

    + + #notify(job) ⇒ Object + + + + + +

    +
    +

    Associate a crash message to each operation of the given job.

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + job + + + (Job) + + + + — +

      the job

      +
      + +
    • + +
    + + +
    + + + + +
    +
    +
    +
    +132
    +133
    +134
    +135
    +136
    +137
    +138
    +139
    +140
    +
    +
    # File 'lib/krill/threaded_manager.rb', line 132
    +
    +def notify(job)
    +  job.operations.each do |operation|
    +    puts("notifying #{operation.id}")
    +    operation.associate(
    +      :job_crash,
    +      "Operation canceled when job #{job.id} crashed"
    +    )
    +  end
    +end
    +
    +
    + +
    +

    + + #startObject + + + + + +

    +
    +

    Starts the thread and waits for 20 seconds if needed.

    + +

    Method called by client via server.

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +57
    +58
    +59
    +60
    +61
    +
    +
    # File 'lib/krill/threaded_manager.rb', line 57
    +
    +def start
    +  start_thread
    +  wait(20) # This so that you wait until either the step is done or 20 seconds is up.
    +  # It doesn't have to wait the whole 20 seconds if the step finishes quickly.
    +end
    +
    +
    + +
    +

    + + #start_threadObject + + + + + +

    +
    +

    Starts the thread for running this job.

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +37
    +38
    +39
    +40
    +41
    +42
    +43
    +44
    +45
    +46
    +47
    +48
    +49
    +50
    +51
    +52
    +
    +
    # File 'lib/krill/threaded_manager.rb', line 37
    +
    +def start_thread
    +  @thread_status.running = true
    +  @thread = Thread.new do
    +    @sandbox.execute
    +  rescue KrillError, KrillSyntaxError, ProtocolError => e
    +    notify(@sandbox.job)
    +    raise e
    +  ensure
    +    @mutex.synchronize { @thread_status.running = false }
    +
    +    if ActiveRecord::Base.connection && ActiveRecord::Base.connection.active?
    +      ActiveRecord::Base.connection.close
    +      puts "#{@sandbox.job.id}: Closing ActiveRecord connection"
    +    end
    +  end
    +end
    +
    +
    + +
    +

    + + #stopObject + + + + + +

    +
    +

    Stops (aborts) this job.

    + +

    Method called by client via server.

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +117
    +118
    +119
    +120
    +121
    +122
    +123
    +
    +
    # File 'lib/krill/threaded_manager.rb', line 117
    +
    +def stop
    +  # TODO: can this be elsewhere?
    +  puts "Stopping job #{@sandbox.job.id}"
    +
    +  @thread.kill
    +  @mutex.synchronize { @thread_status.running = false }
    +end
    +
    +
    + +
    +

    + + #wait(secs) ⇒ String + + + + + +

    +
    +

    Waits for the number of seconds while the thread is still running.

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + secs + + + (Integer) + + + + — +

      the number of seconds to wait

      +
      + +
    • + +
    + +

    Returns:

    +
      + +
    • + + + (String) + + + + — +

      'done' if execution is complete,

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +67
    +68
    +69
    +70
    +71
    +72
    +73
    +74
    +75
    +76
    +77
    +78
    +79
    +80
    +81
    +82
    +83
    +84
    +
    +
    # File 'lib/krill/threaded_manager.rb', line 67
    +
    +def wait(secs)
    +  n = 0
    +  running = true
    +  @mutex.synchronize { running = @thread_status.running }
    +
    +  while running
    +    return 'not_ready' unless n < 10 * secs # wait two seconds
    +
    +    n += 1
    +    sleep(0.1)
    +    @mutex.synchronize { running = @thread_status.running }
    +  end
    +
    +  @sandbox.reload
    +  return 'done' if @sandbox.done?
    +
    +  'ready'
    +end
    +
    +
    + +
    + +
    + + + +
    + + \ No newline at end of file diff --git a/docs/api/Locator.html b/docs/api/Locator.html index 26107ace4..477a7a764 100644 --- a/docs/api/Locator.html +++ b/docs/api/Locator.html @@ -366,8 +366,6 @@

     
     
    -36
    -37
     38
     39
     40
    @@ -378,22 +376,24 @@ 

    45 46 47 -48

    +48 +49 +50

    -
    # File 'app/models/locator.rb', line 36
    +      
    # File 'app/models/locator.rb', line 38
     
     def self.first_empty(wizard)
    -  if wizard
    -    locs = where(wizard_id: wizard.id, item_id: nil)
    -    if !locs.empty?
    -      locs.first
    -    else
    -      m = Locator.largest wizard
    -      loc = Locator.new(wizard_id: wizard.id, number: m ? m.number + 1 : 0)
    -      loc.save
    -      loc
    -    end
    +  return unless wizard
    +
    +  locs = where(wizard_id: wizard.id, item_id: nil)
    +  if !locs.empty?
    +    locs.first
    +  else
    +    m = Locator.largest wizard
    +    loc = Locator.new(wizard_id: wizard.id, number: m ? m.number + 1 : 0)
    +    loc.save
    +    loc
       end
     end
    @@ -425,17 +425,17 @@

     
     
    -54
    -55
     56
    -57
    +57 +58 +59

    -
    # File 'app/models/locator.rb', line 54
    +      
    # File 'app/models/locator.rb', line 56
     
     def self.largest(wizard)
       # find greatest locator for this wizard, should always be the most recent
    -  wizard.locators.order("id desc").first
    +  wizard.locators.order('id desc').first
     end
    @@ -466,8 +466,6 @@

     
     
    -59
    -60
     61
     62
     63
    @@ -504,10 +502,12 @@ 

    94 95 96 -97

    +97 +98 +99

    -
    # File 'app/models/locator.rb', line 59
    +      
    # File 'app/models/locator.rb', line 61
     
     def self.port(wizard)
     
    @@ -532,7 +532,7 @@ 

    items.each do |i| n = wizard.location_to_int(i.primitive_location) - l = Locator.where(wizard_id: wizard.id, number: n).first + l = Locator.find_by(wizard_id: wizard.id, number: n) if l.item_id collisions.push([l.item_id, i.id]) @@ -577,24 +577,24 @@

     
     
    -99
    -100
     101
     102
     103
     104
     105
    -106
    +106 +107 +108

    -
    # File 'app/models/locator.rb', line 99
    +      
    # File 'app/models/locator.rb', line 101
     
     def self.port_all
     
    -  port Wizard.find_by_name('M20')
    -  port Wizard.find_by_name('M80')
    -  port Wizard.find_by_name('SF2')
    -  port Wizard.find_by_name('DFP')
    +  port Wizard.find_by(name: 'M20')
    +  port Wizard.find_by(name: 'M80')
    +  port Wizard.find_by(name: 'SF2')
    +  port Wizard.find_by(name: 'DFP')
     
     end
    @@ -632,8 +632,6 @@

     
     
    -108
    -109
     110
     111
     112
    @@ -642,10 +640,12 @@ 

    115 116 117 -118

    +118 +119 +120

    -
    # File 'app/models/locator.rb', line 108
    +      
    # File 'app/models/locator.rb', line 110
     
     def clear
       r1 = false
    @@ -700,12 +700,12 @@ 

     
     
    -50
    -51
    -52
    +52 +53 +54

    -
    # File 'app/models/locator.rb', line 50
    +      
    # File 'app/models/locator.rb', line 52
     
     def empty?
       item_id.nil?
    @@ -739,13 +739,13 @@ 

     
     
    -13
    -14
     15
    -16
    +16 +17 +18

    -
    # File 'app/models/locator.rb', line 13
    +      
    # File 'app/models/locator.rb', line 15
     
     def has_wizard
       errors.add(:no_wizard, 'no wizard') unless
    @@ -780,18 +780,18 @@ 

     
     
    -18
    -19
     20
     21
     22
     23
     24
     25
    -26
    +26 +27 +28

    -
    # File 'app/models/locator.rb', line 18
    +      
    # File 'app/models/locator.rb', line 20
     
     def no_collisions
       puts "Checking for collisions for #{id}"
    @@ -831,16 +831,16 @@ 

     
     
    -28
    -29
     30
     31
     32
     33
    -34
    +34 +35 +36

    -
    # File 'app/models/locator.rb', line 28
    +      
    # File 'app/models/locator.rb', line 30
     
     def to_s
       if wizard
    @@ -859,9 +859,9 @@ 

    diff --git a/docs/api/ObjectType.html b/docs/api/ObjectType.html index 13df92c19..77849abb0 100644 --- a/docs/api/ObjectType.html +++ b/docs/api/ObjectType.html @@ -613,24 +613,24 @@

    -
    # File 'app/models/object_type.rb', line 205
    +      
    # File 'app/models/object_type.rb', line 202
     
     def self.clean_up_sample_type_links(raw_object_types)
       raw_object_types.each do |rot|
    -    ot = ObjectType.find_by_name rot[:name]
    -    st = SampleType.find_by_name rot[:sample_type_name]
    +    ot = ObjectType.find_by name: rot[:name]
    +    st = SampleType.find_by name: rot[:sample_type_name]
         if st && ot
           ot.sample_type_id = st.id
           ot.save
    @@ -666,6 +666,8 @@ 

     
     
    +158
    +159
     160
     161
     162
    @@ -706,13 +708,10 @@ 

    197 198 199 -200 -201 -202 -203

    +200

    -
    # File 'app/models/object_type.rb', line 160
    +      
    # File 'app/models/object_type.rb', line 158
     
     def self.compare_and_upgrade(raw_ots)
     
    @@ -724,8 +723,7 @@ 

    raw_ots.each do |raw_ot| - ot = ObjectType.find_by_name raw_ot[:name] - i = [] + ot = ObjectType.find_by name: raw_ot[:name] if ot parts.each do |part| @@ -793,19 +791,19 @@

     
     
    -45
    -46
     47
     48
    -49
    +49 +50 +51

    -
    # File 'app/models/object_type.rb', line 45
    +      
    # File 'app/models/object_type.rb', line 47
     
     def columns
    -  if handler == 'collection'
    -    read_attribute(:columns) ? read_attribute(:columns) : 12
    -  end
    +  return unless handler == 'collection'
    +
    +  self[:columns] || 12
     end
    @@ -836,15 +834,15 @@

     
     
    -55
    -56
    -57
    +57 +58 +59

    -
    # File 'app/models/object_type.rb', line 55
    +      
    # File 'app/models/object_type.rb', line 57
     
     def columns=(value)
    -  write_attribute :columns, value
    +  self[:columns] = value
     end
    @@ -875,22 +873,22 @@

     
     
    +145
    +146
     147
     148
     149
     150
     151
    -152
    -153
    -154
    +152

    -
    # File 'app/models/object_type.rb', line 147
    +      
    # File 'app/models/object_type.rb', line 145
     
     def data_object
       begin
         result = JSON.parse(data, symbolize_names: true)
    -  rescue Exception => e
    +  rescue StandardError
         result = {}
       end
       result
    @@ -925,8 +923,6 @@ 

     
     
    -122
    -123
     124
     125
     126
    @@ -942,32 +938,26 @@ 

    136 137 138 -139 -140 -141

    +139

    -
    # File 'app/models/object_type.rb', line 122
    +      
    # File 'app/models/object_type.rb', line 124
     
     def default_dimensions # for collections
    -
    -  if handler == 'collection'
    -    begin
    -      h = JSON.parse(data, symbolize_names: true)
    -    rescue JSON::ParseError
    -      raise "Could not parse data field '#{data}' of object type #{id}. Please go to " \
    -            "<a href='/object_types/#{id}/edit'>Object Type #{id}</a> and edit the data " \
    -            'field so that it reads something like { "rows": 10, "columns": 10 }'
    -    end
    -    if h[:rows] && h[:columns]
    -      [h[:rows], h[:columns]]
    -    else
    -      [1, 1]
    -    end
    +  raise 'Tried to get dimensions of a container that is not a collection' unless handler == 'collection'
    +
    +  begin
    +    h = JSON.parse(data, symbolize_names: true)
    +  rescue JSON::ParserError
    +    raise "Could not parse data field '#{data}' of object type #{id}. Please go to " \
    +          "<a href='/object_types/#{id}/edit'>Object Type #{id}</a> and edit the data " \
    +          'field so that it reads something like { "rows": 10, "columns": 10 }'
    +  end
    +  if h[:rows] && h[:columns]
    +    [h[:rows], h[:columns]]
       else
    -    raise 'Tried to get dimensions of a container that is not a collection'
    +    [1, 1]
       end
    -
     end
    @@ -998,12 +988,12 @@

     
     
    -118
    -119
    -120
    +120 +121 +122

    -
    # File 'app/models/object_type.rb', line 118
    +      
    # File 'app/models/object_type.rb', line 120
     
     def export
       attributes
    @@ -1057,10 +1047,10 @@ 

     
     
    -19
    +21

    -
    # File 'app/models/object_type.rb', line 19
    +      
    # File 'app/models/object_type.rb', line 21
     
     attr_accessible :handler
    @@ -1092,16 +1082,16 @@

     
     
    -87
    -88
     89
     90
     91
     92
    -93
    +93 +94 +95

    -
    # File 'app/models/object_type.rb', line 87
    +      
    # File 'app/models/object_type.rb', line 89
     
     def in_use
       q = 0
    @@ -1139,13 +1129,13 @@ 

     
     
    -59
    -60
     61
    -62
    +62 +63 +64

    -
    # File 'app/models/object_type.rb', line 59
    +      
    # File 'app/models/object_type.rb', line 61
     
     def min_and_max
       errors.add(:min, 'min must be greater than zero and less than or equal to max') unless
    @@ -1198,10 +1188,10 @@ 

     
     
    -12
    +14

    -
    # File 'app/models/object_type.rb', line 12
    +      
    # File 'app/models/object_type.rb', line 14
     
     attr_accessible :name
    @@ -1233,13 +1223,13 @@

     
     
    -64
    -65
     66
    -67
    +67 +68 +69

    -
    # File 'app/models/object_type.rb', line 64
    +      
    # File 'app/models/object_type.rb', line 66
     
     def pos
       errors.add(:cost, 'must be at least $0.01') unless
    @@ -1274,15 +1264,15 @@ 

     
     
    -69
    -70
     71
     72
     73
    -74
    +74 +75 +76

    -
    # File 'app/models/object_type.rb', line 69
    +      
    # File 'app/models/object_type.rb', line 71
     
     def proper_release_method
       errors.add(:release_method, 'must be either return, dispose, or query') unless
    @@ -1319,16 +1309,16 @@ 

     
     
    -79
    -80
     81
     82
     83
     84
    -85
    +85 +86 +87

    -
    # File 'app/models/object_type.rb', line 79
    +      
    # File 'app/models/object_type.rb', line 81
     
     def quantity
       q = 0
    @@ -1366,19 +1356,19 @@ 

     
     
    -39
    -40
     41
     42
    -43
    +43 +44 +45

    -
    # File 'app/models/object_type.rb', line 39
    +      
    # File 'app/models/object_type.rb', line 41
     
     def rows
    -  if handler == 'collection'
    -    read_attribute(:rows) ? read_attribute(:rows) : 1
    -  end
    +  return unless handler == 'collection'
    +
    +  self[:rows] || 1
     end
    @@ -1409,15 +1399,15 @@

     
     
    -51
    -52
    -53
    +53 +54 +55

    -
    # File 'app/models/object_type.rb', line 51
    +      
    # File 'app/models/object_type.rb', line 53
     
     def rows=(value)
    -  write_attribute :rows, value
    +  self[:rows] = value
     end
    @@ -1467,10 +1457,10 @@

     
     
    -25
    +27

    -
    # File 'app/models/object_type.rb', line 25
    +      
    # File 'app/models/object_type.rb', line 27
     
     belongs_to :sample_type
    @@ -1502,12 +1492,12 @@

     
     
    -156
    -157
    -158
    +154 +155 +156

    -
    # File 'app/models/object_type.rb', line 156
    +      
    # File 'app/models/object_type.rb', line 154
     
     def sample_type_name
       sample_type ? sample_type.name : nil
    @@ -1541,8 +1531,6 @@ 

     
     
    -95
    -96
     97
     98
     99
    @@ -1562,10 +1550,12 @@ 

    113 114 115 -116

    +116 +117 +118

    -
    # File 'app/models/object_type.rb', line 95
    +      
    # File 'app/models/object_type.rb', line 97
     
     def save_as_test_type(name)
     
    @@ -1618,12 +1608,12 @@ 

     
     
    -143
    -144
    -145
    +141 +142 +143

    -
    # File 'app/models/object_type.rb', line 143
    +      
    # File 'app/models/object_type.rb', line 141
     
     def to_s
       "<a href='/object_types/#{id}' class='aquarium-item' id='#{id}'>#{id}</a>"
    @@ -1638,9 +1628,9 @@ 

    diff --git a/docs/api/Operation.html b/docs/api/Operation.html index a70841fe6..227f33032 100644 --- a/docs/api/Operation.html +++ b/docs/api/Operation.html @@ -225,28 +225,6 @@

    -
    - - - - -
  • - - - #child_data(child_name, child_role, data_name) ⇒ Object - - - - - - - - - - - - -
  • @@ -269,7 +247,8 @@

    -
    +

    TODO: this belongs elsewhere.

    +
    @@ -678,7 +657,7 @@

  • - #output_data(input_name, data_name) ⇒ Object + #output_data(output_name, data_name) ⇒ Object @@ -871,28 +850,6 @@

    -
    - -

  • - - -
  • - - - #set_child_data(child_name, child_role, data_name, value) ⇒ Object - - - - - - - - - - - - -
  • @@ -969,7 +926,7 @@

  • - #set_output_data(input_name, data_name, value) ⇒ Object + #set_output_data(output_name, data_name, value) ⇒ Object @@ -1123,7 +1080,7 @@

  • - #with_input(name, sample) ⇒ Object + #with_input(name, sample) ⇒ Operation @@ -1242,15 +1199,15 @@

     
     
    -333
    -334
    -335
     336
     337
    -338
    +338 +339 +340 +341

  • -
    # File 'app/models/operation.rb', line 333
    +      
    # File 'app/models/operation.rb', line 336
     
     def self.step(ops = nil)
       ops ||= Operation.includes(:operation_type)
    @@ -1293,18 +1250,18 @@ 

     
     
    -313
    -314
    -315
     316
     317
     318
     319
     320
    -321
    +321 +322 +323 +324

    -
    # File 'app/models/operation.rb', line 313
    +      
    # File 'app/models/operation.rb', line 316
     
     def activate
       set_status 'planning'
    @@ -1403,6 +1360,7 @@ 

     
     
    +126
     127
     128
     129
    @@ -1410,11 +1368,10 @@ 

    131 132 133 -134 -135

    +134

    -
    # File 'app/models/operation.rb', line 127
    +      
    # File 'app/models/operation.rb', line 126
     
     def add_input(name, sample, container)
       items = Item.where(sample_id: sample.id, object_type_id: container.id).reject(&:deleted?)
    @@ -1454,7 +1411,6 @@ 

     
     
    -405
     406
     407
     408
    @@ -1481,20 +1437,21 @@ 

    429 430 431 -432

    +432 +433

    -
    # File 'app/models/operation.rb', line 405
    +      
    # File 'app/models/operation.rb', line 406
     
     def add_successor(opts)
    -  ot = OperationType.find_by_name(opts[:type])
    +  ot = OperationType.find_by(name: opts[:type])
     
       op = ot.operations.create(
         status: 'waiting',
         user_id: user_id
       )
     
    -  plan.plan_associations.create operation_id: op.id
    +  plan.plan_associations.create(operation_id: op.id)
     
       opts[:routing].each do |r|
         ot.field_types.select { |ft| ft.routing == r[:symbol] }.each do |ft|
    @@ -1517,49 +1474,6 @@ 

    - - -
    -

    - - #child_data(child_name, child_role, data_name) ⇒ Object - - - - - -

    -
    - - -
    -
    -
    - - -
    - - - - -
    -
    -
    -
    -362
    -363
    -364
    -365
    -366
    -
    -
    # File 'app/models/operation.rb', line 362
    -
    -def child_data(child_name, child_role, data_name)
    -  fv = get_input(child_name) if child_role == 'input'
    -  fv = get_output(child_name) if child_role == 'output'
    -  fv ? fv.child_data(data_name) : nil
    -end
    -
    @@ -1573,7 +1487,8 @@

    - +

    TODO: this belongs elsewhere

    +
    @@ -1690,16 +1605,16 @@

     
     
    +136
     137
     138
     139
     140
     141
    -142
    -143
    +142

    -
    # File 'app/models/operation.rb', line 137
    +      
    # File 'app/models/operation.rb', line 136
     
     def create_input(name:, item:, sample:)
       field_type = create_field_type(name)
    @@ -1737,18 +1652,18 @@ 

     
     
    -323
    -324
    -325
     326
     327
     328
     329
     330
    -331
    +331 +332 +333 +334

    -
    # File 'app/models/operation.rb', line 323
    +      
    # File 'app/models/operation.rb', line 326
     
     def deactivate
       set_status 'unplanned'
    @@ -1788,8 +1703,6 @@ 

     
     
    -24
    -25
     26
     27
     28
    @@ -1799,16 +1712,18 @@ 

    32 33 34 -35

    +35 +36 +37

    -
    # File 'app/models/operation.rb', line 24
    +      
    # File 'app/models/operation.rb', line 26
     
     def destroy_field_values
       msg = "Cannot destroy operation #{id} because it has jobs associated with it"
       raise msg unless JobAssociation.where(operation_id: id).empty?
     
    -  fvs = FieldValue.where(parent_class: "Operation", parent_id: id)
    +  fvs = FieldValue.where(parent_class: 'Operation', parent_id: id)
       fvs.each do |fv|
         Wire.where("from_id = #{fv.id} OR to_id = #{fv.id}").each do |wire|
           wire.destroy
    @@ -1845,16 +1760,16 @@ 

     
     
    -249
    -250
    -251
     252
     253
     254
    -255
    +255 +256 +257 +258

    -
    # File 'app/models/operation.rb', line 249
    +      
    # File 'app/models/operation.rb', line 252
     
     def find(name)
       ops = []
    @@ -1933,12 +1848,12 @@ 

     
     
    -214
    -215
    -216
    +217 +218 +219

    -
    # File 'app/models/operation.rb', line 214
    +      
    # File 'app/models/operation.rb', line 217
     
     def get_field_value(name, role = 'input')
       field_values.find { |fv| fv.name == name && fv.role == role }
    @@ -2067,12 +1982,12 @@ 

     
     
    -183
     184
    -185
    +185 +186

    -
    # File 'app/models/operation.rb', line 183
    +      
    # File 'app/models/operation.rb', line 184
     
     def get_output(name)
       outputs.find { |o| o.name == name }
    @@ -2134,15 +2049,15 @@ 

     
     
    -188
    -189
    -190
    +190 +191 +192

    -
    # File 'app/models/operation.rb', line 188
    +      
    # File 'app/models/operation.rb', line 190
     
     def input(name)
    -  get_input name
    +  get_input(name)
     end
    @@ -2202,12 +2117,12 @@

     
     
    -200
    -201
    -202
    +203 +204 +205

    -
    # File 'app/models/operation.rb', line 200
    +      
    # File 'app/models/operation.rb', line 203
     
     def input_array(name)
       inputs.select { |i| i.name == name }.extend(IOList)
    @@ -2241,15 +2156,17 @@ 

     
     
    -368
    -369
    -370
    +364 +365 +366 +367

    -
    # File 'app/models/operation.rb', line 368
    +      
    # File 'app/models/operation.rb', line 364
     
     def input_data(input_name, data_name)
    -  child_data(input_name, 'input', data_name)
    +  fv = input(input_name)
    +  fv.child_data(data_name) if fv
     end
    @@ -2346,7 +2263,6 @@

     
     
    -437
     438
     439
     440
    @@ -2360,33 +2276,24 @@ 

    448 449 450 -451 -452 -453 -454 -455

    +451

    -
    # File 'app/models/operation.rb', line 437
    +      
    # File 'app/models/operation.rb', line 438
     
     def leaf?
     
       inputs.each do |i|
    -
         next unless i.predecessors.count > 0
     
         i.predecessors.each do |pred|
    -      if pred.operation.on_the_fly
    -        return pred.operation.leaf?
    -      else
    -        return false
    -      end
    -    end
    +      return pred.operation.leaf? if pred.operation.on_the_fly
     
    +      return false
    +    end
       end
     
       true
    -
     end
    @@ -2435,16 +2342,12 @@

     
     
    -46
    -47
     48
    -
    # File 'app/models/operation.rb', line 46
    +      
    # File 'app/models/operation.rb', line 48
     
    -def name
    -  operation_type.name
    -end
    +delegate :name, to: :operation_type
    @@ -2474,9 +2377,6 @@

     
     
    -340
    -341
    -342
     343
     344
     345
    @@ -2494,16 +2394,18 @@ 

    357 358 359 -360

    +360 +361 +362

    -
    # File 'app/models/operation.rb', line 340
    +      
    # File 'app/models/operation.rb', line 343
     
     def nominal_cost
       begin
    -    eval(operation_type.cost_model.content)
    -  rescue SyntaxError, StandardError => e
    -    raise 'Could not evaluate cost function definition: ' + e.to_s
    +    operation_type.cost_model.load(binding: empty_binding)
    +  rescue ScriptError, StandardError => e
    +    raise "Error loading cost function for #{operation_type.name}: " + e.to_s
       end
     
       temp = status
    @@ -2511,14 +2413,13 @@ 

    begin c = cost(self) - rescue SystemStackError, SyntaxError, StandardError => e + rescue SystemStackError, ScriptError, StandardError => e self.status = temp - raise 'Could not evaluate cost function on the given operation: ' + e.to_s + raise "Error evaluating cost function for #{operation_type.name}: " + e.to_s end self.status = temp c - end

    @@ -2567,16 +2468,12 @@

     
     
    -51
    -52
    -53
    +51

    # File 'app/models/operation.rb', line 51
     
    -def on_the_fly
    -  operation_type.on_the_fly
    -end
    +delegate :on_the_fly, to: :operation_type
    @@ -2634,12 +2531,12 @@

     
     
    -193
    -194
    -195
    +196 +197 +198

    -
    # File 'app/models/operation.rb', line 193
    +      
    # File 'app/models/operation.rb', line 196
     
     def output(name)
       get_output name
    @@ -2702,12 +2599,12 @@ 

     
     
    -207
    -208
    -209
    +210 +211 +212

    -
    # File 'app/models/operation.rb', line 207
    +      
    # File 'app/models/operation.rb', line 210
     
     def output_array(name)
       outputs.select { |o| o.name == name } .extend(IOList)
    @@ -2720,7 +2617,7 @@ 

    - #output_data(input_name, data_name) ⇒ Object + #output_data(output_name, data_name) ⇒ Object @@ -2741,15 +2638,17 @@

     
     
    -372
    -373
    -374
    +369 +370 +371 +372

    -
    # File 'app/models/operation.rb', line 372
    +      
    # File 'app/models/operation.rb', line 369
     
    -def output_data(input_name, data_name)
    -  child_data(input_name, 'output', data_name)
    +def output_data(output_name, data_name)
    +  fv = output(output_name)
    +  fv.child_data(data_name) if fv
     end
    @@ -2833,12 +2732,12 @@

     
     
    -37
    -38
    -39
    +39 +40 +41

    -
    # File 'app/models/operation.rb', line 37
    +      
    # File 'app/models/operation.rb', line 39
     
     def parent_type # interface with FieldValuer
       operation_type
    @@ -2914,9 +2813,6 @@ 

     
     
    -222
    -223
    -224
     225
     226
     227
    @@ -2930,10 +2826,13 @@ 

    235 236 237 -238

    +238 +239 +240 +241

    -
    # File 'app/models/operation.rb', line 222
    +      
    # File 'app/models/operation.rb', line 225
     
     def pass(input_name, output_name = nil)
     
    @@ -2999,12 +2898,12 @@ 

     
     
    -56
    -57
    -58
    +54 +55 +56

    -
    # File 'app/models/operation.rb', line 56
    +      
    # File 'app/models/operation.rb', line 54
     
     def plan
       plans[0] unless plans.empty?
    @@ -3038,6 +2937,12 @@ 

     
     
    +384
    +385
    +386
    +387
    +388
    +389
     390
     391
     392
    @@ -3051,24 +2956,32 @@ 

    400 401 402 -403

    +403 +404

    -
    # File 'app/models/operation.rb', line 390
    +      
    # File 'app/models/operation.rb', line 384
     
     def precondition_value
    -  rval = true
    +  result = true
     
       begin
    -    eval(operation_type.precondition.content)
    -    rval = precondition(self)
    -  rescue Exception => e
    -    Rails.logger.info "PRECONDITION FOR OPERATION #{id} crashed"
    +    operation_type.precondition.load(binding: empty_binding)
    +  rescue ScriptError, StandardError => e
    +    # Raise "Error loading precondition for #{operation_type.name}: " + e.to_s
    +    Rails.logger.info "Error loading precondition for #{operation_type.name} (id: #{id})"
    +    plan.associate 'Precondition load error', e.message.to_s + ': ' + e.backtrace[0].to_s.sub('(eval)', 'line')
    +  end
    +
    +  begin
    +    result = precondition(self)
    +  rescue SystemStackError, ScriptError, StandardError => e
    +    Rails.logger.info "PRECONDITION FOR OPERATION #{id} CRASHED"
         plan.associate 'Precondition Evaluation Error', e.message.to_s + ': ' + e.backtrace[0].to_s.sub('(eval)', 'line')
    -    rval = false # default if there is no precondition or it crashes
    +    result = false # default if there is no precondition or it crashes
       end
     
    -  rval
    +  result
     end
    @@ -3099,25 +3012,25 @@

     
     
    -281
    -282
    -283
     284
     285
     286
     287
     288
     289
    -290
    +290 +291 +292 +293

    -
    # File 'app/models/operation.rb', line 281
    +      
    # File 'app/models/operation.rb', line 284
     
     def predecessors
       predecessor_list = []
       inputs.each do |input|
    -    input.predecessors.each do |pred|
    -      predecessor_list << pred.operation
    +    input.predecessors.each do |predecessor|
    +      predecessor_list << predecessor.operation
         end
       end
     
    @@ -3152,25 +3065,25 @@ 

     
     
    -292
    -293
    -294
     295
     296
     297
     298
     299
     300
    -301
    +301 +302 +303 +304

    -
    # File 'app/models/operation.rb', line 292
    +      
    # File 'app/models/operation.rb', line 295
     
     def primed_predecessors
       ops = []
       inputs.each do |input|
    -    input.predecessors.each do |pred|
    -      ops << pred.operation if pred.operation && pred.operation.status == 'primed'
    +    input.predecessors.each do |predecessor|
    +      ops << predecessor.operation if predecessor.operation && predecessor.operation.status == 'primed'
         end
       end
     
    @@ -3205,72 +3118,29 @@ 

     
     
    -240
    -241
    -242
     243
     244
     245
     246
    -247
    +247 +248 +249 +250

    -
    # File 'app/models/operation.rb', line 240
    +      
    # File 'app/models/operation.rb', line 243
     
     def recurse(&block)
       block.call(self)
       inputs.each do |input|
    -    input.predecessors.each do |pred|
    -      pred.operation.recurse(&block)
    +    input.predecessors.each do |predecessor|
    +      predecessor.operation.recurse(&block)
         end
       end
     end
    - - -
    -

    - - #set_child_data(child_name, child_role, data_name, value) ⇒ Object - - - - - -

    -
    - - -
    -
    -
    - - -
    - - - - -
    -
    -
    -
    -376
    -377
    -378
    -379
    -380
    -
    -
    # File 'app/models/operation.rb', line 376
    -
    -def set_child_data(child_name, child_role, data_name, value)
    -  fv = get_input(child_name) if child_role == 'input'
    -  fv = get_output(child_name) if child_role == 'output'
    -  fv ? fv.set_child_data(data_name, value) : nil
    -end
    -
    @@ -3309,7 +3179,7 @@

    val - (Sample) + (Sample, Item, Number) @@ -3337,12 +3207,12 @@

     
     
    +98
     99
    -100
    -101
    +100

    -
    # File 'app/models/operation.rb', line 99
    +      
    # File 'app/models/operation.rb', line 98
     
     def set_input(name, val, aft = nil)
       set_property(name, val, 'input', false, aft)
    @@ -3376,15 +3246,17 @@ 

     
     
    -382
    -383
    -384
    +374 +375 +376 +377

    -
    # File 'app/models/operation.rb', line 382
    +      
    # File 'app/models/operation.rb', line 374
     
     def set_input_data(input_name, data_name, value)
    -  set_child_data(input_name, 'input', data_name, value)
    +  fv = input(input_name)
    +  fv.set_child_data(data_name, value) if fv
     end
    @@ -3455,12 +3327,12 @@

     
     
    +106
     107
    -108
    -109
    +108

    -
    # File 'app/models/operation.rb', line 107
    +      
    # File 'app/models/operation.rb', line 106
     
     def set_output(name, val, aft = nil)
       set_property(name, val, 'output', false, aft)
    @@ -3473,7 +3345,7 @@ 

    - #set_output_data(input_name, data_name, value) ⇒ Object + #set_output_data(output_name, data_name, value) ⇒ Object @@ -3494,15 +3366,17 @@

     
     
    -386
    -387
    -388
    +379 +380 +381 +382

    -
    # File 'app/models/operation.rb', line 386
    +      
    # File 'app/models/operation.rb', line 379
     
    -def set_output_data(input_name, data_name, value)
    -  set_child_data(input_name, 'output', data_name, value)
    +def set_output_data(output_name, data_name, value)
    +  fv = output(output_name)
    +  fv.set_child_data(data_name, value) if fv
     end
    @@ -3533,15 +3407,15 @@

     
     
    -257
    -258
    -259
     260
     261
    -262
    +262 +263 +264 +265

    -
    # File 'app/models/operation.rb', line 257
    +      
    # File 'app/models/operation.rb', line 260
     
     def set_status_recursively(str)
       recurse do |op|
    @@ -3578,18 +3452,18 @@ 

     
     
    -303
    -304
    -305
     306
     307
     308
     309
     310
    -311
    +311 +312 +313 +314

    -
    # File 'app/models/operation.rb', line 303
    +      
    # File 'app/models/operation.rb', line 306
     
     def siblings
       ops = outputs.collect do |output|
    @@ -3629,19 +3503,19 @@ 

     
     
    -270
    -271
    -272
     273
     274
     275
     276
     277
     278
    -279
    +279 +280 +281 +282

    -
    # File 'app/models/operation.rb', line 270
    +      
    # File 'app/models/operation.rb', line 273
     
     def successors
       successor_list = []
    @@ -3682,13 +3556,13 @@ 

     
     
    -457
    -458
    -459
    -460
    +453 +454 +455 +456

    -
    # File 'app/models/operation.rb', line 457
    +      
    # File 'app/models/operation.rb', line 453
     
     def temporary
       @temporary ||= {}
    @@ -3723,14 +3597,14 @@ 

     
     
    -264
    -265
    -266
     267
    -268
    +268 +269 +270 +271

    -
    # File 'app/models/operation.rb', line 264
    +      
    # File 'app/models/operation.rb', line 267
     
     def to_s
       ins = (inputs.collect { |fv| "#{fv.name}: #{fv.child_sample ? fv.child_sample.name : 'NO SAMPLE'}" }).join(', ')
    @@ -3779,12 +3653,12 @@ 

     
     
    -41
    -42
    -43
    +43 +44 +45

    -
    # File 'app/models/operation.rb', line 41
    +      
    # File 'app/models/operation.rb', line 43
     
     def virtual?
       false
    @@ -3797,7 +3671,7 @@ 

    - #with_input(name, sample) ⇒ Object + #with_input(name, sample) ⇒ Operation @@ -3838,6 +3712,23 @@

    +

    Returns:

    +
      + +
    • + + + (Operation) + + + + — +

      this operation

      +
      + +
    • + +

    @@ -3845,19 +3736,19 @@

     
     
    +65
     66
     67
     68
     69
     70
    -71
    -72
    +71

    @@ -1224,16 +1246,16 @@

     
     
    -108
    -109
    -110
    -111
    -112
    -113
    -114
    +123 +124 +125 +126 +127 +128 +129

    -
    # File 'app/models/operation.rb', line 66
    +      
    # File 'app/models/operation.rb', line 65
     
     def with_input(name, sample)
    -  ft = operation_type.inputs.select { |i| i[:name] == name }.first
    +  ft = operation_type.input(name)
       aft = ft.choose_aft_for(sample)
       set_input(name, sample, aft)
     
    @@ -3919,19 +3810,19 @@ 

     
     
    +77
     78
     79
     80
     81
     82
    -83
    -84
    +83

    -
    # File 'app/models/operation.rb', line 78
    +      
    # File 'app/models/operation.rb', line 77
     
     def with_output(name, sample)
    -  ft = operation_type.outputs.select { |i| i[:name] == name }.first
    +  ft = operation_type.output(name)
       aft = ft.choose_aft_for(sample)
       set_output(name, sample, aft)
     
    @@ -3993,12 +3884,12 @@ 

     
     
    +88
     89
    -90
    -91
    +90

    -
    # File 'app/models/operation.rb', line 89
    +      
    # File 'app/models/operation.rb', line 88
     
     def with_property(name, value)
       set_property(name, value, 'input', false, nil)
    @@ -4013,9 +3904,9 @@ 

    diff --git a/docs/api/OperationType.html b/docs/api/OperationType.html index bef652f4d..ef0ce986f 100644 --- a/docs/api/OperationType.html +++ b/docs/api/OperationType.html @@ -232,7 +232,7 @@

  • - #add_new_allowable_field_type(ft, newaft) ⇒ Object + #add_new_allowable_field_type(ft, new_type) ⇒ Object @@ -255,7 +255,7 @@

  • - #add_new_field_type(newft) ⇒ Object + #add_new_field_type(new_type) ⇒ Object @@ -335,6 +335,28 @@

    +
    + +

  • + + +
  • + + + #add_test(content:, user:) ⇒ Object + + + + + + + + + + + + +
  • @@ -454,7 +476,7 @@

  • - #inputs ⇒ Array<FieldType> + #input(name) ⇒ Object @@ -468,7 +490,7 @@

    -

    The input types of this OperationType.

    +

    Returns the input of this OperationType with the given name.

  • @@ -477,7 +499,7 @@

  • - #name ⇒ String + #inputs ⇒ Array<FieldType> @@ -491,7 +513,7 @@

    -

    Gets name of OperationType.

    +

    The input types of this OperationType.

  • @@ -500,7 +522,7 @@

  • - #outputs ⇒ Array<FieldType> + #name ⇒ String @@ -514,7 +536,7 @@

    -

    The output types of this OperationType.

    +

    Gets name of OperationType.

  • @@ -523,7 +545,7 @@

  • - #pending ⇒ Object + #output(name) ⇒ FieldType @@ -537,7 +559,8 @@

    -
    +

    Returns the output of this OperationType with the given name.

    +

  • @@ -545,7 +568,7 @@

  • - #precondition ⇒ Object + #outputs ⇒ Array<FieldType> @@ -559,7 +582,8 @@

    -
    +

    The output types of this OperationType.

    +

  • @@ -567,7 +591,7 @@

  • - #protocol ⇒ Object + #pending ⇒ Object @@ -589,7 +613,7 @@

  • - #schedule(operations, user, group, opts = {}) ⇒ Object + #precondition ⇒ Object @@ -603,8 +627,7 @@

    -

    TODO: also a Job factory method, returned ops are not used.

    -
    +

  • @@ -612,7 +635,7 @@

  • - #schedule_aux(ops, user, group, opts = {}) ⇒ Object + #protocol ⇒ Object @@ -626,8 +649,7 @@

    -

    TODO: this should be a Job factory method.

    -
    +

  • @@ -701,7 +723,7 @@

  • - #update_field_type(oldft, newft) ⇒ Object + #update_field_type(old_type, new_type) ⇒ Object @@ -816,36 +838,36 @@

     
     
    +308
    +309
    +310
    +311
    +312
    +313
    +314
    +315
    +316
    +317
    +318
    +319
    +320
    +321
    +322
    +323
    +324
    +325
    +326
    +327
    +328
    +329
    +330
    +331
    +332
     333
    -334
    -335
    -336
    -337
    -338
    -339
    -340
    -341
    -342
    -343
    -344
    -345
    -346
    -347
    -348
    -349
    -350
    -351
    -352
    -353
    -354
    -355
    -356
    -357
    -358
    -359
    +334

  • -
    # File 'app/models/operation_type.rb', line 333
    +      
    # File 'app/models/operation_type.rb', line 308
     
     def self.numbers(user = nil)
       q = if user.nil?
    @@ -909,16 +931,16 @@ 

     
     
    -96
    -97
    -98
    -99
    -100
    -101
    -102
    +111 +112 +113 +114 +115 +116 +117

    -
    # File 'app/models/operation_type.rb', line 96
    +      
    # File 'app/models/operation_type.rb', line 111
     
     def add_cost_model(content:, user:)
       if cost_model
    @@ -1013,7 +1035,7 @@ 

    - #add_new_allowable_field_type(ft, newaft) ⇒ Object + #add_new_allowable_field_type(ft, new_type) ⇒ Object @@ -1035,22 +1057,22 @@

     
     
    -176
    -177
    -178
    -179
    -180
    -181
    -182
    -183
    -184
    +151 +152 +153 +154 +155 +156 +157 +158 +159

    -
    # File 'app/models/operation_type.rb', line 176
    +      
    # File 'app/models/operation_type.rb', line 151
     
    -def add_new_allowable_field_type(ft, newaft)
    -  st = (SampleType.find_by_name(newaft[:sample_type][:name]) if newaft[:sample_type])
    -  ot = (ObjectType.find_by_name(newaft[:object_type][:name]) if newaft[:object_type] && newaft[:object_type][:name] != '')
    +def add_new_allowable_field_type(ft, new_type)
    +  st = (SampleType.find_by(name: new_type[:sample_type][:name]) if new_type[:sample_type])
    +  ot = (ObjectType.find_by(name: new_type[:object_type][:name]) if new_type[:object_type] && new_type[:object_type][:name] != '')
     
       ft.allowable_field_types.create(
         sample_type_id: st ? st.id : nil,
    @@ -1065,7 +1087,7 @@ 

    - #add_new_field_type(newft) ⇒ Object + #add_new_field_type(new_type) ⇒ Object @@ -1086,6 +1108,31 @@

     
     
    +179
    +180
    +181
    +182
    +183
    +184
    +185
    +186
    +187
    +188
    +189
    +190
    +191
    +192
    +193
    +194
    +195
    +196
    +197
    +198
    +199
    +200
    +201
    +202
    +203
     204
     205
     206
    @@ -1093,47 +1140,22 @@ 

    208 209 210 -211 -212 -213 -214 -215 -216 -217 -218 -219 -220 -221 -222 -223 -224 -225 -226 -227 -228 -229 -230 -231 -232 -233 -234 -235 -236

    +211

    -
    # File 'app/models/operation_type.rb', line 204
    +      
    # File 'app/models/operation_type.rb', line 179
     
    -def add_new_field_type(newft)
    -  if newft[:allowable_field_types]
    +def add_new_field_type(new_type)
    +  if new_type[:allowable_field_types]
     
    -    sample_type_names = newft[:allowable_field_types].collect do |aft|
    +    sample_type_names = new_type[:allowable_field_types].collect do |aft|
           aft[:sample_type] ? aft[:sample_type][:name] : nil
         end
     
    -    container_names = newft[:allowable_field_types]
    +    container_names = new_type[:allowable_field_types]
                           .select { |aft| aft[:object_type] && aft[:object_type][:name] && aft[:object_type][:name] != '' }
                           .collect do |aft|
    -      raise "Object type '#{aft[:object_type][:name]}' not defined by browser for #{ft[:name]}." unless ObjectType.find_by_name(aft[:object_type][:name])
    +      raise "Object type '#{aft[:object_type][:name]}' not defined by browser for #{ft[:name]}." unless ObjectType.find_by(name: aft[:object_type][:name])
     
           aft[:object_type][:name]
         end
    @@ -1143,18 +1165,18 @@ 

    end add_io( - newft[:name], + new_type[:name], sample_type_names, container_names, - newft[:role], - array: newft[:array], - part: newft[:part], - routing: newft[:routing], - ftype: newft[:ftype], - choices: newft[:choices] + new_type[:role], + array: new_type[:array], + part: new_type[:part], + routing: new_type[:routing], + ftype: new_type[:ftype], + choices: new_type[:choices] ) - field_types.where(name: newft[:name], role: newft[:role])[0] + field_types.where(name: new_type[:name], role: new_type[:role])[0] end

    -
    # File 'app/models/operation_type.rb', line 108
    +      
    # File 'app/models/operation_type.rb', line 123
     
     def add_precondition(content:, user:)
       if precondition
    @@ -1271,16 +1293,16 @@ 

     
     
    -84
    -85
    -86
    -87
    -88
    -89
    -90
    +99 +100 +101 +102 +103 +104 +105

    -
    # File 'app/models/operation_type.rb', line 84
    +      
    # File 'app/models/operation_type.rb', line 99
     
     def add_protocol(content:, user:)
       if protocol
    @@ -1292,6 +1314,53 @@ 

    + + +
    +

    + + #add_test(content:, user:) ⇒ Object + + + + + +

    +
    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +139
    +140
    +141
    +142
    +143
    +144
    +145
    +
    +
    # File 'app/models/operation_type.rb', line 139
    +
    +def add_test(content:, user:)
    +  if test
    +    test.commit(content, user)
    +  else
    +    new_code('test', content, user)
    +  end
    +end
    +
    @@ -1371,12 +1440,12 @@

     
     
    -92
    -93
    -94
    +107 +108 +109

    -
    # File 'app/models/operation_type.rb', line 92
    +      
    # File 'app/models/operation_type.rb', line 107
     
     def cost_model
       code('cost_model')
    @@ -1410,12 +1479,12 @@ 

     
     
    -116
    -117
    -118
    +131 +132 +133

    -
    # File 'app/models/operation_type.rb', line 116
    +      
    # File 'app/models/operation_type.rb', line 131
     
     def documentation
       code('documentation')
    @@ -1449,12 +1518,12 @@ 

     
     
    -76
    -77
    -78
    +91 +92 +93

    -
    # File 'app/models/operation_type.rb', line 76
    +      
    # File 'app/models/operation_type.rb', line 91
     
     def done
       operations.where(status: 'done')
    @@ -1488,19 +1557,19 @@ 

     
     
    -300
    -301
    -302
    -303
    -304
    -305
    -306
    -307
    -308
    -309
    +275 +276 +277 +278 +279 +280 +281 +282 +283 +284

    -
    # File 'app/models/operation_type.rb', line 300
    +      
    # File 'app/models/operation_type.rb', line 275
     
     def error_out_obsolete_operations
       Operation.where(operation_type_id: id, status: %w[pending scheduled]).each do |op|
    @@ -1515,6 +1584,65 @@ 

    + + +
    +

    + + #input(name) ⇒ Object + + + + + +

    +
    +

    Returns the input of this OperationType with the given name.

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + name + + + (String) + + + + — +

      the name of the input

      +
      + +
    • + +
    + + +
    + + + + +
    +
    +
    +
    +63
    +64
    +65
    +
    +
    # File 'app/models/operation_type.rb', line 63
    +
    +def input(name)
    +  inputs.select { |field_type| field_type[:name] == name }.first
    +end
    +
    @@ -1629,9 +1757,9 @@

    -

    +

    - #outputsArray<FieldType> + #output(name) ⇒ FieldType @@ -1639,26 +1767,44 @@

    -

    The output types of this OperationType.

    +

    Returns the output of this OperationType with the given name.

    +

    Parameters:

    +
      + +
    • + + name + + + (String) + + + + — +

      the name of the input

      +
      + +
    • +
    +

    Returns:

    • - (Array<FieldType>) + (FieldType) — -

      meta definitions of the outputs -that could be produced by a successful operation of this type

      +

      the named output

    • @@ -1671,15 +1817,15 @@

       
       
      -64
      -65
      -66
      +79 +80 +81

    -
    # File 'app/models/operation_type.rb', line 64
    +      
    # File 'app/models/operation_type.rb', line 79
     
    -def outputs
    -  field_types.select { |ft| ft.role == 'output' }
    +def output(name)
    +  outputs.select { |field_type| field_type[:name] == name }.name
     end
    @@ -1687,9 +1833,9 @@

    -

    +

    - #pendingObject + #outputsArray<FieldType> @@ -1697,51 +1843,31 @@

    - +

    The output types of this OperationType.

    +
    - -
    - - - - -
    -
    -
    -
    -72
    -73
    -74
    -
    -
    # File 'app/models/operation_type.rb', line 72
    -
    -def pending
    -  operations.where(status: 'pending')
    -end
    -
    -
    - -
    -

    - - #preconditionObject - - - - +

    Returns:

    +
      -

    -
    - - -
    +
  • + + + (Array<FieldType>) + + + + — +

    meta definitions of the outputs +that could be produced by a successful operation of this type

    -
    + +
  • +
    @@ -1749,15 +1875,15 @@

     
     
    -104
    -105
    -106
    +71 +72 +73

    @@ -1765,9 +1891,9 @@

    -

    +

    - #protocolObject + #pendingObject @@ -1788,15 +1914,15 @@

     
     
    -80
    -81
    -82
    +87 +88 +89

    @@ -1804,9 +1930,9 @@

    -

    +

    - #schedule(operations, user, group, opts = {}) ⇒ Object + #preconditionObject @@ -1814,8 +1940,7 @@

    -

    TODO: also a Job factory method, returned ops are not used

    - +
    @@ -1828,47 +1953,15 @@

     
     
    -152
    -153
    -154
    -155
    -156
    -157
    -158
    -159
    -160
    -161
    -162
    -163
    -164
    -165
    -166
    -167
    -168
    -169
    -170
    +119 +120 +121

    @@ -1876,9 +1969,9 @@

    -

    +

    - #schedule_aux(ops, user, group, opts = {}) ⇒ Object + #protocolObject @@ -1886,8 +1979,7 @@

    -

    TODO: this should be a Job factory method

    - +
    @@ -1900,59 +1992,15 @@

     
     
    -125
    -126
    -127
    -128
    -129
    -130
    -131
    -132
    -133
    -134
    -135
    -136
    -137
    -138
    -139
    -140
    -141
    -142
    -143
    -144
    -145
    -146
    -147
    -148
    -149
    +95 +96 +97

    @@ -1983,30 +2031,30 @@

     
     
    -311
    -312
    -313
    -314
    -315
    -316
    -317
    -318
    -319
    -320
    -321
    -322
    -323
    -324
    -325
    -326
    -327
    -328
    -329
    -330
    -331
    +286 +287 +288 +289 +290 +291 +292 +293 +294 +295 +296 +297 +298 +299 +300 +301 +302 +303 +304 +305 +306

    @@ -2267,34 +2315,34 @@

     
     
    -274
    -275
    -276
    -277
    -278
    -279
    -280
    -281
    -282
    -283
    -284
    -285
    -286
    -287
    -288
    -289
    -290
    -291
    -292
    -293
    -294
    -295
    -296
    -297
    -298
    +249 +250 +251 +252 +253 +254 +255 +256 +257 +258 +259 +260 +261 +262 +263 +264 +265 +266 +267 +268 +269 +270 +271 +272 +273

    @@ -337,27 +331,21 @@

     
     
    +23
     24
     25
     26
     27
    -28
    -29
    -30
    -31
    -32
    +28

    @@ -388,14 +376,14 @@

     
     
    -8
    -9
     10
     11
    -12
    +12 +13 +14

    + +
    -
    # File 'app/models/operation_type.rb', line 104
    +      
    # File 'app/models/operation_type.rb', line 71
     
    -def precondition
    -  code('precondition')
    +def outputs
    +  field_types.select { |ft| ft.role == 'output' }
     end
    -
    # File 'app/models/operation_type.rb', line 80
    +      
    # File 'app/models/operation_type.rb', line 87
     
    -def protocol
    -  code('protocol')
    +def pending
    +  operations.where(status: 'pending')
     end
    -
    # File 'app/models/operation_type.rb', line 152
    -
    -def schedule(operations, user, group, opts = {})
    -  ops_to_schedule = []
    -  ops_to_defer = []
    -
    -  operations.each do |op|
    -    pps = op.primed_predecessors
    -    if !pps.empty?
    -      ops_to_schedule += pps
    -      ops_to_defer << op
    -    else
    -      ops_to_schedule << op
    -    end
    -  end
    -
    -  schedule_aux(ops_to_defer, user, group, opts.merge(defer: true))
    -  job = schedule_aux(ops_to_schedule, user, group, opts)
    +      
    # File 'app/models/operation_type.rb', line 119
     
    -  [job, ops_to_schedule]
    +def precondition
    +  code('precondition')
     end
    -
    # File 'app/models/operation_type.rb', line 125
    -
    -def schedule_aux(ops, user, group, opts = {})
    -  job = Job.new
    -
    -  job.path = 'operation.rb'
    -  job.pc = Job.NOT_STARTED
    -  job.set_arguments(operation_type_id: id)
    -  job.group_id = group.id
    -  job. = user.id
    -  job.desired_start_time = Time.now
    -  job.latest_start_time = Time.now + 1.hour
    -  job.successor_id = opts[:successor].id if opts[:successor]
    -  job.save
    -
    -  ops.each do |op|
    -    if opts[:defer]
    -      op.defer
    -    else
    -      op.schedule
    -    end
    -    JobAssociation.create(job_id: job.id, operation_id: op.id)
    -    op.save
    -  end
    +      
    # File 'app/models/operation_type.rb', line 95
     
    -  job
    +def protocol
    +  code('protocol')
     end
    -
    # File 'app/models/operation_type.rb', line 311
    +      
    # File 'app/models/operation_type.rb', line 286
     
     def stats
       r = { 'done' => 0, 'error' => 0 }
    @@ -2058,12 +2106,12 @@ 

     
     
    -120
    -121
    -122
    +135 +136 +137

    -
    # File 'app/models/operation_type.rb', line 120
    +      
    # File 'app/models/operation_type.rb', line 135
     
     def test
       code('test')
    @@ -2097,37 +2145,37 @@ 

     
     
    -186
    -187
    -188
    -189
    -190
    -191
    -192
    -193
    -194
    -195
    -196
    -197
    -198
    -199
    -200
    -201
    -202
    +161 +162 +163 +164 +165 +166 +167 +168 +169 +170 +171 +172 +173 +174 +175 +176 +177

    -
    # File 'app/models/operation_type.rb', line 186
    +      
    # File 'app/models/operation_type.rb', line 161
     
     def update_allowable_field_type(old_aft, new_aft)
       if new_aft[:sample_type]
    -    st = SampleType.find_by_name(new_aft[:sample_type][:name])
    +    st = SampleType.find_by(name: new_aft[:sample_type][:name])
         old_aft.sample_type_id = st.id if st
       else
         old_aft.sample_type_id = nil
       end
     
       if new_aft[:object_type] && new_aft[:object_type][:name] != ''
    -    ot = ObjectType.find_by_name(new_aft[:object_type][:name])
    +    ot = ObjectType.find_by(name: new_aft[:object_type][:name])
         old_aft.object_type_id = ot.id if ot
       else
         old_aft.sample_type_id = nil
    @@ -2143,7 +2191,7 @@ 

    - #update_field_type(oldft, newft) ⇒ Object + #update_field_type(old_type, new_type) ⇒ Object @@ -2164,6 +2212,31 @@

     
     
    +213
    +214
    +215
    +216
    +217
    +218
    +219
    +220
    +221
    +222
    +223
    +224
    +225
    +226
    +227
    +228
    +229
    +230
    +231
    +232
    +233
    +234
    +235
    +236
    +237
     238
     239
     240
    @@ -2173,70 +2246,45 @@ 

    244 245 246 -247 -248 -249 -250 -251 -252 -253 -254 -255 -256 -257 -258 -259 -260 -261 -262 -263 -264 -265 -266 -267 -268 -269 -270 -271 -272

    +247

    -
    # File 'app/models/operation_type.rb', line 238
    +      
    # File 'app/models/operation_type.rb', line 213
     
    -def update_field_type(oldft, newft)
    -  oldft.name = newft[:name]
    -  if oldft.ftype == 'sample'
    -    oldft.routing = newft[:routing]
    -    oldft.array = newft[:array]
    -    oldft.part = newft[:part]
    -    oldft.preferred_operation_type_id = newft[:preferred_operation_type_id]
    -    oldft.preferred_field_type_id = newft[:preferred_field_type_id]
    +def update_field_type(old_type, new_type)
    +  old_type.name = new_type[:name]
    +  if old_type.sample?
    +    old_type.routing = new_type[:routing]
    +    old_type.array = new_type[:array]
    +    old_type.part = new_type[:part]
    +    old_type.preferred_operation_type_id = new_type[:preferred_operation_type_id]
    +    old_type.preferred_field_type_id = new_type[:preferred_field_type_id]
     
    -    puts "PREF(#{oldft.name}): #{newft[:preferred_field_type_id]}"
    +    puts "PREF(#{old_type.name}): #{new_type[:preferred_field_type_id]}"
     
         keepers = []
    -    if newft[:allowable_field_types]
    -      newft[:allowable_field_types].each do |newaft|
    -        matching_afts = oldft.allowable_field_types.select { |aft| aft.id == newaft[:id] }
    -        if matching_afts.length == 1
    -          oldaft = matching_afts[0]
    +    if new_type[:allowable_field_types]
    +      new_type[:allowable_field_types].each do |newaft|
    +        matching_types = old_type.allowable_field_types.select { |aft| aft.id == newaft[:id] }
    +        if matching_types.length == 1
    +          oldaft = matching_types[0]
               keepers << oldaft
               update_allowable_field_type oldaft, newaft
    -        elsif matching_afts.empty?
    -          keepers << add_new_allowable_field_type(oldft, newaft)
    +        elsif matching_types.empty?
    +          keepers << add_new_allowable_field_type(old_type, newaft)
             else
               raise 'More than one allowable field type matched.'
             end
           end
         end
       else
    -    oldft.ftype = newft[:ftype]
    -    oldft.choices = newft[:choices]
    +    old_type.ftype = new_type[:ftype]
    +    old_type.choices = new_type[:choices]
       end
     
    -  oldft.save
    +  old_type.save
     
    -  oldft.allowable_field_types.reject { |aft| keepers.include? aft }.each(&:destroy)
    +  old_type.allowable_field_types.reject { |aft| keepers.include? aft }.each(&:destroy)
     end
    -
    # File 'app/models/operation_type.rb', line 274
    +      
    # File 'app/models/operation_type.rb', line 249
     
     def update_field_types(fts)
       keepers = []
    @@ -2350,12 +2398,12 @@ 

     
     
    -68
    -69
    -70
    +83 +84 +85

    -
    # File 'app/models/operation_type.rb', line 68
    +      
    # File 'app/models/operation_type.rb', line 83
     
     def waiting
       operations.where(status: 'waiting')
    @@ -2370,9 +2418,9 @@ 

    diff --git a/docs/api/Parameter.html b/docs/api/Parameter.html index c464ca0f3..ce06b4475 100644 --- a/docs/api/Parameter.html +++ b/docs/api/Parameter.html @@ -247,12 +247,12 @@

     
     
    -34
    -35
    -36
    +30 +31 +32

    -
    # File 'app/models/parameter.rb', line 34
    +      
    # File 'app/models/parameter.rb', line 30
     
     def self.get(key)
       get_string key
    @@ -286,27 +286,21 @@ 

     
     
    -14
    -15
     16
     17
     18
     19
     20
    -21
    -22
    +21

    -
    # File 'app/models/parameter.rb', line 14
    +      
    # File 'app/models/parameter.rb', line 16
     
     def self.get_float(key)
    -  p = Parameter.find_by_key(key)
    -  if p
    -    p.value.to_f
    -  else
    -    p = Parameter.make key, '0.0'
    -    p.value.to_f
    -  end
    +  p = Parameter.find_by(key: key)
    +  p ||= Parameter.make(key, '0.0')
    +
    +  p.value.to_f
     end
    -
    # File 'app/models/parameter.rb', line 24
    +      
    # File 'app/models/parameter.rb', line 23
     
     def self.get_string(key)
    -  p = Parameter.find_by_key(key)
    -  if p
    -    p.value
    -  else
    -    p = Parameter.make key, ''
    -    p.value
    -  end
    +  p = Parameter.find_by(key: key)
    +  p ||= Parameter.make(key, '')
    +
    +  p.value
     end
    -
    # File 'app/models/parameter.rb', line 8
    +      
    # File 'app/models/parameter.rb', line 10
     
     def self.make(key, value)
       p = Parameter.new key: key, value: value, description: 'Edit me'
    @@ -412,9 +400,9 @@ 

    diff --git a/docs/api/Sample.html b/docs/api/Sample.html index bc99cbe8e..c31f26808 100644 --- a/docs/api/Sample.html +++ b/docs/api/Sample.html @@ -149,6 +149,28 @@

    +
    + + + + +
  • + + + .for_project(project:) ⇒ Object + + + + + + + + + + + + +
  • @@ -171,6 +193,28 @@

    +
    + + + + +
  • + + + .owned_by(user:) ⇒ Object + + + + + + + + + + + + +
  • @@ -195,6 +239,29 @@

    + + + +
  • + + + .with_sample_type(sample_type:) ⇒ Object + + + + + + + + + + + + + +

    scopes for searching Samples.

    +
    +
  • @@ -538,8 +605,6 @@

     
     
    -62
    -63
     64
     65
     66
    @@ -550,17 +615,54 @@ 

    71

    -
    # File 'app/models/sample.rb', line 62
    +      
    # File 'app/models/sample.rb', line 64
     
     def self.creator(raw, user)
    -
       sample = Sample.new
       sample.user_id = user.id
       sample.sample_type_id = raw[:sample_type_id]
       sample.updater raw
     
       sample
    +end
    +
    +
    + +
    +

    + + .for_project(project:) ⇒ Object + + + + + +

    +
    + + +
    +
    +
    + + +
    + + + @@ -604,18 +706,18 @@

     
     
    -216
    -217
    -218
    -219
    -220
    -221
    -222
    -223
    -224
    +205 +206 +207 +208 +209 +210 +211 +212 +213

    +
    +
     
    +238
    +239
    +240
    +
    +
    # File 'app/models/sample.rb', line 238
    +
    +def self.for_project(project:)
    +  where(project: project)
     end
    -
    # File 'app/models/sample.rb', line 216
    +      
    # File 'app/models/sample.rb', line 205
     
     def self.okay_to_drop?(sample, user)
     
    @@ -629,6 +731,45 @@ 

    +
    + +
    +

    + + .owned_by(user:) ⇒ Object + + + + + +

    +
    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +242
    +243
    +244
    +
    +
    # File 'app/models/sample.rb', line 242
    +
    +def self.owned_by(user:)
    +  where(user_id: user.id)
    +end
    +
    @@ -655,21 +796,61 @@

     
     
    -40
    -41
     42
     43
     44
    -45
    +45 +46 +47

    -
    # File 'app/models/sample.rb', line 40
    +      
    # File 'app/models/sample.rb', line 42
     
     def self.sample_from_identifier(str)
    -  if str
    -    parts = str.split(': ')
    -    Sample.find_by_name(parts[1..-1].join(': ')) if parts.length > 1
    -  end
    +  return unless str
    +
    +  parts = str.split(': ')
    +  Sample.find_by(name: parts[1..-1].join(': ')) if parts.length > 1
    +end
    + + + + + +
    +

    + + .with_sample_type(sample_type:) ⇒ Object + + + + + +

    +
    +

    scopes for searching Samples

    + + +
    +
    +
    + + +
    + + + @@ -706,12 +887,12 @@

     
     
    -226
    -227
    -228
    +215 +216 +217

    @@ -1044,12 +1225,12 @@

     
     
    -212
    -213
    -214
    +201 +202 +203

    @@ -1278,12 +1459,12 @@

     
     
    -179
    -180
    -181
    +168 +169 +170

    @@ -1501,9 +1660,9 @@

    diff --git a/docs/api/SampleType.html b/docs/api/SampleType.html index eac2db3cd..fec35e805 100644 --- a/docs/api/SampleType.html +++ b/docs/api/SampleType.html @@ -352,8 +352,6 @@

     
     
    -183
    -184
     185
     186
     187
    @@ -378,20 +376,22 @@ 

    206 207 208 -209

    +209 +210 +211

    @@ -937,8 +937,6 @@

     
     
    -26
    -27
     28
     29
     30
    @@ -954,14 +952,16 @@ 

    40 41 42 -43

    +43 +44 +45

    +
    +
    +
    +234
    +235
    +236
    +
    +
    # File 'app/models/sample.rb', line 234
    +
    +def self.with_sample_type(sample_type:)
    +  where(sample_type_id: sample_type.id)
     end
    -
    # File 'app/models/sample.rb', line 226
    +      
    # File 'app/models/sample.rb', line 215
     
     def data_hash
       JSON.parse(data, symbolize_names: true)
    @@ -745,22 +926,22 @@ 

     
     
    +219
    +220
    +221
    +222
    +223
    +224
    +225
    +226
    +227
    +228
    +229
     230
    -231
    -232
    -233
    -234
    -235
    -236
    -237
    -238
    -239
    -240
    -241
    -242
    +231

    -
    # File 'app/models/sample.rb', line 230
    +      
    # File 'app/models/sample.rb', line 219
     
     def full_json
     
    @@ -770,7 +951,7 @@ 

    ) # rename field for compatibility with ng-control/sample.js - sample_hash["field_values"] = sample_hash.delete "full_field_values" + sample_hash['field_values'] = sample_hash.delete 'full_field_values' sample_hash @@ -848,23 +1029,23 @@

     
     
    -168
    -169
    -170
    -171
    -172
    -173
    -174
    -175
    -176
    -177
    +157 +158 +159 +160 +161 +162 +163 +164 +165 +166

    -
    # File 'app/models/sample.rb', line 168
    +      
    # File 'app/models/sample.rb', line 157
     
     def in(container)
     
    -  c = ObjectType.find_by_name container
    +  c = ObjectType.find_by name: container
       if c
         Item.where("sample_id = ? AND object_type_id = ? AND NOT ( location = 'deleted' )", id, c.id)
       else
    @@ -942,21 +1123,21 @@ 

     
     
    -203
    -204
    -205
    -206
    -207
    -208
    -209
    -210
    +192 +193 +194 +195 +196 +197 +198 +199

    -
    # File 'app/models/sample.rb', line 203
    +      
    # File 'app/models/sample.rb', line 192
     
     def make_item(object_type_name)
     
    -  ot = ObjectType.find_by_name(object_type_name)
    +  ot = ObjectType.find_by(name: object_type_name)
       raise "Could not find object type #{name}" unless ot
     
       Item.make({ quantity: 1, inuse: 0 }, sample: self, object_type: ot)
    @@ -1009,10 +1190,10 @@ 

     
     
    -22
    +24

    -
    # File 'app/models/sample.rb', line 22
    +      
    # File 'app/models/sample.rb', line 24
     
     attr_accessible :name
    -
    # File 'app/models/sample.rb', line 212
    +      
    # File 'app/models/sample.rb', line 201
     
     def num_posts
       post_associations.count
    @@ -1097,20 +1278,20 @@ 

     
     
    -186
    -187
    -188
    -189
    -190
    -191
    -192
    -193
    +175 +176 +177 +178 +179 +180 +181 +182

    -
    # File 'app/models/sample.rb', line 186
    +      
    # File 'app/models/sample.rb', line 175
     
     def owner
    -  u = User.find_by_id(user_id)
    +  u = User.find_by(id: user_id)
       if u
         u.
       else
    @@ -1147,12 +1328,12 @@ 

     
     
    -11
    -12
    -13
    +13 +14 +15

    -
    # File 'app/models/sample.rb', line 11
    +      
    # File 'app/models/sample.rb', line 13
     
     def parent_type # interface with FieldValuer
       sample_type
    @@ -1204,10 +1385,10 @@ 

     
     
    -27
    +29

    -
    # File 'app/models/sample.rb', line 27
    +      
    # File 'app/models/sample.rb', line 29
     
     attr_accessible :sample_type_id
    -
    # File 'app/models/sample.rb', line 179
    +      
    # File 'app/models/sample.rb', line 168
     
     def to_s
       "<a href='/samples/#{id}' class='aquarium-item' id='#{id}'>#{id}</a>"
    @@ -1390,106 +1571,84 @@ 

    147 148 149 -150 -151 -152 -153 -154 -155 -156 -157 -158 -159 -160 -161

    +150
    # File 'app/models/sample.rb', line 77
     
     def updater(raw, user = nil)
    -
       self.name = raw[:name]
       self.description = raw[:description]
       self.project = raw[:project]
     
       Sample.transaction do
    -
         save
    +    raise ActiveRecord::Rollback unless errors.empty?
     
    -    if errors.empty?
    -
    -      sample_type = SampleType.find(raw[:sample_type_id])
    -
    -      if raw[:field_values]
    +    sample_type = SampleType.find(raw[:sample_type_id])
    +    if raw[:field_values]
     
    -        raw[:field_values].each do |raw_fv|
    +      raw[:field_values].each do |raw_fv|
     
    -          ft = sample_type.type(raw_fv[:name])
    +        ft = sample_type.type(raw_fv[:name])
     
    -          if ft && raw_fv[:id] && raw_fv[:deleted]
    +        if ft && raw_fv[:id] && raw_fv[:deleted]
     
    -            fv = FieldValue.find_by_id(raw_fv[:id])
    -            fv.destroy if fv
    +          fv = FieldValue.find_by(id: raw_fv[:id])
    +          fv.destroy if fv
     
    -          elsif ft && !raw_fv[:deleted] # fv might have been made and marked deleted without ever having been saved
    +        elsif ft && !raw_fv[:deleted] # fv might have been made and marked deleted without ever having been saved
     
    -            if raw_fv[:id]
    -              begin
    -                fv = FieldValue.find(raw_fv[:id])
    -              rescue Exception => e
    -                errors.add :missing_field_value, "Field value #{raw_fv[:id]} not found in db."
    -                errors.add :missing_field_value, e.to_s
    -                raise ActiveRecord::Rollback
    -              end
    -            else
    -              fv = field_values.create(name: raw_fv[:name])
    +          if raw_fv[:id]
    +            begin
    +              fv = FieldValue.find(raw_fv[:id])
    +            rescue ActiveRecord::RecordNotFound => e
    +              errors.add :missing_field_value, "Field value #{raw_fv[:id]} not found in db."
    +              errors.add :missing_field_value, e.to_s
    +              raise ActiveRecord::Rollback
                 end
    -
    -            if ft.ftype == 'sample'
    -              child = if raw_fv[:new_child_sample]
    -                        Sample.creator(raw_fv[:new_child_sample], user ? user : User.find(user_id))
    -                      else
    -                        Sample.sample_from_identifier raw_fv[:child_sample_name]
    -                      end
    -              fv.child_sample_id = child.id if child
    -              fv.child_sample_id = nil if !child && raw_fv[:child_sample_name] == ''
    -              if !child && ft.required && raw_fv[:child_sample_name] != ''
    -                errors.add :required, "Sample required for field '#{ft.name}' not found or not specified."
    -                raise ActiveRecord::Rollback
    -              end
    -              unless !child || child.errors.empty?
    -                errors.add :child_error, "#{ft.name}: " + stringify_errors(child.errors)
    -                raise ActiveRecord::Rollback
    -              end
    -            elsif ft.ftype == 'number'
    -              fv.value = raw_fv[:value].to_f
    -            else # string, url
    -              fv.value = raw_fv[:value]
    +          else
    +            fv = field_values.create(name: raw_fv[:name])
    +          end
    +
    +          if ft.sample?
    +            child = if raw_fv[:new_child_sample]
    +                      Sample.creator(raw_fv[:new_child_sample], user || User.find(user_id))
    +                    else
    +                      Sample.sample_from_identifier raw_fv[:child_sample_name]
    +                    end
    +            fv.child_sample_id = child.id if child
    +            fv.child_sample_id = nil if !child && raw_fv[:child_sample_name] == ''
    +            if !child && ft.required && raw_fv[:child_sample_name] != ''
    +              errors.add :required, "Sample required for field '#{ft.name}' not found or not specified."
    +              raise ActiveRecord::Rollback
                 end
    -
    -            puts 'before fv saved: {fv.inspect}'
    -            fv.save
    -            puts "fv saved. now #{fv.inspect}"
    -
    -            unless fv.errors.empty?
    -              errors.add :field_value, "Could not save field #{raw_fv[:name]}: #{stringify_errors(fv.errors)}"
    +            unless !child || child.errors.empty?
    +              errors.add :child_error, "#{ft.name}: " + stringify_errors(child.errors)
                   raise ActiveRecord::Rollback
                 end
    -
    -          end # if
    +          elsif ft.number?
    +            fv.value = raw_fv[:value].to_f
    +          else # string, url
    +            fv.value = raw_fv[:value]
    +          end
    +
    +          puts "before fv saved: #{fv.inspect}"
    +          fv.save
    +          puts "fv saved. now #{fv.inspect}"
    +
    +          unless fv.errors.empty?
    +            errors.add :field_value, "Could not save field #{raw_fv[:name]}: #{stringify_errors(fv.errors)}"
    +            raise ActiveRecord::Rollback
    +          end
    +
    +        end # if
     
    -        end # each
    +      end # each
     
    -      end # if
    +    end # if
     
    -    else
    -
    -      raise ActiveRecord::Rollback
    -
    -    end
    -
       end
    -
     end
    -
    # File 'app/models/sample_type.rb', line 183
    +      
    # File 'app/models/sample_type.rb', line 185
     
     def self.clean_up_allowable_field_types(raw_sample_types)
     
       raw_sample_types.each do |rst|
     
    -    st = SampleType.find_by_name rst[:name]
    +    st = SampleType.find_by name: rst[:name]
     
         st.field_types.each do |ft|
           rst[:field_types].each do |rft|
    -        next unless ft.name == rft[:name] && ft.role == rft[:role] && ft.ftype == 'sample'
    +        next unless ft.name == rft[:name] && ft.role == rft[:role] && ft.sample?
     
             names = rft[:sample_types]
             ft.allowable_field_types.each do |aft|
    @@ -400,7 +400,7 @@ 

    names.each do |name| empty_afts = ft.allowable_field_types.select { |aft| aft.sample_type_id.nil? } if empty_afts.any? - st = SampleType.find_by_name(name) + st = SampleType.find_by(name: name) empty_afts[0].sample_type_id = st ? st.name : nil end end @@ -439,8 +439,6 @@

     
     
    -71
    -72
     73
     74
     75
    @@ -495,10 +493,12 @@ 

    124 125 126 -127

    +127 +128 +129

    -
    # File 'app/models/sample_type.rb', line 71
    +      
    # File 'app/models/sample_type.rb', line 73
     
     def self.compare_and_upgrade(raw_sample_types)
     
    @@ -508,7 +508,7 @@ 

    raw_sample_types.each do |rst| - st = find_by_name(rst[:name]) + st = find_by(name: rst[:name]) if st note = "Found sample type '#{rst[:name]}'" @@ -542,7 +542,7 @@

    # make allowable field types (assumes sample types have been made) make.each do |rst| - st = SampleType.find_by_name rst[:name] + st = SampleType.find_by name: rst[:name] next unless st st.create_afts_from_raw rst @@ -586,8 +586,6 @@

     
     
    -129
    -130
     131
     132
     133
    @@ -616,10 +614,12 @@ 

    156 157 158 -159

    +159 +160 +161

    -
    # File 'app/models/sample_type.rb', line 129
    +      
    # File 'app/models/sample_type.rb', line 131
     
     def self.create_from_raw(raw_sample_type)
     
    @@ -687,8 +687,6 @@ 

     
     
    -161
    -162
     163
     164
     165
    @@ -707,10 +705,12 @@ 

    178 179 180 -181

    +181 +182 +183

    -
    # File 'app/models/sample_type.rb', line 161
    +      
    # File 'app/models/sample_type.rb', line 163
     
     def create_afts_from_raw(raw_sample_type)
     
    @@ -720,8 +720,8 @@ 

    l = rft[:sample_types] ? rft[:sample_types].length : 0 (0..l - 1).each do |i| - st = SampleType.find_by_name(rft[:sample_types][i]) - ot = ObjectType.find_by_name(rft[:sample_types][i]) + st = SampleType.find_by(name: rft[:sample_types][i]) + ot = ObjectType.find_by(name: rft[:sample_types][i]) aft = AllowableFieldType.new( field_type_id: ft.id, sample_type_id: st ? st.id : nil, @@ -762,12 +762,12 @@

     
     
    -22
    -23
    -24
    +24 +25 +26

    -
    # File 'app/models/sample_type.rb', line 22
    +      
    # File 'app/models/sample_type.rb', line 24
     
     def export
       attributes
    @@ -801,8 +801,6 @@ 

     
     
    -45
    -46
     47
     48
     49
    @@ -825,10 +823,12 @@ 

    66 67 68 -69

    +69 +70 +71

    -
    # File 'app/models/sample_type.rb', line 45
    +      
    # File 'app/models/sample_type.rb', line 47
     
     def inconsistencies(raw_sample_type)
     
    @@ -902,10 +902,10 @@ 

     
     
    -14
    +16

    -
    # File 'app/models/sample_type.rb', line 14
    +      
    # File 'app/models/sample_type.rb', line 16
     
     attr_accessible :name
    -
    # File 'app/models/sample_type.rb', line 26
    +      
    # File 'app/models/sample_type.rb', line 28
     
     def required_sample_types(st_list = [])
     
    -  field_types.select { |ft| ft.ftype == 'sample' }.each do |ft|
    +  field_types.select(&:sample?).each do |ft|
     
         ft.allowable_field_types.each do |aft|
     
    @@ -987,9 +987,9 @@ 

    diff --git a/docs/api/Upload.html b/docs/api/Upload.html index af0a6a713..b642d4841 100644 --- a/docs/api/Upload.html +++ b/docs/api/Upload.html @@ -291,12 +291,12 @@

     
     
    -28
    -29
    -30
    +30 +31 +32

    -
    # File 'app/models/upload.rb', line 28
    +      
    # File 'app/models/upload.rb', line 30
     
     def expiring_url
       upload.expiring_url(10)
    @@ -330,12 +330,12 @@ 

     
     
    -34
    -35
    -36
    +36 +37 +38

    -
    # File 'app/models/upload.rb', line 34
    +      
    # File 'app/models/upload.rb', line 36
     
     def export
       attributes
    @@ -369,12 +369,12 @@ 

     
     
    -16
    -17
    -18
    +18 +19 +20

    -
    # File 'app/models/upload.rb', line 16
    +      
    # File 'app/models/upload.rb', line 18
     
     def name
       upload_file_name
    @@ -408,12 +408,12 @@ 

     
     
    -12
    -13
    -14
    +14 +15 +16

    -
    # File 'app/models/upload.rb', line 12
    +      
    # File 'app/models/upload.rb', line 14
     
     def name=(n)
       self.upload_file_name = n
    @@ -447,12 +447,12 @@ 

     
     
    -20
    -21
    -22
    +22 +23 +24

    -
    # File 'app/models/upload.rb', line 20
    +      
    # File 'app/models/upload.rb', line 22
     
     def size
       upload_file_size
    @@ -486,12 +486,12 @@ 

     
     
    -24
    -25
    -26
    +26 +27 +28

    -
    # File 'app/models/upload.rb', line 24
    +      
    # File 'app/models/upload.rb', line 26
     
     def url
       upload.expiring_url(10)
    @@ -506,9 +506,9 @@ 

    diff --git a/docs/api/_index.html b/docs/api/_index.html index e68cf9a27..232a8d880 100644 --- a/docs/api/_index.html +++ b/docs/api/_index.html @@ -180,6 +180,27 @@

    Namespace Listing A-Z

    +
  • + KrillBaseError + + (Krill) + +
  • + +
  • + KrillError + + (Krill) + +
  • + +
  • + KrillSyntaxError + + (Krill) + +
  • + @@ -239,6 +260,20 @@

    Namespace Listing A-Z

    +
  • + ProtocolError + + (Krill) + +
  • + +
  • + ProtocolSandbox + + (Krill) + +
  • + @@ -286,6 +321,20 @@

    Namespace Listing A-Z

    +
  • + ThreadStatus + + (Krill) + +
  • + +
  • + ThreadedManager + + (Krill) + +
  • + @@ -311,9 +360,9 @@

    Namespace Listing A-Z

    diff --git a/docs/api/class_list.html b/docs/api/class_list.html index 4aca1e6a4..b2ad0eef0 100644 --- a/docs/api/class_list.html +++ b/docs/api/class_list.html @@ -43,7 +43,7 @@

    Class List

    diff --git a/docs/api/file.README.html b/docs/api/file.README.html index 1f4d2abc3..716c8252b 100644 --- a/docs/api/file.README.html +++ b/docs/api/file.README.html @@ -78,13 +78,16 @@

    Versions and Releases

    Documentation

    -

    Documentation, including installation instructions, can be found at aquarium.bio.

    +
      +
    • User documentation, including installation instructions, can be found at aquarium.bio.
    • +
    • Developer documentation can be found here.
    • +
    diff --git a/docs/api/index.html b/docs/api/index.html index 7ddb19918..6db52ea2a 100644 --- a/docs/api/index.html +++ b/docs/api/index.html @@ -78,13 +78,16 @@

    Versions and Releases

    Documentation

    -

    Documentation, including installation instructions, can be found at aquarium.bio.

    +
      +
    • User documentation, including installation instructions, can be found at aquarium.bio.
    • +
    • Developer documentation can be found here.
    • +
    diff --git a/docs/api/method_list.html b/docs/api/method_list.html index 049c6e944..ef6943b92 100644 --- a/docs/api/method_list.html +++ b/docs/api/method_list.html @@ -213,6 +213,14 @@

    Method List

  • +
    + #add_test + OperationType +
    +
  • + + +
  • #all Krill::Table @@ -220,7 +228,7 @@

    Method List

  • -
  • +
  • #all_attributes Item @@ -228,7 +236,7 @@

    Method List

  • -
  • +
  • #allowable_object_types FieldType @@ -236,7 +244,7 @@

    Method List

  • -
  • +
  • #allowable_sample_types FieldType @@ -244,7 +252,7 @@

    Method List

  • -
  • +
  • #allowed? FieldType @@ -252,7 +260,7 @@

    Method List

  • -
  • +
  • #annotate Item @@ -260,7 +268,7 @@

    Method List

  • -
  • +
  • #append Krill::Table @@ -268,7 +276,7 @@

    Method List

  • -
  • +
  • #append_notes DataAssociator @@ -276,7 +284,7 @@

    Method List

  • -
  • +
  • #append_step Job @@ -284,7 +292,7 @@

    Method List

  • -
  • +
  • #append_steps Job @@ -292,7 +300,7 @@

    Method List

  • -
  • +
  • #apportion Collection @@ -300,7 +308,7 @@

    Method List

  • -
  • +
  • #arguments Job @@ -308,23 +316,23 @@

    Method List

  • -
  • +
  • - #as_json - DataAssociation + #as_json + FieldType
  • -
  • +
  • - #as_json - FieldType + #as_json + DataAssociation
  • -
  • +
  • #assign_sample_to_pairs Collection @@ -332,7 +340,7 @@

    Method List

  • -
  • +
  • #associate DataAssociator @@ -340,7 +348,7 @@

    Method List

  • -
  • +
  • #associate_matrix Collection @@ -348,7 +356,7 @@

    Method List

  • -
  • +
  • #associations DataAssociator @@ -356,7 +364,7 @@

    Method List

  • -
  • +
  • #backtrace Job @@ -364,7 +372,7 @@

    Method List

  • -
  • +
  • #box_interactive Krill::Base @@ -372,7 +380,7 @@

    Method List

  • -
  • +
  • #boxes_for Krill::Base @@ -380,7 +388,7 @@

    Method List

  • -
  • +
  • #bullet Krill::ShowBlock @@ -388,7 +396,7 @@

    Method List

  • -
  • +
  • #cancel Job @@ -396,7 +404,7 @@

    Method List

  • -
  • +
  • #capacity Collection @@ -404,7 +412,7 @@

    Method List

  • -
  • +
  • #category OperationType @@ -412,7 +420,7 @@

    Method List

  • -
  • +
  • #check Krill::ShowBlock @@ -420,15 +428,15 @@

    Method List

  • -
  • +
  • - #child_data - Operation + #check_again + Krill::ThreadedManager
  • -
  • +
  • #child_data FieldValue @@ -436,7 +444,7 @@

    Method List

  • -
  • +
  • #choose Krill::Table @@ -444,7 +452,7 @@

    Method List

  • -
  • +
  • clean_up_allowable_field_types SampleType @@ -452,7 +460,7 @@

    Method List

  • -
  • +
  • clean_up_sample_type_links ObjectType @@ -460,7 +468,7 @@

    Method List

  • -
  • +
  • #cleanup_input_table Krill::OperationList @@ -468,15 +476,15 @@

    Method List

  • -
  • +
  • - #clear - Collection + #clear + Locator
  • -
  • +
  • #clear Krill::Table @@ -484,15 +492,15 @@

    Method List

  • -
  • +
  • - #clear - Locator + #clear + Collection
  • -
  • +
  • #collect Krill::OperationList @@ -500,7 +508,7 @@

    Method List

  • -
  • +
  • #collection Krill::OperationList @@ -508,7 +516,7 @@

    Method List

  • -
  • +
  • #collection FieldValue @@ -516,7 +524,7 @@

    Method List

  • -
  • +
  • #collection? Item @@ -524,7 +532,7 @@

    Method List

  • -
  • +
  • #collection_column Krill::OperationList @@ -532,7 +540,7 @@

    Method List

  • -
  • +
  • #collection_from Krill::Base @@ -540,7 +548,7 @@

    Method List

  • -
  • +
  • #collection_part FieldValue @@ -548,6 +556,14 @@

    Method List

  • +
  • +
    + #column + Krill::Table +
    +
  • + +
  • #column @@ -558,23 +574,23 @@

    Method List

  • - #column - Krill::Table + #column_column + Krill::OperationList
  • - #column_column - Krill::OperationList + #columns + ObjectType
  • - #columns + #columns= ObjectType
  • @@ -582,7 +598,7 @@

    Method List

  • @@ -598,24 +614,24 @@

    Method List

  • - compare_and_upgrade - ObjectType + containing + Collection
  • - containing - Collection + #containing_collection + Item
  • - #containing_collection - Item + #continue + Krill::ThreadedManager
  • @@ -662,24 +678,24 @@

    Method List

  • - create_from_raw - SampleType + create_from + Job
  • - #create_input - Operation + create_from_raw + SampleType
  • - create_item - FieldValue + #create_input + Operation
  • @@ -910,15 +926,15 @@

    Method List

  • - #drop_data_matrix - Collection + #done? + Krill::ProtocolSandbox
  • @@ -926,29 +942,37 @@

    Method List

  • - #empty? - FieldType + #each_row_col + Collection
  • - #empty? - Collection + #empty? + Locator
  • - #empty? - Locator + #empty? + Collection
  • +
    + #empty? + FieldType +
    +
  • + + +
  • #end_table Krill::OperationList @@ -956,6 +980,14 @@

    Method List

  • +
  • +
    + #error + Krill::KrillBaseError +
    +
  • + +
  • #error @@ -973,6 +1005,14 @@

    Method List

  • +
    + #error_backtrace + Krill::KrillBaseError +
    +
  • + + +
  • #error_backtrace Job @@ -980,7 +1020,7 @@

    Method List

  • -
  • +
  • #error_message Job @@ -988,6 +1028,14 @@

    Method List

  • +
  • +
    + #error_message + Krill::KrillBaseError +
    +
  • + +
  • #error_out_obsolete_operations @@ -1005,6 +1053,14 @@

    Method List

  • +
    + #execute + Krill::ProtocolSandbox +
    +
  • + + +
  • #expiring_url Upload @@ -1012,50 +1068,58 @@

    Method List

  • +
  • +
    + #export + Job +
    +
  • + +
  • - #export - Upload + #export + FieldValue
  • - #export - ObjectType + #export + SampleType
  • - #export - Job + #export + FieldType
  • - #export - Item + #export + Upload
  • - #export - SampleType + #export + ObjectType
  • - #export - FieldValue + #export + Item
  • @@ -1117,6 +1181,14 @@

    Method List

  • +
    + for_project + Sample +
    +
  • + + +
  • #from Krill::Table @@ -1124,7 +1196,7 @@

    Method List

  • -
  • +
  • #full? Collection @@ -1132,7 +1204,7 @@

    Method List

  • -
  • +
  • #full_json Sample @@ -1140,7 +1212,7 @@

    Method List

  • -
  • +
  • #full_json FieldValue @@ -1148,7 +1220,7 @@

    Method List

  • -
  • +
  • #full_object DataAssociation @@ -1156,23 +1228,23 @@

    Method List

  • -
  • +
  • - get - Parameter + #get + Krill::OperationList
  • -
  • +
  • - #get - Krill::OperationList + #get + Krill::ShowBlock
  • -
  • +
  • #get DataAssociator @@ -1180,15 +1252,15 @@

    Method List

  • -
  • +
  • - #get - Krill::ShowBlock + get + Parameter
  • -
  • +
  • #get_association DataAssociator @@ -1196,7 +1268,7 @@

    Method List

  • -
  • +
  • #get_data Item @@ -1204,7 +1276,7 @@

    Method List

  • -
  • +
  • #get_empty Collection @@ -1212,7 +1284,7 @@

    Method List

  • -
  • +
  • #get_field_value Operation @@ -1220,7 +1292,7 @@

    Method List

  • -
  • +
  • get_float Parameter @@ -1228,7 +1300,7 @@

    Method List

  • -
  • +
  • #get_input Operation @@ -1236,7 +1308,7 @@

    Method List

  • -
  • +
  • #get_matrix Collection @@ -1244,7 +1316,7 @@

    Method List

  • -
  • +
  • #get_non_empty Collection @@ -1252,7 +1324,7 @@

    Method List

  • -
  • +
  • #get_output Operation @@ -1260,7 +1332,7 @@

    Method List

  • -
  • +
  • #get_part_data Collection @@ -1268,7 +1340,7 @@

    Method List

  • -
  • +
  • #get_response Krill::ShowResponse @@ -1276,7 +1348,7 @@

    Method List

  • -
  • +
  • get_string Parameter @@ -1284,7 +1356,7 @@

    Method List

  • -
  • +
  • #get_table_response Krill::ShowResponse @@ -1292,7 +1364,7 @@

    Method List

  • -
  • +
  • #group_by Krill::OperationList @@ -1300,7 +1372,7 @@

    Method List

  • -
  • +
  • #handler ObjectType @@ -1308,7 +1380,7 @@

    Method List

  • -
  • +
  • #has_column? Krill::Table @@ -1316,7 +1388,7 @@

    Method List

  • -
  • +
  • #has_columns? Krill::Table @@ -1324,7 +1396,7 @@

    Method List

  • -
  • +
  • #has_sample_type FieldType @@ -1332,6 +1404,14 @@

    Method List

  • +
  • +
    + #has_type + FieldType +
    +
  • + +
  • #has_wizard @@ -1374,16 +1454,16 @@

    Method List

  • - #inconsistencies - FieldType + #inconsistencies + SampleType
  • - #inconsistencies - SampleType + #inconsistencies + FieldType
  • @@ -1396,6 +1476,54 @@

    Method List

    +
  • +
    + #initialize + Krill::KrillBaseError +
    +
  • + + +
  • +
    + #initialize + Krill::KrillError +
    +
  • + + +
  • +
    + #initialize + Krill::ProtocolError +
    +
  • + + +
  • +
    + #initialize + Krill::ProtocolSandbox +
    +
  • + + +
  • +
    + #initialize + Krill::KrillSyntaxError +
    +
  • + + +
  • +
    + #initialize + Krill::ThreadedManager +
    +
  • + +
  • #initialize @@ -1406,15 +1534,15 @@

    Method List

  • - #input - Operation + #input + OperationType
  • - #input_array + #input Operation
  • @@ -1422,15 +1550,15 @@

    Method List

  • - #input_collection - Krill::OperationList + #input_array + Operation
  • - #input_column + #input_collection Krill::OperationList
  • @@ -1438,23 +1566,23 @@

    Method List

  • - #input_data - Operation + #input_column + Krill::OperationList
  • - #input_item - Krill::OperationList + #input_data + Operation
  • - #input_row + #input_item Krill::OperationList
  • @@ -1462,7 +1590,7 @@

    Method List

  • - #input_sample + #input_row Krill::OperationList
  • @@ -1470,8 +1598,8 @@

    Method List

  • - #inputs - Operation + #input_sample + Krill::OperationList
  • @@ -1485,6 +1613,14 @@

    Method List

  • +
    + #inputs + Operation +
    +
  • + + +
  • #insert_operation Krill::Base @@ -1492,7 +1628,7 @@

    Method List

  • -
  • +
  • #inuse_less_than_quantity Item @@ -1500,7 +1636,7 @@

    Method List

  • -
  • +
  • #io_table Krill::OperationList @@ -1508,7 +1644,7 @@

    Method List

  • -
  • +
  • #is_part Item @@ -1516,7 +1652,7 @@

    Method List

  • -
  • +
  • #item Krill::OperationList @@ -1524,6 +1660,14 @@

    Method List

  • +
  • +
    + #item + Krill::ShowBlock +
    +
  • + +
  • #item @@ -1534,8 +1678,8 @@

    Method List

  • - #item - Krill::ShowBlock + #item? + FieldType
  • @@ -1564,6 +1708,38 @@

    Method List

    +
  • +
    + #job + Krill::ProtocolSandbox +
    +
  • + + +
  • +
    + #job + Krill::KrillError +
    +
  • + + +
  • +
    + #job_state + Job +
    +
  • + + +
  • +
    + #json? + FieldType +
    +
  • + +
  • #krill? @@ -1630,24 +1806,24 @@

    Method List

  • - #make - FieldValueKrill + make + Item
  • - #make - Krill::OperationList + #make + FieldValueKrill
  • - make - Item + #make + Krill::OperationList
  • @@ -1750,16 +1926,16 @@

    Method List

  • - #name - Upload + #name + Operation
  • - #name - FieldValue + #name + OperationType
  • @@ -1774,32 +1950,32 @@

    Method List

  • - #name - OperationType + #name + FieldType
  • - #name - FieldType + #name + Sample
  • - #name - SampleType + #name + Upload
  • - #name - Sample + #name + SampleType
  • @@ -1814,8 +1990,8 @@

    Method List

  • - #name - Operation + #name + FieldValue
  • @@ -1830,32 +2006,32 @@

    Method List

  • - new_collection - Collection + #namespace + Krill::KrillBaseError
  • - #new_collection - Krill::Base + new_collection + Collection
  • - #new_data_matrix - Collection + #new_collection + Krill::Base
  • - #new_object - Krill::Base + #new_data_matrix + Collection
  • @@ -1870,13 +2046,21 @@

    Method List

  • - #new_sample + #new_object Krill::Base
  • +
    + #new_sample + Krill::Base +
    +
  • + + +
  • new_sample Item @@ -1884,7 +2068,7 @@

    Method List

  • -
  • +
  • #next Collection @@ -1892,7 +2076,7 @@

    Method List

  • -
  • +
  • #no_collisions Locator @@ -1900,7 +2084,7 @@

    Method List

  • -
  • +
  • #nominal_cost Operation @@ -1908,7 +2092,7 @@

    Method List

  • -
  • +
  • #non_empty_string Collection @@ -1916,7 +2100,7 @@

    Method List

  • -
  • +
  • #non_wizard_location? Item @@ -1924,7 +2108,7 @@

    Method List

  • -
  • +
  • #not_started? Job @@ -1932,7 +2116,7 @@

    Method List

  • -
  • +
  • #note Krill::ShowBlock @@ -1940,7 +2124,7 @@

    Method List

  • -
  • +
  • #notes DataAssociator @@ -1948,7 +2132,7 @@

    Method List

  • -
  • +
  • #notes= DataAssociator @@ -1956,10 +2140,18 @@

    Method List

  • +
  • +
    + #notify + Krill::ThreadedManager +
    +
  • + +
  • - #num_posts - Sample + #num_posts + Item
  • @@ -1974,8 +2166,8 @@

    Method List

  • - #num_posts - Item + #num_posts + Sample
  • @@ -1989,6 +2181,14 @@

    Method List

  • +
    + #number? + FieldType +
    +
  • + + +
  • numbers OperationType @@ -1996,7 +2196,7 @@

    Method List

  • -
  • +
  • #object_type Item @@ -2004,7 +2204,7 @@

    Method List

  • -
  • +
  • okay_to_drop? Sample @@ -2012,7 +2212,7 @@

    Method List

  • -
  • +
  • #on_the_fly Operation @@ -2020,7 +2220,7 @@

    Method List

  • -
  • +
  • #operation_id Krill::OperationList @@ -2028,6 +2228,30 @@

    Method List

  • +
  • +
    + #operation_path + Krill::KrillBaseError +
    +
  • + + +
  • +
    + #operation_type + Krill::KrillBaseError +
    +
  • + + +
  • +
    + #operation_type + Job +
    +
  • + +
  • #operation_type @@ -2053,6 +2277,14 @@

    Method List

  • +
    + #output + OperationType +
    +
  • + + +
  • #output Operation @@ -2060,7 +2292,7 @@

    Method List

  • -
  • +
  • #output_array Operation @@ -2068,7 +2300,7 @@

    Method List

  • -
  • +
  • #output_collection Krill::OperationList @@ -2076,7 +2308,7 @@

    Method List

  • -
  • +
  • #output_collections Krill::OperationList @@ -2084,7 +2316,7 @@

    Method List

  • -
  • +
  • #output_column Krill::OperationList @@ -2092,7 +2324,7 @@

    Method List

  • -
  • +
  • #output_data Operation @@ -2100,7 +2332,7 @@

    Method List

  • -
  • +
  • #output_item Krill::OperationList @@ -2108,7 +2340,7 @@

    Method List

  • -
  • +
  • #output_row Krill::OperationList @@ -2116,7 +2348,7 @@

    Method List

  • -
  • +
  • #output_sample Krill::OperationList @@ -2124,18 +2356,26 @@

    Method List

  • +
  • +
    + #outputs + Operation +
    +
  • + +
  • - #outputs - Operation + #outputs + OperationType
  • - #outputs - OperationType + owned_by + Sample
  • @@ -2174,32 +2414,32 @@

    Method List

  • - #parent_type - Operation + #parent_type + Sample
  • - #parent_type - Sample + #parent_type + Operation
  • - #part - Collection + #part + FieldValue
  • - #part - FieldValue + #part + Collection
  • @@ -2230,13 +2470,21 @@

    Method List

  • - parts + #parts Collection
  • +
    + parts + Collection +
    +
  • + + +
  • #pass Operation @@ -2244,7 +2492,7 @@

    Method List

  • -
  • +
  • #pending OperationType @@ -2252,7 +2500,7 @@

    Method List

  • -
  • +
  • #pending? Job @@ -2260,7 +2508,7 @@

    Method List

  • -
  • +
  • #plan Operation @@ -2268,7 +2516,7 @@

    Method List

  • -
  • +
  • #plankton? Job @@ -2276,7 +2524,7 @@

    Method List

  • -
  • +
  • port Locator @@ -2284,7 +2532,7 @@

    Method List

  • -
  • +
  • port_all Locator @@ -2292,7 +2540,7 @@

    Method List

  • -
  • +
  • #pos ObjectType @@ -2300,7 +2548,7 @@

    Method List

  • -
  • +
  • #position Collection @@ -2308,7 +2556,7 @@

    Method List

  • -
  • +
  • #position_as_hash Collection @@ -2316,7 +2564,7 @@

    Method List

  • -
  • +
  • #precondition OperationType @@ -2324,7 +2572,7 @@

    Method List

  • -
  • +
  • #precondition_value Operation @@ -2332,7 +2580,7 @@

    Method List

  • -
  • +
  • #predecessors Operation @@ -2340,7 +2588,7 @@

    Method List

  • -
  • +
  • #primed_predecessors Operation @@ -2348,7 +2596,7 @@

    Method List

  • -
  • +
  • #primitive_location Item @@ -2356,7 +2604,7 @@

    Method List

  • -
  • +
  • #produce Krill::Base @@ -2364,7 +2612,7 @@

    Method List

  • -
  • +
  • #proper_release_method ObjectType @@ -2372,7 +2620,7 @@

    Method List

  • -
  • +
  • #property Krill::OperationList @@ -2380,6 +2628,14 @@

    Method List

  • +
  • +
    + #protocol + Krill::ProtocolSandbox +
    +
  • + +
  • #protocol @@ -2565,6 +2821,14 @@

    Method List

  • +
    + #running + Krill::ThreadStatus +
    +
  • + + +
  • #running Krill::OperationList @@ -2572,7 +2836,7 @@

    Method List

  • -
  • +
  • #sample Krill::OperationList @@ -2580,7 +2844,7 @@

    Method List

  • -
  • +
  • #sample FieldValue @@ -2588,7 +2852,7 @@

    Method List

  • -
  • +
  • #sample Item @@ -2596,6 +2860,14 @@

    Method List

  • +
  • +
    + #sample? + FieldType +
    +
  • + +
  • sample_from_identifier @@ -2630,48 +2902,48 @@

    Method List

  • - #save_as_test_type - ObjectType + #sandbox + Krill::ThreadedManager
  • - #schedule - OperationType + #save_as_test_type + ObjectType
  • - #schedule_aux - OperationType + schedule + Job
  • - #select - Collection + #select + Krill::ShowBlock
  • - #select - Krill::ShowBlock + #select + Krill::OperationList
  • - #select - Krill::OperationList + #select + Collection
  • @@ -2686,16 +2958,16 @@

    Method List

  • - #set - Collection + #set + FieldValue
  • - #set - FieldValue + #set + Collection
  • @@ -2725,14 +2997,6 @@

    Method List

  • -
    - #set_child_data - Operation -
    -
  • - - -
  • #set_data Item @@ -2740,7 +3004,7 @@

    Method List

  • -
  • +
  • #set_data_matrix Collection @@ -2748,7 +3012,7 @@

    Method List

  • -
  • +
  • #set_input Operation @@ -2756,7 +3020,7 @@

    Method List

  • -
  • +
  • #set_input_data Operation @@ -2764,7 +3028,7 @@

    Method List

  • -
  • +
  • #set_matrix Collection @@ -2772,7 +3036,7 @@

    Method List

  • -
  • +
  • #set_output Operation @@ -2780,7 +3044,7 @@

    Method List

  • -
  • +
  • #set_output_data Operation @@ -2788,7 +3052,7 @@

    Method List

  • -
  • +
  • #set_part_data Collection @@ -2796,7 +3060,7 @@

    Method List

  • -
  • +
  • #set_primitive_location Item @@ -2804,7 +3068,7 @@

    Method List

  • -
  • +
  • #set_status_recursively Operation @@ -2812,7 +3076,7 @@

    Method List

  • -
  • +
  • #show Krill::Base @@ -2820,7 +3084,7 @@

    Method List

  • -
  • +
  • #show_with_input_table Krill::Base @@ -2828,7 +3092,7 @@

    Method List

  • -
  • +
  • #siblings Operation @@ -2836,7 +3100,7 @@

    Method List

  • -
  • +
  • #size Upload @@ -2844,7 +3108,7 @@

    Method List

  • -
  • +
  • #sort_by_location Krill::Base @@ -2852,7 +3116,7 @@

    Method List

  • -
  • +
  • spread Collection @@ -2860,7 +3124,7 @@

    Method List

  • -
  • +
  • #spread Krill::Base @@ -2868,6 +3132,14 @@

    Method List

  • +
  • +
    + #start + Krill::ThreadedManager +
    +
  • + +
  • #start_link @@ -2885,6 +3157,14 @@

    Method List

  • +
    + #start_thread + Krill::ThreadedManager +
    +
  • + + +
  • #stats OperationType @@ -2892,7 +3172,7 @@

    Method List

  • -
  • +
  • #status Job @@ -2900,7 +3180,7 @@

    Method List

  • -
  • +
  • step Operation @@ -2908,7 +3188,7 @@

    Method List

  • -
  • +
  • #step_workflow Job @@ -2916,6 +3196,14 @@

    Method List

  • +
  • +
    + #stop + Krill::ThreadedManager +
    +
  • + +
  • #store @@ -2933,6 +3221,14 @@

    Method List

  • +
    + #string? + FieldType +
    +
  • + + +
  • #stringify_errors Sample @@ -2940,7 +3236,7 @@

    Method List

  • -
  • +
  • #submitter Job @@ -2948,7 +3244,7 @@

    Method List

  • -
  • +
  • #subtract_one Collection @@ -2956,7 +3252,7 @@

    Method List

  • -
  • +
  • #successors Operation @@ -2964,7 +3260,7 @@

    Method List

  • -
  • +
  • #table Krill::ShowBlock @@ -2972,7 +3268,7 @@

    Method List

  • -
  • +
  • #take Krill::Base @@ -2980,7 +3276,7 @@

    Method List

  • -
  • +
  • #temporary Operation @@ -2988,7 +3284,7 @@

    Method List

  • -
  • +
  • #test OperationType @@ -2996,6 +3292,14 @@

    Method List

  • +
  • +
    + #thread + Krill::ThreadedManager +
    +
  • + +
  • #timer @@ -3030,48 +3334,48 @@

    Method List

  • - #to_s - FieldValue + #to_s + Item
  • - #to_s - Locator + #to_s + Operation
  • - #to_s - Item + #to_s + FieldValue
  • - #to_s - Operation + #to_s + ObjectType
  • - #to_s - Sample + #to_s + Locator
  • - #to_s - ObjectType + #to_s + Sample
  • @@ -3229,6 +3533,14 @@

    Method List

  • +
    + #wait + Krill::ThreadedManager +
    +
  • + + +
  • #waiting OperationType @@ -3236,7 +3548,7 @@

    Method List

  • -
  • +
  • #warning Krill::ShowBlock @@ -3244,7 +3556,7 @@

    Method List

  • -
  • +
  • #week Item @@ -3252,7 +3564,7 @@

    Method List

  • -
  • +
  • #with_input Operation @@ -3260,7 +3572,7 @@

    Method List

  • -
  • +
  • #with_output Operation @@ -3268,7 +3580,7 @@

    Method List

  • -
  • +
  • #with_property Operation @@ -3276,6 +3588,14 @@

    Method List

  • +
  • +
    + with_sample_type + Sample +
    +
  • + + diff --git a/docs/development/index.md b/docs/development/index.md index d2064bf75..ac9b92600 100644 --- a/docs/development/index.md +++ b/docs/development/index.md @@ -210,12 +210,22 @@ This file also limits the API to code used in Krill the protocol development lan ## Making an Aquarium Release -1. (make sure Rails tests pass) +1. make sure Rails tests pass + + ```bash + ./develop-compose.sh exec app rspec + ``` + 2. Run `rubocop`, fix anything broken. Once done run `rubocop --auto-gen-config`. 3. (make sure JS tests pass) 4. Make sure JS linting passes -5. Update the version number in `config/initializers/version.rb` to the new version number. -6. Update API documentation by running `yard` +5. Update the version number in `package.json` and `config/initializers/version.rb` to the new version number. +6. Update API documentation by running + + ```bash + ./develop-compose.sh exec app yard + ``` + 7. (Update change log) 8. Create a tag for the new version: