Package org.objectstyle.ashwood.graph

Examples of org.objectstyle.ashwood.graph.MapDigraph


        return entities;
    }

    private void init() {
        List dbEntitiesToResolve = collectAllDbEntities();
        Digraph pkDependencyGraph = new MapDigraph(MapDigraph.HASHMAP_FACTORY);
        indexedDbEntities = new HashMap(dbEntitiesToResolve.size());
        for (Iterator i = dbEntitiesToResolve.iterator(); i.hasNext();) {
            DbEntity origin = (DbEntity) i.next();
            for (Iterator j = origin.getRelationships().iterator(); j.hasNext();) {
                DbRelationship relation = (DbRelationship) j.next();
                if (relation.isToDependentPK()) {
                    DbEntity dst = (DbEntity) relation.getTargetEntity();
                    if (origin.equals(dst)) {
                        continue;
                    }
                    pkDependencyGraph.putArc(origin, dst, Boolean.TRUE);
                }
            }
        }
        int index = 0;
        for (Iterator i = dbEntitiesToResolve.iterator(); i.hasNext();) {
            DbEntity entity = (DbEntity) i.next();
            if (!pkDependencyGraph.containsVertex(entity)) {
                indexedDbEntities.put(entity, new Integer(index++));
            }
        }
        boolean acyclic = GraphUtils.isAcyclic(pkDependencyGraph);
        if (acyclic) {
            IndegreeTopologicalSort sorter = new IndegreeTopologicalSort(
                    pkDependencyGraph);
            while (sorter.hasNext())
                indexedDbEntities.put(sorter.next(), new Integer(index++));
        }
        else {
            StrongConnection contractor = new StrongConnection(
                    pkDependencyGraph,
                    CollectionFactory.ARRAYLIST_FACTORY);
            Digraph contractedDigraph = new MapDigraph(MapDigraph.HASHMAP_FACTORY);
            contractor.contract(contractedDigraph, CollectionFactory.ARRAYLIST_FACTORY);
            IndegreeTopologicalSort sorter = new IndegreeTopologicalSort(
                    contractedDigraph);
            while (sorter.hasNext()) {
                Collection component = (Collection) sorter.next();
View Full Code Here


                fillInMetadata(table, entity);
                dbEntityToTableMap.put(entity, table);
                tables.add(table);
            }
        }
        referentialDigraph = new MapDigraph(MapDigraph.HASHMAP_FACTORY);
        DbUtils.buildReferentialDigraph(referentialDigraph, tables);
        StrongConnection contractor = new StrongConnection(
                referentialDigraph,
                CollectionFactory.ARRAYLIST_FACTORY);
        contractedReferentialDigraph = new MapDigraph(MapDigraph.HASHMAP_FACTORY);
        contractor.contract(
                contractedReferentialDigraph,
                CollectionFactory.ARRAYLIST_FACTORY);
        IndegreeTopologicalSort sorter = new IndegreeTopologicalSort(
                contractedReferentialDigraph);
View Full Code Here

            reflexiveRelNames[i] = (objRel != null ? objRel.getName() : null);
        }

        List sorted = new ArrayList(size);

        Digraph objectDependencyGraph = new MapDigraph(MapDigraph.HASHMAP_FACTORY);
        Object[] masters = new Object[reflexiveRelNames.length];
        for (int i = 0; i < size; i++) {
            Persistent current = (Persistent) objects.get(i);
            objectDependencyGraph.addVertex(current);
            int actualMasterCount = 0;
            for (int k = 0; k < reflexiveRelNames.length; k++) {
                String reflexiveRelName = reflexiveRelNames[k];

                if (reflexiveRelName == null) {
                    continue;
                }

                masters[k] = (reflexiveRelName != null) ? descriptor.getProperty(
                        reflexiveRelName).readProperty(current) : null;

                if (masters[k] == null) {
                    masters[k] = findReflexiveMaster(current, (ObjRelationship) objEntity
                            .getRelationship(reflexiveRelName), current
                            .getObjectId()
                            .getEntityName());
                }

                if (masters[k] != null) {
                    actualMasterCount++;
                }
            }

            int mastersFound = 0;
            for (int j = 0; j < size && mastersFound < actualMasterCount; j++) {

                if (i == j) {
                    continue;
                }

                Object masterCandidate = objects.get(j);
                for (int k = 0; k < masters.length; k++) {
                    if (masterCandidate.equals(masters[k])) {
                        objectDependencyGraph.putArc(
                                masterCandidate,
                                current,
                                Boolean.TRUE);
                        mastersFound++;
                    }
View Full Code Here

TOP

Related Classes of org.objectstyle.ashwood.graph.MapDigraph

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.