Module: ADIWG::Mdtranslator::Readers::Fgdc::Process

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

Class Method Summary collapse

Class Method Details

.unpack(xProcess, hLineage, hResponseObj) ⇒ Object



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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
# File 'lib/adiwg/mdtranslator/readers/fgdc/modules/module_process.rb', line 19

def self.unpack(xProcess, hLineage, hResponseObj)

   # instance classes needed in script
   intMetadataClass = InternalMetadata.new
   hProcess = intMetadataClass.newProcessStep

   # process 2.5.2.1 (procdesc) - process description (required)
   description = xProcess.xpath('./procdesc').text
   unless description.empty?
      hProcess[:description] = description
   end
   if description.empty?
      hResponseObj[:readerExecutionMessages] << 'WARNING: FGDC reader: lineage process description is missing'
   end

   # process 2.5.2.2 (srcused) - source used citation abbreviation []
   axUsed = xProcess.xpath('./srcused')
   unless axUsed.empty?
      axUsed.each do |xUsed|
         usedSrc = xUsed.text
         unless usedSrc.empty?
            hLineage[:dataSources].each do |hSource|
               unless hSource[:sourceId].nil?
                  if usedSrc == hSource[:sourceId]
                     hProcess[:stepSources] << hSource
                  end
               end
            end
         end
      end
   end

   # process 2.5.2.3/2.5.2.4 (procdate/proctime) - procedure date/time {date} (required) {time} (optional)
   hDateTime = nil
   procDate = xProcess.xpath('./procdate').text
   procTime = xProcess.xpath('./proctime').text
   unless procDate.empty?
      hDateTime = DateTime.unpack(procDate, procTime, hResponseObj)
      unless hDateTime.nil?
         hTimePeriod = intMetadataClass.newTimePeriod
         hTimePeriod[:description] = 'Step completion dateTime'
         hTimePeriod[:endDateTime] = hDateTime
         hProcess[:timePeriod] = hTimePeriod
      end
   end
   if hDateTime.nil?
      hResponseObj[:readerExecutionMessages] << 'WARNING: FGDC reader: lineage procedure date is missing'
   end

   # process 2.5.2.5 (srcprod) - source produced citation abbreviation []
   axProduct = xProcess.xpath('./srcprod')
   unless axProduct.empty?
      axProduct.each do |xProduct|
         prodSrc = xProduct.text
         unless prodSrc.empty?
            hLineage[:dataSources].each do |hSource|
               unless hSource[:sourceId].nil?
                  if prodSrc == hSource[:sourceId]
                     hProcess[:stepProducts] << hSource
                  end
               end
            end
         end
      end
   end

   # process 2.5.2.6 (proccont) - process contact {contact}
   xContact = xProcess.xpath('./proccont')
   unless xContact.empty?
      hResponsibility = Contact.unpack(xContact, hResponseObj)
      unless hResponsibility.nil?
         hResponsibility[:roleName] = 'processor'
         hProcess[:processors] << hResponsibility
      end
   end

   return hProcess

end