Module: ADIWG::Mdtranslator::Readers::Fgdc::OrderProcess

Defined in:
lib/adiwg/mdtranslator/readers/fgdc/modules/module_orderProcess.rb

Class Method Summary collapse

Class Method Details

.unpack(xOrder, hDistributor, techPre, hResponseObj) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
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
76
77
78
79
80
# File 'lib/adiwg/mdtranslator/readers/fgdc/modules/module_orderProcess.rb', line 18

def self.unpack(xOrder, hDistributor, techPre, hResponseObj)

   # instance classes needed in script
   intMetadataClass = .new
   hOrder = intMetadataClass.newOrderProcess

   # distribution 6.4.1 (nondig) - non-digital form
   # -> place as offline option
   # -> distribution.distributor.transferOption.offlineOption.note
   nonDigital = xOrder.xpath('./nondig').text
   unless nonDigital.empty?
      hTransfer = intMetadataClass.newTransferOption
      hOffline = intMetadataClass.newMedium
      hOffline[:note] = nonDigital
      hTransfer[:offlineOptions] << hOffline
      hDistributor[:transferOptions] << hTransfer
   end

   # distribution 6.4.2 (digform) - digital form []
   axDigital = xOrder.xpath('./digform')
   unless axDigital.empty?
      axDigital.each do |xDigiForm|
         hReturn = DigitalForm.unpack(xDigiForm, techPre, hResponseObj)
         unless hReturn.nil?
            hDistributor[:transferOptions] << hReturn
         end
      end
   end

   # error messages
   if nonDigital.empty? && axDigital.empty?
      hResponseObj[:readerExecutionMessages] << 'WARNING: FGDC reader: standard order process digital/non-digital form is missing'
   end

   # distribution 6.4.3 (fees) - fees (required)
   # -> distribution.distributor.orderProcess.fees
   fees = xOrder.xpath('./fees').text
   unless fees.empty?
      hOrder[:fees] = fees
   end
   if fees.empty?
      hResponseObj[:readerExecutionMessages] << 'WARNING: FGDC reader: standard order process fee is missing'
   end

   # distribution 6.4.4 (ordering) - ordering information
   # -> distribution.distributor.orderProcess.orderingInstructions
   instructions = xOrder.xpath('./ordering').text
   unless instructions.empty?
      hOrder[:orderingInstructions] = instructions
   end

   # distribution 6.4.5 (turnarnd) - turnaround time
   # -> distribution.distributor.orderProcess.turnaround
   turnaround = xOrder.xpath('./turnarnd').text
   unless turnaround.empty?
      hOrder[:turnaround] = turnaround
   end

   hDistributor[:orderProcess] << hOrder

   return hDistributor

end