Package org.apache.cayenne.map

Examples of org.apache.cayenne.map.Relationship


    }

    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 (e.getEntity() == null) {
            return;
        }

        // update relationship selection
        Relationship rel = e.getRelationship();
        if (rel instanceof ObjRelationship) {
            if (getSelectedComponent() != relationshipsPanel) {
                setSelectedComponent(relationshipsPanel);
                relationshipsPanel.setVisible(true);
            }
View Full Code Here

                        new RelationshipEvent(this, relationship, relationship
                                .getSourceEntity()));
    }

    private boolean validateName(Entity entity, Relationship aRelationship, String newName) {
        Relationship existing = entity.getRelationship(newName);
        if (existing != null && (aRelationship == null || aRelationship != existing)) {
            JOptionPane.showMessageDialog(
                    this,
                    "There is an existing relationship named \""
                            + newName
View Full Code Here

    }

    // Connects last selected DbRelationship in the path to the
    // last DbEntity, creating a dummy relationship if needed.
    private void connectEnds() {
        Relationship last = null;

        int size = dbRelationships.size();
        if (size > 0) {
            last = dbRelationships.get(size - 1);
        }

        Entity target = getEndEntity();

        if (target != null && (last == null || last.getTargetEntity() != target)) {
            // try to connect automatically, if we can't use dummy connector

            Entity source = (last == null) ? getStartEntity() : last.getTargetEntity();
            if (source != null) {

                Relationship anyConnector = source != null ? source
                        .getAnyRelationship(target) : null;

                if (anyConnector != null) {
                    dbRelationships.add((DbRelationship) anyConnector);
                }
View Full Code Here

        // at least two elements to constitute a valid ordering path
        if (selectedPath == null || selectedPath.getPathCount() < 2) {
            return;
        }

        Relationship rel = (Relationship) selectedPath.getLastPathComponent();
        DbEntity target = (DbEntity) rel.getTargetEntity();

        ObjRelationshipInfoModel model = (ObjRelationshipInfoModel) getModel();

        /**
         * Initialize root with one of mapped ObjEntities.
View Full Code Here

        // at least two elements to constitute a valid ordering path
        if (selectedPath == null || selectedPath.getPathCount() < 2) {
            return;
        }

        Relationship rel = (Relationship) selectedPath.getLastPathComponent();
        DbEntity target = (DbEntity) rel.getTargetEntity();

        ObjRelationshipInfoModel model = (ObjRelationshipInfoModel) getModel();

        /**
         * Initialize root with one of mapped ObjEntities.
View Full Code Here

                        new RelationshipEvent(this, relationship, relationship
                                .getSourceEntity()));
    }

    private boolean validateName(Entity entity, Relationship aRelationship, String newName) {
        Relationship existing = entity.getRelationship(newName);
        if (existing != null && (aRelationship == null || aRelationship != existing)) {
            JOptionPane.showMessageDialog(
                    this,
                    "There is an existing relationship named \""
                            + newName
View Full Code Here

        this.fullPath = fullPath + '.' + lastPathComponent;

        if (oldPath != null) {
            this.idPath = oldPath;
            Relationship lastRelationship = currentEntity
                    .getRelationship(lastPathComponent);
            if (lastRelationship != null) {
                ObjEntity targetEntity = (ObjEntity) lastRelationship.getTargetEntity();

                this.lastAlias = context.getTableAlias(fullPath, targetEntity
                        .getDbEntity()
                        .getFullyQualifiedName());
            }
            else {
                this.lastAlias = context.getTableAlias(oldPath, currentEntity
                        .getDbEntity()
                        .getFullyQualifiedName());

            }
        }
        else {
            Relationship lastRelationship = currentEntity
                    .getRelationship(lastPathComponent);

            ObjEntity targetEntity = null;
            if (lastRelationship != null) {
                targetEntity = (ObjEntity) lastRelationship.getTargetEntity();
            }
            else {
                targetEntity = currentEntity;
            }
View Full Code Here

*/
public class RelationshipEventTest extends TestCase {

  public void testRelationship() throws Exception {
    Object src = new Object();
    Relationship r = new DbRelationship();
    r.setName("xyz");
    RelationshipEvent e = new RelationshipEvent(src, null, null);

    e.setRelationship(r);
    assertSame(r, e.getRelationship());
  }
View Full Code Here

        // at least two elements to constitute a valid ordering path
        if (selectedPath == null || selectedPath.getPathCount() < 2) {
            return;
        }

        Relationship rel = (Relationship) selectedPath.getLastPathComponent();
        DbEntity target = (DbEntity) rel.getTargetEntity();
         /**
         * Initialize root with one of mapped ObjEntities.
         */
        Collection<ObjEntity> objEntities = target.getDataMap().getMappedEntities(target);

View Full Code Here

TOP

Related Classes of org.apache.cayenne.map.Relationship

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.