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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
|
# File 'lib/geoserver_migrations/api_connector.rb', line 18
def execute(ordered_actions, direction = :up, options={})
if direction != :up
ordered_actions = ordered_actions.reverse
end
ordered_actions.each do |action_to_complete|
case action_to_complete[:action]
when :add_resource
file_name = action_to_complete[:params][:name]
if direction == :up
GeoserverClient.create_resource file_name
else
GeoserverClient.delete_resource file_name
end
when :create_layer
layer_name = action_to_complete[:params][:name]
layer_config = action_to_complete[:params][:layer_config]
if direction == :up
if !layer_config.sld.nil?
puts " -- Create style #{layer_config.style_name}"
GeoserverClient.create_style layer_config.style_name, sld: layer_config.sld
end
puts " -- Create layer #{layer_config.layer_name} [native_name = #{layer_config.feature_name}]"
GeoserverClient.create_featuretype layer_name, native_name: layer_config.feature_name
GeoserverClient.set_layer_style layer_name, layer_config.style_name
else
puts " -- delete layer #{layer_config.layer_name}"
GeoserverClient.delete_featuretype layer_name
if !layer_config.sld.nil?
puts " -- delete style #{layer_config.style_name}"
GeoserverClient.delete_style layer_config.style_name
end
end
when :delete_layer
if direction == :up
layer_name = action_to_complete[:params][:name]
puts " -- Delete layer #{layer_name}"
GeoserverClient.delete_featuretype layer_name
else
end
when :delete_style
if direction == :up
style_name = action_to_complete[:params][:name]
puts " -- Delete style #{style_name}"
GeoserverClient.delete_style style_name
end
when :update_style
if direction == :up
style_name = action_to_complete[:params][:name]
layer_config = action_to_complete[:params][:layer_config]
puts " -- Updating style #{style_name}"
GeoserverClient.update_style style_name, sld: layer_config.sld
end
when :create_layergroup
layer_name = action_to_complete[:params][:name]
layer_config = action_to_complete[:params][:layer_config]
if direction == :up
GeoserverClient.create_layergroup layer_name, layer_config.layers
else
puts " -- delete layergroup #{layer_config.layer_name}"
GeoserverClient.delete_layergroup layer_name
end
when :delete_layergroup
if direction == :up
layer_name = action_to_complete[:params][:name]
puts " -- Delete layergroup #{layer_name}"
GeoserverClient.delete_layergroup layer_name
else
end
end
end
end
|