org.geotools.data.Parameter Java Examples
The following examples show how to use
org.geotools.data.Parameter.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: GeoWavePluginConfig.java From geowave with Apache License 2.0 | 6 votes |
@Override public Param apply(final ConfigOption input) { if (input.isPassword()) { return new Param( input.getName(), String.class, input.getDescription(), !input.isOptional(), "mypassword", Collections.singletonMap(Parameter.IS_PASSWORD, Boolean.TRUE)); } if (input.getType().isPrimitive() && (input.getType() == boolean.class)) { return new Param( input.getName(), input.getType(), input.getDescription(), true, "true", Collections.singletonMap(Parameter.OPTIONS, BooleanOptions)); } return new Param( input.getName(), input.getType(), input.getDescription(), !input.isOptional()); }
Example #2
Source File: GeoWavePluginConfigTest.java From geowave with Apache License 2.0 | 6 votes |
@Test public void test() throws GeoWavePluginException, URISyntaxException { final List<Param> params = GeoWavePluginConfig.getPluginParams(new MemoryStoreFactoryFamily()); final HashMap<String, Serializable> paramValues = new HashMap<>(); for (final Param param : params) { if (param.getName().equals(GeoWavePluginConfig.LOCK_MGT_KEY)) { final List<String> options = (List<String>) param.metadata.get(Parameter.OPTIONS); assertNotNull(options); assertTrue(options.size() > 0); paramValues.put(param.getName(), options.get(0)); } else if (param.getName().equals(GeoWavePluginConfig.FEATURE_NAMESPACE_KEY)) { paramValues.put(param.getName(), new URI("http://test/test")); } else if (param.getName().equals(GeoWavePluginConfig.TRANSACTION_BUFFER_SIZE)) { paramValues.put(param.getName(), 1000); } else if (!param.getName().equals(GeoWavePluginConfig.AUTH_URL_KEY)) { paramValues.put( param.getName(), (Serializable) (param.getDefaultValue() == null ? "" : param.getDefaultValue())); } } final GeoWavePluginConfig config = new GeoWavePluginConfig(new MemoryStoreFactoryFamily(), paramValues); Assert.assertEquals(1000, (int) config.getTransactionBufferSize()); assertNotNull(config.getLockingManagementFactory()); assertNotNull(config.getLockingManagementFactory().createLockingManager(config)); }
Example #3
Source File: OptionalValueEditorTest.java From sldeditor with GNU General Public License v3.0 | 5 votes |
/** * Test method for {@link * com.sldeditor.rendertransformation.OptionalValueEditor#getCellEditorValue()}. */ @SuppressWarnings({"unchecked", "rawtypes"}) @Test void testGetCellEditorValue() { FunctionTableModel model = new FunctionTableModel(); model.addNewValue(0); ProcessFunction processFunction = createProcessFunction(); FunctionName name = new FunctionNameImpl( "Test", parameter("cellSize", Double.class), new Parameter( "outputBBOX", Number.class, null, null, false, 0, 100, null, null), parameter("outputWidth", Number.class), parameter("outputHeight", Number.class)); assertFalse(name.getArguments().get(0).isRequired()); assertTrue(name.getArguments().get(1).isRequired()); model.populate(name, processFunction); TestOptionalValueEditor obj = new TestOptionalValueEditor(model); assertNotNull(obj.getTableCellEditorComponent(null, null, false, 0, 0)); assertNotNull(obj.getCellEditorValue()); obj.setValue(); assertNull(obj.getTableCellEditorComponent(null, null, false, 1, 0)); }
Example #4
Source File: GeoWavePluginConfig.java From geowave with Apache License 2.0 | 5 votes |
private static Map<String, List<String>> getLockMgtOptions() { final List<String> options = new ArrayList<>(); final Iterator<LockingManagementFactory> it = getLockManagementFactoryList(); while (it.hasNext()) { options.add(it.next().toString()); } final Map<String, List<String>> map = new HashMap<>(); map.put(Parameter.OPTIONS, options); return map; }
Example #5
Source File: GeoWavePluginConfig.java From geowave with Apache License 2.0 | 5 votes |
private static Map<String, List<String>> getIndexQueryStrategyOptions() { final List<String> options = new ArrayList<>(); final Iterator<IndexQueryStrategySPI> it = getInxexQueryStrategyList(); while (it.hasNext()) { options.add(it.next().toString()); } final Map<String, List<String>> map = new HashMap<>(); map.put(Parameter.OPTIONS, options); return map; }
Example #6
Source File: GeoWavePluginConfig.java From geowave with Apache License 2.0 | 5 votes |
private static Map<String, List<String>> getAuthSPIOptions() { final List<String> options = new ArrayList<>(); final Iterator<AuthorizationFactorySPI> it = getAuthorizationFactoryList(); while (it.hasNext()) { options.add(it.next().toString()); } final Map<String, List<String>> map = new HashMap<>(); map.put(Parameter.OPTIONS, options); return map; }
Example #7
Source File: DistributedRenderProcessUtils.java From geowave with Apache License 2.0 | 5 votes |
public static Expression getRenderingProcess() { if (SINGLETON_RENDER_PROCESS == null) { final ProcessFactory processFactory = new AnnotatedBeanProcessFactory( Text.text("Internal GeoWave Process Factory"), "internal", InternalDistributedRenderProcess.class); final Name processName = new NameImpl("internal", "InternalDistributedRender"); final RenderingProcess process = (RenderingProcess) processFactory.create(processName); final Map<String, Parameter<?>> parameters = processFactory.getParameterInfo(processName); final InternalProcessFactory factory = new InternalProcessFactory(); // this is kinda a hack, but the only way to instantiate a process // is // for it to have a registered process factory, so temporarily // register // the process factory Processors.addProcessFactory(factory); SINGLETON_RENDER_PROCESS = new RenderingProcessFunction( processName, Collections.singletonList( new ParameterFunction( null, Collections.singletonList(new LiteralExpressionImpl("data")))), parameters, process, null); Processors.removeProcessFactory(factory); } return SINGLETON_RENDER_PROCESS; }
Example #8
Source File: DatabaseConnectionTest.java From sldeditor with GNU General Public License v3.0 | 4 votes |
@SuppressWarnings("unlikely-arg-type") @Test void testEquals() { Param param = GeoPkgDataStoreFactory.DBTYPE; List<DatabaseConnectionField> expectedDetailList = new ArrayList<DatabaseConnectionField>(); expectedDetailList.add(new DatabaseConnectionField(GeoPkgDataStoreFactory.DATABASE)); expectedDetailList.add(new DatabaseConnectionField(GeoPkgDataStoreFactory.USER)); String expectedDatabaseTypeLabel = "GeoPackage"; boolean expectedSupportsDuplication = false; DatabaseConnection test = new DatabaseConnection( param, expectedDatabaseTypeLabel, expectedSupportsDuplication, expectedDetailList, null); assertTrue(test.equals(test)); assertFalse(test.equals("")); assertFalse(test.equals(null)); assertFalse( new DatabaseConnection( null, expectedDatabaseTypeLabel, expectedSupportsDuplication, expectedDetailList, null) .equals(test)); assertFalse( new DatabaseConnection( param, null, expectedSupportsDuplication, expectedDetailList, null) .equals(test)); assertFalse( new DatabaseConnection( param, expectedDatabaseTypeLabel, expectedSupportsDuplication, null, null) .equals(test)); assertFalse( new DatabaseConnection( new Param( "differetdbtype", String.class, "Type", true, "testgeopkg", Collections.singletonMap(Parameter.LEVEL, "program")), expectedDatabaseTypeLabel, expectedSupportsDuplication, expectedDetailList, null) .equals(test)); assertFalse( new DatabaseConnection( param, "", expectedSupportsDuplication, expectedDetailList, null) .equals(test)); assertFalse( new DatabaseConnection( param, expectedDatabaseTypeLabel, !expectedSupportsDuplication, expectedDetailList, null) .equals(test)); assertFalse( new DatabaseConnection( param, expectedDatabaseTypeLabel, expectedSupportsDuplication, new ArrayList<DatabaseConnectionField>(), null) .equals(test)); }
Example #9
Source File: CheckBoxRendererTest.java From sldeditor with GNU General Public License v3.0 | 4 votes |
/** * Test method for {@link * com.sldeditor.rendertransformation.CheckBoxRenderer#CheckBoxRenderer(com.sldeditor.rendertransformation.FunctionTableModel)}. */ @SuppressWarnings({"unchecked", "rawtypes"}) @Test void testCheckBoxRenderer() { JTable table = new JTable(); FunctionTableModel model = new FunctionTableModel(); assertNull( new CheckBoxRenderer(null) .getTableCellRendererComponent(null, null, false, false, 0, 0)); assertNull( new CheckBoxRenderer(null) .getTableCellRendererComponent(table, null, false, false, 0, 0)); assertNull( new CheckBoxRenderer(model) .getTableCellRendererComponent(null, null, false, false, 0, 0)); model.addNewValue(0); ProcessFunction processFunction = createProcessFunction(); FunctionName name = new FunctionNameImpl( "Test", parameter("cellSize", Double.class), new Parameter( "outputBBOX", Number.class, null, null, false, 0, 100, null, null), parameter("outputWidth", Number.class), parameter("outputHeight", Number.class)); assertFalse(name.getArguments().get(0).isRequired()); assertTrue(name.getArguments().get(1).isRequired()); model.populate(name, processFunction); CheckBoxRenderer obj = new CheckBoxRenderer(model); // Row - optional and not selected assertEquals(obj, obj.getTableCellRendererComponent(table, null, false, false, 0, 0)); assertEquals(obj, obj.getTableCellRendererComponent(table, true, false, false, 0, 0)); assertTrue(obj.isSelected()); assertEquals(obj, obj.getTableCellRendererComponent(table, false, false, false, 0, 0)); assertFalse(obj.isSelected()); // Row - optional and selected assertEquals(obj, obj.getTableCellRendererComponent(table, null, true, false, 0, 0)); assertEquals(obj, obj.getTableCellRendererComponent(table, true, true, false, 0, 0)); assertTrue(obj.isSelected()); assertEquals(obj, obj.getTableCellRendererComponent(table, false, true, false, 0, 0)); assertFalse(obj.isSelected()); // Row - required and not selected assertEquals( JLabel.class, obj.getTableCellRendererComponent(table, null, false, false, 1, 0).getClass()); // Row - required and selected assertEquals( JLabel.class, obj.getTableCellRendererComponent(table, null, true, false, 1, 0).getClass()); }
Example #10
Source File: FunctionTableModelTest.java From sldeditor with GNU General Public License v3.0 | 4 votes |
/** Test all the methods using a ProcessFunction */ @SuppressWarnings({"unchecked", "rawtypes"}) @Test void testProcessFunction() { FunctionTableModel model = new FunctionTableModel(); assertEquals(0, model.getRowCount()); model.addNewValue(0); ProcessFunction processFunction = createProcessFunction(); FunctionName name = new FunctionNameImpl( new NameImpl("vec", "PointStacker"), parameter("cellSize", Double.class), new Parameter( "outputBBOX", Number.class, null, null, false, 0, 100, null, null), parameter("outputWidth", Number.class), parameter("outputHeight", Number.class)); assertFalse(name.getArguments().get(0).isRequired()); assertTrue(name.getArguments().get(1).isRequired()); model.populate(name, processFunction); assertEquals(3, model.getRowCount()); assertEquals(4, model.getColumnCount()); // Get value assertEquals("outputBBOX", model.getValueAt(0, 0)); assertEquals(Number.class.getSimpleName(), model.getValueAt(0, 1)); assertEquals(true, model.getValueAt(0, 2)); assertEquals("env([wms_bbox])", model.getValueAt(0, 3)); assertNull(model.getValueAt(0, 4)); // Is editable assertFalse(model.isCellEditable(0, 0)); assertFalse(model.isCellEditable(0, 1)); assertTrue(model.isCellEditable(0, FunctionTableModel.getOptionalColumn())); assertFalse(model.isCellEditable(0, 3)); assertFalse(model.isCellEditable(0, 4)); // Set value model.setValueAt(true, 0, 2); assertTrue((Boolean) model.getValueAt(0, FunctionTableModel.getOptionalColumn())); model.setValueAt(false, 0, 2); assertFalse((Boolean) model.getValueAt(0, FunctionTableModel.getOptionalColumn())); // Get row assertNull(model.getValue(-1)); assertNull(model.getValue(10)); // Add a new value assertEquals(0, model.getNoOfOccurences(null)); ProcessFunctionParameterValue value = model.getValue(0); assertEquals(1, model.getNoOfOccurences(value)); model.addNewValue(0); assertEquals(4, model.getRowCount()); assertEquals(2, model.getNoOfOccurences(value)); // Remove value model.removeValue(3); assertEquals(3, model.getRowCount()); // Get expression ProcessFunction actualFunction = model.getExpression(null); assertNull(actualFunction); model.setValueAt(true, 0, FunctionTableModel.getOptionalColumn()); ProcessFunctionFactory factory = new ProcessFunctionFactory(); actualFunction = model.getExpression(factory); assertNotNull(actualFunction); // Update expression FilterFactory ff = CommonFactoryFinder.getFilterFactory(); Expression expression = ff.literal(4.2); model.update(expression, 0); model.update(null, 1); }
Example #11
Source File: FunctionTableModelTest.java From sldeditor with GNU General Public License v3.0 | 4 votes |
/** * Test all the methods using a ProcessBriefType. * * <p>Not tested because it needs to interact with GeoServer to create a receive a remote custom * WPS function. */ @SuppressWarnings({"unchecked", "rawtypes"}) @Disabled @Test void testProcessBriefType() { FunctionTableModel model = new FunctionTableModel(); assertEquals(0, model.getRowCount()); model.addNewValue(0); ProcessBriefType customFunction = createCustomFunction(); FunctionName name = new FunctionNameImpl( new NameImpl("vec", "PointStacker"), parameter("cellSize", Double.class), new Parameter( "outputBBOX", Number.class, null, null, false, 0, 100, null, null), parameter("outputWidth", Number.class), parameter("outputHeight", Number.class)); assertFalse(name.getArguments().get(0).isRequired()); assertTrue(name.getArguments().get(1).isRequired()); model.populate(customFunction); assertEquals(3, model.getRowCount()); assertEquals(4, model.getColumnCount()); // Get value assertEquals("outputBBOX", model.getValueAt(0, 0)); assertEquals(Number.class.getSimpleName(), model.getValueAt(0, 1)); assertEquals(true, model.getValueAt(0, 2)); assertEquals("env([wms_bbox])", model.getValueAt(0, 3)); assertNull(model.getValueAt(0, 4)); // Is editable assertFalse(model.isCellEditable(0, 0)); assertFalse(model.isCellEditable(0, 1)); assertTrue(model.isCellEditable(0, FunctionTableModel.getOptionalColumn())); assertFalse(model.isCellEditable(0, 3)); assertFalse(model.isCellEditable(0, 4)); // Set value model.setValueAt(true, 0, 2); assertTrue((Boolean) model.getValueAt(0, FunctionTableModel.getOptionalColumn())); model.setValueAt(false, 0, 2); assertFalse((Boolean) model.getValueAt(0, FunctionTableModel.getOptionalColumn())); // Get row assertNull(model.getValue(-1)); assertNull(model.getValue(10)); // Add a new value assertEquals(0, model.getNoOfOccurences(null)); ProcessFunctionParameterValue value = model.getValue(0); assertEquals(1, model.getNoOfOccurences(value)); model.addNewValue(0); assertEquals(4, model.getRowCount()); assertEquals(2, model.getNoOfOccurences(value)); // Remove value model.removeValue(3); assertEquals(3, model.getRowCount()); // Get expression ProcessFunction actualFunction = model.getExpression(null); assertNull(actualFunction); model.setValueAt(true, 0, FunctionTableModel.getOptionalColumn()); ProcessFunctionFactory factory = new ProcessFunctionFactory(); actualFunction = model.getExpression(factory); assertNotNull(actualFunction); // Update expression FilterFactory ff = CommonFactoryFinder.getFilterFactory(); Expression expression = ff.literal(4.2); model.update(expression, 0); model.update(null, 1); }