]> SALOME platform Git repositories - tools/siman.git/blobdiff - Workspace/Siman-Common/src/org/splat/dal/bo/som/SimulationContext.java
Salome HOME
Refactoring of Database, replacing SQL by DAOs calls. Methods for search by criteria...
[tools/siman.git] / Workspace / Siman-Common / src / org / splat / dal / bo / som / SimulationContext.java
index a91d0af5ef4c6ff602d6b6931d9d7a513bdcf399..828033b883a0dcf893b8dcdbeafc43719a74900f 100644 (file)
@@ -154,91 +154,18 @@ public class SimulationContext extends Persistent implements Serializable {
 //  --------------------------
       return (counter > 1);
     }
-
-//  ==============================================================================================================================
-//  Public services
-//  ==============================================================================================================================
-
-    public static SimulationContextType createType (String name, ProjectSettingsService.Step step) throws InvalidPropertyException, RuntimeException {
-//  ---------------------------------------------------------------------------------------
-//TODO: Check for duplicate definition
-      SimulationContextType type    = new SimulationContextType(name, step);
-      Session               session = Database.getSession();
-      session.save(type);
-          
-      return type;
-    }
-
-    @SuppressWarnings("unchecked")
-       public static List<SimulationContextType> selectAllTypes () {
-//  -----------------------------------------------------------
-         StringBuffer  query = new StringBuffer("from SimulationContextType");  // Useless to order by names as the result mixes localized and non localized types
-                       query = query.append(" order by step asc");
-      return  Database.getSession().createQuery(query.toString()).list();
-    }
-
-    @SuppressWarnings("unchecked")
-       public static List<SimulationContextType> selectTypesOf (ProjectSettingsService.Step... step) {
-//  --------------------------------------------------------------------------------------
-         StringBuffer  query = new StringBuffer("from SimulationContextType where step='").append(step[0].getNumber()).append("'");      
-         for (int i=1; i<step.length; i++) {           // Useless to order as the result mixes localized and non localized types
-        query = query.append(" or step='").append(step[i].getNumber()).append("'");
-         }
-         query = query.append(" order by step asc");
-      return  Database.getSession().createQuery(query.toString()).list();
-    }
-
-       @SuppressWarnings("unchecked")
-       public static List<SimulationContextType> selectTypesWhere (SimulationContextType.Properties sprop) {
-//  ---------------------------------------------------------------------------------------------------
-      StringBuffer         query     = new StringBuffer("from SimulationContextType");
-      String               separator = " where";
-      ProjectSettingsService.Step step      = sprop.getStep();
-      ProgressState        state     = sprop.getProgressState();
-      String               order     = " order by step asc";
-
-      if (step != null) {
-        query     = query.append(separator).append(" step='").append(step.getNumber()).append("'");
-        separator = " and";
-        order     = " order by state desc";         // APPROVED (upper case A) is grater than inCHECK (lower case i)
-      }
-      if (state != null) {
-        query     = query.append(separator).append(" state='").append(state.toString()).append("'");
-//      separator = " and";
-        if (step != null) {
-          if (state != ProgressState.APPROVED) order = " order by name asc";
-          else  order = "";                         // Approved types are localized
-        }
-      }
-      query = query.append(order);
-      return  Database.getSession().createQuery(query.toString()).list();
-    }
-
-    public static SimulationContextType selectType (String name) {
-//  ------------------------------------------------------------
-         StringBuffer  query = new StringBuffer("from SimulationContextType where name='").append(name).append("'");     
-         return (SimulationContextType)Database.getSession().createQuery(query.toString()).uniqueResult();
-    }
-    
-    public static SimulationContextType selectType (int index) {
-//  ----------------------------------------------------------
-         StringBuffer  query = new StringBuffer("from SimulationContextType where rid='").append(index).append("'");     
-         return (SimulationContextType)Database.getSession().createQuery(query.toString()).uniqueResult();
-    }
-    
-//  ==============================================================================================================================
-//  Protected services
-//  ==============================================================================================================================
-
-    public void hold () {
-//  ----------------------
-      counter += 1;
-      if (this.isSaved()) Database.getSession().update(this);
-    }
-
-    public void release () {
-//  -------------------------
-      counter -= 1;
-      if (this.isSaved()) Database.getSession().update(this);
-    }
+       /**
+        * Get counter.
+        * @return counter
+        */
+       public int getCounter() {
+               return counter;
+       }
+       /**
+        * Set counter.
+        * @param aValue a counter value to set
+        */
+       public void setCounter(int aValue) {
+               counter = aValue;
+       }
 }
\ No newline at end of file