2 * ============LICENSE_START==========================================
4 * ===================================================================
5 * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
6 * Modifications Copyright (C) 2019 IBM.
7 * ===================================================================
9 * Unless otherwise specified, all software contained herein is licensed
10 * under the Apache License, Version 2.0 (the "License");
11 * you may not use this software except in compliance with the License.
12 * You may obtain a copy of the License at
14 * http://www.apache.org/licenses/LICENSE-2.0
16 * Unless required by applicable law or agreed to in writing, software
17 * distributed under the License is distributed on an "AS IS" BASIS,
18 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19 * See the License for the specific language governing permissions and
20 * limitations under the License.
22 * Unless otherwise specified, all documentation contained herein is licensed
23 * under the Creative Commons License, Attribution 4.0 Intl. (the "License");
24 * you may not use this documentation except in compliance with the License.
25 * You may obtain a copy of the License at
27 * https://creativecommons.org/licenses/by/4.0/
29 * Unless required by applicable law or agreed to in writing, documentation
30 * distributed under the License is distributed on an "AS IS" BASIS,
31 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
32 * See the License for the specific language governing permissions and
33 * limitations under the License.
35 * ============LICENSE_END============================================
37 * ECOMP is a trademark and service mark of AT&T Intellectual Property.
39 package org.onap.portalapp.scheduler;
41 import java.util.ArrayList;
42 import java.util.Arrays;
43 import java.util.List;
45 import org.onap.portalsdk.core.scheduler.Registerable;
46 import org.onap.portalsdk.workflow.services.WorkflowScheduleService;
47 import org.quartz.Trigger;
48 import org.springframework.beans.factory.annotation.Autowired;
49 import org.springframework.scheduling.quartz.SchedulerFactoryBean;
50 import org.springframework.stereotype.Component;
53 public class RegistryAdapter {
56 private Registerable registry;
59 private WorkflowScheduleService workflowScheduleService;
61 private SchedulerFactoryBean schedulerBean;
63 Trigger [] trigger = new Trigger[1];
65 public Trigger[] getTriggers() {
66 registry.registerTriggers();
67 List<Trigger> allTriggers = new ArrayList<>();
68 List<Trigger> coreTriggers = addCoreTriggers();
69 final Trigger[] extTriggerArray = registry.getTriggers();
70 allTriggers.addAll(Arrays.asList(extTriggerArray));
71 allTriggers.addAll(coreTriggers);
72 return allTriggers.toArray(trigger);
75 public List<Trigger> addCoreTriggers() {
76 // On startup of the application after crash recovery, invoke workflow
78 return getWorkflowScheduleService().triggerWorkflowScheduling();
81 public void setSchedulerBean(final SchedulerFactoryBean schedulerBean) {
82 this.schedulerBean = schedulerBean;
85 public SchedulerFactoryBean getSchedulerBean() {
89 public Registerable getRegistry() {
93 public void setRegistry(Registerable registry) {
94 this.registry = registry;
97 public WorkflowScheduleService getWorkflowScheduleService() {
98 return workflowScheduleService;
101 public void setWorkflowScheduleService(WorkflowScheduleService workflowScheduleService) {
102 this.workflowScheduleService = workflowScheduleService;