Package org.geotools.validation.dto

Examples of org.geotools.validation.dto.PlugInDTO


        // go through each plugIn
        //
        for (Iterator i = plugInNames.iterator(); i.hasNext();) {
            String plugInName = (String) i.next();
            PlugInDTO dto = (PlugInDTO) plugInDTOs.get(plugInName);
            Class plugInClass = null;

            plugInClass = Class.forName(dto.getClassName());

            if (plugInClass == null) {
                throw new ClassNotFoundException("Could class for "
                    + plugInName + ": class " + dto.getClassName()
                    + " not found");
            }

            Map plugInArgs = dto.getArgs();

            if (plugInArgs == null) {
                plugInArgs = new HashMap();
            }

            PlugIn plugIn = new PlugIn(plugInName, plugInClass,
                    dto.getDescription(), plugInArgs);
            plugIns.put(plugInName, plugIn);
        }

        // step 3
        // set up tests and add to processor
        //
        for (Iterator i = testSuiteDTOs.keySet().iterator(); i.hasNext();) {
            TestSuiteDTO tdto = (TestSuiteDTO) testSuiteDTOs.get(i.next());
            Iterator j = tdto.getTests().keySet().iterator();

            // for each TEST in the test suite
            while (j.hasNext()) {
                TestDTO dto = (TestDTO) tdto.getTests().get(j.next());

                // deal with test
                Map testArgs = dto.getArgs();

                if (testArgs == null) {
                    testArgs = new HashMap();
                } else {
                    Map m = new HashMap();
                    Iterator k = testArgs.keySet().iterator();

                    while (k.hasNext()) {
                        ArgumentDTO adto = (ArgumentDTO) testArgs.get(k.next());
                        m.put(adto.getName(), adto.getValue());
                    }

                    testArgs = m;
                }

                PlugIn plugIn = (org.geotools.validation.PlugIn) plugIns.get(dto.getPlugIn()
                                                                                .getName());
                Validation validation = plugIn.createValidation(dto.getName(),
                        dto.getDescription(), testArgs);

                if (validation instanceof FeatureValidation) {
                    addValidation((FeatureValidation) validation);
                }
View Full Code Here


        try {
           
            FileReader fr = features();
            if( fr == null ) return;
                       
            PlugInDTO dto = XMLReader.readPlugIn(fr);
            assertNotNull("Error if null", dto);
            assertTrue("Name read", "Constraint".equals(dto.getName()));
            assertTrue("Description read",
                "All features must pass the provided filter".equals(
                    dto.getDescription()));
            assertTrue("ClassName read",
                "org.geoserver.validation.plugins.filter.OGCFilter".equals(
                    dto.getClassName()));
            assertNotNull("Should be one arg.", dto.getArgs());
            assertTrue("Should be one arg.", dto.getArgs().size() == 1);
            assertTrue("Arg. name", dto.getArgs().containsKey("tempDirectory"));
            assertTrue("Arg. value : " + dto.getArgs().get("tempDirectory"),
                dto.getArgs().containsValue(new URI("file:///c:/temp")));
        } catch (Exception e) {
            fail(e.toString());
        }
    }
View Full Code Here

            //set-up
      FileReader fr = features();
      if( fr == null ) return;
     
            Map m = new HashMap();
            PlugInDTO dto = XMLReader.readPlugIn(fr);
            m.put(dto.getName(), dto);
            fr = new FileReader(
                    "C:/Java/workspace/geoserver/conf/plugins/NameInList.xml");
            dto = XMLReader.readPlugIn(fr);
            m.put(dto.getName(), dto);

            fr = new FileReader(
                    "C:/Java/workspace/geoserver/conf/validation/RoadTestSuite.xml");

            TestSuiteDTO testsuite = XMLReader.readTestSuite("test", fr, m);
View Full Code Here

     *
     * @throws ValidationException DOCUMENT ME!
     */
    public static PlugInDTO readPlugIn(Reader inputSource)
        throws ValidationException {
        PlugInDTO dto = new PlugInDTO();

        try {
            Element elem = null;

            try {
                elem = ReaderUtils.loadConfig(inputSource);
            } catch (ParserConfigurationException pce) {
                throw new ValidationException("Cannot parse the inputSource: Cannot configure the parser.",
                    pce);
            } catch (SAXException se) {
                throw new ValidationException("Cannot parse the inputSource: Cannot configure the parser.",
                    se);
            }

            try {
                dto.setName(ReaderUtils.getElementText(
                        ReaderUtils.getChildElement(elem, "name", true), true));
            } catch (SAXException e) {
                throw new ValidationException("Error parsing name for this plugin",
                    e);
            }

            try {
                dto.setDescription(ReaderUtils.getElementText(
                        ReaderUtils.getChildElement(elem, "description", true),
                        true));
            } catch (SAXException e) {
                throw new ValidationException(
                    "Error parsing description for the " + dto.getName()
                    + " plugin", e);
            }

            try {
                dto.setClassName(ReaderUtils.getElementText(
                        ReaderUtils.getChildElement(elem, "class", true), true));
            } catch (SAXException e) {
                throw new ValidationException("Error parsing class for the "
                    + dto.getName() + " plugin", e);
            }

            NodeList nl = elem.getElementsByTagName("argument");

            if (nl != null) {
                Map m = new HashMap();
                dto.setArgs(m);

                for (int i = 0; i < nl.getLength(); i++) {
                    elem = (Element) nl.item(i);

                    ArgumentDTO adto = null;
View Full Code Here

            r = new HashMap();

            for (int i = 0; i < fileList.length; i++) {
                if (fileList[i].canWrite() && fileList[i].isFile()) {
                    FileReader fr = new FileReader(fileList[i]);
                    PlugInDTO dto = XMLReader.readPlugIn(fr);
                    r.put(dto.getName(), dto);
                    fr.close();
                }
            }
        } catch (IOException e) {
            throw new ValidationException("An io error occured while loading the plugin's",
View Full Code Here

    public boolean equals(Object obj) {
        if ((obj == null) || !(obj instanceof PlugInDTO)) {
            return false;
        }

        PlugInDTO pi = (PlugInDTO) obj;
        boolean r = true;

        if (name != null) {
            r = r && (name.equals(pi.getName()));
        }

        if (description != null) {
            r = r && (description.equals(pi.getDescription()));
        }

        if (className != null) {
            r = r && (className.equals(pi.getClassName()));
        }

        if (args == null) {
            if (pi.getArgs() != null) {
                return false;
            }
        } else {
            if (pi.getArgs() != null) {
                r = r && args.equals(pi.getArgs());
            } else {
                return false;
            }
        }
View Full Code Here

     * </p>
     * @see java.lang.Object#clone()
     * @return PlugInDTO
     */
    public PlugInDTO toDTO() {
        PlugInDTO dto = new PlugInDTO();

        dto.setName(name);
        dto.setDescription(description);
        dto.setClassName(className);

        Map myArgs = new HashMap();

        if (this.args != null) {
            Iterator i = this.args.keySet().iterator();

            while (i.hasNext()) {
                String key = (String) i.next();

                myArgs.put(key, ((ArgumentConfig) this.args.get(key)).toDTO());
            }
        }

        dto.setArgs(myArgs);

        return dto;
    }
View Full Code Here

        // Mark all plug-ins as not loaded
        //
        i = plugIns.values().iterator();

        while (i.hasNext()) {
            PlugInDTO dto = (PlugInDTO) i.next();
            errors.put(dto, Boolean.FALSE);
        }

        // step 2 configure plug-ins with defaults
        Map defaultPlugIns = new HashMap(plugInNames.size());
        i = plugInNames.iterator();

        while (i.hasNext()) {
            String plugInName = (String) i.next();
            PlugInDTO dto = (PlugInDTO) plugIns.get(plugInName);
            Class plugInClass = null;

            try {
                plugInClass = Class.forName(dto.getClassName());
            } catch (ClassNotFoundException e) {
                //Error, using default.
                errors.put(dto, e);
                e.printStackTrace();
            }

            if (plugInClass == null) {
                plugInClass = Validation.class;
            }

            Map plugInArgs = dto.getArgs();

            if (plugInArgs == null) {
                plugInArgs = new HashMap();
            }

            try {
                PlugIn plugIn = new org.geotools.validation.PlugIn(plugInName, plugInClass,
                        dto.getDescription(), plugInArgs);
                defaultPlugIns.put(plugInName, plugIn);
            } catch (ValidationException e) {
                e.printStackTrace();
                // Update dto entry w/ an error?
                errors.put(dto, e);

                continue;
            }

            // mark dto entry as a success
            errors.put(dto, Boolean.TRUE);
        }

        // step 3 configure plug-ins with tests + add to processor
        i = testSuites.keySet().iterator();

        while (i.hasNext()) {
            TestSuiteDTO tdto = (TestSuiteDTO) testSuites.get(i.next());
            Iterator j = tdto.getTests().keySet().iterator();

            while (j.hasNext()) {
                TestDTO dto = (TestDTO) tdto.getTests().get(j.next());

                // deal with test
                Map testArgs = dto.getArgs();

                if (testArgs == null) {
                    testArgs = new HashMap();
                } else {
                    Map m = new HashMap();
                    Iterator k = testArgs.keySet().iterator();

                    while (k.hasNext()) {
                        ArgumentDTO adto = (ArgumentDTO) testArgs.get(k.next());
                        m.put(adto.getName(), adto.getValue());
                    }

                    testArgs = m;
                }

                try {
                    PlugIn plugIn = (org.geotools.validation.PlugIn) defaultPlugIns.get(dto.getPlugIn()
                                                                                           .getName());
                    Validation validation = plugIn.createValidation(dto.getName(),
                            dto.getDescription(), testArgs);

                    if (validation instanceof FeatureValidation) {
                        addValidation((FeatureValidation) validation);
                    }
View Full Code Here

        Iterator i = null;
        i = plugIns.keySet().iterator();

        while (i.hasNext()) {
            PlugInDTO dto = (PlugInDTO) plugIns.get(i.next());
            PlugInConfig config = new PlugInConfig(dto);
            this.plugIns.put(config.getName(), config);
        }

        i = testSuites.keySet().iterator();
View Full Code Here

        // list are empty, and exist.
        Iterator i = null;
        i = this.plugIns.keySet().iterator();

        while (i.hasNext()) {
            PlugInDTO dto = ((PlugInConfig) this.plugIns.get(i.next())).toDTO();
            plugIns.put(dto.getName(), dto);
        }

        i = this.testSuites.keySet().iterator();

        while (i.hasNext()) {
            TestSuiteDTO dto = ((TestSuiteConfig) this.testSuites.get(i.next())).toDTO(plugIns);
            testSuites.put(dto.getName(), dto);
        }

        return true;
    }
View Full Code Here

TOP

Related Classes of org.geotools.validation.dto.PlugInDTO

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.