Examples of EmbeddedAttribute


Examples of org.apache.cayenne.map.EmbeddedAttribute

        this.attribute = attr;

        if (attribute instanceof EmbeddedAttribute
                || embeddableNames.contains(attribute.getType())) {
            this.attributeSaved = new EmbeddedAttribute();
        }
        else {
            this.attributeSaved = new ObjAttribute();
        }

        copyObjAttribute(attributeSaved, attribute);

        relTargets = new ArrayList<DbEntity>(attribute
                .getEntity()
                .getDataMap()
                .getDbEntities());

        /**
         * Register auto-selection of the target
         */
        view.getPathBrowser().addTreeSelectionListener(this);

        view.getAttributeName().setText(attribute.getName());
        if (attribute.getDbAttributePath() != null) {
            if (attribute.getDbAttributePath().contains(".")) {
                String path = attribute.getDbAttributePath();
                view.getCurrentPathLabel().setText(path.replace(".", " -> "));
            }
            else {
                view.getCurrentPathLabel().setText(attribute.getDbAttributePath());
            }
        }
        else {
            view.getCurrentPathLabel().setText("");
        }
        view.getSourceEntityLabel().setText(attribute.getEntity().getName());

        view.getType().setSelectedItem(attribute.getType());

        BindingBuilder builder = new BindingBuilder(
                getApplication().getBindingFactory(),
                this);
        builder.bindToAction(view.getCancelButton(), "closeAction()");
        builder.bindToAction(view.getSelectPathButton(), "setPath(true)");
        builder.bindToAction(view.getSaveButton(), "saveMapping()");

        /*
         * set filter for ObjAttributePathBrowser
         */
        if (view.getPathBrowser().getModel() == null) {
            Entity firstEntity = null;
            if (attribute.getDbAttribute() == null) {

                if (attribute.getParent() instanceof ObjEntity) {
                    DbEntity dbEnt = ((ObjEntity) attribute.getParent()).getDbEntity();

                    if (dbEnt != null) {
                        Collection<DbAttribute> attrib = dbEnt.getAttributes();
                        Collection<DbRelationship> rel = dbEnt.getRelationships();

                        if (attrib.size() > 0) {
                            Iterator<DbAttribute> iter = attrib.iterator();
                            firstEntity = iter.next().getEntity();
                        }
                        else if (rel.size() > 0) {
                            Iterator<DbRelationship> iter = rel.iterator();
                            firstEntity = iter.next().getSourceEntity();
                        }
                    }
                }
            }
            else {
                firstEntity = getFirstEntity();
            }

            if (firstEntity != null) {
                EntityTreeModel treeModel = new EntityTreeModel(firstEntity);
                treeModel.setFilter(new EntityTreeFilter() {

                    public boolean attributeMatch(Object node, Attribute attr) {
                        if (!(node instanceof Attribute)) {
                            return true;
                        }
                        return false;
                    }

                    public boolean relationshipMatch(Object node, Relationship rel) {
                        if (!(node instanceof Relationship)) {
                            return true;
                        }

                        /**
                         * We do not allow A->B->A chains, where relationships are to-one
                         */
                        DbRelationship prev = (DbRelationship) node;
                        return !(!rel.isToMany() && prev.getReverseRelationship() == rel);
                    }
                });
                view.getPathBrowser().setModel(treeModel);
            }
        }

        if (attribute.getDbAttribute() != null) {
            setSelectionPath();
        }

        view.getType().addItemListener(new ItemListener() {

            public void itemStateChanged(ItemEvent e) {
                if (lastObjectType != null) {
                    if (!lastObjectType.equals(e.getItemSelectable())) {

                        if (embeddableNames.contains(e
                                .getItemSelectable()
                                .getSelectedObjects()[0].toString())) {
                            if (attributeSaved instanceof ObjAttribute) {
                                EmbeddedAttribute copyAttrSaved = new EmbeddedAttribute();
                                copyObjAttribute(copyAttrSaved, attributeSaved);
                                attributeSaved = copyAttrSaved;
                            }
                        }
                        else {
View Full Code Here

Examples of org.apache.cayenne.map.EmbeddedAttribute

        super(mediator, eventSource, new ArrayList<Object>(embAttr));
        this.embeddableList = new ArrayList<EmbeddableAttribute>(embAttr);
        this.attr = attr;
        this.isAttributeOverrideChange = false;
        if (attr instanceof EmbeddedAttribute) {
            EmbeddedAttribute embeddedAttribute = (EmbeddedAttribute) attr;
            this.overrideAttr = embeddedAttribute.getAttributeOverrides();
        }
        else {
            this.overrideAttr = null;
        }
View Full Code Here

Examples of org.apache.cayenne.map.EmbeddedAttribute

                }
               
                if(registeredTypesList.contains(newType) || !embNames.contains(newType)){
                    attributeNew = new ObjAttribute();
                } else {
                    attributeNew = new EmbeddedAttribute();
                    attribute.setDbAttributePath(null);
                }
               
                attributeNew.setDbAttributePath(attribute.getDbAttributePath());
                attributeNew.setName(attribute.getName());
View Full Code Here

Examples of org.apache.cayenne.map.EmbeddedAttribute

            return;
        }

        for (Attribute attribute : entity.getAttributes()) {
            if (attribute instanceof EmbeddedAttribute) {
                EmbeddedAttribute embeddedAttribute = (EmbeddedAttribute) attribute;
                for (ObjAttribute subAttribute : embeddedAttribute.getAttributes()) {
                    ValidationFailure failure = validateEmbeddedAttribute(subAttribute);
                    if (failure != null) {
                        validationBuffer.addFailure(failure);
                        return;
                    }
View Full Code Here

Examples of org.apache.cayenne.map.EmbeddedAttribute

        Object createObject(ProjectPath path) {
            JpaEmbedded jpaEmbedded = (JpaEmbedded) path.getObject();

            ObjEntity entity = (ObjEntity) targetPath.getObject();

            EmbeddedAttribute embedded = new EmbeddedAttribute(jpaEmbedded.getName());
            embedded.setType(jpaEmbedded.getPropertyDescriptor().getType().getName());

            for (JpaAttributeOverride override : jpaEmbedded.getAttributeOverrides()) {
                embedded.addAttributeOverride(override.getName(), override
                        .getColumn()
                        .getName());
            }

            entity.addAttribute(embedded);
View Full Code Here

Examples of org.apache.cayenne.map.EmbeddedAttribute

        this.attribute = attr;

        if (attribute instanceof EmbeddedAttribute
                || embeddableNames.contains(attribute.getType())) {
            this.attributeSaved = new EmbeddedAttribute();
        }
        else {
            this.attributeSaved = new ObjAttribute();
        }

        copyObjAttribute(attributeSaved, attribute);

        relTargets = new ArrayList<DbEntity>(attribute
                .getEntity()
                .getDataMap()
                .getDbEntities());

        /**
         * Register auto-selection of the target
         */
        view.getPathBrowser().addTreeSelectionListener(this);

        view.getAttributeName().setText(attribute.getName());
        if (attribute.getDbAttributePath() != null) {
            if (attribute.getDbAttributePath().contains(".")) {
                String path = attribute.getDbAttributePath();
                view.getCurrentPathLabel().setText(path.replace(".", " -> "));
            }
            else {
                view.getCurrentPathLabel().setText(attribute.getDbAttributePath());
            }
        }
        else {
            view.getCurrentPathLabel().setText("");
        }
        view.getSourceEntityLabel().setText(attribute.getEntity().getName());

        view.getType().setSelectedItem(attribute.getType());

        BindingBuilder builder = new BindingBuilder(
                getApplication().getBindingFactory(),
                this);
        builder.bindToAction(view.getCancelButton(), "closeAction()");
        builder.bindToAction(view.getSelectPathButton(), "setPath(true)");
        builder.bindToAction(view.getSaveButton(), "saveMapping()");

        /*
         * set filter for ObjAttributePathBrowser
         */
        if (view.getPathBrowser().getModel() == null) {
            Entity firstEntity = null;
            if (attribute.getDbAttribute() == null) {

                if (attribute.getParent() instanceof ObjEntity) {
                    DbEntity dbEnt = ((ObjEntity) attribute.getParent()).getDbEntity();

                    if (dbEnt != null) {
                        Collection<DbAttribute> attrib = dbEnt.getAttributes();
                        Collection<DbRelationship> rel = dbEnt.getRelationships();

                        if (attrib.size() > 0) {
                            Iterator<DbAttribute> iter = attrib.iterator();
                            firstEntity = iter.next().getEntity();
                        }
                        else if (rel.size() > 0) {
                            Iterator<DbRelationship> iter = rel.iterator();
                            firstEntity = iter.next().getSourceEntity();
                        }
                    }
                }
            }
            else {
                firstEntity = getFirstEntity();
            }

            if (firstEntity != null) {
                EntityTreeModel treeModel = new EntityTreeModel(firstEntity);
                treeModel.setFilter(new EntityTreeFilter() {

                    public boolean attributeMatch(Object node, Attribute attr) {
                        if (!(node instanceof Attribute)) {
                            return true;
                        }
                        return false;
                    }

                    public boolean relationshipMatch(Object node, Relationship rel) {
                        if (!(node instanceof Relationship)) {
                            return true;
                        }

                        /**
                         * We do not allow A->B->A chains, where relationships are to-one
                         */
                        DbRelationship prev = (DbRelationship) node;
                        return !(!rel.isToMany() && prev.getReverseRelationship() == rel);
                    }
                });
                view.getPathBrowser().setModel(treeModel);
            }
        }

        if (attribute.getDbAttribute() != null) {
            setSelectionPath();
        }

        view.getType().addItemListener(new ItemListener() {

            public void itemStateChanged(ItemEvent e) {
                if (lastObjectType != null) {
                    if (!lastObjectType.equals(e.getItemSelectable())) {

                        if (embeddableNames.contains(e
                                .getItemSelectable()
                                .getSelectedObjects()[0].toString())) {
                            if (attributeSaved instanceof ObjAttribute) {
                                EmbeddedAttribute copyAttrSaved = new EmbeddedAttribute();
                                copyObjAttribute(copyAttrSaved, attributeSaved);
                                attributeSaved = copyAttrSaved;
                            }
                        }
                        else {
View Full Code Here

Examples of org.apache.cayenne.map.EmbeddedAttribute

            if (attribute instanceof ObjAttribute) {
                createAttributeProperty(descriptor, (ObjAttribute) attribute);
            }
            else if (attribute instanceof EmbeddedAttribute) {
                EmbeddedAttribute embedded = (EmbeddedAttribute) attribute;
                Iterator embeddedAttributes = embedded.getAttributes().iterator();
                while (embeddedAttributes.hasNext()) {
                    createEmbeddedAttributeProperty(
                            descriptor,
                            embedded,
                            (ObjAttribute) embeddedAttributes.next());
View Full Code Here

Examples of org.apache.cayenne.map.EmbeddedAttribute

        this.attribute = attr;

        if (attribute instanceof EmbeddedAttribute
                || embeddableNames.contains(attribute.getType())) {
            this.attributeSaved = new EmbeddedAttribute();
        }
        else {
            this.attributeSaved = new ObjAttribute();
        }

        copyObjAttribute(attributeSaved, attribute);

        relTargets = new ArrayList<DbEntity>(attribute
                .getEntity()
                .getDataMap()
                .getDbEntities());

        /**
         * Register auto-selection of the target
         */
        view.getPathBrowser().addTreeSelectionListener(this);

        view.getAttributeName().setText(attribute.getName());
        if (attribute.getDbAttributePath() != null) {
            if (attribute.getDbAttributePath().contains(".")) {
                String path = attribute.getDbAttributePath();
                view.getCurrentPathLabel().setText(path.replace(".", " -> "));
            }
            else {
                view.getCurrentPathLabel().setText(attribute.getDbAttributePath());
            }
        }
        else {
            view.getCurrentPathLabel().setText("");
        }
        view.getSourceEntityLabel().setText(attribute.getEntity().getName());

        view.getTypeComboBox().setSelectedItem(attribute.getType());

        BindingBuilder builder = new BindingBuilder(
                getApplication().getBindingFactory(),
                this);
        builder.bindToAction(view.getCancelButton(), "closeAction()");
        builder.bindToAction(view.getSelectPathButton(), "setPath(true)");
        builder.bindToAction(view.getSaveButton(), "saveMapping()");

        /*
         * set filter for ObjAttributePathBrowser
         */
        if (view.getPathBrowser().getModel() == null) {
            Entity firstEntity = null;
            if (attribute.getDbAttribute() == null) {

                if (attribute.getParent() instanceof ObjEntity) {
                    DbEntity dbEnt = ((ObjEntity) attribute.getParent()).getDbEntity();

                    if (dbEnt != null) {
                        Collection<DbAttribute> attrib = dbEnt.getAttributes();
                        Collection<DbRelationship> rel = dbEnt.getRelationships();

                        if (attrib.size() > 0) {
                            Iterator<DbAttribute> iter = attrib.iterator();
                            firstEntity = iter.next().getEntity();
                        }
                        else if (rel.size() > 0) {
                            Iterator<DbRelationship> iter = rel.iterator();
                            firstEntity = iter.next().getSourceEntity();
                        }
                    }
                }
            }
            else {
                firstEntity = getFirstEntity();
            }

            if (firstEntity != null) {
                EntityTreeModel treeModel = new EntityTreeModel(firstEntity);
                treeModel.setFilter(new EntityTreeFilter() {

                    public boolean attributeMatch(Object node, Attribute attr) {
                        if (!(node instanceof Attribute)) {
                            return true;
                        }
                        return false;
                    }

                    public boolean relationshipMatch(Object node, Relationship rel) {
                        if (!(node instanceof Relationship)) {
                            return true;
                        }

                        /**
                         * We do not allow A->B->A chains, where relationships are to-one
                         */
                        DbRelationship prev = (DbRelationship) node;
                        return !(!rel.isToMany() && prev.getReverseRelationship() == rel);
                    }
                });
                view.getPathBrowser().setModel(treeModel);
            }
        }

        if (attribute.getDbAttribute() != null) {
            setSelectionPath();
        }

        view.getTypeComboBox().addItemListener(new ItemListener() {

            public void itemStateChanged(ItemEvent e) {
                if (lastObjectType != null) {
                    if (!lastObjectType.equals(e.getItemSelectable())) {

                        if (embeddableNames.contains(e
                                .getItemSelectable()
                                .getSelectedObjects()[0].toString())) {
                            if (attributeSaved instanceof ObjAttribute) {
                                EmbeddedAttribute copyAttrSaved = new EmbeddedAttribute();
                                copyObjAttribute(copyAttrSaved, attributeSaved);
                                attributeSaved = copyAttrSaved;
                            }
                        }
                        else {
View Full Code Here

Examples of org.apache.cayenne.map.EmbeddedAttribute

            return;
        }

        for (Attribute attribute : entity.getAttributes()) {
            if (attribute instanceof EmbeddedAttribute) {
                EmbeddedAttribute embeddedAttribute = (EmbeddedAttribute) attribute;
                for (ObjAttribute subAttribute : embeddedAttribute.getAttributes()) {
                    ValidationFailure failure = validateEmbeddedAttribute(subAttribute);
                    if (failure != null) {
                        validationBuffer.addFailure(failure);
                        return;
                    }
View Full Code Here

Examples of org.apache.cayenne.map.EmbeddedAttribute

        super(mediator, eventSource, new ArrayList<Object>(embAttr));
        this.embeddableList = new ArrayList<EmbeddableAttribute>(embAttr);
        this.attr = attr;
        this.isAttributeOverrideChange = false;
        if (attr instanceof EmbeddedAttribute) {
            EmbeddedAttribute embeddedAttribute = (EmbeddedAttribute) attr;
            this.overrideAttr = embeddedAttribute.getAttributeOverrides();
        }
        else {
            this.overrideAttr = null;
        }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.