Class: ADIWG::Mdtranslator::Writers::Fgdc::Process

Inherits:
Object
  • Object
show all
Defined in:
lib/adiwg/mdtranslator/writers/fgdc/classes/class_process.rb

Instance Method Summary collapse

Constructor Details

#initialize(xml, hResponseObj) ⇒ Process

Returns a new instance of Process.



18
19
20
21
22
# File 'lib/adiwg/mdtranslator/writers/fgdc/classes/class_process.rb', line 18

def initialize(xml, hResponseObj)
   @xml = xml
   @hResponseObj = hResponseObj
   @NameSpace = ADIWG::Mdtranslator::Writers::Fgdc
end

Instance Method Details

#writeXML(hStep) ⇒ Object



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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
# File 'lib/adiwg/mdtranslator/writers/fgdc/classes/class_process.rb', line 24

def writeXML(hStep)

   # classes used
   contactClass = Contact.new(@xml, @hResponseObj)

   # process 2.5.2.1 (procdesc) - process description (required)
   # <- resourceLineage.processStep.description
   unless hStep[:description].nil?
      @xml.tag!('procdesc', hStep[:description] )
   end
   if hStep[:description].nil?
      @NameSpace.issueWarning(240, 'procdesc')
   end

   # process 2.5.2.2 (srcused) - source used citation abbreviation []
   # <- processStep.stepSources.sourceId
   haveSource = false
   hStep[:stepSources].each do |hSource|
      unless hSource[:sourceId].nil?
         @xml.tag!('srcused', hSource[:sourceId])
         haveSource = true
      end
   end
   if !haveSource && @hResponseObj[:writerShowTags]
      @xml.tag!('srcused')
   end

   # process 2.5.2.3 (procdate) - process date (required)
   # process 2.5.2.4 (proctime) - process time
   # <- processStep.timePeriod.endDateTime
   haveProcDate = false
   haveProcTime = false
   unless hStep[:timePeriod].empty?
      hTimePeriod = hStep[:timePeriod]
      unless hTimePeriod.empty?
         hEndDT = hTimePeriod[:endDateTime]
         hEndDT = hTimePeriod[:startDateTime] if hEndDT.nil? || hEndDT.empty?
         unless hEndDT.empty?
            procDate = AdiwgDateTimeFun.stringDateFromDateTime(hEndDT[:dateTime], hEndDT[:dateResolution])
            procTime = AdiwgDateTimeFun.stringTimeFromDateTime(hEndDT[:dateTime], hEndDT[:dateResolution])
            procDate.gsub!(/[-]/,'')
            unless procDate == 'ERROR'
               @xml.tag!('procdate', procDate)
               haveProcDate = true
            end
            unless procTime == 'ERROR'
               @xml.tag!('proctime', procTime)
               haveProcTime = true
            end
         end
      end
   end
   unless haveProcDate
      @NameSpace.issueWarning(241, 'procdate')
   end
   if !haveProcTime && @hResponseObj[:writerShowTags]
      @xml.tag!('proctime')
   end

   # process 2.5.2.5 (srcprod) - source products citation abbreviation []
   # <- processStep.stepProducts.sourceId
   haveSource = false
   hStep[:stepProducts].each do |hSource|
      unless hSource[:sourceId].nil?
         @xml.tag!('srcprod', hSource[:sourceId])
         haveSource = true
      end
   end
   if !haveSource && @hResponseObj[:writerShowTags]
      @xml.tag!('srcprod')
   end

   # process 2.5.2.6 (proccont) - process contact {contact} first
   haveProcessor = false
   aRParties = hStep[:processors]
   aProcessors = @NameSpace.find_responsibility(aRParties, 'processor')
   aProcessors.each do |contactId|
      hContact = @NameSpace.get_contact(contactId)
      unless hContact.empty?
         @xml.tag!('proccont') do
            contactClass.writeXML(hContact)
            haveProcessor = true
            break
         end
      end
   end
   if !haveProcessor && @hResponseObj[:writerShowTags]
      @xml.tag!('proccont')
   end

end