Total Complexity | 8 |
Total Lines | 44 |
Duplicated Lines | 0 % |
1 | require 'jsondoc' |
||
6 | # classifications avaiable at: https://community.versionone.com/Developers/Developer-Library/Concepts/Asset_State |
||
7 | class Asset < JsonDoc::Document |
||
8 | attr_accessor :dSchema |
||
9 | |||
10 | def getDefaultSchema() |
||
11 | dSchema = {} |
||
12 | return dSchema |
||
13 | end |
||
14 | |||
15 | def inflate() |
||
16 | self.inflateNames |
||
17 | self.convertIntegers |
||
18 | end |
||
19 | |||
20 | def convertIntegers() |
||
21 | [:Order,:AssetState].each do |yKey| |
||
22 | xxVal = self.getProp(yKey) |
||
23 | if xxVal.is_a?(String) && xxVal =~ /^-?[0-9]+$/ |
||
24 | xxVal = xxVal.to_i |
||
25 | self.setProp(yKey,xxVal) |
||
26 | end |
||
27 | end |
||
28 | end |
||
29 | |||
30 | def inflateNames() |
||
31 | dAssetState = { |
||
32 | 0 => 'Future', |
||
33 | 64 => 'Active', |
||
34 | 128 => 'Closed', |
||
35 | 200 => 'Template (Dead)', |
||
36 | 208 => 'Broken Down (Dead)', |
||
37 | 255 => 'Deleted (Dead)' |
||
38 | } |
||
39 | if @dDocument.has_key?(:AssetState) |
||
40 | sAssetState = @dDocument[:AssetState] |
||
41 | if sAssetState.is_a?(String) && sAssetState =~ /^[0-9]+$/ |
||
42 | iAssetState = sAssetState.to_i |
||
43 | if dAssetState.has_key?(iAssetState) |
||
44 | sAssetStateName = dAssetState[iAssetState] |
||
45 | self.setProp(:'AssetState.Name',sAssetStateName) |
||
46 | end |
||
47 | end |
||
48 | end |
||
49 | end |
||
50 | end |
||
52 |