Package org.apache.cayenne.map

Examples of org.apache.cayenne.map.Embeddable


            // format even if no serialVersionUID is defined by the user
            SerialVersionUIDAdder e3 = new SerialVersionUIDAdder(e2);
            return e3;
        }

        Embeddable embeddable = embeddablesByClass.get(key);
        if (embeddable != null) {
            // create enhancer chain
            EmbeddableVisitor e1 = new EmbeddableVisitor(out);

            // this ensures that both enhanced and original classes have compatible
View Full Code Here


     */
    public static void setEmbeddableAttributeName(EmbeddableAttribute attribute, String newName) {
        String oldName = attribute.getName();

        attribute.setName(newName);
        Embeddable embeddable = attribute.getEmbeddable();
       
        if (embeddable != null) {
            embeddable.removeAttribute(oldName);
            embeddable.addAttribute(attribute);
        }
    }
View Full Code Here

    public void currentEmbeddableChanged(EmbeddableDisplayEvent e) {
        if (e.getSource() == this) {
            return;
        }

        Embeddable embeddable = (Embeddable) e.getEmbeddable();
        if (embeddable != null) {
            rebuildTable(embeddable);
        }

    }
View Full Code Here

        @Override
        protected Object create(String name, Object namingContext) {
            DataMap map = (DataMap) namingContext;
            if (map.getDefaultPackage() != null) {
                return new Embeddable(map.getDefaultPackage() + "." + name);
            }
            return new Embeddable(name);
        }
View Full Code Here

            return new EmbeddableAttribute(name);
        }

        @Override
        protected boolean isNameInUse(String name, Object namingContext) {
            Embeddable emb = (Embeddable) namingContext;
            return emb.getAttribute(name) != null;
        }
