Revision 61528
Added by Konstantinos Triantafyllou over 2 years ago
RegistryCalls.java | ||
---|---|---|
33 | 33 |
|
34 | 34 |
|
35 | 35 |
public String mapType(String type, boolean communityMap) { |
36 |
if(type.equals("organization")) { |
|
36 |
if (type.equals("organization")) {
|
|
37 | 37 |
type = "institution"; |
38 |
} else if(type.equals("ri") && communityMap) { |
|
38 |
} else if (type.equals("ri") && communityMap) {
|
|
39 | 39 |
type = "community"; |
40 | 40 |
} |
41 | 41 |
return type; |
... | ... | |
64 | 64 |
params.put("coid", coid); |
65 | 65 |
params.put("mail", email); |
66 | 66 |
JsonElement response = httpUtils.get("co_people.json", params); |
67 |
if(response != null) { |
|
67 |
if (response != null) {
|
|
68 | 68 |
JsonArray coPeople = response.getAsJsonObject().get("CoPeople").getAsJsonArray(); |
69 |
if(coPeople.size() > 0) { |
|
69 |
if (coPeople.size() > 0) {
|
|
70 | 70 |
return coPeople.get(0).getAsJsonObject().get("Id").getAsInt(); |
71 | 71 |
} |
72 | 72 |
} |
... | ... | |
79 | 79 |
params.put("coid", coid); |
80 | 80 |
params.put("mail", email); |
81 | 81 |
JsonElement response = httpUtils.get("co_people.json", params); |
82 |
if(response != null) { |
|
82 |
if (response != null) {
|
|
83 | 83 |
JsonArray coPeople = response.getAsJsonObject().get("CoPeople").getAsJsonArray(); |
84 |
for(int i = 0; i < coPeople.size(); i++) { |
|
84 |
for (int i = 0; i < coPeople.size(); i++) {
|
|
85 | 85 |
coPersonIds.add(coPeople.get(i).getAsJsonObject().get("Id").getAsInt()); |
86 | 86 |
} |
87 | 87 |
} |
... | ... | |
120 | 120 |
public JsonArray getCous(String name) { |
121 | 121 |
Map<String, String> params = new HashMap<>(); |
122 | 122 |
params.put("coid", coid); |
123 |
if(name != null) { |
|
123 |
if (name != null) {
|
|
124 | 124 |
params.put("name", name.toLowerCase()); |
125 | 125 |
} |
126 | 126 |
JsonElement response = httpUtils.get("cous.json", params); |
... | ... | |
274 | 274 |
JsonArray emails = new JsonArray(); |
275 | 275 |
infos.forEach(info -> { |
276 | 276 |
JsonObject user = new JsonObject(); |
277 |
boolean add = true; |
|
278 |
String email = info.getAsJsonObject().get("Mail").getAsString(); |
|
279 |
for(JsonElement element : emails) { |
|
280 |
if(element.getAsJsonObject().get("email").getAsString().equals(email)) { |
|
281 |
add = false; |
|
282 |
} |
|
283 |
} |
|
284 |
if(add) { |
|
285 |
user.addProperty("email", email); |
|
286 |
user.addProperty("memberSince", info.getAsJsonObject().get("Created").getAsString()); |
|
287 |
emails.add(user); |
|
288 |
} |
|
277 |
user.addProperty("coPersonId", info.getAsJsonObject().get("Person").getAsJsonObject().get("Id").getAsString()); |
|
278 |
user.addProperty("email", info.getAsJsonObject().get("Mail").getAsString()); |
|
279 |
user.addProperty("memberSince", info.getAsJsonObject().get("Created").getAsString()); |
|
280 |
emails.add(user); |
|
289 | 281 |
}); |
290 | 282 |
return emails; |
291 | 283 |
} |
... | ... | |
304 | 296 |
JsonArray names = new JsonArray(); |
305 | 297 |
infos.forEach(info -> { |
306 | 298 |
JsonObject user = new JsonObject(); |
299 |
user.addProperty("coPersonId", info.getAsJsonObject().get("Person").getAsJsonObject().get("Id").getAsString()); |
|
307 | 300 |
user.addProperty("name", info.getAsJsonObject().get("Given").getAsString() + " " + info.getAsJsonObject().get("Family").getAsString()); |
308 | 301 |
user.addProperty("memberSince", info.getAsJsonObject().get("Created").getAsString()); |
309 | 302 |
names.add(user); |
... | ... | |
322 | 315 |
} |
323 | 316 |
JsonElement response = httpUtils.get("identifiers.json", params); |
324 | 317 |
JsonArray infos = (response != null) ? response.getAsJsonObject().get("Identifiers").getAsJsonArray() : new JsonArray(); |
325 |
JsonArray emails = new JsonArray();
|
|
318 |
JsonArray ids = new JsonArray();
|
|
326 | 319 |
infos.forEach(info -> { |
327 | 320 |
JsonObject user = new JsonObject(); |
321 |
user.addProperty("coPersonId", info.getAsJsonObject().get("Person").getAsJsonObject().get("Id").getAsString()); |
|
328 | 322 |
user.addProperty("id", info.getAsJsonObject().get("Identifier").getAsString()); |
329 | 323 |
user.addProperty("memberSince", info.getAsJsonObject().get("Created").getAsString()); |
330 |
emails.add(user);
|
|
324 |
ids.add(user);
|
|
331 | 325 |
}); |
332 |
return emails;
|
|
326 |
return ids;
|
|
333 | 327 |
} |
334 | 328 |
|
335 | 329 |
/** |
... | ... | |
347 | 341 |
* 16. Remove a member role from a User |
348 | 342 |
*/ |
349 | 343 |
public void removeMemberRole(Integer coPersonId, Integer couId, Integer id) { |
350 |
if(id != null) { |
|
344 |
if (id != null) {
|
|
351 | 345 |
httpUtils.put("co_person_roles/" + id.toString() + ".json", jsonUtils.coPersonRoles(coPersonId, couId, "Deleted")); |
352 | 346 |
} |
353 | 347 |
} |
Also available in: Unified diff
[Users | Trunk]: Fix merge info method