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(); }
@Override protected void initializeFromSettings(NetCDFLayerSettingsContainer settings) { super.initializeFromSettings(settings); variableName = settings.getLayerName(); variableUoM = settings.getLayerUOM(); }
public Component buildComponent(final String id) { return new NetCDFOutTabPanel(id, layerModel, resourceModel); } }));
@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); } }
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()); setConvertedInput(convertedInput);
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()); }
@Test public void testComponent() { login(); NetCDFLayerSettingsContainer container = editor.getModelObject(); 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");
public NetCDFLayerSettingsContainer(NetCDFSettingsContainer globalContainer) { setCompressionLevel(globalContainer.getCompressionLevel()); setDataPacking(globalContainer.getDataPacking()); setGlobalAttributes(globalContainer.getGlobalAttributes()); setShuffle(globalContainer.isShuffle()); }
/** 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); }
@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()); } }
public NetCDFOutTabPanel(String id, IModel<LayerInfo> model, IModel<ResourceInfo> resourceModel) { super(id, model); if (resourceModel.getObject() != null) { // Selection of the IModel associated to the metadata map final PropertyModel<MetadataMap> metadata = new PropertyModel<MetadataMap>( resourceModel, "metadata"); // Selection of the CoverageInfo model IModel<CoverageInfo> cmodel = null; if (resourceModel.getObject() instanceof CoverageInfo) { CoverageInfo cinfo = (CoverageInfo) resourceModel.getObject(); cmodel = new Model<CoverageInfo>(cinfo); } // Getting the NetcdfSettingsContainer model from MetadataMap IModel<NetCDFLayerSettingsContainer> netcdfModel = new MetadataMapModel(metadata, NetCDFSettingsContainer.NETCDFOUT_KEY, NetCDFLayerSettingsContainer.class); NetCDFOutSettingsEditor editor = new NetCDFOutSettingsEditor("netcdfeditor", netcdfModel, cmodel); add(editor); setVisible(true); } else { add(new Label("netcdfeditor", new ResourceModel("NetCDFOutTabPanel.invalid"))); setVisible(false); } } }
globalContainer = new NetCDFSettingsContainer(); container = new NetCDFLayerSettingsContainer(globalContainer); map.put(NetCDFSettingsContainer.NETCDFOUT_KEY, container);
public NetCDFOutTabPanel( String id, IModel<LayerInfo> model, IModel<CoverageInfo> resourceModel) { super(id, model); // Selection of the IModel associated to the metadata map final PropertyModel<MetadataMap> metadata = new PropertyModel<MetadataMap>(resourceModel, "metadata"); // Selection of the CoverageInfo model IModel<CoverageInfo> cmodel = null; if (resourceModel.getObject() instanceof CoverageInfo) { CoverageInfo cinfo = (CoverageInfo) resourceModel.getObject(); cmodel = new Model<CoverageInfo>(cinfo); } // Getting the NetcdfSettingsContainer model from MetadataMap IModel<NetCDFLayerSettingsContainer> netcdfModel = new MetadataMapModel<NetCDFLayerSettingsContainer>( metadata, NetCDFSettingsContainer.NETCDFOUT_KEY, NetCDFLayerSettingsContainer.class); NetCDFOutSettingsEditor editor = new NetCDFOutSettingsEditor("netcdfeditor", netcdfModel, cmodel); add(editor); } }
@Override protected void onUpdate(AjaxRequestTarget target) { String name = standardName.getModelObject(); if (name != null && !name.isEmpty()) { NetCDFParserBean bean = GeoServerExtensions.bean(NetCDFParserBean.class); if (bean != null && bean.getParser() != null) { NetCDFCFParser parser = bean.getParser(); Entry e = null; if (parser.hasEntryId(name)) { e = parser.getEntry(name); } else if (parser.hasAliasId(name)) { e = parser.getEntryFromAlias(name); } if (e != null) { uom.setModelObject(e.getCanonicalUnits()); target.addComponent(container); } } } } });
@Override public NetCDFEncoder getEncoderFor( GranuleStack granuleStack, File file, Map<String, String> encodingParameters, String outputFormat) throws IOException { NetCDFLayerSettingsContainer settings = NetCDFEncoder.getSettings(encodingParameters); if (settings != null && Boolean.TRUE.equals( settings.getMetadata().get(GHRSSTEncoder.SETTINGS_KEY, Boolean.class))) { return new GHRSSTEncoder(granuleStack, file, encodingParameters, outputFormat); } // if no GHRSST settings, or disabled, then look for some other encoder return null; }
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);
@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()); } }
@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); } }
public Component buildComponent(final String id) { return new NetCDFOutTabPanel(id, layerModel, resourceModel); } }));
@Override protected void onUpdate(AjaxRequestTarget target) { String name = standardName.getModelObject(); if (name != null && !name.isEmpty()) { NetCDFParserBean bean = GeoServerExtensions.bean(NetCDFParserBean.class); if (bean != null && bean.getParser() != null) { NetCDFCFParser parser = bean.getParser(); Entry e = null; if (parser.hasEntryId(name)) { e = parser.getEntry(name); } else if (parser.hasAliasId(name)) { e = parser.getEntryFromAlias(name); } if (e != null) { uom.setModelObject(e.getCanonicalUnits()); target.add(container); } } } } });