Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
AuthorityRemoveCommand |
|
| 2.0;2 |
1 | /* | |
2 | * Copyright (c) 2009, Swiss Federal Department of Defence Civil Protection and Sport | |
3 | * (http://www.vbs.admin.ch) | |
4 | * Copyright (c) 2009, Ergon Informatik AG (http://www.ergon.ch) | |
5 | * All rights reserved. | |
6 | * | |
7 | * Licensed under the Open Permis License which accompanies this distribution, | |
8 | * and is available at http://www.openpermis.org/BSDlicenceKent.txt | |
9 | */ | |
10 | package org.openpermis.editor.policy.command; | |
11 | ||
12 | import org.openpermis.policy.bean.AuthorityBean; | |
13 | import org.openpermis.policy.bean.PolicyBean; | |
14 | import org.openpermis.policy.bean.RoleAssignmentRuleBean; | |
15 | import org.openpermis.policy.bean.RoleAssignmentRuleBeanCollection; | |
16 | ||
17 | ||
18 | /** | |
19 | * Command that deletes an authority all over the model. | |
20 | * @since 0.3.0 | |
21 | */ | |
22 | public class AuthorityRemoveCommand extends PartRemoveCommand<AuthorityBean> | |
23 | { | |
24 | //---- Constructors | |
25 | ||
26 | /** | |
27 | * Creates a command. | |
28 | * @param authority the authority to modify, must not be {@code null}. | |
29 | * @since 0.3.0 | |
30 | */ | |
31 | public AuthorityRemoveCommand (AuthorityBean authority) { | |
32 | 0 | super(authority); |
33 | 0 | } |
34 | ||
35 | //---- Methods | |
36 | ||
37 | /** | |
38 | * @since 0.3.0 | |
39 | */ | |
40 | public void removePart (PolicyBean policyBean, boolean doExec) { | |
41 | 0 | RoleAssignmentRuleBeanCollection roleAssignmentRules = policyBean.getRoleAssignmentRules(); |
42 | 0 | for (final RoleAssignmentRuleBean currRule : roleAssignmentRules) { |
43 | 0 | if (currRule.getAuthority().equals(getPart())) { |
44 | 0 | currRule.setAuthority(null); |
45 | } | |
46 | } | |
47 | 0 | } |
48 | ||
49 | ||
50 | } |