62 if(AxConstants.USERS.equals(reason)) {
63 long memberId = json.getInt(
"memberId");
64 Jsons users = Jsons.array();
65 getParticipantsIds().forEach(
id -> {
66 users.addValue(Jsons.read(AxContact.from(memberId,
id).toJson()));
68 writeResponse(application, users.build());
69 }
else if(AxConstants.PROJECTS.equals(reason)) {
70 long memberId = json.getInt(
"memberId");
71 Jsons projects = Jsons.array();
72 Dao dao =
new DossierPU();
73 SqlClause.select(
"pc").from(
"AxProjectCategory pc")
74 .where().equal(
"pc.serverDomain", server.getServerDomain())
75 .dao(
new AlliancePU())
76 .resultList(AxProjectCategory.class).forEach(pc -> {
77 Dossier dossier = dao.find(Dossier.class, Long.valueOf(pc.getProjectId()));
78 if(dossier !=
null && dossier.getProject() !=
null) {
79 projects.addValue(Jsons.read(AxProject.from(memberId, server, dossier, pc).toJson()));
82 writeResponse(application, projects.build());
83 }
else if(AxConstants.PROJECT_GRANTS.equals(reason)) {
84 long memberId = json.getInt(
"memberId");
85 Jsons projectGrants = Jsons.array();
86 Dao dao =
new DossierPU();
87 SqlClause.select(
"pc").from(
"AxProjectGrantPublic pc")
88 .where().equal(
"pc.serverDomain", server.getServerDomain())
89 .dao(
new AlliancePU())
90 .resultList(AxProjectGrantPublic.class).forEach(pc -> {
91 ProjectGrant projectGrant = dao.find(ProjectGrant.class, Long.valueOf(pc.getProjectGrantId()));
92 if(projectGrant !=
null) {
93 projectGrants.addValue(Jsons.read(AxProjectGrant.from(memberId, projectGrant).toJson()));
96 writeResponse(application, projectGrants.build());
97 }
else if(AxConstants.CENTERS.equals(reason)) {
98 long memberId = json.getInt(
"memberId");
99 Jsons centers = Jsons.array();
100 Contacts.getCenters().forEach(center -> {
101 centers.addValue(Jsons.read(AxCenter.from(memberId, center).toJson()));
103 writeResponse(application, centers.build());
104 }
else if(AxConstants.STUDENTS.equals(reason)) {
105 long memberId = json.getInt(
"memberId");
106 Jsons students = Jsons.array();
107 Contacts.getStudents().forEach(student -> {
108 if(student.isStudent() && !student.isWorker()) {
109 students.addValue(Jsons.read(AxStudent.from(memberId, student).toJson()));
112 writeResponse(application, students.build());
113 }
else if(AxConstants.CHALLENGES.equals(reason)) {
114 long memberId = json.getInt(
"memberId");
115 Jsons challenges = Jsons.array();
116 Dao dao =
new StudentsPU();
117 SqlClause.select(
"pc").from(
"AxChallengeCategory pc")
118 .where().equal(
"pc.serverDomain", server.getServerDomain())
119 .dao(
new AlliancePU())
120 .resultList(AxChallengeCategory.class).forEach(pc -> {
121 Challenge challenge = dao.find(Challenge.class, Long.valueOf(pc.getChallengeId()));
122 if(challenge !=
null) {
123 challenges.addValue(Jsons.read(AxChallenge.from(memberId, server, challenge, pc).toJson()));
126 writeResponse(application, challenges.build());
127 }
else if(AxConstants.TAGS.equals(reason)) {
128 long memberId = json.getInt(
"memberId");
129 Jsons tags = Jsons.array();
130 Dao dao =
new DossierPU();
131 SqlClause.select(
"pc").from(
"AxProjectCategory pc")
132 .where().equal(
"pc.serverDomain", server.getServerDomain())
133 .dao(
new AlliancePU())
134 .resultList(AxProjectCategory.class).forEach(pc -> {
135 Dossier dossier = dao.find(Dossier.class, Long.valueOf(pc.getProjectId()));
136 if(dossier !=
null && dossier.getProject() !=
null) {
137 AxTag.from(memberId, dossier).forEach(tag -> {
138 tags.addValue(Jsons.read(tag.toJson()));
142 SqlClause.select(
"pc").from(
"AxProjectGrantPublic pc")
143 .where().equal(
"pc.serverDomain", server.getServerDomain())
144 .dao(
new AlliancePU())
145 .resultList(AxProjectGrantPublic.class).forEach(pc -> {
146 ProjectGrant projectGrant = dao.find(ProjectGrant.class, Long.valueOf(pc.getProjectGrantId()));
147 if(projectGrant !=
null) {
148 AxTag.from(memberId, projectGrant).forEach(tag -> {
149 tags.addValue(Jsons.read(tag.toJson()));
153 writeResponse(application, tags.build());