Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
cleaned code in geoserver algs
  • Loading branch information
volaya committed Nov 5, 2012
1 parent 983535f commit d53f123
Show file tree
Hide file tree
Showing 7 changed files with 76 additions and 29 deletions.
2 changes: 1 addition & 1 deletion python/plugins/sextante/r/EditRScriptDialog.py
Expand Up @@ -92,7 +92,7 @@ def saveAlgorithm(self):

if self.filename:
if not self.filename.endswith(".rsx"):
self.filename += ".rsx"
self.filename += ".rsx"
text = str(self.text.toPlainText())
if self.alg is not None:
self.alg.script = text
Expand Down
7 changes: 1 addition & 6 deletions python/plugins/sextante/servertools/DeleteDatastore.py
Expand Up @@ -16,27 +16,22 @@
* *
***************************************************************************
"""
from sextante.servertools.GeoServerToolsAlgorithm import GeoServerToolsAlgorithm

__author__ = 'Victor Olaya'
__date__ = 'October 2012'
__copyright__ = '(C) 2012, Victor Olaya'
# This will get replaced with a git SHA1 when you do a git archive
__revision__ = '$Format:%H$'

import os
from qgis.core import *
from PyQt4 import QtGui
from sextante.parameters.ParameterString import ParameterString
from sextante.servertools.GeoServerToolsAlgorithm import GeoServerToolsAlgorithm

class DeleteDatastore(GeoServerToolsAlgorithm):

DATASTORE = "DATASTORE"
WORKSPACE = "WORKSPACE"

def getIcon(self):
return QtGui.QIcon(os.path.dirname(__file__) + "/../images/geoserver.png")

def processAlgorithm(self, progress):
self.createCatalog()
datastoreName = self.getParameterValue(self.DATASTORE)
Expand Down
5 changes: 0 additions & 5 deletions python/plugins/sextante/servertools/DeleteWorkspace.py
Expand Up @@ -24,18 +24,13 @@
# This will get replaced with a git SHA1 when you do a git archive
__revision__ = '$Format:%H$'

import os
from qgis.core import *
from PyQt4 import QtGui
from sextante.parameters.ParameterString import ParameterString

class DeleteWorkspace(GeoServerToolsAlgorithm):

WORKSPACE = "WORKSPACE"

def getIcon(self):
return QtGui.QIcon(os.path.dirname(__file__) + "/../images/geoserver.png")

def processAlgorithm(self, progress):
self.createCatalog()
workspaceName = self.getParameterValue(self.WORKSPACE)
Expand Down
Expand Up @@ -16,28 +16,31 @@
* *
***************************************************************************
"""
from sextante.servertools.CreateWorkspace import CreateWorkspace
from sextante.servertools.ImportVectorIntoGeoServer import ImportVectorIntoGeoServer
from sextante.servertools.ImportRasterIntoGeoServer import ImportRasterIntoGeoServer
from sextante.servertools.DeleteWorkspace import DeleteWorkspace
from sextante.servertools.DeleteDatastore import DeleteDatastore

__author__ = 'Victor Olaya'
__date__ = 'October 2012'
__copyright__ = '(C) 2012, Victor Olaya'
# This will get replaced with a git SHA1 when you do a git archive
__revision__ = '$Format:%H$'


import os
from sextante.servertools.CreateWorkspace import CreateWorkspace
from sextante.servertools.ImportVectorIntoGeoServer import ImportVectorIntoGeoServer
from sextante.servertools.ImportRasterIntoGeoServer import ImportRasterIntoGeoServer
from sextante.servertools.DeleteWorkspace import DeleteWorkspace
from sextante.servertools.DeleteDatastore import DeleteDatastore
from sextante.servertools.StyleGeoServerLayer import StyleGeoServerLayer
from sextante.core.AlgorithmProvider import AlgorithmProvider
from PyQt4 import QtGui
import os

class GeoServerToolsAlgorithmProvider(AlgorithmProvider):

def __init__(self):
AlgorithmProvider.__init__(self)
self.alglist = [ImportVectorIntoGeoServer(), ImportRasterIntoGeoServer(),
CreateWorkspace(), DeleteWorkspace(), DeleteDatastore()]#, CreateMosaicGeoserver(), StyleGeoserverLayer(), TruncateSeedGWC()]
CreateWorkspace(), DeleteWorkspace(), DeleteDatastore(),
StyleGeoServerLayer()]#, TruncateSeedGWC()]

