BrightSide Workbench Full Report + Source Code
org.turro.alliance.content.control.ProjectCtrl Class Reference
Inheritance diagram for org.turro.alliance.content.control.ProjectCtrl:
Collaboration diagram for org.turro.alliance.content.control.ProjectCtrl:

Public Member Functions

 ProjectCtrl ()
 
void setServer (WsServer server)
 
void setAction (ProjectAction action)
 
void setAxId (String axId)
 
void setParticiationLabel (String particiationLabel)
 
boolean toggleBanned (KeyValueMap map)
 
boolean askParticipate (KeyValueMap map)
 
- Public Member Functions inherited from org.turro.elephant.direct.AbstractDirectContentCtrl
 AbstractDirectContentCtrl (String tmplRoot)
 
String createFormAction ()
 
String createPOST (String values)
 
String getAjaxSubmitUrl (String containerId)
 
String getAjaxUrl (String containerId, String values)
 
String getAjaxUrl (String containerId, KeyValueMap values)
 
String getAjaxEvalUrl (KeyValueMap values)
 
String createRightNowURL (String values)
 
String createRightNowURL (KeyValueMap values)
 
String createLinkTo (String link, KeyValueMap values)
 
String createURL ()
 
String createURL (IConstructor constructor, String values)
 
String createURL (IConstructor constructor, String values, int daysValid)
 
String createURL (IConstructor constructor, String values, int daysValid, boolean withDomain)
 
String createURL (IConstructor constructor, IContact recipe, String values, int daysValid, boolean withDomain)
 
String createURL (IConstructor constructor, IContact recipe, KeyValueMap values, int daysValid, boolean withDomain)
 
void setTemplate (String template)
 
void render (IConstructor constructor)
 
String parse (IConstructor constructor)
 
boolean itsMe (String id)
 
boolean myTurn (HttpServletRequest request)
 
void execute (ServletContext context, HttpServletRequest request, HttpServletResponse response)
 
void execute (IConstructor constructor)
 

Protected Member Functions

void prepareCleanMarker (ElephantMarker marker, KeyValueMap map)
 
void prepareMarker (ElephantMarker marker)
 
String getIdentifier ()
 
void doExecute (IConstructor constructor, KeyValueMap map)
 
- Protected Member Functions inherited from org.turro.elephant.direct.AbstractDirectContentCtrl
String getRedirContext (IConstructor constructor, boolean withDomain)
 
ElephantMarker getMarker (IConstructor constructor)
 
ElephantMarker getCleanMarkerFrom (IConstructor constructor)
 
void addContainerId (ElephantMarker marker, boolean container)
 
String getTmplRoot ()
 
String getTemplate ()
 
void writeMarkerToResponse (IConstructor constructor, KeyValueMap map)
 
void writeMarkerToResponse (IConstructor constructor, KeyValueMap map, Map extra)
 
void setNeedsUser (boolean needsUser)
 

Additional Inherited Members

- Protected Attributes inherited from org.turro.elephant.direct.AbstractDirectContentCtrl
String template = "full"
 

Detailed Description

Author
Lluis TurrĂ³ Cutiller lluis.nosp@m.@tur.nosp@m.ro.or.nosp@m.g

Definition at line 50 of file ProjectCtrl.java.

Constructor & Destructor Documentation

◆ ProjectCtrl()

org.turro.alliance.content.control.ProjectCtrl.ProjectCtrl ( )

Definition at line 56 of file ProjectCtrl.java.

56  {
57  super("widgets/alliance/project");
58  setNeedsUser(true);
59  }

Member Function Documentation

◆ askParticipate()

boolean org.turro.alliance.content.control.ProjectCtrl.askParticipate ( KeyValueMap  map)

Definition at line 168 of file ProjectCtrl.java.

168  {
169  IContact contact = Contacts.getContactById(map.get("contactId"));
170  if(Contacts.isValid(contact)) {
171  IContact business = contact.getBusiness();
172  if(Contacts.isValid(business)) {
173  WsServer server = Servers.getServer(WsServerPK.from(map.get("serverDomain"), map.get("service")));
174  Jsons response = Servers.getData(server, AxConstants.AXPARTICIPATION_ASK, Jsons.object()
175  .add("as", map.get("as"))
176  .add("axId", map.get("axId"))
177  .add("contactId", contact.getId())
178  .add("contactName", contact.getName())
179  .add("contactFace", contact.getFaces().getUrl())
180  .add("companyId", business.getId())
181  .add("companyName", business.getName())
182  .add("companyFace", business.getFaces().getUrl())
183  );
184  if(!Jsons.isEmpty(response) && response.getBoolean("requested")) {
185  P2Ps.getP2PData(server.getServerDomain(), CompoundId.from(map.get("axId")).getMemberId(),
186  P2PServer.P2P_SERVICE, WsConstants.SEND_EMAIL, Jsons.object(Jsons.read(
187  JsonMailStructure.subject(I_.format("Alliance request from %s", server.getName()))
188  .message(I_.format("%s has requested to participate as %s in a project", contact.getName(), map.get("as")))
189  .administrators()
190  .toJson())));
191  MailSenders.getPool()
192  .addAdministrators()
193  .send(I_.format("Alliance request to %s", server.getName()),
194  I_.format("%s has requested to participate as %s in an outside project", contact.getName(), map.get("as")));
195  return true;
196  }
197  }
198  }
199  return false;
200  }
Here is the call graph for this function:

