Package org.apache.cayenne.map

Examples of org.apache.cayenne.map.Embeddable


                  }
                 
                  Iterator<Embeddable> embIterator = dm.getEmbeddables().iterator();
                 
                  while(embIterator.hasNext()) {
                      Embeddable emb = embIterator.next();
                      if(matchFound(emb.getClassName(), pattern)){
                          paths.add(emb);
                      }
                     
                      Iterator<EmbeddableAttribute> attrIterator = emb.getAttributes().iterator();
                     
                      while(attrIterator.hasNext()) {
                          EmbeddableAttribute attr = attrIterator.next();
                          if(matchFound(attr.getName(), pattern)){
                              paths.add(attr);
View Full Code Here


        actionManager.getAction(RemoveAttributeAction.class).setEnabled(false);
        actionManager.getAction(RemoveCallbackMethodAction.class).setEnabled(false);
    }

    public void currentEmbeddableChanged(EmbeddableDisplayEvent e) {
        Embeddable emb = e.getEmbeddable();
        if (e.isMainTabFocus() && emb instanceof Embeddable) {
           
            if (getSelectedComponent() != embeddablePanel) {
                setSelectedComponent(embeddablePanel);
                embeddablePanel.setVisible(true);
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

    void setClassName(String newClassName) {
        if (newClassName != null && newClassName.trim().length() == 0) {
            newClassName = null;
        }

        Embeddable embeddable = mediator.getCurrentEmbeddable();

        if (embeddable == null) {
            return;
        }

        if (Util.nullSafeEquals(newClassName, embeddable.getClassName())) {
            return;
        }

        if (newClassName == null) {
            throw new ValidationException("Embeddable name is required.");
        }
        else if (embeddable.getDataMap().getEmbeddable(newClassName) == null) {
           
            // if newClassName dupliucates in other DataMaps
            DataChannelDescriptor domain = (DataChannelDescriptor) mediator.getProject().getRootNode();
            if (domain != null) {
                for (DataMap nextMap : domain.getDataMaps()) {
                    if (nextMap == embeddable.getDataMap()) {
                        continue;
                    }

                    Embeddable conflictingEmbeddable = nextMap.getEmbeddable(newClassName);
                    if (conflictingEmbeddable != null) {
                        throw new ValidationException(
                                    "Duplicate Embeddable name in another DataMap: "
                                            + newClassName
                                            + ".");
View Full Code Here

        }

    }

    public void currentEmbeddableChanged(EmbeddableDisplayEvent e) {
        Embeddable embeddable = e.getEmbeddable();
        if (embeddable == null || !e.isEmbeddableChanged()) {
            return;
        }
        initFromModel(embeddable);
    }
View Full Code Here

    @Override
    public void performAction(ActionEvent e) {
        ProjectController mediator = getProjectController();

        if (getProjectController().getCurrentEmbeddable() != null) {
            Embeddable embeddable = mediator.getCurrentEmbeddable();

            EmbeddableAttribute attr = (EmbeddableAttribute) NamedObjectFactory
                    .createObject(EmbeddableAttribute.class, embeddable);

            createEmbAttribute(embeddable, attr);
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

    public void performAction(ActionEvent e) {
        ProjectController mediator = getProjectController();

        DataMap dataMap = mediator.getCurrentDataMap();

        Embeddable embeddable = (Embeddable) NamedObjectFactory.createObject(
                Embeddable.class,
                mediator.getCurrentDataMap());

        createEmbeddable(dataMap, embeddable);
View Full Code Here

            }
        }
    }

    public void embeddableAdded(EmbeddableEvent e, DataMap map) {
        Embeddable embeddable = e.getEmbeddable();

        DefaultMutableTreeNode mapNode = getProjectModel().getNodeForObjectPath(
                new Object[] {
                        e.getDomain() != null
                                ? e.getDomain()
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

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.