public DomElement toDomElement() throws ValidationException, ConversionException { parameterUpdater.handleParameterSaveRequest(parameterMap); DefaultDomConverter domConverter = createDomConverter(); DefaultDomElement parametersElement = new DefaultDomElement("parameters"); domConverter.convertValueToDom(propertySet, parametersElement); return parametersElement; }
@Test public void testEscapingXmlParameters() throws Exception { DefaultDomElement domElement = new DefaultDomElement("parameter"); String unescapedString = "12 < 13 && 56 > 42 & \"true\" + 'a name'"; String escapedString = "12 < 13 && 56 > 42 & "true" + 'a name'"; domElement.addChild(new DefaultDomElement("expression", unescapedString)); DefaultDomElement withAttribute = new DefaultDomElement("withAttribute"); withAttribute.setAttribute("attrib", unescapedString); domElement.addChild(withAttribute); OperatorMenu.escapeXmlElements(domElement); assertEquals(escapedString, domElement.getChild("expression").getValue()); assertEquals(escapedString, domElement.getChild("withAttribute").getAttribute("attrib")); String xmlString = domElement.toXml(); XppDom readDomElement = OperatorMenu.createDom(xmlString); assertEquals(unescapedString, readDomElement.getChild("expression").getValue()); assertEquals(unescapedString, readDomElement.getChild("withAttribute").getAttribute("attrib")); } }
assertEquals(expectedfigure.getAttributes(), actualFigure.getAttributes()); DefaultDomElement domElement = new DefaultDomElement("figure"); domConverter.convertValueToDom(expectedfigure, domElement); assertEquals(expectedXml, domElement.toXml());
DefaultDomElement parameters = new DefaultDomElement("parameters"); domConverter.convertValueToDom(parameterSet, parameters); assertEquals(expectedXML, parameters.toXml().trim());
public DomElement toDomElement() throws ValidationException, ConversionException { parameterUpdater.handleParameterSaveRequest(parameterMap); DefaultDomConverter domConverter = createDomConverter(); DefaultDomElement parametersElement = new DefaultDomElement("parameters"); domConverter.convertValueToDom(propertySet, parametersElement); return parametersElement; }
private static LayerRef[] getLayerRefs(List<Layer> layers, ProductManager productManager) { ArrayList<LayerRef> layerRefs = new ArrayList<LayerRef>(layers.size()); for (int i = 0; i < layers.size(); i++) { Layer layer = layers.get(i); if (isSerializableLayer(layer)) { PropertySet configuration = layer.getConfiguration(); // todo - check - why create a configuration copy here?! (nf, 10.2009) PropertySet configurationCopy = getConfigurationCopy(configuration); SessionDomConverter domConverter = new SessionDomConverter(productManager); DomElement element = new DefaultDomElement("configuration"); try { domConverter.convertValueToDom(configurationCopy, element); } catch (ConversionException e) { e.printStackTrace(); } layerRefs.add(new LayerRef(layer, i, element, getLayerRefs(layer.getChildren(), productManager))); } } return layerRefs.toArray(new LayerRef[layerRefs.size()]); }
private static LayerRef[] getLayerRefs(List<Layer> layers, ProductManager productManager) { ArrayList<LayerRef> layerRefs = new ArrayList<LayerRef>(layers.size()); for (int i = 0; i < layers.size(); i++) { Layer layer = layers.get(i); if (isSerializableLayer(layer)) { PropertySet configuration = layer.getConfiguration(); // todo - check - why create a configuration copy here?! (nf, 10.2009) PropertySet configurationCopy = getConfigurationCopy(configuration); SessionDomConverter domConverter = new SessionDomConverter(productManager); DomElement element = new DefaultDomElement("configuration"); try { domConverter.convertValueToDom(configurationCopy, element); } catch (ConversionException e) { e.printStackTrace(); } layerRefs.add(new LayerRef(layer, i, element, getLayerRefs(layer.getChildren(), productManager))); } } return layerRefs.toArray(new LayerRef[layerRefs.size()]); }
public void setIO(final File srcFile, final File tgtFile, final String format) { final String readOperatorAlias = OperatorSpi.getOperatorAlias(ReadOp.class); final Node readerNode = findNode(graph, readOperatorAlias); if (readerNode != null) { final DomElement param = new DefaultDomElement("parameters"); param.createChild("file").setValue(srcFile.getAbsolutePath()); readerNode.setConfiguration(param); } final String writeOperatorAlias = OperatorSpi.getOperatorAlias(WriteOp.class); final Node writerNode = findNode(graph, writeOperatorAlias); if (writerNode != null && tgtFile != null) { final DomElement origParam = writerNode.getConfiguration(); origParam.getChild("file").setValue(tgtFile.getAbsolutePath()); if (format != null) origParam.getChild("formatName").setValue(format); } }
if (graph.getNode(sourceNodeId) == null) { DomElement configuration = new DefaultDomElement("parameters"); configuration.createChild("file").setValue(sourceFilePath); DomElement configuration = new DefaultDomElement("parameters"); configuration.createChild("file").setValue(commandLineArgs.getTargetFilePath()); configuration.createChild("formatName").setValue(commandLineArgs.getTargetFormatName());
@Test public void testLayerConfigurationPersistency() throws Exception { final Layer layer = createLayer(layerType); final SessionDomConverter domConverter = new SessionDomConverter(getProductManager()); final DomElement originalDomElement = new DefaultDomElement("configuration"); domConverter.convertValueToDom(layer.getConfiguration(), originalDomElement); //System.out.println(originalDomElement.toXml()); PropertySet template = layer.getLayerType().createLayerConfig(null); final PropertyContainer restoredConfiguration = (PropertyContainer) domConverter.convertDomToValue(originalDomElement, template); compareConfigurations(layer.getConfiguration(), restoredConfiguration); final DomElement restoredDomElement = new DefaultDomElement("configuration"); domConverter.convertValueToDom(restoredConfiguration, restoredDomElement); // assertEquals(originalDomElement.toXml(), restoredDomElement.toXml()); }
@Test public void testLayerConfigurationPersistency() throws Exception { final Layer layer = createLayer(layerType); final SessionDomConverter domConverter = new SessionDomConverter(getProductManager()); final DomElement originalDomElement = new DefaultDomElement("configuration"); domConverter.convertValueToDom(layer.getConfiguration(), originalDomElement); //System.out.println(originalDomElement.toXml()); PropertySet template = layer.getLayerType().createLayerConfig(null); final PropertyContainer restoredConfiguration = (PropertyContainer) domConverter.convertDomToValue(originalDomElement, template); compareConfigurations(layer.getConfiguration(), restoredConfiguration); final DomElement restoredDomElement = new DefaultDomElement("configuration"); domConverter.convertValueToDom(restoredConfiguration, restoredDomElement); // assertEquals(originalDomElement.toXml(), restoredDomElement.toXml()); }
@Test public void testPersistency() throws ValidationException, ConversionException, MalformedURLException { final WmsLayerType wmsLayerType = LayerTypeRegistry.getLayerType(WmsLayerType.class); final PropertySet configuration = wmsLayerType.createLayerConfig(null); configuration.setValue(WmsLayerType.PROPERTY_NAME_STYLE_NAME, "FancyStyle"); configuration.setValue(WmsLayerType.PROPERTY_NAME_URL, new URL("http://www.mapserver.org")); configuration.setValue(WmsLayerType.PROPERTY_NAME_CRS_ENVELOPE, new CRSEnvelope("EPSG:4324", -10, 20, 15, 50)); configuration.setValue(WmsLayerType.PROPERTY_NAME_IMAGE_SIZE, new Dimension(200, 300)); configuration.setValue(WmsLayerType.PROPERTY_NAME_LAYER_INDEX, 12); configuration.setValue(WmsLayerType.PROPERTY_NAME_RASTER, band); final DomElement originalDomElement = new DefaultDomElement("configuration"); final SessionDomConverter domConverter = new SessionDomConverter(productManager); // domConverter.convertValueToDom(configuration, originalDomElement); // For debug purposes System.out.println(originalDomElement.toXml()); // final PropertyContainer restoredConfiguration = (PropertyContainer) domConverter.convertDomToValue(originalDomElement, wmsLayerType.createLayerConfig(null)); compareConfigurations(configuration, restoredConfiguration); }
@Test public void testPersistency() throws ValidationException, ConversionException, MalformedURLException { final WmsLayerType wmsLayerType = LayerTypeRegistry.getLayerType(WmsLayerType.class); final PropertySet configuration = wmsLayerType.createLayerConfig(null); configuration.setValue(WmsLayerType.PROPERTY_NAME_STYLE_NAME, "FancyStyle"); configuration.setValue(WmsLayerType.PROPERTY_NAME_URL, new URL("http://www.mapserver.org")); configuration.setValue(WmsLayerType.PROPERTY_NAME_CRS_ENVELOPE, new CRSEnvelope("EPSG:4324", -10, 20, 15, 50)); configuration.setValue(WmsLayerType.PROPERTY_NAME_IMAGE_SIZE, new Dimension(200, 300)); configuration.setValue(WmsLayerType.PROPERTY_NAME_LAYER_INDEX, 12); configuration.setValue(WmsLayerType.PROPERTY_NAME_RASTER, band); final DomElement originalDomElement = new DefaultDomElement("configuration"); final SessionDomConverter domConverter = new SessionDomConverter(productManager); domConverter.convertValueToDom(configuration, originalDomElement); // For debug purposes // System.out.println(originalDomElement.toXml()); final PropertyContainer restoredConfiguration = (PropertyContainer) domConverter.convertDomToValue(originalDomElement, wmsLayerType.createLayerConfig(null)); compareConfigurations(configuration, restoredConfiguration); }
final DomElement domElement1 = new DefaultDomElement("configuration"); dc.convertValueToDom(configuration1, domElement1);