Commit c3873af845229022da6c4f4de072fae74fdf659f

Authored by Paulo Graça
1 parent 584d471cf1
Exists in tests

Remove logging

ptcrisync/pom.xml
... ... @@ -3,7 +3,7 @@
3 3 <modelVersion>4.0.0</modelVersion>
4 4 <groupId>PTCRISync</groupId>
5 5 <artifactId>PTCRISync</artifactId>
6   - <version>0.0.1-SNAPSHOT</version>
  6 + <version>0.0.1</version>
7 7  
8 8 <properties>
9 9 <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
... ... @@ -56,6 +56,18 @@
56 56 <build>
57 57 <sourceDirectory>src</sourceDirectory>
58 58 <plugins>
  59 +<plugin>
  60 + <groupId>org.apache.maven.plugins</groupId>
  61 + <artifactId>maven-jar-plugin</artifactId>
  62 + <configuration>
  63 + <archive>
  64 + <manifest>
  65 + <addDefaultImplementationEntries>true</addDefaultImplementationEntries>
  66 + <addDefaultSpecificationEntries>true</addDefaultSpecificationEntries>
  67 + </manifest>
  68 + </archive>
  69 + </configuration>
  70 +</plugin>
59 71 <plugin>
60 72 <artifactId>maven-compiler-plugin</artifactId>
61 73 <version>3.3</version>
... ... @@ -66,4 +78,10 @@
66 78 </plugin>
67 79 </plugins>
68 80 </build>
  81 + <name>PTCRISync</name>
  82 + <description>This project aims to help the syncronization between ORCID and local systems.</description>
  83 + <organization>
  84 + <name>FCT|FCCN</name>
  85 + <url>http://www.fccn.pt</url>
  86 + </organization>
