/root> #-------------------------------------------------------------------------------
/root> # ============LICENSE_START=======================================================
/root> #  Copyright (C) 2016-2018 Ericsson. All rights reserved.
/root> # ================================================================================
/root> # Licensed under the Apache License, Version 2.0 (the "License");
/root> # you may not use this file except in compliance with the License.
/root> # You may obtain a copy of the License at
/root> # 
/root> #      http://www.apache.org/licenses/LICENSE-2.0
/root> # 
/root> # Unless required by applicable law or agreed to in writing, software
/root> # distributed under the License is distributed on an "AS IS" BASIS,
/root> # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
/root> # See the License for the specific language governing permissions and
/root> # limitations under the License.
/root> # 
/root> # SPDX-License-Identifier: Apache-2.0
/root> # ============LICENSE_END=========================================================
/root> #-------------------------------------------------------------------------------
/root> 
/root> model create name=PeriodicPolicyModel
result: SUCCESS

/root> 
/root> schema create name=SimpleLongType   flavour=Java schema=java.lang.Long
result: SUCCESS

/root> schema create name=SimpleStringType flavour=Java schema=java.lang.String
result: SUCCESS

/root> schema create name=EventListType  flavour=Java schema=org.onap.policy.apex.service.engine.event.ApexEventList
result: SUCCESS

/root> 
/root> event create name=PERIODIC_EVENT nameSpace=org.onap.policy.apex.periodic source=APEX target=APEX
result: SUCCESS

/root> event parameter create name=PERIODIC_EVENT parName=PERIODIC_DELAY        schemaName=SimpleLongType
result: SUCCESS

/root> event parameter create name=PERIODIC_EVENT parName=PERIODIC_FIRST_TIME   schemaName=SimpleLongType
result: SUCCESS

/root> event parameter create name=PERIODIC_EVENT parName=PERIODIC_LAST_TIME    schemaName=SimpleLongType
result: SUCCESS

/root> event parameter create name=PERIODIC_EVENT parName=PERIODIC_CURRENT_TIME schemaName=SimpleLongType
result: SUCCESS

/root> event parameter create name=PERIODIC_EVENT parName=PERIODIC_EVENT_COUNT  schemaName=SimpleLongType
result: SUCCESS

/root> 
/root> event create name=EventListEvent nameSpace=org.onap.policy.apex.periodic source=APEX target=APEX
result: SUCCESS

/root> event parameter create name=EventListEvent parName=EventList schemaName=EventListType
result: SUCCESS

/root> 
/root> event create name=InputEvent nameSpace=org.onap.policy.apex.periodic source=APEX target=APEX
result: SUCCESS

/root> event parameter create name=InputEvent parName=Par0 schemaName=SimpleStringType
result: SUCCESS

/root> event parameter create name=InputEvent parName=Par1 schemaName=SimpleStringType
result: SUCCESS

/root> 
/root> event create name=OutputEvent nameSpace=org.onap.policy.apex.periodic source=APEX target=APEX
result: SUCCESS

/root> event parameter create name=OutputEvent parName=Par0 schemaName=SimpleStringType
result: SUCCESS

/root> event parameter create name=OutputEvent parName=Par1 schemaName=SimpleStringType
result: SUCCESS

/root> 
/root> task create name=PeriodicTask
result: SUCCESS

/root> task inputfield create name=PeriodicTask fieldName=PERIODIC_DELAY        schemaName=SimpleLongType
result: SUCCESS
inputFields and outputFields are deprecated from Task definition and will be removed. Instead, inputEvent and outputEvents are automatically populated to Tasks based on State definition

/root> task inputfield create name=PeriodicTask fieldName=PERIODIC_FIRST_TIME   schemaName=SimpleLongType
result: SUCCESS
inputFields and outputFields are deprecated from Task definition and will be removed. Instead, inputEvent and outputEvents are automatically populated to Tasks based on State definition

/root> task inputfield create name=PeriodicTask fieldName=PERIODIC_LAST_TIME    schemaName=SimpleLongType
result: SUCCESS
inputFields and outputFields are deprecated from Task definition and will be removed. Instead, inputEvent and outputEvents are automatically populated to Tasks based on State definition

/root> task inputfield create name=PeriodicTask fieldName=PERIODIC_CURRENT_TIME schemaName=SimpleLongType
result: SUCCESS
inputFields and outputFields are deprecated from Task definition and will be removed. Instead, inputEvent and outputEvents are automatically populated to Tasks based on State definition

/root> task inputfield create name=PeriodicTask fieldName=PERIODIC_EVENT_COUNT  schemaName=SimpleLongType
result: SUCCESS
inputFields and outputFields are deprecated from Task definition and will be removed. Instead, inputEvent and outputEvents are automatically populated to Tasks based on State definition

