BrightSide Workbench Full Report + Source Code
elephant-plugins/src/main/java/org/turro/plugin/command/SummaryPlugin.java
Go to the documentation of this file.
1 /*
2  * TurrĂ³ i Cutiller Foundation. License notice.
3  * Copyright (C) 2012 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.plugin.command;
20 
21 import java.util.ArrayList;
22 import java.util.Collection;
23 import org.turro.command.Command;
24 import org.turro.command.Context;
25 import org.turro.elephant.context.Application;
26 import org.turro.plugin.contacts.IContact;
27 
32 public abstract class SummaryPlugin implements IPlugin, Command {
33 
34  protected String name;
35  protected IContact contact;
36  protected Collection<Object> result;
37 
38  public SummaryPlugin(String name) {
39  this.name = name;
40  }
41 
42  @Override
43  public String getName() {
44  return name;
45  }
46 
47  @Override
48  public boolean stopsPropagating() {
49  return false;
50  }
51 
52  @Override
53  public void setParams(Object params) {
54  if(params instanceof IContact) {
56  }
57  }
58 
59  @Override
60  public Object execute(Context context) {
61 // if(getName().equals(context.get(CommandFactory.COMMAND_PARS))) {
62 // setParams(context.get(CommandFactory.DATA));
63 // result = (Collection<Object>) context.get(CommandFactory.RESULT);
64 // executePlugin(context);
65 // context.put(CommandFactory.RESULT, result);
66 // if(stopsPropagating()) {
67 // return PROCESSING_COMPLETE;
68 // }
69 // }
70 // return CONTINUE_PROCESSING;
71  return null;
72  };
73 
74  protected void addToResult(Object data) {
75  if(result == null) {
76  result = new ArrayList<Object>();
77  }
78  result.add(data);
79  }
80 
81  protected abstract void executePlugin(Context context) throws Exception;
82 
83  public static Collection<Object> getSummaryFor(Application app, IContact contact, String name) {
84  return null; //(Collection<Object>) CommandFactory.executePlugins(app, contact, name);
85  }
86 
87 }
88 
Map< String, Object > params
abstract void executePlugin(Context context)
static Collection< Object > getSummaryFor(Application app, IContact contact, String name)