Update of /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17149
Modified Files:
Domain.java FunctionalSpaceFacade.java
Log Message:
added new functions
Index: Domain.java
===================================================================
RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Domain.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** Domain.java 22 Aug 2005 08:46:44 -0000 1.5
--- Domain.java 2 Sep 2005 13:39:37 -0000 1.6
***************
*** 9,12 ****
--- 9,13 ----
import java.io.Serializable;
import java.util.Set;
+ import java.util.HashSet;
import org.apache.log4j.Logger;
***************
*** 108,112 ****
* @hibernate.key
* column="DOMAIN_ID"
! * @hibernate.one-to-many
* class="net.sourceforge.bprocessor.model.Surface"
*/
--- 109,113 ----
* @hibernate.key
* column="DOMAIN_ID"
! * @hibernate.many-to-many
* class="net.sourceforge.bprocessor.model.Surface"
*/
***************
*** 124,127 ****
--- 125,143 ----
/**
+ * Add a surface to the list of surfaces
+ * @param surface The surface
+ */
+ public void addSurface(Surface surface) {
+ Set s = getSurfaces();
+ if (s == null) {
+ Set set = new HashSet();
+ set.add(surface);
+ setSurfaces(set);
+ } else {
+ s.add(surface);
+ }
+ }
+
+ /**
* String representation of the object
* @return The string
Index: FunctionalSpaceFacade.java
===================================================================
RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/FunctionalSpaceFacade.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** FunctionalSpaceFacade.java 17 Aug 2005 11:22:54 -0000 1.4
--- FunctionalSpaceFacade.java 2 Sep 2005 13:39:37 -0000 1.5
***************
*** 203,205 ****
--- 203,237 ----
return result;
}
+
+ /**
+ * Find the Functional spaces matched with a surface
+ * @param surface The id of the surface
+ * @return The space the given surface is conected with
+ */
+ public Set findBySurface(Surface surface) {
+ Set result = new HashSet();
+
+ HibernateUtil hu = HibernateUtil.getInstance();
+ try {
+ Session session = hu.currentSession();
+ Transaction tx = session.beginTransaction();
+
+ Query q = session.createQuery("SELECT f FROM FunctionalSpace AS f," +
+ "Domain AS d " +
+ "JOIN d.surfaces AS surfaces " +
+ "WHERE surfaces.id = :id AND d.id = f.id");
+ q.setLong("id", surface.getId().longValue());
+
+ Iterator it = q.iterate();
+ while (it.hasNext()) {
+ result.add((FunctionalSpace)it.next());
+ }
+ tx.commit();
+ } catch (Exception ex) {
+ log.error(ex.getMessage(), ex);
+ } finally {
+ hu.closeSession();
+ }
+ return result;
+ }
}
|