Ejemplo n.º 1
0
def create_datastore(sync_job, task_metadata, task_status):
    name = store_name(sync_job)
    try:
        d_gs = gs.get_store(name)
    except:
        d_gs = gs.create_datastore(name, sync_job["workspace"])

    d_gs.connection_parameters = dict(GEOSERVER_PGSQL_CONNECTION_DEFAULTS)
    d_gs.connection_parameters.update(
        {"schema": sync_job["schema"], "namespace": GEOSERVER_WORKSPACE_NAMESPACE.format(sync_job["workspace"])}
    )
    gs.save(d_gs)
    d_gs = gs.get_store(name)
    if not d_gs:
        raise Exception("Create data store for workspace({0}) in geoserver failed.".format(sync_job["workspace"]))
def create_datastore(sync_job, task_metadata, task_status):
    name = store_name(sync_job)
    try:
        d_gs = gs.get_store(name)
    except:
        d_gs = gs.create_datastore(name, sync_job["workspace"])

    d_gs.connection_parameters = dict(GEOSERVER_PGSQL_CONNECTION_DEFAULTS)

    for k in d_gs.connection_parameters.iterkeys():
        if k in sync_job:
            d_gs.connection_parameters[k] = str(sync_job[k])

    d_gs.connection_parameters["namespace"] = GEOSERVER_WORKSPACE_NAMESPACE.format(sync_job["workspace"])

    if "geoserver_setting" in sync_job:
        for k, v in sync_job["geoserver_setting"].iteritems():
            d_gs.connection_parameters[k] = str(v)
    gs.save(d_gs)
    d_gs = gs.get_store(name)
    if not d_gs:
        raise Exception("Create data store for workspace({0}) in geoserver failed.".format(sync_job["workspace"]))