Salome HOME
SimulationContextFacade has been moved into Siman-Common. Import document action...
[tools/siman.git] / Workspace / Siman-Common / src / org / splat / service / SimulationContextTypeServiceImpl.java
1 /*****************************************************************************
2  * Company         OPEN CASCADE
3  * Application     SIMAN
4  * File            $Id$ 
5  * Creation date   22.10.2012
6  * @author         $Author$
7  * @version        $Revision$
8  * @copyright      OPEN CASCADE 2012
9  *****************************************************************************/
10
11 package org.splat.service; 
12
13 import org.splat.dal.bo.som.ProgressState;
14 import org.splat.dal.bo.som.SimulationContextType;
15 import org.splat.dal.dao.som.SimulationContextTypeDAO;
16 import org.splat.kernel.InvalidPropertyException;
17 import org.splat.service.technical.ProjectSettingsService;
18 import org.springframework.transaction.annotation.Transactional;
19
20 /**
21  * Simulation context type service implementation.
22  *
23  * @author <a href="mailto:roman.kozlov@opencascade.com">Roman Kozlov (RKV)</a>
24  */
25 public class SimulationContextTypeServiceImpl implements
26                 SimulationContextTypeService {
27
28         /**
29          * Injected simulation context type DAO.
30          */
31         private SimulationContextTypeDAO _simulationContextTypeDAO;
32
33         /**
34          * {@inheritDoc}
35          * 
36          * @see org.splat.service.SimulationContextService#createType(java.lang.String, org.splat.service.technical.ProjectSettingsService.Step)
37          */
38         @Transactional
39         public SimulationContextType createType(String name,
40                         ProjectSettingsService.Step step) throws InvalidPropertyException {
41                 // TODO: Check for duplicate definition
42                 SimulationContextType type = new SimulationContextType(name, step);
43                 getSimulationContextTypeDAO().create(type);
44
45                 return type;
46         }
47
48         /**
49          * Approve the simulation context type.
50          * 
51          * @param simCtxType
52          *            the type to approve
53          * @return true if approval succeeded
54          */
55         public boolean approve(SimulationContextType simCtxType) {
56                 if (simCtxType.getState() != ProgressState.inCHECK)
57                         return false;
58                 simCtxType.setState(ProgressState.APPROVED); // The type name is supposed being localized
59                 getSimulationContextTypeDAO().update(simCtxType);
60                 return true;
61         }
62
63         /**
64          * Get the simulationContextTypeDAO.
65          * 
66          * @return the simulationContextTypeDAO
67          */
68         public SimulationContextTypeDAO getSimulationContextTypeDAO() {
69                 return _simulationContextTypeDAO;
70         }
71
72         /**
73          * Set the simulationContextTypeDAO.
74          * 
75          * @param simulationContextTypeDAO
76          *            the simulationContextTypeDAO to set
77          */
78         public void setSimulationContextTypeDAO(
79                         SimulationContextTypeDAO simulationContextTypeDAO) {
80                 _simulationContextTypeDAO = simulationContextTypeDAO;
81         }
82
83 }