Class: ADIWG::Mdtranslator::Writers::Fgdc::TransferInformation

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

Instance Method Summary collapse

Constructor Details

#initialize(xml, hResponseObj) ⇒ TransferInformation

Returns a new instance of TransferInformation.



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

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

Instance Method Details

#writeXML(hTransOpt) ⇒ Object



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
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
127
128
129
130
131
132
133
134
135
# File 'lib/adiwg/mdtranslator/writers/fgdc/classes/class_transferInfo.rb', line 23

def writeXML(hTransOpt)

   hSpec = {}
   unless hTransOpt[:distributionFormats].empty?
      unless hTransOpt[:distributionFormats][0][:formatSpecification].empty?
         hSpec = hTransOpt[:distributionFormats][0][:formatSpecification]
      end
   end

   # transfer information 6.4.2.1.1 (formname) - format name (required)
   # <- formatSpecification.identifier.identifier
   # FGDC requires a format name for digital options (online and offline)
   # the format name is saved in the identifier of the format specification
   # of the first distribution format
   # as backup, allow specification title to serve as format name
   haveId = false
   unless hSpec.empty?
      if hSpec[:identifiers].empty?
         @xml.tag!('formname', hSpec[:title])
         haveId = true
      else
         unless hSpec[:identifiers][0][:identifier].nil?
            @xml.tag!('formname', hSpec[:identifiers][0][:identifier])
            haveId = true
         end
      end
   end
   unless haveId
      @NameSpace.issueWarning(450, 'formname')
   end

   # transfer information 6.4.2.1.2 (formvern) - format version number
   # <- formatSpecification.edition
   haveVersion = false
   unless hSpec.empty?
      unless hSpec[:edition].nil?
         @xml.tag!('formvern', hSpec[:edition])
         haveVersion = true
      end
   end
   if !haveVersion && @hResponseObj[:writerShowTags]
      @xml.tag!('formvern')
   end

   # transfer information 6.4.2.1.3 (formverd) - format version date
   # <- formatSpecification.dates[].dateType='revision'
   haveRevDate = false
   unless hSpec.empty?
      hSpec[:dates].each do |hDate|
         if hDate[:dateType] == 'revision'
            revDate = AdiwgDateTimeFun.stringDateFromDateTime(hDate[:date], hDate[:dateResolution])
            revDate.gsub!(/[-]/,'')
            unless revDate == 'ERROR'
               @xml.tag!('formverd', revDate)
               haveRevDate = true
            end
            break
         end
      end
   end
   if !haveRevDate && @hResponseObj[:writerShowTags]
      @xml.tag!('formverd')
   end

   # transfer information 6.4.2.1.4 (formspec) - format specification
   # <- formatSpecification.title
   haveTitle = false
   unless hSpec.empty?
      unless hSpec[:title].nil?
         @xml.tag!('formspec', hSpec[:title])
         haveTitle = true
      end
   end
   if !haveTitle && @hResponseObj[:writerShowTags]
      @xml.tag!('formspec')
   end

   # transfer information 6.4.2.1.5 (formcont) - format information content
   # <- formatSpecification.otherDetails[0]
   haveContent = false
   unless hSpec.empty?
      unless hSpec[:otherDetails].empty?
         @xml.tag!('formcont', hSpec[:otherDetails][0])
         haveContent = true
      end
   end
   if !haveContent && @hResponseObj[:writerShowTags]
      @xml.tag!('formcont')
   end

   # transfer information 6.4.2.1.6 (filedec) - decompression method
   # <- transferOption.distributionFormat[0].compressionMethod
   haveCompress = false
   unless hTransOpt[:distributionFormats].empty?
      unless hTransOpt[:distributionFormats][0][:compressionMethod].nil?
         @xml.tag!('filedec',hTransOpt[:distributionFormats][0][:compressionMethod])
         haveCompress = true
      end
   end
   if !haveCompress && @hResponseObj[:writerShowTags]
      @xml.tag!('filedec')
   end

   # transfer information 6.4.2.1.7 (transize) - transfer size
   # <- transferOption.transferSize
   unless hTransOpt[:transferSize].nil?
      @xml.tag!('transize', hTransOpt[:transferSize])
   end
   if hTransOpt[:transferSize].nil? && @hResponseObj[:writerShowTags]
      @xml.tag!('transize')
   end

end