/root> 
/root> task outputfield create name=PeriodicTask fieldName=EventList schemaName=EventListType
result: SUCCESS
inputFields and outputFields are deprecated from Task definition and will be removed. Instead, inputEvent and outputEvents are automatically populated to Tasks based on State definition

/root> 
/root> task logic create name=PeriodicTask logicFlavour=JAVASCRIPT logic=LS
/*
 * ============LICENSE_START=======================================================
 *  Copyright (C) 2016-2018 Ericsson. All rights reserved.
 *  Modifications Copyright (C) 2020 Nordix Foundation.
 * ================================================================================
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 * SPDX-License-Identifier: Apache-2.0
 * ============LICENSE_END=========================================================
 */

executor.logger.info(executor.subject.id);
executor.logger.info(executor.inFields);

var eventList = executor.subject.getOutFieldSchemaHelper("EventList").createNewInstance();

var eventType = org.onap.policy.apex.service.engine.event.ApexEvent;

for (i = 0; i < 5; i++) {
    var event = new eventType("InputEvent", "0.0.1", "org.onap.policy.apex.periodic", "APEX", "APEX");

    var par0 = "Hello: " + i;
    var par1 = "Goodbye: " + i;

    event.put("Par0", par0);
    event.put("Par1", par1);

    eventList.add(event);
}

executor.outFields.put("EventList", eventList);

executor.logger.info(executor.outFields);

true;
LE
result: SUCCESS

/root> 
/root> task create name=OutputTask
result: SUCCESS

/root> task inputfield create name=OutputTask fieldName=Par0 schemaName=SimpleStringType
result: SUCCESS
inputFields and outputFields are deprecated from Task definition and will be removed. Instead, inputEvent and outputEvents are automatically populated to Tasks based on State definition

/root> task inputfield create name=OutputTask fieldName=Par1 schemaName=SimpleStringType
result: SUCCESS
inputFields and outputFields are deprecated from Task definition and will be removed. Instead, inputEvent and outputEvents are automatically populated to Tasks based on State definition

/root> 
/root> task outputfield create name=OutputTask fieldName=Par0 schemaName=SimpleStringType
result: SUCCESS
inputFields and outputFields are deprecated from Task definition and will be removed. Instead, inputEvent and outputEvents are automatically populated to Tasks based on State definition

/root> task outputfield create name=OutputTask fieldName=Par1 schemaName=SimpleStringType
result: SUCCESS
inputFields and outputFields are deprecated from Task definition and will be removed. Instead, inputEvent and outputEvents are automatically populated to Tasks based on State definition

/root> 
/root> task logic create name=OutputTask logicFlavour=JAVASCRIPT logic=LS
/*
 * ============LICENSE_START=======================================================
 *  Copyright (C) 2016-2018 Ericsson. All rights reserved.
 *  Modifications Copyright (C) 2020 Nordix Foundation.
 * ================================================================================
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 * SPDX-License-Identifier: Apache-2.0
 * ============LICENSE_END=========================================================
 */

executor.logger.info(executor.subject.id);
executor.logger.info(executor.inFields);

executor.logger.info(executor.outFields);

true;
LE
result: SUCCESS

/root> 
/root> policy create name=PeriodicPolicy template=freestyle firstState=PeriodicState
result: SUCCESS

/root> 
/root> policy state create name=PeriodicPolicy stateName=PeriodicState triggerName=PERIODIC_EVENT defaultTaskName=PeriodicTask
result: SUCCESS

/root> policy state output create name=PeriodicPolicy stateName=PeriodicState outputName=PeriodicOutput eventName=EventListEvent
result: SUCCESS

/root> policy state taskref create name=PeriodicPolicy stateName=PeriodicState taskName=PeriodicTask outputType=DIRECT outputName=PeriodicOutput
result: SUCCESS

/root> 
/root> 
/root> policy create name=OutputPolicy template=freestyle firstState=OutputState
result: SUCCESS

/root> 
/root> policy state create name=OutputPolicy stateName=OutputState triggerName=InputEvent defaultTaskName=OutputTask
result: SUCCESS

/root> policy state output create name=OutputPolicy stateName=OutputState outputName=OutputOutput eventName=OutputEvent
result: SUCCESS

/root> policy state taskref create name=OutputPolicy stateName=OutputState taskName=OutputTask outputType=DIRECT outputName=OutputOutput
result: SUCCESS

/root> 
/root> validate
result: SUCCESS
{
  "name": "PeriodicPolicyModel",
  "version": "0.0.1"
}

***observations noted during validation of model***
AxArtifactKey:(name=PeriodicPolicyModel_Albums,version=0.0.1):org.onap.policy.apex.model.contextmodel.concepts.AxContextAlbums:OBSERVATION:albums are empty
********************************

/root> 
/root> 