19 package org.turro.alliance.service;
21 import org.turro.alliance.provider.Projects;
22 import org.turro.alliance.db.AlliancePU;
23 import org.turro.alliance.db.entities.AxCategory;
24 import org.turro.alliance.db.entities.AxTalentCategory;
25 import org.turro.alliance.provider.Banned;
26 import org.turro.alliance.provider.CategoryProvider;
27 import org.turro.alliance.provider.PhaseProvider;
28 import org.turro.alliance.provider.PreferencesProvider;
29 import org.turro.alliance.provider.ProjectGrantProvider;
30 import org.turro.alliance.provider.ProjectProvider;
31 import org.turro.alliance.provider.TagProvider;
32 import org.turro.collections.KeyValueMap;
33 import org.turro.elephant.context.Application;
34 import org.turro.importer.ImportFromMembers;
35 import org.turro.json.Jsons;
36 import org.turro.server.db.entities.AxMemberPreferences;
37 import org.turro.sql.SqlClause;
38 import org.turro.string.Strings;
39 import org.turro.ws.WsMember;
40 import org.turro.ws.service.IWsService;
41 import org.turro.ws.service.server.SecuredServerService;
42 import org.turro.ws.service.WsService;
48 @WsService(path = AxServer.SERVER_SERVICE, name =
"Alliance Server")
49 public class
AxServer extends SecuredServerService implements IWsService {
51 public static final String SERVER_SERVICE =
"/axserver";
56 AxCategory cat = SqlClause.select(
"c").from(
"AxCategory c")
57 .where().equal(
"c.categoryId", json.getLong(
"id"))
61 writeResponse(application, cat.
toJson());
64 Jsons categories = Jsons.array();
65 SqlClause.select(
"c").from(
"AxCategory c")
66 .orderBy(
"c.uniquePath")
68 .resultList(
AxCategory.class).forEach(category -> {
69 categories.addValue(Jsons.read(category.toJson()));
71 writeResponse(application, categories.build());
74 .
project(json.getString(
"id")).toString());
75 }
else if(
AxConstants.PARTICIPATIONS.equals(reason)) {
78 }
else if(
AxConstants.AXPARTICIPATIONS.equals(reason)) {
80 .
axParticipations(json.getString(
"id"), json.getString(
"as",
null)).build());
81 }
else if(
AxConstants.AXFULL_PARTICIPATIONS.equals(reason)) {
84 }
else if(
AxConstants.AXPENDING_REQUESTS.equals(reason)) {
85 if(!Strings.isBlank(json.getString(
"id",
null))) {
92 }
else if(
AxConstants.AXPENDING_VALIDATE.equals(reason)) {
94 }
else if(
AxConstants.AXPENDING_DELETE.equals(reason)) {
96 }
else if(
AxConstants.UPDATE_SERVER.equals(reason)) {
98 writeResponse(application, Jsons.object().add(
"imported",
true).build());
99 }
else if(
AxConstants.PROJECT_ITERATOR.equals(reason)) {
102 }
else if(
AxConstants.PROJECT_GRANT_ITERATOR.equals(reason)) {
105 }
else if(
AxConstants.CATEGORY_ITERATOR.equals(reason)) {
108 }
else if(
AxConstants.PHASE_ITERATOR.equals(reason)) {
109 writeResponse(application,
new PhaseProvider(member, reason, json)
112 writeResponse(application,
new TagProvider(member, reason, json)
117 }
else if(
AxConstants.SAVE_PREFERENCES.equals(reason)) {
120 writeResponse(application, Jsons.object()
124 writeResponse(application, Jsons.object()
127 }
else if(
AxConstants.AXPARTICIPATION_REQUESTED.equals(reason)) {
128 writeResponse(application, Jsons.object()
131 }
else if(
AxConstants.AXPARTICIPATION_STATUS.equals(reason)) {
132 writeResponse(application, Jsons.object()
135 }
else if(
AxConstants.AXPARTICIPATION_SAVE.equals(reason)) {
136 writeResponse(application, Jsons.object()
137 .add(
"participant",
Projects.
from(member).
save(Jsons.read(json.getObject(
"item").toString())))
139 }
else if(
AxConstants.AXPARTICIPATION_ASK.equals(reason)) {
141 writeResponse(application, Jsons.object()
142 .add(
"requested",
true)
144 }
else if(
AxConstants.TALENT_CATEGORY.equals(reason)) {
146 .where().equal(
"c.categoryId", json.getLong(
"id"))
150 writeResponse(application, cat.
toJson());
152 }
else if(
AxConstants.TALENT_CATEGORIES.equals(reason)) {
153 Jsons categories = Jsons.array();
154 SqlClause.select(
"c").from(
"AxTalentCategory c")
158 categories.addValue(Jsons.read(category.toJson()));
160 writeResponse(application, categories.build());
162 writeResponse(application,
"none");
boolean toggle(String axId)
boolean status(String axId)
static Banned of(WsMember member)
void axValidatePending(Jsons axPending)
Jsons axParticipations(String projectId, String as)
boolean save(Jsons request)
void axAskParticipate(Jsons request)
boolean hasRequested(Jsons request)
Jsons participations(String projectId)
void axDeleteParticipation(Jsons axRequest)
boolean isParticipant(Jsons request)
static Projects from(WsMember member)
Jsons axPendingParticipations()
Jsons axFullParticipations()
Jsons project(String projectId)
Jsons axAllParticipations(String projectId)
static final String MEMBER_PREFERENCES
void doProcess(Application application, KeyValueMap map, WsMember member, Jsons json, String reason)
static AxMemberPreferences fromJson(JsonValue value)