BrightSide Workbench Full Report + Source Code
UserActivityContent.java
Go to the documentation of this file.
1 /*
2  * TurrĂ³ i Cutiller Foundation. License notice.
3  * Copyright (C) 2021 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.user.activity;
20 
21 import org.turro.action.Contacts;
22 import org.turro.collections.KeyValueMap;
23 import org.turro.elephant.context.IConstructor;
24 import org.turro.elephant.direct.AbstractDirectContentCtrl;
25 import org.turro.elephant.direct.DirectContent;
26 import org.turro.marker.ElephantMarker;
27 import org.turro.plugin.contacts.IContact;
28 
33 @DirectContent(identifier="user-activity")
35 
37  super("widgets/activity");
38  }
39 
40  public String createURL(IContact contact, ActivityType... types) {
41  return createRightNowURL("contact=" + contact.getId());
42  }
43 
44  @Override
45  public String getIdentifier() {
46  return UserActivityContent.class.getAnnotation(DirectContent.class).identifier();
47  }
48 
49  @Override
50  protected void prepareMarker(ElephantMarker marker) {
51  // do nothing
52  }
53 
54  @Override
55  protected void prepareCleanMarker(ElephantMarker marker, KeyValueMap map) {
56  marker.putAll(map);
57  if(map.containsKey("contact")) {
58  marker.put("activities", UserActivities.getActivity(Contacts.getContactById(map.get("contact"))));
59  }
60  }
61 
62  @Override
63  protected void doExecute(IConstructor constructor, KeyValueMap map) {
64  if(map.containsKey("contact")) {
65  writeMarkerToResponse(constructor, map);
66  }
67  }
68 
69 }
static IContact getContactById(String id)
Definition: Contacts.java:72
Object put(Object key, Object value)
static Set< Activity > getActivity(IContact contact)
void prepareCleanMarker(ElephantMarker marker, KeyValueMap map)
String createURL(IContact contact, ActivityType... types)
void doExecute(IConstructor constructor, KeyValueMap map)