Thread: [Bprocessor-commit] model/src/net/sourceforge/bprocessor/model Project.java,1.1,1.2
Status: Pre-Alpha
Brought to you by:
henryml
From: Michael L. <he...@us...> - 2005-10-02 21:06:34
|
Update of /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2573/src/net/sourceforge/bprocessor/model Modified Files: Project.java Log Message: All access to database now through the Project instance Index: Project.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Project.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Project.java 21 Sep 2005 07:29:30 -0000 1.1 --- Project.java 2 Oct 2005 14:36:30 -0000 1.2 *************** *** 9,17 **** import java.util.HashSet; import java.util.Set; - import org.apache.log4j.Logger; - /** * The Project --- 9,16 ---- import java.util.HashSet; + import java.util.Iterator; import java.util.Set; import org.apache.log4j.Logger; /** * The Project *************** *** 27,55 **** /** The instance */ private static Project instance; /** ! * Create a vertex ! * @param v The Vertex */ ! void create(Vertex v) { } /** * Update a vertex * @param v The vertex */ ! public synchronized void update(Vertex v) { } /** * Remove a vertex * @param v The vertex */ ! public synchronized void remove(Vertex v) { } /** * Find all vertexs * @return The vertexs */ ! public Set findAll() { ! Set result = new HashSet(); ! return result; } /** * Find a vertex by id --- 26,387 ---- /** The instance */ private static Project instance; + /** ! * Get the instance ! * @return The instance */ ! public static synchronized Project getInstance() { ! if (instance == null) { ! instance = new Project(); ! } ! return instance; ! } ! ! /** ! * Intern an attribute ! * @param a The attribute ! */ ! public void intern(Attribute a) { ! AttributeFacade.getInstance().create(a); ! } ! ! /** ! * Update an attribute ! * @param a The attribute ! */ ! public void update(Attribute a) { ! AttributeFacade.getInstance().update(a); ! } ! ! /** ! * Remove an attribute ! * @param a The attribute ! */ ! public void remove(Attribute a) { ! AttributeFacade.getInstance().remove(a); ! } ! ! /** ! * Find a attribute by id ! * @param id The id ! * @return The attribute ! */ ! public Attribute findAttributeById(Long id) { ! return AttributeFacade.getInstance().findById(id); ! } ! ! /** ! * Create a construction space ! * @param c The construction space ! */ ! public void intern(ConstructionSpace c) { ! ConstructionSpaceFacade.getInstance().create(c); ! } ! ! /** ! * Update a construction space ! * @param c The construction space ! */ ! public void update(ConstructionSpace c) { ! ConstructionSpaceFacade.getInstance().update(c); ! } ! ! /** ! * Remove a construction space ! * @param c The construction space ! */ ! public void remove(ConstructionSpace c) { ! ConstructionSpaceFacade.getInstance().remove(c); ! } ! ! /** ! * Find all construction spaces ! * @return The construction spaces ! */ ! public Set getConstructionSpaces() { ! return ConstructionSpaceFacade.getInstance().findAll(); ! } ! ! /** ! * Find a construction space by id ! * @param id The id ! * @return The construction space ! */ ! public ConstructionSpace findConstructionSpaceById(Long id) { ! return ConstructionSpaceFacade.getInstance().findById(id); ! } ! ! /** ! * Update the Domain ! * @param domain The domain to update ! */ ! public void update(Domain domain) { ! if (domain instanceof ConstructionSpace) { ! ConstructionSpaceFacade.getInstance().update((ConstructionSpace)domain); ! } else if (domain instanceof FunctionalSpace) { ! FunctionalSpaceFacade.getInstance().update((FunctionalSpace)domain); ! } else if (domain instanceof Element) { ! ElementFacade.getInstance().update((Element)domain); ! } else if (domain instanceof Part) { ! PartFacade.getInstance().update((Part)domain); ! } else { ! log.error("Unsupported type: " + domain.getClass().getName()); ! } ! } ! ! /** ! * Find all domains ! * @return the set of all domains ! */ ! public Set getDomains() { ! return DomainFacade.getInstance().findAll(); ! } ! ! /** ! * Find a domain by id ! * @param id The id ! * @return The domain ! */ ! public Domain findDomainById(Long id) { ! return DomainFacade.getInstance().findById(id); ! } ! ! /** ! * Intern an edge ! * @param e The edge ! */ ! public void intern(Edge e) { ! EdgeFacade.getInstance().create(e); ! } ! ! /** ! * Update an edge ! * @param e The edge ! */ ! public void update(Edge e) { ! EdgeFacade.getInstance().update(e); ! } ! ! /** ! * Remove an edge ! * @param e The edge ! */ ! public void remove(Edge e) { ! EdgeFacade.getInstance().remove(e); ! } ! ! /** ! * Find all edges ! * @return The edges ! */ ! public Set getEdges() { ! return EdgeFacade.getInstance().findAll(); ! } ! ! /** ! * Find an edge by id ! * @param id The id ! * @return The edge ! */ ! public Edge findEdgeById(Long id) { ! return EdgeFacade.getInstance().findById(id); ! } ! ! /** ! * Intern an element ! * @param e The element ! */ ! public void intern(Element e) { ! ElementFacade.getInstance().create(e); ! } ! ! /** ! * Update an element ! * @param e The element ! */ ! public void update(Element e) { ! ElementFacade.getInstance().update(e); ! } ! ! /** ! * Remove an element ! * @param e The element ! */ ! public void remove(Element e) { ! ElementFacade.getInstance().remove(e); ! } ! ! /** ! * Find all elements ! * @return The elements ! */ ! public Set getElements() { ! return ElementFacade.getInstance().findAll(); ! } ! ! /** ! * Find a element by id ! * @param id The id ! * @return The element ! */ ! public Element findElementById(Long id) { ! return ElementFacade.getInstance().findById(id); ! } ! ! /** ! * Intern a functional space ! * @param f The functional space ! */ ! public void intern(FunctionalSpace f) { ! FunctionalSpaceFacade.getInstance().create(f); ! } ! ! /** ! * Update a functional space ! * @param f The functional space ! */ ! public void update(FunctionalSpace f) { ! FunctionalSpaceFacade.getInstance().update(f); ! } ! ! /** ! * Remove a functional space ! * @param f The functional space ! */ ! public void remove(FunctionalSpace f) { ! FunctionalSpaceFacade.getInstance().remove(f); ! } ! ! /** ! * Find all functional spaces ! * @return The functional spaces ! */ ! public Set getFunctionalSpaces() { ! return FunctionalSpaceFacade.getInstance().findAll(); ! } ! ! /** ! * Find a functional space by id ! * @param id The id ! * @return The functional space ! */ ! public FunctionalSpace findFunctionalSpaceById(Long id) { ! return FunctionalSpaceFacade.getInstance().findById(id); ! } ! ! /** ! * Intern a part ! * @param p The part ! */ ! public void intern(Part p) { ! PartFacade.getInstance().create(p); ! } ! ! /** ! * Update a part ! * @param p The part ! */ ! public void update(Part p) { ! PartFacade.getInstance().update(p); ! } ! ! /** ! * Remove a part ! * @param p The part ! */ ! public void remove(Part p) { ! PartFacade.getInstance().remove(p); ! } ! ! /** ! * Find all parts ! * @return The parts ! */ ! public Set getParts() { ! return PartFacade.getInstance().findAll(); ! } ! ! /** ! * Find a part by id ! * @param id The id ! * @return The part ! */ ! public Part findPartById(Long id) { ! return PartFacade.getInstance().findById(id); ! } ! ! /** ! * Intern a surface ! * @param s The surface ! */ ! public void intern(Surface s) { ! SurfaceFacade.getInstance().create(s); ! } ! ! /** ! * Update a surface ! * @param s The surface ! */ ! public void update(Surface s) { ! SurfaceFacade.getInstance().update(s); ! } ! ! /** ! * Remove a surface ! * @param s The surface ! */ ! public void remove(Surface s) { ! SurfaceFacade.getInstance().remove(s); ! } ! ! /** ! * Find all surfaces ! * @return The surfaces ! */ ! public Set getSurfaces() { ! return SurfaceFacade.getInstance().findAll(); ! } ! ! /** ! * Find a surface by id ! * @param id The id ! * @return The surface ! */ ! public Surface findSurfaceById(Long id) { ! return SurfaceFacade.getInstance().findById(id); ! } ! ! /** ! * Intern a vertex ! * @param v The vertex ! */ ! public void intern(Vertex v) { ! VertexFacade.getInstance().create(v); ! } ! /** * Update a vertex * @param v The vertex */ ! public void update(Vertex v) { ! VertexFacade.getInstance().update(v); } + /** * Remove a vertex * @param v The vertex */ ! public void remove(Vertex v) { ! VertexFacade.getInstance().remove(v); } + /** * Find all vertexs * @return The vertexs */ ! public Set getVertices() { ! return VertexFacade.getInstance().findAll(); } + /** * Find a vertex by id *************** *** 57,73 **** * @return The vertex */ ! public synchronized Vertex findById(Long id) { ! Vertex result = null; ! return result; ! } ! /** ! * Find a vertex by name ! * @param name The name ! * @return The vertex ! */ ! public Vertex findByName(String name) { ! Vertex result = null; ! return result; } /** * Find vertex based upon location and delta --- 389,396 ---- * @return The vertex */ ! public Vertex findVertexById(Long id) { ! return VertexFacade.getInstance().findById(id); } + /** * Find vertex based upon location and delta *************** *** 80,83 **** --- 403,417 ---- public Set findByLocation(double x, double y, double z, double delta) { Set result = new HashSet(); + Set vertices = getVertices(); + Iterator iter = vertices.iterator(); + double limit = delta; + Vertex tester = new Vertex("", x, y, z); + while (iter.hasNext()) { + Vertex current = (Vertex) iter.next(); + double distance = current.distance(tester); + if (distance <= limit) { + result.add(current); + } + } return result; } |