@Override protected void convertInput() { globalAttributes.visitChildren(new Component.IVisitor<Component>() { @Override public Object component(Component component) { if (component instanceof FormComponent) { FormComponent<?> formComponent = (FormComponent<?>) component; formComponent.processInput(); } return Component.IVisitor.CONTINUE_TRAVERSAL; } }); compressionLevel.processInput(); dataPacking.processInput(); shuffle.processInput(); standardName.processInput(); uom.processInput(); List<GlobalAttribute> info = globalAttributes.getModelObject(); NetCDFLayerSettingsContainer convertedInput = new NetCDFLayerSettingsContainer(); convertedInput.setCompressionLevel(compressionLevel.getModelObject()); convertedInput.setGlobalAttributes(info); convertedInput.setDataPacking(dataPacking.getModelObject()); convertedInput.setShuffle(shuffle.getModelObject()); convertedInput.setLayerName(standardName.getModelObject()); convertedInput.setLayerUOM(uom.getModelObject()); setConvertedInput(convertedInput); } }
protected void initializeFromSettings(NetCDFLayerSettingsContainer settings) { shuffle = settings.isShuffle(); copyAttributes = settings.isCopyAttributes(); copyGlobalAttributes = settings.isCopyGlobalAttributes(); dataPacking = settings.getDataPacking(); compressionLevel = checkLevel(settings.getCompressionLevel()); globalAttributes = settings.getGlobalAttributes(); variableAttributes = settings.getVariableAttributes(); extraVariables = settings.getExtraVariables(); }
NetCDFSettingsContainer.NETCDFOUT_KEY, NetCDFLayerSettingsContainer.class); shuffle = settings.isShuffle(); dataPacking = settings.getDataPacking(); compressionLevel = checkLevel(settings.getCompressionLevel()); variableName = settings.getLayerName(); variableUoM = settings.getLayerUOM(); List<GlobalAttribute> globalAttributesSettings = settings.getGlobalAttributes(); for (GlobalAttribute globalAttribute : globalAttributesSettings) { globalAttributes.put(globalAttribute.getKey(), globalAttribute.getValue());
@Override protected void initializeFromSettings(NetCDFLayerSettingsContainer settings) { super.initializeFromSettings(settings); variableName = settings.getLayerName(); variableUoM = settings.getLayerUOM(); }
public NetCDFLayerSettingsContainer(NetCDFSettingsContainer globalContainer) { setCompressionLevel(globalContainer.getCompressionLevel()); setDataPacking(globalContainer.getDataPacking()); setGlobalAttributes(globalContainer.getGlobalAttributes()); setShuffle(globalContainer.isShuffle()); }
standardName.processInput(); uom.processInput(); NetCDFLayerSettingsContainer convertedInput = new NetCDFLayerSettingsContainer(); convertedInput.setCompressionLevel(compressionLevel.getModelObject()); convertedInput.setGlobalAttributes(globalAttributes.getModelObject()); convertedInput.setVariableAttributes(variableAttributes.getModelObject()); convertedInput.setExtraVariables(extraVariables.getModelObject()); convertedInput.setDataPacking(dataPacking.getModelObject()); convertedInput.setShuffle(shuffle.getModelObject()); convertedInput.setCopyAttributes(copyAttributes.getModelObject()); convertedInput.setCopyGlobalAttributes(copyGlobalAttributes.getModelObject()); convertedInput.setLayerName(standardName.getModelObject()); convertedInput.setLayerUOM(uom.getModelObject());
public NetCDFLayerSettingsContainer(NetCDFSettingsContainer globalContainer) { setCompressionLevel(globalContainer.getCompressionLevel()); setDataPacking(globalContainer.getDataPacking()); setShuffle(globalContainer.isShuffle()); setCopyAttributes(globalContainer.isCopyAttributes()); setCopyGlobalAttributes(globalContainer.isCopyGlobalAttributes()); setGlobalAttributes(globalContainer.getGlobalAttributes()); setVariableAttributes(globalContainer.getVariableAttributes()); setExtraVariables(globalContainer.getExtraVariables()); }
NetCDFLayerSettingsContainer container = new NetCDFLayerSettingsContainer(); container.setCompressionLevel(0); container.setShuffle(true); container.setDataPacking(DataPacking.SHORT); String key = "NetCDFOutput.Key"; info.getMetadata().put(key, container);
/** Configure NetCDF output settings for <code>Temperature_surface</code>. */ private void configureTemperatureSurface() { NetCDFLayerSettingsContainer container = new NetCDFLayerSettingsContainer(); container.setCopyAttributes(true); List<VariableAttribute> variableAttributes = new ArrayList<VariableAttribute>(); variableAttributes.add( new VariableAttribute("test-variable-attribute", "Test Variable Attribute")); variableAttributes.add(new VariableAttribute("Grib2_Parameter_Category", "Test Category")); container.setVariableAttributes(variableAttributes); List<ExtraVariable> extraVariables = new ArrayList<ExtraVariable>(); extraVariables.add(new ExtraVariable("reftime", "forecast_reference_time", "time")); extraVariables.add(new ExtraVariable("reftime", "scalar_forecast_reference_time", "")); container.setExtraVariables(extraVariables); List<GlobalAttribute> globalAttributes = new ArrayList<GlobalAttribute>(); globalAttributes.add(new GlobalAttribute("test-global-attribute", "Test Global Attribute")); globalAttributes.add(new GlobalAttribute("test-global-attribute-integer", "42")); globalAttributes.add(new GlobalAttribute("test-global-attribute-double", "1.5")); container.setGlobalAttributes(globalAttributes); CoverageInfo info = getCatalog().getCoverageByName(getLayerId(TEMPERATURE_SURFACE)); info.getMetadata().put(NetCDFSettingsContainer.NETCDFOUT_KEY, container); getCatalog().save(info); }
globalContainer = new NetCDFSettingsContainer(); container = new NetCDFLayerSettingsContainer(globalContainer); map.put(NetCDFSettingsContainer.NETCDFOUT_KEY, container);
@Override public IModel<CoverageInfo> createOwnModel( IModel<? extends LayerInfo> layerModel, boolean isNew) { CoverageInfo info = (CoverageInfo) layerModel.getObject().getResource(); // Check if the MetadataMap already contains the NetCDF Settings MetadataMap map = info.getMetadata(); NetCDFLayerSettingsContainer container = map.get(NetCDFSettingsContainer.NETCDFOUT_KEY, NetCDFLayerSettingsContainer.class); // If not present, add it to the map if (isNew || container == null) { // container = new NetCDFLayerSettingsContainer(); // Getting NetCDF Settings from the Global ones GeoServer gs = GeoServerExtensions.bean(GeoServer.class); MetadataMap globalMap = gs.getGlobal().getSettings().getMetadata(); NetCDFSettingsContainer globalContainer = globalMap.get( NetCDFSettingsContainer.NETCDFOUT_KEY, NetCDFSettingsContainer.class); // If not present, create a new container if (globalContainer == null) { globalContainer = new NetCDFSettingsContainer(); } container = new NetCDFLayerSettingsContainer(globalContainer); map.put(NetCDFSettingsContainer.NETCDFOUT_KEY, container); } return new Model<>(info); } }
NetCDFLayerSettingsContainer container = new NetCDFLayerSettingsContainer(); container.setCompressionLevel(0); container.setShuffle(true); container.setDataPacking(isPackedLayer ? DataPacking.SHORT : DataPacking.NONE); container.setGlobalAttributes(attributes); container.setLayerName(STANDARD_NAME); container.setLayerUOM(isCF ? CANONICAL_UNIT : originalUnit);
tester.getComponentFromLastRenderedPage( "form:panel:netcdfeditor:container:shuffle"); assertEquals(shuffle.getModelObject(), container.isShuffle()); tester.getComponentFromLastRenderedPage( "form:panel:netcdfeditor:container:copyAttributes"); assertEquals(copyAttributes.getModelObject(), container.isCopyAttributes()); tester.getComponentFromLastRenderedPage( "form:panel:netcdfeditor:container:copyGlobalAttributes"); assertEquals(copyGlobalAttributes.getModelObject(), container.isCopyGlobalAttributes()); tester.getComponentFromLastRenderedPage( "form:panel:netcdfeditor:container:compressionLevel"); assertEquals(compressionLevel.getModelObject().intValue(), container.getCompressionLevel()); tester.getComponentFromLastRenderedPage( "form:panel:netcdfeditor:container:dataPacking"); assertEquals(dataPacking.getModelObject(), container.getDataPacking()); formTester.submit(); tester.assertNoErrorMessage(); assertEquals("test-name", actualContainer.getLayerName()); assertEquals("test-uom", actualContainer.getLayerUOM()); formTester.submit(); tester.assertNoErrorMessage(); assertEquals(1, actualContainer.getGlobalAttributes().size()); assertEquals(
CheckBox shuffle = (CheckBox) tester .getComponentFromLastRenderedPage("form:panel:netcdfeditor:container:shuffle"); assertEquals(shuffle.getModelObject(), container.isShuffle()); TextField<Integer> compressionLevel = (TextField<Integer>) tester .getComponentFromLastRenderedPage("form:panel:netcdfeditor:container:compressionLevel"); assertEquals(compressionLevel.getModelObject().intValue(), container.getCompressionLevel()); DropDownChoice<DataPacking> dataPacking = (DropDownChoice<DataPacking>) tester .getComponentFromLastRenderedPage("form:panel:netcdfeditor:container:dataPacking"); assertEquals(dataPacking.getModelObject(), container.getDataPacking()); assertEquals(actualContainer.getLayerName(), "test"); assertEquals(actualContainer.getLayerUOM(), "test");
@Before public void setUpInternal() throws Exception { // Creatign models LayerInfo layerInfo = getCatalog().getLayerByName(getLayerId(MockData.TASMANIA_DEM)); layerModel = new Model<LayerInfo>(layerInfo); ResourceInfo resource = layerInfo.getResource(); resourceModel = new Model<CoverageInfo>((CoverageInfo) resource); // Add Element to MetadataMap MetadataMap metadata = resource.getMetadata(); if (!metadata.containsKey(NetCDFSettingsContainer.NETCDFOUT_KEY)) { metadata.put(NetCDFSettingsContainer.NETCDFOUT_KEY, new NetCDFLayerSettingsContainer()); } }
NetCDFLayerSettingsContainer container = new NetCDFLayerSettingsContainer(); container.setCompressionLevel(isCompressed ? 9 : 0); container.setShuffle(true); container.setDataPacking(isPackedLayer ? DataPacking.SHORT : DataPacking.NONE); attributes.add(new GlobalAttribute("Conventions", "CF-1.6")); attributes.add(new GlobalAttribute("NULLAttribute", null)); container.setGlobalAttributes(attributes); container.setLayerName(STANDARD_NAME); container.setLayerUOM(isCF ? CANONICAL_UNIT : originalUnit);
@Before public void setUpInternal() throws Exception { // Creatign models LayerInfo layerInfo = getCatalog().getLayerByName(getLayerId(MockData.TASMANIA_DEM)); layerModel = new Model<LayerInfo>(layerInfo); ResourceInfo resource = layerInfo.getResource(); resourceModel = new Model<ResourceInfo>(resource); // Add Element to MetadataMap MetadataMap metadata = resource.getMetadata(); if (!metadata.containsKey(NetCDFSettingsContainer.NETCDFOUT_KEY)) { metadata.put(NetCDFSettingsContainer.NETCDFOUT_KEY, new NetCDFLayerSettingsContainer()); } }