1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 package org.efaps.update.schema.user;
22
23 import java.net.URL;
24 import java.util.HashSet;
25 import java.util.List;
26 import java.util.Map;
27 import java.util.Set;
28
29 import org.efaps.db.Instance;
30 import org.efaps.update.AbstractUpdate;
31 import org.efaps.update.LinkInstance;
32 import org.efaps.util.EFapsException;
33
34
35
36
37
38
39 public class RoleUpdate
40 extends AbstractUpdate
41 {
42
43
44
45 private static final Set<Link> ALLLINKS = new HashSet<>();
46
47
48 private static final Link LINK2ACCESSCMD = new Link("Admin_UI_Access", "UserLink",
49 "Admin_UI_Command", "UILink").setIncludeChildTypes(true);
50
51
52 private static final Link LINK2ACCESSSET = new Link("Admin_Access_AccessSet2UserAbstract", "UserAbstractLink",
53 "Admin_Access_AccessSet", "AccessSetLink");
54
55 static {
56 RoleUpdate.ALLLINKS.add(RoleUpdate.LINK2ACCESSCMD);
57 RoleUpdate.ALLLINKS.add(RoleUpdate.LINK2ACCESSSET);
58 }
59
60
61
62
63 private boolean global = true;
64
65
66
67
68
69 public RoleUpdate(final URL _url)
70 {
71 super(_url, "temp", RoleUpdate.ALLLINKS);
72 }
73
74 @Override
75 public String getDataModelTypeName()
76 {
77 return this.global ? "Admin_User_RoleGlobal" : "Admin_User_RoleLocal";
78 }
79
80
81
82
83
84
85
86 @Override
87 protected AbstractDefinition newDefinition()
88 {
89 return new RoleDefinition();
90 }
91
92
93
94
95 public class RoleDefinition
96 extends AbstractDefinition
97 {
98
99
100
101
102 private boolean setAccess = false;
103
104 @Override
105 protected void readXML(final List<String> _tags,
106 final Map<String, String> _attributes,
107 final String _text)
108 throws EFapsException
109 {
110 final String value = _tags.get(0);
111 if ("status".equals(value)) {
112 addValue("Status", _text);
113 } else if ("global".equals(value)) {
114 RoleUpdate.this.global = Boolean.valueOf(_text);
115 } else if ("access".equals(value)) {
116 this.setAccess = true;
117 if (_tags.size() > 2) {
118 final String subValue1 = _tags.get(1);
119 if ("userinterface".equals(subValue1)) {
120 final String subValue2 = _tags.get(2);
121 if ("cmd".equals(subValue2)) {
122 addLink(RoleUpdate.LINK2ACCESSCMD, new LinkInstance(_text));
123 } else {
124 super.readXML(_tags, _attributes, _text);
125 }
126 } else if ("datamodel".equals(subValue1)) {
127 final String subValue2 = _tags.get(2);
128 if ("accessset".equals(subValue2)) {
129 addLink(RoleUpdate.LINK2ACCESSSET, new LinkInstance(_text));
130 }
131 } else {
132 super.readXML(_tags, _attributes, _text);
133 }
134 }
135 } else {
136 super.readXML(_tags, _attributes, _text);
137 }
138 }
139
140 @Override
141 protected void setLinksInDB(final Instance _instance,
142 final Link _linktype,
143 final Set<LinkInstance> _links)
144 throws EFapsException
145 {
146 if (this.setAccess) {
147 super.setLinksInDB(_instance, _linktype, _links);
148 }
149 }
150 }
151 }