69 87 </project>
70 88 \ No newline at end of file
... ...
ptcrisync/src/pt/ptcris/PTCRISync.java
... ... @@ -3,8 +3,6 @@ package pt.ptcris;
3 3 import java.util.LinkedList;
4 4 import java.util.List;
5 5  
6   -import org.apache.logging.log4j.LogManager;
7   -import org.apache.logging.log4j.Logger;
8 6 import org.um.dsi.gavea.orcid.client.exception.OrcidClientException;
9 7 import org.um.dsi.gavea.orcid.model.work.Work;
10 8 import org.um.dsi.gavea.orcid.model.work.WorkSummary;
... ... @@ -15,9 +13,9 @@ import pt.ptcris.utils.UpdateRecord;
15 13 import pt.ptcris.ORCIDHelper;
16 14  
17 15 public class PTCRISync {
18   -
  16 +
19 17 private static ORCIDHelper helper;
20   - private static final Logger _log = LogManager.getLogger(PTCRISync.class);
  18 +
21 19 /**
22 20 * Export a list of works to an ORCID profile.
23 21 *
... ... @@ -26,12 +24,13 @@ public class PTCRISync {
26 24 * @param local_work
27 25 * The list of works to be exported (those marked as synced).
28 26 * @param progressHandler
29   - * The implementation of the ProgressHandler interface responsible for receiving progress updates.
30   - * @throws ORCIDException
  27 + * The implementation of the ProgressHandler interface
  28 + * responsible for receiving progress updates.
  29 + * @throws ORCIDException
31 30 */
32   - public static void export(ORCIDClient orcidClient, List<Work> localWorks,
33   - ProgressHandler progressHandler) throws OrcidClientException {
34   -
  31 + public static void export(ORCIDClient orcidClient, List<Work> localWorks, ProgressHandler progressHandler)
  32 + throws OrcidClientException {
  33 +
35 34 int progress = 0;
36 35 progressHandler.setProgress(progress);
37 36 progressHandler.setCurrentStatus("ORCID_SYNC_EXPORT_STARTED");
... ... @@ -40,10 +39,8 @@ public class PTCRISync {
40 39  
41 40 List<WorkSummary> orcidWorks = helper.getSourcedWorkSummaries();
42 41 List<UpdateRecord> recordsToUpdate = new LinkedList<UpdateRecord>();
43   -
44   -
  42 +
45 43 progressHandler.setCurrentStatus("ORCID_SYNC_EXPORT_WORKS_ITERATION");
46   - _log.info("[export] " + "ORCID_SYNC_EXPORT_WORKS_ITERATION");
47 44 for (int counter = 0; counter != orcidWorks.size(); counter++) {
48 45 progress = (int) ((double) ((double) counter / orcidWorks.size()) * 100);
49 46 progressHandler.setProgress(progress);
... ... @@ -53,7 +50,6 @@ public class PTCRISync {
53 50 helper.deleteWork(orcidWorks.get(counter).getPutCode());
54 51 } else {
55 52 for (Work localWork : matchingWorks) {
56   - _log.debug("[export] Local work " + ORCIDHelper.getWorkTitle(localWork));
57 53 Work orcidWork = helper.getFullWork(orcidWorks.get(counter).getPutCode());
58 54 recordsToUpdate.add(new UpdateRecord(localWork, orcidWork));
59 55 localWorks.remove(localWork);
... ... @@ -62,7 +58,6 @@ public class PTCRISync {
62 58 }
63 59  
64 60 progressHandler.setCurrentStatus("ORCID_SYNC_EXPORT_UPDATING_WORKS");
65   - _log.info("[export] " + "ORCID_SYNC_EXPORT_UPDATING_WORKS");
66 61 for (int counter = 0; counter != recordsToUpdate.size(); counter++) {
67 62 progress = (int) ((double) ((double) counter / recordsToUpdate.size()) * 100);
68 63 progressHandler.setProgress(progress);
... ... @@ -72,7 +67,6 @@ public class PTCRISync {
72 67 }
73 68  
74 69 progressHandler.setCurrentStatus("ORCID_SYNC_EXPORT_ADDING_WORKS");
75   - _log.info("[export] " + "ORCID_SYNC_EXPORT_ADDING_WORKS");
76 70 for (int counter = 0; counter != localWorks.size(); counter++) {
77 71 progress = (int) ((double) ((double) counter / localWorks.size()) * 100);
78 72 progressHandler.setProgress(progress);
... ... @@ -90,17 +84,19 @@ public class PTCRISync {
90 84 * @param orcidClient
91 85 * The ORCID client to access to the profile.
92 86 * @param localWorks
93   - * The full list of works in the local profile. In fact, for each work only the external identifiers are needed, so the remaining
94   - * attributes may be left null.
  87 + * The full list of works in the local profile. In fact, for each
  88 + * work only the external identifiers are needed, so the
  89 + * remaining attributes may be left null.
95 90 * @param progressHandler
96   - * The implementation of the ProgressHandler interface responsible for receiving progress updates
  91 + * The implementation of the ProgressHandler interface
  92 + * responsible for receiving progress updates
97 93 * @return The list of new works found in the ORCID profile.
98   - * @throws ORCIDException
  94 + * @throws ORCIDException
99 95 */
100   - public static List<Work> importWorks(ORCIDClient orcidClient, List<Work> localWorks, ProgressHandler progressHandler) throws OrcidClientException {
  96 + public static List<Work> importWorks(ORCIDClient orcidClient, List<Work> localWorks,
  97 + ProgressHandler progressHandler) throws OrcidClientException {
101 98 int progress = 0;
102 99 progressHandler.setProgress(progress);
103   - _log.info("[importWorks] " + "ORCID_SYNC_IMPORT_WORKS_STARTED");
104 100 progressHandler.setCurrentStatus("ORCID_SYNC_IMPORT_WORKS_STARTED");
105 101  
106 102 List<Work> worksToImport = new LinkedList<Work>();
... ... @@ -109,7 +105,6 @@ public class PTCRISync {
109 105  
110 106 List<WorkSummary> orcidWorks = helper.getAllWorkSummaries();
111 107  
112   - _log.info("[importWorks] " + "ORCID_SYNC_IMPORT_WORKS_ITERATION");
113 108 progressHandler.setCurrentStatus("ORCID_SYNC_IMPORT_WORKS_ITERATION");
114 109 for (int counter = 0; counter != orcidWorks.size(); counter++) {
115 110 progress = (int) ((double) ((double) counter / orcidWorks.size()) * 100);
... ... @@ -133,26 +128,31 @@ public class PTCRISync {
133 128 * @param orcidClient
134 129 * The ORCID client to access to the profile.
135 130 * @param localWorks
136   - * The list of works for which we wish to discover updates (those marked as synced). For the moment, only new external identifiers will
137   - * be found, so, for each work only the external identifiers are needed, so the remaining attributes may be left null. Also the putcode
138   - * attribute should be used to store the local key of each work.
  131 + * The list of works for which we wish to discover updates (those
  132 + * marked as synced). For the moment, only new external
  133 + * identifiers will be found, so, for each work only the external
  134 + * identifiers are needed, so the remaining attributes may be
  135 + * left null. Also the putcode attribute should be used to store
  136 + * the local key of each work.
139 137 * @param progressHandler
140   - * The implementation of the ProgressHandler interface responsible for receiving progress updates
141   - * @return The list of updated works. Only the works that have changes are returned. Also, for each of them, only the attributes that changed are
142   - * set. For the moment, only new external identifiers will be returned.
143   - * @throws ORCIDException
  138 + * The implementation of the ProgressHandler interface
  139 + * responsible for receiving progress updates
  140 + * @return The list of updated works. Only the works that have changes are
  141 + * returned. Also, for each of them, only the attributes that
  142 + * changed are set. For the moment, only new external identifiers
  143 + * will be returned.
  144 + * @throws ORCIDException
144 145 */
145   - public static List<Work> importUpdates(ORCIDClient orcidClient, List<Work> localWorks, ProgressHandler progressHandler) throws OrcidClientException {
  146 + public static List<Work> importUpdates(ORCIDClient orcidClient, List<Work> localWorks,
  147 + ProgressHandler progressHandler) throws OrcidClientException {
146 148 int progress = 0;
147 149 progressHandler.setProgress(progress);
148   - _log.info("[importUpdates] " + "ORCID_SYNC_IMPORT_UPDATES_STARTED");
149 150 progressHandler.setCurrentStatus("ORCID_SYNC_IMPORT_UPDATES_STARTED");
150   -
  151 +
151 152 List<Work> worksToUpdate = new LinkedList<Work>();
152 153 helper = new ORCIDHelper(orcidClient);
153 154 List<WorkSummary> orcidWorks = helper.getAllWorkSummaries();
154 155  
155   - _log.info("[importUpdates] " + "ORCID_SYNC_IMPORT_UPDATES_ITERATION");
156 156 progressHandler.setCurrentStatus("ORCID_SYNC_IMPORT_UPDATES_ITERATION");
157 157 for (int counter = 0; counter != orcidWorks.size(); counter++) {
158 158 progress = (int) ((double) ((double) counter / orcidWorks.size()) * 100);
... ... @@ -173,7 +173,5 @@ public class PTCRISync {
173 173  
174 174 return worksToUpdate;
175 175 }
176   -
177   -
178 176  
179 177 }
... ...