Esempio n. 1
0
 def publishProject(self, tree, explorer):
     layers = qgislayers.getAllLayers()
     dlg = PublishProjectDialog(explorer.catalogs())
     dlg.exec_()
     catalog = dlg.catalog
     if catalog is None:
         return
     workspace = dlg.workspace
     groupName = dlg.groupName
     explorer.setProgressMaximum(len(layers), "Publish layers")
     progress = 0
     ogcat = OGCatalog(catalog)
     for layer in layers:
         explorer.setProgress(progress)
         if not explorer.run(publishLayer, None, [], ogcat, layer,
                             workspace, True):
             explorer.setProgress(0)
             return
         progress += 1
         explorer.setProgress(progress)
     explorer.resetActivity()
     groups = qgislayers.getGroups()
     for group in groups:
         names = [layer.name() for layer in groups[group]]
         try:
             layergroup = catalog.create_layergroup(group, names, names)
             explorer.run(catalog.save,
                          "Create layer group '" + group + "'", [],
                          layergroup)
         except ConflictingDataError, e:
             explorer.setWarning(str(e))
 def publishProject(self, tree, explorer):        
     layers = qgislayers.getAllLayers()                
     dlg = PublishProjectDialog(explorer.catalogs())
     dlg.exec_()   
     catalog  = dlg.catalog
     if catalog is None:
         return
     workspace = dlg.workspace
     groupName = dlg.groupName
     explorer.setProgressMaximum(len(layers), "Publish layers")
     progress = 0
     ogcat = OGCatalog(catalog)                    
     for layer in layers:
         explorer.setProgress(progress)                                         
         if not explorer.run(publishLayer,
                  None, 
                  [],
                  ogcat, layer, workspace, True):
             explorer.setProgress(0)
             return
         progress += 1                
         explorer.setProgress(progress)  
     explorer.resetActivity()
     groups = qgislayers.getGroups()
     for group in groups:
         names = [layer.name() for layer in groups[group]] 
         try:
             layergroup = catalog.create_layergroup(group, names, names)
             explorer.run(catalog.save, "Create layer group '" + group + "'", 
                  [], layergroup)
         except ConflictingDataError, e:
             explorer.setWarning(str(e))
 def publishProject(self, tree, explorer):        
     layers = qgislayers.getAllLayers()                
     dlg = PublishProjectDialog(explorer.catalogs())
     dlg.exec_()     
     catalog  = dlg.catalog
     if catalog is None:
         return
     workspace = dlg.workspace
     groupName = dlg.groupName
     explorer.setProgressMaximum(len(layers), "Publish layers")
     progress = 0                    
     for layer in layers:
         explorer.setProgress(progress)            
         ogcat = OGCatalog(catalog)                 
         if not explorer.run(ogcat.publishLayer,
                  None, #"Publish layer '" + layer.name() + "'",
                  [],
                  layer, workspace, True):
             explorer.setProgress(0)
             return
         progress += 1                
         explorer.setProgress(progress)  
     explorer.resetActivity()
     groups = qgislayers.getGroups()
     for group in groups:
         names = [layer.name() for layer in groups[group]] 
         layergroup = catalog.create_layergroup(group, names, names)
         explorer.run(catalog.save, "Create layer group '" + group + "'", 
                  [], layergroup)
     
     if groupName is not None:
         names = [layer.name() for layer in layers]      
         layergroup = catalog.create_layergroup(groupName, names, names)
         explorer.run(catalog.save, "Create global layer group", 
                  [], layergroup)                
     tree.findAllItems(catalog)[0].refreshContent(explorer)                                                
Esempio n. 4
0
def publishProject(tree, explorer):
    layers = qgislayers.getAllLayers()
    if not layers:
        return

    dlg = PublishProjectDialog(explorer.catalogs())
    dlg.exec_()
    catalog = dlg.catalog
    if catalog is None:
        return
    workspace = dlg.workspace
    groupName = dlg.groupName
    ogcat = OGCatalog(catalog)

    groups = qgislayers.getGroups()
    grouplyrs = []
    for group in groups:
        grouplyrs.extend([layer for layer in groups[group]])

    ungroupedlyrs = [layer for layer in layers if layer not in grouplyrs]
    publishedLyrs = []

    if ungroupedlyrs:
        lyrsdlg = PublishLayersDialog(
            {0: catalog}, ungroupedlyrs, workspace=workspace, overwrite=False)
        lyrsdlg.exec_()
        toPublish = lyrsdlg.topublish
        if toPublish is None:
            return

        explorer.setProgressMaximum(len(toPublish), "Publish ungrouped layer")
        progress = 0
        for layer, catalog, workspace, layername in toPublish:
            publishedLyrs.append(layername)
            explorer.setProgress(progress)
            if not explorer.run(ogcat.publishLayer,
                                None,
                                [],
                                layer, workspace, True, layername):
                explorer.setProgress(0)
                return
            progress += 1
            explorer.setProgress(progress)
        explorer.resetActivity()

    for group in groups:
        grouplyrs = [layer for layer in groups[group]]
        if not grouplyrs:
            continue  # don't publish empty groups, when publishing project

        dlg = PublishLayerGroupDialog(catalog, group, grouplyrs,
                                      workspace=workspace,
                                      overwritegroup=False,
                                      overwritelayers=False)
        dlg.exec_()
        grpName = dlg.definedname
        toPublish = dlg.topublish
        if grpName is None:  # toPublish can be empty list
            return

        explorer.setProgressMaximum(len(toPublish), "Publish grouped layer")
        progress = 0
        layernames = []
        for layer, catalog, workspace, layername in toPublish:
            layernames.append(layername)
            publishedLyrs.append(layername)
            explorer.setProgress(progress)
            if not explorer.run(ogcat.publishLayer,
                                None,
                                [],
                                layer, workspace, True, layername):
                explorer.setProgress(0)
                return
            progress += 1
            explorer.setProgress(progress)
        explorer.resetActivity()
        names = reversed(layernames)

        layergroup = catalog.create_layergroup(grpName, names, names)
        if not explorer.run(catalog.save,
                            "Create layer group from group '" + group + "'",
                            [],
                            layergroup):
            return

    if groupName is not None:
        names = reversed(publishedLyrs)
        layergroup = catalog.create_layergroup(groupName, names, names)
        if not explorer.run(catalog.save,
                            "Create global layer group",
                            [],
                            layergroup):
            return

    tree.findAllItems(catalog)[0].refreshContent(explorer)
    explorer.setInfo("Project published")