◆ doExecute()

void org.turro.alliance.content.control.ProjectCtrl.doExecute ( IConstructor  constructor,
KeyValueMap  map 
)
protected

Reimplemented from org.turro.elephant.direct.AbstractDirectContentCtrl.

Definition at line 138 of file ProjectCtrl.java.

138  {
139  String type = map.get("type");
140  if("click".equals(type)) {
141  processClick(constructor, map);
142  }
143  }

◆ getIdentifier()

String org.turro.alliance.content.control.ProjectCtrl.getIdentifier ( )
protected

Reimplemented from org.turro.elephant.direct.AbstractDirectContentCtrl.

Definition at line 133 of file ProjectCtrl.java.

133  {
134  return ProjectCtrl.class.getAnnotation(DirectContent.class).identifier();
135  }

◆ prepareCleanMarker()

void org.turro.alliance.content.control.ProjectCtrl.prepareCleanMarker ( ElephantMarker  marker,
KeyValueMap  map 
)
protected

Reimplemented from org.turro.elephant.direct.AbstractDirectContentCtrl.

Definition at line 79 of file ProjectCtrl.java.

79  {
80  marker.putAll(map);
81  marker.put("checkLink", getAjaxUrl((String) marker.get("domid"), map));
82  }
String getAjaxUrl(String containerId, String values)
Here is the call graph for this function:

◆ prepareMarker()

void org.turro.alliance.content.control.ProjectCtrl.prepareMarker ( ElephantMarker  marker)
protected

Reimplemented from org.turro.elephant.direct.AbstractDirectContentCtrl.

Definition at line 87 of file ProjectCtrl.java.

87  {
88  addContainerId(marker, true);
89  IContact contact = Authentication.getIContact();
90  if(contact.isWebUser()) {
91  KeyValueMap kvm = new KeyValueMap(Collections.EMPTY_MAP);
92  kvm.put("type", "click");
93  kvm.put("serverDomain", server.getServerDomain());
94  kvm.put("service", server.getService());
95  kvm.put("action", action.name());
96  kvm.put("axId", axId);
97  switch(action) {
98  case TOGGLE_BAN -> {
99  marker.put("banned", Boolean.toString(isBanned()));
100  }
101  case PARTICIPATE -> {
102  marker.put("participationLabel", particiationLabel);
103  marker.put("participant", isParticipant(contact.getId()));
104  marker.put("requested", Boolean.toString(hasRequested(contact.getId())));
105  kvm.put("contactId", contact.getId());
106  kvm.put("as", particiationLabel);
107  }
108  }
109  marker.put("checkLink", getAjaxUrl((String) marker.get("containerId"), kvm));
110  }
111  }
void addContainerId(ElephantMarker marker, boolean container)
String getServerDomain()
Definition: WsServer.java:52
Here is the call graph for this function:

◆ setAction()

void org.turro.alliance.content.control.ProjectCtrl.setAction ( ProjectAction  action)

Definition at line 65 of file ProjectCtrl.java.

65  {
66  this.action = action;
67  setTemplate(action.toString().replaceAll("_", "-").toLowerCase());
68  }
Here is the caller graph for this function:

◆ setAxId()

void org.turro.alliance.content.control.ProjectCtrl.setAxId ( String  axId)

Definition at line 70 of file ProjectCtrl.java.

70  {
71  this.axId = axId;
72  }
Here is the caller graph for this function:

◆ setParticiationLabel()

void org.turro.alliance.content.control.ProjectCtrl.setParticiationLabel ( String  particiationLabel)

Definition at line 74 of file ProjectCtrl.java.

74  {
75  this.particiationLabel = particiationLabel;
76  }
Here is the caller graph for this function:

◆ setServer()

void org.turro.alliance.content.control.ProjectCtrl.setServer ( WsServer  server)

Definition at line 61 of file ProjectCtrl.java.

61  {
62  this.server = server;
63  }
Here is the caller graph for this function:

◆ toggleBanned()

boolean org.turro.alliance.content.control.ProjectCtrl.toggleBanned ( KeyValueMap  map)

Definition at line 158 of file ProjectCtrl.java.

158  {
159  WsServer server = Servers.getServer(WsServerPK.from(map.get("serverDomain"), map.get("service")));
160  Jsons response = Servers.getData(server, AxConstants.BAN_TOGGLE, Jsons.object().add("axId", map.get("axId")));
161  if(!Jsons.isEmpty(response)) {
162  return response.getBoolean("banned");
163  } else {
164  return false;
165  }
166  }
Here is the call graph for this function:

The documentation for this class was generated from the following file: