@SuppressWarnings("unchecked") public Map<String, Parameter<?>> getResultInfo(Name name, Map<String, Object> parameters) throws IllegalArgumentException { Method method = method(name.getLocalPart()); DescribeResult info = (DescribeResult) annotation; addResult(method, result, info); } else if (annotation instanceof DescribeResults) { DescribeResults info = (DescribeResults) annotation; for (DescribeResult dr : info.value()) { addResult(method, result, dr);
/** * Cerate a process (for the indicated name). * * <p>Subclasses can control the process using their implementation of: * * <ul> * <li>{@ #method(String)}: must return a non null method * <li>{@link #createProcessBean(Name)}: return a bean to use; or null for static methods * </ul> */ public Process create(Name name) { String methodName = name.getLocalPart(); Method meth = method(methodName); Object process = createProcessBean(name); if (process != null && (lookupInvertGridGeometry(process, meth.getName()) != null || lookupInvertQuery(process, meth.getName()) != null || lookupCustomizeReadParams(process, meth.getName()) != null)) { return new InvokeMethodRenderingProcess(meth, process); } else { return new InvokeMethodProcess(meth, process); } }
/** * Uses the provided path to look up a constant of the specified type. If the path * * @param strDefault * @param type * @return */ private Object lookupConstant(String path, Class<?> process, Class<?> type) { int hashIdx = path.indexOf("#"); if (hashIdx == -1) { // simple reference into the target type, let's see if the constant is is the // process class Object result = getConstantValue(path, process, type); if (result == null) { // see if it's in the target class then result = getConstantValue(path, type, type); } return result; } else { // an absolute reference String className = path.substring(0, hashIdx); String field = path.substring(hashIdx + 1); try { Class holder = Class.forName(className); return getConstantValue(field, holder, type); } catch (ClassNotFoundException e) { throw new IllegalArgumentException("Failed to locate class " + className); } } }
public Map<String, Parameter<?>> getParameterInfo(Name name) { // build the parameter descriptions by using the DescribeParameter // annotations Method method = method(name.getLocalPart()); Map<String, Parameter<?>> input = new LinkedHashMap<String, Parameter<?>>(); Annotation[][] params = method.getParameterAnnotations(); Class<?>[] paramTypes = getMethodParamTypes(method); for (int i = 0; i < paramTypes.length; i++) { if (!(ProgressListener.class.isAssignableFrom(paramTypes[i]))) { Parameter<?> param = paramInfo(method.getDeclaringClass(), i, paramTypes[i], params[i]); input.put(param.key, param); } } return input; }
public String getVersion(Name name) { DescribeProcess info = getProcessDescription(name); if (info != null) { return info.version(); } else { return null; } }
defaultValue = lookupConstant(strDefault, process, type); fillParameterMetadata(meta, metadata);
public Query invertQuery( Map<String, Object> input, Query targetQuery, GridGeometry targetGridGeometry) throws ProcessException { Method invertQueryMethod = lookupInvertQuery(targetObject, method.getName()); if (invertQueryMethod == null) { return targetQuery; } try { Object[] args = buildProcessArguments(invertQueryMethod, input, null, true); args[args.length - 2] = targetQuery; args[args.length - 1] = targetGridGeometry; return (Query) invertQueryMethod.invoke(targetObject, args); } catch (IllegalAccessException e) { throw new ProcessException(e); } catch (InvocationTargetException e) { Throwable t = e.getTargetException(); if (t instanceof ProcessException) { throw ((ProcessException) t); } else { throw new ProcessException(t); } } }
public GridGeometry invertGridGeometry( Map<String, Object> input, Query targetQuery, GridGeometry targetGridGeometry) throws ProcessException { Method invertGridGeometryMethod = lookupInvertGridGeometry(targetObject, this.method.getName()); if (invertGridGeometryMethod == null) { return targetGridGeometry; } try { Object[] args = buildProcessArguments(invertGridGeometryMethod, input, null, true); args[args.length - 2] = targetQuery; args[args.length - 1] = targetGridGeometry; return (GridGeometry) invertGridGeometryMethod.invoke(targetObject, args); } catch (IllegalAccessException e) { throw new ProcessException(e); } catch (InvocationTargetException e) { Throwable t = e.getTargetException(); if (t instanceof ProcessException) { throw ((ProcessException) t); } else { throw new ProcessException(t); } } }
@Override public GeneralParameterValue[] customizeReadParams( Map<String, Object> input, GridCoverageReader reader, GeneralParameterValue[] params) { Method customizeReadParamsMethod = lookupCustomizeReadParams(targetObject, this.method.getName()); if (customizeReadParamsMethod == null) { return params; } try { Object[] args = buildProcessArguments(customizeReadParamsMethod, input, null, true); args[args.length - 2] = reader; args[args.length - 1] = params; return (GeneralParameterValue[]) customizeReadParamsMethod.invoke(targetObject, args); } catch (IllegalAccessException e) { throw new ProcessException(e); } catch (InvocationTargetException e) { Throwable t = e.getTargetException(); if (t instanceof ProcessException) { throw ((ProcessException) t); } else { throw new ProcessException(t); } } } }
private void addResult(Method method, Map<String, Parameter<?>> result, DescribeResult info) { Class resultType = info.type(); if (Object.class.equals(resultType)) { resultType = method.getReturnType(); } // metadata Map<String, Object> metadata = null; if (info != null && info.meta() != null && info.meta().length > 0) { String[] meta = info.meta(); metadata = new HashMap<String, Object>(); fillParameterMetadata(meta, metadata); } int min = info.primary() ? 0 : 1; Parameter resultParam = new Parameter( info.name(), resultType, new SimpleInternationalString(info.name()), new SimpleInternationalString(info.description()), min > 0, min, 1, null, metadata); result.put(resultParam.key, resultParam); }
public InternationalString getTitle(Name name) { DescribeProcess info = getProcessDescription(name); if (info != null) { return new SimpleInternationalString(info.title()); } else { return null; } }
public Query invertQuery(Map<String, Object> input, Query targetQuery, GridGeometry targetGridGeometry) throws ProcessException { Method invertQueryMethod = lookupInvertQuery(targetObject, method.getName() ); if (invertQueryMethod == null) { return targetQuery; } try { Object[] args = buildProcessArguments(invertQueryMethod, input, null, true); args[args.length - 2] = targetQuery; args[args.length - 1] = targetGridGeometry; return (Query) invertQueryMethod.invoke(targetObject, args); } catch (IllegalAccessException e) { throw new ProcessException(e); } catch (InvocationTargetException e) { Throwable t = e.getTargetException(); if (t instanceof ProcessException) { throw ((ProcessException) t); } else { throw new ProcessException(t); } } }
public GridGeometry invertGridGeometry(Map<String, Object> input, Query targetQuery, GridGeometry targetGridGeometry) throws ProcessException { Method invertGridGeometryMethod = lookupInvertGridGeometry(targetObject, this.method.getName() ); if (invertGridGeometryMethod == null) { return targetGridGeometry; } try { Object[] args = buildProcessArguments(invertGridGeometryMethod, input, null, true); args[args.length - 2] = targetQuery; args[args.length - 1] = targetGridGeometry; return (GridGeometry) invertGridGeometryMethod.invoke(targetObject, args); } catch (IllegalAccessException e) { throw new ProcessException(e); } catch (InvocationTargetException e) { Throwable t = e.getTargetException(); if (t instanceof ProcessException) { throw ((ProcessException) t); } else { throw new ProcessException(t); } } }
/** * Cerate a process (for the indicated name). * <p> * Subclasses can control the process using their implementation of: * <ul> * <li>{@ #method(String)}: must return a non null method</li> * <li>{@link #createProcessBean(Name)}: return a bean to use; or null for static methods</li> * </ul> */ public Process create(Name name) { String methodName = name.getLocalPart(); Method meth = method(methodName); Object process = createProcessBean(name); if (process != null && (lookupInvertGridGeometry(process, meth.getName()) != null || lookupInvertQuery(process, meth.getName()) != null)) { return new InvokeMethodRenderingProcess(meth, process); } else { return new InvokeMethodProcess(meth, process); } }
@SuppressWarnings("unchecked") public Map<String, Parameter<?>> getResultInfo(Name name, Map<String, Object> parameters) throws IllegalArgumentException { Method method = method(name.getLocalPart()); DescribeResult info = (DescribeResult) annotation; addResult(method, result, info); } else if(annotation instanceof DescribeResults) { DescribeResults info = (DescribeResults) annotation; for (DescribeResult dr : info.value()) { addResult(method, result, dr);
public InternationalString getDescription(Name name) { DescribeProcess info = getProcessDescription(name); if (info != null) { return new SimpleInternationalString(info.description()); } else { return null; } }
public String getVersion(Name name) { DescribeProcess info = getProcessDescription(name); if (info != null) { return info.version(); } else { return null; } }
public InternationalString getDescription(Name name) { DescribeProcess info = getProcessDescription(name); if (info != null) { return new SimpleInternationalString(info.description()); } else { return null; } }
public InternationalString getTitle(Name name) { DescribeProcess info = getProcessDescription(name); if (info != null) { return new SimpleInternationalString(info.title()); } else { return null; } }