2012-12-02 00:03:21 +01:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
|
|
|
"""
|
|
|
|
***************************************************************************
|
2012-12-03 11:09:54 +01:00
|
|
|
workspace.py
|
2012-12-02 00:03:21 +01:00
|
|
|
---------------------
|
|
|
|
Date : November 2012
|
2012-12-03 09:07:13 +01:00
|
|
|
Copyright : (C) 2012 by David Winslow
|
|
|
|
Email : dwins at opengeo dot com
|
2012-12-02 00:03:21 +01:00
|
|
|
***************************************************************************
|
|
|
|
* *
|
|
|
|
* This program is free software; you can redistribute it and/or modify *
|
|
|
|
* it under the terms of the GNU General Public License as published by *
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or *
|
|
|
|
* (at your option) any later version. *
|
|
|
|
* *
|
|
|
|
***************************************************************************
|
|
|
|
"""
|
|
|
|
|
2012-12-03 09:07:13 +01:00
|
|
|
__author__ = 'David Winslow'
|
2012-12-02 00:03:21 +01:00
|
|
|
__date__ = 'November 2012'
|
2012-12-03 09:07:13 +01:00
|
|
|
__copyright__ = '(C) 2012, David Winslow'
|
2013-10-01 20:52:22 +03:00
|
|
|
|
2012-12-02 00:03:21 +01:00
|
|
|
# This will get replaced with a git SHA1 when you do a git archive
|
2013-10-01 20:52:22 +03:00
|
|
|
|
2012-12-02 00:03:21 +01:00
|
|
|
__revision__ = '$Format:%H$'
|
|
|
|
|
2013-10-01 20:52:22 +03:00
|
|
|
from processing.admintools.geoserver.support import xml_property, write_bool, \
|
|
|
|
ResourceInfo, url
|
|
|
|
|
2012-11-05 20:07:16 +01:00
|
|
|
|
|
|
|
def workspace_from_index(catalog, node):
|
2013-10-01 20:52:22 +03:00
|
|
|
name = node.find('name')
|
2012-11-05 20:07:16 +01:00
|
|
|
return Workspace(catalog, name.text)
|
|
|
|
|
2013-10-01 20:52:22 +03:00
|
|
|
|
2012-12-10 00:12:07 +01:00
|
|
|
class Workspace(ResourceInfo):
|
2013-10-01 20:52:22 +03:00
|
|
|
|
|
|
|
resource_type = 'workspace'
|
2012-11-05 20:07:16 +01:00
|
|
|
|
|
|
|
def __init__(self, catalog, name):
|
|
|
|
super(Workspace, self).__init__()
|
|
|
|
self.catalog = catalog
|
|
|
|
self.name = name
|
|
|
|
|
|
|
|
@property
|
|
|
|
def href(self):
|
2013-10-01 20:52:22 +03:00
|
|
|
return url(self.catalog.service_url, ['workspaces', self.name + '.xml'
|
|
|
|
])
|
2012-11-05 20:07:16 +01:00
|
|
|
|
|
|
|
@property
|
|
|
|
def coveragestore_url(self):
|
2013-10-01 20:52:22 +03:00
|
|
|
return url(self.catalog.service_url, ['workspaces', self.name,
|
|
|
|
'coveragestores.xml'])
|
2012-11-05 20:07:16 +01:00
|
|
|
|
|
|
|
@property
|
|
|
|
def datastore_url(self):
|
2013-10-01 20:52:22 +03:00
|
|
|
return url(self.catalog.service_url, ['workspaces', self.name,
|
|
|
|
'datastores.xml'])
|
2012-11-05 20:07:16 +01:00
|
|
|
|
2013-10-01 20:52:22 +03:00
|
|
|
enabled = xml_property('enabled', lambda x: x.lower() == 'true')
|
|
|
|
writers = dict(enabled=write_bool('enabled'))
|
2012-11-05 20:07:16 +01:00
|
|
|
|
|
|
|
def __repr__(self):
|
2013-10-01 20:52:22 +03:00
|
|
|
return '%s @ %s' % (self.name, self.href)
|