Package org.apache.cayenne.map.event

Examples of org.apache.cayenne.map.event.RelationshipEvent


        DbEntity entity = mediator.getCurrentDbEntity();
        DbRelationship rel = mediator.getCurrentDbRelationship();
        entity.removeRelationship(rel.getName());
        ProjectUtil.cleanObjMappings(mediator.getCurrentDataMap());

        RelationshipEvent e = new RelationshipEvent(
                Application.getFrame(),
                rel,
                entity,
                MapEvent.REMOVE);
        mediator.fireDbRelationshipEvent(e);
View Full Code Here


                objEnt);
        rel.setSourceEntity(objEnt);
        objEnt.addRelationship(rel);

        mediator.fireObjRelationshipEvent(
            new RelationshipEvent(this, rel, objEnt, MapEvent.ADD));
       
        RelationshipDisplayEvent rde = new RelationshipDisplayEvent(
                this,
                rel,
                objEnt,
View Full Code Here

        rel.setSourceEntity(dbEnt);
        dbEnt.addRelationship(rel);

        mediator.fireDbRelationshipEvent(
            new RelationshipEvent(this, rel, dbEnt, MapEvent.ADD));

        RelationshipDisplayEvent rde = new RelationshipDisplayEvent(
                this,
                rel,
                dbEnt,
View Full Code Here

    protected void saveMapping() {
        ObjRelationshipInfoModel model = (ObjRelationshipInfoModel) getModel();

        if (model.savePath()) {
            mediator.fireObjRelationshipEvent(new RelationshipEvent(Application
                    .getFrame(), model.getRelationship(), model
                    .getRelationship()
                    .getSourceEntity()));
        }
        shutdown();
View Full Code Here

                    relationship.getSourceEntity(),
                    relationship,
                    sourceEntityName);

            getMediator().fireDbRelationshipEvent(
                    new RelationshipEvent(this, relationship, relationship
                            .getSourceEntity(), oldName));
        }

        model.commit();

        // check "to dep pk" setting,
        // maybe this is no longer valid
        if (relationship.isToDependentPK() && !relationship.isValidForDepPk()) {
            relationship.setToDependentPK(false);
        }

        // If new reverse DbRelationship was created, add it to the target
        // Don't create reverse with no joins - makes no sense...
        if (updatingReverse) {

            // If didn't find anything, create reverseDbRel
            if (reverseRelationship == null) {
                reverseRelationship = new DbRelationship(targetEntityName);
                reverseRelationship.setSourceEntity(relationship.getTargetEntity());
                reverseRelationship.setTargetEntity(relationship.getSourceEntity());
                reverseRelationship.setToMany(!relationship.isToMany());
                relationship.getTargetEntity().addRelationship(reverseRelationship);

                // fire only if the relationship is to the same entity...
                // this is needed to update entity view...
                if (relationship.getSourceEntity() == relationship.getTargetEntity()) {
                    getMediator().fireDbRelationshipEvent(
                            new RelationshipEvent(
                                    this,
                                    reverseRelationship,
                                    reverseRelationship.getSourceEntity(),
                                    MapEvent.ADD));
                }
            }
            else if (!Util.nullSafeEquals(targetEntityName, reverseRelationship.getName())) {
                String oldName = reverseRelationship.getName();
                ProjectUtil.setRelationshipName(
                        reverseRelationship.getSourceEntity(),
                        reverseRelationship,
                        targetEntityName);

                getMediator().fireDbRelationshipEvent(
                        new RelationshipEvent(
                                this,
                                reverseRelationship,
                                reverseRelationship.getSourceEntity(),
                                oldName));
            }

            Collection reverseJoins = getReverseJoins();
            reverseRelationship.setJoins(reverseJoins);

            // check if joins map to a primary key of this entity
            if (!relationship.isToDependentPK() && reverseRelationship.isValidForDepPk()) {
                reverseRelationship.setToDependentPK(true);
            }
        }

        getMediator()
                .fireDbRelationshipEvent(
                        new RelationshipEvent(this, relationship, relationship
                                .getSourceEntity()));
        dispose();
    }