def initializeSettings(self):
AlgorithmProvider.initializeSettings(self)
Expand Down
10 changes: 4 additions & 6 deletions python/plugins/sextante/servertools/ImportRasterIntoGeoServer.py
Expand Up @@ -16,10 +16,6 @@
* *
***************************************************************************
"""
from sextante.core.LayerExporter import LayerExporter
from sextante.parameters.ParameterString import ParameterString
from sextante.servertools.GeoServerToolsAlgorithm import GeoServerToolsAlgorithm
from sextante.parameters.ParameterRaster import ParameterRaster

__author__ = 'Victor Olaya'
__date__ = 'October 2012'
Expand All @@ -28,18 +24,20 @@
__revision__ = '$Format:%H$'

from qgis.core import *
from sextante.parameters.ParameterString import ParameterString
from sextante.servertools.GeoServerToolsAlgorithm import GeoServerToolsAlgorithm
from sextante.parameters.ParameterRaster import ParameterRaster


class ImportRasterIntoGeoServer(GeoServerToolsAlgorithm):

INPUT = "INPUT"
WORKSPACE = "WORKSPACE"
NAME = "NAME"


def exportRasterLayer(self, inputFilename):
return inputFilename


def processAlgorithm(self, progress):
self.createCatalog()
inputFilename = self.getParameterValue(self.INPUT)
Expand Down
Expand Up @@ -16,20 +16,20 @@
* *
***************************************************************************
"""
from sextante.core.LayerExporter import LayerExporter
from sextante.parameters.ParameterString import ParameterString
from sextante.servertools.GeoServerToolsAlgorithm import GeoServerToolsAlgorithm

__author__ = 'Victor Olaya'
__date__ = 'October 2012'
__copyright__ = '(C) 2012, Victor Olaya'
# This will get replaced with a git SHA1 when you do a git archive
__revision__ = '$Format:%H$'

import os
from qgis.core import *
from sextante.parameters.ParameterVector import ParameterVector
from sextante.core.QGisLayers import QGisLayers
import os
from sextante.core.LayerExporter import LayerExporter
from sextante.parameters.ParameterString import ParameterString
from sextante.servertools.GeoServerToolsAlgorithm import GeoServerToolsAlgorithm

class ImportVectorIntoGeoServer(GeoServerToolsAlgorithm):

Expand Down
56 changes: 56 additions & 0 deletions python/plugins/sextante/servertools/StyleGeoServerLayer.py
@@ -0,0 +1,56 @@
# -*- coding: utf-8 -*-

"""
***************************************************************************
DeleteDatastore.py
---------------------
Date : October 2012
Copyright : (C) 2012 by Victor Olaya
Email : volayaf at gmail dot com
***************************************************************************
* *
* 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. *
* *
***************************************************************************
"""

__author__ = 'Victor Olaya'
__date__ = 'October 2012'
__copyright__ = '(C) 2012, Victor Olaya'
# This will get replaced with a git SHA1 when you do a git archive
__revision__ = '$Format:%H$'

from qgis.core import *
from sextante.parameters.ParameterString import ParameterString
from sextante.servertools.GeoServerToolsAlgorithm import GeoServerToolsAlgorithm
from sextante.parameters.ParameterFile import ParameterFile
from sextante.parameters.ParameterBoolean import ParameterBoolean


class StyleGeoServerLayer(GeoServerToolsAlgorithm):

STYLE = "STYLE"
OVERWRITE = "OVERWRITE"
NAME = "NAME"

def processAlgorithm(self, progress):
self.createCatalog()
stylefile = self.getParameterValue(self.STYLE)
overwrite = self.getParameterValue(self.OVERWRITE)
name = self.getParameterValue(self.NAME)
self.catalog.create_style(name, stylefile, overwrite)


def defineCharacteristics(self):
self.addBaseParameters()
self.name = "Add style"
self.group = "GeoServer management tools"
self.addParameter(ParameterString(self.NAME, "Style name"))
self.addParameter(ParameterFile(self.STYLE, "Style SLD file"))
self.addParameter(ParameterBoolean(self.OVERWRITE, "Overwrite"))



0 comments on commit d53f123

Please sign in to comment.