[Bprocessor-commit] model/src/net/sourceforge/bprocessor/model Project.java,1.17,1.18 MemoryFacade.j
Status: Pre-Alpha
Brought to you by:
henryml
From: Michael L. <he...@us...> - 2006-01-16 13:47:19
|
Update of /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31463/src/net/sourceforge/bprocessor/model Modified Files: Project.java Removed Files: MemoryFacade.java DatabaseFacade.java Log Message: Removed DatabaseFacade and MemoryFacade --- DatabaseFacade.java DELETED --- --- MemoryFacade.java DELETED --- Index: Project.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Project.java,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** Project.java 16 Jan 2006 11:42:50 -0000 1.17 --- Project.java 16 Jan 2006 13:46:59 -0000 1.18 *************** *** 8,11 **** --- 8,13 ---- package net.sourceforge.bprocessor.model; + import java.util.Collection; + import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; *************** *** 32,35 **** --- 34,57 ---- private List observers; + /** The vertices */ + private HashMap vertices = new HashMap(); + /** The vertex id */ + private long vertexId; + + /** The edges */ + private HashMap edges = new HashMap(); + /** The edge id */ + private long edgeId; + + /** The surfaces */ + private HashMap surfaces = new HashMap(); + /** The surface id */ + private long surfaceId; + + /** The domains */ + private HashMap spaces = new HashMap(); + /** The domain id */ + private long spaceId; + /** * Get the instance *************** *** 83,87 **** */ public void clear() { ! DatabaseFacade.getInstance().clear(); changed(this); } --- 105,112 ---- */ public void clear() { ! spaces.clear(); ! edges.clear(); ! surfaces.clear(); ! vertices.clear(); changed(this); } *************** *** 93,97 **** */ public void intern(Space space) { ! DatabaseFacade.getInstance().intern((Object) space); changed(this); } --- 118,123 ---- */ public void intern(Space space) { ! space.setId(new Long(spaceId++)); ! spaces.put(space.getId(), space); changed(this); } *************** *** 102,106 **** */ public Set getConstructionSpaces() { ! return DatabaseFacade.getInstance().getConstructionSpaces(); } --- 128,132 ---- */ public Set getConstructionSpaces() { ! return filter(spaces.values(), ConstructionSpace.class); } *************** *** 110,114 **** */ public Set getSpaces() { ! return DatabaseFacade.getInstance().getSpaces(); } --- 136,140 ---- */ public Set getSpaces() { ! return new HashSet(spaces.values()); } *************** *** 119,123 **** */ public Space findSpaceById(Long id) { ! return DatabaseFacade.getInstance().findSpaceById(id); } --- 145,149 ---- */ public Space findSpaceById(Long id) { ! return (Space) spaces.get(id); } *************** *** 127,131 **** */ public void intern(Edge e) { ! DatabaseFacade.getInstance().intern((Object) e); changed(this); } --- 153,158 ---- */ public void intern(Edge e) { ! e.setId(new Long(edgeId++)); ! edges.put(e.getId(), e); changed(this); } *************** *** 136,140 **** */ public void remove(Edge e) { ! DatabaseFacade.getInstance().remove(e); changed(this); } --- 163,168 ---- */ public void remove(Edge e) { ! edges.remove(e.getId()); ! e.setId(null); changed(this); } *************** *** 145,149 **** */ public Set getEdges() { ! return DatabaseFacade.getInstance().getEdges(); } --- 173,177 ---- */ public Set getEdges() { ! return new HashSet(edges.values()); } *************** *** 154,158 **** */ public Edge findEdgeById(Long id) { ! return DatabaseFacade.getInstance().findEdgeById(id); } --- 182,186 ---- */ public Edge findEdgeById(Long id) { ! return (Edge) edges.get(id); } *************** *** 177,183 **** } } ! } ! DatabaseFacade.getInstance().remove(space); ! changed(this); } --- 205,211 ---- } } ! } ! spaces.remove(space.getId()); ! space.setId(null); } *************** *** 187,191 **** */ public Set getFunctionalSpaces() { ! return DatabaseFacade.getInstance().getFunctionalSpaces(); } --- 215,219 ---- */ public Set getFunctionalSpaces() { ! return filter(spaces.values(), FunctionalSpace.class); } *************** *** 195,199 **** */ public void intern(Surface s) { ! DatabaseFacade.getInstance().intern((Object) s); changed(this); } --- 223,228 ---- */ public void intern(Surface s) { ! s.setId(new Long(surfaceId++)); ! surfaces.put(s.getId(), s); changed(this); } *************** *** 214,218 **** s.setFrontDomain(null); } ! DatabaseFacade.getInstance().remove(s); changed(this); } --- 243,248 ---- s.setFrontDomain(null); } ! surfaces.remove(s.getId()); ! s.setId(null); changed(this); } *************** *** 223,227 **** */ public Set getSurfaces() { ! return DatabaseFacade.getInstance().getSurfaces(); } --- 253,257 ---- */ public Set getSurfaces() { ! return new HashSet(surfaces.values()); } *************** *** 232,236 **** */ public Surface findSurfaceById(Long id) { ! return DatabaseFacade.getInstance().findSurfaceById(id); } --- 262,266 ---- */ public Surface findSurfaceById(Long id) { ! return (Surface) surfaces.get(id); } *************** *** 240,244 **** */ public void intern(Vertex v) { ! DatabaseFacade.getInstance().intern((Object) v); changed(this); } --- 270,275 ---- */ public void intern(Vertex v) { ! v.setId(new Long(vertexId++)); ! vertices.put(v.getId(), v); changed(this); } *************** *** 249,253 **** */ public void remove(Vertex v) { ! DatabaseFacade.getInstance().remove(v); changed(this); } --- 280,285 ---- */ public void remove(Vertex v) { ! vertices.remove(v.getId()); ! v.setId(null); changed(this); } *************** *** 258,262 **** */ public Set getVertices() { ! return DatabaseFacade.getInstance().getVertices(); } --- 290,294 ---- */ public Set getVertices() { ! return new HashSet(vertices.values()); } *************** *** 267,271 **** */ public Vertex findVertexById(Long id) { ! return DatabaseFacade.getInstance().findVertexById(id); } --- 299,303 ---- */ public Vertex findVertexById(Long id) { ! return (Vertex) vertices.get(id); } *************** *** 311,313 **** --- 343,364 ---- return result; } + + /** + * Make a set of objects in values of the specified clarse + * @param values The values to filter + * @param clarse The class + * @return The set + */ + private Set filter(Collection values, Class clarse) { + HashSet result = new HashSet(); + Iterator iter = values.iterator(); + while (iter.hasNext()) { + Object current = iter.next(); + if (current.getClass() == clarse) { + result.add(current); + } + } + return result; + } + } |