diff options
Diffstat (limited to 'model/model-api')
4 files changed, 45 insertions, 28 deletions
diff --git a/model/model-api/src/main/java/org/onap/policy/apex/model/modelapi/ApexEditorApi.java b/model/model-api/src/main/java/org/onap/policy/apex/model/modelapi/ApexEditorApi.java index fab6ba163..8974d1fa8 100644 --- a/model/model-api/src/main/java/org/onap/policy/apex/model/modelapi/ApexEditorApi.java +++ b/model/model-api/src/main/java/org/onap/policy/apex/model/modelapi/ApexEditorApi.java @@ -1,7 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2016-2018 Ericsson. All rights reserved. - * Modifications Copyright (C) 2021 Bell Canada. All rights reserved. + * Modifications Copyright (C) 2021-2022 Bell Canada. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -205,10 +205,11 @@ public interface ApexEditorApi { * @param target of the event, set to null to use the default value * @param uuid event UUID, set to null to generate a UUID * @param description event description, set to null to generate a description + * @param toscaPolicyState specifies TOSCA policy processing status * @return result of the operation */ ApexApiResult createEvent(final String name, final String version, final String nameSpace, final String source, - final String target, final String uuid, final String description); + final String target, final String uuid, final String description, final String toscaPolicyState); /** * Update an event. @@ -220,10 +221,11 @@ public interface ApexEditorApi { * @param target of the event, set to null to not update * @param uuid event UUID, set to null to not update * @param description event description, set to null to not update + * @param toscaPolicyState specifies TOSCA policy processing status * @return result of the operation */ ApexApiResult updateEvent(final String name, final String version, final String nameSpace, final String source, - final String target, final String uuid, final String description); + final String target, final String uuid, final String description, final String toscaPolicyState); /** * List events. @@ -900,4 +902,4 @@ public interface ApexEditorApi { */ ApexApiResult deletePolicyStateContextRef(final String name, final String version, final String stateName, final String contextAlbumName, final String contextAlbumVersion); -} +}
\ No newline at end of file diff --git a/model/model-api/src/main/java/org/onap/policy/apex/model/modelapi/impl/ApexModelImpl.java b/model/model-api/src/main/java/org/onap/policy/apex/model/modelapi/impl/ApexModelImpl.java index 05976c6ed..cca9d3454 100644 --- a/model/model-api/src/main/java/org/onap/policy/apex/model/modelapi/impl/ApexModelImpl.java +++ b/model/model-api/src/main/java/org/onap/policy/apex/model/modelapi/impl/ApexModelImpl.java @@ -3,7 +3,7 @@ * Copyright (C) 2016-2018 Ericsson. All rights reserved. * Modifications Copyright (C) 2019 Samsung Electronics Co., Ltd. * Modifications Copyright (C) 2019 Nordix Foundation. - * Modifications Copyright (C) 2021 Bell Canada. All rights reserved. + * Modifications Copyright (C) 2022 Bell Canada. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -251,8 +251,9 @@ public final class ApexModelImpl implements ApexModel { */ @Override public ApexApiResult createEvent(final String name, final String version, final String nameSpace, - final String source, final String target, final String uuid, final String description) { - return eventFacade.createEvent(name, version, nameSpace, source, target, uuid, description); + final String source, final String target, final String uuid, final String description, + final String toscaPolicyState) { + return eventFacade.createEvent(name, version, nameSpace, source, target, uuid, description, toscaPolicyState); } /** @@ -260,8 +261,9 @@ public final class ApexModelImpl implements ApexModel { */ @Override public ApexApiResult updateEvent(final String name, final String version, final String nameSpace, - final String source, final String target, final String uuid, final String description) { - return eventFacade.updateEvent(name, version, nameSpace, source, target, uuid, description); + final String source, final String target, final String uuid, final String description, + final String toscaPolicyState) { + return eventFacade.updateEvent(name, version, nameSpace, source, target, uuid, description, toscaPolicyState); } /** @@ -892,4 +894,4 @@ public final class ApexModelImpl implements ApexModel { return policyModel; } -} +}
\ No newline at end of file diff --git a/model/model-api/src/main/java/org/onap/policy/apex/model/modelapi/impl/EventFacade.java b/model/model-api/src/main/java/org/onap/policy/apex/model/modelapi/impl/EventFacade.java index 0a758407b..f1f939397 100644 --- a/model/model-api/src/main/java/org/onap/policy/apex/model/modelapi/impl/EventFacade.java +++ b/model/model-api/src/main/java/org/onap/policy/apex/model/modelapi/impl/EventFacade.java @@ -2,6 +2,7 @@ * ============LICENSE_START======================================================= * Copyright (C) 2016-2018 Ericsson. All rights reserved. * Modifications Copyright (C) 2019 Nordix Foundation. + * Modifications Copyright (C) 2022 Bell Canada. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -85,10 +86,12 @@ public class EventFacade { * @param target of the event, set to null to use the default value * @param uuid event UUID, set to null to generate a UUID * @param description event description, set to null to generate a description + * @param toscaPolicyState specifies TOSCA policy processing status * @return result of the operation */ public ApexApiResult createEvent(final String name, final String version, final String nameSpace, - final String source, final String target, final String uuid, final String description) { + final String source, final String target, final String uuid, final String description, + final String toscaPolicyState) { try { final AxArtifactKey key = new AxArtifactKey(); key.setName(name); @@ -107,6 +110,9 @@ public class EventFacade { event.setNameSpace((nameSpace != null ? nameSpace : apexProperties.getProperty("DEFAULT_EVENT_NAMESPACE"))); event.setSource((source != null ? source : apexProperties.getProperty("DEFAULT_EVENT_SOURCE"))); event.setTarget((target != null ? target : apexProperties.getProperty("DEFAULT_EVENT_TARGET"))); + if (toscaPolicyState != null) { + event.setToscaPolicyState(toscaPolicyState); + } apexModel.getPolicyModel().getEvents().getEventMap().put(key, event); @@ -130,10 +136,12 @@ public class EventFacade { * @param target of the event, set to null to not update * @param uuid event UUID, set to null to not update * @param description event description, set to null to not update + * @param toscaPolicyState specifies TOSCA policy processing status * @return result of the operation */ public ApexApiResult updateEvent(final String name, final String version, final String nameSpace, - final String source, final String target, final String uuid, final String description) { + final String source, final String target, final String uuid, final String description, + final String toscaPolicyState) { try { final AxEvent event = apexModel.getPolicyModel().getEvents().get(name, version); if (event == null) { @@ -150,6 +158,9 @@ public class EventFacade { if (target != null) { event.setTarget(target); } + if (toscaPolicyState != null) { + event.setToscaPolicyState(toscaPolicyState); + } return keyInformationFacade.updateKeyInformation(name, version, uuid, description); } catch (final Exception e) { @@ -382,4 +393,4 @@ public class EventFacade { return new ApexApiResult(ApexApiResult.Result.FAILED, e); } } -} +}
\ No newline at end of file diff --git a/model/model-api/src/test/java/org/onap/policy/apex/model/modelapi/ApexEditorApiEventTest.java b/model/model-api/src/test/java/org/onap/policy/apex/model/modelapi/ApexEditorApiEventTest.java index bc46ee3d3..775fcc1d3 100644 --- a/model/model-api/src/test/java/org/onap/policy/apex/model/modelapi/ApexEditorApiEventTest.java +++ b/model/model-api/src/test/java/org/onap/policy/apex/model/modelapi/ApexEditorApiEventTest.java @@ -2,6 +2,7 @@ * ============LICENSE_START======================================================= * Copyright (C) 2016-2018 Ericsson. All rights reserved. * Modifications Copyright (C) 2020 Nordix Foundation. + * Modifications Copyright (C) 2022 Bell Canada. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -44,29 +45,29 @@ public class ApexEditorApiEventTest { assertEquals(ApexApiResult.Result.SUCCESS, result.getResult()); result = apexModel.createEvent("MyEvent002", "0.0.2", "My Namespace", "My Source", "my target", - "1fa2e430-f2b2-11e6-bc64-92361f002700", "A description of 002"); + "1fa2e430-f2b2-11e6-bc64-92361f002700", "A description of 002", null); assertEquals(ApexApiResult.Result.SUCCESS, result.getResult()); result = apexModel.createEvent("MyEvent012", "0.1.2", "My Namespace", "My Source", "my target", - "1fa2e430-f2b2-11e6-bc64-92361f002700", "A description of 012"); + "1fa2e430-f2b2-11e6-bc64-92361f002700", "A description of 012", null); assertEquals(ApexApiResult.Result.SUCCESS, result.getResult()); result = apexModel.createEvent("MyEvent012", "0.1.4", "My Namespace", "My Source", "my target", - "1fa2e430-f2b2-11e6-bc64-92361f002700", "A description of 014"); + "1fa2e430-f2b2-11e6-bc64-92361f002700", "A description of 014", null); assertEquals(ApexApiResult.Result.SUCCESS, result.getResult()); - result = apexModel.createEvent("MyEvent012", null, null, null, null, null, null); + result = apexModel.createEvent("MyEvent012", null, null, null, null, null, null, null); assertEquals(ApexApiResult.Result.SUCCESS, result.getResult()); - result = apexModel.createEvent("MyEvent012", null, null, null, null, null, null); + result = apexModel.createEvent("MyEvent012", null, null, null, null, null, null, null); assertEquals(ApexApiResult.Result.CONCEPT_EXISTS, result.getResult()); result = apexModel.createEvent("MyEvent002", "0.0.2", "My Namespace", "My Source", "my target", - "1fa2e430-f2b2-11e6-bc64-92361f002700", "A description of 002"); + "1fa2e430-f2b2-11e6-bc64-92361f002700", "A description of 002", null); assertEquals(ApexApiResult.Result.CONCEPT_EXISTS, result.getResult()); result = apexModel.createEvent("@£$%^", "0.2.5", "My Namespace", "My Source", "my target", - "1fa2e430-f2b2-11e6-bc64-92361f002700", "A description of 002"); + "1fa2e430-f2b2-11e6-bc64-92361f002700", "A description of 002", null); assertEquals(ApexApiResult.Result.FAILED, result.getResult()); result = apexModel.deleteEvent("MyEvent012", "0.1.4"); assertEquals(ApexApiResult.Result.SUCCESS, result.getResult()); result = apexModel.createEvent("MyEvent012", "0.1.4", "My Namespace", "My Source", "my target", - "1fa2e430-f2b2-11e6-bc64-92361f002700", "A description of 014"); + "1fa2e430-f2b2-11e6-bc64-92361f002700", "A description of 014", null); assertEquals(ApexApiResult.Result.SUCCESS, result.getResult()); result = apexModel.validateEvent(null, null); @@ -74,18 +75,19 @@ public class ApexEditorApiEventTest { result = apexModel.updateContextSchema(null, null, null, null, null, null); assertEquals(ApexApiResult.Result.FAILED, result.getResult()); - result = apexModel.updateEvent("MyEvent012", "0.1.2", "Another Namespace", null, "Another target", null, null); + result = apexModel.updateEvent("MyEvent012", "0.1.2", "Another Namespace", null, "Another target", null, null, + null); assertEquals(ApexApiResult.Result.SUCCESS, result.getResult()); result = apexModel.updateEvent("MyEvent002", "0.0.2", "My Namespace", "My Source", "my target", - "1fa2e430-f2b2-11e6-bc64-92361f002700", "A description of 002"); + "1fa2e430-f2b2-11e6-bc64-92361f002700", "A description of 002", null); assertEquals(ApexApiResult.Result.SUCCESS, result.getResult()); - result = apexModel.updateEvent("MyEvent012", null, null, null, null, null, null); + result = apexModel.updateEvent("MyEvent012", null, null, null, null, null, null, null); assertEquals(ApexApiResult.Result.SUCCESS, result.getResult()); - result = apexModel.updateEvent("MyEvent015", null, null, null, null, null, null); + result = apexModel.updateEvent("MyEvent015", null, null, null, null, null, null, null); assertEquals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST, result.getResult()); - result = apexModel.updateEvent("MyEvent014", "0.1.5", null, null, null, null, null); + result = apexModel.updateEvent("MyEvent014", "0.1.5", null, null, null, null, null, null); assertEquals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST, result.getResult()); - result = apexModel.updateEvent("@£$%^^", "0.6.9", null, null, null, null, null); + result = apexModel.updateEvent("@£$%^^", "0.6.9", null, null, null, null, null, null); assertEquals(ApexApiResult.Result.FAILED, result.getResult()); result = apexModel.listEvent("@£$%", null); @@ -194,4 +196,4 @@ public class ApexEditorApiEventTest { assertEquals(ApexApiResult.Result.SUCCESS, result.getResult()); assertEquals(0, result.getMessages().size()); } -} +}
\ No newline at end of file |