9 package cz.vutbr.fit.knot.annotations.modules.suggestionManager;
12 import java.util.ArrayList;
13 import java.util.HashMap;
14 import java.util.Iterator;
54 StringBuilder result =
new StringBuilder(
"\"" +
typeName +
"\": [");
57 Iterator<String> atIt = requestedAttributes.iterator();
59 String at = atIt.next();
60 result.append(
"\"").append(at).append(
"\"");
62 while (atIt.hasNext()) {
63 String at = atIt.next();
64 result.append(
", \"").append(at).append(
"\"");
67 Iterator<String> atIt = availableAttributes.iterator();
69 String at = atIt.next();
70 result.append(
"\"").append(at).append(
"\"");
72 while (atIt.hasNext()) {
73 String at = atIt.next();
74 result.append(
", \"").append(at).append(
"\"");
79 return result.toString();
90 StringBuilder result =
new StringBuilder(
"\"" +
typeName +
"\": [");
92 Iterator<String> atIt = availableAttributes.iterator();
93 boolean firstFound =
false;
94 while (atIt.hasNext() && !firstFound) {
95 String at = atIt.next();
96 if (filterAtt.contains(at)) {
97 result.append(
"\"").append(at).append(
"\"");
101 while (atIt.hasNext()) {
102 String at = atIt.next();
103 if (filterAtt.contains(at)) {
104 result.append(
", \"").append(at).append(
"\"");
109 return result.toString();
121 public void filterAttributes(ArrayList<String> desiredAttributes, ArrayList<String> unnecessaryAttributes) {
126 if ((desiredAttributes == null || desiredAttributes.isEmpty()) &&
availableAttributes != null) {
127 if (unnecessaryAttributes != null && !unnecessaryAttributes.isEmpty()) {
129 Iterator<String> avIt = availableAttributes.iterator();
130 while (avIt.hasNext()) {
131 String a = avIt.next();
132 if (!unnecessaryAttributes.contains(a)) {
133 requestedAttributes.add(a);
143 Iterator<String> desIt = desiredAttributes.iterator();
144 while (desIt.hasNext()) {
145 String d = desIt.next();
147 requestedAttributes.add(d);
159 ArrayList<SecApiReqTypeDef> availableTypes = AppBean.getAvTypeDefinitions();
161 ArrayList<SecApiReqTypeDef> desiredTypes = AppBean.getDesTypeDefinitions();
162 ArrayList<SecApiReqTypeDef> unnecessaryTypes = AppBean.getUnTypeDefinitions();
163 ArrayList<SecApiReqTypeDef> unnecessaryAts = AppBean.getUnAtDefinitions();
164 ArrayList<SecApiReqTypeDef> requestedTypes =
new ArrayList<SecApiReqTypeDef>();
166 ArrayList<SecApiReqTypeDef> desiredTypesEA = AppBean.getDesTypeDefinitionsEA();
167 ArrayList<SecApiReqTypeDef> unnecessaryTypesEA = AppBean.getUnTypeDefinitionsEA();
168 ArrayList<SecApiReqTypeDef> unnecessaryAtsEA = AppBean.getUnAtDefinitionsEA();
169 ArrayList<SecApiReqTypeDef> requestedTypesEA =
new ArrayList<SecApiReqTypeDef>();
171 if (availableTypes == null) {
172 AppBean.setReqTypeDefinitions(requestedTypes);
173 AppBean.setReqTypeDefinitionsEA(requestedTypesEA);
177 if ((desiredTypes == null || desiredTypes.isEmpty())) {
178 if (unnecessaryTypes != null && !unnecessaryTypes.isEmpty()) {
179 if (unnecessaryAts == null) {
180 unnecessaryAts =
new ArrayList<SecApiReqTypeDef>();
182 Iterator<SecApiReqTypeDef> avIt = availableTypes.iterator();
183 while (avIt.hasNext()) {
185 if (!unnecessaryTypes.contains(a)) {
187 requestedTypes.add(ca);
188 boolean uFound =
false;
189 Iterator<SecApiReqTypeDef> unIt = unnecessaryAts.iterator();
190 while (unIt.hasNext() && !uFound) {
192 if (u.
getTypeName().contentEquals(a.getTypeName())) {
195 ca.filterAttributes(null, u.getAvailableAttributes());
199 ca.filterAttributes(null, null);
204 requestedTypes =
new ArrayList<SecApiReqTypeDef>();
205 Iterator<SecApiReqTypeDef> avIt = availableTypes.iterator();
206 while (avIt.hasNext()) {
209 ca.filterAttributes(null, null);
210 requestedTypes.add(ca);
215 Iterator<SecApiReqTypeDef> desIt = desiredTypes.iterator();
216 while (desIt.hasNext()) {
218 Iterator<SecApiReqTypeDef> avIt = availableTypes.iterator();
219 while (avIt.hasNext()) {
221 if (a.
getTypeName().contentEquals(d.getTypeName())) {
223 requestedTypes.add(ca);
224 ca.filterAttributes(d.getAvailableAttributes(), null);
231 if ((desiredTypesEA == null || desiredTypesEA.isEmpty())) {
232 if (unnecessaryTypesEA != null && !unnecessaryTypesEA.isEmpty()) {
233 if (unnecessaryAtsEA == null) {
234 unnecessaryAtsEA =
new ArrayList<SecApiReqTypeDef>();
236 Iterator<SecApiReqTypeDef> avIt = availableTypes.iterator();
237 while (avIt.hasNext()) {
239 if (!unnecessaryTypesEA.contains(a)) {
241 requestedTypesEA.add(ca);
242 boolean uFound =
false;
243 Iterator<SecApiReqTypeDef> unIt = unnecessaryAtsEA.iterator();
244 while (unIt.hasNext() && !uFound) {
246 if (u.
getTypeName().contentEquals(a.getTypeName())) {
249 ca.filterAttributes(null, u.getAvailableAttributes());
253 ca.filterAttributes(null, null);
258 requestedTypesEA =
new ArrayList<SecApiReqTypeDef>();
259 Iterator<SecApiReqTypeDef> avIt = availableTypes.iterator();
260 while (avIt.hasNext()) {
263 ca.filterAttributes(null, null);
268 Iterator<SecApiReqTypeDef> desIt = desiredTypesEA.iterator();
269 while (desIt.hasNext()) {
271 Iterator<SecApiReqTypeDef> avIt = availableTypes.iterator();
272 while (avIt.hasNext()) {
274 if (a.
getTypeName().contentEquals(d.getTypeName())) {
276 requestedTypesEA.add(ca);
277 ca.filterAttributes(d.getAvailableAttributes(), null);
284 AppBean.setReqTypeDefinitions(requestedTypes);
285 AppBean.setReqTypeDefinitionsEA(requestedTypesEA);
312 this.availableAttributes.add(availableAttribute);
358 return priorities.get(name);
368 priorities.put(name, priority);
377 this.altDescDef = desc;
398 result.setAvailableAttributes(
new ArrayList<String>(this.availableAttributes));
401 result.setRequestedAttributes(
new ArrayList<String>(this.requestedAttributes));
404 result.setPriorities(
new HashMap<String, Integer>(this.priorities));
406 result.setAltDescDef(this.altDescDef);
441 if (getClass() != obj.getClass()) {
454 hash = 67 * hash + (this.typeName != null ? this.typeName.hashCode() : 0);
static void filterTypes()
void addAvailableAttribute(String availableAttribute)
boolean equals(Object obj)
String getRequestString(ArrayList< String > filterAtt)
void setAvailableAttributes(ArrayList< String > availableAttributes)
ArrayList< String > requestedAttributes
ArrayList< String > availableAttributes
void setTypeName(String typeName)
Singleton for storing global variables.
void setPriority(String name, Integer priority)
SecApiReqTypeDef(String name)
ArrayList< String > getAvailableAttributes()
void filterAttributes(ArrayList< String > desiredAttributes, ArrayList< String > unnecessaryAttributes)
ArrayList< String > getRequestedAttributes()
Class for creating of requested type definition for SEC API.
void setPriorities(HashMap< String, Integer > priorities)
HashMap< String, Integer > getPriorities()
Integer getPriority(String name)
HashMap< String, Integer > priorities
void setRequestedAttributes(ArrayList< String > requestedAttributes)
String getRequestString()
void setAltDescDef(String desc)