Package org.apache.cayenne.validation

Examples of org.apache.cayenne.validation.ValidationException


                MapQueryCacheFactory.class.getName()));
    }

    void setDomainName(String newName) {
        if (newName == null || newName.trim().length() == 0) {
            throw new ValidationException("Enter name for DataDomain");
        }

        Configuration configuration = ((ApplicationProject) Application.getProject())
                .getConfiguration();
       
        DataDomain domain = projectController.getCurrentDataDomain();

        DataDomain matchingDomain = configuration.getDomain(newName);

        if (matchingDomain == null) {
            Domain prefs = projectController.getPreferenceDomainForDataDomain();

            DomainEvent e = new DomainEvent(this, domain, domain.getName());
            ProjectUtil.setDataDomainName(configuration, domain, newName);
            prefs.rename(newName);
            projectController.fireDomainEvent(e);
        }
        else if (matchingDomain != domain) {
            throw new ValidationException("There is another DataDomain named '"
                    + newName
                    + "'. Use a different name.");
        }
    }
View Full Code Here


        if (text.length() > 0) {
            try {
                Integer.parseInt(text);
            }
            catch (NumberFormatException ex) {
                throw new ValidationException("Cache size must be an integer: " + text);
            }
        }

        setDomainProperty(DataRowStore.SNAPSHOT_CACHE_SIZE_PROPERTY, text, Integer
                .toString(DataRowStore.SNAPSHOT_CACHE_SIZE_DEFAULT));
View Full Code Here

        if (Util.nullSafeEquals(newName, query.getName())) {
            return;
        }

        if (newName == null) {
            throw new ValidationException("Query name is required.");
        }

        DataMap map = mediator.getCurrentDataMap();

        if (map.getQuery(newName) == null) {
            // completely new name, set new name for entity
            QueryEvent e = new QueryEvent(this, query, query.getName());
            ProjectUtil.setQueryName(map, query, newName);
            mediator.fireQueryEvent(e);
        }
        else {
            // there is a query with the same name
            throw new ValidationException("There is another query named '"
                    + newName
                    + "'. Use a different name.");
        }
    }
View Full Code Here

    }

    public void setTimeInterval(double d) {
        int ms = (int) (d * 1000.0);
        if (ms < CayennePreferenceService.MIN_SAVE_INTERVAL) {
            throw new ValidationException(
                    "Time interval is too small, minimum allowed is "
                            + (CayennePreferenceService.MIN_SAVE_INTERVAL / 1000.0));
        }

        this.editor.setSaveInterval(ms);
View Full Code Here

        eventController.fireDataMapEvent(new DataMapEvent(this, dataMap));
    }

    void setDataMapName(String newName) {
        if (newName == null || newName.trim().length() == 0) {
            throw new ValidationException("Enter name for DataMap");
        }

        DataMap map = eventController.getCurrentDataMap();

        // search for matching map name across domains, as currently they have to be
        // unique globally
        Configuration config = ((ApplicationProject) Application.getProject())
                .getConfiguration();

        DataMap matchingMap = null;

        for (DataDomain domain : config.getDomains()) {
            DataMap nextMap = domain.getMap(newName);

            if (nextMap == map) {
                continue;
            }

            if (nextMap != null) {
                matchingMap = nextMap;
                break;
            }
        }

        if (matchingMap != null) {

            // there is an entity with the same name
            throw new ValidationException("There is another DataMap named '"
                    + newName
                    + "'. Use a different name.");
        }
        String oldName = map.getName();
        if (Util.nullSafeEquals(newName, oldName)) {
View Full Code Here

        else {
            try {
                setQueryProperty("fetchOffset", new Integer(string));
            }
            catch (NumberFormatException nfex) {
                throw new ValidationException("Fetch offset must be an integer: "
                        + string);
            }
        }
    }
View Full Code Here

        else {
            try {
                setQueryProperty("fetchLimit", new Integer(string));
            }
            catch (NumberFormatException nfex) {
                throw new ValidationException("Fetch limit must be an integer: " + string);
            }
        }
    }
View Full Code Here

        else {
            try {
                setQueryProperty("pageSize", new Integer(string));
            }
            catch (NumberFormatException nfex) {
                throw new ValidationException("Page size must be an integer: " + string);
            }
        }
    }
View Full Code Here

        if (Util.nullSafeEquals(newName, query.getName())) {
            return;
        }

        if (newName == null) {
            throw new ValidationException("Query name is required.");
        }

        DataMap map = mediator.getCurrentDataMap();

        if (map.getQuery(newName) == null) {
            // completely new name, set new name for entity
            QueryEvent e = new QueryEvent(this, query, query.getName(), map);
            ProjectUtil.setQueryName(map, query, newName);
            mediator.fireQueryEvent(e);
        }
        else {
            // there is a query with the same name
            throw new ValidationException("There is another query named '"
                    + newName
                    + "'. Use a different name.");
        }
    }
View Full Code Here

                            }
                        }
                    }

                    if (result.hasFailures()) {
                        throw new ValidationException(result);
                    }
                }

                graphManager.graphCommitStarted();
View Full Code Here

TOP

Related Classes of org.apache.cayenne.validation.ValidationException

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.