Revize 74a73b3b
Přidáno uživatelem Vojtěch Danišík před asi 4 roky(ů)
src/main/java/vldc/aswi/service/ConfigurationManagerImpl.java | ||
---|---|---|
13 | 13 |
import vldc.aswi.domain.Configuration; |
14 | 14 |
import vldc.aswi.domain.Function; |
15 | 15 |
import vldc.aswi.domain.parameter.ParameterInConfiguration; |
16 |
import vldc.aswi.service.parameter.ParameterInConfigurationManager; |
|
17 |
import vldc.aswi.service.parameter.ParameterTypeManager; |
|
16 | 18 |
|
17 | 19 |
import javax.transaction.Transactional; |
18 | 20 |
import java.util.ArrayList; |
... | ... | |
43 | 45 |
@Autowired |
44 | 46 |
private LocationRepository locationRepository; |
45 | 47 |
|
46 |
/** Autowired parameter type repository. */
|
|
48 |
/** Autowired parameter type manager. */
|
|
47 | 49 |
@Autowired |
48 |
private ParameterTypeRepository parameterTypeRepository;
|
|
50 |
private ParameterTypeManager parameterTypeRepository;
|
|
49 | 51 |
|
50 | 52 |
/** Autowired function repository. */ |
51 | 53 |
@Autowired |
... | ... | |
55 | 57 |
@Autowired |
56 | 58 |
private UserRepository userRepository; |
57 | 59 |
|
60 |
/** Autowired parameter in configuration manager. */ |
|
61 |
@Autowired |
|
62 |
private ParameterInConfigurationManager parameterInConfigurationManager; |
|
63 |
|
|
58 | 64 |
/** |
59 | 65 |
* Initialization setup for configuration manager. Check if configuration repository contains |
60 | 66 |
* records and if not, initialize default values. |
... | ... | |
108 | 114 |
} |
109 | 115 |
} |
110 | 116 |
|
117 |
/** |
|
118 |
* Delete single configuration by id. |
|
119 |
* @param id - ID of configuration. |
|
120 |
* @return True if deleting was successful, false if not. |
|
121 |
*/ |
|
122 |
@Override |
|
123 |
public boolean deleteConfiguration(Long id) { |
|
124 |
try { |
|
125 |
this.parameterInConfigurationManager.deleteParametersInConfiguration(id); |
|
126 |
this.configurationRepository.deleteById(id); |
|
127 |
return true; |
|
128 |
} catch (Exception e) { |
|
129 |
return false; |
|
130 |
} |
|
131 |
} |
|
132 |
|
|
133 |
/** |
|
134 |
* Delete all configurations by assembly id. |
|
135 |
* @param assemblyId - ID of assembly. |
|
136 |
* @return True if all configurations were successfully deleted, false if not. |
|
137 |
*/ |
|
138 |
@Override |
|
139 |
public boolean deleteConfigurations(Long assemblyId) { |
|
140 |
try { |
|
141 |
// Delete parameters in current configuration. |
|
142 |
List<Configuration> configurations = this.configurationRepository.getByAssemblyId(assemblyId); |
|
143 |
for (Configuration configuration : configurations) { |
|
144 |
this.parameterInConfigurationManager.deleteParametersInConfiguration(configuration.getId()); |
|
145 |
} |
|
146 |
|
|
147 |
// Delete configuration. |
|
148 |
this.configurationRepository.deleteAll(configurations); |
|
149 |
return true; |
|
150 |
} catch (Exception e) { |
|
151 |
return false; |
|
152 |
} |
|
153 |
} |
|
154 |
|
|
111 | 155 |
/** |
112 | 156 |
* Saves new configuration into database |
113 | 157 |
* @param newConfiguration container with data for a new configuration |
Také k dispozici: Unified diff
re #7887 Deleting configurations and assemblies, Minor restructuralization.