public ProcessSelectionPage(Map<String, Object> input) { super("process selection"); this.input = input; processFactories = Processors.getProcessFactories(); selectedFactory = null; }
/** * Look up an implementation of the named process on the classpath. * * @param name Name of the Process to create * @return created process */ public static synchronized Process createProcess(Name name) { ProcessFactory factory = createProcessFactory(name); if (factory == null) return null; return factory.create(name); }
public Function function(Name processName, List<Expression> args, Literal fallback) { // if the param function just return it if (processName.equals(new NameImpl(ParameterFunction.NAME.getName()))) { return new ParameterFunction(fallback, args); } // lookup the process if (functionNames == null) { init(); } if (!processToFunction.containsKey(processName)) { // no such function return null; } else { // wrap the process org.geotools.process.Process process = Processors.createProcess(processName); Map<String, Parameter<?>> parameters = Processors.getParameterInfo(processName); if (process instanceof RenderingProcess) { return new RenderingProcessFunction( processName, args, parameters, (RenderingProcess) process, fallback); } else { return new ProcessFunction(processName, args, parameters, process, fallback); } } }
Map<String, Parameter<?>> parameterInfo = Processors.getParameterInfo(processName); if (parameterInfo instanceof LinkedHashMap) { Map<String, Parameter<?>> resultParams = Processors.getResultInfo(processName, null); org.opengis.parameter.Parameter result = resultParams.values().iterator().next(); functionName = new FunctionNameImpl(name, result, inputParams);
public void onApplicationEvent(ApplicationEvent event) { // add and remove the process factory as necessary if (event instanceof ContextRefreshedEvent) { Processors.addProcessFactory(this); } else if (event instanceof ContextClosedEvent) { Processors.removeProcessFactory(this); } } }
public void testSPI() throws Exception { NameImpl boundsName = new NameImpl("bean", "Bounds"); ProcessFactory factory = Processors.createProcessFactory(boundsName); assertNotNull(factory); assertTrue(factory instanceof BeanProcessFactory); org.geotools.process.Process buffer = Processors .createProcess(boundsName); assertNotNull(buffer); }
private Object getResult(Map<String, Object> results, Map<String, Object> processInputs) { if (results.size() == 1) { return results.values().iterator().next(); } // return the sole value returned Map<String, Parameter<?>> resultInfo = Processors.getResultInfo(processName, processInputs); String primary = getPrimary(resultInfo); return results.get(primary); }
public DeprecatedProcessFactory() { Processors.addProcessFactory(this); }
@Override public void run () { Name n = new NameImpl("ras", "PolygonExtraction"); //System.out.println(Processors.getParameterInfo(n)); Map<String,Object> params = new HashMap<>(); params.put("data", coverage); params.put("insideEdges", true); List<Number> noDataValues = new ArrayList<>(); noDataValues.add(NO_DATA); params.put("nodata", noDataValues); //TODO: try to extract min/max from coverage values (or cache as properties on MeasurementGrid?), // split data range into e.g. 10 equally sized classification ranges if (usesRanges) { params.put("ranges", ranges); } // TODO: clip to enclosing field geometry (use "roi" param) Process process = Processors.createProcess(n); Map<String, Object> result = process.execute(params, null); SimpleFeatureCollection featureCollection = (SimpleFeatureCollection) result.get("result"); handleFeatures(featureCollection); }
private static boolean isVectorSource(Expression tranformation) { // instanceof is sufficient for null check if (tranformation instanceof ProcessFunction) { ProcessFunction processFunction = (ProcessFunction) tranformation; Name processName = processFunction.getProcessName(); Map<String, org.geotools.data.Parameter<?>> params = Processors.getParameterInfo(processName); for (org.geotools.data.Parameter<?> param : params.values()) { if (SimpleFeatureCollection.class.isAssignableFrom(param.getType())) { return true; } } } return false; }
public void onApplicationEvent(ApplicationEvent event) { // add and remove the process factory as necessary if (event instanceof ContextRefreshedEvent) { Processors.addProcessFactory(this); } else if (event instanceof ContextClosedEvent) { Processors.removeProcessFactory(this); } } }
private Object getResult(Map<String, Object> results, Map<String, Object> processInputs) { if (results.size() == 1) { return results.values().iterator().next(); } // return the sole value returned Map<String, Parameter<?>> resultInfo = Processors.getResultInfo(processName, processInputs); String primary = getPrimary(resultInfo); return results.get(primary); }
public SpringBeanProcessFactory(String title, String namespace, Class markerInterface) { super(new SimpleInternationalString(title), namespace); this.markerInterface = markerInterface; // create an iterator that will register this factory into SPI iterator = new FactoryIteratorProvider() { public <T> Iterator<T> iterator(Class<T> category) { if (ProcessFactory.class.isAssignableFrom(category)) { return (Iterator<T>) Collections.singletonList(SpringBeanProcessFactory.this) .iterator(); } else { return null; } } }; // register the new process and make the process function factory lookup again the processes Processors.addProcessFactory(this); for(FunctionFactory ff : CommonFactoryFinder.getFunctionFactories(null)) { if(ff instanceof ProcessFunctionFactory) { ProcessFunctionFactory pff = (ProcessFunctionFactory) ff; pff.clear(); } } }
/** * Look up a Factory by name of a process it supports. * * @param name Name of the Process you wish to work with * @return ProcessFactory capable of creating an instanceof the named process */ public static synchronized ProcessFactory createProcessFactory(Name name) { // store a local reference to last factory, since it could change if this method is called // within the factories getNames() method, which could happen if a factory delegates in some // way ProcessFactory last = lastFactory; if (last != null && last.getNames().contains(name)) { return last; } for (ProcessFactory factory : getProcessFactories()) { if (factory.getNames().contains(name)) { lastFactory = factory; return factory; } } return null; // go fish }
/** * Look up an implementation of the named process on the classpath and describe the input * parameter required. * * @param name Name of the Process * @return Description of the parameters required */ public static synchronized Map<String, Parameter<?>> getParameterInfo(Name name) { ProcessFactory factory = createProcessFactory(name); if (factory == null) return null; return factory.getParameterInfo(name); }
Processors.addProcessFactory(this); } else if (event instanceof ContextClosedEvent) { Processors.removeProcessFactory(this);
public Function function(Name processName, List<Expression> args, Literal fallback) { // if the param function just return it if(processName.equals(new NameImpl(ParameterFunction.NAME))) { return new ParameterFunction(fallback, args); } // lookup the process if(functionNames == null) { init(); } if (!processToFunction.containsKey(processName)) { // no such function return null; } else { // wrap the process org.geotools.process.Process process = Processors.createProcess(processName); Map<String, Parameter<?>> parameters = Processors.getParameterInfo(processName); if (process instanceof RenderingProcess){ return new RenderingProcessFunction(processName.getLocalPart(), processName, args, parameters, (RenderingProcess) process, fallback); } else { return new ProcessFunction(processName.getLocalPart(), processName, args, parameters, process, fallback); } } }
ProcessFunction processFunction = (ProcessFunction) exp; Name processName = processFunction.getProcessName(); Map<String, Parameter<?>> outputs = Processors.getResultInfo(processName, null); if (outputs.isEmpty()) { continue;
public SpringBeanProcessFactory(String title, String namespace, Class markerInterface) { super(new SimpleInternationalString(title), namespace); this.markerInterface = markerInterface; // create an iterator that will register this factory into SPI iterator = new FactoryIteratorProvider() { public <T> Iterator<T> iterator(Class<T> category) { if (ProcessFactory.class.isAssignableFrom(category)) { return (Iterator<T>) Collections.singletonList(SpringBeanProcessFactory.this) .iterator(); } else { return null; } } }; // register the new process and make the process function factory lookup again the processes Processors.addProcessFactory(this); for (FunctionFactory ff : CommonFactoryFinder.getFunctionFactories(null)) { if (ff instanceof ProcessFunctionFactory) { ProcessFunctionFactory pff = (ProcessFunctionFactory) ff; pff.clear(); } } }
new ArrayList<ProcessFactory>(Processors.getProcessFactories()); Collections.sort(factories, FACTORY_COMPARATOR);