[Bprocessor-commit] model/src/net/sourceforge/bprocessor/model/xml PersistenceManager.java,1.1,1.2
Status: Pre-Alpha
Brought to you by:
henryml
From: Jesper P. <je...@us...> - 2005-07-28 06:49:36
|
Update of /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/xml In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7820 Modified Files: PersistenceManager.java Log Message: Update to use the new facades and relationships Index: PersistenceManager.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/xml/PersistenceManager.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** PersistenceManager.java 18 Jul 2005 09:25:56 -0000 1.1 --- PersistenceManager.java 28 Jul 2005 06:49:28 -0000 1.2 *************** *** 36,39 **** --- 36,40 ---- import java.io.OutputStream; import java.util.HashMap; + import java.util.HashSet; import java.util.Iterator; import java.util.List; *************** *** 156,160 **** mapper.put(new Long(cs.getId()), csm.getId()); ! ConstructionSpaceFacade.getInstance().add(csm); Notification n = new Notification(Notification.CONSTRUCTION_SPACE_CREATED, csm.getId()); --- 157,161 ---- mapper.put(new Long(cs.getId()), csm.getId()); ! csm = ConstructionSpaceFacade.getInstance().create(csm); Notification n = new Notification(Notification.CONSTRUCTION_SPACE_CREATED, csm.getId()); *************** *** 176,180 **** mapper.put(new Long(fs.getId()), fsm.getId()); ! FunctionalSpaceFacade.getInstance().add(fsm); Notification n = new Notification(Notification.FUNCTIONAL_SPACE_CREATED, fsm.getId()); --- 177,181 ---- mapper.put(new Long(fs.getId()), fsm.getId()); ! fsm = FunctionalSpaceFacade.getInstance().create(fsm); Notification n = new Notification(Notification.FUNCTIONAL_SPACE_CREATED, fsm.getId()); *************** *** 198,202 **** mapper.put(new Long(e.getId()), em.getId()); ! ElementFacade.getInstance().add(em); Notification n = new Notification(Notification.ELEMENT_CREATED, em.getId()); --- 199,203 ---- mapper.put(new Long(e.getId()), em.getId()); ! em = ElementFacade.getInstance().create(em); Notification n = new Notification(Notification.ELEMENT_CREATED, em.getId()); *************** *** 220,224 **** mapper.put(new Long(p.getId()), pm.getId()); ! PartFacade.getInstance().add(pm); Notification n = new Notification(Notification.PART_CREATED, pm.getId()); --- 221,225 ---- mapper.put(new Long(p.getId()), pm.getId()); ! pm = PartFacade.getInstance().create(pm); Notification n = new Notification(Notification.PART_CREATED, pm.getId()); *************** *** 244,248 **** mapper.put(new Long(s.getId()), sm.getId()); ! SurfaceFacade.getInstance().add(sm); Notification n = new Notification(Notification.SURFACE_CREATED, sm.getId()); --- 245,249 ---- mapper.put(new Long(s.getId()), sm.getId()); ! sm = SurfaceFacade.getInstance().create(sm); Notification n = new Notification(Notification.SURFACE_CREATED, sm.getId()); *************** *** 266,270 **** mapper.put(new Long(e.getId()), em.getId()); ! EdgeFacade.getInstance().add(em); Notification n = new Notification(Notification.EDGE_CREATED, em.getId()); --- 267,271 ---- mapper.put(new Long(e.getId()), em.getId()); ! em = EdgeFacade.getInstance().create(em); Notification n = new Notification(Notification.EDGE_CREATED, em.getId()); *************** *** 293,297 **** mapper.put(new Long(v.getId()), vm.getId()); ! VertexFacade.getInstance().add(vm); Notification n = new Notification(Notification.VERTEX_CREATED, vm.getId()); --- 294,298 ---- mapper.put(new Long(v.getId()), vm.getId()); ! vm = VertexFacade.getInstance().create(vm); Notification n = new Notification(Notification.VERTEX_CREATED, vm.getId()); *************** *** 316,319 **** --- 317,321 ---- List as = cs.getAttributeref(); if (as != null && as.size() > 0) { + Set ar = new HashSet(); Iterator ias = as.iterator(); while (ias.hasNext()) { *************** *** 321,329 **** net.sourceforge.bprocessor.model.Attribute a = (net.sourceforge.bprocessor.model.Attribute)attribs.get(aid); ! csm.getAttributes().add(a); } } List ss = cs.getSurfaceref(); if (ss != null && ss.size() > 0) { Iterator iss = ss.iterator(); while (iss.hasNext()) { --- 323,333 ---- net.sourceforge.bprocessor.model.Attribute a = (net.sourceforge.bprocessor.model.Attribute)attribs.get(aid); ! ar.add(a); } + csm.setAttributes(ar); } List ss = cs.getSurfaceref(); if (ss != null && ss.size() > 0) { + Set sr = new HashSet(); Iterator iss = ss.iterator(); while (iss.hasNext()) { *************** *** 331,339 **** net.sourceforge.bprocessor.model.Surface s = SurfaceFacade.getInstance().findById(sid); ! csm.getSurfaces().add(s); } } List es = cs.getElementref(); if (es != null && es.size() > 0) { Iterator ies = es.iterator(); while (ies.hasNext()) { --- 335,345 ---- net.sourceforge.bprocessor.model.Surface s = SurfaceFacade.getInstance().findById(sid); ! sr.add(s); } + csm.setSurfaces(sr); } List es = cs.getElementref(); if (es != null && es.size() > 0) { + Set er = new HashSet(); Iterator ies = es.iterator(); while (ies.hasNext()) { *************** *** 341,347 **** net.sourceforge.bprocessor.model.Element e = ElementFacade.getInstance().findById(eid); ! csm.getElements().add(e); } } } } --- 347,355 ---- net.sourceforge.bprocessor.model.Element e = ElementFacade.getInstance().findById(eid); ! er.add(e); } + csm.setElements(er); } + ConstructionSpaceFacade.getInstance().update(csm); } } *************** *** 363,366 **** --- 371,375 ---- List as = fs.getAttributeref(); if (as != null && as.size() > 0) { + Set ar = new HashSet(); Iterator ias = as.iterator(); while (ias.hasNext()) { *************** *** 368,376 **** net.sourceforge.bprocessor.model.Attribute a = (net.sourceforge.bprocessor.model.Attribute)attribs.get(aid); ! fsm.getAttributes().add(a); } } List ss = fs.getSurfaceref(); if (ss != null && ss.size() > 0) { Iterator iss = ss.iterator(); while (iss.hasNext()) { --- 377,387 ---- net.sourceforge.bprocessor.model.Attribute a = (net.sourceforge.bprocessor.model.Attribute)attribs.get(aid); ! ar.add(a); } + fsm.setAttributes(ar); } List ss = fs.getSurfaceref(); if (ss != null && ss.size() > 0) { + Set sr = new HashSet(); Iterator iss = ss.iterator(); while (iss.hasNext()) { *************** *** 378,386 **** net.sourceforge.bprocessor.model.Surface s = SurfaceFacade.getInstance().findById(sid); ! fsm.getSurfaces().add(s); } } List es = fs.getElementref(); if (es != null && es.size() > 0) { Iterator ies = es.iterator(); while (ies.hasNext()) { --- 389,399 ---- net.sourceforge.bprocessor.model.Surface s = SurfaceFacade.getInstance().findById(sid); ! sr.add(s); } + fsm.setSurfaces(sr); } List es = fs.getElementref(); if (es != null && es.size() > 0) { + Set er = new HashSet(); Iterator ies = es.iterator(); while (ies.hasNext()) { *************** *** 388,394 **** net.sourceforge.bprocessor.model.Element e = ElementFacade.getInstance().findById(eid); ! fsm.getElements().add(e); } } } } --- 401,409 ---- net.sourceforge.bprocessor.model.Element e = ElementFacade.getInstance().findById(eid); ! er.add(e); } + fsm.setElements(er); } + FunctionalSpaceFacade.getInstance().update(fsm); } } *************** *** 411,414 **** --- 426,430 ---- List as = e.getAttributeref(); if (as != null && as.size() > 0) { + Set ar = new HashSet(); Iterator ias = as.iterator(); while (ias.hasNext()) { *************** *** 416,424 **** net.sourceforge.bprocessor.model.Attribute a = (net.sourceforge.bprocessor.model.Attribute)attribs.get(aid); ! em.getAttributes().add(a); } } List ss = e.getSurfaceref(); if (ss != null && ss.size() > 0) { Iterator iss = ss.iterator(); while (iss.hasNext()) { --- 432,442 ---- net.sourceforge.bprocessor.model.Attribute a = (net.sourceforge.bprocessor.model.Attribute)attribs.get(aid); ! ar.add(a); } + em.setAttributes(ar); } List ss = e.getSurfaceref(); if (ss != null && ss.size() > 0) { + Set sr = new HashSet(); Iterator iss = ss.iterator(); while (iss.hasNext()) { *************** *** 426,434 **** net.sourceforge.bprocessor.model.Surface s = SurfaceFacade.getInstance().findById(sid); ! em.getSurfaces().add(s); } } List ps = e.getPartref(); if (ps != null && ps.size() > 0) { Iterator ips = ps.iterator(); while (ips.hasNext()) { --- 444,454 ---- net.sourceforge.bprocessor.model.Surface s = SurfaceFacade.getInstance().findById(sid); ! sr.add(s); } + em.setSurfaces(sr); } List ps = e.getPartref(); if (ps != null && ps.size() > 0) { + Set pr = new HashSet(); Iterator ips = ps.iterator(); while (ips.hasNext()) { *************** *** 436,442 **** net.sourceforge.bprocessor.model.Part p = PartFacade.getInstance().findById(pid); ! em.getParts().add(p); } } } } --- 456,464 ---- net.sourceforge.bprocessor.model.Part p = PartFacade.getInstance().findById(pid); ! pr.add(p); } + em.setParts(pr); } + ElementFacade.getInstance().update(em); } } *************** *** 459,462 **** --- 481,485 ---- List as = p.getAttributeref(); if (as != null && as.size() > 0) { + Set ar = new HashSet(); Iterator ias = as.iterator(); while (ias.hasNext()) { *************** *** 464,472 **** net.sourceforge.bprocessor.model.Attribute a = (net.sourceforge.bprocessor.model.Attribute)attribs.get(aid); ! pm.getAttributes().add(a); } } List ss = p.getSurfaceref(); if (ss != null && ss.size() > 0) { Iterator iss = ss.iterator(); while (iss.hasNext()) { --- 487,497 ---- net.sourceforge.bprocessor.model.Attribute a = (net.sourceforge.bprocessor.model.Attribute)attribs.get(aid); ! ar.add(a); } + pm.setAttributes(ar); } List ss = p.getSurfaceref(); if (ss != null && ss.size() > 0) { + Set sr = new HashSet(); Iterator iss = ss.iterator(); while (iss.hasNext()) { *************** *** 474,480 **** net.sourceforge.bprocessor.model.Surface s = SurfaceFacade.getInstance().findById(sid); ! pm.getSurfaces().add(s); } } } } --- 499,507 ---- net.sourceforge.bprocessor.model.Surface s = SurfaceFacade.getInstance().findById(sid); ! sr.add(s); } + pm.setSurfaces(sr); } + PartFacade.getInstance().update(pm); } } *************** *** 497,500 **** --- 524,528 ---- List es = s.getEdgeref(); if (es != null && es.size() > 0) { + Set er = new HashSet(); Iterator ies = es.iterator(); while (ies.hasNext()) { *************** *** 502,508 **** net.sourceforge.bprocessor.model.Edge e = EdgeFacade.getInstance().findById(eid); ! sm.getEdges().add(e); } } } } --- 530,538 ---- net.sourceforge.bprocessor.model.Edge e = EdgeFacade.getInstance().findById(eid); ! er.add(e); } + sm.setEdges(er); } + SurfaceFacade.getInstance().update(sm); } } *************** *** 531,534 **** --- 561,566 ---- v = VertexFacade.getInstance().findById(vid); em.setTo(v); + + EdgeFacade.getInstance().update(em); } } *************** *** 548,562 **** net.sourceforge.bprocessor.model.Vertex vm = VertexFacade.getInstance().findById(id); - - List es = v.getEdgeref(); - if (es != null && es.size() > 0) { - Iterator ies = es.iterator(); - while (ies.hasNext()) { - Long eid = (Long)mapper.get((Long)ies.next()); - net.sourceforge.bprocessor.model.Edge e = - EdgeFacade.getInstance().findById(eid); - vm.getEdges().add(e); - } - } } } --- 580,583 ---- *************** *** 1164,1177 **** net.sourceforge.bprocessor.model.xml.Vertex vx = findVertex(bp, v); - Set data = v.getEdges(); - Iterator it = data.iterator(); - while (it.hasNext()) { - net.sourceforge.bprocessor.model.Edge e = - (net.sourceforge.bprocessor.model.Edge)it.next(); - - Map m = (Map)mapper.get(KEY_EDGE); - - vx.getEdgeref().add(m.get(e.getId())); - } } } --- 1185,1188 ---- |