View Full Code Here

                        dataMap,
                        objEntity);
            }
            else if (content instanceof Embeddable) {
                // paste Embeddable to DataMap
                Embeddable embeddable = (Embeddable) content;
                embeddable.setClassName(getFreeName(
                        new EmbeddableNameChecker(domain),
                        embeddable.getClassName()));

                dataMap.addEmbeddable(embeddable);
                CreateEmbeddableAction.fireEmbeddableEvent(
                        this,
                        mediator,
                        dataMap,
                        embeddable);
            }
            else if (content instanceof EJBQLQuery) {
                EJBQLQuery query = (EJBQLQuery) content;

                query.setName(getFreeName(new QueryNameChecker(domain), query.getName()));
                query.setDataMap(dataMap);

                dataMap.addQuery(query);
                QueryType.fireQueryEvent(this, mediator, dataMap, query);
            }
            else if (content instanceof Query) {
                // paste Query to DataMap
                AbstractQuery query = (AbstractQuery) content;

                query.setName(getFreeName(new QueryNameChecker(domain), query.getName()));
                query.setDataMap(dataMap);

                dataMap.addQuery(query);
                QueryType.fireQueryEvent(this, mediator, dataMap, query);
            }
            else if (content instanceof Procedure) {
                // paste Procedure to DataMap
                Procedure procedure = (Procedure) content;
                procedure.setName(getFreeName(new ProcedureNameChecker(domain), procedure
                        .getName()));

                dataMap.addProcedure(procedure);
                CreateProcedureAction.fireProcedureEvent(
                        this,
                        mediator,
                        dataMap,
                        procedure);
            }
        }
        else if (where instanceof DbEntity) {
            final DbEntity dbEntity = (DbEntity) where;

            // attrs and rels must be unique in entity namespace
            FreeNameChecker checker = new FreeNameChecker() {

                public boolean isNameFree(String name) {
                    return dbEntity.getAttribute(name) == null
                            && dbEntity.getRelationship(name) == null;
                }
            };

            if (content instanceof DbAttribute) {
                DbAttribute attr = (DbAttribute) content;
                attr.setName(getFreeName(checker, attr.getName()));

                dbEntity.addAttribute(attr);
                CreateAttributeAction.fireDbAttributeEvent(this, mediator, mediator
                        .getCurrentDataMap(), dbEntity, attr);
            }
            else if (content instanceof DbRelationship) {
                DbRelationship rel = (DbRelationship) content;
                rel.setName(getFreeName(checker, rel.getName()));

                dbEntity.addRelationship(rel);
                CreateRelationshipAction.fireDbRelationshipEvent(
                        this,
                        mediator,
                        dbEntity,
                        rel);
            }
        }
        else if (where instanceof ObjEntity) {
            final ObjEntity objEntity = (ObjEntity) where;

            // attrs and rels must be unique in entity namespace
            FreeNameChecker checker = new FreeNameChecker() {

                public boolean isNameFree(String name) {
                    return objEntity.getAttribute(name) == null
                            && objEntity.getRelationship(name) == null;
                }
            };

            if (content instanceof ObjAttribute) {
                ObjAttribute attr = (ObjAttribute) content;
                attr.setName(getFreeName(checker, attr.getName()));

                objEntity.addAttribute(attr);
                CreateAttributeAction.fireObjAttributeEvent(this, mediator, mediator
                        .getCurrentDataMap(), objEntity, attr);
            }
            else if (content instanceof ObjRelationship) {
                ObjRelationship rel = (ObjRelationship) content;
                rel.setName(getFreeName(checker, rel.getName()));

                objEntity.addRelationship(rel);
                CreateRelationshipAction.fireObjRelationshipEvent(
                        this,
                        mediator,
                        objEntity,
                        rel);
            }
        }

        else if (where instanceof Embeddable) {
            final Embeddable embeddable = (Embeddable) where;

            // attrs and rels must be unique in entity namespace
            FreeNameChecker checker = new FreeNameChecker() {

                public boolean isNameFree(String name) {
                    return embeddable.getAttribute(name) == null;
                }
            };

            if (content instanceof EmbeddableAttribute) {
                EmbeddableAttribute attr = (EmbeddableAttribute) content;
                attr.setName(getFreeName(checker, attr.getName()));

                embeddable.addAttribute(attr);
                CreateAttributeAction.fireEmbeddableAttributeEvent(
                        this,
                        mediator,
                        embeddable,
                        attr);
View Full Code Here

                .iterator();
        while (it.hasNext()) {
            DataMap dataMap = (DataMap) it.next();
            Iterator<Embeddable> embs = dataMap.getEmbeddables().iterator();
            while (embs.hasNext()) {
                Embeddable emb = (Embeddable) embs.next();
                embeddableNames.add(emb.getClassName());
            }
        }

        String[] registeredTypes = ModelerUtil.getRegisteredTypeNames();
        for (int i = 0; i < registeredTypes.length; i++) {
View Full Code Here

     */
    public static void setEmbeddableAttributeName(EmbeddableAttribute attribute, String newName) {
        String oldName = attribute.getName();

        attribute.setName(newName);
        Embeddable embeddable = attribute.getEmbeddable();
       
        if (embeddable != null) {
            embeddable.removeAttribute(oldName);
            embeddable.addAttribute(attribute);
        }
    }
View Full Code Here

                        dataMap,
                        objEntity);
            }
            else if (content instanceof Embeddable) {
                // paste Embeddable to DataMap
                Embeddable embeddable = (Embeddable) content;
                embeddable.setClassName(getFreeName(
                        new EmbeddableNameChecker(domain),
                        embeddable.getClassName()));

                dataMap.addEmbeddable(embeddable);
                CreateEmbeddableAction.fireEmbeddableEvent(
                        this,
                        mediator,
                        dataMap,
                        embeddable);
            }
            else if (content instanceof Query) {
                // paste Query to DataMap
                AbstractQuery query = (AbstractQuery) content;

                /**
                 * Change Query root do current datamap's
                 */
                Object root = query.getRoot();
                Object newRoot = root;

                if (root instanceof ObjEntity) {
                    newRoot = dataMap.getObjEntity(((ObjEntity) root).getName());
                }
                else if (root instanceof DbEntity) {
                    newRoot = dataMap.getDbEntity(((DbEntity) root).getName());
                }
                else if (root instanceof Procedure) {
                    newRoot = dataMap.getProcedure(((Procedure) root).getName());
                }

                if (newRoot == null) {
                    JOptionPane
                            .showMessageDialog(
                                    Application.getFrame(),
                                    "Query root cannot be resolved. Pasting has not been performed.",
                                    "Warning",
                                    JOptionPane.WARNING_MESSAGE);
                    return;
                }

                query.setName(getFreeName(new QueryNameChecker(domain), query.getName()));
                query.setDataMap(dataMap);

                dataMap.addQuery(query);
                QueryTypeController.fireQueryEvent(this, mediator, dataMap, query);
            }
            else if (content instanceof Procedure) {
                // paste Procedure to DataMap
                Procedure procedure = (Procedure) content;
                procedure.setName(getFreeName(new ProcedureNameChecker(domain), procedure
                        .getName()));

                dataMap.addProcedure(procedure);
                CreateProcedureAction.fireProcedureEvent(
                        this,
                        mediator,
                        dataMap,
                        procedure);
            }
        }
        else if (where instanceof DbEntity) {
            final DbEntity dbEntity = (DbEntity) where;

            // attrs and rels must be unique in entity namespace
            FreeNameChecker checker = new FreeNameChecker() {

                public boolean isNameFree(String name) {
                    return dbEntity.getAttribute(name) == null
                            && dbEntity.getRelationship(name) == null;
                }
            };

            if (content instanceof DbAttribute) {
                DbAttribute attr = (DbAttribute) content;
                attr.setName(getFreeName(checker, attr.getName()));

                dbEntity.addAttribute(attr);
                CreateAttributeAction.fireDbAttributeEvent(this, mediator, mediator
                        .getCurrentDataMap(), dbEntity, attr);
            }
            else if (content instanceof DbRelationship) {
                DbRelationship rel = (DbRelationship) content;
                rel.setName(getFreeName(checker, rel.getName()));

                dbEntity.addRelationship(rel);
                CreateRelationshipAction.fireDbRelationshipEvent(
                        this,
                        mediator,
                        dbEntity,
                        rel);
            }
        }
        else if (where instanceof ObjEntity) {
            final ObjEntity objEntity = (ObjEntity) where;

            // attrs and rels must be unique in entity namespace
            FreeNameChecker checker = new FreeNameChecker() {

                public boolean isNameFree(String name) {
                    return objEntity.getAttribute(name) == null
                            && objEntity.getRelationship(name) == null;
                }
            };

            if (content instanceof ObjAttribute) {
                ObjAttribute attr = (ObjAttribute) content;
                attr.setName(getFreeName(checker, attr.getName()));

                objEntity.addAttribute(attr);
                CreateAttributeAction.fireObjAttributeEvent(this, mediator, mediator
                        .getCurrentDataMap(), objEntity, attr);
            }
            else if (content instanceof ObjRelationship) {
                ObjRelationship rel = (ObjRelationship) content;
                rel.setName(getFreeName(checker, rel.getName()));

                objEntity.addRelationship(rel);
                CreateRelationshipAction.fireObjRelationshipEvent(
                        this,
                        mediator,
                        objEntity,
                        rel);
            }
        }

        else if (where instanceof Embeddable) {
            final Embeddable embeddable = (Embeddable) where;

            // attrs and rels must be unique in entity namespace
            FreeNameChecker checker = new FreeNameChecker() {

                public boolean isNameFree(String name) {
                    return embeddable.getAttribute(name) == null;
                }
            };

            if (content instanceof EmbeddableAttribute) {
                EmbeddableAttribute attr = (EmbeddableAttribute) content;
                attr.setName(getFreeName(checker, attr.getName()));

                embeddable.addAttribute(attr);
                CreateAttributeAction.fireEmbeddableAttributeEvent(
                        this,
                        mediator,
                        embeddable,
                        attr);
View Full Code Here

        this.stringToEmbeddables = new HashMap<String, Embeddable>();
        this.embeddableNames = new ArrayList<String>();

        Iterator<Embeddable> embs = mediator.getEmbeddableNamesInCurRentDataDomain().iterator();
        while (embs.hasNext()) {
            Embeddable emb = (Embeddable) embs.next();
            stringToEmbeddables.put(emb.getClassName(), emb);
            embeddableNames.add(emb.getClassName());
        }
        initController(model.getAttribute(row));
    }
View Full Code Here

TOP

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

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.