View Full Code Here

    public void setUpdatedValueAt(Object aValue, int row, int column) {

        DbRelationship rel = getRelationship(row);
        // If name column
        if (column == NAME) {
            RelationshipEvent e = new RelationshipEvent(
                    eventSource,
                    rel,
                    entity,
                    rel.getName());
            rel.setName((String)aValue);
            //String text = (String) aValue;
            //ProjectUtil.setRelationshipName(entity, rel, text);
            mediator.fireDbRelationshipEvent(e);
            fireTableCellUpdated(row, column);
        }
        // If target column
        else if (column == TARGET) {
            DbEntity target = (DbEntity) aValue;

            // clear joins...
            rel.removeAllJoins();
            rel.setTargetEntity(target);

            RelationshipEvent e = new RelationshipEvent(eventSource, rel, entity);
            mediator.fireDbRelationshipEvent(e);
        }
        else if (column == TO_DEPENDENT_KEY) {
            boolean flag = ((Boolean) aValue).booleanValue();

            // make sure reverse relationship "to-dep-pk" is unset.
            if (flag) {
                DbRelationship reverse = rel.getReverseRelationship();
                if (reverse != null && reverse.isToDependentPK()) {
                    String message = "Unset reverse relationship's \"To Dep PK\" setting?";
                    int answer = JOptionPane.showConfirmDialog(Application
                            .getFrame(), message);
                    if (answer != JOptionPane.YES_OPTION) {
                        // no action needed
                        return;
                    }

                    // unset reverse
                    reverse.setToDependentPK(false);
                }
            }

            rel.setToDependentPK(flag);
            RelationshipEvent e = new RelationshipEvent(eventSource, rel, entity);
            mediator.fireDbRelationshipEvent(e);
        }
        else if (column == CARDINALITY) {
            Boolean temp = (Boolean) aValue;
            rel.setToMany(temp.booleanValue());
            RelationshipEvent e = new RelationshipEvent(eventSource, rel, entity);
            mediator.fireDbRelationshipEvent(e);
        }
        fireTableRowsUpdated(row, row);
    }
View Full Code Here

                while (relationships.hasNext()) {

                    ObjRelationship r = (ObjRelationship) relationships.next();
                    if (r.isUsedForLocking() != on) {
                        r.setUsedForLocking(on);
                        parent.fireObjRelationshipEvent(new RelationshipEvent(
                                this,
                                r,
                                entity));
                    }
                }
View Full Code Here

        }
    }

    public void setUpdatedValueAt(Object value, int row, int column) {
        ObjRelationship relationship = getRelationship(row);
        RelationshipEvent event =
            new RelationshipEvent(eventSource, relationship, entity);

        if (column == REL_NAME) {
            String text = (String) value;
            event.setOldName(relationship.getName());
            ProjectUtil.setRelationshipName(entity, relationship, text);
            fireTableCellUpdated(row, column);
        }
        else if (column == REL_TARGET) {
            ObjEntity target = (ObjEntity) value;
View Full Code Here

    public void removeRow(int row) {
        if (row < 0)
            return;
        Relationship rel = getRelationship(row);
        RelationshipEvent e;
        e = new RelationshipEvent(eventSource, rel, entity, RelationshipEvent.REMOVE);
        mediator.fireObjRelationshipEvent(e);
        objectList.remove(row);
        entity.removeRelationship(rel.getName());
        fireTableRowsDeleted(row, row);
    }
View Full Code Here

            if (updateRelationships) {
                for (ObjRelationship r : entity.getRelationships()) {
                    if (r.isUsedForLocking() != on) {
                        r.setUsedForLocking(on);
                        parent.fireObjRelationshipEvent(new RelationshipEvent(
                                this,
                                r,
                                entity));
                    }
                }
View Full Code Here

TOP

Related Classes of org.apache.cayenne.map.event.RelationshipEvent

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.