Class: RGeoServer::Workspace
Overview
A workspace is a grouping of data stores. More commonly known as a namespace, it is commonly used to group data that is related in some way.
Constant Summary
collapse
- OBJ_ATTRIBUTES =
{
:enabled => 'enabled',
:catalog => 'catalog',
:name => 'name'
}
- OBJ_DEFAULT_ATTRIBUTES =
{
:enabled => 'true',
:catalog => nil,
:name => nil
}
- @@route =
"workspaces"
- @@resource_name =
"workspace"
Instance Attribute Summary
Attributes inherited from ResourceInfo
#catalog
Class Method Summary
collapse
Instance Method Summary
collapse
#clear, #create_method, #delete, list, #new?, #profile, #profile=, #profile_xml_to_ng, #refresh, #save, #to_s, update_attribute_accessors, #update_method, #update_params
Constructor Details
#initialize(catalog, options) ⇒ Workspace
Returns a new instance of Workspace.
51
52
53
54
55
56
57
|
# File 'lib/rgeoserver/workspace.rb', line 51
def initialize catalog, options
super(catalog)
_run_initialize_callbacks do
@name = options[:name].strip
end
@route = route
end
|
Class Method Details
.member_xpath ⇒ Object
31
32
33
|
# File 'lib/rgeoserver/workspace.rb', line 31
def self.member_xpath
"//#{resource_name}"
end
|
.resource_name ⇒ Object
23
24
25
|
# File 'lib/rgeoserver/workspace.rb', line 23
def self.resource_name
@@resource_name
end
|
.root_xpath ⇒ Object
27
28
29
|
# File 'lib/rgeoserver/workspace.rb', line 27
def self.root_xpath
"//#{@@route}/#{@@resource_name}"
end
|
Instance Method Details
#coverage_stores(&block) ⇒ Object
63
64
65
|
# File 'lib/rgeoserver/workspace.rb', line 63
def coverage_stores &block
self.class.list CoverageStore, @catalog, profile['coverageStores'], {:workspace => self}, true, &block
end
|
#data_stores(&block) ⇒ Object
59
60
61
|
# File 'lib/rgeoserver/workspace.rb', line 59
def data_stores &block
self.class.list DataStore, @catalog, profile['dataStores'], {:workspace => self}, true, &block
end
|
#message ⇒ Object
39
40
41
42
43
44
45
46
47
|
# File 'lib/rgeoserver/workspace.rb', line 39
def message
builder = Nokogiri::XML::Builder.new do |xml|
xml.workspace {
xml.enabled @enabled if enabled_changed?
xml.name @name
}
end
return builder.doc.to_xml
end
|
#profile_xml_to_hash(profile_xml) ⇒ Object
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
|
# File 'lib/rgeoserver/workspace.rb', line 71
def profile_xml_to_hash profile_xml
doc = profile_xml_to_ng profile_xml
h = {
'name' => doc.at_xpath('//name').text.strip,
'enabled' => @enabled
}
doc.xpath('//atom:link/@href', "xmlns:atom"=>"http://www.w3.org/2005/Atom").each{ |l|
target = l.text.match(/([a-zA-Z]+)\.xml$/)[1]
if !target.nil? && target != l.parent.parent.name.to_s.downcase
begin
h[l.parent.parent.name.to_s] << target
rescue
h[l.parent.parent.name.to_s] = []
end
else
h[l.parent.parent.name.to_s] = begin
response = @catalog.do_url l.text
Nokogiri::XML(response).xpath('//name').collect{ |a| a.text.strip }
rescue RestClient::ResourceNotFound
[]
end.freeze
end
}
h
end
|
#route ⇒ Object
35
36
37
|
# File 'lib/rgeoserver/workspace.rb', line 35
def route
@@route
end
|
#wms_stores(&block) ⇒ Object
67
68
69
|
# File 'lib/rgeoserver/workspace.rb', line 67
def wms_stores &block
self.class.list WmsStore, @catalog, profile['wmsStores'], {:workspace => self}, true, &block
end
|