Salome HOME
Refactoring continues: UserService is created instead of UserDirectory. Database...
[tools/siman.git] / Workspace / Siman / src / org / splat / simer / SearchBaseAction.java
index 2c321176fc3a7b51ea54aaa5ff84e6e6b11f7228..86a35c0bddac9227309ca6f8953f468bf7677413 100644 (file)
@@ -10,10 +10,10 @@ import org.hibernate.Transaction;
 import org.splat.kernel.InvalidPropertyException;
 import org.splat.kernel.Name;
 import org.splat.dal.bo.kernel.User;
-import org.splat.kernel.UserDirectory;
 import org.splat.som.ApplicationRights;
 import org.splat.dal.dao.som.Database;
 import org.splat.service.SimulationContextService;
+import org.splat.service.UserService;
 import org.splat.service.technical.ProjectSettingsService;
 import org.splat.service.dto.Proxy;
 import org.splat.dal.bo.som.SimulationContext;
@@ -41,6 +41,11 @@ public abstract class SearchBaseAction extends Action {
         */
        private SimulationContextService _simulationContextService;
 
+       /**
+        * Injected user service.
+        */
+       private UserService _userService;
+
        enum UserAction {
                refreshResult, selectContextType, selectContextValue, cancelSelect, removeContext
        }
@@ -65,7 +70,7 @@ public abstract class SearchBaseAction extends Action {
                                action = UserAction.cancelSelect;
                }
                // Execution of the user action
-               Session connex = Database.getSession();
+               Session connex = Database.getCurSession();
                Transaction transax = connex.beginTransaction();
                String done;
                try {
@@ -98,7 +103,8 @@ public abstract class SearchBaseAction extends Action {
                // ---------------------------------------
                SimulationContext.Properties sprop = new SimulationContext.Properties();
 
-               newtype = getSimulationContextService().selectType(Integer.valueOf(ctype));
+               newtype = getSimulationContextService().selectType(
+                               Integer.valueOf(ctype));
                newvalue = getSimulationContextService().selectSimulationContextsWhere(
                                sprop.setType(newtype));
                if (cindex.length() > 0 && Integer.valueOf(cindex) == 0)
@@ -208,7 +214,7 @@ public abstract class SearchBaseAction extends Action {
        protected void setCandidates() {
                // -------------------------------
                manager = new Vector<Name>();
-               List<User> users = UserDirectory.selectAllUsers();
+               List<User> users = getUserService().selectAllUsers();
                User me = getConnectedUser(); // May be null
                for (Iterator<User> i = users.iterator(); i.hasNext();) {
                        User next = i.next();
@@ -231,7 +237,8 @@ public abstract class SearchBaseAction extends Action {
                SimulationContextType[] types = critext
                                .toArray(new SimulationContextType[critext.size()]);
                ContextTypeComparator compare = new ContextTypeComparator();
-               ProjectSettingsService.Step step = types[0].getAttachedStep();
+               ProjectSettingsService.Step step = getSimulationContextService()
+                               .getAttachedStep(types[0]);
                int from = 0;
                int to = 0;
                while (to < types.length - 1) {
@@ -242,7 +249,7 @@ public abstract class SearchBaseAction extends Action {
                        if (to > from + 1)
                                Arrays.sort(types, from, to, compare);
                        from = to;
-                       step = types[to].getAttachedStep();
+                       step = getSimulationContextService().getAttachedStep(types[to]);
                }
                if (to > from)
                        Arrays.sort(types, from, to + 1, compare);
@@ -280,4 +287,20 @@ public abstract class SearchBaseAction extends Action {
                        SimulationContextService simulationContextService) {
                _simulationContextService = simulationContextService;
        }
+
+       /**
+        * Get the userService.
+        * @return the userService
+        */
+       public UserService getUserService() {
+               return _userService;
+       }
+
+       /**
+        * Set the userService.
+        * @param userService the userService to set
+        */
+       public void setUserService(UserService userService) {
+               _userService = userService;
+       }
 }
\ No newline at end of file