Commit 3823c3d6ca038968be60b734e6dc85464fba3b76

Authored by Paulo Graça
1 parent 64bb1a8477
Exists in tests

PG: downgrade from Java8

ptcrisync/src/main/java/pt/ptcris/ORCIDHelper.java
... ... @@ -3,8 +3,6 @@ package pt.ptcris;
3 3 import java.math.BigInteger;
4 4 import java.util.LinkedList;
5 5 import java.util.List;
6   -import java.util.stream.Collectors;
7   -import java.util.stream.Stream;
8 6  
9 7 import org.um.dsi.gavea.orcid.model.work.Work;
10 8 import org.um.dsi.gavea.orcid.model.work.WorkSummary;
... ... @@ -36,9 +34,12 @@ public class ORCIDHelper {
36 34 */
37 35 public List<WorkSummary> getAllWorkSummaries() throws OrcidClientException, NullPointerException {
38 36 ActivitiesSummary activitiesSummary = client.getActivitiesSummary();
39   - Stream<WorkGroup> workGroupList = activitiesSummary.getWorks().getGroup().stream();
40   - Stream<WorkSummary> workSummaryList = workGroupList.map(w -> groupToWork(w));
41   - return workSummaryList.collect(Collectors.toList());
  37 + List<WorkGroup> workGroupList = activitiesSummary.getWorks().getGroup();
  38 + List<WorkSummary> workSummaryList = new LinkedList<WorkSummary>();
  39 + for (WorkGroup group:workGroupList) {
  40 + workSummaryList.add(groupToWork(group));
  41 + }
  42 + return workSummaryList;
42 43 }
43 44  
44 45 /**
... ... @@ -54,16 +55,22 @@ public class ORCIDHelper {
54 55 ActivitiesSummary activitiesSummary = client.getActivitiesSummary();
55 56 String sourceClientID = client.getClientId();
56 57 Works works = activitiesSummary.getWorks();
  58 + List<WorkSummary> returnedWorkSummary = new LinkedList<WorkSummary>();
  59 +
57 60 if (works == null) {
58   - return new LinkedList<WorkSummary>();
  61 + return returnedWorkSummary;
59 62 }
60   - Stream<WorkGroup> workGroupList = works.getGroup().stream();
61   -
62   - Stream<WorkSummary> workSummaryList = workGroupList.map(WorkGroup::getWorkSummary)
63   - .flatMap(List::stream)
64   - .filter(s -> s.getSource().getSourceOrcid().getUriPath().equals(sourceClientID));
  63 + List<WorkGroup> workGroupList = works.getGroup();
  64 +
  65 + for (WorkGroup workGroup:workGroupList) {
  66 + for (WorkSummary workSummary:workGroup.getWorkSummary()) {
  67 + if (workSummary.getSource().getSourceOrcid().getUriPath().equals(sourceClientID)) {
  68 + returnedWorkSummary.add(workSummary);
  69 + }
  70 + }
  71 + }
65 72  
66   - return workSummaryList.collect(Collectors.toList());
  73 + return returnedWorkSummary;
67 74 }
68 75  
69 76  
... ...