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