2 * ============LICENSE_START=======================================================
3 * Copyright (C) 2016-2018 Ericsson. All rights reserved.
4 * ================================================================================
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
17 * SPDX-License-Identifier: Apache-2.0
18 * ============LICENSE_END=========================================================
21 package org.onap.policy.apex.examples.aadm.model;
23 import org.onap.policy.apex.model.basicmodel.concepts.ApexRuntimeException;
24 import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
25 import org.onap.policy.apex.model.basicmodel.concepts.AxKeyInformation;
26 import org.onap.policy.apex.model.basicmodel.concepts.AxReferenceKey;
27 import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult;
28 import org.onap.policy.apex.model.contextmodel.concepts.AxContextAlbum;
29 import org.onap.policy.apex.model.contextmodel.concepts.AxContextAlbums;
30 import org.onap.policy.apex.model.contextmodel.concepts.AxContextSchema;
31 import org.onap.policy.apex.model.contextmodel.concepts.AxContextSchemas;
32 import org.onap.policy.apex.model.eventmodel.concepts.AxEvent;
33 import org.onap.policy.apex.model.eventmodel.concepts.AxEvents;
34 import org.onap.policy.apex.model.eventmodel.concepts.AxField;
35 import org.onap.policy.apex.model.policymodel.concepts.AxLogicReader;
36 import org.onap.policy.apex.model.policymodel.concepts.AxPolicies;
37 import org.onap.policy.apex.model.policymodel.concepts.AxPolicy;
38 import org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel;
39 import org.onap.policy.apex.model.policymodel.concepts.AxState;
40 import org.onap.policy.apex.model.policymodel.concepts.AxStateOutput;
41 import org.onap.policy.apex.model.policymodel.concepts.AxStateTaskOutputType;
42 import org.onap.policy.apex.model.policymodel.concepts.AxStateTaskReference;
43 import org.onap.policy.apex.model.policymodel.concepts.AxTask;
44 import org.onap.policy.apex.model.policymodel.concepts.AxTaskLogic;
45 import org.onap.policy.apex.model.policymodel.concepts.AxTaskSelectionLogic;
46 import org.onap.policy.apex.model.policymodel.concepts.AxTasks;
47 import org.onap.policy.apex.model.policymodel.handling.PolicyLogicReader;
50 * The Class AADMDomainModelFactory.
52 public class AadmDomainModelFactory {
53 // Recurring string constants
54 private static final String MATCH = "Match";
55 private static final String ESTABLISH = "Establish";
56 private static final String DECIDE = "Decide";
57 private static final String TASK_SELECTION_LOGIC = "TaskSelectionLogic";
58 private static final String DEFAULT_TASK_LOGIC = "DefaultTaskLogic";
59 private static final String TASK_LOGIC = "TaskLogic";
60 private static final String VERSION = "VERSION";
61 private static final String THRESHOLD = "THRESHOLD";
62 private static final String PROFILE2 = "PROFILE";
63 private static final String BLACKLIST_ON = "BLACKLIST_ON";
64 private static final String ACTTASK = "ACTTASK";
65 private static final String TCP_ON = "TCP_ON";
66 private static final String PROBE_ON = "PROBE_ON";
67 private static final String APPLICATION = "APPLICATION";
68 private static final String NW_IP = "NW_IP";
69 private static final String IMSI_IP = "IMSI_IP";
70 private static final String ENODEB_ID = "ENODEB_ID";
71 private static final String DEFAULT_SOURCE = "External";
72 private static final String DEFAULT_NAMESPACE = "org.onap.policy.apex.examples.aadm.events";
73 private static final String JAVA_LANG_INTEGER = "java.lang.Integer";
74 private static final String JAVA_LANG_DOUBLE = "java.lang.Double";
75 private static final String JAVA_LANG_BOOLEAN = "java.lang.Boolean";
76 private static final String JAVA_LANG_STRING = "java.lang.String";
77 private static final String JAVA_LANG_LONG = "java.lang.Long";
78 private static final String DEFAULT_VERSION = "0.0.1";
81 * Gets the AADM policy model.
83 * @return the AADM policy model
85 // CHECKSTYLE:OFF: checkstyle
86 public AxPolicyModel getAadmPolicyModel() {
87 // CHECKSTYLE:ON: checkstyle
88 // Data types for event parameters
89 final AxContextSchema imsi = new AxContextSchema(new AxArtifactKey("IMSI", DEFAULT_VERSION), "Java",
91 final AxContextSchema ueIpAddress = new AxContextSchema(new AxArtifactKey("UEIPAddress", DEFAULT_VERSION),
92 "Java", JAVA_LANG_STRING);
93 final AxContextSchema nwIpAddress = new AxContextSchema(new AxArtifactKey("NWIPAddress", DEFAULT_VERSION),
94 "Java", JAVA_LANG_STRING);
95 final AxContextSchema dosFlag = new AxContextSchema(new AxArtifactKey("DOSFlag", DEFAULT_VERSION), "Java",
97 final AxContextSchema roundTripTime = new AxContextSchema(new AxArtifactKey("RoundTripTime", DEFAULT_VERSION),
98 "Java", JAVA_LANG_LONG);
99 final AxContextSchema applicationName = new AxContextSchema(
100 new AxArtifactKey("ApplicationName", DEFAULT_VERSION), "Java", JAVA_LANG_STRING);
101 final AxContextSchema protocolGroup = new AxContextSchema(new AxArtifactKey("ProtocolGroup", DEFAULT_VERSION),
102 "Java", JAVA_LANG_STRING);
103 final AxContextSchema eNodeBId = new AxContextSchema(new AxArtifactKey("ENodeBID", DEFAULT_VERSION), "Java",
105 final AxContextSchema httpHostClass = new AxContextSchema(new AxArtifactKey("HttpHostClass", DEFAULT_VERSION),
106 "Java", JAVA_LANG_STRING);
107 final AxContextSchema tcpOnFlag = new AxContextSchema(new AxArtifactKey("TCPOnFlag", DEFAULT_VERSION), "Java",
109 final AxContextSchema probeOnFlag = new AxContextSchema(new AxArtifactKey("ProbeOnFlag", DEFAULT_VERSION),
110 "Java", JAVA_LANG_BOOLEAN);
111 final AxContextSchema blacklistOnFlag = new AxContextSchema(
112 new AxArtifactKey("BlacklistOnFlag", DEFAULT_VERSION), "Java", JAVA_LANG_BOOLEAN);
113 final AxContextSchema averageThroughput = new AxContextSchema(
114 new AxArtifactKey("AverageThroughput", DEFAULT_VERSION), "Java", JAVA_LANG_DOUBLE);
115 final AxContextSchema serviceRequestCount = new AxContextSchema(
116 new AxArtifactKey("ServiceRequestCount", DEFAULT_VERSION), "Java", JAVA_LANG_INTEGER);
117 final AxContextSchema attchCount = new AxContextSchema(new AxArtifactKey("AttachCount", DEFAULT_VERSION),
118 "Java", JAVA_LANG_INTEGER);
119 final AxContextSchema subscriberCount = new AxContextSchema(
120 new AxArtifactKey("SubscriberCount", DEFAULT_VERSION), "Java", JAVA_LANG_INTEGER);
121 final AxContextSchema averageServiceRequest = new AxContextSchema(
122 new AxArtifactKey("AverageServiceRequest", DEFAULT_VERSION), "Java", JAVA_LANG_DOUBLE);
123 final AxContextSchema averageAttach = new AxContextSchema(new AxArtifactKey("AverageAttach", DEFAULT_VERSION),
124 "Java", JAVA_LANG_DOUBLE);
125 final AxContextSchema actionTask = new AxContextSchema(new AxArtifactKey("ActionTask", DEFAULT_VERSION), "Java",
127 final AxContextSchema version = new AxContextSchema(new AxArtifactKey("Version", DEFAULT_VERSION), "Java",
129 final AxContextSchema profile = new AxContextSchema(new AxArtifactKey("Profile", DEFAULT_VERSION), "Java",
131 final AxContextSchema threshold = new AxContextSchema(new AxArtifactKey("Threshold", DEFAULT_VERSION), "Java",
133 final AxContextSchema triggerSpec = new AxContextSchema(new AxArtifactKey("TriggerSpec", DEFAULT_VERSION),
134 "Java", JAVA_LANG_STRING);
135 final AxContextSchema periodicEventCount = new AxContextSchema(
136 new AxArtifactKey("PeriodicEventCount", DEFAULT_VERSION), "Java", JAVA_LANG_LONG);
137 final AxContextSchema periodicDelay = new AxContextSchema(new AxArtifactKey("PeriodicDelay", DEFAULT_VERSION),
138 "Java", JAVA_LANG_LONG);
139 final AxContextSchema periodicTime = new AxContextSchema(new AxArtifactKey("PeriodicTime", DEFAULT_VERSION),
140 "Java", JAVA_LANG_LONG);
142 final AxContextSchemas aadmContextSchemas = new AxContextSchemas(
143 new AxArtifactKey("AADMDatatypes", DEFAULT_VERSION));
144 aadmContextSchemas.getSchemasMap().put(imsi.getKey(), imsi);
145 aadmContextSchemas.getSchemasMap().put(ueIpAddress.getKey(), ueIpAddress);
146 aadmContextSchemas.getSchemasMap().put(nwIpAddress.getKey(), nwIpAddress);
147 aadmContextSchemas.getSchemasMap().put(dosFlag.getKey(), dosFlag);
148 aadmContextSchemas.getSchemasMap().put(roundTripTime.getKey(), roundTripTime);
149 aadmContextSchemas.getSchemasMap().put(applicationName.getKey(), applicationName);
150 aadmContextSchemas.getSchemasMap().put(protocolGroup.getKey(), protocolGroup);
151 aadmContextSchemas.getSchemasMap().put(eNodeBId.getKey(), eNodeBId);
152 aadmContextSchemas.getSchemasMap().put(httpHostClass.getKey(), httpHostClass);
153 aadmContextSchemas.getSchemasMap().put(tcpOnFlag.getKey(), tcpOnFlag);
154 aadmContextSchemas.getSchemasMap().put(probeOnFlag.getKey(), probeOnFlag);
155 aadmContextSchemas.getSchemasMap().put(blacklistOnFlag.getKey(), blacklistOnFlag);
156 aadmContextSchemas.getSchemasMap().put(averageThroughput.getKey(), averageThroughput);
157 aadmContextSchemas.getSchemasMap().put(serviceRequestCount.getKey(), serviceRequestCount);
158 aadmContextSchemas.getSchemasMap().put(attchCount.getKey(), attchCount);
159 aadmContextSchemas.getSchemasMap().put(subscriberCount.getKey(), subscriberCount);
160 aadmContextSchemas.getSchemasMap().put(averageServiceRequest.getKey(), averageServiceRequest);
161 aadmContextSchemas.getSchemasMap().put(averageAttach.getKey(), averageAttach);
162 aadmContextSchemas.getSchemasMap().put(actionTask.getKey(), actionTask);
163 aadmContextSchemas.getSchemasMap().put(version.getKey(), version);
164 aadmContextSchemas.getSchemasMap().put(profile.getKey(), profile);
165 aadmContextSchemas.getSchemasMap().put(threshold.getKey(), threshold);
166 aadmContextSchemas.getSchemasMap().put(triggerSpec.getKey(), triggerSpec);
167 aadmContextSchemas.getSchemasMap().put(periodicEventCount.getKey(), periodicEventCount);
168 aadmContextSchemas.getSchemasMap().put(periodicDelay.getKey(), periodicDelay);
169 aadmContextSchemas.getSchemasMap().put(periodicTime.getKey(), periodicTime);
171 final AxEvent aadmEvent = new AxEvent(new AxArtifactKey("AADMEvent", DEFAULT_VERSION),
173 aadmEvent.setSource(DEFAULT_SOURCE);
174 aadmEvent.setTarget("Apex");
175 aadmEvent.getParameterMap().put("IMSI",
176 new AxField(new AxReferenceKey(aadmEvent.getKey(), "IMSI"), imsi.getKey()));
177 aadmEvent.getParameterMap().put(ENODEB_ID,
178 new AxField(new AxReferenceKey(aadmEvent.getKey(), ENODEB_ID), eNodeBId.getKey()));
179 aadmEvent.getParameterMap().put(IMSI_IP,
180 new AxField(new AxReferenceKey(aadmEvent.getKey(), IMSI_IP), ueIpAddress.getKey()));
181 aadmEvent.getParameterMap().put(NW_IP,
182 new AxField(new AxReferenceKey(aadmEvent.getKey(), NW_IP), nwIpAddress.getKey()));
183 aadmEvent.getParameterMap().put("DoS",
184 new AxField(new AxReferenceKey(aadmEvent.getKey(), "DoS"), dosFlag.getKey()));
185 aadmEvent.getParameterMap().put("TCP_UE_SIDE_MEDIAN_RTT_TX_TO_RX",
186 new AxField(new AxReferenceKey(aadmEvent.getKey(), "TCP_UE_SIDE_MEDIAN_RTT_TX_TO_RX"),
187 roundTripTime.getKey()));
188 aadmEvent.getParameterMap().put("TCP_UE_SIDE_AVG_THROUGHPUT",
189 new AxField(new AxReferenceKey(aadmEvent.getKey(), "TCP_UE_SIDE_AVG_THROUGHPUT"),
190 averageThroughput.getKey()));
191 aadmEvent.getParameterMap().put(APPLICATION,
192 new AxField(new AxReferenceKey(aadmEvent.getKey(), APPLICATION), applicationName.getKey()));
193 aadmEvent.getParameterMap().put("protocol_group",
194 new AxField(new AxReferenceKey(aadmEvent.getKey(), "protocol_group"), protocolGroup.getKey()));
195 aadmEvent.getParameterMap().put("http_host_class",
196 new AxField(new AxReferenceKey(aadmEvent.getKey(), "http_host_class"), httpHostClass.getKey()));
197 aadmEvent.getParameterMap().put(PROBE_ON,
198 new AxField(new AxReferenceKey(aadmEvent.getKey(), PROBE_ON), probeOnFlag.getKey()));
199 aadmEvent.getParameterMap().put(TCP_ON,
200 new AxField(new AxReferenceKey(aadmEvent.getKey(), TCP_ON), tcpOnFlag.getKey()));
201 aadmEvent.getParameterMap().put("SGW_IP_ADDRESS",
202 new AxField(new AxReferenceKey(aadmEvent.getKey(), "SGW_IP_ADDRESS"), nwIpAddress.getKey()));
203 aadmEvent.getParameterMap().put("UE_IP_ADDRESS",
204 new AxField(new AxReferenceKey(aadmEvent.getKey(), "UE_IP_ADDRESS"), ueIpAddress.getKey()));
205 aadmEvent.getParameterMap().put("SERVICE_REQUEST_COUNT", new AxField(
206 new AxReferenceKey(aadmEvent.getKey(), "SERVICE_REQUEST_COUNT"), serviceRequestCount.getKey()));
207 aadmEvent.getParameterMap().put("ATTACH_COUNT",
208 new AxField(new AxReferenceKey(aadmEvent.getKey(), "ATTACH_COUNT"), attchCount.getKey()));
209 aadmEvent.getParameterMap().put("NUM_SUBSCRIBERS", new AxField(
210 new AxReferenceKey(aadmEvent.getKey(), "NUM_SUBSCRIBERS"), subscriberCount.getKey()));
211 aadmEvent.getParameterMap().put("AVG_SUBSCRIBER_SERVICE_REQUEST",
212 new AxField(new AxReferenceKey(aadmEvent.getKey(), "AVG_SUBSCRIBER_SERVICE_REQUEST"),
213 averageServiceRequest.getKey()));
214 aadmEvent.getParameterMap().put("AVG_SUBSCRIBER_ATTACH", new AxField(
215 new AxReferenceKey(aadmEvent.getKey(), "AVG_SUBSCRIBER_ATTACH"), averageAttach.getKey()));
216 aadmEvent.getParameterMap().put(ACTTASK,
217 new AxField(new AxReferenceKey(aadmEvent.getKey(), ACTTASK), actionTask.getKey()));
219 final AxEvent aadmXStreamActEvent = new AxEvent(new AxArtifactKey("XSTREAM_AADM_ACT_EVENT", DEFAULT_VERSION),
221 aadmXStreamActEvent.setSource("Apex");
222 aadmXStreamActEvent.setTarget(DEFAULT_SOURCE);
223 aadmXStreamActEvent.getParameterMap().put("IMSI",
224 new AxField(new AxReferenceKey(aadmXStreamActEvent.getKey(), "IMSI"), imsi.getKey()));
225 aadmXStreamActEvent.getParameterMap().put(IMSI_IP,
226 new AxField(new AxReferenceKey(aadmXStreamActEvent.getKey(), IMSI_IP), ueIpAddress.getKey()));
227 aadmXStreamActEvent.getParameterMap().put(ENODEB_ID,
228 new AxField(new AxReferenceKey(aadmXStreamActEvent.getKey(), ENODEB_ID), eNodeBId.getKey()));
229 aadmXStreamActEvent.getParameterMap().put(NW_IP,
230 new AxField(new AxReferenceKey(aadmXStreamActEvent.getKey(), NW_IP), nwIpAddress.getKey()));
231 aadmXStreamActEvent.getParameterMap().put(ACTTASK,
232 new AxField(new AxReferenceKey(aadmXStreamActEvent.getKey(), ACTTASK), actionTask.getKey()));
233 aadmXStreamActEvent.getParameterMap().put(PROBE_ON, new AxField(
234 new AxReferenceKey(aadmXStreamActEvent.getKey(), PROBE_ON), probeOnFlag.getKey()));
235 aadmXStreamActEvent.getParameterMap().put(TCP_ON,
236 new AxField(new AxReferenceKey(aadmXStreamActEvent.getKey(), TCP_ON), tcpOnFlag.getKey()));
237 aadmXStreamActEvent.getParameterMap().put(VERSION,
238 new AxField(new AxReferenceKey(aadmXStreamActEvent.getKey(), VERSION), version.getKey()));
239 aadmXStreamActEvent.getParameterMap().put("TRIGGER_SPEC", new AxField(
240 new AxReferenceKey(aadmXStreamActEvent.getKey(), "TRIGGER_SPEC"), triggerSpec.getKey()));
241 aadmXStreamActEvent.getParameterMap().put("MAJ_MIN_MAINT_VERSION", new AxField(
242 new AxReferenceKey(aadmXStreamActEvent.getKey(), "MAJ_MIN_MAINT_VERSION"), version.getKey()));
243 aadmXStreamActEvent.getParameterMap().put(BLACKLIST_ON, new AxField(
244 new AxReferenceKey(aadmXStreamActEvent.getKey(), BLACKLIST_ON), blacklistOnFlag.getKey()));
245 aadmXStreamActEvent.getParameterMap().put(PROFILE2,
246 new AxField(new AxReferenceKey(aadmXStreamActEvent.getKey(), PROFILE2), profile.getKey()));
247 aadmXStreamActEvent.getParameterMap().put(THRESHOLD,
248 new AxField(new AxReferenceKey(aadmXStreamActEvent.getKey(), THRESHOLD), threshold.getKey()));
250 final AxEvent vMmeEvent = new AxEvent(new AxArtifactKey("VMMEEvent", DEFAULT_VERSION),
252 vMmeEvent.setSource(DEFAULT_SOURCE);
253 vMmeEvent.setTarget("Apex");
254 vMmeEvent.getParameterMap().put("IMSI",
255 new AxField(new AxReferenceKey(vMmeEvent.getKey(), "IMSI"), imsi.getKey()));
256 vMmeEvent.getParameterMap().put(ENODEB_ID,
257 new AxField(new AxReferenceKey(vMmeEvent.getKey(), ENODEB_ID), eNodeBId.getKey()));
258 vMmeEvent.getParameterMap().put(IMSI_IP,
259 new AxField(new AxReferenceKey(vMmeEvent.getKey(), IMSI_IP), ueIpAddress.getKey()));
260 vMmeEvent.getParameterMap().put(NW_IP,
261 new AxField(new AxReferenceKey(vMmeEvent.getKey(), NW_IP), nwIpAddress.getKey()));
262 vMmeEvent.getParameterMap().put(PROFILE2,
263 new AxField(new AxReferenceKey(vMmeEvent.getKey(), PROFILE2), profile.getKey()));
264 vMmeEvent.getParameterMap().put(THRESHOLD,
265 new AxField(new AxReferenceKey(vMmeEvent.getKey(), THRESHOLD), threshold.getKey()));
267 final AxEvent sapcEvent = new AxEvent(new AxArtifactKey("SAPCEvent", DEFAULT_VERSION),
269 sapcEvent.setSource(DEFAULT_SOURCE);
270 sapcEvent.setTarget("Apex");
271 sapcEvent.getParameterMap().put("IMSI",
272 new AxField(new AxReferenceKey(sapcEvent.getKey(), "IMSI"), imsi.getKey()));
273 sapcEvent.getParameterMap().put(ENODEB_ID,
274 new AxField(new AxReferenceKey(sapcEvent.getKey(), ENODEB_ID), eNodeBId.getKey()));
275 sapcEvent.getParameterMap().put(IMSI_IP,
276 new AxField(new AxReferenceKey(sapcEvent.getKey(), IMSI_IP), ueIpAddress.getKey()));
277 sapcEvent.getParameterMap().put(NW_IP,
278 new AxField(new AxReferenceKey(sapcEvent.getKey(), NW_IP), nwIpAddress.getKey()));
279 sapcEvent.getParameterMap().put(PROFILE2,
280 new AxField(new AxReferenceKey(sapcEvent.getKey(), PROFILE2), profile.getKey()));
281 sapcEvent.getParameterMap().put(THRESHOLD,
282 new AxField(new AxReferenceKey(sapcEvent.getKey(), THRESHOLD), threshold.getKey()));
283 sapcEvent.getParameterMap().put(TCP_ON,
284 new AxField(new AxReferenceKey(sapcEvent.getKey(), TCP_ON), tcpOnFlag.getKey()));
285 sapcEvent.getParameterMap().put(PROBE_ON,
286 new AxField(new AxReferenceKey(sapcEvent.getKey(), PROBE_ON), probeOnFlag.getKey()));
287 sapcEvent.getParameterMap().put(VERSION,
288 new AxField(new AxReferenceKey(sapcEvent.getKey(), VERSION), version.getKey()));
289 sapcEvent.getParameterMap().put(BLACKLIST_ON,
290 new AxField(new AxReferenceKey(sapcEvent.getKey(), BLACKLIST_ON), blacklistOnFlag.getKey()));
292 final AxEvent sapcBlacklistSubscriberEvent = new AxEvent(
293 new AxArtifactKey("SAPCBlacklistSubscriberEvent", DEFAULT_VERSION),
295 sapcBlacklistSubscriberEvent.setSource("Apex");
296 sapcBlacklistSubscriberEvent.setTarget(DEFAULT_SOURCE);
297 sapcBlacklistSubscriberEvent.getParameterMap().put("IMSI",
298 new AxField(new AxReferenceKey(sapcBlacklistSubscriberEvent.getKey(), "IMSI"), imsi.getKey()));
299 sapcBlacklistSubscriberEvent.getParameterMap().put(PROFILE2, new AxField(
300 new AxReferenceKey(sapcBlacklistSubscriberEvent.getKey(), PROFILE2), profile.getKey()));
301 sapcBlacklistSubscriberEvent.getParameterMap().put(BLACKLIST_ON,
302 new AxField(new AxReferenceKey(sapcBlacklistSubscriberEvent.getKey(), BLACKLIST_ON),
303 blacklistOnFlag.getKey()));
304 sapcBlacklistSubscriberEvent.getParameterMap().put(IMSI_IP, new AxField(
305 new AxReferenceKey(sapcBlacklistSubscriberEvent.getKey(), IMSI_IP), ueIpAddress.getKey()));
306 sapcBlacklistSubscriberEvent.getParameterMap().put(NW_IP, new AxField(
307 new AxReferenceKey(sapcBlacklistSubscriberEvent.getKey(), NW_IP), nwIpAddress.getKey()));
308 sapcBlacklistSubscriberEvent.getParameterMap().put(PROBE_ON, new AxField(
309 new AxReferenceKey(sapcBlacklistSubscriberEvent.getKey(), PROBE_ON), probeOnFlag.getKey()));
310 sapcBlacklistSubscriberEvent.getParameterMap().put(TCP_ON, new AxField(
311 new AxReferenceKey(sapcBlacklistSubscriberEvent.getKey(), TCP_ON), tcpOnFlag.getKey()));
313 final AxEvent periodicEvent = new AxEvent(new AxArtifactKey("PeriodicEvent", DEFAULT_VERSION),
315 periodicEvent.setSource("System");
316 periodicEvent.setTarget("Apex");
317 periodicEvent.getParameterMap().put("PERIODIC_EVENT_COUNT",
318 new AxField(new AxReferenceKey(periodicEvent.getKey(), "PERIODIC_EVENT_COUNT"),
319 periodicEventCount.getKey()));
320 periodicEvent.getParameterMap().put("PERIODIC_DELAY", new AxField(
321 new AxReferenceKey(periodicEvent.getKey(), "PERIODIC_DELAY"), periodicDelay.getKey()));
322 periodicEvent.getParameterMap().put("PERIODIC_FIRST_TIME", new AxField(
323 new AxReferenceKey(periodicEvent.getKey(), "PERIODIC_FIRST_TIME"), periodicTime.getKey()));
324 periodicEvent.getParameterMap().put("PERIODIC_CURRENT_TIME", new AxField(
325 new AxReferenceKey(periodicEvent.getKey(), "PERIODIC_CURRENT_TIME"), periodicTime.getKey()));
326 periodicEvent.getParameterMap().put("PERIODIC_LAST_TIME", new AxField(
327 new AxReferenceKey(periodicEvent.getKey(), "PERIODIC_LAST_TIME"), periodicTime.getKey()));
329 final AxEvents aadmEvents = new AxEvents(new AxArtifactKey("AADMEvents", DEFAULT_VERSION));
330 aadmEvents.getEventMap().put(aadmEvent.getKey(), aadmEvent);
331 aadmEvents.getEventMap().put(aadmXStreamActEvent.getKey(), aadmXStreamActEvent);
332 aadmEvents.getEventMap().put(vMmeEvent.getKey(), vMmeEvent);
333 aadmEvents.getEventMap().put(sapcEvent.getKey(), sapcEvent);
334 aadmEvents.getEventMap().put(sapcBlacklistSubscriberEvent.getKey(), sapcBlacklistSubscriberEvent);
335 aadmEvents.getEventMap().put(periodicEvent.getKey(), periodicEvent);
337 // Data types for context
338 final AxContextSchema eNodeBStatus = new AxContextSchema(new AxArtifactKey("ENodeBStatus", DEFAULT_VERSION),
339 "Java", "org.onap.policy.apex.examples.aadm.concepts.ENodeBStatus");
340 final AxContextSchema imsiStatus = new AxContextSchema(new AxArtifactKey("IMSIStatus", DEFAULT_VERSION), "Java",
341 "org.onap.policy.apex.examples.aadm.concepts.ImsiStatus");
342 final AxContextSchema ipAddressStatus = new AxContextSchema(
343 new AxArtifactKey("IPAddressStatus", DEFAULT_VERSION), "Java",
344 "org.onap.policy.apex.examples.aadm.concepts.IpAddressStatus");
345 aadmContextSchemas.getSchemasMap().put(eNodeBStatus.getKey(), eNodeBStatus);
346 aadmContextSchemas.getSchemasMap().put(imsiStatus.getKey(), imsiStatus);
347 aadmContextSchemas.getSchemasMap().put(ipAddressStatus.getKey(), ipAddressStatus);
349 // Three context albums for AADM
350 final AxContextAlbum eNodeBStatusAlbum = new AxContextAlbum(
351 new AxArtifactKey("ENodeBStatusAlbum", DEFAULT_VERSION), APPLICATION, true,
352 eNodeBStatus.getKey());
353 final AxContextAlbum imsiStatusAlbum = new AxContextAlbum(new AxArtifactKey("IMSIStatusAlbum", DEFAULT_VERSION),
354 APPLICATION, true, imsiStatus.getKey());
355 final AxContextAlbum ipAddressStatusAlbum = new AxContextAlbum(
356 new AxArtifactKey("IPAddressStatusAlbum", DEFAULT_VERSION), APPLICATION, true,
357 ipAddressStatus.getKey());
359 final AxContextAlbums aadmAlbums = new AxContextAlbums(new AxArtifactKey("AADMContext", DEFAULT_VERSION));
360 aadmAlbums.getAlbumsMap().put(eNodeBStatusAlbum.getKey(), eNodeBStatusAlbum);
361 aadmAlbums.getAlbumsMap().put(imsiStatusAlbum.getKey(), imsiStatusAlbum);
362 aadmAlbums.getAlbumsMap().put(ipAddressStatusAlbum.getKey(), ipAddressStatusAlbum);
365 final AxLogicReader logicReader = new PolicyLogicReader()
366 .setLogicPackage(this.getClass().getPackage().getName()).setDefaultLogic(null);
368 final AxTask aadmMatchTask = new AxTask(new AxArtifactKey("AADMMatchTask", DEFAULT_VERSION));
369 aadmMatchTask.duplicateInputFields(aadmEvent.getParameterMap());
370 aadmMatchTask.duplicateOutputFields(aadmEvent.getParameterMap());
371 aadmMatchTask.getContextAlbumReferences().add(eNodeBStatusAlbum.getKey());
372 aadmMatchTask.getContextAlbumReferences().add(imsiStatusAlbum.getKey());
373 aadmMatchTask.getContextAlbumReferences().add(ipAddressStatusAlbum.getKey());
374 aadmMatchTask.setTaskLogic(new AxTaskLogic(aadmMatchTask.getKey(), TASK_LOGIC, "MVEL", logicReader));
376 final AxTask aadmEstablishTask = new AxTask(new AxArtifactKey("AADMEstablishTask", DEFAULT_VERSION));
377 aadmEstablishTask.duplicateInputFields(aadmEvent.getParameterMap());
378 aadmEstablishTask.duplicateOutputFields(aadmEvent.getParameterMap());
379 logicReader.setDefaultLogic(DEFAULT_TASK_LOGIC);
380 aadmEstablishTask.setTaskLogic(new AxTaskLogic(aadmEstablishTask.getKey(), TASK_LOGIC, "MVEL", logicReader));
382 final AxTask aadmDecideTask = new AxTask(new AxArtifactKey("AADMDecideTask", DEFAULT_VERSION));
383 aadmDecideTask.duplicateInputFields(aadmEvent.getParameterMap());
384 aadmDecideTask.duplicateOutputFields(aadmEvent.getParameterMap());
385 aadmDecideTask.setTaskLogic(new AxTaskLogic(aadmDecideTask.getKey(), TASK_LOGIC, "MVEL", logicReader));
387 logicReader.setDefaultLogic(null);
389 final AxTask aadmDoSSuggestionActTask = new AxTask(
390 new AxArtifactKey("AADMDoSSuggestionActTask", DEFAULT_VERSION));
391 aadmDoSSuggestionActTask.duplicateInputFields(aadmEvent.getParameterMap());
392 aadmDoSSuggestionActTask.duplicateOutputFields(aadmXStreamActEvent.getParameterMap());
393 aadmDoSSuggestionActTask.getContextAlbumReferences().add(eNodeBStatusAlbum.getKey());
394 aadmDoSSuggestionActTask.getContextAlbumReferences().add(imsiStatusAlbum.getKey());
395 aadmDoSSuggestionActTask.setTaskLogic(
396 new AxTaskLogic(aadmDoSSuggestionActTask.getKey(), TASK_LOGIC, "MVEL", logicReader));
398 final AxTask aadmNoActTask = new AxTask(new AxArtifactKey("AADMNoActTask", DEFAULT_VERSION));
399 aadmNoActTask.duplicateInputFields(aadmEvent.getParameterMap());
400 aadmNoActTask.duplicateOutputFields(aadmXStreamActEvent.getParameterMap());
401 aadmNoActTask.setTaskLogic(new AxTaskLogic(aadmNoActTask.getKey(), TASK_LOGIC, "MVEL", logicReader));
403 final AxTask aadmDoSProvenActTask = new AxTask(new AxArtifactKey("AADMDoSProvenActTask", DEFAULT_VERSION));
404 aadmDoSProvenActTask.duplicateInputFields(aadmEvent.getParameterMap());
405 aadmDoSProvenActTask.duplicateOutputFields(aadmXStreamActEvent.getParameterMap());
406 aadmDoSProvenActTask.getContextAlbumReferences().add(eNodeBStatusAlbum.getKey());
407 aadmDoSProvenActTask.getContextAlbumReferences().add(imsiStatusAlbum.getKey());
409 .setTaskLogic(new AxTaskLogic(aadmDoSProvenActTask.getKey(), TASK_LOGIC, "MVEL", logicReader));
411 final AxTask vMmeMatchTask = new AxTask(new AxArtifactKey("VMMEMatchTask", DEFAULT_VERSION));
412 vMmeMatchTask.duplicateInputFields(vMmeEvent.getParameterMap());
413 vMmeMatchTask.duplicateOutputFields(vMmeEvent.getParameterMap());
414 vMmeMatchTask.setTaskLogic(new AxTaskLogic(vMmeMatchTask.getKey(), TASK_LOGIC, "MVEL", logicReader));
416 final AxTask vMmeEstablishTask = new AxTask(new AxArtifactKey("VMMEEstablishTask", DEFAULT_VERSION));
417 vMmeEstablishTask.duplicateInputFields(vMmeEvent.getParameterMap());
418 vMmeEstablishTask.duplicateOutputFields(vMmeEvent.getParameterMap());
419 logicReader.setDefaultLogic(DEFAULT_TASK_LOGIC);
420 vMmeEstablishTask.setTaskLogic(new AxTaskLogic(vMmeEstablishTask.getKey(), TASK_LOGIC, "MVEL", logicReader));
422 final AxTask vMmeDecideTask = new AxTask(new AxArtifactKey("VMMEDecideTask", DEFAULT_VERSION));
423 vMmeDecideTask.duplicateInputFields(vMmeEvent.getParameterMap());
424 vMmeDecideTask.duplicateOutputFields(vMmeEvent.getParameterMap());
425 vMmeDecideTask.setTaskLogic(new AxTaskLogic(vMmeDecideTask.getKey(), TASK_LOGIC, "MVEL", logicReader));
427 final AxTask vMmeNoActTask = new AxTask(new AxArtifactKey("VMMENoActTask", DEFAULT_VERSION));
428 vMmeNoActTask.duplicateInputFields(vMmeEvent.getParameterMap());
429 vMmeNoActTask.duplicateOutputFields(vMmeEvent.getParameterMap());
430 vMmeNoActTask.setTaskLogic(new AxTaskLogic(vMmeNoActTask.getKey(), TASK_LOGIC, "MVEL", logicReader));
432 final AxTask vMmeActTask = new AxTask(new AxArtifactKey("VMMEActTask", DEFAULT_VERSION));
433 vMmeActTask.duplicateInputFields(vMmeEvent.getParameterMap());
434 vMmeActTask.duplicateOutputFields(vMmeEvent.getParameterMap());
435 logicReader.setDefaultLogic(null);
436 vMmeActTask.setTaskLogic(new AxTaskLogic(vMmeActTask.getKey(), TASK_LOGIC, "MVEL", logicReader));
438 final AxTask sapcMatchTask = new AxTask(new AxArtifactKey("SAPCMatchTask", DEFAULT_VERSION));
439 sapcMatchTask.duplicateInputFields(sapcEvent.getParameterMap());
440 sapcMatchTask.duplicateOutputFields(sapcBlacklistSubscriberEvent.getParameterMap());
441 sapcMatchTask.setTaskLogic(new AxTaskLogic(sapcMatchTask.getKey(), TASK_LOGIC, "MVEL", logicReader));
443 final AxTask sapcEstablishTask = new AxTask(new AxArtifactKey("SAPCEstablishTask", DEFAULT_VERSION));
444 sapcEstablishTask.duplicateInputFields(sapcEvent.getParameterMap());
445 sapcEstablishTask.duplicateOutputFields(sapcBlacklistSubscriberEvent.getParameterMap());
446 logicReader.setDefaultLogic(DEFAULT_TASK_LOGIC);
447 sapcEstablishTask.setTaskLogic(new AxTaskLogic(sapcEstablishTask.getKey(), TASK_LOGIC, "MVEL", logicReader));
449 final AxTask sapcDecideTask = new AxTask(new AxArtifactKey("SAPCDecideTask", DEFAULT_VERSION));
450 sapcDecideTask.duplicateInputFields(sapcEvent.getParameterMap());
451 sapcDecideTask.duplicateOutputFields(sapcBlacklistSubscriberEvent.getParameterMap());
452 sapcDecideTask.setTaskLogic(new AxTaskLogic(sapcDecideTask.getKey(), TASK_LOGIC, "MVEL", logicReader));
454 final AxTask sapcActTask = new AxTask(new AxArtifactKey("SAPCActTask", DEFAULT_VERSION));
455 sapcActTask.duplicateInputFields(sapcEvent.getParameterMap());
456 sapcActTask.duplicateOutputFields(sapcBlacklistSubscriberEvent.getParameterMap());
457 sapcActTask.getContextAlbumReferences().add(imsiStatusAlbum.getKey());
458 logicReader.setDefaultLogic(null);
459 sapcActTask.setTaskLogic(new AxTaskLogic(sapcActTask.getKey(), TASK_LOGIC, "MVEL", logicReader));
461 logicReader.setDefaultLogic(DEFAULT_TASK_LOGIC);
463 final AxTask periodicMatchTask = new AxTask(new AxArtifactKey("PeriodicMatchTask", DEFAULT_VERSION));
464 periodicMatchTask.duplicateInputFields(periodicEvent.getParameterMap());
465 periodicMatchTask.duplicateOutputFields(periodicEvent.getParameterMap());
466 periodicMatchTask.setTaskLogic(new AxTaskLogic(periodicMatchTask.getKey(), TASK_LOGIC, "MVEL", logicReader));
468 final AxTask periodicEstablishTask = new AxTask(new AxArtifactKey("PeriodicEstablishTask", DEFAULT_VERSION));
469 periodicEstablishTask.duplicateInputFields(periodicEvent.getParameterMap());
470 periodicEstablishTask.duplicateOutputFields(periodicEvent.getParameterMap());
471 periodicEstablishTask.setTaskLogic(
472 new AxTaskLogic(periodicEstablishTask.getKey(), TASK_LOGIC, "MVEL", logicReader));
474 final AxTask periodicDecideTask = new AxTask(new AxArtifactKey("PeriodicDecideTask", DEFAULT_VERSION));
475 periodicDecideTask.duplicateInputFields(periodicEvent.getParameterMap());
476 periodicDecideTask.duplicateOutputFields(periodicEvent.getParameterMap());
477 periodicDecideTask.setTaskLogic(new AxTaskLogic(periodicDecideTask.getKey(), TASK_LOGIC, "MVEL", logicReader));
479 final AxTask periodicActTask = new AxTask(new AxArtifactKey("PeriodicActTask", DEFAULT_VERSION));
480 periodicActTask.duplicateInputFields(periodicEvent.getParameterMap());
481 periodicActTask.duplicateOutputFields(sapcBlacklistSubscriberEvent.getParameterMap());
482 periodicActTask.getContextAlbumReferences().add(imsiStatusAlbum.getKey());
483 logicReader.setDefaultLogic(null);
484 periodicActTask.setTaskLogic(new AxTaskLogic(periodicActTask.getKey(), TASK_LOGIC, "MVEL", logicReader));
486 final AxTasks aadmTasks = new AxTasks(new AxArtifactKey("AADMTasks", DEFAULT_VERSION));
487 aadmTasks.getTaskMap().put(aadmMatchTask.getKey(), aadmMatchTask);
488 aadmTasks.getTaskMap().put(aadmEstablishTask.getKey(), aadmEstablishTask);
489 aadmTasks.getTaskMap().put(aadmDecideTask.getKey(), aadmDecideTask);
490 aadmTasks.getTaskMap().put(aadmDoSSuggestionActTask.getKey(), aadmDoSSuggestionActTask);
491 aadmTasks.getTaskMap().put(aadmNoActTask.getKey(), aadmNoActTask);
492 aadmTasks.getTaskMap().put(aadmDoSProvenActTask.getKey(), aadmDoSProvenActTask);
493 aadmTasks.getTaskMap().put(vMmeMatchTask.getKey(), vMmeMatchTask);
494 aadmTasks.getTaskMap().put(vMmeEstablishTask.getKey(), vMmeEstablishTask);
495 aadmTasks.getTaskMap().put(vMmeDecideTask.getKey(), vMmeDecideTask);
496 aadmTasks.getTaskMap().put(vMmeNoActTask.getKey(), vMmeNoActTask);
497 aadmTasks.getTaskMap().put(vMmeActTask.getKey(), vMmeActTask);
498 aadmTasks.getTaskMap().put(sapcMatchTask.getKey(), sapcMatchTask);
499 aadmTasks.getTaskMap().put(sapcEstablishTask.getKey(), sapcEstablishTask);
500 aadmTasks.getTaskMap().put(sapcDecideTask.getKey(), sapcDecideTask);
501 aadmTasks.getTaskMap().put(sapcActTask.getKey(), sapcActTask);
502 aadmTasks.getTaskMap().put(periodicMatchTask.getKey(), periodicMatchTask);
503 aadmTasks.getTaskMap().put(periodicEstablishTask.getKey(), periodicEstablishTask);
504 aadmTasks.getTaskMap().put(periodicDecideTask.getKey(), periodicDecideTask);
505 aadmTasks.getTaskMap().put(periodicActTask.getKey(), periodicActTask);
508 logicReader.setDefaultLogic(null);
510 final AxPolicy aadmPolicy = new AxPolicy(new AxArtifactKey("AADMPolicy", DEFAULT_VERSION));
511 aadmPolicy.setTemplate("MEDA");
513 final AxState aadmActState = new AxState(new AxReferenceKey(aadmPolicy.getKey(), "Act"));
514 aadmActState.setTrigger(aadmEvent.getKey());
515 final AxStateOutput aadmAct2Out = new AxStateOutput(aadmActState.getKey(), AxReferenceKey.getNullKey(),
516 aadmXStreamActEvent.getKey());
517 aadmActState.getStateOutputs().put(aadmAct2Out.getKey().getLocalName(), aadmAct2Out);
518 aadmActState.getContextAlbumReferences().add(ipAddressStatusAlbum.getKey());
519 aadmActState.getContextAlbumReferences().add(imsiStatusAlbum.getKey());
520 aadmActState.getContextAlbumReferences().add(eNodeBStatusAlbum.getKey());
521 aadmActState.setTaskSelectionLogic(
522 new AxTaskSelectionLogic(aadmActState.getKey(), TASK_SELECTION_LOGIC, "MVEL", logicReader));
523 aadmActState.setDefaultTask(aadmNoActTask.getKey());
524 aadmActState.getTaskReferences().put(aadmNoActTask.getKey(), new AxStateTaskReference(aadmActState.getKey(),
525 aadmNoActTask.getKey(), AxStateTaskOutputType.DIRECT, aadmAct2Out.getKey()));
526 aadmActState.getTaskReferences().put(aadmDoSSuggestionActTask.getKey(),
527 new AxStateTaskReference(aadmActState.getKey(), aadmDoSSuggestionActTask.getKey(),
528 AxStateTaskOutputType.DIRECT, aadmAct2Out.getKey()));
529 aadmActState.getTaskReferences().put(aadmDoSProvenActTask.getKey(),
530 new AxStateTaskReference(aadmActState.getKey(), aadmDoSProvenActTask.getKey(),
531 AxStateTaskOutputType.DIRECT, aadmAct2Out.getKey()));
533 logicReader.setDefaultLogic("DefaultTaskSelectionLogic");
535 final AxState aadmDecideState = new AxState(new AxReferenceKey(aadmPolicy.getKey(), DECIDE));
536 aadmDecideState.setTrigger(aadmEvent.getKey());
537 final AxStateOutput aadmDec2Act = new AxStateOutput(aadmDecideState.getKey(), aadmActState.getKey(),
539 aadmDecideState.getStateOutputs().put(aadmDec2Act.getKey().getLocalName(), aadmDec2Act);
540 aadmDecideState.setTaskSelectionLogic(
541 new AxTaskSelectionLogic(aadmDecideState.getKey(), TASK_SELECTION_LOGIC, "MVEL", logicReader));
542 aadmDecideState.setDefaultTask(aadmDecideTask.getKey());
543 aadmDecideState.getTaskReferences().put(aadmDecideTask.getKey(),
544 new AxStateTaskReference(aadmDecideState.getKey(), aadmDecideTask.getKey(),
545 AxStateTaskOutputType.DIRECT, aadmDec2Act.getKey()));
547 final AxState aadmEstablishState = new AxState(new AxReferenceKey(aadmPolicy.getKey(), ESTABLISH));
548 aadmEstablishState.setTrigger(aadmEvent.getKey());
549 final AxStateOutput aadmEst2Dec = new AxStateOutput(aadmEstablishState.getKey(), aadmDecideState.getKey(),
551 aadmEstablishState.getStateOutputs().put(aadmEst2Dec.getKey().getLocalName(), aadmEst2Dec);
552 aadmEstablishState.setTaskSelectionLogic(new AxTaskSelectionLogic(aadmEstablishState.getKey(),
553 TASK_SELECTION_LOGIC, "MVEL", logicReader));
554 aadmEstablishState.setDefaultTask(aadmEstablishTask.getKey());
555 aadmEstablishState.getTaskReferences().put(aadmEstablishTask.getKey(),
556 new AxStateTaskReference(aadmEstablishState.getKey(), aadmEstablishTask.getKey(),
557 AxStateTaskOutputType.DIRECT, aadmEst2Dec.getKey()));
559 final AxState aadmMatchState = new AxState(new AxReferenceKey(aadmPolicy.getKey(), MATCH));
560 aadmMatchState.setTrigger(aadmEvent.getKey());
561 final AxStateOutput aadmMat2Est = new AxStateOutput(aadmMatchState.getKey(), aadmEstablishState.getKey(),
563 aadmMatchState.getStateOutputs().put(aadmMat2Est.getKey().getLocalName(), aadmMat2Est);
564 aadmMatchState.setTaskSelectionLogic(
565 new AxTaskSelectionLogic(aadmMatchState.getKey(), TASK_SELECTION_LOGIC, "MVEL", logicReader));
566 aadmMatchState.setDefaultTask(aadmMatchTask.getKey());
567 aadmMatchState.getTaskReferences().put(aadmMatchTask.getKey(), new AxStateTaskReference(aadmMatchState.getKey(),
568 aadmMatchTask.getKey(), AxStateTaskOutputType.DIRECT, aadmMat2Est.getKey()));
570 aadmPolicy.setFirstState(aadmMatchState.getKey().getLocalName());
571 aadmPolicy.getStateMap().put(aadmMatchState.getKey().getLocalName(), aadmMatchState);
572 aadmPolicy.getStateMap().put(aadmEstablishState.getKey().getLocalName(), aadmEstablishState);
573 aadmPolicy.getStateMap().put(aadmDecideState.getKey().getLocalName(), aadmDecideState);
574 aadmPolicy.getStateMap().put(aadmActState.getKey().getLocalName(), aadmActState);
576 final AxPolicy vMmePolicy = new AxPolicy(new AxArtifactKey("VMMEPolicy", DEFAULT_VERSION));
577 vMmePolicy.setTemplate("MEDA");
579 final AxState vMmeActState = new AxState(new AxReferenceKey(vMmePolicy.getKey(), "Act"));
580 vMmeActState.setTrigger(vMmeEvent.getKey());
581 final AxStateOutput vMmeAct2Out = new AxStateOutput(vMmeActState.getKey(), AxReferenceKey.getNullKey(),
583 vMmeActState.getStateOutputs().put(vMmeAct2Out.getKey().getLocalName(), vMmeAct2Out);
584 vMmeActState.setDefaultTask(vMmeActTask.getKey());
585 vMmeActState.getTaskReferences().put(vMmeActTask.getKey(), new AxStateTaskReference(vMmeActState.getKey(),
586 vMmeActTask.getKey(), AxStateTaskOutputType.DIRECT, vMmeAct2Out.getKey()));
587 vMmeActState.getTaskReferences().put(vMmeNoActTask.getKey(), new AxStateTaskReference(vMmeActState.getKey(),
588 vMmeNoActTask.getKey(), AxStateTaskOutputType.DIRECT, vMmeAct2Out.getKey()));
590 final AxState vMmeDecideState = new AxState(new AxReferenceKey(vMmePolicy.getKey(), DECIDE));
591 vMmeDecideState.setTrigger(vMmeEvent.getKey());
592 final AxStateOutput vMmeDec2Act = new AxStateOutput(vMmeDecideState.getKey(), vMmeActState.getKey(),
594 vMmeDecideState.getStateOutputs().put(vMmeDec2Act.getKey().getLocalName(), vMmeDec2Act);
595 vMmeDecideState.setDefaultTask(vMmeDecideTask.getKey());
596 vMmeDecideState.getTaskReferences().put(vMmeDecideTask.getKey(),
597 new AxStateTaskReference(vMmeDecideState.getKey(), vMmeDecideTask.getKey(),
598 AxStateTaskOutputType.DIRECT, vMmeDec2Act.getKey()));
600 final AxState vMmeEstablishState = new AxState(new AxReferenceKey(vMmePolicy.getKey(), ESTABLISH));
601 vMmeEstablishState.setTrigger(vMmeEvent.getKey());
602 final AxStateOutput vMmeEst2Dec = new AxStateOutput(vMmeEstablishState.getKey(), vMmeDecideState.getKey(),
604 vMmeEstablishState.getStateOutputs().put(vMmeEst2Dec.getKey().getLocalName(), vMmeEst2Dec);
605 vMmeEstablishState.setDefaultTask(vMmeEstablishTask.getKey());
606 vMmeEstablishState.getTaskReferences().put(vMmeEstablishTask.getKey(),
607 new AxStateTaskReference(vMmeEstablishState.getKey(), vMmeEstablishTask.getKey(),
608 AxStateTaskOutputType.DIRECT, vMmeEst2Dec.getKey()));
610 final AxState vMmeMatchState = new AxState(new AxReferenceKey(vMmePolicy.getKey(), MATCH));
611 vMmeMatchState.setTrigger(vMmeEvent.getKey());
612 final AxStateOutput vMmeMat2Est = new AxStateOutput(vMmeMatchState.getKey(), vMmeEstablishState.getKey(),
614 vMmeMatchState.getStateOutputs().put(vMmeMat2Est.getKey().getLocalName(), vMmeMat2Est);
615 vMmeMatchState.setDefaultTask(vMmeMatchTask.getKey());
616 vMmeMatchState.getTaskReferences().put(vMmeMatchTask.getKey(), new AxStateTaskReference(vMmeMatchState.getKey(),
617 vMmeMatchTask.getKey(), AxStateTaskOutputType.DIRECT, vMmeMat2Est.getKey()));
619 vMmePolicy.setFirstState(vMmeMatchState.getKey().getLocalName());
620 vMmePolicy.getStateMap().put(vMmeMatchState.getKey().getLocalName(), vMmeMatchState);
621 vMmePolicy.getStateMap().put(vMmeEstablishState.getKey().getLocalName(), vMmeEstablishState);
622 vMmePolicy.getStateMap().put(vMmeDecideState.getKey().getLocalName(), vMmeDecideState);
623 vMmePolicy.getStateMap().put(vMmeActState.getKey().getLocalName(), vMmeActState);
625 final AxPolicy sapcPolicy = new AxPolicy(new AxArtifactKey("SAPCPolicy", DEFAULT_VERSION));
626 sapcPolicy.setTemplate("MEDA");
628 final AxState sapcActState = new AxState(new AxReferenceKey(sapcPolicy.getKey(), "Act"));
629 sapcActState.setTrigger(sapcEvent.getKey());
630 final AxStateOutput sapcAct2Out = new AxStateOutput(sapcActState.getKey(), AxReferenceKey.getNullKey(),
631 sapcBlacklistSubscriberEvent.getKey());
632 sapcActState.getStateOutputs().put(sapcAct2Out.getKey().getLocalName(), sapcAct2Out);
633 sapcActState.setDefaultTask(sapcActTask.getKey());
634 sapcActState.getTaskReferences().put(sapcActTask.getKey(), new AxStateTaskReference(sapcActState.getKey(),
635 sapcActTask.getKey(), AxStateTaskOutputType.DIRECT, sapcAct2Out.getKey()));
637 final AxState sapcDecideState = new AxState(new AxReferenceKey(sapcPolicy.getKey(), DECIDE));
638 sapcDecideState.setTrigger(sapcEvent.getKey());
639 final AxStateOutput sapcDec2Act = new AxStateOutput(sapcDecideState.getKey(), sapcActState.getKey(),
641 sapcDecideState.getStateOutputs().put(sapcDec2Act.getKey().getLocalName(), sapcDec2Act);
642 sapcDecideState.setDefaultTask(sapcDecideTask.getKey());
643 sapcDecideState.getTaskReferences().put(sapcDecideTask.getKey(),
644 new AxStateTaskReference(sapcDecideState.getKey(), sapcDecideTask.getKey(),
645 AxStateTaskOutputType.DIRECT, sapcDec2Act.getKey()));
647 final AxState sapcEstablishState = new AxState(new AxReferenceKey(sapcPolicy.getKey(), ESTABLISH));
648 sapcEstablishState.setTrigger(sapcEvent.getKey());
649 final AxStateOutput sapcEst2Dec = new AxStateOutput(sapcEstablishState.getKey(), sapcDecideState.getKey(),
651 sapcEstablishState.getStateOutputs().put(sapcEst2Dec.getKey().getLocalName(), sapcEst2Dec);
652 sapcEstablishState.setDefaultTask(sapcEstablishTask.getKey());
653 sapcEstablishState.getTaskReferences().put(sapcEstablishTask.getKey(),
654 new AxStateTaskReference(sapcEstablishState.getKey(), sapcEstablishTask.getKey(),
655 AxStateTaskOutputType.DIRECT, sapcEst2Dec.getKey()));
657 final AxState sapcMatchState = new AxState(new AxReferenceKey(sapcPolicy.getKey(), MATCH));
658 sapcMatchState.setTrigger(aadmXStreamActEvent.getKey());
659 final AxStateOutput sapcMat2Est = new AxStateOutput(sapcMatchState.getKey(), sapcEstablishState.getKey(),
661 sapcMatchState.getStateOutputs().put(sapcMat2Est.getKey().getLocalName(), sapcMat2Est);
662 sapcMatchState.setDefaultTask(sapcMatchTask.getKey());
663 sapcMatchState.getTaskReferences().put(sapcMatchTask.getKey(), new AxStateTaskReference(sapcMatchState.getKey(),
664 sapcMatchTask.getKey(), AxStateTaskOutputType.DIRECT, sapcMat2Est.getKey()));
666 sapcPolicy.setFirstState(sapcMatchState.getKey().getLocalName());
667 sapcPolicy.getStateMap().put(sapcMatchState.getKey().getLocalName(), sapcMatchState);
668 sapcPolicy.getStateMap().put(sapcEstablishState.getKey().getLocalName(), sapcEstablishState);
669 sapcPolicy.getStateMap().put(sapcDecideState.getKey().getLocalName(), sapcDecideState);
670 sapcPolicy.getStateMap().put(sapcActState.getKey().getLocalName(), sapcActState);
672 final AxPolicy periodicPolicy = new AxPolicy(new AxArtifactKey("PeriodicPolicy", DEFAULT_VERSION));
673 periodicPolicy.setTemplate("MEDA");
675 final AxState periodicActState = new AxState(new AxReferenceKey(periodicPolicy.getKey(), "Act"));
676 periodicActState.setTrigger(periodicEvent.getKey());
677 final AxStateOutput perAct2Out = new AxStateOutput(periodicActState.getKey(), AxReferenceKey.getNullKey(),
678 sapcBlacklistSubscriberEvent.getKey());
679 periodicActState.getStateOutputs().put(perAct2Out.getKey().getLocalName(), perAct2Out);
680 periodicActState.setDefaultTask(periodicActTask.getKey());
681 periodicActState.getTaskReferences().put(periodicActTask.getKey(),
682 new AxStateTaskReference(periodicActState.getKey(), periodicActTask.getKey(),
683 AxStateTaskOutputType.DIRECT, perAct2Out.getKey()));
685 final AxState periodicDecideState = new AxState(new AxReferenceKey(periodicPolicy.getKey(), DECIDE));
686 periodicDecideState.setTrigger(periodicEvent.getKey());
687 final AxStateOutput perDec2Act = new AxStateOutput(periodicDecideState.getKey(), periodicActState.getKey(),
688 periodicEvent.getKey());
689 periodicDecideState.getStateOutputs().put(perDec2Act.getKey().getLocalName(), perDec2Act);
690 periodicDecideState.setDefaultTask(periodicDecideTask.getKey());
691 periodicDecideState.getTaskReferences().put(periodicDecideTask.getKey(),
692 new AxStateTaskReference(periodicDecideState.getKey(), periodicDecideTask.getKey(),
693 AxStateTaskOutputType.DIRECT, perDec2Act.getKey()));
695 final AxState periodicEstablishState = new AxState(new AxReferenceKey(periodicPolicy.getKey(), ESTABLISH));
696 periodicEstablishState.setTrigger(periodicEvent.getKey());
697 final AxStateOutput perEst2Dec = new AxStateOutput(periodicEstablishState.getKey(),
698 periodicDecideState.getKey(), periodicEvent.getKey());
699 periodicEstablishState.getStateOutputs().put(perEst2Dec.getKey().getLocalName(), perEst2Dec);
700 periodicEstablishState.setDefaultTask(periodicEstablishTask.getKey());
701 periodicEstablishState.getTaskReferences().put(periodicEstablishTask.getKey(),
702 new AxStateTaskReference(periodicEstablishState.getKey(), periodicEstablishTask.getKey(),
703 AxStateTaskOutputType.DIRECT, perEst2Dec.getKey()));
705 final AxState periodicMatchState = new AxState(new AxReferenceKey(periodicPolicy.getKey(), MATCH));
706 periodicMatchState.setTrigger(periodicEvent.getKey());
707 final AxStateOutput perMat2Est = new AxStateOutput(periodicMatchState.getKey(), periodicEstablishState.getKey(),
708 periodicEvent.getKey());
709 periodicMatchState.getStateOutputs().put(perMat2Est.getKey().getLocalName(), perMat2Est);
710 periodicMatchState.setDefaultTask(periodicMatchTask.getKey());
711 periodicMatchState.getTaskReferences().put(periodicMatchTask.getKey(),
712 new AxStateTaskReference(periodicMatchState.getKey(), periodicMatchTask.getKey(),
713 AxStateTaskOutputType.DIRECT, perMat2Est.getKey()));
715 periodicPolicy.setFirstState(periodicMatchState.getKey().getLocalName());
716 periodicPolicy.getStateMap().put(periodicMatchState.getKey().getLocalName(), periodicMatchState);
717 periodicPolicy.getStateMap().put(periodicEstablishState.getKey().getLocalName(), periodicEstablishState);
718 periodicPolicy.getStateMap().put(periodicDecideState.getKey().getLocalName(), periodicDecideState);
719 periodicPolicy.getStateMap().put(periodicActState.getKey().getLocalName(), periodicActState);
721 final AxPolicies aadmPolicies = new AxPolicies(new AxArtifactKey("AADMPolicies", DEFAULT_VERSION));
722 aadmPolicies.getPolicyMap().put(aadmPolicy.getKey(), aadmPolicy);
723 aadmPolicies.getPolicyMap().put(vMmePolicy.getKey(), vMmePolicy);
724 aadmPolicies.getPolicyMap().put(sapcPolicy.getKey(), sapcPolicy);
725 aadmPolicies.getPolicyMap().put(periodicPolicy.getKey(), periodicPolicy);
727 final AxKeyInformation keyInformation = new AxKeyInformation(
728 new AxArtifactKey("AADMKeyInformation", DEFAULT_VERSION));
729 final AxPolicyModel aadmPolicyModel = new AxPolicyModel(new AxArtifactKey("AADMPolicyModel", DEFAULT_VERSION));
730 aadmPolicyModel.setPolicies(aadmPolicies);
731 aadmPolicyModel.setEvents(aadmEvents);
732 aadmPolicyModel.setTasks(aadmTasks);
733 aadmPolicyModel.setAlbums(aadmAlbums);
734 aadmPolicyModel.setSchemas(aadmContextSchemas);
735 aadmPolicyModel.setKeyInformation(keyInformation);
736 aadmPolicyModel.getKeyInformation().generateKeyInfo(aadmPolicyModel);
738 final AxValidationResult result = aadmPolicyModel.validate(new AxValidationResult());
739 if (!result.getValidationResult().equals(AxValidationResult.ValidationResult.VALID)) {
740 throw new ApexRuntimeException("model " + aadmPolicyModel.getId() + " is not valid" + result);
742 return aadmPolicyModel;