All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.disy.ogc.wps.v_1_0_0.DefaultDescribeProcessService Maven / Gradle / Ivy

There is a newer version: 2.0.0
Show newest version
/**
 * Legato is a configurable, lightweight web mapping client that can be
 * easily embedded into web pages and portals, CMS and individual web
 * applications. Legato is implemented in JavaScript and based on the
 * popular open source library OpenLayers.
 *
 * Copyright (C) 2010  disy Informationssysteme GmbH, http://www.disy.net
 *
 * 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 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see .
 */

package net.disy.ogc.wps.v_1_0_0;

import java.util.ArrayList;
import java.util.List;
import java.util.Locale;

import net.disy.ogc.ows.v_1_1_0.InvalidParameterValueException;
import net.disy.ogc.ows.v_1_1_0.MissingParameterValueException;
import net.disy.ogc.ows.v_1_1_0.OwsException;
import net.disy.ogc.ows.v_1_1_0.util.OwsUtils;
import net.opengis.ows.v_1_1_0.CodeType;
import net.opengis.wps.v_1_0_0.DescribeProcess;
import net.opengis.wps.v_1_0_0.ProcessDescriptions;

public class DefaultDescribeProcessService implements DescribeProcessService {

  private WpsProcessRegistry wpsProcessRegistry;

  public WpsProcessRegistry getWpsProcessRegistry() {
    return wpsProcessRegistry;
  }

  public void setWpsProcessRegistry(WpsProcessRegistry wpsProcessRegistry) {
    this.wpsProcessRegistry = wpsProcessRegistry;
  }

  private Locale defaultLanguage;

  public Locale getDefaultLanguage() {
    return defaultLanguage;
  }

  public void setDefaultLanguage(Locale defaultLanguage) {
    this.defaultLanguage = defaultLanguage;
  }

  @Override
  public ProcessDescriptions execute(DescribeProcess request) throws OwsException {

    final List identifiers = request.getIdentifier();
    if (identifiers.isEmpty()) {
      throw new MissingParameterValueException("identifier"); //$NON-NLS-1$
    }

    final List processes = new ArrayList(identifiers.size());

    for (CodeType identifier : identifiers) {
      if (identifier.getCodeSpace() == null && "ALL".equals(identifier.getValue())) { //$NON-NLS-1$
        processes.addAll(getWpsProcessRegistry().getProcesses());
      }
      else {
        final WpsProcess process = getWpsProcessRegistry().getProcessByIdentifier(identifier);
        if (process == null) {
          // TODO
          throw new InvalidParameterValueException("identifier", OwsUtils.toString(identifier)); //$NON-NLS-1$
        }
        processes.add(process);
      }
    }
    final ProcessDescriptions response = new ProcessDescriptions();
    response.setService("WPS"); //$NON-NLS-1$
    response.setVersion("1.0.0"); //$NON-NLS-1$
    if (getDefaultLanguage() != null) {
      response.setLang(getDefaultLanguage().toString());
    }
    for (WpsProcess process : processes) {
      response.getProcessDescription().add(process.getProcessDescription());
    }
    return response;
  }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy