Package org.apache.cayenne.validation

Examples of org.apache.cayenne.validation.ValidationResult


            statement.execute(sql);
            return true;
        }
        catch (SQLException ex) {
            if (this.failures == null) {
                this.failures = new ValidationResult();
            }

            failures.addFailure(new SimpleValidationFailure(sql, ex.getMessage()));
            QueryLogger.logQueryError(ex);
            return false;
View Full Code Here


        synchronized (graphManager) {

            if (graphManager.hasChanges()) {

                ValidationResult result = new ValidationResult();
                Iterator<?> it = graphManager.dirtyNodes().iterator();
                while (it.hasNext()) {
                    Persistent p = (Persistent) it.next();
                    if (p instanceof Validating) {
                        switch (p.getPersistenceState()) {
                            case PersistenceState.NEW:
                                ((Validating) p).validateForInsert(result);
                                break;
                            case PersistenceState.MODIFIED:
                                ((Validating) p).validateForUpdate(result);
                                break;
                            case PersistenceState.DELETED:
                                ((Validating) p).validateForDelete(result);
                                break;
                        }
                    }
                }

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

                graphManager.graphCommitStarted();
View Full Code Here

        synchronized (graphManager) {

            if (graphManager.hasChanges()) {

                ValidationResult result = new ValidationResult();
                Iterator<?> it = graphManager.dirtyNodes().iterator();
                while (it.hasNext()) {
                    Persistent p = (Persistent) it.next();
                    if (p instanceof Validating) {
                        switch (p.getPersistenceState()) {
                            case PersistenceState.NEW:
                                ((Validating) p).validateForInsert(result);
                                break;
                            case PersistenceState.MODIFIED:
                                ((Validating) p).validateForUpdate(result);
                                break;
                            case PersistenceState.DELETED:
                                ((Validating) p).validateForDelete(result);
                                break;
                        }
                    }
                }

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

                graphManager.graphCommitStarted();
View Full Code Here

        synchronized (graphManager) {

            if (graphManager.hasChanges()) {

                ValidationResult result = new ValidationResult();
                Iterator<?> it = graphManager.dirtyNodes().iterator();
                while (it.hasNext()) {
                    Persistent p = (Persistent) it.next();
                    if (p instanceof Validating) {
                        switch (p.getPersistenceState()) {
                            case PersistenceState.NEW:
                                ((Validating) p).validateForInsert(result);
                                break;
                            case PersistenceState.MODIFIED:
                                ((Validating) p).validateForUpdate(result);
                                break;
                            case PersistenceState.DELETED:
                                ((Validating) p).validateForDelete(result);
                                break;
                        }
                    }
                }

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

                graphManager.graphCommitStarted();
View Full Code Here

            }

            long t1 = System.currentTimeMillis();

            // report conflicts...
            ValidationResult conflicts = loader.getContext().getConflicts();
            if (conflicts.hasFailures()) {
                for (Object failure : conflicts.getFailures()) {
                    logger.info("*** mapping conflict: " + failure);
                }
            }

            if (logger.isDebugEnabled()) {
View Full Code Here

    protected PersistenceUnitInfo unit;
    protected ClassLoader tempClassLoader;

    public EntityMapLoaderContext(PersistenceUnitInfo unit) {
        this.unit = unit;
        this.conflicts = new ValidationResult();
        this.entityMap = new JpaEntityMap();
        this.tempClassLoader = unit.getNewTempClassLoader();
    }
View Full Code Here

            statement.execute(sql);
            return true;
        }
        catch (SQLException ex) {
            if (this.failures == null) {
                this.failures = new ValidationResult();
            }

            failures.addFailure(new SimpleValidationFailure(sql, ex.getMessage()));
            QueryLogger.logQueryError(ex);
            return false;
View Full Code Here

            }
        }

        if (objectsToValidate != null) {
            ValidationResult result = new ValidationResult();

            Iterator validationIt = objectsToValidate.iterator();
            while (validationIt.hasNext()) {
                Validating object = (Validating) validationIt.next();
                switch (((Persistent) object).getPersistenceState()) {
                    case PersistenceState.NEW:
                        object.validateForInsert(result);
                        break;
                    case PersistenceState.MODIFIED:
                        object.validateForUpdate(result);
                        break;
                    case PersistenceState.DELETED:
                        object.validateForDelete(result);
                        break;
                }
            }

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

        return noop;
View Full Code Here

                        .getFrameController()
                        .getProjectController();
                projectController.setDirty(true);
            }
           
            ValidationResult failures = mergerContext.getValidationResult();

            if (failures == null || !failures.hasFailures()) {
                JOptionPane.showMessageDialog(getView(), "Migration Complete.");
            }
            else {
                new ValidationResultBrowser(this).startupAction(
                        "Migration Complete",
View Full Code Here

        DataContext context = createDataContext();
        Exhibit exhibit = context.newObject(Exhibit.class);
        exhibit.setOpeningDate(new Date());
        exhibit.setClosingDate(new Date());

        ValidationResult result = new ValidationResult();
        exhibit.validateForSave(result);

        assertTrue("Validation of 'toGallery' should've failed.", result.hasFailures());
        assertTrue(result.hasFailures(exhibit));

        List failures = result.getFailures();
        assertEquals(1, failures.size());

        BeanValidationFailure failure = (BeanValidationFailure) failures.get(0);
        assertEquals(Exhibit.TO_GALLERY_PROPERTY, failure.getProperty());

        // fix the problem and see if it goes away
        Gallery gallery = context.newObject(Gallery.class);
        exhibit.setToGallery(gallery);
        result = new ValidationResult();
        exhibit.validateForSave(result);
        assertFalse("No failures expected: " + result, result.hasFailures());
    }
View Full Code Here

TOP

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

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.