BrightSide Workbench Full Report + Source Code
Events.java
Go to the documentation of this file.
1 /*
2  * TurrĂ³ i Cutiller Foundation. License notice.
3  * Copyright (C) 2015 Lluis TurrĂ³ Cutiller <http://www.turro.org/>
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU Affero General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU Affero General Public License for more details.
14  *
15  * You should have received a copy of the GNU Affero General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  */
18 
19 package org.turro.action;
20 
21 import java.util.ArrayList;
22 import java.util.Collection;
23 import java.util.Collections;
24 import java.util.Date;
25 import java.util.HashMap;
26 import org.turro.annotation.ExternalEvent;
27 import org.turro.elephant.context.Application;
28 import org.turro.plugin.calendar.ICalendarEvent;
29 import org.turro.plugin.calendar.ICalendarInfo;
30 import org.turro.reflection.Instances;
31 
36 public class Events {
37 
38  /* External Events */
39 
40  public static Collection<ICalendarEvent> getPublicEvents(Date start, Date end, HashMap<String, String> args) {
41  ArrayList<ICalendarEvent> events = new ArrayList<>();
42  if("self".equals(args.get("target")) && !Application.getApplication().isInRole("user:in")) {
43  return Collections.EMPTY_LIST;
44  }
45  Instances.cached().byAnnotation(ExternalEvent.class, ICalendarInfo.class).forEach((iCalendar) -> {
46  events.addAll(iCalendar.execute(start, end, args));
47  });
48  return events;
49  }
50 
51  private Events() {
52  }
53 
54 }
static Collection< ICalendarEvent > getPublicEvents(Date start, Date end, HashMap< String, String > args)
Definition: Events.java:40