Package org.apache.cayenne.map

Examples of org.apache.cayenne.map.DataMap


            throw new ConfigurationException("Domain is not loaded: " + domainName);
        }

        // load DataMaps tree
        for (String name : locations.keySet()) {
            DataMap map = domain.getMap(name);
            if (map != null) {
                continue;
            }

            loadDataMap(domain, name, locations);
View Full Code Here


            getStatus().addFailedMap(mapName, location, "map location not found");
            return null;
        }

        try {
            DataMap map = getMapLoader().loadDataMap(new InputSource(mapIn));

            logger.info("loaded <map name='"
                    + mapName
                    + "' location='"
                    + location
                    + "'>.");

            map.setName(mapName);
            map.setLocation(location);

            domain.addMap(map);
            return map;
        }
        catch (Exception dmex) {
View Full Code Here

            logger.info("<map-ref> has no 'name'.");
            throw new ConfigurationException("<map-ref> has no 'name'.");
        }

        logger.info("loaded map-ref: " + mapName + ".");
        DataMap map = null;
        DataNode node = null;

        try {
            map = findMap(domainName, mapName);
        }
View Full Code Here

    public void setObjEntityClassName(String n) {
        objEntityClassName = n;
    }

    public void execute(MergerContext mergerContext) {
        DataMap map = mergerContext.getDataMap();
        map.addDbEntity(getEntity());

        // create a ObjEntity
        String objEntityName = NameConverter.underscoredToJava(getEntity().getName(), true);
        // this loop will terminate even if no valid name is found
        // to prevent loader from looping forever (though such case is very unlikely)
        String baseName = objEntityName;
        for (int i = 1; i < 1000 && map.getObjEntity(objEntityName) != null; i++) {
            objEntityName = baseName + i;
        }

        ObjEntity objEntity = new ObjEntity(objEntityName);
        objEntity.setDbEntity(getEntity());

        // try to find a class name for the ObjEntity
        String className = objEntityClassName;
        if (className == null) {
            // we should generate a className based on the objEntityName
            String packageName = map.getDefaultPackage();
            if (Util.isEmptyString(packageName)) {
                packageName = "";
            }
            else if (!packageName.endsWith(".")) {
                packageName = packageName + ".";
            }
            className = packageName + objEntityName;
        }

        objEntity.setClassName(className);
        map.addObjEntity(objEntity);

        synchronizeWithObjEntity(getEntity());
    }
View Full Code Here

    public synchronized DataMap toDataMap(String name, EntityMapLoaderContext context) {
        this.context = context;

        // reset
        DataMap dataMap = new DataMap(name);
        dataMap.setDefaultPackage(context.getEntityMap().getPackageName());
        dataMap.setDefaultSchema(context.getEntityMap().getSchema());

        this.targetPath = new ProjectPath(dataMap);

        if (visitor == null) {
            visitor = createVisitor();
View Full Code Here

        // DbAttribute "no precision" means -1, not 0 like in JPA.
        if (column.getPrecision() > 0) {
            dbAttribute.setAttributePrecision(column.getPrecision());
        }

        DataMap dataMap = targetPath.firstInstanceOf(DataMap.class);
        DbEntity entity = dataMap.getDbEntity(tableName);

        if (entity == null) {
            // table may be defined in a superclass that is not processed yet... so create
            // a barebone version, with all remaining properties to be set later
            entity = new DbEntity(tableName);
            dataMap.addDbEntity(entity);
        }

        entity.addAttribute(dbAttribute);
    }
View Full Code Here

        @Override
        public boolean onStartNode(ProjectPath path) {
            JpaEntityListener jpaListener = (JpaEntityListener) path.getObject();

            DataMap map = (DataMap) targetPath.firstInstanceOf(DataMap.class);
            EntityListener listener = makeEntityListener(jpaListener);
            map.addDefaultEntityListener(listener);

            return false;
        }
View Full Code Here

        @Override
        public void onFinishNode(ProjectPath path) {

            JpaEntity entity = path.firstInstanceOf(JpaEntity.class);
            DataMap dataMap = targetPath.firstInstanceOf(DataMap.class);
            ObjEntity cayenneEntity = targetPath.firstInstanceOf(ObjEntity.class);

            // as superentity may not be loaded yet, must lookup DbEntity via JPA
            // mapping...
            DbEntity cayennePrimaryTable = dataMap.getDbEntity(entity
                    .lookupTable()
                    .getName());

            for (JpaSecondaryTable secondaryTable : entity.getSecondaryTables()) {

                // create a relationship between master DbEntity and a secondary
                // DbEntity...

                DbEntity cayenneSecondaryTable = dataMap.getDbEntity(secondaryTable
                        .getName());

                JpaDbRelationship dbRelationship = new JpaDbRelationship(
                        getSecondaryTableDbRelationshipName(secondaryTable.getName()));
                dbRelationship.setTargetEntityName(secondaryTable.getName());
View Full Code Here

    /**
     * Removes named DataMap from this DataDomain and any underlying DataNodes that
     * include it.
     */
    public synchronized void removeMap(String mapName) {
        DataMap map = getMap(mapName);
        if (map == null) {
            return;
        }

        // remove from data nodes
View Full Code Here

            }

            cayenneQuery.setName(jpaQuery.getName());
            cayenneQuery.setJpaQuery(jpaQuery);

            DataMap parentMap = (DataMap) targetPath.firstInstanceOf(DataMap.class);

            ObjEntity parentEntity = (ObjEntity) targetPath
                    .firstInstanceOf(ObjEntity.class);
            if (parentEntity != null) {
                cayenneQuery.setParentEntity(parentEntity);
            }
            else {
                cayenneQuery.setParentMap(parentMap);
            }

            parentMap.addQuery(cayenneQuery);

            return cayenneQuery;
        }
View Full Code Here

TOP

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

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.