return this expression instead of assigning it to the temporary variable
[vid.git] / epsdk-app-onap / src / main / java / org / onap / portalapp / scheduler / RegistryAdapter.java
1 /*
2  * ============LICENSE_START==========================================
3  * ONAP Portal SDK
4  * ===================================================================
5  * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
6  * Modifications Copyright (C) 2019 IBM.
7  * ===================================================================
8  *
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
13  *
14  *             http://www.apache.org/licenses/LICENSE-2.0
15  *
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.
21  *
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
26  *
27  *             https://creativecommons.org/licenses/by/4.0/
28  *
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.
34  *
35  * ============LICENSE_END============================================
36  *
37  * ECOMP is a trademark and service mark of AT&T Intellectual Property.
38  */
39 package org.onap.portalapp.scheduler;
40
41 import java.util.ArrayList;
42 import java.util.Arrays;
43 import java.util.List;
44
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;
51
52 @Component
53 public class RegistryAdapter {
54
55         @Autowired
56         private Registerable registry;
57
58         @Autowired
59         private WorkflowScheduleService workflowScheduleService;
60
61         private SchedulerFactoryBean schedulerBean;
62
63         Trigger [] trigger = new Trigger[1];
64
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);
73         }
74
75         public List<Trigger> addCoreTriggers() {
76                 // On startup of the application after crash recovery, invoke workflow
77                 // schedule trigger
78                 return getWorkflowScheduleService().triggerWorkflowScheduling();
79         }
80
81         public void setSchedulerBean(final SchedulerFactoryBean schedulerBean) {
82                 this.schedulerBean = schedulerBean;
83         }
84
85         public SchedulerFactoryBean getSchedulerBean() {
86                 return schedulerBean;
87         }
88
89         public Registerable getRegistry() {
90                 return registry;
91         }
92
93         public void setRegistry(Registerable registry) {
94                 this.registry = registry;
95         }
96
97         public WorkflowScheduleService getWorkflowScheduleService() {
98                 return workflowScheduleService;
99         }
100
101         public void setWorkflowScheduleService(WorkflowScheduleService workflowScheduleService) {
102                 this.workflowScheduleService = workflowScheduleService;
103         }
104
105 }