From 5e803d194c784001c2727371e235772917dccda7 Mon Sep 17 00:00:00 2001 From: lpedro Date: Tue, 4 Jul 2017 10:54:54 +0000 Subject: [PATCH 01/16] C4351 --- .classpath | 27 + .project | 37 + .settings/org.eclipse.jdt.core.prefs | 12 + LICENSE.md | 21 + NOTES.md | 24 + README.md | 4 + _config.yml | 1 + docs/allclasses-frame.html | 34 + docs/allclasses-noframe.html | 34 + docs/constant-values.html | 258 +++ docs/deprecated-list.html | 195 +++ docs/help-doc.html | 229 +++ docs/index-files/index-1.html | 173 ++ docs/index-files/index-10.html | 131 ++ docs/index-files/index-11.html | 200 +++ docs/index-files/index-12.html | 166 ++ docs/index-files/index-13.html | 131 ++ docs/index-files/index-14.html | 173 ++ docs/index-files/index-15.html | 164 ++ docs/index-files/index-16.html | 165 ++ docs/index-files/index-2.html | 172 ++ docs/index-files/index-3.html | 158 ++ docs/index-files/index-4.html | 171 ++ docs/index-files/index-5.html | 141 ++ docs/index-files/index-6.html | 302 ++++ docs/index-files/index-7.html | 132 ++ docs/index-files/index-8.html | 246 +++ docs/index-files/index-9.html | 131 ++ docs/index.html | 74 + docs/overview-frame.html | 25 + docs/overview-summary.html | 151 ++ docs/overview-tree.html | 178 ++ docs/package-list | 5 + docs/pt/ptcris/ORCIDClient.html | 593 +++++++ docs/pt/ptcris/ORCIDClientImpl.html | 817 +++++++++ docs/pt/ptcris/PTCRISGrouper.html | 307 ++++ docs/pt/ptcris/PTCRISync.html | 1334 +++++++++++++++ docs/pt/ptcris/PTCRISyncResult.html | 588 +++++++ docs/pt/ptcris/TempORCIDClient.html | 328 ++++ docs/pt/ptcris/class-use/ORCIDClient.html | 403 +++++ docs/pt/ptcris/class-use/ORCIDClientImpl.html | 124 ++ docs/pt/ptcris/class-use/PTCRISGrouper.html | 124 ++ docs/pt/ptcris/class-use/PTCRISync.html | 124 ++ docs/pt/ptcris/class-use/PTCRISyncResult.html | 461 ++++++ docs/pt/ptcris/class-use/TempORCIDClient.html | 124 ++ .../exceptions/InvalidActivityException.html | 346 ++++ .../class-use/InvalidActivityException.html | 192 +++ docs/pt/ptcris/exceptions/package-frame.html | 20 + .../pt/ptcris/exceptions/package-summary.html | 142 ++ docs/pt/ptcris/exceptions/package-tree.html | 145 ++ docs/pt/ptcris/exceptions/package-use.html | 176 ++ .../pt/ptcris/grouper/ActivityComparator.html | 315 ++++ docs/pt/ptcris/grouper/ActivityGroup.html | 203 +++ docs/pt/ptcris/grouper/GroupGenerator.html | 318 ++++ .../grouper/class-use/ActivityComparator.html | 191 +++ .../grouper/class-use/ActivityGroup.html | 192 +++ .../grouper/class-use/GroupGenerator.html | 124 ++ docs/pt/ptcris/grouper/package-frame.html | 22 + docs/pt/ptcris/grouper/package-summary.html | 159 ++ docs/pt/ptcris/grouper/package-tree.html | 139 ++ docs/pt/ptcris/grouper/package-use.html | 192 +++ docs/pt/ptcris/handlers/ProgressHandler.html | 330 ++++ .../handlers/class-use/ProgressHandler.html | 371 +++++ docs/pt/ptcris/handlers/package-frame.html | 20 + docs/pt/ptcris/handlers/package-summary.html | 145 ++ docs/pt/ptcris/handlers/package-tree.html | 133 ++ docs/pt/ptcris/handlers/package-use.html | 182 ++ docs/pt/ptcris/package-frame.html | 28 + docs/pt/ptcris/package-summary.html | 192 +++ docs/pt/ptcris/package-tree.html | 153 ++ docs/pt/ptcris/package-use.html | 194 +++ docs/pt/ptcris/utils/ExternalIdsDiff.html | 323 ++++ docs/pt/ptcris/utils/ORCIDFundingHelper.html | 479 ++++++ docs/pt/ptcris/utils/ORCIDHelper.html | 1200 ++++++++++++++ docs/pt/ptcris/utils/ORCIDWorkHelper.html | 478 ++++++ docs/pt/ptcris/utils/UpdateRecord.html | 320 ++++ .../utils/class-use/ExternalIdsDiff.html | 227 +++ .../utils/class-use/ORCIDFundingHelper.html | 124 ++ .../ptcris/utils/class-use/ORCIDHelper.html | 197 +++ .../utils/class-use/ORCIDWorkHelper.html | 124 ++ .../ptcris/utils/class-use/UpdateRecord.html | 124 ++ docs/pt/ptcris/utils/package-frame.html | 24 + docs/pt/ptcris/utils/package-summary.html | 173 ++ docs/pt/ptcris/utils/package-tree.html | 144 ++ docs/pt/ptcris/utils/package-use.html | 166 ++ docs/script.js | 30 + docs/serialized-form.html | 155 ++ docs/stylesheet.css | 574 +++++++ pom.xml | 73 + src/main/java/pt/ptcris/ORCIDClient.java | 193 +++ src/main/java/pt/ptcris/ORCIDClientImpl.java | 422 +++++ src/main/java/pt/ptcris/PTCRISGrouper.java | 61 + src/main/java/pt/ptcris/PTCRISync.java | 1466 +++++++++++++++++ src/main/java/pt/ptcris/PTCRISyncResult.java | 189 +++ src/main/java/pt/ptcris/TempORCIDClient.java | 35 + .../exceptions/InvalidActivityException.java | 47 + .../pt/ptcris/grouper/ActivityComparator.java | 74 + .../java/pt/ptcris/grouper/ActivityGroup.java | 69 + .../pt/ptcris/grouper/GroupGenerator.java | 82 + .../pt/ptcris/handlers/ProgressHandler.java | 55 + .../java/pt/ptcris/utils/ExternalIdsDiff.java | 97 ++ .../java/pt/ptcris/utils/ORCIDAddWorker.java | 71 + .../java/pt/ptcris/utils/ORCIDDelWorker.java | 70 + .../pt/ptcris/utils/ORCIDFundingHelper.java | 377 +++++ .../ptcris/utils/ORCIDGetBulkWorkWorker.java | 80 + .../ptcris/utils/ORCIDGetFundingWorker.java | 74 + .../pt/ptcris/utils/ORCIDGetWorkWorker.java | 73 + .../java/pt/ptcris/utils/ORCIDHelper.java | 1114 +++++++++++++ .../java/pt/ptcris/utils/ORCIDUpdWorker.java | 75 + .../java/pt/ptcris/utils/ORCIDWorkHelper.java | 417 +++++ .../java/pt/ptcris/utils/ORCIDWorker.java | 71 + .../java/pt/ptcris/utils/UpdateRecord.java | 47 + .../java/pt/ptcris/test/PTCRISExample.java | 170 ++ src/test/java/pt/ptcris/test/TestClients.java | 127 ++ src/test/java/pt/ptcris/test/TestHelper.java | 357 ++++ src/test/java/pt/ptcris/test/Tester.java | 76 + .../pt/ptcris/test/grouper/GrouperTest.java | 49 + .../test/grouper/IntegerComparator.java | 48 + .../test/grouper/StdWorkComparator.java | 38 + .../ptcris/test/scenarios/AllScenarios.java | 71 + .../pt/ptcris/test/scenarios/Scenario.java | 331 ++++ .../pt/ptcris/test/scenarios/Scenario01.java | 85 + .../pt/ptcris/test/scenarios/Scenario02.java | 93 ++ .../pt/ptcris/test/scenarios/Scenario03.java | 85 + .../pt/ptcris/test/scenarios/Scenario04.java | 64 + .../pt/ptcris/test/scenarios/Scenario05.java | 73 + .../pt/ptcris/test/scenarios/Scenario06.java | 79 + .../pt/ptcris/test/scenarios/Scenario07.java | 71 + .../pt/ptcris/test/scenarios/Scenario08.java | 82 + .../pt/ptcris/test/scenarios/Scenario09.java | 82 + .../pt/ptcris/test/scenarios/Scenario10.java | 76 + .../pt/ptcris/test/scenarios/Scenario11.java | 100 ++ .../pt/ptcris/test/scenarios/Scenario12.java | 89 + .../pt/ptcris/test/scenarios/Scenario13.java | 118 ++ .../pt/ptcris/test/scenarios/Scenario14.java | 104 ++ .../pt/ptcris/test/scenarios/Scenario15.java | 82 + .../pt/ptcris/test/scenarios/Scenario16.java | 96 ++ .../pt/ptcris/test/scenarios/Scenario17.java | 107 ++ .../pt/ptcris/test/scenarios/Scenario18.java | 104 ++ .../pt/ptcris/test/scenarios/Scenario19.java | 104 ++ .../pt/ptcris/test/scenarios/Scenario20.java | 38 + .../pt/ptcris/test/scenarios/ScenarioF01.java | 85 + .../pt/ptcris/test/scenarios/ScenarioF02.java | 93 ++ .../pt/ptcris/test/scenarios/ScenarioF03.java | 85 + .../pt/ptcris/test/scenarios/ScenarioF04.java | 64 + .../pt/ptcris/test/scenarios/ScenarioF05.java | 73 + .../pt/ptcris/test/scenarios/ScenarioF06.java | 79 + .../pt/ptcris/test/scenarios/ScenarioF07.java | 71 + .../pt/ptcris/test/scenarios/ScenarioF08.java | 82 + .../pt/ptcris/test/scenarios/ScenarioF09.java | 82 + .../pt/ptcris/test/scenarios/ScenarioF10.java | 76 + .../pt/ptcris/test/scenarios/ScenarioF11.java | 100 ++ .../pt/ptcris/test/scenarios/ScenarioF12.java | 92 ++ .../pt/ptcris/test/scenarios/ScenarioF13.java | 118 ++ .../pt/ptcris/test/scenarios/ScenarioF14.java | 104 ++ .../pt/ptcris/test/scenarios/ScenarioF15.java | 82 + .../pt/ptcris/test/scenarios/ScenarioF16.java | 96 ++ .../pt/ptcris/test/scenarios/ScenarioF17.java | 107 ++ .../pt/ptcris/test/scenarios/ScenarioF18.java | 104 ++ .../pt/ptcris/test/scenarios/ScenarioF19.java | 104 ++ .../pt/ptcris/test/scenarios/ScenarioF20.java | 38 + .../test/scenarios/ScenarioFIgnoredTypes.java | 55 + .../test/scenarios/ScenarioFInvalidLocal.java | 90 + .../test/scenarios/ScenarioFunding.java | 344 ++++ .../test/scenarios/ScenarioInvalidLocal1.java | 77 + .../test/scenarios/ScenarioInvalidLocal2.java | 90 + .../test/scenarios/ScenarioPerformance.java | 128 ++ .../test/scenarios/ScenarioPerformance2.java | 166 ++ target/classes/META-INF/MANIFEST.MF | 5 + .../maven/pt.ptcris/ptcrisync/pom.properties | 7 + .../maven/pt.ptcris/ptcrisync/pom.xml | 73 + 171 files changed, 29979 insertions(+) create mode 100644 .classpath create mode 100644 .project create mode 100644 .settings/org.eclipse.jdt.core.prefs create mode 100644 LICENSE.md create mode 100644 NOTES.md create mode 100644 README.md create mode 100644 _config.yml create mode 100644 docs/allclasses-frame.html create mode 100644 docs/allclasses-noframe.html create mode 100644 docs/constant-values.html create mode 100644 docs/deprecated-list.html create mode 100644 docs/help-doc.html create mode 100644 docs/index-files/index-1.html create mode 100644 docs/index-files/index-10.html create mode 100644 docs/index-files/index-11.html create mode 100644 docs/index-files/index-12.html create mode 100644 docs/index-files/index-13.html create mode 100644 docs/index-files/index-14.html create mode 100644 docs/index-files/index-15.html create mode 100644 docs/index-files/index-16.html create mode 100644 docs/index-files/index-2.html create mode 100644 docs/index-files/index-3.html create mode 100644 docs/index-files/index-4.html create mode 100644 docs/index-files/index-5.html create mode 100644 docs/index-files/index-6.html create mode 100644 docs/index-files/index-7.html create mode 100644 docs/index-files/index-8.html create mode 100644 docs/index-files/index-9.html create mode 100644 docs/index.html create mode 100644 docs/overview-frame.html create mode 100644 docs/overview-summary.html create mode 100644 docs/overview-tree.html create mode 100644 docs/package-list create mode 100644 docs/pt/ptcris/ORCIDClient.html create mode 100644 docs/pt/ptcris/ORCIDClientImpl.html create mode 100644 docs/pt/ptcris/PTCRISGrouper.html create mode 100644 docs/pt/ptcris/PTCRISync.html create mode 100644 docs/pt/ptcris/PTCRISyncResult.html create mode 100644 docs/pt/ptcris/TempORCIDClient.html create mode 100644 docs/pt/ptcris/class-use/ORCIDClient.html create mode 100644 docs/pt/ptcris/class-use/ORCIDClientImpl.html create mode 100644 docs/pt/ptcris/class-use/PTCRISGrouper.html create mode 100644 docs/pt/ptcris/class-use/PTCRISync.html create mode 100644 docs/pt/ptcris/class-use/PTCRISyncResult.html create mode 100644 docs/pt/ptcris/class-use/TempORCIDClient.html create mode 100644 docs/pt/ptcris/exceptions/InvalidActivityException.html create mode 100644 docs/pt/ptcris/exceptions/class-use/InvalidActivityException.html create mode 100644 docs/pt/ptcris/exceptions/package-frame.html create mode 100644 docs/pt/ptcris/exceptions/package-summary.html create mode 100644 docs/pt/ptcris/exceptions/package-tree.html create mode 100644 docs/pt/ptcris/exceptions/package-use.html create mode 100644 docs/pt/ptcris/grouper/ActivityComparator.html create mode 100644 docs/pt/ptcris/grouper/ActivityGroup.html create mode 100644 docs/pt/ptcris/grouper/GroupGenerator.html create mode 100644 docs/pt/ptcris/grouper/class-use/ActivityComparator.html create mode 100644 docs/pt/ptcris/grouper/class-use/ActivityGroup.html create mode 100644 docs/pt/ptcris/grouper/class-use/GroupGenerator.html create mode 100644 docs/pt/ptcris/grouper/package-frame.html create mode 100644 docs/pt/ptcris/grouper/package-summary.html create mode 100644 docs/pt/ptcris/grouper/package-tree.html create mode 100644 docs/pt/ptcris/grouper/package-use.html create mode 100644 docs/pt/ptcris/handlers/ProgressHandler.html create mode 100644 docs/pt/ptcris/handlers/class-use/ProgressHandler.html create mode 100644 docs/pt/ptcris/handlers/package-frame.html create mode 100644 docs/pt/ptcris/handlers/package-summary.html create mode 100644 docs/pt/ptcris/handlers/package-tree.html create mode 100644 docs/pt/ptcris/handlers/package-use.html create mode 100644 docs/pt/ptcris/package-frame.html create mode 100644 docs/pt/ptcris/package-summary.html create mode 100644 docs/pt/ptcris/package-tree.html create mode 100644 docs/pt/ptcris/package-use.html create mode 100644 docs/pt/ptcris/utils/ExternalIdsDiff.html create mode 100644 docs/pt/ptcris/utils/ORCIDFundingHelper.html create mode 100644 docs/pt/ptcris/utils/ORCIDHelper.html create mode 100644 docs/pt/ptcris/utils/ORCIDWorkHelper.html create mode 100644 docs/pt/ptcris/utils/UpdateRecord.html create mode 100644 docs/pt/ptcris/utils/class-use/ExternalIdsDiff.html create mode 100644 docs/pt/ptcris/utils/class-use/ORCIDFundingHelper.html create mode 100644 docs/pt/ptcris/utils/class-use/ORCIDHelper.html create mode 100644 docs/pt/ptcris/utils/class-use/ORCIDWorkHelper.html create mode 100644 docs/pt/ptcris/utils/class-use/UpdateRecord.html create mode 100644 docs/pt/ptcris/utils/package-frame.html create mode 100644 docs/pt/ptcris/utils/package-summary.html create mode 100644 docs/pt/ptcris/utils/package-tree.html create mode 100644 docs/pt/ptcris/utils/package-use.html create mode 100644 docs/script.js create mode 100644 docs/serialized-form.html create mode 100644 docs/stylesheet.css create mode 100644 pom.xml create mode 100644 src/main/java/pt/ptcris/ORCIDClient.java create mode 100644 src/main/java/pt/ptcris/ORCIDClientImpl.java create mode 100644 src/main/java/pt/ptcris/PTCRISGrouper.java create mode 100644 src/main/java/pt/ptcris/PTCRISync.java create mode 100644 src/main/java/pt/ptcris/PTCRISyncResult.java create mode 100644 src/main/java/pt/ptcris/TempORCIDClient.java create mode 100644 src/main/java/pt/ptcris/exceptions/InvalidActivityException.java create mode 100644 src/main/java/pt/ptcris/grouper/ActivityComparator.java create mode 100644 src/main/java/pt/ptcris/grouper/ActivityGroup.java create mode 100644 src/main/java/pt/ptcris/grouper/GroupGenerator.java create mode 100644 src/main/java/pt/ptcris/handlers/ProgressHandler.java create mode 100644 src/main/java/pt/ptcris/utils/ExternalIdsDiff.java create mode 100644 src/main/java/pt/ptcris/utils/ORCIDAddWorker.java create mode 100644 src/main/java/pt/ptcris/utils/ORCIDDelWorker.java create mode 100644 src/main/java/pt/ptcris/utils/ORCIDFundingHelper.java create mode 100644 src/main/java/pt/ptcris/utils/ORCIDGetBulkWorkWorker.java create mode 100644 src/main/java/pt/ptcris/utils/ORCIDGetFundingWorker.java create mode 100644 src/main/java/pt/ptcris/utils/ORCIDGetWorkWorker.java create mode 100644 src/main/java/pt/ptcris/utils/ORCIDHelper.java create mode 100644 src/main/java/pt/ptcris/utils/ORCIDUpdWorker.java create mode 100644 src/main/java/pt/ptcris/utils/ORCIDWorkHelper.java create mode 100644 src/main/java/pt/ptcris/utils/ORCIDWorker.java create mode 100644 src/main/java/pt/ptcris/utils/UpdateRecord.java create mode 100644 src/test/java/pt/ptcris/test/PTCRISExample.java create mode 100644 src/test/java/pt/ptcris/test/TestClients.java create mode 100644 src/test/java/pt/ptcris/test/TestHelper.java create mode 100644 src/test/java/pt/ptcris/test/Tester.java create mode 100644 src/test/java/pt/ptcris/test/grouper/GrouperTest.java create mode 100644 src/test/java/pt/ptcris/test/grouper/IntegerComparator.java create mode 100644 src/test/java/pt/ptcris/test/grouper/StdWorkComparator.java create mode 100644 src/test/java/pt/ptcris/test/scenarios/AllScenarios.java create mode 100644 src/test/java/pt/ptcris/test/scenarios/Scenario.java create mode 100644 src/test/java/pt/ptcris/test/scenarios/Scenario01.java create mode 100644 src/test/java/pt/ptcris/test/scenarios/Scenario02.java create mode 100644 src/test/java/pt/ptcris/test/scenarios/Scenario03.java create mode 100644 src/test/java/pt/ptcris/test/scenarios/Scenario04.java create mode 100644 src/test/java/pt/ptcris/test/scenarios/Scenario05.java create mode 100644 src/test/java/pt/ptcris/test/scenarios/Scenario06.java create mode 100644 src/test/java/pt/ptcris/test/scenarios/Scenario07.java create mode 100644 src/test/java/pt/ptcris/test/scenarios/Scenario08.java create mode 100644 src/test/java/pt/ptcris/test/scenarios/Scenario09.java create mode 100644 src/test/java/pt/ptcris/test/scenarios/Scenario10.java create mode 100644 src/test/java/pt/ptcris/test/scenarios/Scenario11.java create mode 100644 src/test/java/pt/ptcris/test/scenarios/Scenario12.java create mode 100644 src/test/java/pt/ptcris/test/scenarios/Scenario13.java create mode 100644 src/test/java/pt/ptcris/test/scenarios/Scenario14.java create mode 100644 src/test/java/pt/ptcris/test/scenarios/Scenario15.java create mode 100644 src/test/java/pt/ptcris/test/scenarios/Scenario16.java create mode 100644 src/test/java/pt/ptcris/test/scenarios/Scenario17.java create mode 100644 src/test/java/pt/ptcris/test/scenarios/Scenario18.java create mode 100644 src/test/java/pt/ptcris/test/scenarios/Scenario19.java create mode 100644 src/test/java/pt/ptcris/test/scenarios/Scenario20.java create mode 100644 src/test/java/pt/ptcris/test/scenarios/ScenarioF01.java create mode 100644 src/test/java/pt/ptcris/test/scenarios/ScenarioF02.java create mode 100644 src/test/java/pt/ptcris/test/scenarios/ScenarioF03.java create mode 100644 src/test/java/pt/ptcris/test/scenarios/ScenarioF04.java create mode 100644 src/test/java/pt/ptcris/test/scenarios/ScenarioF05.java create mode 100644 src/test/java/pt/ptcris/test/scenarios/ScenarioF06.java create mode 100644 src/test/java/pt/ptcris/test/scenarios/ScenarioF07.java create mode 100644 src/test/java/pt/ptcris/test/scenarios/ScenarioF08.java create mode 100644 src/test/java/pt/ptcris/test/scenarios/ScenarioF09.java create mode 100644 src/test/java/pt/ptcris/test/scenarios/ScenarioF10.java create mode 100644 src/test/java/pt/ptcris/test/scenarios/ScenarioF11.java create mode 100644 src/test/java/pt/ptcris/test/scenarios/ScenarioF12.java create mode 100644 src/test/java/pt/ptcris/test/scenarios/ScenarioF13.java create mode 100644 src/test/java/pt/ptcris/test/scenarios/ScenarioF14.java create mode 100644 src/test/java/pt/ptcris/test/scenarios/ScenarioF15.java create mode 100644 src/test/java/pt/ptcris/test/scenarios/ScenarioF16.java create mode 100644 src/test/java/pt/ptcris/test/scenarios/ScenarioF17.java create mode 100644 src/test/java/pt/ptcris/test/scenarios/ScenarioF18.java create mode 100644 src/test/java/pt/ptcris/test/scenarios/ScenarioF19.java create mode 100644 src/test/java/pt/ptcris/test/scenarios/ScenarioF20.java create mode 100644 src/test/java/pt/ptcris/test/scenarios/ScenarioFIgnoredTypes.java create mode 100644 src/test/java/pt/ptcris/test/scenarios/ScenarioFInvalidLocal.java create mode 100644 src/test/java/pt/ptcris/test/scenarios/ScenarioFunding.java create mode 100644 src/test/java/pt/ptcris/test/scenarios/ScenarioInvalidLocal1.java create mode 100644 src/test/java/pt/ptcris/test/scenarios/ScenarioInvalidLocal2.java create mode 100644 src/test/java/pt/ptcris/test/scenarios/ScenarioPerformance.java create mode 100644 src/test/java/pt/ptcris/test/scenarios/ScenarioPerformance2.java create mode 100644 target/classes/META-INF/MANIFEST.MF create mode 100644 target/classes/META-INF/maven/pt.ptcris/ptcrisync/pom.properties create mode 100644 target/classes/META-INF/maven/pt.ptcris/ptcrisync/pom.xml diff --git a/.classpath b/.classpath new file mode 100644 index 0000000..e474853 --- /dev/null +++ b/.classpath @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/.project b/.project new file mode 100644 index 0000000..13e7316 --- /dev/null +++ b/.project @@ -0,0 +1,37 @@ + + + ptcrisync-1.0 + + + + + + org.eclipse.wst.common.project.facet.core.builder + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.wst.validation.validationbuilder + + + + + org.eclipse.m2e.core.maven2Builder + + + + + + org.eclipse.jem.workbench.JavaEMFNature + org.eclipse.wst.common.modulecore.ModuleCoreNature + org.eclipse.m2e.core.maven2Nature + org.eclipse.jdt.core.javanature + com.jaspersoft.studio.babel.editor.rbeNature + org.eclipse.wst.common.project.facet.core.nature + + diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..ace45ce --- /dev/null +++ b/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,12 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/LICENSE.md b/LICENSE.md new file mode 100644 index 0000000..a488a8e --- /dev/null +++ b/LICENSE.md @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2017 FCT | FCCN - Computação Científica Nacional + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/NOTES.md b/NOTES.md new file mode 100644 index 0000000..7f067fe --- /dev/null +++ b/NOTES.md @@ -0,0 +1,24 @@ +Release Notes +============= + +### PTCRISync [1.0](https://github.com/fccn/PTCRISync/releases/tag/v1.0) (March, 2017) + +* Updates to support the ORCID API 2.0 +* Support for bulk getting and adding works +* New functionality: generic work grouper + +### PTCRISync [0.2](https://github.com/fccn/PTCRISync/releases/tag/v0.2) (December, 2016) + +* Updates to support the ORCID API 2.0rc2 + +### PTCRISync [0.1](https://github.com/fccn/PTCRISync/releases/tag/v0.1) (November, 2016) + +* Support for the synchronization of research productions (works) +* Support for the following synchronization procedures: + - Export local works + - Import novel remote works + - Import remote work updates + - Import invalid remote works + - Import novel remote work counter +* Built over the ORCID API 2.0rc1 +* Based on the PTCRISync specification v0.5 diff --git a/README.md b/README.md new file mode 100644 index 0000000..eb1e60b --- /dev/null +++ b/README.md @@ -0,0 +1,4 @@ +PTCRISync +============= + +This repository contains the source code for [PTCRISync](http://www.ptcris.pt), synchronization framework for a national CRIS ecosystems based on ORCID. Check out the [wiki](https://github.com/fccn/PTCRISync/wiki) for resources on how to start using PTCRISync and the [documentation](http://fccn.github.io/PTCRISync/) for more technical information. And don't hesitate to post us questions on our [google groups](https://groups.google.com/forum/#!forum/ptcrisync) or directly to the email: ptcrisync@googlegroups.com. diff --git a/_config.yml b/_config.yml new file mode 100644 index 0000000..c419263 --- /dev/null +++ b/_config.yml @@ -0,0 +1 @@ +theme: jekyll-theme-cayman \ No newline at end of file diff --git a/docs/allclasses-frame.html b/docs/allclasses-frame.html new file mode 100644 index 0000000..98faf3d --- /dev/null +++ b/docs/allclasses-frame.html @@ -0,0 +1,34 @@ + + + + + +All Classes + + + + + +

All Classes

+
+ +
+ + diff --git a/docs/allclasses-noframe.html b/docs/allclasses-noframe.html new file mode 100644 index 0000000..9648823 --- /dev/null +++ b/docs/allclasses-noframe.html @@ -0,0 +1,34 @@ + + + + + +All Classes + + + + + +

All Classes

+
+ +
+ + diff --git a/docs/constant-values.html b/docs/constant-values.html new file mode 100644 index 0000000..4f17bb1 --- /dev/null +++ b/docs/constant-values.html @@ -0,0 +1,258 @@ + + + + + +Constant Field Values + + + + + + + + +
+ + + + + + + +
+ + +
+

Constant Field Values

+

Contents

+ +
+
+ + +

pt.ptcris.*

+ + +
+ +
+ + + + + + + +
+ + + + diff --git a/docs/deprecated-list.html b/docs/deprecated-list.html new file mode 100644 index 0000000..ccc8d2e --- /dev/null +++ b/docs/deprecated-list.html @@ -0,0 +1,195 @@ + + + + + +Deprecated List + + + + + + + + +
+ + + + + + + +
+ + +
+

Deprecated API

+

Contents

+ +
+
+ + + + + + + +
+ +
+ + + + + + + +
+ + + + diff --git a/docs/help-doc.html b/docs/help-doc.html new file mode 100644 index 0000000..c544033 --- /dev/null +++ b/docs/help-doc.html @@ -0,0 +1,229 @@ + + + + + +API Help + + + + + + + + +
+ + + + + + + +
+ + +
+

How This API Document Is Organized

+
This API (Application Programming Interface) document has pages corresponding to the items in the navigation bar, described as follows.
+
+
+ +This help file applies to API documentation generated using the standard doclet.
+ +
+ + + + + + + +
+ + + + diff --git a/docs/index-files/index-1.html b/docs/index-files/index-1.html new file mode 100644 index 0000000..e4e59fb --- /dev/null +++ b/docs/index-files/index-1.html @@ -0,0 +1,173 @@ + + + + + +A-Index + + + + + + + + +
+ + + + + + + +
+ + +
A C D E F G H I L M O P R S T U  + + +

A

+
+
act - Variable in class pt.ptcris.PTCRISyncResult
+
 
+
ActivityComparator<A> - Class in pt.ptcris.grouper
+
+
An activity comparator used by the grouper to creates groups of matching + activities.
+
+
ActivityComparator() - Constructor for class pt.ptcris.grouper.ActivityComparator
+
 
+
ActivityGroup<A> - Class in pt.ptcris.grouper
+
+
Represents groups of matched activities.
+
+
add(List<E>, ProgressHandler) - Method in class pt.ptcris.utils.ORCIDHelper
+
+
Synchronously adds a list of activities to an ORCID profile, either + through atomic or bulk calls if available.
+
+
addFunding(Funding) - Method in interface pt.ptcris.ORCIDClient
+
+
Adds a new funding entry to the ORCID profile and returns the assigned + put-code.
+
+
addFunding(Funding) - Method in class pt.ptcris.ORCIDClientImpl
+
+
Adds a new funding entry to the ORCID profile and returns the assigned + put-code.
+
+
ADDOK - Static variable in class pt.ptcris.PTCRISyncResult
+
 
+
addWork(Work) - Method in interface pt.ptcris.ORCIDClient
+
+
Adds a new work to the ORCID profile and returns the assigned put-code.
+
+
addWork(Work) - Method in class pt.ptcris.ORCIDClientImpl
+
+
Adds a new work to the ORCID profile and returns the assigned put-code.
+
+
addWorks(List<Work>) - Method in interface pt.ptcris.ORCIDClient
+
+
Adds a list of new works to the ORCID profile.
+
+
addWorks(List<Work>) - Method in class pt.ptcris.ORCIDClientImpl
+
+
Adds a list of new works to the ORCID profile.
+
+
+A C D E F G H I L M O P R S T U 
+ +
+ + + + + + + +
+ + + + diff --git a/docs/index-files/index-10.html b/docs/index-files/index-10.html new file mode 100644 index 0000000..6f37810 --- /dev/null +++ b/docs/index-files/index-10.html @@ -0,0 +1,131 @@ + + + + + +M-Index + + + + + + + + +
+ + + + + + + +
+ + +
A C D E F G H I L M O P R S T U  + + +

M

+
+
more - Variable in class pt.ptcris.utils.ExternalIdsDiff
+
+
External identifiers inserted in the second set.
+
+
+A C D E F G H I L M O P R S T U 
+ +
+ + + + + + + +
+ + + + diff --git a/docs/index-files/index-11.html b/docs/index-files/index-11.html new file mode 100644 index 0000000..1cdbba9 --- /dev/null +++ b/docs/index-files/index-11.html @@ -0,0 +1,200 @@ + + + + + +O-Index + + + + + + + + +
+ + + + + + + +
+ + +
A C D E F G H I L M O P R S T U  + + +

O

+
+
ok_add(BigInteger) - Static method in class pt.ptcris.PTCRISyncResult
+
+
Creates a successful "add" message with the assigned put-code.
+
+
ok_del() - Static method in class pt.ptcris.PTCRISyncResult
+
+
Creates a successful "delete" message.
+
+
ok_get(BigInteger, E) - Static method in class pt.ptcris.PTCRISyncResult
+
+
Creates a successful "get" message with the assigned put-code.
+
+
ok_upd() - Static method in class pt.ptcris.PTCRISyncResult
+
+
Creates a successful "update" message.
+
+
ORCIDClient - Interface in pt.ptcris
+
+
Interface that encapsulates the communication with the ORCID client for a + specified user profile.
+
+
ORCIDClientImpl - Class in pt.ptcris
+
+
An implementation of the ORCID client interface built over the + Degois client.
+
+
ORCIDClientImpl(String, String, String, String, String, OrcidAccessToken, int) - Constructor for class pt.ptcris.ORCIDClientImpl
+
+
Instantiates an ORCID client to communicate with the ORCID API.
+
+
ORCIDClientImpl(String, String, String, String, String, OrcidAccessToken) - Constructor for class pt.ptcris.ORCIDClientImpl
+
+
Instantiates an ORCID client to communicate with the ORCID API.
+
+
ORCIDClientImpl(String, String, String, String, String, OrcidAccessToken, boolean) - Constructor for class pt.ptcris.ORCIDClientImpl
+
+
Instantiates an ORCID client to communicate with the ORCID API.
+
+
ORCIDClientImpl(String, String, String, String, String, OrcidAccessToken, boolean, int) - Constructor for class pt.ptcris.ORCIDClientImpl
+
+
Instantiates an ORCID client to communicate with the ORCID API.
+
+
ORCIDFundingHelper - Class in pt.ptcris.utils
+
+
An helper to simplify the use of the low-level ORCID + client.
+
+
ORCIDFundingHelper(ORCIDClient) - Constructor for class pt.ptcris.utils.ORCIDFundingHelper
+
+
Initializes the helper with a given ORCID client.
+
+
ORCIDHelper<E extends org.um.dsi.gavea.orcid.model.common.ElementSummary,S extends org.um.dsi.gavea.orcid.model.common.ElementSummary,G,T extends java.lang.Enum<T>> - Class in pt.ptcris.utils
+
+
An abstract helper to help manage ORCID activities and simplify the usage of + the low-level ORCID client.
+
+
ORCIDHelper(ORCIDClient, int, int) - Constructor for class pt.ptcris.utils.ORCIDHelper
+
+
Initializes the helper with a given ORCID client, which defines whether + asynchronous calls will be performed, and sets whether bulk ORCID + commands are available and with which size.
+
+
ORCIDWorkHelper - Class in pt.ptcris.utils
+
+
An helper to simplify the use of the low-level ORCID + client.
+
+
ORCIDWorkHelper(ORCIDClient) - Constructor for class pt.ptcris.utils.ORCIDWorkHelper
+
+
Initializes the helper with a given ORCID client.
+
+
OVERLAPPING_EIDs - Static variable in class pt.ptcris.utils.ORCIDHelper
+
 
+
+A C D E F G H I L M O P R S T U 
+ +
+ + + + + + + +
+ + + + diff --git a/docs/index-files/index-12.html b/docs/index-files/index-12.html new file mode 100644 index 0000000..aaf303b --- /dev/null +++ b/docs/index-files/index-12.html @@ -0,0 +1,166 @@ + + + + + +P-Index + + + + + + + + +
+ + + + + + + +
+ + +
A C D E F G H I L M O P R S T U  + + +

P

+
+
posElement - Variable in class pt.ptcris.utils.UpdateRecord
+
 
+
preElement - Variable in class pt.ptcris.utils.UpdateRecord
+
 
+
ProgressHandler - Interface in pt.ptcris.handlers
+
+
An interface for reporting the progress of the synchronization procedures and + the comprising tasks.
+
+
pt.ptcris.exceptions - package pt.ptcris.exceptions
+
 
+
pt.ptcris.grouper - package pt.ptcris.grouper
+
 
+
pt.ptcris.handlers - package pt.ptcris.handlers
+
 
+
pt.ptcris.utils - package pt.ptcris.utils
+
 
+
PTCRISGrouper - Class in pt.ptcris
+
+
+ A generic activity grouper for the PTCRIS framework.
+
+
PTCRISGrouper() - Constructor for class pt.ptcris.PTCRISGrouper
+
 
+
PTCRISync - Class in pt.ptcris
+
+
+ An implementation of the PTCRISync synchronization service based on the + version 0.4.3 of the specification, enhanced with minimal quality criteria.
+
+
PTCRISync() - Constructor for class pt.ptcris.PTCRISync
+
 
+
PTCRISyncResult<E extends org.um.dsi.gavea.orcid.model.common.ElementSummary> - Class in pt.ptcris
+
+
A class that encapsulates the result of the synchronization procedures for a + particular activity.
+
+
putcode - Variable in class pt.ptcris.PTCRISyncResult
+
 
+
+A C D E F G H I L M O P R S T U 
+ +
+ + + + + + + +
+ + + + diff --git a/docs/index-files/index-13.html b/docs/index-files/index-13.html new file mode 100644 index 0000000..7820250 --- /dev/null +++ b/docs/index-files/index-13.html @@ -0,0 +1,131 @@ + + + + + +R-Index + + + + + + + + +
+ + + + + + + +
+ + +
A C D E F G H I L M O P R S T U  + + +

R

+
+
readFundingsSummary(OrcidAccessToken) - Method in class pt.ptcris.TempORCIDClient
+
+
Deprecated.
+
+A C D E F G H I L M O P R S T U 
+ +
+ + + + + + + +
+ + + + diff --git a/docs/index-files/index-14.html b/docs/index-files/index-14.html new file mode 100644 index 0000000..804a417 --- /dev/null +++ b/docs/index-files/index-14.html @@ -0,0 +1,173 @@ + + + + + +S-Index + + + + + + + + +
+ + + + + + + +
+ + +
A C D E F G H I L M O P R S T U  + + +

S

+
+
same - Variable in class pt.ptcris.utils.ExternalIdsDiff
+
+
External identifiers preserved in both sets.
+
+
sendError(String) - Method in interface pt.ptcris.handlers.ProgressHandler
+
+
Used to send an error message to the progress handler
+
+
setCurrentStatus(String) - Method in interface pt.ptcris.handlers.ProgressHandler
+
+
Used to set the text of the current task
+
+
setCurrentStatus(String, int) - Method in interface pt.ptcris.handlers.ProgressHandler
+
 
+
setExternalIdsE(Funding, ExternalIds) - Method in class pt.ptcris.utils.ORCIDFundingHelper
+
+
Assigns a set of external identifiers to an activity.
+
+
setExternalIdsE(E, ExternalIds) - Method in class pt.ptcris.utils.ORCIDHelper
+
+
Assigns a set of external identifiers to an activity.
+
+
setExternalIdsE(Work, ExternalIds) - Method in class pt.ptcris.utils.ORCIDWorkHelper
+
+
Assigns a set of external identifiers to an activity.
+
+
setExternalIdsS(FundingSummary, ExternalIds) - Method in class pt.ptcris.utils.ORCIDFundingHelper
+
+
Assigns a set of external identifiers to an activity summary.
+
+
setExternalIdsS(S, ExternalIds) - Method in class pt.ptcris.utils.ORCIDHelper
+
+
Assigns a set of external identifiers to an activity summary.
+
+
setExternalIdsS(WorkSummary, ExternalIds) - Method in class pt.ptcris.utils.ORCIDWorkHelper
+
+
Assigns a set of external identifiers to an activity summary.
+
+
setProgress(int) - Method in interface pt.ptcris.handlers.ProgressHandler
+
+
Deprecated.
+
+
step() - Method in interface pt.ptcris.handlers.ProgressHandler
+
 
+
step(int) - Method in interface pt.ptcris.handlers.ProgressHandler
+
 
+
+A C D E F G H I L M O P R S T U 
+ +
+ + + + + + + +
+ + + + diff --git a/docs/index-files/index-15.html b/docs/index-files/index-15.html new file mode 100644 index 0000000..d5f1b5d --- /dev/null +++ b/docs/index-files/index-15.html @@ -0,0 +1,164 @@ + + + + + +T-Index + + + + + + + + +
+ + + + + + + +
+ + +
A C D E F G H I L M O P R S T U  + + +

T

+
+
TempORCIDClient - Class in pt.ptcris
+
+
Deprecated. +
temporary class to be deleted once readFundingsSummary is added to the + ORCID client.
+
+
+
TempORCIDClient(String, String, String, String, String, boolean) - Constructor for class pt.ptcris.TempORCIDClient
+
+
Deprecated.
+
testMinimalQuality(S) - Method in class pt.ptcris.utils.ORCIDHelper
+
+
Tests whether an activity summary has minimal quality to be synchronized, + by inspecting its meta-data and that of coexisting activities, and + returns the detected invalid fields.
+
+
threads() - Method in interface pt.ptcris.ORCIDClient
+
+
The number of worker threads that will be used to communicate with the + ORCID API.
+
+
threads() - Method in class pt.ptcris.ORCIDClientImpl
+
+
The number of worker threads that will be used to communicate with the + ORCID API.
+
+
threshold() - Method in class pt.ptcris.grouper.ActivityComparator
+
+
A (non-inclusive) threshold on the similarity metric that defines + matching activities.
+
+
tryMinimalQualityE(E, Collection<E>) - Method in class pt.ptcris.utils.ORCIDHelper
+
+
Tests whether an activity has minimal quality to be synchronized, by + inspecting its meta-data.
+
+
+A C D E F G H I L M O P R S T U 
+ +
+ + + + + + + +
+ + + + diff --git a/docs/index-files/index-16.html b/docs/index-files/index-16.html new file mode 100644 index 0000000..00a9eb4 --- /dev/null +++ b/docs/index-files/index-16.html @@ -0,0 +1,165 @@ + + + + + +U-Index + + + + + + + + +
+ + + + + + + +
+ + +
A C D E F G H I L M O P R S T U  + + +

U

+
+
update(BigInteger, E) - Method in class pt.ptcris.utils.ORCIDHelper
+
+
Synchronously updates an activity to an ORCID profile.
+
+
updateFunding(BigInteger, Funding) - Method in interface pt.ptcris.ORCIDClient
+
+
Updates a funding entry in the ORCID profile.
+
+
updateFunding(BigInteger, Funding) - Method in class pt.ptcris.ORCIDClientImpl
+
+
Updates a funding entry in the ORCID profile.
+
+
UPDATEOK - Static variable in class pt.ptcris.PTCRISyncResult
+
 
+
UpdateRecord<E extends org.um.dsi.gavea.orcid.model.common.ElementSummary,S extends org.um.dsi.gavea.orcid.model.common.ElementSummary> - Class in pt.ptcris.utils
+
+
An helper class that stores two versions of the same activity, as well as the difference between their + external identifiers.
+
+
UpdateRecord(E, S, ExternalIdsDiff) - Constructor for class pt.ptcris.utils.UpdateRecord
+
+
Constructs an object containing two versions of an activity and the + difference between their external identifiers.
+
+
updateWork(BigInteger, Work) - Method in interface pt.ptcris.ORCIDClient
+
+
Updates a work in the ORCID profile.
+
+
updateWork(BigInteger, Work) - Method in class pt.ptcris.ORCIDClientImpl
+
+
Updates a work in the ORCID profile.
+
+
UPTODATE - Static variable in class pt.ptcris.PTCRISyncResult
+
 
+
uptodate() - Static method in class pt.ptcris.PTCRISyncResult
+
+
Creates an "already up-to-date" message.
+
+
+A C D E F G H I L M O P R S T U 
+ +
+ + + + + + + +
+ + + + diff --git a/docs/index-files/index-2.html b/docs/index-files/index-2.html new file mode 100644 index 0000000..ec3c21b --- /dev/null +++ b/docs/index-files/index-2.html @@ -0,0 +1,172 @@ + + + + + +C-Index + + + + + + + + +
+ + + + + + + +
+ + +
A C D E F G H I L M O P R S T U  + + +

C

+
+
cleanWorkLocalKey(ElementSummary) - Static method in class pt.ptcris.utils.ORCIDHelper
+
+
Clears (sets to null) the local key of an activity, currently assumed to + be stored in the put-code field.
+
+
client - Variable in class pt.ptcris.utils.ORCIDHelper
+
+
The client used to communicate with ORCID.
+
+
CLIENTERROR - Static variable in class pt.ptcris.PTCRISyncResult
+
 
+
cloneE(Funding) - Method in class pt.ptcris.utils.ORCIDFundingHelper
+
+
Clones an activity.
+
+
cloneE(Work) - Method in class pt.ptcris.utils.ORCIDWorkHelper
+
+
Clones an activity.
+
+
cloneS(FundingSummary) - Method in class pt.ptcris.utils.ORCIDFundingHelper
+
+
Clones an activity summary.
+
+
cloneS(WorkSummary) - Method in class pt.ptcris.utils.ORCIDWorkHelper
+
+
Clones an activity summary.
+
+
code - Variable in class pt.ptcris.PTCRISyncResult
+
 
+
compare(A, A) - Method in class pt.ptcris.grouper.ActivityComparator
+
+
Calculates a similarity metric between two activities.
+
+
createUpdate(Funding, ExternalIdsDiff) - Method in class pt.ptcris.utils.ORCIDFundingHelper
+
+
Creates an update to an activity given the difference on meta-data.
+
+
createUpdate(E, ExternalIdsDiff) - Method in class pt.ptcris.utils.ORCIDHelper
+
+
Creates an update to an activity given the difference on meta-data.
+
+
createUpdate(Work, ExternalIdsDiff) - Method in class pt.ptcris.utils.ORCIDWorkHelper
+
+
Creates an update to an activity given the difference on meta-data.
+
+
+A C D E F G H I L M O P R S T U 
+ +
+ + + + + + + +
+ + + + diff --git a/docs/index-files/index-3.html b/docs/index-files/index-3.html new file mode 100644 index 0000000..cf06447 --- /dev/null +++ b/docs/index-files/index-3.html @@ -0,0 +1,158 @@ + + + + + +D-Index + + + + + + + + +
+ + + + + + + +
+ + +
A C D E F G H I L M O P R S T U  + + +

D

+
+
delete(BigInteger) - Method in class pt.ptcris.utils.ORCIDHelper
+
+
Synchronously deletes an activity from an ORCID profile.
+
+
deleteAllSourced() - Method in class pt.ptcris.utils.ORCIDHelper
+
+
Deletes the entire set of activity summaries in the ORCID profile whose + source is the Member API id defined in the ORCID client.
+
+
deleteFunding(BigInteger) - Method in interface pt.ptcris.ORCIDClient
+
+
Deletes a funding entry from the ORCID profile.
+
+
deleteFunding(BigInteger) - Method in class pt.ptcris.ORCIDClientImpl
+
+
Deletes a funding entry from the ORCID profile.
+
+
DELETEOK - Static variable in class pt.ptcris.PTCRISyncResult
+
 
+
deleteWork(BigInteger) - Method in interface pt.ptcris.ORCIDClient
+
+
Deletes a work from the ORCID profile.
+
+
deleteWork(BigInteger) - Method in class pt.ptcris.ORCIDClientImpl
+
+
Deletes a work from the ORCID profile.
+
+
done() - Method in interface pt.ptcris.handlers.ProgressHandler
+
+
Used to set the current task as finalized
+
+
+A C D E F G H I L M O P R S T U 
+ +
+ + + + + + + +
+ + + + diff --git a/docs/index-files/index-4.html b/docs/index-files/index-4.html new file mode 100644 index 0000000..91f08f7 --- /dev/null +++ b/docs/index-files/index-4.html @@ -0,0 +1,171 @@ + + + + + +E-Index + + + + + + + + +
+ + + + + + + +
+ + +
A C D E F G H I L M O P R S T U  + + +

E

+
+
eidsDiff - Variable in class pt.ptcris.utils.UpdateRecord
+
 
+
exception - Variable in class pt.ptcris.PTCRISyncResult
+
 
+
export(ORCIDClient, List<Work>, ProgressHandler) - Static method in class pt.ptcris.PTCRISync
+
+ +
+
exportForce(ORCIDClient, List<Work>, ProgressHandler) - Static method in class pt.ptcris.PTCRISync
+
+ +
+
exportFundings(ORCIDClient, List<Funding>, Collection<FundingType>, ProgressHandler) - Static method in class pt.ptcris.PTCRISync
+
+
+ Exports a list of local CRIS funding entries to an ORCID profile and + keeps them up-to-date.
+
+
exportWorks(ORCIDClient, List<Work>, ProgressHandler) - Static method in class pt.ptcris.PTCRISync
+
+
+ Exports a list of local CRIS productions to an ORCID profile and keeps + them up-to-date.
+
+
exportWorksForced(ORCIDClient, List<Work>, ProgressHandler) - Static method in class pt.ptcris.PTCRISync
+
+
+ Exports a list of local CRIS productions to an ORCID profile and keeps + them up-to-date.
+
+
ExternalIdsDiff - Class in pt.ptcris.utils
+
+
Calculates and stores the symmetric difference between two sets of + external identifiers.
+
+
ExternalIdsDiff(ExternalIds, ExternalIds) - Constructor for class pt.ptcris.utils.ExternalIdsDiff
+
+
Calculates and stores the symmetric difference between two sets of + external identifiers.
+
+
+A C D E F G H I L M O P R S T U 
+ +
+ + + + + + + +
+ + + + diff --git a/docs/index-files/index-5.html b/docs/index-files/index-5.html new file mode 100644 index 0000000..540671f --- /dev/null +++ b/docs/index-files/index-5.html @@ -0,0 +1,141 @@ + + + + + +F-Index + + + + + + + + +
+ + + + + + + +
+ + +
A C D E F G H I L M O P R S T U  + + +

F

+
+
factoryStaticFundings() - Static method in class pt.ptcris.utils.ORCIDHelper
+
+
Creates a static (i.e., no server connection) ORCID helper to manage + funding activities.
+
+
factoryStaticWorks() - Static method in class pt.ptcris.utils.ORCIDHelper
+
+
Creates a static (i.e., no server connection) ORCID helper to manage work + activities.
+
+
fail(OrcidClientException) - Static method in class pt.ptcris.PTCRISyncResult
+
+
Creates message reporting a failure at the ORCID API level.
+
+
+A C D E F G H I L M O P R S T U 
+ +
+ + + + + + + +
+ + + + diff --git a/docs/index-files/index-6.html b/docs/index-files/index-6.html new file mode 100644 index 0000000..3135874 --- /dev/null +++ b/docs/index-files/index-6.html @@ -0,0 +1,302 @@ + + + + + +G-Index + + + + + + + + +
+ + + + + + + +
+ + +
A C D E F G H I L M O P R S T U  + + +

G

+
+
getActivitiesSummary() - Method in interface pt.ptcris.ORCIDClient
+
+
Retrieves every activity summary from the ORCID profile.
+
+
getActivitiesSummary() - Method in class pt.ptcris.ORCIDClientImpl
+
+
Retrieves every activity summary from the ORCID profile.
+
+
getActivityLocalKey(ElementSummary) - Static method in class pt.ptcris.utils.ORCIDHelper
+
+
Retrieves the local key of an activity, currently assumed to be stored in + the put-code field.
+
+
getActivityLocalKey(ElementSummary, BigInteger) - Static method in class pt.ptcris.utils.ORCIDHelper
+
+
Retrieves the local key of an activity, currently assumed to be stored in + the put-code field.
+
+
getAllTypedSummaries(Collection<T>) - Method in class pt.ptcris.utils.ORCIDHelper
+
+
Retrieves the entire set of activity summaries of given types from the + set ORCID profile that have at least an external identifier set.
+
+
getClientId() - Method in interface pt.ptcris.ORCIDClient
+
+
Returns the Member API client id that will commit the changes (i.e., the + works' source).
+
+
getClientId() - Method in class pt.ptcris.ORCIDClientImpl
+
+
Returns the Member API client id that will commit the changes (i.e., the + works' source).
+
+
getFulls(List<S>, Map<BigInteger, PTCRISyncResult<E>>, ProgressHandler) - Method in class pt.ptcris.utils.ORCIDHelper
+
+
Reads a full ORCID activity from an ORCID profile and adds it to a + callback map.
+
+
getFunding(FundingSummary) - Method in interface pt.ptcris.ORCIDClient
+
+
Retrieves a complete funding entry from the ORCID profile (as opposed to + only its summary).
+
+
getFunding(FundingSummary) - Method in class pt.ptcris.ORCIDClientImpl
+
+
Retrieves a complete funding entry from the ORCID profile (as opposed to + only its summary).
+
+
getFundingsSummary() - Method in interface pt.ptcris.ORCIDClient
+
+
Retrieves every funding summary from the ORCID profile.
+
+
getFundingsSummary() - Method in class pt.ptcris.ORCIDClientImpl
+
+
Retrieves every funding summary from the ORCID profile.
+
+
getGroups() - Method in class pt.ptcris.grouper.GroupGenerator
+
+
The activity groups generated so far.
+
+
getInvalidTypes() - Method in exception pt.ptcris.exceptions.InvalidActivityException
+
 
+
getNonNullExternalIdsE(Funding) - Method in class pt.ptcris.utils.ORCIDFundingHelper
+
+
Returns the non-null external identifiers of an activity (null becomes + empty list).
+
+
getNonNullExternalIdsE(E) - Method in class pt.ptcris.utils.ORCIDHelper
+
+
Returns the non-null external identifiers of an activity (null becomes + empty list).
+
+
getNonNullExternalIdsE(Work) - Method in class pt.ptcris.utils.ORCIDWorkHelper
+
+
Returns the non-null external identifiers of an activity (null becomes + empty list).
+
+
getNonNullExternalIdsS(FundingSummary) - Method in class pt.ptcris.utils.ORCIDFundingHelper
+
+
Returns the non-null external identifiers of an activity summary (null + becomes empty list).
+
+
getNonNullExternalIdsS(S) - Method in class pt.ptcris.utils.ORCIDHelper
+
+
Returns the non-null external identifiers of an activity summary (null + becomes empty list).
+
+
getNonNullExternalIdsS(WorkSummary) - Method in class pt.ptcris.utils.ORCIDWorkHelper
+
+
Returns the non-null external identifiers of an activity summary (null + becomes empty list).
+
+
GETOK - Static variable in class pt.ptcris.PTCRISyncResult
+
 
+
getPartOfExternalIdsE(E) - Method in class pt.ptcris.utils.ORCIDHelper
+
+
Returns the non-null part-of external identifiers of an activity (null + becomes empty list).
+
+
getSelfExternalIdsDiffS(S, Collection<E>) - Method in class pt.ptcris.utils.ORCIDHelper
+
+
Calculates the symmetric difference of self external + identifiers between an activity summary and a set of activities.
+
+
getSelfExternalIdsE(E) - Method in class pt.ptcris.utils.ORCIDHelper
+
+
Returns the non-null self external identifiers of an activity (null + becomes empty list).
+
+
getSourcedSummaries() - Method in class pt.ptcris.utils.ORCIDHelper
+
+
Retrieves the entire set (i.e., not merged) of activity summaries in the + ORCID profile whose source is the Member API id defined in the ORCID + client.
+
+
getTypeE(E) - Method in class pt.ptcris.utils.ORCIDHelper
+
+
Retrieves the type of an activity.
+
+
getUserId() - Method in interface pt.ptcris.ORCIDClient
+
+
Returns the user ORCID to whose profiles the changes will be commited.
+
+
getUserId() - Method in class pt.ptcris.ORCIDClientImpl
+
+
Returns the user ORCID to whose profiles the changes will be commited.
+
+
getWork(WorkSummary) - Method in interface pt.ptcris.ORCIDClient
+
+
Retrieves a complete work from the ORCID profile (as opposed to only its + summary).
+
+
getWork(WorkSummary) - Method in class pt.ptcris.ORCIDClientImpl
+
+
Retrieves a complete work from the ORCID profile (as opposed to only its + summary).
+
+
getWorks(List<WorkSummary>) - Method in interface pt.ptcris.ORCIDClient
+
+
Retrieves a list of complete work from the ORCID profile (as opposed to + only their summaries).
+
+
getWorks(List<WorkSummary>) - Method in class pt.ptcris.ORCIDClientImpl
+
+
Retrieves a list of complete work from the ORCID profile (as opposed to + only their summaries).
+
+
getWorksSummary() - Method in interface pt.ptcris.ORCIDClient
+
+
Retrieves every work summary from the ORCID profile.
+
+
getWorksSummary() - Method in class pt.ptcris.ORCIDClientImpl
+
+
Retrieves every work summary from the ORCID profile.
+
+
group(E) - Method in class pt.ptcris.grouper.GroupGenerator
+
+
Adds an activity with the already existing groups.
+
+
group(Collection<E>, ActivityComparator<E>) - Static method in class pt.ptcris.PTCRISGrouper
+
+
Groups a list of local activities into groups of matching activities, + according to the provided comparator.
+
+
GroupGenerator<E> - Class in pt.ptcris.grouper
+
+
A generator that, provided the concrete activity + comparator iteratively groups works that are below the threshold as + activity groups.
+
+
GroupGenerator(ActivityComparator<E>) - Constructor for class pt.ptcris.grouper.GroupGenerator
+
+
Creates a new activity group generator, provided a comparator that will + determine whether activities match.
+
+
+A C D E F G H I L M O P R S T U 
+ +
+ + + + + + + +
+ + + + diff --git a/docs/index-files/index-7.html b/docs/index-files/index-7.html new file mode 100644 index 0000000..956ab19 --- /dev/null +++ b/docs/index-files/index-7.html @@ -0,0 +1,132 @@ + + + + + +H-Index + + + + + + + + +
+ + + + + + + +
+ + +
A C D E F G H I L M O P R S T U  + + +

H

+
+
hasNewSelfIDs(E, S) - Method in class pt.ptcris.utils.ORCIDHelper
+
+
Checks whether an activity is already up to date regarding another one + regarding self external identifiers.
+
+
+A C D E F G H I L M O P R S T U 
+ +
+ + + + + + + +
+ + + + diff --git a/docs/index-files/index-8.html b/docs/index-files/index-8.html new file mode 100644 index 0000000..facf96d --- /dev/null +++ b/docs/index-files/index-8.html @@ -0,0 +1,246 @@ + + + + + +I-Index + + + + + + + + +
+ + + + + + + +
+ + +
A C D E F G H I L M O P R S T U  + + +

I

+
+
importCounter(ORCIDClient, List<Work>, ProgressHandler) - Static method in class pt.ptcris.PTCRISync
+
+ +
+
importFundingCounter(ORCIDClient, List<Funding>, Collection<FundingType>, ProgressHandler) - Static method in class pt.ptcris.PTCRISync
+
+
+ Counts new valid funding activities in an ORCID profile given a set of + known local CRIS funding entries, following the criteria of + PTCRISync.importFundings(ORCIDClient, List, Collection, ProgressHandler) + but is more efficient, generating less API calls.
+
+
importFundings(ORCIDClient, List<Funding>, Collection<FundingType>, ProgressHandler) - Static method in class pt.ptcris.PTCRISync
+
+
+ Discovers new valid funding activities in an ORCID profile given a set of + known local CRIS funding entries.
+
+
importFundingUpdates(ORCIDClient, List<Funding>, Collection<FundingType>, ProgressHandler) - Static method in class pt.ptcris.PTCRISync
+
+
+ Discovers updates to existing local CRIS funding activities in an ORCID + profile.
+
+
importInvalid(ORCIDClient, List<Work>, ProgressHandler) - Static method in class pt.ptcris.PTCRISync
+
+ +
+
importInvalidFundings(ORCIDClient, List<Funding>, Collection<FundingType>, ProgressHandler) - Static method in class pt.ptcris.PTCRISync
+
+
+ Discovers new invalid funding activities (that do not pass the quality + criteria, see + ORCIDHelper.testMinimalQuality(ElementSummary)) in an + ORCID profile given a set of known local CRIS entries, as well as the + causes for invalidity (defined at ORCIDFundingHelper).
+
+
importInvalidWorks(ORCIDClient, List<Work>, ProgressHandler) - Static method in class pt.ptcris.PTCRISync
+
+
+ Discovers new invalid works (that do not pass the quality criteria, see + ORCIDHelper.testMinimalQuality(ElementSummary)) in an ORCID + profile given a set of known local CRIS entries, as well as the causes + for invalidity (defined at ORCIDWorkHelper).
+
+
importUpdates(ORCIDClient, List<Work>, ProgressHandler) - Static method in class pt.ptcris.PTCRISync
+
+ +
+
importWorkCounter(ORCIDClient, List<Work>, ProgressHandler) - Static method in class pt.ptcris.PTCRISync
+
+
+ Counts new valid works in an ORCID profile given a set of + known local CRIS productions, following the criteria of + PTCRISync.importWorks(ORCIDClient, List, ProgressHandler) + but is more efficient, generating less API calls.
+
+
importWorks(ORCIDClient, List<Work>, ProgressHandler) - Static method in class pt.ptcris.PTCRISync
+
+
+ Discovers new valid works in an ORCID profile given a set of known local + CRIS productions.
+
+
importWorkUpdates(ORCIDClient, List<Work>, ProgressHandler) - Static method in class pt.ptcris.PTCRISync
+
+
+ Discovers updates to existing local CRIS productions in an ORCID + profile.
+
+
INVALID - Static variable in class pt.ptcris.PTCRISyncResult
+
 
+
invalid(InvalidActivityException) - Static method in class pt.ptcris.PTCRISyncResult
+
+
Creates message reporting an invalid activity.
+
+
INVALID_EXTERNALIDENTIFIERS - Static variable in class pt.ptcris.utils.ORCIDHelper
+
 
+
INVALID_ORGANIZATION - Static variable in class pt.ptcris.utils.ORCIDHelper
+
 
+
INVALID_PUBLICATIONDATE - Static variable in class pt.ptcris.utils.ORCIDHelper
+
 
+
INVALID_TITLE - Static variable in class pt.ptcris.utils.ORCIDHelper
+
 
+
INVALID_TYPE - Static variable in class pt.ptcris.utils.ORCIDHelper
+
 
+
INVALID_YEAR - Static variable in class pt.ptcris.utils.ORCIDHelper
+
 
+
InvalidActivityException - Exception in pt.ptcris.exceptions
+
 
+
InvalidActivityException() - Constructor for exception pt.ptcris.exceptions.InvalidActivityException
+
 
+
InvalidActivityException(String) - Constructor for exception pt.ptcris.exceptions.InvalidActivityException
+
 
+
InvalidActivityException(Throwable) - Constructor for exception pt.ptcris.exceptions.InvalidActivityException
+
 
+
InvalidActivityException(String, Throwable) - Constructor for exception pt.ptcris.exceptions.InvalidActivityException
+
 
+
InvalidActivityException(Set<String>) - Constructor for exception pt.ptcris.exceptions.InvalidActivityException
+
 
+
isUpToDateE(E, E) - Method in class pt.ptcris.utils.ORCIDHelper
+
+
Checks whether an activity is already up to date regarding another one, + considering the self external identifiers and + additional meta-data.
+
+
isUpToDateS(E, S) - Method in class pt.ptcris.utils.ORCIDHelper
+
+
Checks whether an activity is already up to date regarding another one, + considering the self external identifiers and + additional meta-data.
+
+
+A C D E F G H I L M O P R S T U 
+ +
+ + + + + + + +
+ + + + diff --git a/docs/index-files/index-9.html b/docs/index-files/index-9.html new file mode 100644 index 0000000..fef97ae --- /dev/null +++ b/docs/index-files/index-9.html @@ -0,0 +1,131 @@ + + + + + +L-Index + + + + + + + + +
+ + + + + + + +
+ + +
A C D E F G H I L M O P R S T U  + + +

L

+
+
less - Variable in class pt.ptcris.utils.ExternalIdsDiff
+
+
External identifiers removed from the first set.
+
+
+A C D E F G H I L M O P R S T U 
+ +
+ + + + + + + +
+ + + + diff --git a/docs/index.html b/docs/index.html new file mode 100644 index 0000000..7ed7f4b --- /dev/null +++ b/docs/index.html @@ -0,0 +1,74 @@ + + + + + +Generated Documentation (Untitled) + + + + + + + + + +<noscript> +<div>JavaScript is disabled on your browser.</div> +</noscript> +<h2>Frame Alert</h2> +<p>This document is designed to be viewed using the frames feature. If you see this message, you are using a non-frame-capable web client. Link to <a href="overview-summary.html">Non-frame version</a>.</p> + + + diff --git a/docs/overview-frame.html b/docs/overview-frame.html new file mode 100644 index 0000000..50148e0 --- /dev/null +++ b/docs/overview-frame.html @@ -0,0 +1,25 @@ + + + + + +Overview List + + + + + +
All Classes
+
+

Packages

+ +
+

 

+ + diff --git a/docs/overview-summary.html b/docs/overview-summary.html new file mode 100644 index 0000000..2728fbe --- /dev/null +++ b/docs/overview-summary.html @@ -0,0 +1,151 @@ + + + + + +Overview + + + + + + + + +
+ + + + + + + +
+ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Packages 
PackageDescription
pt.ptcris 
pt.ptcris.exceptions 
pt.ptcris.grouper 
pt.ptcris.handlers 
pt.ptcris.utils 
+
+ +
+ + + + + + + +
+ + + + diff --git a/docs/overview-tree.html b/docs/overview-tree.html new file mode 100644 index 0000000..bd66310 --- /dev/null +++ b/docs/overview-tree.html @@ -0,0 +1,178 @@ + + + + + +Class Hierarchy + + + + + + + + +
+ + + + + + + +
+ + +
+

Hierarchy For All Packages

+Package Hierarchies: + +
+
+

Class Hierarchy

+ +

Interface Hierarchy

+ +
+ +
+ + + + + + + +
+ + + + diff --git a/docs/package-list b/docs/package-list new file mode 100644 index 0000000..f538e4c --- /dev/null +++ b/docs/package-list @@ -0,0 +1,5 @@ +pt.ptcris +pt.ptcris.exceptions +pt.ptcris.grouper +pt.ptcris.handlers +pt.ptcris.utils diff --git a/docs/pt/ptcris/ORCIDClient.html b/docs/pt/ptcris/ORCIDClient.html new file mode 100644 index 0000000..5965159 --- /dev/null +++ b/docs/pt/ptcris/ORCIDClient.html @@ -0,0 +1,593 @@ + + + + + +ORCIDClient + + + + + + + + +
+ + + + + + + +
+ + + +
+
pt.ptcris
+

Interface ORCIDClient

+
+
+
+
    +
  • +
    +
    All Known Implementing Classes:
    +
    ORCIDClientImpl
    +
    +
    +
    +
    public interface ORCIDClient
    +
    Interface that encapsulates the communication with the ORCID client for a + specified user profile. + + Currently focuses on managing works.
    +
  • +
+
+
+
    +
  • + +
      +
    • + + +

      Method Summary

      + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
      All Methods Instance Methods Abstract Methods 
      Modifier and TypeMethod and Description
      PTCRISyncResult<org.um.dsi.gavea.orcid.model.funding.Funding>addFunding(org.um.dsi.gavea.orcid.model.funding.Funding funding) +
      Adds a new funding entry to the ORCID profile and returns the assigned + put-code.
      +
      PTCRISyncResult<org.um.dsi.gavea.orcid.model.work.Work>addWork(org.um.dsi.gavea.orcid.model.work.Work work) +
      Adds a new work to the ORCID profile and returns the assigned put-code.
      +
      java.util.List<PTCRISyncResult<org.um.dsi.gavea.orcid.model.work.Work>>addWorks(java.util.List<org.um.dsi.gavea.orcid.model.work.Work> works) +
      Adds a list of new works to the ORCID profile.
      +
      PTCRISyncResult<org.um.dsi.gavea.orcid.model.funding.Funding>deleteFunding(java.math.BigInteger putcode) +
      Deletes a funding entry from the ORCID profile.
      +
      PTCRISyncResult<org.um.dsi.gavea.orcid.model.work.Work>deleteWork(java.math.BigInteger putcode) +
      Deletes a work from the ORCID profile.
      +
      org.um.dsi.gavea.orcid.model.activities.ActivitiesSummarygetActivitiesSummary() +
      Retrieves every activity summary from the ORCID profile.
      +
      java.lang.StringgetClientId() +
      Returns the Member API client id that will commit the changes (i.e., the + works' source).
      +
      PTCRISyncResult<org.um.dsi.gavea.orcid.model.funding.Funding>getFunding(org.um.dsi.gavea.orcid.model.funding.FundingSummary summary) +
      Retrieves a complete funding entry from the ORCID profile (as opposed to + only its summary).
      +
      org.um.dsi.gavea.orcid.model.activities.FundingsgetFundingsSummary() +
      Retrieves every funding summary from the ORCID profile.
      +
      java.lang.StringgetUserId() +
      Returns the user ORCID to whose profiles the changes will be commited.
      +
      PTCRISyncResult<org.um.dsi.gavea.orcid.model.work.Work>getWork(org.um.dsi.gavea.orcid.model.work.WorkSummary summary) +
      Retrieves a complete work from the ORCID profile (as opposed to only its + summary).
      +
      java.util.Map<java.math.BigInteger,PTCRISyncResult<org.um.dsi.gavea.orcid.model.work.Work>>getWorks(java.util.List<org.um.dsi.gavea.orcid.model.work.WorkSummary> summaries) +
      Retrieves a list of complete work from the ORCID profile (as opposed to + only their summaries).
      +
      org.um.dsi.gavea.orcid.model.activities.WorksgetWorksSummary() +
      Retrieves every work summary from the ORCID profile.
      +
      intthreads() +
      The number of worker threads that will be used to communicate with the + ORCID API.
      +
      PTCRISyncResult<org.um.dsi.gavea.orcid.model.funding.Funding>updateFunding(java.math.BigInteger putcode, + org.um.dsi.gavea.orcid.model.funding.Funding funding) +
      Updates a funding entry in the ORCID profile.
      +
      PTCRISyncResult<org.um.dsi.gavea.orcid.model.work.Work>updateWork(java.math.BigInteger putcode, + org.um.dsi.gavea.orcid.model.work.Work work) +
      Updates a work in the ORCID profile.
      +
      +
    • +
    +
  • +
+
+
+
    +
  • + +
      +
    • + + +

      Method Detail

      + + + +
        +
      • +

        getClientId

        +
        java.lang.String getClientId()
        +
        Returns the Member API client id that will commit the changes (i.e., the + works' source).
        +
        +
        Returns:
        +
        the client id
        +
        +
      • +
      + + + +
        +
      • +

        getUserId

        +
        java.lang.String getUserId()
        +
        Returns the user ORCID to whose profiles the changes will be commited.
        +
        +
        Returns:
        +
        the user ORCID
        +
        +
      • +
      + + + +
        +
      • +

        getActivitiesSummary

        +
        org.um.dsi.gavea.orcid.model.activities.ActivitiesSummary getActivitiesSummary()
        +                                                                        throws org.um.dsi.gavea.orcid.client.exception.OrcidClientException
        +
        Retrieves every activity summary from the ORCID profile.
        +
        +
        Returns:
        +
        the activities summary of the ORCID profile
        +
        Throws:
        +
        org.um.dsi.gavea.orcid.client.exception.OrcidClientException - if the communication with ORCID fails
        +
        +
      • +
      + + + +
        +
      • +

        getWorksSummary

        +
        org.um.dsi.gavea.orcid.model.activities.Works getWorksSummary()
        +                                                       throws org.um.dsi.gavea.orcid.client.exception.OrcidClientException
        +
        Retrieves every work summary from the ORCID profile.
        +
        +
        Returns:
        +
        the work summaries of the ORCID profile
        +
        Throws:
        +
        org.um.dsi.gavea.orcid.client.exception.OrcidClientException - if the communication with ORCID fails
        +
        +
      • +
      + + + +
        +
      • +

        getFundingsSummary

        +
        org.um.dsi.gavea.orcid.model.activities.Fundings getFundingsSummary()
        +                                                             throws org.um.dsi.gavea.orcid.client.exception.OrcidClientException
        +
        Retrieves every funding summary from the ORCID profile.
        +
        +
        Returns:
        +
        the funding summaries of the ORCID profile
        +
        Throws:
        +
        org.um.dsi.gavea.orcid.client.exception.OrcidClientException - if the communication with ORCID fails
        +
        +
      • +
      + + + +
        +
      • +

        getWork

        +
        PTCRISyncResult<org.um.dsi.gavea.orcid.model.work.Work> getWork(org.um.dsi.gavea.orcid.model.work.WorkSummary summary)
        +
        Retrieves a complete work from the ORCID profile (as opposed to only its + summary). Exceptions are embedded in the PTCRISyncResult.
        +
        +
        Parameters:
        +
        summary - the summary of the work to be retrieved
        +
        Returns:
        +
        the complete work
        +
        +
      • +
      + + + +
        +
      • +

        getFunding

        +
        PTCRISyncResult<org.um.dsi.gavea.orcid.model.funding.Funding> getFunding(org.um.dsi.gavea.orcid.model.funding.FundingSummary summary)
        +
        Retrieves a complete funding entry from the ORCID profile (as opposed to + only its summary). Exceptions are embedded in the PTCRISyncResult.
        +
        +
        Parameters:
        +
        summary - the summary of the funding entry to be retrieved
        +
        Returns:
        +
        the complete funding entry
        +
        +
      • +
      + + + +
        +
      • +

        getWorks

        +
        java.util.Map<java.math.BigInteger,PTCRISyncResult<org.um.dsi.gavea.orcid.model.work.Work>> getWorks(java.util.List<org.um.dsi.gavea.orcid.model.work.WorkSummary> summaries)
        +
        Retrieves a list of complete work from the ORCID profile (as opposed to + only their summaries). Exceptions are embedded in the + PTCRISyncResult. This should generate a single API call + internally.
        +
        +
        Parameters:
        +
        summaries - the summaries of the works to be retrieved
        +
        Returns:
        +
        the complete works
        +
        +
      • +
      + + + +
        +
      • +

        addWork

        +
        PTCRISyncResult<org.um.dsi.gavea.orcid.model.work.Work> addWork(org.um.dsi.gavea.orcid.model.work.Work work)
        +
        Adds a new work to the ORCID profile and returns the assigned put-code. + Exceptions are embedded in the PTCRISyncResult.
        +
        +
        Parameters:
        +
        work - the work to be added to the ORCID profile
        +
        Returns:
        +
        the put-code assigned by ORCID to the newly created work
        +
        +
      • +
      + + + +
        +
      • +

        addFunding

        +
        PTCRISyncResult<org.um.dsi.gavea.orcid.model.funding.Funding> addFunding(org.um.dsi.gavea.orcid.model.funding.Funding funding)
        +
        Adds a new funding entry to the ORCID profile and returns the assigned + put-code. Exceptions are embedded in the PTCRISyncResult.
        +
        +
        Parameters:
        +
        funding - the funding entry to be added to the ORCID profile
        +
        Returns:
        +
        the put-code assigned by ORCID to the newly created funding entry
        +
        +
      • +
      + + + +
        +
      • +

        addWorks

        +
        java.util.List<PTCRISyncResult<org.um.dsi.gavea.orcid.model.work.Work>> addWorks(java.util.List<org.um.dsi.gavea.orcid.model.work.Work> works)
        +
        Adds a list of new works to the ORCID profile. Exceptions are embedded in + the PTCRISyncResult. This should generate a single API call + internally.
        +
        +
        Parameters:
        +
        works - the works to be added to the ORCID profile
        +
        Returns:
        +
        the put-codes assigned by ORCID to each of the newly created + works
        +
        +
      • +
      + + + +
        +
      • +

        deleteWork

        +
        PTCRISyncResult<org.um.dsi.gavea.orcid.model.work.Work> deleteWork(java.math.BigInteger putcode)
        +
        Deletes a work from the ORCID profile. Exceptions are embedded in + the PTCRISyncResult.
        +
        +
        Parameters:
        +
        putcode - the put-code of the work to be deleted
        +
        Returns:
        +
        the outcome of the delete request
        +
        +
      • +
      + + + +
        +
      • +

        deleteFunding

        +
        PTCRISyncResult<org.um.dsi.gavea.orcid.model.funding.Funding> deleteFunding(java.math.BigInteger putcode)
        +
        Deletes a funding entry from the ORCID profile. Exceptions are embedded + in the PTCRISyncResult.
        +
        +
        Parameters:
        +
        putcode - the put-code of the funding entry to be deleted
        +
        Returns:
        +
        the outcome of the delete request
        +
        +
      • +
      + + + +
        +
      • +

        updateWork

        +
        PTCRISyncResult<org.um.dsi.gavea.orcid.model.work.Work> updateWork(java.math.BigInteger putcode,
        +                                                                   org.um.dsi.gavea.orcid.model.work.Work work)
        +
        Updates a work in the ORCID profile. Exceptions are embedded in + the PTCRISyncResult.
        +
        +
        Parameters:
        +
        putcode - the put-code of the work to be updated
        +
        work - the new state of the work
        +
        Returns:
        +
        the outcome of the update request
        +
        +
      • +
      + + + +
        +
      • +

        updateFunding

        +
        PTCRISyncResult<org.um.dsi.gavea.orcid.model.funding.Funding> updateFunding(java.math.BigInteger putcode,
        +                                                                            org.um.dsi.gavea.orcid.model.funding.Funding funding)
        +
        Updates a funding entry in the ORCID profile. Exceptions are embedded in + the PTCRISyncResult.
        +
        +
        Parameters:
        +
        putcode - the put-code of the funding entry to be updated
        +
        funding - the new state of the funding entry
        +
        Returns:
        +
        the outcome of the update request
        +
        +
      • +
      + + + +
        +
      • +

        threads

        +
        int threads()
        +
        The number of worker threads that will be used to communicate with the + ORCID API.
        +
        +
        Returns:
        +
        the number of ORCID worker threads
        +
        +
      • +
      +
    • +
    +
  • +
+
+
+ + +
+ + + + + + + +
+ + + + diff --git a/docs/pt/ptcris/ORCIDClientImpl.html b/docs/pt/ptcris/ORCIDClientImpl.html new file mode 100644 index 0000000..56880ad --- /dev/null +++ b/docs/pt/ptcris/ORCIDClientImpl.html @@ -0,0 +1,817 @@ + + + + + +ORCIDClientImpl + + + + + + + + +
+ + + + + + + +
+ + + +
+
pt.ptcris
+

Class ORCIDClientImpl

+
+
+ +
+
    +
  • +
    +
    All Implemented Interfaces:
    +
    ORCIDClient
    +
    +
    +
    +
    public class ORCIDClientImpl
    +extends java.lang.Object
    +implements ORCIDClient
    +
    An implementation of the ORCID client interface built over the + Degois client. + + Besides the tokens to use the ORCID Member API, it also store the tokens to + access a particular ORCID user profile.
    +
    +
    See Also:
    +
    ORCIDClient
    +
    +
  • +
+
+
+
    +
  • + +
      +
    • + + +

      Constructor Summary

      + + + + + + + + + + + + + + + + + +
      Constructors 
      Constructor and Description
      ORCIDClientImpl(java.lang.String loginUri, + java.lang.String apiUri, + java.lang.String clientId, + java.lang.String clientSecret, + java.lang.String redirectUri, + org.um.dsi.gavea.orcid.client.OrcidAccessToken orcidToken) +
      Instantiates an ORCID client to communicate with the ORCID API.
      +
      ORCIDClientImpl(java.lang.String loginUri, + java.lang.String apiUri, + java.lang.String clientId, + java.lang.String clientSecret, + java.lang.String redirectUri, + org.um.dsi.gavea.orcid.client.OrcidAccessToken orcidToken, + boolean debugMode) +
      Instantiates an ORCID client to communicate with the ORCID API.
      +
      ORCIDClientImpl(java.lang.String loginUri, + java.lang.String apiUri, + java.lang.String clientId, + java.lang.String clientSecret, + java.lang.String redirectUri, + org.um.dsi.gavea.orcid.client.OrcidAccessToken orcidToken, + boolean debugMode, + int threads) +
      Instantiates an ORCID client to communicate with the ORCID API.
      +
      ORCIDClientImpl(java.lang.String loginUri, + java.lang.String apiUri, + java.lang.String clientId, + java.lang.String clientSecret, + java.lang.String redirectUri, + org.um.dsi.gavea.orcid.client.OrcidAccessToken orcidToken, + int threads) +
      Instantiates an ORCID client to communicate with the ORCID API.
      +
      +
    • +
    + +
      +
    • + + +

      Method Summary

      + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
      All Methods Instance Methods Concrete Methods 
      Modifier and TypeMethod and Description
      PTCRISyncResult<org.um.dsi.gavea.orcid.model.funding.Funding>addFunding(org.um.dsi.gavea.orcid.model.funding.Funding fund) +
      Adds a new funding entry to the ORCID profile and returns the assigned + put-code.
      +
      PTCRISyncResult<org.um.dsi.gavea.orcid.model.work.Work>addWork(org.um.dsi.gavea.orcid.model.work.Work work) +
      Adds a new work to the ORCID profile and returns the assigned put-code.
      +
      java.util.List<PTCRISyncResult<org.um.dsi.gavea.orcid.model.work.Work>>addWorks(java.util.List<org.um.dsi.gavea.orcid.model.work.Work> works) +
      Adds a list of new works to the ORCID profile.
      +
      PTCRISyncResult<org.um.dsi.gavea.orcid.model.funding.Funding>deleteFunding(java.math.BigInteger putcode) +
      Deletes a funding entry from the ORCID profile.
      +
      PTCRISyncResult<org.um.dsi.gavea.orcid.model.work.Work>deleteWork(java.math.BigInteger putcode) +
      Deletes a work from the ORCID profile.
      +
      org.um.dsi.gavea.orcid.model.activities.ActivitiesSummarygetActivitiesSummary() +
      Retrieves every activity summary from the ORCID profile.
      +
      java.lang.StringgetClientId() +
      Returns the Member API client id that will commit the changes (i.e., the + works' source).
      +
      PTCRISyncResult<org.um.dsi.gavea.orcid.model.funding.Funding>getFunding(org.um.dsi.gavea.orcid.model.funding.FundingSummary putcode) +
      Retrieves a complete funding entry from the ORCID profile (as opposed to + only its summary).
      +
      org.um.dsi.gavea.orcid.model.activities.FundingsgetFundingsSummary() +
      Retrieves every funding summary from the ORCID profile.
      +
      java.lang.StringgetUserId() +
      Returns the user ORCID to whose profiles the changes will be commited.
      +
      PTCRISyncResult<org.um.dsi.gavea.orcid.model.work.Work>getWork(org.um.dsi.gavea.orcid.model.work.WorkSummary putcode) +
      Retrieves a complete work from the ORCID profile (as opposed to only its + summary).
      +
      java.util.Map<java.math.BigInteger,PTCRISyncResult<org.um.dsi.gavea.orcid.model.work.Work>>getWorks(java.util.List<org.um.dsi.gavea.orcid.model.work.WorkSummary> summaries) +
      Retrieves a list of complete work from the ORCID profile (as opposed to + only their summaries).
      +
      org.um.dsi.gavea.orcid.model.activities.WorksgetWorksSummary() +
      Retrieves every work summary from the ORCID profile.
      +
      intthreads() +
      The number of worker threads that will be used to communicate with the + ORCID API.
      +
      PTCRISyncResult<org.um.dsi.gavea.orcid.model.funding.Funding>updateFunding(java.math.BigInteger putcode, + org.um.dsi.gavea.orcid.model.funding.Funding work) +
      Updates a funding entry in the ORCID profile.
      +
      PTCRISyncResult<org.um.dsi.gavea.orcid.model.work.Work>updateWork(java.math.BigInteger putcode, + org.um.dsi.gavea.orcid.model.work.Work work) +
      Updates a work in the ORCID profile.
      +
      +
        +
      • + + +

        Methods inherited from class java.lang.Object

        +equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • +
      +
    • +
    +
  • +
+
+
+
    +
  • + +
      +
    • + + +

      Constructor Detail

      + + + +
        +
      • +

        ORCIDClientImpl

        +
        public ORCIDClientImpl(java.lang.String loginUri,
        +                       java.lang.String apiUri,
        +                       java.lang.String clientId,
        +                       java.lang.String clientSecret,
        +                       java.lang.String redirectUri,
        +                       org.um.dsi.gavea.orcid.client.OrcidAccessToken orcidToken,
        +                       int threads)
        +
        Instantiates an ORCID client to communicate with the ORCID API.
        +
        +
        Parameters:
        +
        loginUri - the login URI of the ORCID service
        +
        apiUri - the URI of the ORCID API
        +
        clientId - the id of the ORCID Member API client
        +
        clientSecret - the secret of the ORCID Member API client
        +
        redirectUri - the redirect URI for requesting the access token
        +
        orcidToken - the access token to the user ORCID profile
        +
        threads - the number of ORCID worker threads
        +
        +
      • +
      + + + +
        +
      • +

        ORCIDClientImpl

        +
        public ORCIDClientImpl(java.lang.String loginUri,
        +                       java.lang.String apiUri,
        +                       java.lang.String clientId,
        +                       java.lang.String clientSecret,
        +                       java.lang.String redirectUri,
        +                       org.um.dsi.gavea.orcid.client.OrcidAccessToken orcidToken)
        +
        Instantiates an ORCID client to communicate with the ORCID API.
        +
        +
        Parameters:
        +
        loginUri - the login URI of the ORCID service
        +
        apiUri - the URI of the ORCID API
        +
        clientId - the id of the ORCID Member API client
        +
        clientSecret - the secret of the ORCID Member API client
        +
        redirectUri - the redirect URI for requesting the access token
        +
        orcidToken - the access token to the user ORCID profile
        +
        +
      • +
      + + + +
        +
      • +

        ORCIDClientImpl

        +
        public ORCIDClientImpl(java.lang.String loginUri,
        +                       java.lang.String apiUri,
        +                       java.lang.String clientId,
        +                       java.lang.String clientSecret,
        +                       java.lang.String redirectUri,
        +                       org.um.dsi.gavea.orcid.client.OrcidAccessToken orcidToken,
        +                       boolean debugMode)
        +
        Instantiates an ORCID client to communicate with the ORCID API.
        +
        +
        Parameters:
        +
        loginUri - the login URI of the ORCID service
        +
        apiUri - the URI of the ORCID API
        +
        clientId - the id of the ORCID Member API client
        +
        clientSecret - the secret of the ORCID Member API client
        +
        redirectUri - the redirect URI for requesting the access token
        +
        orcidToken - the access token to the user ORCID profile
        +
        debugMode - Enter debug mode
        +
        +
      • +
      + + + +
        +
      • +

        ORCIDClientImpl

        +
        public ORCIDClientImpl(java.lang.String loginUri,
        +                       java.lang.String apiUri,
        +                       java.lang.String clientId,
        +                       java.lang.String clientSecret,
        +                       java.lang.String redirectUri,
        +                       org.um.dsi.gavea.orcid.client.OrcidAccessToken orcidToken,
        +                       boolean debugMode,
        +                       int threads)
        +
        Instantiates an ORCID client to communicate with the ORCID API.
        +
        +
        Parameters:
        +
        loginUri - the login URI of the ORCID service
        +
        apiUri - the URI of the ORCID API
        +
        clientId - the id of the ORCID Member API client
        +
        clientSecret - the secret of the ORCID Member API client
        +
        redirectUri - the redirect URI for requesting the access token
        +
        orcidToken - the access token to the user ORCID profile
        +
        debugMode - Enter debug mode
        +
        threads - the number of ORCID worker threads
        +
        +
      • +
      +
    • +
    + +
      +
    • + + +

      Method Detail

      + + + +
        +
      • +

        getClientId

        +
        public java.lang.String getClientId()
        +
        Returns the Member API client id that will commit the changes (i.e., the + works' source).
        +
        +
        Specified by:
        +
        getClientId in interface ORCIDClient
        +
        Returns:
        +
        the client id
        +
        +
      • +
      + + + +
        +
      • +

        getUserId

        +
        public java.lang.String getUserId()
        +
        Returns the user ORCID to whose profiles the changes will be commited.
        +
        +
        Specified by:
        +
        getUserId in interface ORCIDClient
        +
        Returns:
        +
        the user ORCID
        +
        +
      • +
      + + + +
        +
      • +

        getActivitiesSummary

        +
        public org.um.dsi.gavea.orcid.model.activities.ActivitiesSummary getActivitiesSummary()
        +                                                                               throws org.um.dsi.gavea.orcid.client.exception.OrcidClientException
        +
        Retrieves every activity summary from the ORCID profile.
        +
        +
        Specified by:
        +
        getActivitiesSummary in interface ORCIDClient
        +
        Returns:
        +
        the activities summary of the ORCID profile
        +
        Throws:
        +
        org.um.dsi.gavea.orcid.client.exception.OrcidClientException - if the communication with ORCID fails
        +
        +
      • +
      + + + +
        +
      • +

        getWorksSummary

        +
        public org.um.dsi.gavea.orcid.model.activities.Works getWorksSummary()
        +                                                              throws org.um.dsi.gavea.orcid.client.exception.OrcidClientException
        +
        Retrieves every work summary from the ORCID profile.
        +
        +
        Specified by:
        +
        getWorksSummary in interface ORCIDClient
        +
        Returns:
        +
        the work summaries of the ORCID profile
        +
        Throws:
        +
        org.um.dsi.gavea.orcid.client.exception.OrcidClientException - if the communication with ORCID fails
        +
        +
      • +
      + + + +
        +
      • +

        getFundingsSummary

        +
        public org.um.dsi.gavea.orcid.model.activities.Fundings getFundingsSummary()
        +                                                                    throws org.um.dsi.gavea.orcid.client.exception.OrcidClientException
        +
        Retrieves every funding summary from the ORCID profile.
        +
        +
        Specified by:
        +
        getFundingsSummary in interface ORCIDClient
        +
        Returns:
        +
        the funding summaries of the ORCID profile
        +
        Throws:
        +
        org.um.dsi.gavea.orcid.client.exception.OrcidClientException - if the communication with ORCID fails
        +
        +
      • +
      + + + +
        +
      • +

        getWork

        +
        public PTCRISyncResult<org.um.dsi.gavea.orcid.model.work.Work> getWork(org.um.dsi.gavea.orcid.model.work.WorkSummary putcode)
        +
        Retrieves a complete work from the ORCID profile (as opposed to only its + summary). Exceptions are embedded in the PTCRISyncResult.
        +
        +
        Specified by:
        +
        getWork in interface ORCIDClient
        +
        Parameters:
        +
        putcode - the summary of the work to be retrieved
        +
        Returns:
        +
        the complete work
        +
        +
      • +
      + + + +
        +
      • +

        getFunding

        +
        public PTCRISyncResult<org.um.dsi.gavea.orcid.model.funding.Funding> getFunding(org.um.dsi.gavea.orcid.model.funding.FundingSummary putcode)
        +
        Retrieves a complete funding entry from the ORCID profile (as opposed to + only its summary). Exceptions are embedded in the PTCRISyncResult.
        +
        +
        Specified by:
        +
        getFunding in interface ORCIDClient
        +
        Parameters:
        +
        putcode - the summary of the funding entry to be retrieved
        +
        Returns:
        +
        the complete funding entry
        +
        +
      • +
      + + + +
        +
      • +

        getWorks

        +
        public java.util.Map<java.math.BigInteger,PTCRISyncResult<org.um.dsi.gavea.orcid.model.work.Work>> getWorks(java.util.List<org.um.dsi.gavea.orcid.model.work.WorkSummary> summaries)
        +
        Retrieves a list of complete work from the ORCID profile (as opposed to + only their summaries). Exceptions are embedded in the + PTCRISyncResult. This should generate a single API call + internally.
        +
        +
        Specified by:
        +
        getWorks in interface ORCIDClient
        +
        Parameters:
        +
        summaries - the summaries of the works to be retrieved
        +
        Returns:
        +
        the complete works
        +
        +
      • +
      + + + +
        +
      • +

        addWork

        +
        public PTCRISyncResult<org.um.dsi.gavea.orcid.model.work.Work> addWork(org.um.dsi.gavea.orcid.model.work.Work work)
        +
        Adds a new work to the ORCID profile and returns the assigned put-code. + Exceptions are embedded in the PTCRISyncResult.
        +
        +
        Specified by:
        +
        addWork in interface ORCIDClient
        +
        Parameters:
        +
        work - the work to be added to the ORCID profile
        +
        Returns:
        +
        the put-code assigned by ORCID to the newly created work
        +
        +
      • +
      + + + +
        +
      • +

        addFunding

        +
        public PTCRISyncResult<org.um.dsi.gavea.orcid.model.funding.Funding> addFunding(org.um.dsi.gavea.orcid.model.funding.Funding fund)
        +
        Adds a new funding entry to the ORCID profile and returns the assigned + put-code. Exceptions are embedded in the PTCRISyncResult.
        +
        +
        Specified by:
        +
        addFunding in interface ORCIDClient
        +
        Parameters:
        +
        fund - the funding entry to be added to the ORCID profile
        +
        Returns:
        +
        the put-code assigned by ORCID to the newly created funding entry
        +
        +
      • +
      + + + +
        +
      • +

        addWorks

        +
        public java.util.List<PTCRISyncResult<org.um.dsi.gavea.orcid.model.work.Work>> addWorks(java.util.List<org.um.dsi.gavea.orcid.model.work.Work> works)
        +
        Adds a list of new works to the ORCID profile. Exceptions are embedded in + the PTCRISyncResult. This should generate a single API call + internally.
        +
        +
        Specified by:
        +
        addWorks in interface ORCIDClient
        +
        Parameters:
        +
        works - the works to be added to the ORCID profile
        +
        Returns:
        +
        the put-codes assigned by ORCID to each of the newly created + works
        +
        +
      • +
      + + + +
        +
      • +

        deleteWork

        +
        public PTCRISyncResult<org.um.dsi.gavea.orcid.model.work.Work> deleteWork(java.math.BigInteger putcode)
        +
        Deletes a work from the ORCID profile. Exceptions are embedded in + the PTCRISyncResult.
        +
        +
        Specified by:
        +
        deleteWork in interface ORCIDClient
        +
        Parameters:
        +
        putcode - the put-code of the work to be deleted
        +
        Returns:
        +
        the outcome of the delete request
        +
        +
      • +
      + + + +
        +
      • +

        deleteFunding

        +
        public PTCRISyncResult<org.um.dsi.gavea.orcid.model.funding.Funding> deleteFunding(java.math.BigInteger putcode)
        +
        Deletes a funding entry from the ORCID profile. Exceptions are embedded + in the PTCRISyncResult.
        +
        +
        Specified by:
        +
        deleteFunding in interface ORCIDClient
        +
        Parameters:
        +
        putcode - the put-code of the funding entry to be deleted
        +
        Returns:
        +
        the outcome of the delete request
        +
        +
      • +
      + + + +
        +
      • +

        updateWork

        +
        public PTCRISyncResult<org.um.dsi.gavea.orcid.model.work.Work> updateWork(java.math.BigInteger putcode,
        +                                                                          org.um.dsi.gavea.orcid.model.work.Work work)
        +
        Updates a work in the ORCID profile. Exceptions are embedded in + the PTCRISyncResult.
        +
        +
        Specified by:
        +
        updateWork in interface ORCIDClient
        +
        Parameters:
        +
        putcode - the put-code of the work to be updated
        +
        work - the new state of the work
        +
        Returns:
        +
        the outcome of the update request
        +
        +
      • +
      + + + +
        +
      • +

        updateFunding

        +
        public PTCRISyncResult<org.um.dsi.gavea.orcid.model.funding.Funding> updateFunding(java.math.BigInteger putcode,
        +                                                                                   org.um.dsi.gavea.orcid.model.funding.Funding work)
        +
        Updates a funding entry in the ORCID profile. Exceptions are embedded in + the PTCRISyncResult.
        +
        +
        Specified by:
        +
        updateFunding in interface ORCIDClient
        +
        Parameters:
        +
        putcode - the put-code of the funding entry to be updated
        +
        work - the new state of the funding entry
        +
        Returns:
        +
        the outcome of the update request
        +
        +
      • +
      + + + +
        +
      • +

        threads

        +
        public int threads()
        +
        The number of worker threads that will be used to communicate with the + ORCID API.
        +
        +
        Specified by:
        +
        threads in interface ORCIDClient
        +
        Returns:
        +
        the number of ORCID worker threads
        +
        +
      • +
      +
    • +
    +
  • +
+
+
+ + +
+ + + + + + + +
+ + + + diff --git a/docs/pt/ptcris/PTCRISGrouper.html b/docs/pt/ptcris/PTCRISGrouper.html new file mode 100644 index 0000000..74027f2 --- /dev/null +++ b/docs/pt/ptcris/PTCRISGrouper.html @@ -0,0 +1,307 @@ + + + + + +PTCRISGrouper + + + + + + + + +
+ + + + + + + +
+ + + +
+
pt.ptcris
+

Class PTCRISGrouper

+
+
+ +
+
    +
  • +
    +
    +
    public class PTCRISGrouper
    +extends java.lang.Object
    +

    + A generic activity grouper for the PTCRIS framework. The method is + customizable by a comparison criteria that + determines when two activities match each other, in which case they are + grouped together. This relationship is transitive: two non-matching + activities may belong to the same group if they both match a third one. +

    + +

    + The user should provide an activity comparator + that defines matching activities by calculating a similarity metric, and the + respective threshold. +

    + + TODO: Activities within groups are not ordered, groups are sets. Should they + be? Specifically, ordered by meta-data quality (e.g., number of filled + fields). + + TODO: Singleton groups are being returned. Does this encumber the process? + Should they be filtered by the grouper or by requesting services?
    +
  • +
+
+
+
    +
  • + +
      +
    • + + +

      Constructor Summary

      + + + + + + + + +
      Constructors 
      Constructor and Description
      PTCRISGrouper() 
      +
    • +
    + +
      +
    • + + +

      Method Summary

      + + + + + + + + + + +
      All Methods Static Methods Concrete Methods 
      Modifier and TypeMethod and Description
      static <E> java.util.List<ActivityGroup<E>>group(java.util.Collection<E> locals, + ActivityComparator<E> comparator) +
      Groups a list of local activities into groups of matching activities, + according to the provided comparator.
      +
      +
        +
      • + + +

        Methods inherited from class java.lang.Object

        +equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • +
      +
    • +
    +
  • +
+
+
+
    +
  • + +
      +
    • + + +

      Constructor Detail

      + + + +
        +
      • +

        PTCRISGrouper

        +
        public PTCRISGrouper()
        +
      • +
      +
    • +
    + +
      +
    • + + +

      Method Detail

      + + + +
        +
      • +

        group

        +
        public static <E> java.util.List<ActivityGroup<E>> group(java.util.Collection<E> locals,
        +                                                         ActivityComparator<E> comparator)
        +
        Groups a list of local activities into groups of matching activities, + according to the provided comparator.
        +
        +
        Type Parameters:
        +
        E - the type of entries being grouped
        +
        Parameters:
        +
        locals - the local activities to be grouped
        +
        comparator - the provided activity comparator
        +
        Returns:
        +
        the local activities, grouped
        +
        +
      • +
      +
    • +
    +
  • +
+
+
+ + +
+ + + + + + + +
+ + + + diff --git a/docs/pt/ptcris/PTCRISync.html b/docs/pt/ptcris/PTCRISync.html new file mode 100644 index 0000000..6b472ea --- /dev/null +++ b/docs/pt/ptcris/PTCRISync.html @@ -0,0 +1,1334 @@ + + + + + +PTCRISync + + + + + + + + +
+ + + + + + + +
+ + + +
+
pt.ptcris
+

Class PTCRISync

+
+
+ +
+
    +
  • +
    +
    +
    public final class PTCRISync
    +extends java.lang.Object
    +

    + An implementation of the PTCRISync synchronization service based on the + version 0.4.3 of the specification, enhanced with minimal quality criteria. + This service allows CRIS services to maintain their repositories synchronized + with ORCID. This requires the CRIS service to have access to the ORCID Member + API. +

    + +

    + The service has two main functionalities: to keep a set of local activities + updated in an ORCID user profile through an + export procedure, and import activities not known locally from the ORCID + profile, either through the + import + for completely new activities or through the + import for new information for already known entries. Activities must meet + certain quality criteria to be imported (the set of invalid activities can be + retrieved as well through + importInvalidBase(ORCIDHelper, List, Collection, ProgressHandler). +

    + +

    + The implementation of the service assumes that the local CRIS communicates + the local activities following the established ORCID schema, according to the + ORCID Member API 2.0. This uniforms the API and simplifies the + synchronization process. The current version focuses on synchronizing + research productions and funding entries, which must be encoded as ORCID + works and funding activities. +

    + +

    + The communication with ORCID is encapsulated in an ORCID client that contains information regarding the CRIS Member API and the ORCID + profile that is to be managed. An helper provides utility + methods for the synchronization of activities. +

    + +

    + The procedures do not currently consider the contributors (authors) of activities + when assessing the quality criteria nor when assessing whether they are + up-to-date, as this information is not available in ORCID summaries and would + require additional calls to the ORCID API. +

    + + See https://ptcris.pt/hub-ptcris/.
    +
  • +
+
+
+ +
+
+
    +
  • + +
      +
    • + + +

      Constructor Detail

      + + + +
        +
      • +

        PTCRISync

        +
        public PTCRISync()
        +
      • +
      +
    • +
    + +
      +
    • + + +

      Method Detail

      + + + +
        +
      • +

        exportWorks

        +
        public static java.util.Map<java.math.BigInteger,PTCRISyncResult<org.um.dsi.gavea.orcid.model.work.Work>> exportWorks(ORCIDClient client,
        +                                                                                                                      java.util.List<org.um.dsi.gavea.orcid.model.work.Work> locals,
        +                                                                                                                      ProgressHandler handler)
        +                                                                                                               throws org.um.dsi.gavea.orcid.client.exception.OrcidClientException,
        +                                                                                                                      java.lang.IllegalArgumentException
        +

        + Exports a list of local CRIS productions to an ORCID profile and keeps + them up-to-date. This procedure manages the work activities in the ORCID + user profile that are sourced by the CRIS, both previously specified in + the client. +

        + +

        + The procedure detects every CRIS sourced work in the ORCID profile that + matches any local entry that is being exported; if there is no matching + local entry, the ORCID activity is deleted from the profile. Otherwise it + will be updated with the meta-data of one of the matching local entries. + Finally, for local entries without any matching ORCID activity, new ones + are created. The matching is performed by detecting shared + external identifiers (see + ORCIDHelper.getSelfExternalIdsDiffS(ElementSummary, Collection) + ). +

        + +

        + Activities are only updated if the meta-data is not up-to-date. + Currently, the title, the publication year and the publication are + considered (see ORCIDHelper.isUpToDateE(ElementSummary, ElementSummary)). +

        + +

        + The procedure expects the CRIS service to provide the local works in the + ORCID schema, in particular encoding them as works. Thus, + the meta-data of the CRIS sourced entries in the ORCID profile is exactly + that of the provided local entries that are to be exported. The put-code + of these local entries is assumed to be used as local key identifiers, + and are disregarded during the update of the ORCID profile (new entries + are assigned fresh put-codes and updated entries use the put-code of the + existing ORCID entry). +

        + +

        + The provided local activities must pass a quality criteria to be kept + synchronized in ORCID. Currently, this forces the existence of external + identifiers, the title, the publication year and the publication type + (see ORCIDHelper.testMinimalQuality(ElementSummary). +

        + +

        + The procedure reports the status for each of the input local activities, + identifying them by the provided local put-code, including the ORCID + error if the process failed. See PTCRISyncResult for the codes. + If the local put-code is empty, returns a default value, which currently + is the put-code remotely assigned by ORCID. +

        +
        +
        Parameters:
        +
        client - the ORCID client defining the CRIS Member API and user the + profile to be managed
        +
        locals - the list of local productions to be exported that should be + kept synchronized in the ORCID user profile
        +
        handler - the progress handler responsible for receiving progress + updates
        +
        Returns:
        +
        the result of the synchronization of each of the provided local + work
        +
        Throws:
        +
        org.um.dsi.gavea.orcid.client.exception.OrcidClientException - if the communication with ORCID fails when getting the + activities summary
        +
        java.lang.IllegalArgumentException - if null arguments
        +
        +
      • +
      + + + +
        +
      • +

        export

        +
        @Deprecated
        +public static java.util.Map<java.math.BigInteger,PTCRISyncResult<org.um.dsi.gavea.orcid.model.work.Work>> export(ORCIDClient client,
        +                                                                                                                             java.util.List<org.um.dsi.gavea.orcid.model.work.Work> locals,
        +                                                                                                                             ProgressHandler handler)
        +                                                                                                                      throws org.um.dsi.gavea.orcid.client.exception.OrcidClientException,
        +                                                                                                                             java.lang.IllegalArgumentException
        + +
        +
        Parameters:
        +
        client - the ORCID client defining the CRIS Member API and user the + profile to be managed
        +
        locals - the list of local productions to be exported that should be + kept synchronized in the ORCID user profile
        +
        handler - the progress handler responsible for receiving progress + updates
        +
        Returns:
        +
        the result of the synchronization of each of the provided local + work
        +
        Throws:
        +
        org.um.dsi.gavea.orcid.client.exception.OrcidClientException - if the communication with ORCID fails when getting the + activities summary
        +
        java.lang.IllegalArgumentException - if null arguments
        +
        +
      • +
      + + + +
        +
      • +

        exportWorksForced

        +
        public static java.util.Map<java.math.BigInteger,PTCRISyncResult<org.um.dsi.gavea.orcid.model.work.Work>> exportWorksForced(ORCIDClient client,
        +                                                                                                                            java.util.List<org.um.dsi.gavea.orcid.model.work.Work> locals,
        +                                                                                                                            ProgressHandler handler)
        +                                                                                                                     throws org.um.dsi.gavea.orcid.client.exception.OrcidClientException,
        +                                                                                                                            java.lang.IllegalArgumentException
        +

        + Exports a list of local CRIS productions to an ORCID profile and keeps + them up-to-date. This procedure manages the work activities in the ORCID + user profile that are sourced by the CRIS, both previously specified in + the client. +

        + +

        + The procedure detects every CRIS sourced work in the ORCID profile that + matches any local entry that is being exported; if there is no matching + local entry, the ORCID activity is deleted from the profile. Otherwise it + will be updated with the meta-data of one of the matching local entries. + Finally, for local entries without any matching ORCID activity, new ones + are created. The matching is performed by detecting shared + external identifiers (see + ORCIDHelper.getSelfExternalIdsDiffS(ElementSummary, Collection) + ). +

        + +

        + Activities are always updated, even if already up-to-date (no test is + performed). The caller of this method should guarantee that the input + local productions have been effectively updated, otherwise there will be + unnecessary calls to the ORCID API. +

        + +

        + The procedure expects the CRIS service to provide the local works in the + ORCID schema, in particular encoding them as works. Thus, + the meta-data of the CRIS sourced entries in the ORCID profile is exactly + that of the provided local entries that are to be exported. The put-code + of these local entries is assumed to be used as local key identifiers, + and are disregarded during the update of the ORCID profile (new entries + are assigned fresh put-codes and updated entries use the put-code of the + existing ORCID entry). +

        + +

        + The provided local activities must pass a quality criteria to be kept + synchronized in ORCID. Currently, this forces the existence of external + identifiers, the title, the publication year and the publication type + (see ORCIDHelper.testMinimalQuality(ElementSummary). +

        + +

        + The procedure reports the status for each of the input local activities, + identifying them by the provided local put-code, including the ORCID + error if the process failed. See PTCRISyncResult for the codes. + If the local put-code is empty, returns a default value, which currently + is the put-code remotely assigned by ORCID. +

        +
        +
        Parameters:
        +
        client - the ORCID client defining the CRIS Member API and user the + profile to be managed
        +
        locals - the list of local productions to be exported that should be + kept synchronized in the ORCID user profile
        +
        handler - the progress handler responsible for receiving progress + updates
        +
        Returns:
        +
        the result of the synchronization of each of the provided local + work
        +
        Throws:
        +
        org.um.dsi.gavea.orcid.client.exception.OrcidClientException - if the communication with ORCID fails when getting the + activities summary
        +
        java.lang.IllegalArgumentException - if null arguments
        +
        +
      • +
      + + + +
        +
      • +

        exportForce

        +
        @Deprecated
        +public static java.util.Map<java.math.BigInteger,PTCRISyncResult<org.um.dsi.gavea.orcid.model.work.Work>> exportForce(ORCIDClient client,
        +                                                                                                                                  java.util.List<org.um.dsi.gavea.orcid.model.work.Work> locals,
        +                                                                                                                                  ProgressHandler handler)
        +                                                                                                                           throws org.um.dsi.gavea.orcid.client.exception.OrcidClientException,
        +                                                                                                                                  java.lang.IllegalArgumentException
        + +
        +
        Parameters:
        +
        client - the ORCID client defining the CRIS Member API and user the + profile to be managed
        +
        locals - the list of local productions to be exported that should be + kept synchronized in the ORCID user profile
        +
        handler - the progress handler responsible for receiving progress + updates
        +
        Returns:
        +
        the result of the synchronization of each of the provided local + work
        +
        Throws:
        +
        org.um.dsi.gavea.orcid.client.exception.OrcidClientException - if the communication with ORCID fails when getting the + activities summary
        +
        java.lang.IllegalArgumentException - if null arguments
        +
        +
      • +
      + + + +
        +
      • +

        exportFundings

        +
        public static java.util.Map<java.math.BigInteger,PTCRISyncResult<org.um.dsi.gavea.orcid.model.funding.Funding>> exportFundings(ORCIDClient client,
        +                                                                                                                               java.util.List<org.um.dsi.gavea.orcid.model.funding.Funding> locals,
        +                                                                                                                               java.util.Collection<org.um.dsi.gavea.orcid.model.funding.FundingType> types,
        +                                                                                                                               ProgressHandler handler)
        +                                                                                                                        throws org.um.dsi.gavea.orcid.client.exception.OrcidClientException,
        +                                                                                                                               java.lang.IllegalArgumentException
        +

        + Exports a list of local CRIS funding entries to an ORCID profile and + keeps them up-to-date. This procedure manages the funding activities in + the ORCID user profile that are sourced by the CRIS, both previously + specified in the client. +

        + +

        + The procedure detects every CRIS sourced funding activity in the ORCID + profile that matches any local entry that is being exported; if there is + no matching local entry, the ORCID activity is deleted from the profile. + Otherwise it will be updated with the meta-data of one of the matching + local entries. Finally, for local entries without any matching ORCID + activity, new ones are created. The matching is performed by detecting + shared external identifiers (see + ORCIDHelper.getSelfExternalIdsDiffS(ElementSummary, Collection) + ). +

        + +

        + Activities are only updated if the meta-data is not up-to-date. + Currently, the title, the start year, the funding type and the funding + organization are considered (see + ORCIDHelper.isUpToDateE(ElementSummary, ElementSummary)). +

        + +

        + The procedure expects the CRIS service to provide the local funding + entries in the ORCID schema, in particular encoding them as + funding activities. Thus, the meta-data of the CRIS + sourced entries in the ORCID profile is exactly that of the provided + local entries that are to be exported. The put-code of these local + entries is assumed to be used as local key identifiers, and are + disregarded during the update of the ORCID profile (new entries are + assigned fresh put-codes and updated entries use the put-code of the + existing ORCID entry). +

        + +

        + The provided local activities must pass a quality criteria to be kept + synchronized in ORCID. Currently, this forces the existence of external + identifiers, the title, the start year, the funding type and the funding + organization (see + ORCIDHelper.testMinimalQuality(ElementSummary). +

        + +

        + A set of funding types can be provided to allow the independent + synchronization of different types of entries. Local and remote + activities outside the provided types are simply ignored (they are not + considered invalid). +

        + +

        + The procedure reports the status for each of the input local activities, + identifying them by the provided local put-code, including the ORCID + error if the process failed. See PTCRISyncResult for the codes. + If the local put-code is empty, returns a default value, which currently + is the put-code remotely assigned by ORCID. +

        +
        +
        Parameters:
        +
        client - the ORCID client defining the CRIS Member API and user the + profile to be managed
        +
        locals - the list of local productions to be exported that should be + kept synchronized in the ORCID user profile
        +
        types - the types of ORCID funding entries that should be considered + (others are simply ignored).
        +
        handler - the progress handler responsible for receiving progress + updates
        +
        Returns:
        +
        the result of the synchronization of each of the provided local + funding entry
        +
        Throws:
        +
        org.um.dsi.gavea.orcid.client.exception.OrcidClientException - if the communication with ORCID fails when getting the + activities summary
        +
        java.lang.IllegalArgumentException - if null arguments
        +
        +
      • +
      + + + +
        +
      • +

        importWorks

        +
        public static java.util.List<org.um.dsi.gavea.orcid.model.work.Work> importWorks(ORCIDClient client,
        +                                                                                 java.util.List<org.um.dsi.gavea.orcid.model.work.Work> locals,
        +                                                                                 ProgressHandler handler)
        +                                                                          throws org.um.dsi.gavea.orcid.client.exception.OrcidClientException,
        +                                                                                 java.lang.InterruptedException,
        +                                                                                 java.lang.IllegalArgumentException
        +

        + Discovers new valid works in an ORCID profile given a set of known local + CRIS productions. Creates creation notifications for each work group at + ORCID (merged into as a single work by the helper + ) without matching local productions (i.e., those without shared + external identifiers). To import updates for works + with shared external identifiers + importWorkUpdates(ORCIDClient, List, ProgressHandler) should be + used instead. +

        + +

        + Currently, these creation notifications simply take the shape of ORCID + works themselves (representing a merged work group). The group merging + selects the meta-data of the preferred activity and the external + identifiers of the whole group (see + ORCIDHelper.group(Object)). The selection of the + meta-data from a group could be changed without affecting the correction + of the procedure. +

        + +

        + Since the put-code attribute is used as a local key of each activity, it + is null for these creation notifications (and not the put-code of the + remote ORCID activity that gave origin to it). Since only the external + identifiers of the local productions are used to search for matches, the + remainder meta-data of the input local activities could be left null. +

        + +

        + ORCID activities without minimal quality are ignored by this procedure. + Currently, the quality criteria forces the existence of external + identifiers, the title, publication year and publication type (see + ORCIDHelper.testMinimalQuality(ElementSummary)). Works that do + not match the criteria can be imported with + importInvalid(ORCIDClient, List, ProgressHandler). Note that + currently group merging simply collects the meta-data (other than the + external identifiers) from the preferred activity, which is used in the + quality assessment. +

        +
        +
        Parameters:
        +
        client - the ORCID client defining the CRIS Member API and user the + profile to be managed
        +
        locals - the full list of local productions
        +
        handler - the progress handler responsible for receiving progress + updates
        +
        Returns:
        +
        the list of new valid works found in the ORCID profile
        +
        Throws:
        +
        org.um.dsi.gavea.orcid.client.exception.OrcidClientException - if the communication with ORCID fails when getting the + activities summary
        +
        java.lang.InterruptedException - if the asynchronous GET process is interrupted
        +
        java.lang.IllegalArgumentException - if null arguments
        +
        +
      • +
      + + + +
        +
      • +

        importFundings

        +
        public static java.util.List<org.um.dsi.gavea.orcid.model.funding.Funding> importFundings(ORCIDClient client,
        +                                                                                          java.util.List<org.um.dsi.gavea.orcid.model.funding.Funding> locals,
        +                                                                                          java.util.Collection<org.um.dsi.gavea.orcid.model.funding.FundingType> types,
        +                                                                                          ProgressHandler handler)
        +                                                                                   throws org.um.dsi.gavea.orcid.client.exception.OrcidClientException,
        +                                                                                          java.lang.InterruptedException,
        +                                                                                          java.lang.IllegalArgumentException
        +

        + Discovers new valid funding activities in an ORCID profile given a set of + known local CRIS funding entries. Creates creation notifications for each + funding group at ORCID (merged into as a single funding entry by the + helper ) without matching local entries (i.e., + those without shared external identifiers). To import + updates for funding activities with shared external identifiers + importFundingUpdates(ORCIDClient, List, Collection, ProgressHandler) + should be used instead. +

        + +

        + Currently, these creation notifications simply take the shape of ORCID + funding activities themselves (representing a merged activity group). The + group merging selects the meta-data of the preferred activity and the + external identifiers of the whole group (see + ORCIDHelper.group(Object)). The selection of the meta-data + from a group could be changed without affecting the correction of the + procedure. +

        + +

        + Since the put-code attribute is used as a local key of each activity, it + is null for these creation notifications (and not the put-code of the + remote ORCID activity that gave origin to it). Since only the external + identifiers of the local funding entries are used to search for matches, + the remainder meta-data of the input local activities could be left null. +

        + +

        + ORCID activities without minimal quality are ignored by this procedure. + Currently, the quality criteria forces the existence of external + identifiers, the title, publication year and publication type (see + ORCIDHelper.testMinimalQuality(ElementSummary)). Funding + entries that do not match the criteria can be imported with + importInvalid(ORCIDClient, List, ProgressHandler). Note that + currently group merging simply collects the meta-data (other than the + external identifiers) from the preferred activity, which is used in the + quality assessment. +

        + +

        + A set of funding types can be provided to allow the independent + synchronization of different types of entries. Local and remote + activities outside the provided types are simply ignored (they are not + considered invalid). +

        + *
        +
        +
        Parameters:
        +
        client - the ORCID client defining the CRIS Member API and user the + profile to be managed
        +
        locals - the full list of local funding entries
        +
        handler - the progress handler responsible for receiving progress + updates
        +
        types - the types of ORCID funding activities that should be + considered (others are simply ignored)
        +
        Returns:
        +
        the list of new valid funding activities found in the ORCID + profile
        +
        Throws:
        +
        org.um.dsi.gavea.orcid.client.exception.OrcidClientException - if the communication with ORCID fails when getting the + activities summary
        +
        java.lang.InterruptedException - if the asynchronous GET process is interrupted
        +
        java.lang.IllegalArgumentException - if null arguments
        +
        +
      • +
      + + + +
        +
      • +

        importWorkCounter

        +
        public static java.lang.Integer importWorkCounter(ORCIDClient client,
        +                                                  java.util.List<org.um.dsi.gavea.orcid.model.work.Work> locals,
        +                                                  ProgressHandler handler)
        +                                           throws org.um.dsi.gavea.orcid.client.exception.OrcidClientException,
        +                                                  java.lang.IllegalArgumentException
        +

        + Counts new valid works in an ORCID profile given a set of + known local CRIS productions, following the criteria of + importWorks(ORCIDClient, List, ProgressHandler) + but is more efficient, generating less API calls. +

        +
        +
        Parameters:
        +
        client - the ORCID client defining the CRIS Member API and user the + profile to be managed
        +
        locals - the full list of local productions
        +
        handler - the progress handler responsible for receiving progress + updates
        +
        Returns:
        +
        the number of new valid works found in the ORCID + profile
        +
        Throws:
        +
        org.um.dsi.gavea.orcid.client.exception.OrcidClientException - if the communication with ORCID fails when getting the + activities summary
        +
        java.lang.IllegalArgumentException - if null arguments
        +
        See Also:
        +
        importWorks(ORCIDClient, List, ProgressHandler)
        +
        +
      • +
      + + + +
        +
      • +

        importCounter

        +
        @Deprecated
        +public static java.lang.Integer importCounter(ORCIDClient client,
        +                                                          java.util.List<org.um.dsi.gavea.orcid.model.work.Work> locals,
        +                                                          ProgressHandler handler)
        +                                                   throws org.um.dsi.gavea.orcid.client.exception.OrcidClientException,
        +                                                          java.lang.IllegalArgumentException
        + +
        +
        Parameters:
        +
        client - the ORCID client defining the CRIS Member API and user the + profile to be managed
        +
        locals - the full list of local productions
        +
        handler - the progress handler responsible for receiving progress + updates
        +
        Returns:
        +
        the number of new valid works found in the ORCID profile
        +
        Throws:
        +
        org.um.dsi.gavea.orcid.client.exception.OrcidClientException - if the communication with ORCID fails when getting the + activities summary
        +
        java.lang.IllegalArgumentException - if null arguments
        +
        +
      • +
      + + + +
        +
      • +

        importFundingCounter

        +
        public static java.lang.Integer importFundingCounter(ORCIDClient client,
        +                                                     java.util.List<org.um.dsi.gavea.orcid.model.funding.Funding> locals,
        +                                                     java.util.Collection<org.um.dsi.gavea.orcid.model.funding.FundingType> types,
        +                                                     ProgressHandler handler)
        +                                              throws org.um.dsi.gavea.orcid.client.exception.OrcidClientException,
        +                                                     java.lang.IllegalArgumentException
        +

        + Counts new valid funding activities in an ORCID profile given a set of + known local CRIS funding entries, following the criteria of + importFundings(ORCIDClient, List, Collection, ProgressHandler) + but is more efficient, generating less API calls. +

        +
        +
        Parameters:
        +
        client - the ORCID client defining the CRIS Member API and user the + profile to be managed
        +
        locals - the full list of local funding entries
        +
        types - the types of ORCID funding entries that should be considered + (others are simply ignored)
        +
        handler - the progress handler responsible for receiving progress + updates
        +
        Returns:
        +
        the number of new valid funding activities found in the ORCID + profile
        +
        Throws:
        +
        org.um.dsi.gavea.orcid.client.exception.OrcidClientException - if the communication with ORCID fails when getting the + activities summary
        +
        java.lang.IllegalArgumentException - if null arguments
        +
        See Also:
        +
        importFundings(ORCIDClient, List, Collection, ProgressHandler)
        +
        +
      • +
      + + + +
        +
      • +

        importInvalidWorks

        +
        public static java.util.Map<org.um.dsi.gavea.orcid.model.work.Work,java.util.Set<java.lang.String>> importInvalidWorks(ORCIDClient client,
        +                                                                                                                       java.util.List<org.um.dsi.gavea.orcid.model.work.Work> locals,
        +                                                                                                                       ProgressHandler handler)
        +                                                                                                                throws org.um.dsi.gavea.orcid.client.exception.OrcidClientException,
        +                                                                                                                       java.lang.InterruptedException,
        +                                                                                                                       java.lang.IllegalArgumentException
        +

        + Discovers new invalid works (that do not pass the quality criteria, see + ORCIDHelper.testMinimalQuality(ElementSummary)) in an ORCID + profile given a set of known local CRIS entries, as well as the causes + for invalidity (defined at ORCIDWorkHelper). Other than the + criteria, the behavior is similar to that of + importWorks(ORCIDClient, List, ProgressHandler). + Note that currently group merging simply collects the meta-data (other + than the external identifiers) from the preferred activity, which is used + in the quality assessment. +

        +
        +
        Parameters:
        +
        client - the ORCID client defining the CRIS Member API and user the + profile to be managed
        +
        locals - the full list of local works
        +
        handler - the progress handler responsible for receiving progress + updates
        +
        Returns:
        +
        the list of new invalid works found in the ORCID profile
        +
        Throws:
        +
        org.um.dsi.gavea.orcid.client.exception.OrcidClientException - if the communication with ORCID fails when getting the + activities summary
        +
        java.lang.InterruptedException - if the asynchronous GET process is interrupted
        +
        java.lang.IllegalArgumentException - if null arguments
        +
        See Also:
        +
        importWorks(ORCIDClient, List, ProgressHandler)
        +
        +
      • +
      + + + +
        +
      • +

        importInvalid

        +
        @Deprecated
        +public static java.util.Map<org.um.dsi.gavea.orcid.model.work.Work,java.util.Set<java.lang.String>> importInvalid(ORCIDClient client,
        +                                                                                                                              java.util.List<org.um.dsi.gavea.orcid.model.work.Work> locals,
        +                                                                                                                              ProgressHandler handler)
        +                                                                                                                       throws org.um.dsi.gavea.orcid.client.exception.OrcidClientException,
        +                                                                                                                              java.lang.InterruptedException,
        +                                                                                                                              java.lang.IllegalArgumentException
        + +
        +
        Parameters:
        +
        client - the ORCID client defining the CRIS Member API and user the + profile to be managed
        +
        locals - the full list of local works
        +
        handler - the progress handler responsible for receiving progress + updates
        +
        Returns:
        +
        the list of new invalid works found in the ORCID profile
        +
        Throws:
        +
        org.um.dsi.gavea.orcid.client.exception.OrcidClientException - if the communication with ORCID fails when getting the + activities summary
        +
        java.lang.InterruptedException - if the asynchronous GET process is interrupted
        +
        java.lang.IllegalArgumentException - if null arguments
        +
        +
      • +
      + + + +
        +
      • +

        importInvalidFundings

        +
        public static java.util.Map<org.um.dsi.gavea.orcid.model.funding.Funding,java.util.Set<java.lang.String>> importInvalidFundings(ORCIDClient client,
        +                                                                                                                                java.util.List<org.um.dsi.gavea.orcid.model.funding.Funding> locals,
        +                                                                                                                                java.util.Collection<org.um.dsi.gavea.orcid.model.funding.FundingType> types,
        +                                                                                                                                ProgressHandler handler)
        +                                                                                                                         throws org.um.dsi.gavea.orcid.client.exception.OrcidClientException,
        +                                                                                                                                java.lang.InterruptedException,
        +                                                                                                                                java.lang.IllegalArgumentException
        +

        + Discovers new invalid funding activities (that do not pass the quality + criteria, see + ORCIDHelper.testMinimalQuality(ElementSummary)) in an + ORCID profile given a set of known local CRIS entries, as well as the + causes for invalidity (defined at ORCIDFundingHelper). Other than + the criteria, the behavior is similar to that of + importFundings(ORCIDClient, List, Collection, ProgressHandler). + Note that currently group merging simply collects the meta-data (other + than the external identifiers) from the preferred activity, which is used + in the quality assessment. +

        +
        +
        Parameters:
        +
        client - the ORCID client defining the CRIS Member API and user the + profile to be managed
        +
        locals - the full list of local funding activities
        +
        types - the types of ORCID funding activities that should be + considered (others are simply ignored)
        +
        handler - the progress handler responsible for receiving progress + updates
        +
        Returns:
        +
        the list of new invalid funding activities found in the ORCID + profile
        +
        Throws:
        +
        org.um.dsi.gavea.orcid.client.exception.OrcidClientException - if the communication with ORCID fails when getting the + activities summary
        +
        java.lang.InterruptedException - if the asynchronous GET process is interrupted
        +
        java.lang.IllegalArgumentException - if null arguments
        +
        See Also:
        +
        importFundings(ORCIDClient, List, Collection, ProgressHandler)
        +
        +
      • +
      + + + +
        +
      • +

        importWorkUpdates

        +
        public static java.util.List<org.um.dsi.gavea.orcid.model.work.Work> importWorkUpdates(ORCIDClient client,
        +                                                                                       java.util.List<org.um.dsi.gavea.orcid.model.work.Work> locals,
        +                                                                                       ProgressHandler handler)
        +                                                                                throws org.um.dsi.gavea.orcid.client.exception.OrcidClientException,
        +                                                                                       java.lang.IllegalArgumentException
        +

        + Discovers updates to existing local CRIS productions in an ORCID + profile. For each work group at ORCID (merged into as a + single activity by the helper), finds matching + local entries (i.e., those with shared external + identifiers) and creates update notifications if not already up to date. + To import works without shared external identifiers, + importWorks(ORCIDClient, List, ProgressHandler) + should be used instead. +

        + +

        + These update notifications simply take the shape of ORCID activities + themselves (representing a matching activity group). These works contain + only the meta-data that needs to be updated locally. Currently, only the + introduction of newly found external identifiers is considered (i.e., + those that were already present in the local entry that is being updated + are removed from the returned update). Thus, the remainder fields are + returned null. Since only external identifiers are considered the quality + criteria is not enforced on the remote ORCID activities. +

        + +

        + The local entries are tested to be up-to-date by simply checking whether + they contain every external identifiers in the ORCID group (see + ORCIDHelper.hasNewSelfIDs(ElementSummary, ElementSummary). Thus + the remainder meta-data of the local entries can be currently left null. +

        + +

        + The put-code attribute is used as a local key of each CRIS production. + This means that the returned activities representing the updates have the + put-code of the local entry that is to be updated (and not the put-code + of the ORCID activity that gave origin to it). +

        +
        +
        Parameters:
        +
        client - the ORCID client defining the CRIS Member API and user the + profile to be managed
        +
        locals - the full list of local productions
        +
        handler - the progress handler responsible for receiving progress + updates
        +
        Returns:
        +
        the list of work updates found in the ORCID profile, pointing + to the respective local activity
        +
        Throws:
        +
        org.um.dsi.gavea.orcid.client.exception.OrcidClientException - if the communication with ORCID fails when getting the + activities summary
        +
        java.lang.IllegalArgumentException - if null arguments
        +
        +
      • +
      + + + +
        +
      • +

        importUpdates

        +
        @Deprecated
        +public static java.util.List<org.um.dsi.gavea.orcid.model.work.Work> importUpdates(ORCIDClient client,
        +                                                                                               java.util.List<org.um.dsi.gavea.orcid.model.work.Work> locals,
        +                                                                                               ProgressHandler handler)
        +                                                                                        throws org.um.dsi.gavea.orcid.client.exception.OrcidClientException,
        +                                                                                               java.lang.IllegalArgumentException
        + +
        +
        Parameters:
        +
        client - the ORCID client defining the CRIS Member API and user the + profile to be managed
        +
        locals - the full list of local productions
        +
        handler - the progress handler responsible for receiving progress + updates
        +
        Returns:
        +
        the list of work updates found in the ORCID profile, pointing + to the respective local activity
        +
        Throws:
        +
        org.um.dsi.gavea.orcid.client.exception.OrcidClientException - if the communication with ORCID fails when getting the + activities summary
        +
        java.lang.IllegalArgumentException - if null arguments
        +
        +
      • +
      + + + +
        +
      • +

        importFundingUpdates

        +
        public static java.util.List<org.um.dsi.gavea.orcid.model.funding.Funding> importFundingUpdates(ORCIDClient client,
        +                                                                                                java.util.List<org.um.dsi.gavea.orcid.model.funding.Funding> locals,
        +                                                                                                java.util.Collection<org.um.dsi.gavea.orcid.model.funding.FundingType> types,
        +                                                                                                ProgressHandler handler)
        +                                                                                         throws org.um.dsi.gavea.orcid.client.exception.OrcidClientException,
        +                                                                                                java.lang.IllegalArgumentException
        +

        + Discovers updates to existing local CRIS funding activities in an ORCID + profile. For each funding activity group at ORCID (merged into as a + single activity by the helper), finds matching + local entries (i.e., those with shared external + identifiers) and creates update notifications if not already up to date. + To import funding activities without shared external identifiers, + importFundings(ORCIDClient, List, Collection, ProgressHandler) + should be used instead. +

        + +

        + These update notifications simply take the shape of ORCID activities + themselves (representing a matching activity group). These works contain + only the meta-data that needs to be updated locally. Currently, only the + introduction of newly found external identifiers is considered (i.e., + those that were already present in the local entry that is being updated + are removed from the returned update). Thus, the remainder fields are + returned null. Since only external identifiers are considered the quality + criteria is not enforced on the remote ORCID activities. +

        + +

        + The local entries are tested to be up-to-date by simply checking whether + they contain every external identifiers in the ORCID group (see + ORCIDHelper.hasNewSelfIDs(ElementSummary, ElementSummary). Thus + the remainder meta-data of the local entries can be currently left null. +

        + +

        + A set of activity types can be provided to allow the independent + synchronization of different types of entries. Local and remote + activities outside the provided types are simply ignored (they are not + considered invalid). +

        + +

        + The put-code attribute is used as a local key of each CRIS funding entry. + This means that the returned activities representing the updates have the + put-code of the local entry that is to be updated (and not the put-code + of the ORCID activity that gave origin to it). +

        +
        +
        Parameters:
        +
        client - the ORCID client defining the CRIS Member API and user the + profile to be managed
        +
        locals - the full list of local funding activities
        +
        types - the types of ORCID funding activities that should be + considered (others are simply ignored)
        +
        handler - the progress handler responsible for receiving progress + updates
        +
        Returns:
        +
        the list of funding updates found in the ORCID profile, pointing + to the respective local activity
        +
        Throws:
        +
        org.um.dsi.gavea.orcid.client.exception.OrcidClientException - if the communication with ORCID fails when getting the + activities summary
        +
        java.lang.IllegalArgumentException - if null arguments
        +
        +
      • +
      +
    • +
    +
  • +
+
+
+ + +
+ + + + + + + +
+ + + + diff --git a/docs/pt/ptcris/PTCRISyncResult.html b/docs/pt/ptcris/PTCRISyncResult.html new file mode 100644 index 0000000..fda8513 --- /dev/null +++ b/docs/pt/ptcris/PTCRISyncResult.html @@ -0,0 +1,588 @@ + + + + + +PTCRISyncResult + + + + + + + + +
+ + + + + + + +
+ + + +
+
pt.ptcris
+

Class PTCRISyncResult<E extends org.um.dsi.gavea.orcid.model.common.ElementSummary>

+
+
+ +
+
    +
  • +
    +
    +
    public final class PTCRISyncResult<E extends org.um.dsi.gavea.orcid.model.common.ElementSummary>
    +extends java.lang.Object
    +
    A class that encapsulates the result of the synchronization procedures for a + particular activity. Currently only the + export methods report these results.
    +
  • +
+
+
+
    +
  • + + + +
      +
    • + + +

      Method Summary

      + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
      All Methods Static Methods Concrete Methods 
      Modifier and TypeMethod and Description
      static <E extends org.um.dsi.gavea.orcid.model.common.ElementSummary>
      PTCRISyncResult<E>
      fail(org.um.dsi.gavea.orcid.client.exception.OrcidClientException exception) +
      Creates message reporting a failure at the ORCID API level.
      +
      static <E extends org.um.dsi.gavea.orcid.model.common.ElementSummary>
      PTCRISyncResult<E>
      invalid(InvalidActivityException exception) +
      Creates message reporting an invalid activity.
      +
      static <E extends org.um.dsi.gavea.orcid.model.common.ElementSummary>
      PTCRISyncResult<E>
      ok_add(java.math.BigInteger putcode) +
      Creates a successful "add" message with the assigned put-code.
      +
      static <E extends org.um.dsi.gavea.orcid.model.common.ElementSummary>
      PTCRISyncResult<E>
      ok_del() +
      Creates a successful "delete" message.
      +
      static <E extends org.um.dsi.gavea.orcid.model.common.ElementSummary>
      PTCRISyncResult<E>
      ok_get(java.math.BigInteger putcode, + E element) +
      Creates a successful "get" message with the assigned put-code.
      +
      static <E extends org.um.dsi.gavea.orcid.model.common.ElementSummary>
      PTCRISyncResult<E>
      ok_upd() +
      Creates a successful "update" message.
      +
      static <E extends org.um.dsi.gavea.orcid.model.common.ElementSummary>
      PTCRISyncResult<E>
      uptodate() +
      Creates an "already up-to-date" message.
      +
      +
        +
      • + + +

        Methods inherited from class java.lang.Object

        +equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • +
      +
    • +
    +
  • +
+
+
+
    +
  • + + + +
      +
    • + + +

      Method Detail

      + + + + + +
        +
      • +

        ok_get

        +
        public static <E extends org.um.dsi.gavea.orcid.model.common.ElementSummary> PTCRISyncResult<E> ok_get(java.math.BigInteger putcode,
        +                                                                                                       E element)
        +
        Creates a successful "get" message with the assigned put-code.
        +
        +
        Type Parameters:
        +
        E - the activity type
        +
        Parameters:
        +
        putcode - the put-code of the get request
        +
        element - the retrieved activity
        +
        Returns:
        +
        an OK get message
        +
        +
      • +
      + + + +
        +
      • +

        ok_add

        +
        public static <E extends org.um.dsi.gavea.orcid.model.common.ElementSummary> PTCRISyncResult<E> ok_add(java.math.BigInteger putcode)
        +
        Creates a successful "add" message with the assigned put-code.
        +
        +
        Type Parameters:
        +
        E - the activity type
        +
        Parameters:
        +
        putcode - the put-code of the newly added activity
        +
        Returns:
        +
        an OK add message
        +
        +
      • +
      + + + +
        +
      • +

        ok_upd

        +
        public static <E extends org.um.dsi.gavea.orcid.model.common.ElementSummary> PTCRISyncResult<E> ok_upd()
        +
        Creates a successful "update" message.
        +
        +
        Type Parameters:
        +
        E - the activity type
        +
        Returns:
        +
        an OK update message
        +
        +
      • +
      + + + +
        +
      • +

        ok_del

        +
        public static <E extends org.um.dsi.gavea.orcid.model.common.ElementSummary> PTCRISyncResult<E> ok_del()
        +
        Creates a successful "delete" message.
        +
        +
        Type Parameters:
        +
        E - the activity type
        +
        Returns:
        +
        an OK delete message
        +
        +
      • +
      + + + +
        +
      • +

        uptodate

        +
        public static <E extends org.um.dsi.gavea.orcid.model.common.ElementSummary> PTCRISyncResult<E> uptodate()
        +
        Creates an "already up-to-date" message.
        +
        +
        Type Parameters:
        +
        E - the activity type
        +
        Returns:
        +
        an already up to date message
        +
        +
      • +
      + + + +
        +
      • +

        fail

        +
        public static <E extends org.um.dsi.gavea.orcid.model.common.ElementSummary> PTCRISyncResult<E> fail(org.um.dsi.gavea.orcid.client.exception.OrcidClientException exception)
        +
        Creates message reporting a failure at the ORCID API level.
        +
        +
        Type Parameters:
        +
        E - the activity type
        +
        Parameters:
        +
        exception - the ORCID client exception
        +
        Returns:
        +
        the resulting message
        +
        +
      • +
      + + + +
        +
      • +

        invalid

        +
        public static <E extends org.um.dsi.gavea.orcid.model.common.ElementSummary> PTCRISyncResult<E> invalid(InvalidActivityException exception)
        +
        Creates message reporting an invalid activity.
        +
        +
        Type Parameters:
        +
        E - the activity type
        +
        Parameters:
        +
        exception - the reasons for invalidity
        +
        Returns:
        +
        the resulting message
        +
        +
      • +
      +
    • +
    +
  • +
+
+
+ + +
+ + + + + + + +
+ + + + diff --git a/docs/pt/ptcris/TempORCIDClient.html b/docs/pt/ptcris/TempORCIDClient.html new file mode 100644 index 0000000..7d174e9 --- /dev/null +++ b/docs/pt/ptcris/TempORCIDClient.html @@ -0,0 +1,328 @@ + + + + + +TempORCIDClient + + + + + + + + +
+ + + + + + + +
+ + + +
+
pt.ptcris
+

Class TempORCIDClient

+
+
+ +
+
    +
  • +
    +
    All Implemented Interfaces:
    +
    java.io.Serializable
    +
    +
    +
    Deprecated.  +
    temporary class to be deleted once readFundingsSummary is added to the + ORCID client.
    +
    +
    +
    public class TempORCIDClient
    +extends org.um.dsi.gavea.orcid.client.OrcidOAuthClient
    +
    +
    See Also:
    +
    Serialized Form
    +
    +
  • +
+
+
+
    +
  • + +
      +
    • + + +

      Constructor Summary

      + + + + + + + + +
      Constructors 
      Constructor and Description
      TempORCIDClient(java.lang.String loginUri, + java.lang.String apiUri, + java.lang.String clientId, + java.lang.String clientSecret, + java.lang.String redirectUri, + boolean debugMode) +
      Deprecated. 
      +
    • +
    + +
      +
    • + + +

      Method Summary

      + + + + + + + + + + +
      All Methods Instance Methods Concrete Methods Deprecated Methods 
      Modifier and TypeMethod and Description
      org.um.dsi.gavea.orcid.model.activities.FundingsreadFundingsSummary(org.um.dsi.gavea.orcid.client.OrcidAccessToken token) +
      Deprecated. 
      +
        +
      • + + +

        Methods inherited from class org.um.dsi.gavea.orcid.client.OrcidOAuthClient

        +addAddress, addEducation, addEmployment, addExternalIdentifier, addFunding, addKeyword, addOtherName, addPeerReview, addResearcherUrl, addWork, addWorks, deleteAddress, deleteEducation, deleteEmployment, deleteExternalIdentifier, deleteFunding, deleteKeyword, deleteOtherName, deletePeerReview, deleteResearcherUrl, deleteWork, getAccessTokens, getAuthorizeUri, getAuthorizeUri, readActivitiesSummary, readAddress, readAddresses, readBiography, readEducation, readEducationSummary, readEmails, readEmployment, readEmploymentSummary, readExternalIdentifier, readExternalIdentifiers, readFunding, readFundingSummary, readKeyword, readKeywords, readOtherName, readOtherNames, readPeerReview, readPeerReviewSummary, readPerson, readPersonalDetails, readResearcherUrl, readResearcherUrls, readWork, readWorks, readWorksSummary, readWorkSummary, updateAddress, updateEducation, updateEmployment, updateExternalIdentifier, updateFunding, updateKeyword, updateOtherName, updatePeerReview, updateResearcherUrl, updateWork
      • +
      +
        +
      • + + +

        Methods inherited from class org.um.dsi.gavea.orcid.client.BaseOrcidOAuthClient

        +getClientId
      • +
      +
        +
      • + + +

        Methods inherited from class java.lang.Object

        +equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • +
      +
    • +
    +
  • +
+
+
+
    +
  • + +
      +
    • + + +

      Constructor Detail

      + + + +
        +
      • +

        TempORCIDClient

        +
        public TempORCIDClient(java.lang.String loginUri,
        +                       java.lang.String apiUri,
        +                       java.lang.String clientId,
        +                       java.lang.String clientSecret,
        +                       java.lang.String redirectUri,
        +                       boolean debugMode)
        +
        Deprecated. 
        +
      • +
      +
    • +
    + +
      +
    • + + +

      Method Detail

      + + + +
        +
      • +

        readFundingsSummary

        +
        public org.um.dsi.gavea.orcid.model.activities.Fundings readFundingsSummary(org.um.dsi.gavea.orcid.client.OrcidAccessToken token)
        +                                                                     throws org.um.dsi.gavea.orcid.client.exception.OrcidClientException
        +
        Deprecated. 
        +
        +
        Throws:
        +
        org.um.dsi.gavea.orcid.client.exception.OrcidClientException
        +
        +
      • +
      +
    • +
    +
  • +
+
+
+ + +
+ + + + + + + +
+ + + + diff --git a/docs/pt/ptcris/class-use/ORCIDClient.html b/docs/pt/ptcris/class-use/ORCIDClient.html new file mode 100644 index 0000000..9676f11 --- /dev/null +++ b/docs/pt/ptcris/class-use/ORCIDClient.html @@ -0,0 +1,403 @@ + + + + + +Uses of Interface pt.ptcris.ORCIDClient + + + + + + + + +
+ + + + + + + +
+ + +
+

Uses of Interface
pt.ptcris.ORCIDClient

+
+
+ +
+ +
+ + + + + + + +
+ + + + diff --git a/docs/pt/ptcris/class-use/ORCIDClientImpl.html b/docs/pt/ptcris/class-use/ORCIDClientImpl.html new file mode 100644 index 0000000..26d9a4c --- /dev/null +++ b/docs/pt/ptcris/class-use/ORCIDClientImpl.html @@ -0,0 +1,124 @@ + + + + + +Uses of Class pt.ptcris.ORCIDClientImpl + + + + + + + + +
+ + + + + + + +
+ + +
+

Uses of Class
pt.ptcris.ORCIDClientImpl

+
+
No usage of pt.ptcris.ORCIDClientImpl
+ +
+ + + + + + + +
+ + + + diff --git a/docs/pt/ptcris/class-use/PTCRISGrouper.html b/docs/pt/ptcris/class-use/PTCRISGrouper.html new file mode 100644 index 0000000..45d2373 --- /dev/null +++ b/docs/pt/ptcris/class-use/PTCRISGrouper.html @@ -0,0 +1,124 @@ + + + + + +Uses of Class pt.ptcris.PTCRISGrouper + + + + + + + + +
+ + + + + + + +
+ + +
+

Uses of Class
pt.ptcris.PTCRISGrouper

+
+
No usage of pt.ptcris.PTCRISGrouper
+ +
+ + + + + + + +
+ + + + diff --git a/docs/pt/ptcris/class-use/PTCRISync.html b/docs/pt/ptcris/class-use/PTCRISync.html new file mode 100644 index 0000000..ad3e1d5 --- /dev/null +++ b/docs/pt/ptcris/class-use/PTCRISync.html @@ -0,0 +1,124 @@ + + + + + +Uses of Class pt.ptcris.PTCRISync + + + + + + + + +
+ + + + + + + +
+ + +
+

Uses of Class
pt.ptcris.PTCRISync

+
+
No usage of pt.ptcris.PTCRISync
+ +
+ + + + + + + +
+ + + + diff --git a/docs/pt/ptcris/class-use/PTCRISyncResult.html b/docs/pt/ptcris/class-use/PTCRISyncResult.html new file mode 100644 index 0000000..cdbe83b --- /dev/null +++ b/docs/pt/ptcris/class-use/PTCRISyncResult.html @@ -0,0 +1,461 @@ + + + + + +Uses of Class pt.ptcris.PTCRISyncResult + + + + + + + + +
+ + + + + + + +
+ + +
+

Uses of Class
pt.ptcris.PTCRISyncResult

+
+
+ +
+ +
+ + + + + + + +
+ + + + diff --git a/docs/pt/ptcris/class-use/TempORCIDClient.html b/docs/pt/ptcris/class-use/TempORCIDClient.html new file mode 100644 index 0000000..48521d9 --- /dev/null +++ b/docs/pt/ptcris/class-use/TempORCIDClient.html @@ -0,0 +1,124 @@ + + + + + +Uses of Class pt.ptcris.TempORCIDClient + + + + + + + + +
+ + + + + + + +
+ + +
+

Uses of Class
pt.ptcris.TempORCIDClient

+
+
No usage of pt.ptcris.TempORCIDClient
+ +
+ + + + + + + +
+ + + + diff --git a/docs/pt/ptcris/exceptions/InvalidActivityException.html b/docs/pt/ptcris/exceptions/InvalidActivityException.html new file mode 100644 index 0000000..71e4e36 --- /dev/null +++ b/docs/pt/ptcris/exceptions/InvalidActivityException.html @@ -0,0 +1,346 @@ + + + + + +InvalidActivityException + + + + + + + + +
+ + + + + + + +
+ + + +
+
pt.ptcris.exceptions
+

Class InvalidActivityException

+
+
+ +
+
    +
  • +
    +
    All Implemented Interfaces:
    +
    java.io.Serializable
    +
    +
    +
    +
    public class InvalidActivityException
    +extends java.lang.Exception
    +
    +
    See Also:
    +
    Serialized Form
    +
    +
  • +
+
+
+
    +
  • + + + +
      +
    • + + +

      Method Summary

      + + + + + + + + + + +
      All Methods Instance Methods Concrete Methods 
      Modifier and TypeMethod and Description
      java.util.Set<java.lang.String>getInvalidTypes() 
      +
        +
      • + + +

        Methods inherited from class java.lang.Throwable

        +addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
      • +
      +
        +
      • + + +

        Methods inherited from class java.lang.Object

        +equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
      • +
      +
    • +
    +
  • +
+
+
+
    +
  • + +
      +
    • + + +

      Constructor Detail

      + + + +
        +
      • +

        InvalidActivityException

        +
        public InvalidActivityException()
        +
      • +
      + + + +
        +
      • +

        InvalidActivityException

        +
        public InvalidActivityException(java.lang.String message)
        +
      • +
      + + + +
        +
      • +

        InvalidActivityException

        +
        public InvalidActivityException(java.lang.Throwable cause)
        +
      • +
      + + + +
        +
      • +

        InvalidActivityException

        +
        public InvalidActivityException(java.lang.String message,
        +                                java.lang.Throwable cause)
        +
      • +
      + + + +
        +
      • +

        InvalidActivityException

        +
        public InvalidActivityException(java.util.Set<java.lang.String> res)
        +
      • +
      +
    • +
    + +
      +
    • + + +

      Method Detail

      + + + +
        +
      • +

        getInvalidTypes

        +
        public java.util.Set<java.lang.String> getInvalidTypes()
        +
      • +
      +
    • +
    +
  • +
+
+
+ + +
+ + + + + + + +
+ + + + diff --git a/docs/pt/ptcris/exceptions/class-use/InvalidActivityException.html b/docs/pt/ptcris/exceptions/class-use/InvalidActivityException.html new file mode 100644 index 0000000..0a1b166 --- /dev/null +++ b/docs/pt/ptcris/exceptions/class-use/InvalidActivityException.html @@ -0,0 +1,192 @@ + + + + + +Uses of Class pt.ptcris.exceptions.InvalidActivityException + + + + + + + + +
+ + + + + + + +
+ + +
+

Uses of Class
pt.ptcris.exceptions.InvalidActivityException

+
+
+ +
+ +
+ + + + + + + +
+ + + + diff --git a/docs/pt/ptcris/exceptions/package-frame.html b/docs/pt/ptcris/exceptions/package-frame.html new file mode 100644 index 0000000..76d7c22 --- /dev/null +++ b/docs/pt/ptcris/exceptions/package-frame.html @@ -0,0 +1,20 @@ + + + + + +pt.ptcris.exceptions + + + + + +

pt.ptcris.exceptions

+
+

Exceptions

+ +
+ + diff --git a/docs/pt/ptcris/exceptions/package-summary.html b/docs/pt/ptcris/exceptions/package-summary.html new file mode 100644 index 0000000..0fb8bc3 --- /dev/null +++ b/docs/pt/ptcris/exceptions/package-summary.html @@ -0,0 +1,142 @@ + + + + + +pt.ptcris.exceptions + + + + + + + + +
+ + + + + + + +
+ + +
+

Package pt.ptcris.exceptions

+
+
+ +
+ +
+ + + + + + + +
+ + + + diff --git a/docs/pt/ptcris/exceptions/package-tree.html b/docs/pt/ptcris/exceptions/package-tree.html new file mode 100644 index 0000000..f0348aa --- /dev/null +++ b/docs/pt/ptcris/exceptions/package-tree.html @@ -0,0 +1,145 @@ + + + + + +pt.ptcris.exceptions Class Hierarchy + + + + + + + + +
+ + + + + + + +
+ + +
+

Hierarchy For Package pt.ptcris.exceptions

+Package Hierarchies: + +
+
+

Class Hierarchy

+ +
+ +
+ + + + + + + +
+ + + + diff --git a/docs/pt/ptcris/exceptions/package-use.html b/docs/pt/ptcris/exceptions/package-use.html new file mode 100644 index 0000000..b379d5f --- /dev/null +++ b/docs/pt/ptcris/exceptions/package-use.html @@ -0,0 +1,176 @@ + + + + + +Uses of Package pt.ptcris.exceptions + + + + + + + + +
+ + + + + + + +
+ + +
+

Uses of Package
pt.ptcris.exceptions

+
+
+ +
+ +
+ + + + + + + +
+ + + + diff --git a/docs/pt/ptcris/grouper/ActivityComparator.html b/docs/pt/ptcris/grouper/ActivityComparator.html new file mode 100644 index 0000000..4eb84c8 --- /dev/null +++ b/docs/pt/ptcris/grouper/ActivityComparator.html @@ -0,0 +1,315 @@ + + + + + +ActivityComparator + + + + + + + + +
+ + + + + + + +
+ + + +
+
pt.ptcris.grouper
+

Class ActivityComparator<A>

+
+
+ +
+
    +
  • +
    +
    Type Parameters:
    +
    A - the type of activities being compared
    +
    +
    +
    +
    public abstract class ActivityComparator<A>
    +extends java.lang.Object
    +
    An activity comparator used by the grouper to creates groups of matching + activities. Concrete implementations should be provided by the users through + a compare(Object, Object) that calculates a similarity + metric between to activities, and a threshold().
    +
  • +
+
+
+
    +
  • + +
      +
    • + + +

      Constructor Summary

      + + + + + + + + +
      Constructors 
      Constructor and Description
      ActivityComparator() 
      +
    • +
    + +
      +
    • + + +

      Method Summary

      + + + + + + + + + + + + + + +
      All Methods Instance Methods Abstract Methods 
      Modifier and TypeMethod and Description
      abstract floatcompare(A act1, + A act2) +
      Calculates a similarity metric between two activities.
      +
      abstract intthreshold() +
      A (non-inclusive) threshold on the similarity metric that defines + matching activities.
      +
      +
        +
      • + + +

        Methods inherited from class java.lang.Object

        +equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • +
      +
    • +
    +
  • +
+
+
+
    +
  • + +
      +
    • + + +

      Constructor Detail

      + + + +
        +
      • +

        ActivityComparator

        +
        public ActivityComparator()
        +
      • +
      +
    • +
    + +
      +
    • + + +

      Method Detail

      + + + +
        +
      • +

        threshold

        +
        public abstract int threshold()
        +
        A (non-inclusive) threshold on the similarity metric that defines + matching activities.
        +
        +
        Returns:
        +
        the threshold value
        +
        +
      • +
      + + + + + +
        +
      • +

        compare

        +
        public abstract float compare(A act1,
        +                              A act2)
        +
        Calculates a similarity metric between two activities.
        +
        +
        Parameters:
        +
        act1 - one activity
        +
        act2 - other activity
        +
        Returns:
        +
        the similarity metric between the activities
        +
        +
      • +
      +
    • +
    +
  • +
+
+
+ + +
+ + + + + + + +
+ + + + diff --git a/docs/pt/ptcris/grouper/ActivityGroup.html b/docs/pt/ptcris/grouper/ActivityGroup.html new file mode 100644 index 0000000..ddab9c1 --- /dev/null +++ b/docs/pt/ptcris/grouper/ActivityGroup.html @@ -0,0 +1,203 @@ + + + + + +ActivityGroup + + + + + + + + +
+ + + + + + + +
+ + + +
+
pt.ptcris.grouper
+

Class ActivityGroup<A>

+
+
+ +
+
    +
  • +
    +
    Type Parameters:
    +
    A - the type of activities being grouped
    +
    +
    +
    +
    public class ActivityGroup<A>
    +extends java.lang.Object
    +
    Represents groups of matched activities. Currently, simply encapsulates a set of + activities, there is no additional structure.
    +
  • +
+
+
+
    +
  • + +
      +
    • + + +

      Method Summary

      +
        +
      • + + +

        Methods inherited from class java.lang.Object

        +equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • +
      +
    • +
    +
  • +
+
+
+ + +
+ + + + + + + +
+ + + + diff --git a/docs/pt/ptcris/grouper/GroupGenerator.html b/docs/pt/ptcris/grouper/GroupGenerator.html new file mode 100644 index 0000000..1f8e75c --- /dev/null +++ b/docs/pt/ptcris/grouper/GroupGenerator.html @@ -0,0 +1,318 @@ + + + + + +GroupGenerator + + + + + + + + +
+ + + + + + + +
+ + + +
+
pt.ptcris.grouper
+

Class GroupGenerator<E>

+
+
+ +
+
    +
  • +
    +
    Type Parameters:
    +
    E - the type of activities being grouped
    +
    +
    +
    +
    public class GroupGenerator<E>
    +extends java.lang.Object
    +
    A generator that, provided the concrete activity + comparator iteratively groups works that are below the threshold as + activity groups.
    +
  • +
+
+
+
    +
  • + +
      +
    • + + +

      Constructor Summary

      + + + + + + + + +
      Constructors 
      Constructor and Description
      GroupGenerator(ActivityComparator<E> comparator) +
      Creates a new activity group generator, provided a comparator that will + determine whether activities match.
      +
      +
    • +
    + +
      +
    • + + +

      Method Summary

      + + + + + + + + + + + + + + +
      All Methods Instance Methods Concrete Methods 
      Modifier and TypeMethod and Description
      java.util.List<ActivityGroup<E>>getGroups() +
      The activity groups generated so far.
      +
      voidgroup(E act) +
      Adds an activity with the already existing groups.
      +
      +
        +
      • + + +

        Methods inherited from class java.lang.Object

        +equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • +
      +
    • +
    +
  • +
+
+
+
    +
  • + +
      +
    • + + +

      Constructor Detail

      + + + +
        +
      • +

        GroupGenerator

        +
        public GroupGenerator(ActivityComparator<E> comparator)
        +
        Creates a new activity group generator, provided a comparator that will + determine whether activities match.
        +
        +
        Parameters:
        +
        comparator - the activity comparator
        +
        +
      • +
      +
    • +
    + +
      +
    • + + +

      Method Detail

      + + + + + +
        +
      • +

        group

        +
        public void group(E act)
        +
        Adds an activity with the already existing groups. If the activity + matches more than one group, then those groups are merged. If it matches + none, a new group is created.
        +
        +
        Parameters:
        +
        act - the activity to be added to the groups
        +
        +
      • +
      + + + +
        +
      • +

        getGroups

        +
        public java.util.List<ActivityGroup<E>> getGroups()
        +
        The activity groups generated so far. The order is currently meaningless.
        +
        +
        Returns:
        +
        the groups
        +
        +
      • +
      +
    • +
    +
  • +
+
+
+ + +
+ + + + + + + +
+ + + + diff --git a/docs/pt/ptcris/grouper/class-use/ActivityComparator.html b/docs/pt/ptcris/grouper/class-use/ActivityComparator.html new file mode 100644 index 0000000..2f86cf9 --- /dev/null +++ b/docs/pt/ptcris/grouper/class-use/ActivityComparator.html @@ -0,0 +1,191 @@ + + + + + +Uses of Class pt.ptcris.grouper.ActivityComparator + + + + + + + + +
+ + + + + + + +
+ + +
+

Uses of Class
pt.ptcris.grouper.ActivityComparator

+
+
+ +
+ +
+ + + + + + + +
+ + + + diff --git a/docs/pt/ptcris/grouper/class-use/ActivityGroup.html b/docs/pt/ptcris/grouper/class-use/ActivityGroup.html new file mode 100644 index 0000000..77365fe --- /dev/null +++ b/docs/pt/ptcris/grouper/class-use/ActivityGroup.html @@ -0,0 +1,192 @@ + + + + + +Uses of Class pt.ptcris.grouper.ActivityGroup + + + + + + + + +
+ + + + + + + +
+ + +
+

Uses of Class
pt.ptcris.grouper.ActivityGroup

+
+
+ +
+ +
+ + + + + + + +
+ + + + diff --git a/docs/pt/ptcris/grouper/class-use/GroupGenerator.html b/docs/pt/ptcris/grouper/class-use/GroupGenerator.html new file mode 100644 index 0000000..e93580e --- /dev/null +++ b/docs/pt/ptcris/grouper/class-use/GroupGenerator.html @@ -0,0 +1,124 @@ + + + + + +Uses of Class pt.ptcris.grouper.GroupGenerator + + + + + + + + +
+ + + + + + + +
+ + +
+

Uses of Class
pt.ptcris.grouper.GroupGenerator

+
+
No usage of pt.ptcris.grouper.GroupGenerator
+ +
+ + + + + + + +
+ + + + diff --git a/docs/pt/ptcris/grouper/package-frame.html b/docs/pt/ptcris/grouper/package-frame.html new file mode 100644 index 0000000..4be7e54 --- /dev/null +++ b/docs/pt/ptcris/grouper/package-frame.html @@ -0,0 +1,22 @@ + + + + + +pt.ptcris.grouper + + + + + +

pt.ptcris.grouper

+
+

Classes

+ +
+ + diff --git a/docs/pt/ptcris/grouper/package-summary.html b/docs/pt/ptcris/grouper/package-summary.html new file mode 100644 index 0000000..f8ae4eb --- /dev/null +++ b/docs/pt/ptcris/grouper/package-summary.html @@ -0,0 +1,159 @@ + + + + + +pt.ptcris.grouper + + + + + + + + +
+ + + + + + + +
+ + +
+

Package pt.ptcris.grouper

+
+
+ +
+ +
+ + + + + + + +
+ + + + diff --git a/docs/pt/ptcris/grouper/package-tree.html b/docs/pt/ptcris/grouper/package-tree.html new file mode 100644 index 0000000..5dfedf8 --- /dev/null +++ b/docs/pt/ptcris/grouper/package-tree.html @@ -0,0 +1,139 @@ + + + + + +pt.ptcris.grouper Class Hierarchy + + + + + + + + +
+ + + + + + + +
+ + +
+

Hierarchy For Package pt.ptcris.grouper

+Package Hierarchies: + +
+
+

Class Hierarchy

+ +
+ +
+ + + + + + + +
+ + + + diff --git a/docs/pt/ptcris/grouper/package-use.html b/docs/pt/ptcris/grouper/package-use.html new file mode 100644 index 0000000..5ed86ae --- /dev/null +++ b/docs/pt/ptcris/grouper/package-use.html @@ -0,0 +1,192 @@ + + + + + +Uses of Package pt.ptcris.grouper + + + + + + + + +
+ + + + + + + +
+ + +
+

Uses of Package
pt.ptcris.grouper

+
+
+ +
+ +
+ + + + + + + +
+ + + + diff --git a/docs/pt/ptcris/handlers/ProgressHandler.html b/docs/pt/ptcris/handlers/ProgressHandler.html new file mode 100644 index 0000000..5d590cd --- /dev/null +++ b/docs/pt/ptcris/handlers/ProgressHandler.html @@ -0,0 +1,330 @@ + + + + + +ProgressHandler + + + + + + + + +
+ + + + + + + +
+ + + +
+
pt.ptcris.handlers
+

Interface ProgressHandler

+
+
+
+
    +
  • +
    +
    +
    public interface ProgressHandler
    +
    An interface for reporting the progress of the synchronization procedures and + the comprising tasks.
    +
  • +
+
+
+
    +
  • + + +
  • +
+
+
+
    +
  • + +
      +
    • + + +

      Method Detail

      + + + +
        +
      • +

        setProgress

        +
        @Deprecated
        +void setProgress(int progress)
        +
        Deprecated. 
        +
        Used to set the progress of a task, by using percentual values (between 0 + and 100). It can be used to start a task, where progress = 0
        +
        +
        Parameters:
        +
        progress - the progress of the current task
        +
        +
      • +
      + + + +
        +
      • +

        setCurrentStatus

        +
        void setCurrentStatus(java.lang.String message)
        +
        Used to set the text of the current task
        +
        +
        Parameters:
        +
        message - the message to be sent to the progress handler
        +
        +
      • +
      + + + +
        +
      • +

        setCurrentStatus

        +
        void setCurrentStatus(java.lang.String message,
        +                      int size)
        +
      • +
      + + + +
        +
      • +

        sendError

        +
        void sendError(java.lang.String message)
        +
        Used to send an error message to the progress handler
        +
        +
        Parameters:
        +
        message - the error message to be sent to the progress handler
        +
        +
      • +
      + + + +
        +
      • +

        done

        +
        void done()
        +
        Used to set the current task as finalized
        +
      • +
      + + + +
        +
      • +

        step

        +
        void step()
        +
      • +
      + + + +
        +
      • +

        step

        +
        void step(int step)
        +
      • +
      +
    • +
    +
  • +
+
+
+ + +
+ + + + + + + +
+ + + + diff --git a/docs/pt/ptcris/handlers/class-use/ProgressHandler.html b/docs/pt/ptcris/handlers/class-use/ProgressHandler.html new file mode 100644 index 0000000..a21a56f --- /dev/null +++ b/docs/pt/ptcris/handlers/class-use/ProgressHandler.html @@ -0,0 +1,371 @@ + + + + + +Uses of Interface pt.ptcris.handlers.ProgressHandler + + + + + + + + +
+ + + + + + + +
+ + +
+

Uses of Interface
pt.ptcris.handlers.ProgressHandler

+
+
+ +
+ +
+ + + + + + + +
+ + + + diff --git a/docs/pt/ptcris/handlers/package-frame.html b/docs/pt/ptcris/handlers/package-frame.html new file mode 100644 index 0000000..94c04df --- /dev/null +++ b/docs/pt/ptcris/handlers/package-frame.html @@ -0,0 +1,20 @@ + + + + + +pt.ptcris.handlers + + + + + +

pt.ptcris.handlers

+
+

Interfaces

+ +
+ + diff --git a/docs/pt/ptcris/handlers/package-summary.html b/docs/pt/ptcris/handlers/package-summary.html new file mode 100644 index 0000000..9a40690 --- /dev/null +++ b/docs/pt/ptcris/handlers/package-summary.html @@ -0,0 +1,145 @@ + + + + + +pt.ptcris.handlers + + + + + + + + +
+ + + + + + + +
+ + +
+

Package pt.ptcris.handlers

+
+
+ +
+ +
+ + + + + + + +
+ + + + diff --git a/docs/pt/ptcris/handlers/package-tree.html b/docs/pt/ptcris/handlers/package-tree.html new file mode 100644 index 0000000..57ca408 --- /dev/null +++ b/docs/pt/ptcris/handlers/package-tree.html @@ -0,0 +1,133 @@ + + + + + +pt.ptcris.handlers Class Hierarchy + + + + + + + + +
+ + + + + + + +
+ + +
+

Hierarchy For Package pt.ptcris.handlers

+Package Hierarchies: + +
+
+

Interface Hierarchy

+ +
+ +
+ + + + + + + +
+ + + + diff --git a/docs/pt/ptcris/handlers/package-use.html b/docs/pt/ptcris/handlers/package-use.html new file mode 100644 index 0000000..cc9b94e --- /dev/null +++ b/docs/pt/ptcris/handlers/package-use.html @@ -0,0 +1,182 @@ + + + + + +Uses of Package pt.ptcris.handlers + + + + + + + + +
+ + + + + + + +
+ + +
+

Uses of Package
pt.ptcris.handlers

+
+
+ +
+ +
+ + + + + + + +
+ + + + diff --git a/docs/pt/ptcris/package-frame.html b/docs/pt/ptcris/package-frame.html new file mode 100644 index 0000000..8b4ba55 --- /dev/null +++ b/docs/pt/ptcris/package-frame.html @@ -0,0 +1,28 @@ + + + + + +pt.ptcris + + + + + +

pt.ptcris

+
+

Interfaces

+ +

Classes

+ +
+ + diff --git a/docs/pt/ptcris/package-summary.html b/docs/pt/ptcris/package-summary.html new file mode 100644 index 0000000..26f262e --- /dev/null +++ b/docs/pt/ptcris/package-summary.html @@ -0,0 +1,192 @@ + + + + + +pt.ptcris + + + + + + + + +
+ + + + + + + +
+ + +
+

Package pt.ptcris

+
+
+ +
+ +
+ + + + + + + +
+ + + + diff --git a/docs/pt/ptcris/package-tree.html b/docs/pt/ptcris/package-tree.html new file mode 100644 index 0000000..6454df7 --- /dev/null +++ b/docs/pt/ptcris/package-tree.html @@ -0,0 +1,153 @@ + + + + + +pt.ptcris Class Hierarchy + + + + + + + + +
+ + + + + + + +
+ + +
+

Hierarchy For Package pt.ptcris

+Package Hierarchies: + +
+
+

Class Hierarchy

+ +

Interface Hierarchy

+ +
+ +
+ + + + + + + +
+ + + + diff --git a/docs/pt/ptcris/package-use.html b/docs/pt/ptcris/package-use.html new file mode 100644 index 0000000..5c00635 --- /dev/null +++ b/docs/pt/ptcris/package-use.html @@ -0,0 +1,194 @@ + + + + + +Uses of Package pt.ptcris + + + + + + + + +
+ + + + + + + +
+ + +
+

Uses of Package
pt.ptcris

+
+
+ +
+ +
+ + + + + + + +
+ + + + diff --git a/docs/pt/ptcris/utils/ExternalIdsDiff.html b/docs/pt/ptcris/utils/ExternalIdsDiff.html new file mode 100644 index 0000000..65c8b1a --- /dev/null +++ b/docs/pt/ptcris/utils/ExternalIdsDiff.html @@ -0,0 +1,323 @@ + + + + + +ExternalIdsDiff + + + + + + + + +
+ + + + + + + +
+ + + +
+
pt.ptcris.utils
+

Class ExternalIdsDiff

+
+
+ +
+
    +
  • +
    +
    +
    public final class ExternalIdsDiff
    +extends java.lang.Object
    +
    Calculates and stores the symmetric difference between two sets of + external identifiers. Useful to detect matching + activities and potential updates.
    +
  • +
+
+
+
    +
  • + +
      +
    • + + +

      Field Summary

      + + + + + + + + + + + + + + + + + + +
      Fields 
      Modifier and TypeField and Description
      java.util.Set<org.um.dsi.gavea.orcid.model.common.ExternalId>less +
      External identifiers removed from the first set.
      +
      java.util.Set<org.um.dsi.gavea.orcid.model.common.ExternalId>more +
      External identifiers inserted in the second set.
      +
      java.util.Set<org.um.dsi.gavea.orcid.model.common.ExternalId>same +
      External identifiers preserved in both sets.
      +
      +
    • +
    + +
      +
    • + + +

      Constructor Summary

      + + + + + + + + +
      Constructors 
      Constructor and Description
      ExternalIdsDiff(org.um.dsi.gavea.orcid.model.common.ExternalIds weids1, + org.um.dsi.gavea.orcid.model.common.ExternalIds weids2) +
      Calculates and stores the symmetric difference between two sets of + external identifiers.
      +
      +
    • +
    + +
      +
    • + + +

      Method Summary

      +
        +
      • + + +

        Methods inherited from class java.lang.Object

        +equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • +
      +
    • +
    +
  • +
+
+
+
    +
  • + +
      +
    • + + +

      Field Detail

      + + + +
        +
      • +

        less

        +
        public final java.util.Set<org.um.dsi.gavea.orcid.model.common.ExternalId> less
        +
        External identifiers removed from the first set.
        +
      • +
      + + + +
        +
      • +

        same

        +
        public final java.util.Set<org.um.dsi.gavea.orcid.model.common.ExternalId> same
        +
        External identifiers preserved in both sets.
        +
      • +
      + + + +
        +
      • +

        more

        +
        public final java.util.Set<org.um.dsi.gavea.orcid.model.common.ExternalId> more
        +
        External identifiers inserted in the second set.
        +
      • +
      +
    • +
    + +
      +
    • + + +

      Constructor Detail

      + + + +
        +
      • +

        ExternalIdsDiff

        +
        public ExternalIdsDiff(org.um.dsi.gavea.orcid.model.common.ExternalIds weids1,
        +                       org.um.dsi.gavea.orcid.model.common.ExternalIds weids2)
        +
        Calculates and stores the symmetric difference between two sets of + external identifiers.
        +
        +
        Parameters:
        +
        weids1 - the first set of external identifiers
        +
        weids2 - the second set of external identifiers
        +
        +
      • +
      +
    • +
    +
  • +
+
+
+ + +
+ + + + + + + +
+ + + + diff --git a/docs/pt/ptcris/utils/ORCIDFundingHelper.html b/docs/pt/ptcris/utils/ORCIDFundingHelper.html new file mode 100644 index 0000000..821c2d4 --- /dev/null +++ b/docs/pt/ptcris/utils/ORCIDFundingHelper.html @@ -0,0 +1,479 @@ + + + + + +ORCIDFundingHelper + + + + + + + + +
+ + + + + + + +
+ + + +
+
pt.ptcris.utils
+

Class ORCIDFundingHelper

+
+
+ +
+
    +
  • +
    +
    +
    public final class ORCIDFundingHelper
    +extends ORCIDHelper<org.um.dsi.gavea.orcid.model.funding.Funding,org.um.dsi.gavea.orcid.model.funding.FundingSummary,org.um.dsi.gavea.orcid.model.activities.FundingGroup,org.um.dsi.gavea.orcid.model.funding.FundingType>
    +
    An helper to simplify the use of the low-level ORCID + client. + + Provides support for asynchronous communication with ORCID + although it is only active for GET requests due to resource + limitations.
    +
  • +
+
+
+ +
+
+
    +
  • + +
      +
    • + + +

      Constructor Detail

      + + + +
        +
      • +

        ORCIDFundingHelper

        +
        public ORCIDFundingHelper(ORCIDClient orcidClient)
        +
        Initializes the helper with a given ORCID client.
        +
        +
        Parameters:
        +
        orcidClient - the ORCID client
        +
        +
      • +
      +
    • +
    + +
      +
    • + + +

      Method Detail

      + + + +
        +
      • +

        getNonNullExternalIdsE

        +
        public org.um.dsi.gavea.orcid.model.common.ExternalIds getNonNullExternalIdsE(org.um.dsi.gavea.orcid.model.funding.Funding funding)
        +
        Returns the non-null external identifiers of an activity (null becomes + empty list). Cannot rely on + ORCIDHelper.getNonNullExternalIdsS(ElementSummary) because + ORCIDHelper.summarize(ElementSummary) itself calls this method.
        +
        +
        Specified by:
        +
        getNonNullExternalIdsE in class ORCIDHelper<org.um.dsi.gavea.orcid.model.funding.Funding,org.um.dsi.gavea.orcid.model.funding.FundingSummary,org.um.dsi.gavea.orcid.model.activities.FundingGroup,org.um.dsi.gavea.orcid.model.funding.FundingType>
        +
        Parameters:
        +
        funding - the ORCID activity from which to retrieve the external + identifiers
        +
        Returns:
        +
        the non-null external identifiers
        +
        +
      • +
      + + + +
        +
      • +

        getNonNullExternalIdsS

        +
        public org.um.dsi.gavea.orcid.model.common.ExternalIds getNonNullExternalIdsS(org.um.dsi.gavea.orcid.model.funding.FundingSummary funding)
        +
        Returns the non-null external identifiers of an activity summary (null + becomes empty list).
        +
        +
        Specified by:
        +
        getNonNullExternalIdsS in class ORCIDHelper<org.um.dsi.gavea.orcid.model.funding.Funding,org.um.dsi.gavea.orcid.model.funding.FundingSummary,org.um.dsi.gavea.orcid.model.activities.FundingGroup,org.um.dsi.gavea.orcid.model.funding.FundingType>
        +
        Parameters:
        +
        funding - the ORCID activity summary from which to retrieve the external + identifiers
        +
        Returns:
        +
        the non-null external identifiers
        +
        +
      • +
      + + + +
        +
      • +

        setExternalIdsE

        +
        public void setExternalIdsE(org.um.dsi.gavea.orcid.model.funding.Funding funding,
        +                            org.um.dsi.gavea.orcid.model.common.ExternalIds eids)
        +
        Assigns a set of external identifiers to an activity.
        +
        +
        Specified by:
        +
        setExternalIdsE in class ORCIDHelper<org.um.dsi.gavea.orcid.model.funding.Funding,org.um.dsi.gavea.orcid.model.funding.FundingSummary,org.um.dsi.gavea.orcid.model.activities.FundingGroup,org.um.dsi.gavea.orcid.model.funding.FundingType>
        +
        Parameters:
        +
        funding - the ORCID activity to which to assign the external identifiers
        +
        eids - the external identifiers to be assigned
        +
        +
      • +
      + + + +
        +
      • +

        setExternalIdsS

        +
        public void setExternalIdsS(org.um.dsi.gavea.orcid.model.funding.FundingSummary summary,
        +                            org.um.dsi.gavea.orcid.model.common.ExternalIds eids)
        +
        Assigns a set of external identifiers to an activity summary.
        +
        +
        Specified by:
        +
        setExternalIdsS in class ORCIDHelper<org.um.dsi.gavea.orcid.model.funding.Funding,org.um.dsi.gavea.orcid.model.funding.FundingSummary,org.um.dsi.gavea.orcid.model.activities.FundingGroup,org.um.dsi.gavea.orcid.model.funding.FundingType>
        +
        Parameters:
        +
        summary - the ORCID activity summary to which to assign the external + identifiers
        +
        eids - the external identifiers to be assigned
        +
        +
      • +
      + + + +
        +
      • +

        createUpdate

        +
        public org.um.dsi.gavea.orcid.model.funding.Funding createUpdate(org.um.dsi.gavea.orcid.model.funding.Funding original,
        +                                                                 ExternalIdsDiff diff)
        +
        Creates an update to an activity given the difference on meta-data. + Essentially creates an activity with the same put-code as the original + activity and with the new meta-data that must be assigned to it. + Currently, only new external identifiers are considered.
        +
        +
        Specified by:
        +
        createUpdate in class ORCIDHelper<org.um.dsi.gavea.orcid.model.funding.Funding,org.um.dsi.gavea.orcid.model.funding.FundingSummary,org.um.dsi.gavea.orcid.model.activities.FundingGroup,org.um.dsi.gavea.orcid.model.funding.FundingType>
        +
        Parameters:
        +
        original - the original ORCID activity
        +
        diff - the difference on external identifiers
        +
        Returns:
        +
        the update to be applied to the ORCID activity
        +
        +
      • +
      + + + +
        +
      • +

        cloneS

        +
        public org.um.dsi.gavea.orcid.model.funding.FundingSummary cloneS(org.um.dsi.gavea.orcid.model.funding.FundingSummary summary)
        +
        Clones an activity summary.
        +
        +
        Parameters:
        +
        summary - the ORCID activity summary to be cloned
        +
        Returns:
        +
        the cloned ORCID activity summary
        +
        +
      • +
      + + + +
        +
      • +

        cloneE

        +
        public org.um.dsi.gavea.orcid.model.funding.Funding cloneE(org.um.dsi.gavea.orcid.model.funding.Funding funding)
        +
        Clones an activity.
        +
        +
        Parameters:
        +
        funding - the ORCID activity to be cloned
        +
        Returns:
        +
        the cloned ORCID activity
        +
        +
      • +
      +
    • +
    +
  • +
+
+
+ + +
+ + + + + + + +
+ + + + diff --git a/docs/pt/ptcris/utils/ORCIDHelper.html b/docs/pt/ptcris/utils/ORCIDHelper.html new file mode 100644 index 0000000..926d5c9 --- /dev/null +++ b/docs/pt/ptcris/utils/ORCIDHelper.html @@ -0,0 +1,1200 @@ + + + + + +ORCIDHelper + + + + + + + + +
+ + + + + + + +
+ + + +
+
pt.ptcris.utils
+

Class ORCIDHelper<E extends org.um.dsi.gavea.orcid.model.common.ElementSummary,S extends org.um.dsi.gavea.orcid.model.common.ElementSummary,G,T extends java.lang.Enum<T>>

+
+
+ +
+
    +
  • +
    +
    Type Parameters:
    +
    E - The class of ORCID activities being synchronized
    +
    S - The class of ORCID activity summaries
    +
    G - The class of ORCID activity groups
    +
    T - The class of ORCID activity types
    +
    +
    +
    Direct Known Subclasses:
    +
    ORCIDFundingHelper, ORCIDWorkHelper
    +
    +
    +
    +
    public abstract class ORCIDHelper<E extends org.um.dsi.gavea.orcid.model.common.ElementSummary,S extends org.um.dsi.gavea.orcid.model.common.ElementSummary,G,T extends java.lang.Enum<T>>
    +extends java.lang.Object
    +
    An abstract helper to help manage ORCID activities and simplify the usage of + the low-level ORCID client. Supports bulk + requests when available. The concrete ORCID activities to be managed by the + helper are expected to support external identifiers. + + Provides support for asynchronous communication with ORCID although it is + only active for GET requests due to resource limitations.
    +
  • +
+
+
+
    +
  • + + + +
      +
    • + + +

      Constructor Summary

      + + + + + + + + +
      Constructors 
      Constructor and Description
      ORCIDHelper(ORCIDClient orcidClient, + int bulk_size_add, + int bulk_size_get) +
      Initializes the helper with a given ORCID client, which defines whether + asynchronous calls will be performed, and sets whether bulk ORCID + commands are available and with which size.
      +
      +
    • +
    + +
      +
    • + + +

      Method Summary

      + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
      All Methods Static Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and TypeMethod and Description
      java.util.List<PTCRISyncResult<E>>add(java.util.List<E> activities, + ProgressHandler handler) +
      Synchronously adds a list of activities to an ORCID profile, either + through atomic or bulk calls if available.
      +
      static voidcleanWorkLocalKey(org.um.dsi.gavea.orcid.model.common.ElementSummary activity) +
      Clears (sets to null) the local key of an activity, currently assumed to + be stored in the put-code field.
      +
      abstract EcreateUpdate(E original, + ExternalIdsDiff diff) +
      Creates an update to an activity given the difference on meta-data.
      +
      PTCRISyncResult<E>delete(java.math.BigInteger putcode) +
      Synchronously deletes an activity from an ORCID profile.
      +
      voiddeleteAllSourced() +
      Deletes the entire set of activity summaries in the ORCID profile whose + source is the Member API id defined in the ORCID client.
      +
      static ORCIDHelper<org.um.dsi.gavea.orcid.model.funding.Funding,org.um.dsi.gavea.orcid.model.funding.FundingSummary,org.um.dsi.gavea.orcid.model.activities.FundingGroup,org.um.dsi.gavea.orcid.model.funding.FundingType>factoryStaticFundings() +
      Creates a static (i.e., no server connection) ORCID helper to manage + funding activities.
      +
      static ORCIDHelper<org.um.dsi.gavea.orcid.model.work.Work,org.um.dsi.gavea.orcid.model.work.WorkSummary,org.um.dsi.gavea.orcid.model.activities.WorkGroup,org.um.dsi.gavea.orcid.model.work.WorkType>factoryStaticWorks() +
      Creates a static (i.e., no server connection) ORCID helper to manage work + activities.
      +
      static java.math.BigIntegergetActivityLocalKey(org.um.dsi.gavea.orcid.model.common.ElementSummary activity) +
      Retrieves the local key of an activity, currently assumed to be stored in + the put-code field.
      +
      static java.math.BigIntegergetActivityLocalKey(org.um.dsi.gavea.orcid.model.common.ElementSummary activity, + java.math.BigInteger defaultValue) +
      Retrieves the local key of an activity, currently assumed to be stored in + the put-code field.
      +
      java.util.List<S>getAllTypedSummaries(java.util.Collection<T> types) +
      Retrieves the entire set of activity summaries of given types from the + set ORCID profile that have at least an external identifier set.
      +
      voidgetFulls(java.util.List<S> summaries, + java.util.Map<java.math.BigInteger,PTCRISyncResult<E>> cb, + ProgressHandler handler) +
      Reads a full ORCID activity from an ORCID profile and adds it to a + callback map.
      +
      abstract org.um.dsi.gavea.orcid.model.common.ExternalIdsgetNonNullExternalIdsE(E activity) +
      Returns the non-null external identifiers of an activity (null becomes + empty list).
      +
      abstract org.um.dsi.gavea.orcid.model.common.ExternalIdsgetNonNullExternalIdsS(S summary) +
      Returns the non-null external identifiers of an activity summary (null + becomes empty list).
      +
      org.um.dsi.gavea.orcid.model.common.ExternalIdsgetPartOfExternalIdsE(E activity) +
      Returns the non-null part-of external identifiers of an activity (null + becomes empty list).
      +
      java.util.Map<E,ExternalIdsDiff>getSelfExternalIdsDiffS(S summary, + java.util.Collection<E> activities) +
      Calculates the symmetric difference of self external + identifiers between an activity summary and a set of activities.
      +
      org.um.dsi.gavea.orcid.model.common.ExternalIdsgetSelfExternalIdsE(E activity) +
      Returns the non-null self external identifiers of an activity (null + becomes empty list).
      +
      java.util.List<S>getSourcedSummaries() +
      Retrieves the entire set (i.e., not merged) of activity summaries in the + ORCID profile whose source is the Member API id defined in the ORCID + client.
      +
      TgetTypeE(E activity) +
      Retrieves the type of an activity.
      +
      booleanhasNewSelfIDs(E preElement, + S posElement) +
      Checks whether an activity is already up to date regarding another one + regarding self external identifiers.
      +
      booleanisUpToDateE(E preElement, + E posElement) +
      Checks whether an activity is already up to date regarding another one, + considering the self external identifiers and + additional meta-data.
      +
      booleanisUpToDateS(E preElement, + S posElement) +
      Checks whether an activity is already up to date regarding another one, + considering the self external identifiers and + additional meta-data.
      +
      abstract voidsetExternalIdsE(E activity, + org.um.dsi.gavea.orcid.model.common.ExternalIds eids) +
      Assigns a set of external identifiers to an activity.
      +
      abstract voidsetExternalIdsS(S summary, + org.um.dsi.gavea.orcid.model.common.ExternalIds eids) +
      Assigns a set of external identifiers to an activity summary.
      +
      java.util.Set<java.lang.String>testMinimalQuality(S summary) +
      Tests whether an activity summary has minimal quality to be synchronized, + by inspecting its meta-data and that of coexisting activities, and + returns the detected invalid fields.
      +
      voidtryMinimalQualityE(E activity, + java.util.Collection<E> others) +
      Tests whether an activity has minimal quality to be synchronized, by + inspecting its meta-data.
      +
      PTCRISyncResult<E>update(java.math.BigInteger remotePutcode, + E updated) +
      Synchronously updates an activity to an ORCID profile.
      +
      +
        +
      • + + +

        Methods inherited from class java.lang.Object

        +equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • +
      +
    • +
    +
  • +
+
+
+
    +
  • + +
      +
    • + + +

      Field Detail

      + + + +
        +
      • +

        INVALID_EXTERNALIDENTIFIERS

        +
        public static final java.lang.String INVALID_EXTERNALIDENTIFIERS
        +
        +
        See Also:
        +
        Constant Field Values
        +
        +
      • +
      + + + +
        +
      • +

        INVALID_TITLE

        +
        public static final java.lang.String INVALID_TITLE
        +
        +
        See Also:
        +
        Constant Field Values
        +
        +
      • +
      + + + +
        +
      • +

        INVALID_PUBLICATIONDATE

        +
        public static final java.lang.String INVALID_PUBLICATIONDATE
        +
        +
        See Also:
        +
        Constant Field Values
        +
        +
      • +
      + + + +
        +
      • +

        INVALID_YEAR

        +
        public static final java.lang.String INVALID_YEAR
        +
        +
        See Also:
        +
        Constant Field Values
        +
        +
      • +
      + + + +
        +
      • +

        INVALID_TYPE

        +
        public static final java.lang.String INVALID_TYPE
        +
        +
        See Also:
        +
        Constant Field Values
        +
        +
      • +
      + + + +
        +
      • +

        INVALID_ORGANIZATION

        +
        public static final java.lang.String INVALID_ORGANIZATION
        +
        +
        See Also:
        +
        Constant Field Values
        +
        +
      • +
      + + + +
        +
      • +

        OVERLAPPING_EIDs

        +
        public static final java.lang.String OVERLAPPING_EIDs
        +
        +
        See Also:
        +
        Constant Field Values
        +
        +
      • +
      + + + +
        +
      • +

        client

        +
        public final ORCIDClient client
        +
        The client used to communicate with ORCID. Defines the ORCID user profile + being managed and the Member API id being user to source activities.
        +
      • +
      +
    • +
    + +
      +
    • + + +

      Constructor Detail

      + + + +
        +
      • +

        ORCIDHelper

        +
        public ORCIDHelper(ORCIDClient orcidClient,
        +                   int bulk_size_add,
        +                   int bulk_size_get)
        +
        Initializes the helper with a given ORCID client, which defines whether + asynchronous calls will be performed, and sets whether bulk ORCID + commands are available and with which size.
        +
        +
        Parameters:
        +
        orcidClient - the ORCID client
        +
        bulk_size_add - number of activities per bulk add request
        +
        bulk_size_get - number of activities per bulk get request
        +
        +
      • +
      +
    • +
    + +
      +
    • + + +

      Method Detail

      + + + +
        +
      • +

        factoryStaticWorks

        +
        public static ORCIDHelper<org.um.dsi.gavea.orcid.model.work.Work,org.um.dsi.gavea.orcid.model.work.WorkSummary,org.um.dsi.gavea.orcid.model.activities.WorkGroup,org.um.dsi.gavea.orcid.model.work.WorkType> factoryStaticWorks()
        +
        Creates a static (i.e., no server connection) ORCID helper to manage work + activities.
        +
        +
        Returns:
        +
        the ORCID work helper
        +
        +
      • +
      + + + +
        +
      • +

        factoryStaticFundings

        +
        public static ORCIDHelper<org.um.dsi.gavea.orcid.model.funding.Funding,org.um.dsi.gavea.orcid.model.funding.FundingSummary,org.um.dsi.gavea.orcid.model.activities.FundingGroup,org.um.dsi.gavea.orcid.model.funding.FundingType> factoryStaticFundings()
        +
        Creates a static (i.e., no server connection) ORCID helper to manage + funding activities.
        +
        +
        Returns:
        +
        the ORCID funding helper
        +
        +
      • +
      + + + +
        +
      • +

        getAllTypedSummaries

        +
        public final java.util.List<S> getAllTypedSummaries(java.util.Collection<T> types)
        +                                             throws org.um.dsi.gavea.orcid.client.exception.OrcidClientException
        +
        Retrieves the entire set of activity summaries of given types from the + set ORCID profile that have at least an external identifier set. Merges + each ORCID group into a single summary, following group(Object).
        +
        +
        Parameters:
        +
        types - the ORCID types of the activities to be retrieved (may be null)
        +
        Returns:
        +
        the set of ORCID activity summaries in the defined ORCID profile
        +
        Throws:
        +
        org.um.dsi.gavea.orcid.client.exception.OrcidClientException - if the communication with ORCID fails
        +
        +
      • +
      + + + +
        +
      • +

        getSourcedSummaries

        +
        public final java.util.List<S> getSourcedSummaries()
        +                                            throws org.um.dsi.gavea.orcid.client.exception.OrcidClientException
        +
        Retrieves the entire set (i.e., not merged) of activity summaries in the + ORCID profile whose source is the Member API id defined in the ORCID + client.
        +
        +
        Returns:
        +
        the set of ORCID activity summaries in the ORCID profile for the + defined source
        +
        Throws:
        +
        org.um.dsi.gavea.orcid.client.exception.OrcidClientException - if the communication with ORCID fails
        +
        +
      • +
      + + + +
        +
      • +

        getFulls

        +
        public final void getFulls(java.util.List<S> summaries,
        +                           java.util.Map<java.math.BigInteger,PTCRISyncResult<E>> cb,
        +                           ProgressHandler handler)
        +                    throws java.lang.InterruptedException
        +
        Reads a full ORCID activity from an ORCID profile and adds it to a + callback map. The resulting activity contains every external identifier + set in the input activity summary, because the summary resulted from the + merging of a group, but the retrieved full activity is a single activity. + It also clears the put-code, since at this level they represent the local + identifier. If possible the number of threads is higher than 1, process + is asynchronous. If the list is not a singleton, a bulk request will be + performed if supported for the concrete ORCID activity type. If the + communication with ORCID fails for any activity, the exceptions are + embedded in failed PTCRISyncResult.
        +
        +
        Parameters:
        +
        summaries - the ORCID activity summaries representing the merged groups
        +
        cb - the callback object
        +
        handler - the handler to report progress
        +
        Throws:
        +
        java.lang.InterruptedException - if the asynchronous GET process is interrupted
        +
        See Also:
        +
        readClient(List)
        +
        +
      • +
      + + + +
        +
      • +

        add

        +
        public final java.util.List<PTCRISyncResult<E>> add(java.util.List<E> activities,
        +                                                    ProgressHandler handler)
        +
        Synchronously adds a list of activities to an ORCID profile, either + through atomic or bulk calls if available. A list of results is returned, + one for each input activity. The OK result includes the newly assigned + put-code. If the communication with ORCID fails, the exception is + embedded in a failed PTCRISyncResult. If the overall + communication fails, the result is replicated for each input.
        +
        +
        Parameters:
        +
        activities - the new ORCID activities to be added
        +
        handler - the handler to report progress
        +
        Returns:
        +
        the results of the ORCID call for each input activity
        +
        +
      • +
      + + + + + +
        +
      • +

        update

        +
        public final PTCRISyncResult<E> update(java.math.BigInteger remotePutcode,
        +                                       E updated)
        +
        Synchronously updates an activity to an ORCID profile. If the + communication with ORCID fails, the exception is embedded in a failed + PTCRISyncResult.
        +
        +
        Parameters:
        +
        remotePutcode - the put-code of the remote ORCID activity that will be updated
        +
        updated - the new state of the activity that will be updated
        +
        Returns:
        +
        the result of the ORCID call
        +
        See Also:
        +
        updateClient(BigInteger, ElementSummary)
        +
        +
      • +
      + + + +
        +
      • +

        delete

        +
        public final PTCRISyncResult<E> delete(java.math.BigInteger putcode)
        +
        Synchronously deletes an activity from an ORCID profile. If the + communication with ORCID fails, the exception is embedded in a failed + PTCRISyncResult.
        +
        +
        Parameters:
        +
        putcode - the remote put-code of the ORCID activity to be deleted
        +
        Returns:
        +
        the outcome of the delete request
        +
        See Also:
        +
        deleteClient(BigInteger)
        +
        +
      • +
      + + + +
        +
      • +

        deleteAllSourced

        +
        public final void deleteAllSourced()
        +                            throws org.um.dsi.gavea.orcid.client.exception.OrcidClientException
        +
        Deletes the entire set of activity summaries in the ORCID profile whose + source is the Member API id defined in the ORCID client.
        +
        +
        Throws:
        +
        org.um.dsi.gavea.orcid.client.exception.OrcidClientException - if the communication with ORCID fails
        +
        +
      • +
      + + + + + +
        +
      • +

        getNonNullExternalIdsE

        +
        public abstract org.um.dsi.gavea.orcid.model.common.ExternalIds getNonNullExternalIdsE(E activity)
        +
        Returns the non-null external identifiers of an activity (null becomes + empty list). Cannot rely on + getNonNullExternalIdsS(ElementSummary) because + summarize(ElementSummary) itself calls this method.
        +
        +
        Parameters:
        +
        activity - the ORCID activity from which to retrieve the external + identifiers
        +
        Returns:
        +
        the non-null external identifiers
        +
        +
      • +
      + + + + + +
        +
      • +

        getNonNullExternalIdsS

        +
        public abstract org.um.dsi.gavea.orcid.model.common.ExternalIds getNonNullExternalIdsS(S summary)
        +
        Returns the non-null external identifiers of an activity summary (null + becomes empty list).
        +
        +
        Parameters:
        +
        summary - the ORCID activity summary from which to retrieve the external + identifiers
        +
        Returns:
        +
        the non-null external identifiers
        +
        +
      • +
      + + + + + +
        +
      • +

        setExternalIdsE

        +
        public abstract void setExternalIdsE(E activity,
        +                                     org.um.dsi.gavea.orcid.model.common.ExternalIds eids)
        +
        Assigns a set of external identifiers to an activity.
        +
        +
        Parameters:
        +
        activity - the ORCID activity to which to assign the external identifiers
        +
        eids - the external identifiers to be assigned
        +
        +
      • +
      + + + + + +
        +
      • +

        setExternalIdsS

        +
        public abstract void setExternalIdsS(S summary,
        +                                     org.um.dsi.gavea.orcid.model.common.ExternalIds eids)
        +
        Assigns a set of external identifiers to an activity summary.
        +
        +
        Parameters:
        +
        summary - the ORCID activity summary to which to assign the external + identifiers
        +
        eids - the external identifiers to be assigned
        +
        +
      • +
      + + + + + +
        +
      • +

        createUpdate

        +
        public abstract E createUpdate(E original,
        +                               ExternalIdsDiff diff)
        +
        Creates an update to an activity given the difference on meta-data. + Essentially creates an activity with the same put-code as the original + activity and with the new meta-data that must be assigned to it. + Currently, only new external identifiers are considered.
        +
        +
        Parameters:
        +
        original - the original ORCID activity
        +
        diff - the difference on external identifiers
        +
        Returns:
        +
        the update to be applied to the ORCID activity
        +
        +
      • +
      + + + +
        +
      • +

        getActivityLocalKey

        +
        public static java.math.BigInteger getActivityLocalKey(org.um.dsi.gavea.orcid.model.common.ElementSummary activity)
        +
        Retrieves the local key of an activity, currently assumed to be stored in + the put-code field.
        +
        +
        Parameters:
        +
        activity - the ORCID activity from which to get the local key
        +
        Returns:
        +
        the local key
        +
        +
      • +
      + + + +
        +
      • +

        getActivityLocalKey

        +
        public static java.math.BigInteger getActivityLocalKey(org.um.dsi.gavea.orcid.model.common.ElementSummary activity,
        +                                                       java.math.BigInteger defaultValue)
        +
        Retrieves the local key of an activity, currently assumed to be stored in + the put-code field. If empty, returns a default value.
        +
        +
        Parameters:
        +
        activity - the ORCID activity from which to get the local key
        +
        defaultValue - a default value in case the put-code is empty
        +
        Returns:
        +
        the local key
        +
        +
      • +
      + + + +
        +
      • +

        cleanWorkLocalKey

        +
        public static void cleanWorkLocalKey(org.um.dsi.gavea.orcid.model.common.ElementSummary activity)
        +
        Clears (sets to null) the local key of an activity, currently assumed to + be stored in the put-code field.
        +
        +
        Parameters:
        +
        activity - the activity to which to clear the local key
        +
        +
      • +
      + + + + + +
        +
      • +

        getTypeE

        +
        public final T getTypeE(E activity)
        +
        Retrieves the type of an activity. Build on + getTypeS(ElementSummary).
        +
        +
        Parameters:
        +
        activity - the ORCID activity
        +
        Returns:
        +
        the activity's type
        +
        +
      • +
      + + + + + +
        +
      • +

        getPartOfExternalIdsE

        +
        public final org.um.dsi.gavea.orcid.model.common.ExternalIds getPartOfExternalIdsE(E activity)
        +
        Returns the non-null part-of external identifiers of an activity (null + becomes empty list). Builds on + getPartOfExternalIdsS(ElementSummary).
        +
        +
        Parameters:
        +
        activity - the ORCID activity from which to retrieve the external + identifiers
        +
        Returns:
        +
        the non-null part-of external identifiers
        +
        +
      • +
      + + + + + +
        +
      • +

        getSelfExternalIdsE

        +
        public final org.um.dsi.gavea.orcid.model.common.ExternalIds getSelfExternalIdsE(E activity)
        +
        Returns the non-null self external identifiers of an activity (null + becomes empty list). Builds on + getSelfExternalIdsS(ElementSummary).
        +
        +
        Parameters:
        +
        activity - the ORCID activity from which to retrieve the external + identifiers
        +
        Returns:
        +
        the non-null self external identifiers
        +
        +
      • +
      + + + + + +
        +
      • +

        getSelfExternalIdsDiffS

        +
        public final java.util.Map<E,ExternalIdsDiff> getSelfExternalIdsDiffS(S summary,
        +                                                                      java.util.Collection<E> activities)
        +
        Calculates the symmetric difference of self external + identifiers between an activity summary and a set of activities. + Elements that do not match (i.e., no identifier is common) are ignored.
        +
        +
        Parameters:
        +
        summary - the activity summary to be compared with other activities
        +
        activities - the set of activities against which the activity summary is + compared
        +
        Returns:
        +
        The symmetric difference of self external identifiers between the + summary and other activities
        +
        +
      • +
      + + + + + +
        +
      • +

        hasNewSelfIDs

        +
        public final boolean hasNewSelfIDs(E preElement,
        +                                   S posElement)
        +
        Checks whether an activity is already up to date regarding another one + regarding self external identifiers. + + This test is expected to be used by the import algorithms, where only new + self external identifiers are to be considered.
        +
        +
        Parameters:
        +
        preElement - the potentially out of date ORCID activity
        +
        posElement - the up to date ORCID activity
        +
        Returns:
        +
        true if all the self external identifiers between the two + activities are the same, false otherwise
        +
        +
      • +
      + + + + + +
        +
      • +

        isUpToDateS

        +
        public final boolean isUpToDateS(E preElement,
        +                                 S posElement)
        +
        Checks whether an activity is already up to date regarding another one, + considering the self external identifiers and + additional meta-data. Only meta-data existent in the activity summaries + is conside + + This test is expected to be used by the export algorithms, where the + meta-data is expected to be up-to-date on the remote profile.
        +
        +
        Parameters:
        +
        preElement - the potentially out of date ORCID activity
        +
        posElement - the up to date ORCID activity
        +
        Returns:
        +
        true if all the self external identifiers and the meta-data + between the two activities are the same, false otherwise
        +
        +
      • +
      + + + + + +
        +
      • +

        isUpToDateE

        +
        public final boolean isUpToDateE(E preElement,
        +                                 E posElement)
        +
        Checks whether an activity is already up to date regarding another one, + considering the self external identifiers and + additional meta-data. Only meta-data existent in the activity summaries + is considered. Builds on + isUpToDateS(ElementSummary, ElementSummary). + + This test is expected to be used by the export algorithms, where the + meta-data is expected to be up-to-date on the remote profile.
        +
        +
        Parameters:
        +
        preElement - the potentially out of date ORCID activity
        +
        posElement - the up to date ORCID activity
        +
        Returns:
        +
        true if all the self external identifiers and the meta-data + between the two activities are the same, false otherwise
        +
        +
      • +
      + + + + + +
        +
      • +

        tryMinimalQualityE

        +
        public final void tryMinimalQualityE(E activity,
        +                                     java.util.Collection<E> others)
        +                              throws InvalidActivityException
        +
        Tests whether an activity has minimal quality to be synchronized, by + inspecting its meta-data. Throws an exception if the test fails. Only + meta-data available in activity summaries is considered. + + TODO: contributors are not being considered as they are not contained in + the summaries.
        +
        +
        Parameters:
        +
        activity - the activity to test for quality
        +
        others - other coexisting activities
        +
        Throws:
        +
        InvalidActivityException - if the quality test fails, containing the reasons for failing
        +
        +
      • +
      + + + + + +
        +
      • +

        testMinimalQuality

        +
        public final java.util.Set<java.lang.String> testMinimalQuality(S summary)
        +
        Tests whether an activity summary has minimal quality to be synchronized, + by inspecting its meta-data and that of coexisting activities, and + returns the detected invalid fields. Only uses meta-data available in + activity summaries. Builds on + testMinimalQuality(ElementSummary, Collection). + + TODO: contributors are not being considered as they are not contained in + the summaries.
        +
        +
        Parameters:
        +
        summary - the ORCID activity summary to test for quality
        +
        Returns:
        +
        the set of invalid meta-data, empty if valid
        +
        +
      • +
      +
    • +
    +
  • +
+
+
+ + +
+ + + + + + + +
+ + + + diff --git a/docs/pt/ptcris/utils/ORCIDWorkHelper.html b/docs/pt/ptcris/utils/ORCIDWorkHelper.html new file mode 100644 index 0000000..fa6a2fd --- /dev/null +++ b/docs/pt/ptcris/utils/ORCIDWorkHelper.html @@ -0,0 +1,478 @@ + + + + + +ORCIDWorkHelper + + + + + + + + +
+ + + + + + + +
+ + + +
+
pt.ptcris.utils
+

Class ORCIDWorkHelper

+
+
+ +
+
    +
  • +
    +
    +
    public final class ORCIDWorkHelper
    +extends ORCIDHelper<org.um.dsi.gavea.orcid.model.work.Work,org.um.dsi.gavea.orcid.model.work.WorkSummary,org.um.dsi.gavea.orcid.model.activities.WorkGroup,org.um.dsi.gavea.orcid.model.work.WorkType>
    +
    An helper to simplify the use of the low-level ORCID + client. + + Provides support for asynchronous communication with ORCID although it is + only active for GET requests due to resource limitations.
    +
  • +
+
+
+ +
+
+
    +
  • + +
      +
    • + + +

      Constructor Detail

      + + + +
        +
      • +

        ORCIDWorkHelper

        +
        public ORCIDWorkHelper(ORCIDClient orcidClient)
        +
        Initializes the helper with a given ORCID client.
        +
        +
        Parameters:
        +
        orcidClient - the ORCID client
        +
        +
      • +
      +
    • +
    + +
      +
    • + + +

      Method Detail

      + + + +
        +
      • +

        getNonNullExternalIdsE

        +
        public org.um.dsi.gavea.orcid.model.common.ExternalIds getNonNullExternalIdsE(org.um.dsi.gavea.orcid.model.work.Work work)
        +
        Returns the non-null external identifiers of an activity (null becomes + empty list). Cannot rely on + ORCIDHelper.getNonNullExternalIdsS(ElementSummary) because + ORCIDHelper.summarize(ElementSummary) itself calls this method.
        +
        +
        Specified by:
        +
        getNonNullExternalIdsE in class ORCIDHelper<org.um.dsi.gavea.orcid.model.work.Work,org.um.dsi.gavea.orcid.model.work.WorkSummary,org.um.dsi.gavea.orcid.model.activities.WorkGroup,org.um.dsi.gavea.orcid.model.work.WorkType>
        +
        Parameters:
        +
        work - the ORCID activity from which to retrieve the external + identifiers
        +
        Returns:
        +
        the non-null external identifiers
        +
        +
      • +
      + + + +
        +
      • +

        getNonNullExternalIdsS

        +
        public org.um.dsi.gavea.orcid.model.common.ExternalIds getNonNullExternalIdsS(org.um.dsi.gavea.orcid.model.work.WorkSummary summary)
        +
        Returns the non-null external identifiers of an activity summary (null + becomes empty list).
        +
        +
        Specified by:
        +
        getNonNullExternalIdsS in class ORCIDHelper<org.um.dsi.gavea.orcid.model.work.Work,org.um.dsi.gavea.orcid.model.work.WorkSummary,org.um.dsi.gavea.orcid.model.activities.WorkGroup,org.um.dsi.gavea.orcid.model.work.WorkType>
        +
        Parameters:
        +
        summary - the ORCID activity summary from which to retrieve the external + identifiers
        +
        Returns:
        +
        the non-null external identifiers
        +
        +
      • +
      + + + +
        +
      • +

        setExternalIdsE

        +
        public void setExternalIdsE(org.um.dsi.gavea.orcid.model.work.Work work,
        +                            org.um.dsi.gavea.orcid.model.common.ExternalIds eids)
        +
        Assigns a set of external identifiers to an activity.
        +
        +
        Specified by:
        +
        setExternalIdsE in class ORCIDHelper<org.um.dsi.gavea.orcid.model.work.Work,org.um.dsi.gavea.orcid.model.work.WorkSummary,org.um.dsi.gavea.orcid.model.activities.WorkGroup,org.um.dsi.gavea.orcid.model.work.WorkType>
        +
        Parameters:
        +
        work - the ORCID activity to which to assign the external identifiers
        +
        eids - the external identifiers to be assigned
        +
        +
      • +
      + + + +
        +
      • +

        setExternalIdsS

        +
        public void setExternalIdsS(org.um.dsi.gavea.orcid.model.work.WorkSummary summary,
        +                            org.um.dsi.gavea.orcid.model.common.ExternalIds eids)
        +
        Assigns a set of external identifiers to an activity summary.
        +
        +
        Specified by:
        +
        setExternalIdsS in class ORCIDHelper<org.um.dsi.gavea.orcid.model.work.Work,org.um.dsi.gavea.orcid.model.work.WorkSummary,org.um.dsi.gavea.orcid.model.activities.WorkGroup,org.um.dsi.gavea.orcid.model.work.WorkType>
        +
        Parameters:
        +
        summary - the ORCID activity summary to which to assign the external + identifiers
        +
        eids - the external identifiers to be assigned
        +
        +
      • +
      + + + +
        +
      • +

        createUpdate

        +
        public org.um.dsi.gavea.orcid.model.work.Work createUpdate(org.um.dsi.gavea.orcid.model.work.Work original,
        +                                                           ExternalIdsDiff diff)
        +
        Creates an update to an activity given the difference on meta-data. + Essentially creates an activity with the same put-code as the original + activity and with the new meta-data that must be assigned to it. + Currently, only new external identifiers are considered.
        +
        +
        Specified by:
        +
        createUpdate in class ORCIDHelper<org.um.dsi.gavea.orcid.model.work.Work,org.um.dsi.gavea.orcid.model.work.WorkSummary,org.um.dsi.gavea.orcid.model.activities.WorkGroup,org.um.dsi.gavea.orcid.model.work.WorkType>
        +
        Parameters:
        +
        original - the original ORCID activity
        +
        diff - the difference on external identifiers
        +
        Returns:
        +
        the update to be applied to the ORCID activity
        +
        +
      • +
      + + + +
        +
      • +

        cloneS

        +
        public org.um.dsi.gavea.orcid.model.work.WorkSummary cloneS(org.um.dsi.gavea.orcid.model.work.WorkSummary summary)
        +
        Clones an activity summary.
        +
        +
        Parameters:
        +
        summary - the ORCID activity summary to be cloned
        +
        Returns:
        +
        the cloned ORCID activity summary
        +
        +
      • +
      + + + +
        +
      • +

        cloneE

        +
        public org.um.dsi.gavea.orcid.model.work.Work cloneE(org.um.dsi.gavea.orcid.model.work.Work work)
        +
        Clones an activity.
        +
        +
        Parameters:
        +
        work - the ORCID activity to be cloned
        +
        Returns:
        +
        the cloned ORCID activity
        +
        +
      • +
      +
    • +
    +
  • +
+
+
+ + +
+ + + + + + + +
+ + + + diff --git a/docs/pt/ptcris/utils/UpdateRecord.html b/docs/pt/ptcris/utils/UpdateRecord.html new file mode 100644 index 0000000..9298225 --- /dev/null +++ b/docs/pt/ptcris/utils/UpdateRecord.html @@ -0,0 +1,320 @@ + + + + + +UpdateRecord + + + + + + + + +
+ + + + + + + +
+ + + +
+
pt.ptcris.utils
+

Class UpdateRecord<E extends org.um.dsi.gavea.orcid.model.common.ElementSummary,S extends org.um.dsi.gavea.orcid.model.common.ElementSummary>

+
+
+ +
+
    +
  • +
    +
    +
    public final class UpdateRecord<E extends org.um.dsi.gavea.orcid.model.common.ElementSummary,S extends org.um.dsi.gavea.orcid.model.common.ElementSummary>
    +extends java.lang.Object
    +
    An helper class that stores two versions of the same activity, as well as the difference between their + external identifiers.
    +
  • +
+
+
+
    +
  • + + + +
      +
    • + + +

      Constructor Summary

      + + + + + + + + +
      Constructors 
      Constructor and Description
      UpdateRecord(E preActivity, + S posActivity, + ExternalIdsDiff eidsDiff) +
      Constructs an object containing two versions of an activity and the + difference between their external identifiers.
      +
      +
    • +
    + +
      +
    • + + +

      Method Summary

      +
        +
      • + + +

        Methods inherited from class java.lang.Object

        +equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • +
      +
    • +
    +
  • +
+
+
+
    +
  • + +
      +
    • + + +

      Field Detail

      + + + +
        +
      • +

        preElement

        +
        public final E extends org.um.dsi.gavea.orcid.model.common.ElementSummary preElement
        +
      • +
      + + + +
        +
      • +

        posElement

        +
        public final S extends org.um.dsi.gavea.orcid.model.common.ElementSummary posElement
        +
      • +
      + + + + +
    • +
    + +
      +
    • + + +

      Constructor Detail

      + + + + + +
        +
      • +

        UpdateRecord

        +
        public UpdateRecord(E preActivity,
        +                    S posActivity,
        +                    ExternalIdsDiff eidsDiff)
        +
        Constructs an object containing two versions of an activity and the + difference between their external identifiers. The + updated version is assumed to be only a summary, since the contained + information is sufficient for the synchronization procedures.
        +
        +
        Parameters:
        +
        preActivity - the current version of the activity
        +
        posActivity - the updated version of the activity
        +
        eidsDiff - the difference between the identifiers
        +
        +
      • +
      +
    • +
    +
  • +
+
+
+ + +
+ + + + + + + +
+ + + + diff --git a/docs/pt/ptcris/utils/class-use/ExternalIdsDiff.html b/docs/pt/ptcris/utils/class-use/ExternalIdsDiff.html new file mode 100644 index 0000000..18d1d28 --- /dev/null +++ b/docs/pt/ptcris/utils/class-use/ExternalIdsDiff.html @@ -0,0 +1,227 @@ + + + + + +Uses of Class pt.ptcris.utils.ExternalIdsDiff + + + + + + + + +
+ + + + + + + +
+ + +
+

Uses of Class
pt.ptcris.utils.ExternalIdsDiff

+
+
+ +
+ +
+ + + + + + + +
+ + + + diff --git a/docs/pt/ptcris/utils/class-use/ORCIDFundingHelper.html b/docs/pt/ptcris/utils/class-use/ORCIDFundingHelper.html new file mode 100644 index 0000000..0526e8b --- /dev/null +++ b/docs/pt/ptcris/utils/class-use/ORCIDFundingHelper.html @@ -0,0 +1,124 @@ + + + + + +Uses of Class pt.ptcris.utils.ORCIDFundingHelper + + + + + + + + +
+ + + + + + + +
+ + +
+

Uses of Class
pt.ptcris.utils.ORCIDFundingHelper

+
+
No usage of pt.ptcris.utils.ORCIDFundingHelper
+ +
+ + + + + + + +
+ + + + diff --git a/docs/pt/ptcris/utils/class-use/ORCIDHelper.html b/docs/pt/ptcris/utils/class-use/ORCIDHelper.html new file mode 100644 index 0000000..53c857b --- /dev/null +++ b/docs/pt/ptcris/utils/class-use/ORCIDHelper.html @@ -0,0 +1,197 @@ + + + + + +Uses of Class pt.ptcris.utils.ORCIDHelper + + + + + + + + +
+ + + + + + + +
+ + +
+

Uses of Class
pt.ptcris.utils.ORCIDHelper

+
+
+ +
+ +
+ + + + + + + +
+ + + + diff --git a/docs/pt/ptcris/utils/class-use/ORCIDWorkHelper.html b/docs/pt/ptcris/utils/class-use/ORCIDWorkHelper.html new file mode 100644 index 0000000..9a850e7 --- /dev/null +++ b/docs/pt/ptcris/utils/class-use/ORCIDWorkHelper.html @@ -0,0 +1,124 @@ + + + + + +Uses of Class pt.ptcris.utils.ORCIDWorkHelper + + + + + + + + +
+ + + + + + + +
+ + +
+

Uses of Class
pt.ptcris.utils.ORCIDWorkHelper

+
+
No usage of pt.ptcris.utils.ORCIDWorkHelper
+ +
+ + + + + + + +
+ + + + diff --git a/docs/pt/ptcris/utils/class-use/UpdateRecord.html b/docs/pt/ptcris/utils/class-use/UpdateRecord.html new file mode 100644 index 0000000..8db7a40 --- /dev/null +++ b/docs/pt/ptcris/utils/class-use/UpdateRecord.html @@ -0,0 +1,124 @@ + + + + + +Uses of Class pt.ptcris.utils.UpdateRecord + + + + + + + + +
+ + + + + + + +
+ + +
+

Uses of Class
pt.ptcris.utils.UpdateRecord

+
+
No usage of pt.ptcris.utils.UpdateRecord
+ +
+ + + + + + + +
+ + + + diff --git a/docs/pt/ptcris/utils/package-frame.html b/docs/pt/ptcris/utils/package-frame.html new file mode 100644 index 0000000..6f45ad0 --- /dev/null +++ b/docs/pt/ptcris/utils/package-frame.html @@ -0,0 +1,24 @@ + + + + + +pt.ptcris.utils + + + + + +

pt.ptcris.utils

+
+

Classes

+ +
+ + diff --git a/docs/pt/ptcris/utils/package-summary.html b/docs/pt/ptcris/utils/package-summary.html new file mode 100644 index 0000000..1e11e83 --- /dev/null +++ b/docs/pt/ptcris/utils/package-summary.html @@ -0,0 +1,173 @@ + + + + + +pt.ptcris.utils + + + + + + + + +
+ + + + + + + +
+ + +
+

Package pt.ptcris.utils

+
+
+ +
+ +
+ + + + + + + +
+ + + + diff --git a/docs/pt/ptcris/utils/package-tree.html b/docs/pt/ptcris/utils/package-tree.html new file mode 100644 index 0000000..4115767 --- /dev/null +++ b/docs/pt/ptcris/utils/package-tree.html @@ -0,0 +1,144 @@ + + + + + +pt.ptcris.utils Class Hierarchy + + + + + + + + +
+ + + + + + + +
+ + +
+

Hierarchy For Package pt.ptcris.utils

+Package Hierarchies: + +
+
+

Class Hierarchy

+ +
+ +
+ + + + + + + +
+ + + + diff --git a/docs/pt/ptcris/utils/package-use.html b/docs/pt/ptcris/utils/package-use.html new file mode 100644 index 0000000..877fa24 --- /dev/null +++ b/docs/pt/ptcris/utils/package-use.html @@ -0,0 +1,166 @@ + + + + + +Uses of Package pt.ptcris.utils + + + + + + + + +
+ + + + + + + +
+ + +
+

Uses of Package
pt.ptcris.utils

+
+
+ +
+ +
+ + + + + + + +
+ + + + diff --git a/docs/script.js b/docs/script.js new file mode 100644 index 0000000..b346356 --- /dev/null +++ b/docs/script.js @@ -0,0 +1,30 @@ +function show(type) +{ + count = 0; + for (var key in methods) { + var row = document.getElementById(key); + if ((methods[key] & type) != 0) { + row.style.display = ''; + row.className = (count++ % 2) ? rowColor : altColor; + } + else + row.style.display = 'none'; + } + updateTabs(type); +} + +function updateTabs(type) +{ + for (var value in tabs) { + var sNode = document.getElementById(tabs[value][0]); + var spanNode = sNode.firstChild; + if (value == type) { + sNode.className = activeTableTab; + spanNode.innerHTML = tabs[value][1]; + } + else { + sNode.className = tableTab; + spanNode.innerHTML = "" + tabs[value][1] + ""; + } + } +} diff --git a/docs/serialized-form.html b/docs/serialized-form.html new file mode 100644 index 0000000..4ed1da8 --- /dev/null +++ b/docs/serialized-form.html @@ -0,0 +1,155 @@ + + + + + +Serialized Form + + + + + + + + +
+ + + + + + + +
+ + +
+

Serialized Form

+
+
+ +
+ +
+ + + + + + + +
+ + + + diff --git a/docs/stylesheet.css b/docs/stylesheet.css new file mode 100644 index 0000000..cebb4fd --- /dev/null +++ b/docs/stylesheet.css @@ -0,0 +1,574 @@ +/* Javadoc style sheet */ +/* +Overall document style +*/ + +@import url('resources/fonts/dejavu.css'); + +body { + background-color:#ffffff; + color:#353833; + font-family:'DejaVu Sans', Arial, Helvetica, sans-serif; + font-size:14px; + margin:0; +} +a:link, a:visited { + text-decoration:none; + color:#4A6782; +} +a:hover, a:focus { + text-decoration:none; + color:#bb7a2a; +} +a:active { + text-decoration:none; + color:#4A6782; +} +a[name] { + color:#353833; +} +a[name]:hover { + text-decoration:none; + color:#353833; +} +pre { + font-family:'DejaVu Sans Mono', monospace; + font-size:14px; +} +h1 { + font-size:20px; +} +h2 { + font-size:18px; +} +h3 { + font-size:16px; + font-style:italic; +} +h4 { + font-size:13px; +} +h5 { + font-size:12px; +} +h6 { + font-size:11px; +} +ul { + list-style-type:disc; +} +code, tt { + font-family:'DejaVu Sans Mono', monospace; + font-size:14px; + padding-top:4px; + margin-top:8px; + line-height:1.4em; +} +dt code { + font-family:'DejaVu Sans Mono', monospace; + font-size:14px; + padding-top:4px; +} +table tr td dt code { + font-family:'DejaVu Sans Mono', monospace; + font-size:14px; + vertical-align:top; + padding-top:4px; +} +sup { + font-size:8px; +} +/* +Document title and Copyright styles +*/ +.clear { + clear:both; + height:0px; + overflow:hidden; +} +.aboutLanguage { + float:right; + padding:0px 21px; + font-size:11px; + z-index:200; + margin-top:-9px; +} +.legalCopy { + margin-left:.5em; +} +.bar a, .bar a:link, .bar a:visited, .bar a:active { + color:#FFFFFF; + text-decoration:none; +} +.bar a:hover, .bar a:focus { + color:#bb7a2a; +} +.tab { + background-color:#0066FF; + color:#ffffff; + padding:8px; + width:5em; + font-weight:bold; +} +/* +Navigation bar styles +*/ +.bar { + background-color:#4D7A97; + color:#FFFFFF; + padding:.8em .5em .4em .8em; + height:auto;/*height:1.8em;*/ + font-size:11px; + margin:0; +} +.topNav { + background-color:#4D7A97; + color:#FFFFFF; + float:left; + padding:0; + width:100%; + clear:right; + height:2.8em; + padding-top:10px; + overflow:hidden; + font-size:12px; +} +.bottomNav { + margin-top:10px; + background-color:#4D7A97; + color:#FFFFFF; + float:left; + padding:0; + width:100%; + clear:right; + height:2.8em; + padding-top:10px; + overflow:hidden; + font-size:12px; +} +.subNav { + background-color:#dee3e9; + float:left; + width:100%; + overflow:hidden; + font-size:12px; +} +.subNav div { + clear:left; + float:left; + padding:0 0 5px 6px; + text-transform:uppercase; +} +ul.navList, ul.subNavList { + float:left; + margin:0 25px 0 0; + padding:0; +} +ul.navList li{ + list-style:none; + float:left; + padding: 5px 6px; + text-transform:uppercase; +} +ul.subNavList li{ + list-style:none; + float:left; +} +.topNav a:link, .topNav a:active, .topNav a:visited, .bottomNav a:link, .bottomNav a:active, .bottomNav a:visited { + color:#FFFFFF; + text-decoration:none; + text-transform:uppercase; +} +.topNav a:hover, .bottomNav a:hover { + text-decoration:none; + color:#bb7a2a; + text-transform:uppercase; +} +.navBarCell1Rev { + background-color:#F8981D; + color:#253441; + margin: auto 5px; +} +.skipNav { + position:absolute; + top:auto; + left:-9999px; + overflow:hidden; +} +/* +Page header and footer styles +*/ +.header, .footer { + clear:both; + margin:0 20px; + padding:5px 0 0 0; +} +.indexHeader { + margin:10px; + position:relative; +} +.indexHeader span{ + margin-right:15px; +} +.indexHeader h1 { + font-size:13px; +} +.title { + color:#2c4557; + margin:10px 0; +} +.subTitle { + margin:5px 0 0 0; +} +.header ul { + margin:0 0 15px 0; + padding:0; +} +.footer ul { + margin:20px 0 5px 0; +} +.header ul li, .footer ul li { + list-style:none; + font-size:13px; +} +/* +Heading styles +*/ +div.details ul.blockList ul.blockList ul.blockList li.blockList h4, div.details ul.blockList ul.blockList ul.blockListLast li.blockList h4 { + background-color:#dee3e9; + border:1px solid #d0d9e0; + margin:0 0 6px -8px; + padding:7px 5px; +} +ul.blockList ul.blockList ul.blockList li.blockList h3 { + background-color:#dee3e9; + border:1px solid #d0d9e0; + margin:0 0 6px -8px; + padding:7px 5px; +} +ul.blockList ul.blockList li.blockList h3 { + padding:0; + margin:15px 0; +} +ul.blockList li.blockList h2 { + padding:0px 0 20px 0; +} +/* +Page layout container styles +*/ +.contentContainer, .sourceContainer, .classUseContainer, .serializedFormContainer, .constantValuesContainer { + clear:both; + padding:10px 20px; + position:relative; +} +.indexContainer { + margin:10px; + position:relative; + font-size:12px; +} +.indexContainer h2 { + font-size:13px; + padding:0 0 3px 0; +} +.indexContainer ul { + margin:0; + padding:0; +} +.indexContainer ul li { + list-style:none; + padding-top:2px; +} +.contentContainer .description dl dt, .contentContainer .details dl dt, .serializedFormContainer dl dt { + font-size:12px; + font-weight:bold; + margin:10px 0 0 0; + color:#4E4E4E; +} +.contentContainer .description dl dd, .contentContainer .details dl dd, .serializedFormContainer dl dd { + margin:5px 0 10px 0px; + font-size:14px; + font-family:'DejaVu Sans Mono',monospace; +} +.serializedFormContainer dl.nameValue dt { + margin-left:1px; + font-size:1.1em; + display:inline; + font-weight:bold; +} +.serializedFormContainer dl.nameValue dd { + margin:0 0 0 1px; + font-size:1.1em; + display:inline; +} +/* +List styles +*/ +ul.horizontal li { + display:inline; + font-size:0.9em; +} +ul.inheritance { + margin:0; + padding:0; +} +ul.inheritance li { + display:inline; + list-style:none; +} +ul.inheritance li ul.inheritance { + margin-left:15px; + padding-left:15px; + padding-top:1px; +} +ul.blockList, ul.blockListLast { + margin:10px 0 10px 0; + padding:0; +} +ul.blockList li.blockList, ul.blockListLast li.blockList { + list-style:none; + margin-bottom:15px; + line-height:1.4; +} +ul.blockList ul.blockList li.blockList, ul.blockList ul.blockListLast li.blockList { + padding:0px 20px 5px 10px; + border:1px solid #ededed; + background-color:#f8f8f8; +} +ul.blockList ul.blockList ul.blockList li.blockList, ul.blockList ul.blockList ul.blockListLast li.blockList { + padding:0 0 5px 8px; + background-color:#ffffff; + border:none; +} +ul.blockList ul.blockList ul.blockList ul.blockList li.blockList { + margin-left:0; + padding-left:0; + padding-bottom:15px; + border:none; +} +ul.blockList ul.blockList ul.blockList ul.blockList li.blockListLast { + list-style:none; + border-bottom:none; + padding-bottom:0; +} +table tr td dl, table tr td dl dt, table tr td dl dd { + margin-top:0; + margin-bottom:1px; +} +/* +Table styles +*/ +.overviewSummary, .memberSummary, .typeSummary, .useSummary, .constantsSummary, .deprecatedSummary { + width:100%; + border-left:1px solid #EEE; + border-right:1px solid #EEE; + border-bottom:1px solid #EEE; +} +.overviewSummary, .memberSummary { + padding:0px; +} +.overviewSummary caption, .memberSummary caption, .typeSummary caption, +.useSummary caption, .constantsSummary caption, .deprecatedSummary caption { + position:relative; + text-align:left; + background-repeat:no-repeat; + color:#253441; + font-weight:bold; + clear:none; + overflow:hidden; + padding:0px; + padding-top:10px; + padding-left:1px; + margin:0px; + white-space:pre; +} +.overviewSummary caption a:link, .memberSummary caption a:link, .typeSummary caption a:link, +.useSummary caption a:link, .constantsSummary caption a:link, .deprecatedSummary caption a:link, +.overviewSummary caption a:hover, .memberSummary caption a:hover, .typeSummary caption a:hover, +.useSummary caption a:hover, .constantsSummary caption a:hover, .deprecatedSummary caption a:hover, +.overviewSummary caption a:active, .memberSummary caption a:active, .typeSummary caption a:active, +.useSummary caption a:active, .constantsSummary caption a:active, .deprecatedSummary caption a:active, +.overviewSummary caption a:visited, .memberSummary caption a:visited, .typeSummary caption a:visited, +.useSummary caption a:visited, .constantsSummary caption a:visited, .deprecatedSummary caption a:visited { + color:#FFFFFF; +} +.overviewSummary caption span, .memberSummary caption span, .typeSummary caption span, +.useSummary caption span, .constantsSummary caption span, .deprecatedSummary caption span { + white-space:nowrap; + padding-top:5px; + padding-left:12px; + padding-right:12px; + padding-bottom:7px; + display:inline-block; + float:left; + background-color:#F8981D; + border: none; + height:16px; +} +.memberSummary caption span.activeTableTab span { + white-space:nowrap; + padding-top:5px; + padding-left:12px; + padding-right:12px; + margin-right:3px; + display:inline-block; + float:left; + background-color:#F8981D; + height:16px; +} +.memberSummary caption span.tableTab span { + white-space:nowrap; + padding-top:5px; + padding-left:12px; + padding-right:12px; + margin-right:3px; + display:inline-block; + float:left; + background-color:#4D7A97; + height:16px; +} +.memberSummary caption span.tableTab, .memberSummary caption span.activeTableTab { + padding-top:0px; + padding-left:0px; + padding-right:0px; + background-image:none; + float:none; + display:inline; +} +.overviewSummary .tabEnd, .memberSummary .tabEnd, .typeSummary .tabEnd, +.useSummary .tabEnd, .constantsSummary .tabEnd, .deprecatedSummary .tabEnd { + display:none; + width:5px; + position:relative; + float:left; + background-color:#F8981D; +} +.memberSummary .activeTableTab .tabEnd { + display:none; + width:5px; + margin-right:3px; + position:relative; + float:left; + background-color:#F8981D; +} +.memberSummary .tableTab .tabEnd { + display:none; + width:5px; + margin-right:3px; + position:relative; + background-color:#4D7A97; + float:left; + +} +.overviewSummary td, .memberSummary td, .typeSummary td, +.useSummary td, .constantsSummary td, .deprecatedSummary td { + text-align:left; + padding:0px 0px 12px 10px; + width:100%; +} +th.colOne, th.colFirst, th.colLast, .useSummary th, .constantsSummary th, +td.colOne, td.colFirst, td.colLast, .useSummary td, .constantsSummary td{ + vertical-align:top; + padding-right:0px; + padding-top:8px; + padding-bottom:3px; +} +th.colFirst, th.colLast, th.colOne, .constantsSummary th { + background:#dee3e9; + text-align:left; + padding:8px 3px 3px 7px; +} +td.colFirst, th.colFirst { + white-space:nowrap; + font-size:13px; +} +td.colLast, th.colLast { + font-size:13px; +} +td.colOne, th.colOne { + font-size:13px; +} +.overviewSummary td.colFirst, .overviewSummary th.colFirst, +.overviewSummary td.colOne, .overviewSummary th.colOne, +.memberSummary td.colFirst, .memberSummary th.colFirst, +.memberSummary td.colOne, .memberSummary th.colOne, +.typeSummary td.colFirst{ + width:25%; + vertical-align:top; +} +td.colOne a:link, td.colOne a:active, td.colOne a:visited, td.colOne a:hover, td.colFirst a:link, td.colFirst a:active, td.colFirst a:visited, td.colFirst a:hover, td.colLast a:link, td.colLast a:active, td.colLast a:visited, td.colLast a:hover, .constantValuesContainer td a:link, .constantValuesContainer td a:active, .constantValuesContainer td a:visited, .constantValuesContainer td a:hover { + font-weight:bold; +} +.tableSubHeadingColor { + background-color:#EEEEFF; +} +.altColor { + background-color:#FFFFFF; +} +.rowColor { + background-color:#EEEEEF; +} +/* +Content styles +*/ +.description pre { + margin-top:0; +} +.deprecatedContent { + margin:0; + padding:10px 0; +} +.docSummary { + padding:0; +} + +ul.blockList ul.blockList ul.blockList li.blockList h3 { + font-style:normal; +} + +div.block { + font-size:14px; + font-family:'DejaVu Serif', Georgia, "Times New Roman", Times, serif; +} + +td.colLast div { + padding-top:0px; +} + + +td.colLast a { + padding-bottom:3px; +} +/* +Formatting effect styles +*/ +.sourceLineNo { + color:green; + padding:0 30px 0 0; +} +h1.hidden { + visibility:hidden; + overflow:hidden; + font-size:10px; +} +.block { + display:block; + margin:3px 10px 2px 0px; + color:#474747; +} +.deprecatedLabel, .descfrmTypeLabel, .memberNameLabel, .memberNameLink, +.overrideSpecifyLabel, .packageHierarchyLabel, .paramLabel, .returnLabel, +.seeLabel, .simpleTagLabel, .throwsLabel, .typeNameLabel, .typeNameLink { + font-weight:bold; +} +.deprecationComment, .emphasizedPhrase, .interfaceName { + font-style:italic; +} + +div.block div.block span.deprecationComment, div.block div.block span.emphasizedPhrase, +div.block div.block span.interfaceName { + font-style:normal; +} + +div.contentContainer ul.blockList li.blockList h2{ + padding-bottom:0px; +} diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..20da392 --- /dev/null +++ b/pom.xml @@ -0,0 +1,73 @@ + + 4.0.0 + pt.ptcris + ptcrisync + 0.0.1 + + + UTF-8 + 1.8 + 2.0 + 1.1.9 + 4.12 + + + + + + org.um.dsi.gavea + degois-orcid-client + ${orcid-api-client.version} + + + + ch.qos.logback + logback-classic + ${logback-version} + compile + + + + junit + junit + ${junit.version} + + + + + + + + + org.apache.maven.plugins + maven-jar-plugin + 3.0.0 + + ${java.version} + ${java.version} + + + + maven-compiler-plugin + 3.3 + + ${java.version} + ${java.version} + + + + true + maven-deploy-plugin + 2.8.2 + + true + + + + + + + PTCRISync + This project aims to help the synchronization between ORCID and local systems. + diff --git a/src/main/java/pt/ptcris/ORCIDClient.java b/src/main/java/pt/ptcris/ORCIDClient.java new file mode 100644 index 0000000..2726774 --- /dev/null +++ b/src/main/java/pt/ptcris/ORCIDClient.java @@ -0,0 +1,193 @@ +/* + * Copyright (c) 2016, 2017 PTCRIS - FCT|FCCN and others. + * Licensed under MIT License + * http://ptcris.pt + * + * This copyright and license information (including a link to the full license) + * shall be included in its entirety in all copies or substantial portion of + * the software. + */ +package pt.ptcris; + +import java.math.BigInteger; +import java.util.List; +import java.util.Map; + +import org.um.dsi.gavea.orcid.client.exception.OrcidClientException; +import org.um.dsi.gavea.orcid.model.activities.ActivitiesSummary; +import org.um.dsi.gavea.orcid.model.activities.Fundings; +import org.um.dsi.gavea.orcid.model.activities.Works; +import org.um.dsi.gavea.orcid.model.funding.Funding; +import org.um.dsi.gavea.orcid.model.funding.FundingSummary; +import org.um.dsi.gavea.orcid.model.work.Work; +import org.um.dsi.gavea.orcid.model.work.WorkSummary; + +/** + * Interface that encapsulates the communication with the ORCID client for a + * specified user profile. + * + * Currently focuses on managing {@link org.um.dsi.gavea.orcid.model.work.Work + * works}. + */ +public interface ORCIDClient { + + /** + * Returns the Member API client id that will commit the changes (i.e., the + * works' source). + * + * @return the client id + */ + public String getClientId(); + + /** + * Returns the user ORCID to whose profiles the changes will be commited. + * + * @return the user ORCID + */ + public String getUserId(); + + /** + * Retrieves every activity summary from the ORCID profile. + * + * @return the activities summary of the ORCID profile + * @throws OrcidClientException + * if the communication with ORCID fails + */ + public ActivitiesSummary getActivitiesSummary() throws OrcidClientException; + + /** + * Retrieves every work summary from the ORCID profile. + * + * @return the work summaries of the ORCID profile + * @throws OrcidClientException + * if the communication with ORCID fails + */ + public Works getWorksSummary() throws OrcidClientException; + + /** + * Retrieves every funding summary from the ORCID profile. + * + * @return the funding summaries of the ORCID profile + * @throws OrcidClientException + * if the communication with ORCID fails + */ + public Fundings getFundingsSummary() throws OrcidClientException; + + /** + * Retrieves a complete work from the ORCID profile (as opposed to only its + * summary). Exceptions are embedded in the {@link PTCRISyncResult}. + * + * @param summary + * the summary of the work to be retrieved + * @return the complete work + */ + public PTCRISyncResult getWork(WorkSummary summary); + + /** + * Retrieves a complete funding entry from the ORCID profile (as opposed to + * only its summary). Exceptions are embedded in the {@link PTCRISyncResult}. + * + * @param summary + * the summary of the funding entry to be retrieved + * @return the complete funding entry + */ + public PTCRISyncResult getFunding(FundingSummary summary); + + /** + * Retrieves a list of complete work from the ORCID profile (as opposed to + * only their summaries). Exceptions are embedded in the + * {@link PTCRISyncResult}. This should generate a single API call + * internally. + * + * @param summaries + * the summaries of the works to be retrieved + * @return the complete works + */ + public Map> getWorks(List summaries); + + /** + * Adds a new work to the ORCID profile and returns the assigned put-code. + * Exceptions are embedded in the {@link PTCRISyncResult}. + * + * @param work + * the work to be added to the ORCID profile + * @return the put-code assigned by ORCID to the newly created work + */ + public PTCRISyncResult addWork(Work work); + + /** + * Adds a new funding entry to the ORCID profile and returns the assigned + * put-code. Exceptions are embedded in the {@link PTCRISyncResult}. + * + * @param funding + * the funding entry to be added to the ORCID profile + * @return the put-code assigned by ORCID to the newly created funding entry + */ + public PTCRISyncResult addFunding(Funding funding); + + /** + * Adds a list of new works to the ORCID profile. Exceptions are embedded in + * the {@link PTCRISyncResult}. This should generate a single API call + * internally. + * + * @param works + * the works to be added to the ORCID profile + * @return the put-codes assigned by ORCID to each of the newly created + * works + */ + public List> addWorks(List works); + + /** + * Deletes a work from the ORCID profile. Exceptions are embedded in + * the {@link PTCRISyncResult}. + * + * @param putcode + * the put-code of the work to be deleted + * @return the outcome of the delete request + */ + public PTCRISyncResult deleteWork(BigInteger putcode); + + /** + * Deletes a funding entry from the ORCID profile. Exceptions are embedded + * in the {@link PTCRISyncResult}. + * + * @param putcode + * the put-code of the funding entry to be deleted + * @return the outcome of the delete request + */ + public PTCRISyncResult deleteFunding(BigInteger putcode); + + /** + * Updates a work in the ORCID profile. Exceptions are embedded in + * the {@link PTCRISyncResult}. + * + * @param putcode + * the put-code of the work to be updated + * @param work + * the new state of the work + * @return the outcome of the update request + */ + public PTCRISyncResult updateWork(BigInteger putcode, Work work); + + /** + * Updates a funding entry in the ORCID profile. Exceptions are embedded in + * the {@link PTCRISyncResult}. + * + * @param putcode + * the put-code of the funding entry to be updated + * @param funding + * the new state of the funding entry + * @return the outcome of the update request + */ + public PTCRISyncResult updateFunding(BigInteger putcode, Funding funding); + + /** + * The number of worker threads that will be used to communicate with the + * ORCID API. + * + * @return the number of ORCID worker threads + */ + public int threads(); + + +} \ No newline at end of file diff --git a/src/main/java/pt/ptcris/ORCIDClientImpl.java b/src/main/java/pt/ptcris/ORCIDClientImpl.java new file mode 100644 index 0000000..c8060a3 --- /dev/null +++ b/src/main/java/pt/ptcris/ORCIDClientImpl.java @@ -0,0 +1,422 @@ +/* + * Copyright (c) 2016, 2017 PTCRIS - FCT|FCCN and others. + * Licensed under MIT License + * http://ptcris.pt + * + * This copyright and license information (including a link to the full license) + * shall be included in its entirety in all copies or substantial portion of + * the software. + */ +package pt.ptcris; + +import java.io.Serializable; +import java.math.BigInteger; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.um.dsi.gavea.orcid.client.OrcidAccessToken; +import org.um.dsi.gavea.orcid.client.exception.OrcidClientException; +import org.um.dsi.gavea.orcid.model.activities.ActivitiesSummary; +import org.um.dsi.gavea.orcid.model.activities.Fundings; +import org.um.dsi.gavea.orcid.model.activities.Works; +import org.um.dsi.gavea.orcid.model.bulk.Bulk; +import org.um.dsi.gavea.orcid.model.common.ElementSummary; +import org.um.dsi.gavea.orcid.model.work.Work; +import org.um.dsi.gavea.orcid.model.work.WorkSummary; +import org.um.dsi.gavea.orcid.model.error.Error; +import org.um.dsi.gavea.orcid.model.funding.Funding; +import org.um.dsi.gavea.orcid.model.funding.FundingSummary; + +import pt.ptcris.utils.ORCIDFundingHelper; +import pt.ptcris.utils.ORCIDHelper; +import pt.ptcris.utils.ORCIDWorkHelper; + +/** + * An implementation of the ORCID client interface built over the + * {@link org.um.dsi.gavea.orcid.client.OrcidOAuthClient Degois client}. + * + * Besides the tokens to use the ORCID Member API, it also store the tokens to + * access a particular ORCID user profile. + * + * @see ORCIDClient + */ +public class ORCIDClientImpl implements ORCIDClient { + + private final OrcidAccessToken orcidToken; + private final TempORCIDClient orcidClient; + private final String clientId; + private final int threads; + + /** + * Instantiates an ORCID client to communicate with the ORCID API. + * + * @param loginUri + * the login URI of the ORCID service + * @param apiUri + * the URI of the ORCID API + * @param clientId + * the id of the ORCID Member API client + * @param clientSecret + * the secret of the ORCID Member API client + * @param redirectUri + * the redirect URI for requesting the access token + * @param orcidToken + * the access token to the user ORCID profile + * @param threads + * the number of ORCID worker threads + */ + public ORCIDClientImpl(String loginUri, String apiUri, String clientId, + String clientSecret, String redirectUri, + OrcidAccessToken orcidToken, int threads) { + this(loginUri, apiUri, clientId, clientSecret, redirectUri, orcidToken, + false, threads); + } + + /** + * Instantiates an ORCID client to communicate with the ORCID API. + * + * @param loginUri + * the login URI of the ORCID service + * @param apiUri + * the URI of the ORCID API + * @param clientId + * the id of the ORCID Member API client + * @param clientSecret + * the secret of the ORCID Member API client + * @param redirectUri + * the redirect URI for requesting the access token + * @param orcidToken + * the access token to the user ORCID profile + */ + public ORCIDClientImpl(String loginUri, String apiUri, String clientId, + String clientSecret, String redirectUri, OrcidAccessToken orcidToken) { + this(loginUri, apiUri, clientId, clientSecret, redirectUri, orcidToken, + false, Runtime.getRuntime().availableProcessors() + 2); + } + + /** + * Instantiates an ORCID client to communicate with the ORCID API. + * + * @param loginUri + * the login URI of the ORCID service + * @param apiUri + * the URI of the ORCID API + * @param clientId + * the id of the ORCID Member API client + * @param clientSecret + * the secret of the ORCID Member API client + * @param redirectUri + * the redirect URI for requesting the access token + * @param orcidToken + * the access token to the user ORCID profile + * @param debugMode + * Enter debug mode + */ + public ORCIDClientImpl(String loginUri, String apiUri, String clientId, + String clientSecret, String redirectUri, + OrcidAccessToken orcidToken, boolean debugMode) { + this(loginUri, apiUri, clientId, clientSecret, redirectUri, orcidToken, + debugMode, Runtime.getRuntime().availableProcessors() + 2); + } + + /** + * Instantiates an ORCID client to communicate with the ORCID API. + * + * @param loginUri + * the login URI of the ORCID service + * @param apiUri + * the URI of the ORCID API + * @param clientId + * the id of the ORCID Member API client + * @param clientSecret + * the secret of the ORCID Member API client + * @param redirectUri + * the redirect URI for requesting the access token + * @param orcidToken + * the access token to the user ORCID profile + * @param debugMode + * Enter debug mode + * @param threads + * the number of ORCID worker threads + */ + public ORCIDClientImpl(String loginUri, String apiUri, String clientId, + String clientSecret, String redirectUri, + OrcidAccessToken orcidToken, boolean debugMode, int threads) { + this.orcidToken = orcidToken; + this.clientId = clientId; + this.threads = threads; + this.orcidClient = new TempORCIDClient(loginUri, apiUri, clientId, + clientSecret, redirectUri, debugMode); + } + + /** + * {@inheritDoc} + */ + @Override + public String getClientId() { + return clientId; + } + + /** + * {@inheritDoc} + */ + @Override + public String getUserId() { + return orcidToken.getOrcid(); + } + + /** + * {@inheritDoc} + */ + @Override + public ActivitiesSummary getActivitiesSummary() throws OrcidClientException { + return orcidClient.readActivitiesSummary(orcidToken); + } + + /** + * {@inheritDoc} + */ + @Override + public Works getWorksSummary() throws OrcidClientException { + return orcidClient.readWorksSummary(orcidToken); + } + + /** + * {@inheritDoc} + */ + @Override + public Fundings getFundingsSummary() throws OrcidClientException { + return orcidClient.readFundingsSummary(orcidToken); + } + + /** + * {@inheritDoc} + */ + @Override + public PTCRISyncResult getWork(WorkSummary putcode) { + PTCRISyncResult res; + try { + Work fund = orcidClient.readWork(orcidToken, putcode.getPutCode() + .toString()); + finalizeGet(fund, putcode); + res = PTCRISyncResult.ok_get(putcode.getPutCode(), fund); + } catch (OrcidClientException e) { + res = PTCRISyncResult.fail(e); + } + return res; + } + + /** + * {@inheritDoc} + */ + @Override + public PTCRISyncResult getFunding(FundingSummary putcode) { + PTCRISyncResult res; + try { + Funding fund = orcidClient.readFunding(orcidToken, putcode + .getPutCode().toString()); + finalizeGet(fund, putcode); + res = PTCRISyncResult.ok_get(putcode.getPutCode(), fund); + } catch (OrcidClientException e) { + res = PTCRISyncResult.fail(e); + } + return res; + } + + /** + * {@inheritDoc} + */ + @Override + public Map> getWorks(List summaries) { + List pcs = new ArrayList(); + for (ElementSummary i : summaries) + pcs.add(i.getPutCode().toString()); + Map> res = new HashMap>(); + try { + List bulk = orcidClient.readWorks(orcidToken, pcs) + .getWorkOrError(); + for (int i = 0; i < summaries.size(); i++) { + Serializable w = bulk.get(i); + if (w instanceof Work) { + finalizeGet((Work) w, summaries.get(i)); + res.put(summaries.get(i).getPutCode(), PTCRISyncResult.ok_get( + summaries.get(i).getPutCode(), (Work) w)); + } else { + Error err = (Error) w; + OrcidClientException e = new OrcidClientException( + err.getResponseCode(), err.getUserMessage(), + err.getErrorCode(), err.getDeveloperMessage()); + res.put(summaries.get(i).getPutCode(), + PTCRISyncResult.fail(e)); + } + } + } catch (OrcidClientException e1) { + for (int i = 0; i < summaries.size(); i++) + res.put(summaries.get(i).getPutCode(), PTCRISyncResult.fail(e1)); + } + return res; + } + + /** + * {@inheritDoc} + */ + @Override + public PTCRISyncResult addWork(Work work) { + PTCRISyncResult res; + try { + BigInteger putcode = new BigInteger(orcidClient.addWork(orcidToken, + work)); + res = PTCRISyncResult.ok_add(putcode); + } catch (OrcidClientException e) { + return PTCRISyncResult.fail(e); + } + return res; + } + + /** + * {@inheritDoc} + */ + @Override + public PTCRISyncResult addFunding(Funding fund) { + PTCRISyncResult res; + try { + BigInteger putcode = new BigInteger(orcidClient.addFunding( + orcidToken, fund)); + res = PTCRISyncResult.ok_add(putcode); + } catch (OrcidClientException e) { + return PTCRISyncResult.fail(e); + } + return res; + } + + /** + * {@inheritDoc} + */ + @Override + public List> addWorks(List works) { + Bulk bulk = new Bulk(); + List> res = new ArrayList>(); + for (Work work : works) + bulk.getWorkOrError().add(work); + try { + Bulk res_bulk = orcidClient.addWorks(orcidToken, bulk); + for (Serializable r : res_bulk.getWorkOrError()) { + if (r instanceof Work) + res.add(PTCRISyncResult.ok_add(((Work) r).getPutCode())); + else { + Error err = (Error) r; + OrcidClientException e = new OrcidClientException( + err.getResponseCode(), err.getUserMessage(), + err.getErrorCode(), err.getDeveloperMessage()); + res.add(PTCRISyncResult.fail(e)); + } + } + } catch (OrcidClientException e) { + for (int i = 0; i < works.size(); i++) + res.add(PTCRISyncResult.fail(e)); + } + return res; + } + + /** + * {@inheritDoc} + */ + @Override + public PTCRISyncResult deleteWork(BigInteger putcode) { + try { + orcidClient.deleteWork(orcidToken, putcode.toString()); + return PTCRISyncResult.ok_del(); + } catch (OrcidClientException e) { + return PTCRISyncResult.fail(e); + } + } + + /** + * {@inheritDoc} + */ + @Override + public PTCRISyncResult deleteFunding(BigInteger putcode) { + try { + orcidClient.deleteFunding(orcidToken, putcode.toString()); + return PTCRISyncResult.ok_del(); + } catch (OrcidClientException e) { + return PTCRISyncResult.fail(e); + } + } + + /** + * {@inheritDoc} + */ + @Override + public PTCRISyncResult updateWork(BigInteger putcode, Work work) { + PTCRISyncResult res; + try { + orcidClient.updateWork(orcidToken, putcode.toString(), work); + res = PTCRISyncResult.ok_upd(); + } catch (OrcidClientException e) { + return PTCRISyncResult.fail(e); + } + return res; + } + + /** + * {@inheritDoc} + */ + @Override + public PTCRISyncResult updateFunding(BigInteger putcode, Funding work) { + PTCRISyncResult res; + try { + orcidClient.updateFunding(orcidToken, putcode.toString(), work); + res = PTCRISyncResult.ok_upd(); + } catch (OrcidClientException e) { + return PTCRISyncResult.fail(e); + } + return res; + } + + /** + * {@inheritDoc} + */ + @Override + public int threads() { + return threads; + } + + /** + * Finalizes a work reading by updating the meta-data. Clears the + * put-code and assigns the complete set of external identifiers. + * + * @see #getWork(WorkSummary) + * + * @param full + * the newly retrieved element + * @param summary + * the original summary + */ + private static void finalizeGet(Work full, WorkSummary summary) { + // External ids are not inherited... + full.setExternalIds(new ORCIDWorkHelper(null) + .getNonNullExternalIdsS((WorkSummary) summary)); + ORCIDHelper.cleanWorkLocalKey(full); + } + + /** + * Finalizes a funding reading by updating the meta-data. Clears the + * put-code and assigns the complete set of external identifiers. + * + * @see #getFunding(FundingSummary) + * + * @param full + * the newly retrieved element + * @param summary + * the original summary + */ + private static void finalizeGet(Funding full, FundingSummary summary) { + full.setExternalIds(new ORCIDFundingHelper(null) + .getNonNullExternalIdsS((FundingSummary) summary)); + ORCIDHelper.cleanWorkLocalKey(full); + } + +} diff --git a/src/main/java/pt/ptcris/PTCRISGrouper.java b/src/main/java/pt/ptcris/PTCRISGrouper.java new file mode 100644 index 0000000..f324a4b --- /dev/null +++ b/src/main/java/pt/ptcris/PTCRISGrouper.java @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2016, 2017 PTCRIS - FCT|FCCN and others. + * Licensed under MIT License + * http://ptcris.pt + * + * This copyright and license information (including a link to the full license) + * shall be included in its entirety in all copies or substantial portion of + * the software. + */ +package pt.ptcris; + +import java.util.Collection; +import java.util.List; + +import pt.ptcris.grouper.ActivityComparator; +import pt.ptcris.grouper.ActivityGroup; +import pt.ptcris.grouper.GroupGenerator; + +/** + *

+ * A generic activity grouper for the PTCRIS framework. The method is + * customizable by a {@link ActivityComparator comparison criteria} that + * determines when two activities match each other, in which case they are + * grouped together. This relationship is transitive: two non-matching + * activities may belong to the same group if they both match a third one. + *

+ * + *

+ * The user should provide an {@link ActivityComparator activity comparator} + * that defines matching activities by calculating a similarity metric, and the + * respective threshold. + *

+ * + * TODO: Activities within groups are not ordered, groups are sets. Should they + * be? Specifically, ordered by meta-data quality (e.g., number of filled + * fields). + * + * TODO: Singleton groups are being returned. Does this encumber the process? + * Should they be filtered by the grouper or by requesting services? + */ +public class PTCRISGrouper { + + /** + * Groups a list of local activities into groups of matching activities, + * according to the provided comparator. + * + * @param the type of entries being grouped + * @param locals + * the local activities to be grouped + * @param comparator + * the provided activity comparator + * @return the local activities, grouped + */ + public static List> group(Collection locals, ActivityComparator comparator) { + GroupGenerator gen = new GroupGenerator(comparator); + for (E e : locals) + gen.group(e); + return gen.getGroups(); + } + +} diff --git a/src/main/java/pt/ptcris/PTCRISync.java b/src/main/java/pt/ptcris/PTCRISync.java new file mode 100644 index 0000000..1d65aca --- /dev/null +++ b/src/main/java/pt/ptcris/PTCRISync.java @@ -0,0 +1,1466 @@ +/* + * Copyright (c) 2016, 2017 PTCRIS - FCT|FCCN and others. + * Licensed under MIT License + * http://ptcris.pt + * + * This copyright and license information (including a link to the full license) + * shall be included in its entirety in all copies or substantial portion of + * the software. + */ +package pt.ptcris; + +import java.math.BigInteger; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.HashMap; +import java.util.HashSet; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import org.um.dsi.gavea.orcid.client.exception.OrcidClientException; +import org.um.dsi.gavea.orcid.model.common.ElementSummary; +import org.um.dsi.gavea.orcid.model.common.ExternalId; +import org.um.dsi.gavea.orcid.model.common.ExternalIds; +import org.um.dsi.gavea.orcid.model.funding.Funding; +import org.um.dsi.gavea.orcid.model.funding.FundingType; +import org.um.dsi.gavea.orcid.model.person.externalidentifier.ExternalIdentifier; +import org.um.dsi.gavea.orcid.model.work.Work; +import org.um.dsi.gavea.orcid.model.work.WorkType; + +import pt.ptcris.exceptions.InvalidActivityException; +import pt.ptcris.handlers.ProgressHandler; +import pt.ptcris.utils.ExternalIdsDiff; +import pt.ptcris.utils.ORCIDFundingHelper; +import pt.ptcris.utils.ORCIDHelper; +import pt.ptcris.utils.ORCIDWorkHelper; +import pt.ptcris.utils.UpdateRecord; + +/** + *

+ * An implementation of the PTCRISync synchronization service based on the + * version 0.4.3 of the specification, enhanced with minimal quality criteria. + * This service allows CRIS services to maintain their repositories synchronized + * with ORCID. This requires the CRIS service to have access to the ORCID Member + * API. + *

+ * + *

+ * The service has two main functionalities: to keep a set of local activities + * updated in an ORCID user profile through an + * {@link #exportBase(ORCIDHelper, List, Collection, boolean, ProgressHandler) + * export} procedure, and import activities not known locally from the ORCID + * profile, either through the + * {@link #importBase(ORCIDHelper, List, Collection, ProgressHandler) import} + * for completely new activities or through the + * {@link #importUpdatesBase(ORCIDHelper, List, Collection, ProgressHandler) + * import} for new information for already known entries. Activities must meet + * certain quality criteria to be imported (the set of invalid activities can be + * retrieved as well through + * {@link #importInvalidBase(ORCIDHelper, List, Collection, ProgressHandler)}. + *

+ * + *

+ * The implementation of the service assumes that the local CRIS communicates + * the local activities following the established ORCID schema, according to the + * ORCID Member API 2.0. This uniforms the API and simplifies the + * synchronization process. The current version focuses on synchronizing + * research productions and funding entries, which must be encoded as ORCID + * {@link Work works} and {@link Funding funding} activities. + *

+ * + *

+ * The communication with ORCID is encapsulated in an ORCID {@link ORCIDClient + * client} that contains information regarding the CRIS Member API and the ORCID + * profile that is to be managed. An {@link ORCIDHelper helper} provides utility + * methods for the synchronization of activities. + *

+ * + *

+ * The procedures do not currently consider the contributors (authors) of activities + * when assessing the quality criteria nor when assessing whether they are + * up-to-date, as this information is not available in ORCID summaries and would + * require additional calls to the ORCID API. + *

+ * + * See https://ptcris.pt/hub-ptcris/. + */ +public final class PTCRISync { + + /** + *

+ * Exports a list of local CRIS productions to an ORCID profile and keeps + * them up-to-date. This procedure manages the work activities in the ORCID + * user profile that are sourced by the CRIS, both previously specified in + * the {@code client}. + *

+ * + *

+ * The procedure detects every CRIS sourced work in the ORCID profile that + * matches any local entry that is being exported; if there is no matching + * local entry, the ORCID activity is deleted from the profile. Otherwise it + * will be updated with the meta-data of one of the matching local entries. + * Finally, for local entries without any matching ORCID activity, new ones + * are created. The matching is performed by detecting shared + * {@link ExternalIdentifier external identifiers} (see + * {@link ORCIDWorkHelper#getSelfExternalIdsDiffS(ElementSummary, Collection)} + * ). + *

+ * + *

+ * Activities are only updated if the meta-data is not up-to-date. + * Currently, the title, the publication year and the publication are + * considered (see {@link ORCIDWorkHelper#isUpToDateE(ElementSummary, ElementSummary)}). + *

+ * + *

+ * The procedure expects the CRIS service to provide the local works in the + * ORCID schema, in particular encoding them as {@link Work works}. Thus, + * the meta-data of the CRIS sourced entries in the ORCID profile is exactly + * that of the provided local entries that are to be exported. The put-code + * of these local entries is assumed to be used as local key identifiers, + * and are disregarded during the update of the ORCID profile (new entries + * are assigned fresh put-codes and updated entries use the put-code of the + * existing ORCID entry). + *

+ * + *

+ * The provided local activities must pass a quality criteria to be kept + * synchronized in ORCID. Currently, this forces the existence of external + * identifiers, the title, the publication year and the publication type + * (see {@link ORCIDWorkHelper#testMinimalQuality(ElementSummary)}. + *

+ * + *

+ * The procedure reports the status for each of the input local activities, + * identifying them by the provided local put-code, including the ORCID + * error if the process failed. See {@link PTCRISyncResult} for the codes. + * If the local put-code is empty, returns a default value, which currently + * is the put-code remotely assigned by ORCID. + *

+ * + * @param client + * the ORCID client defining the CRIS Member API and user the + * profile to be managed + * @param locals + * the list of local productions to be exported that should be + * kept synchronized in the ORCID user profile + * @param handler + * the progress handler responsible for receiving progress + * updates + * @return the result of the synchronization of each of the provided local + * work + * @throws OrcidClientException + * if the communication with ORCID fails when getting the + * activities summary + * @throws IllegalArgumentException + * if null arguments + */ + public static Map> exportWorks(ORCIDClient client, List locals, ProgressHandler handler) + throws OrcidClientException, IllegalArgumentException { + return exportBase(new ORCIDWorkHelper(client), locals, Arrays.asList(WorkType.values()), false, handler); + } + + /** + * @deprecated Replaced by {@link #exportWorks(ORCIDClient, List, ProgressHandler)} + * + * @param client + * the ORCID client defining the CRIS Member API and user the + * profile to be managed + * @param locals + * the list of local productions to be exported that should be + * kept synchronized in the ORCID user profile + * @param handler + * the progress handler responsible for receiving progress + * updates + * @return the result of the synchronization of each of the provided local + * work + * @throws OrcidClientException + * if the communication with ORCID fails when getting the + * activities summary + * @throws IllegalArgumentException + * if null arguments + */ + @Deprecated + public static Map> export(ORCIDClient client, List locals, ProgressHandler handler) + throws OrcidClientException, IllegalArgumentException { + return exportWorks(client, locals, handler); + } + + /** + *

+ * Exports a list of local CRIS productions to an ORCID profile and keeps + * them up-to-date. This procedure manages the work activities in the ORCID + * user profile that are sourced by the CRIS, both previously specified in + * the {@code client}. + *

+ * + *

+ * The procedure detects every CRIS sourced work in the ORCID profile that + * matches any local entry that is being exported; if there is no matching + * local entry, the ORCID activity is deleted from the profile. Otherwise it + * will be updated with the meta-data of one of the matching local entries. + * Finally, for local entries without any matching ORCID activity, new ones + * are created. The matching is performed by detecting shared + * {@link ExternalIdentifier external identifiers} (see + * {@link ORCIDWorkHelper#getSelfExternalIdsDiffS(ElementSummary, Collection)} + * ). + *

+ * + *

+ * Activities are always updated, even if already up-to-date (no test is + * performed). The caller of this method should guarantee that the input + * local productions have been effectively updated, otherwise there will be + * unnecessary calls to the ORCID API. + *

+ * + *

+ * The procedure expects the CRIS service to provide the local works in the + * ORCID schema, in particular encoding them as {@link Work works}. Thus, + * the meta-data of the CRIS sourced entries in the ORCID profile is exactly + * that of the provided local entries that are to be exported. The put-code + * of these local entries is assumed to be used as local key identifiers, + * and are disregarded during the update of the ORCID profile (new entries + * are assigned fresh put-codes and updated entries use the put-code of the + * existing ORCID entry). + *

+ * + *

+ * The provided local activities must pass a quality criteria to be kept + * synchronized in ORCID. Currently, this forces the existence of external + * identifiers, the title, the publication year and the publication type + * (see {@link ORCIDWorkHelper#testMinimalQuality(ElementSummary)}. + *

+ * + *

+ * The procedure reports the status for each of the input local activities, + * identifying them by the provided local put-code, including the ORCID + * error if the process failed. See {@link PTCRISyncResult} for the codes. + * If the local put-code is empty, returns a default value, which currently + * is the put-code remotely assigned by ORCID. + *

+ * + * @param client + * the ORCID client defining the CRIS Member API and user the + * profile to be managed + * @param locals + * the list of local productions to be exported that should be + * kept synchronized in the ORCID user profile + * @param handler + * the progress handler responsible for receiving progress + * updates + * @return the result of the synchronization of each of the provided local + * work + * @throws OrcidClientException + * if the communication with ORCID fails when getting the + * activities summary + * @throws IllegalArgumentException + * if null arguments + */ + public static Map> exportWorksForced(ORCIDClient client, List locals, ProgressHandler handler) + throws OrcidClientException, IllegalArgumentException { + return exportBase(new ORCIDWorkHelper(client), locals, Arrays.asList(WorkType.values()), true, handler); + } + + /** + * @deprecated Replaced by {@link #exportWorksForced(ORCIDClient, List, ProgressHandler)} + * + * @param client + * the ORCID client defining the CRIS Member API and user the + * profile to be managed + * @param locals + * the list of local productions to be exported that should be + * kept synchronized in the ORCID user profile + * @param handler + * the progress handler responsible for receiving progress + * updates + * @return the result of the synchronization of each of the provided local + * work + * @throws OrcidClientException + * if the communication with ORCID fails when getting the + * activities summary + * @throws IllegalArgumentException + * if null arguments + */ + @Deprecated + public static Map> exportForce(ORCIDClient client, List locals, ProgressHandler handler) + throws OrcidClientException, IllegalArgumentException { + return exportWorksForced(client, locals, handler); + } + + /** + *

+ * Exports a list of local CRIS funding entries to an ORCID profile and + * keeps them up-to-date. This procedure manages the funding activities in + * the ORCID user profile that are sourced by the CRIS, both previously + * specified in the {@code client}. + *

+ * + *

+ * The procedure detects every CRIS sourced funding activity in the ORCID + * profile that matches any local entry that is being exported; if there is + * no matching local entry, the ORCID activity is deleted from the profile. + * Otherwise it will be updated with the meta-data of one of the matching + * local entries. Finally, for local entries without any matching ORCID + * activity, new ones are created. The matching is performed by detecting + * shared {@link ExternalIdentifier external identifiers} (see + * {@link ORCIDFundingHelper#getSelfExternalIdsDiffS(ElementSummary, Collection)} + * ). + *

+ * + *

+ * Activities are only updated if the meta-data is not up-to-date. + * Currently, the title, the start year, the funding type and the funding + * organization are considered (see + * {@link ORCIDFundingHelper#isUpToDateE(ElementSummary, ElementSummary)}). + *

+ * + *

+ * The procedure expects the CRIS service to provide the local funding + * entries in the ORCID schema, in particular encoding them as + * {@link Funding funding activities}. Thus, the meta-data of the CRIS + * sourced entries in the ORCID profile is exactly that of the provided + * local entries that are to be exported. The put-code of these local + * entries is assumed to be used as local key identifiers, and are + * disregarded during the update of the ORCID profile (new entries are + * assigned fresh put-codes and updated entries use the put-code of the + * existing ORCID entry). + *

+ * + *

+ * The provided local activities must pass a quality criteria to be kept + * synchronized in ORCID. Currently, this forces the existence of external + * identifiers, the title, the start year, the funding type and the funding + * organization (see + * {@link ORCIDFundingHelper#testMinimalQuality(ElementSummary)}. + *

+ * + *

+ * A set of funding types can be provided to allow the independent + * synchronization of different types of entries. Local and remote + * activities outside the provided types are simply ignored (they are not + * considered invalid). + *

+ * + *

+ * The procedure reports the status for each of the input local activities, + * identifying them by the provided local put-code, including the ORCID + * error if the process failed. See {@link PTCRISyncResult} for the codes. + * If the local put-code is empty, returns a default value, which currently + * is the put-code remotely assigned by ORCID. + *

+ * + * @param client + * the ORCID client defining the CRIS Member API and user the + * profile to be managed + * @param locals + * the list of local productions to be exported that should be + * kept synchronized in the ORCID user profile + * @param types + * the types of ORCID funding entries that should be considered + * (others are simply ignored). + * @param handler + * the progress handler responsible for receiving progress + * updates + * @return the result of the synchronization of each of the provided local + * funding entry + * @throws OrcidClientException + * if the communication with ORCID fails when getting the + * activities summary + * @throws IllegalArgumentException + * if null arguments + */ + public static Map> exportFundings(ORCIDClient client, List locals, Collection types, ProgressHandler handler) + throws OrcidClientException, IllegalArgumentException { + return exportBase(new ORCIDFundingHelper(client), locals, types, false, handler); + } + + /** + *

+ * Exports a list of local CRIS activities to an ORCID profile and keeps + * them up-to-date. This procedure manages the activities in the ORCID user + * profile that are sourced by the CRIS, both previously specified in the + * {@code client}. + *

+ * + *

+ * The procedure detects every CRIS sourced activity in the ORCID profile + * that matches any local entry that is being exported; if there is no + * matching local entry, the ORCID activity is deleted from the profile. + * Otherwise it will be updated with the meta-data of one of the matching + * local entries. Finally, for local entries without any matching ORCID + * activity, new ones are created. The matching is performed by detecting + * shared {@link ExternalIdentifier external identifiers} (see + * {@link ORCIDHelper#getSelfExternalIdsDiffS(ElementSummary, Collection)} + * ). + *

+ * + *

+ * The procedure expects the CRIS service to provide the local activities in + * the ORCID schema, in particular encoding them as {@link ElementSummary + * activities}. Thus, the meta-data of the CRIS sourced entries in the ORCID + * profile is exactly that of the provided local entries that are to be + * exported. The put-code of these local entries is assumed to be used as + * local key identifiers, and are disregarded during the update of the ORCID + * profile (new entries are assigned fresh put-codes and updated entries use + * the put-code of the existing ORCID entry). + *

+ * + *

+ * The provided local activities must pass a quality criteria to be kept + * synchronized in ORCID (see + * {@link ORCIDHelper#testMinimalQuality(ElementSummary)}. + *

+ * + *

+ * A set of funding types can be provided to allow the independent + * synchronization of different types of entries. Local and remote + * activities outside the provided types are simply ignored (they are not + * considered invalid). + *

+ * + *

+ * The procedure reports the status for each of the input local activities, + * identifying them by the provided local put-code, including the ORCID + * error if the process failed. See {@link PTCRISyncResult} for the codes. + * If the local put-code is empty, returns a default value, which currently + * is the put-code remotely assigned by ORCID. + *

+ * * + *

+ * Unless {@code forced}, the ORCID activities are only updated if the + * meta-data is not up-to-date (see + * {@link ORCIDHelper#isUpToDateE(ElementSummary, ElementSummary)}). + *

+ * + *

+ * The update stage must be two-phased in order to avoid potential + * conflicts: the first phase removes external identifiers that are obsolete + * from the CRIS sourced activities, so that there are no conflicts with the + * new ones inserted in the second phase. + *

+ * + *

+ * This procedure performs a single GET call to the API to obtain the + * summaries and PUT or POST calls for each of the local input activities. + * Bulk POST requests are performed when supported. Additionally, DELETE + * calls can also be performed. The procedure only fails if the initial GET + * fails, otherwise individual failures are reported in the output. No + * asynchronous workers are used. + *

+ * + * @param helper + * helper that encapsulates the ORCID client defining the CRIS + * Member API and user the profile to be managed + * @param locals + * the list of local activities to be exported that should be + * kept synchronized in the ORCID user profile + * @param types + * the types of ORCID activities that should be considered + * (others are simply ignored). + * @param forced + * whether the update of ORCID activities should be forced, + * without testing if up-to-date + * @param handler + * the progress handler responsible for receiving progress + * updates + * @return the result of the synchronization of each of the provided local + * activity + * @throws OrcidClientException + * if the communication with ORCID fails when getting the + * activities summary + * @throws IllegalArgumentException + * if null arguments + */ + private static > Map> exportBase( + ORCIDHelper helper, List locals, + Collection types, boolean forced, ProgressHandler handler) + throws OrcidClientException, IllegalArgumentException { + + if (helper == null || locals == null || handler == null) + throw new IllegalArgumentException("Null arguments."); + + if (types == null) + types = new HashSet(); + + handler.setCurrentStatus("ORCID_SYNC_EXPORT_STARTED"); + + List orcids = helper.getSourcedSummaries(); + + Map> result = new HashMap>(); + + // start by filtering local works that do not pass the quality criteria + handler.setCurrentStatus("ORCID_SYNC_EXPORT_QUALITY",locals.size()); + Set invalids = new HashSet(); + for (int c = 0; c != locals.size(); c++) { + E local = locals.get(c); + + if (!types.contains(helper.getTypeE(local))) { + invalids.add(local); + } else { + try { + helper.tryMinimalQualityE(local, locals); + } catch (InvalidActivityException invalid) { + invalids.add(local); + result.put(ORCIDHelper.getActivityLocalKey(local, + BigInteger.valueOf(c)), PTCRISyncResult + .invalid(invalid)); + } + } + handler.step(); + } + locals.removeAll(invalids); + + // detect which remote works should be deleted or updated + handler.setCurrentStatus("ORCID_SYNC_EXPORT_ITERATION",orcids.size()); + List> toUpdate = new LinkedList>(); + for (int c = 0; c != orcids.size(); c++) { + S orcid = orcids.get(c); + + Map worksDiffs = helper.getSelfExternalIdsDiffS(orcid, locals); + // there is no local work matching a CRIS sourced remote work + if (worksDiffs.isEmpty()) { + // TODO: the delete may fail (the result is returned); how to communicate this to the caller? + helper.delete(orcid.getPutCode()); + } + // there is at least one local work matching a CRIS sourced remote work + else { + E local = worksDiffs.keySet().iterator().next(); + // if the remote work is not up-to-date or forced updates + if (forced || !helper.isUpToDateS(local, orcid)) + toUpdate.add(new UpdateRecord(local, orcid, worksDiffs.get(local))); + else + result.put(ORCIDHelper.getActivityLocalKey(local, BigInteger.valueOf(c)), + PTCRISyncResult.uptodate()); + locals.remove(local); + } + handler.step(); + } + + // first update phase, remove spurious identifiers + handler.setCurrentStatus("ORCID_SYNC_EXPORT_UPDATING_PHASE_1",toUpdate.size()); + for (int c = 0; c != toUpdate.size(); c++) { + + UpdateRecord update = toUpdate.get(c); + // the remote work has spurious external identifiers + if (!update.eidsDiff.more.isEmpty()) { + E local = update.preElement; + ExternalIds weids = new ExternalIds(); + List ids = new ArrayList(update.eidsDiff.same); + ids.addAll(helper.getPartOfExternalIdsE(local).getExternalId()); + weids.setExternalId(ids); + helper.setExternalIdsE(local,weids); + + PTCRISyncResult res = helper.update(update.posElement.getPutCode(), local); + result.put(ORCIDHelper.getActivityLocalKey(local, BigInteger.valueOf(c)),res); + } + handler.step(); + } + + // second update phase, add missing identifiers + handler.setCurrentStatus("ORCID_SYNC_EXPORT_UPDATING_PHASE_2",toUpdate.size()); + for (int c = 0; c != toUpdate.size(); c++) { + + // the remote work is missing external identifiers or not updated in the 1st phase + UpdateRecord update = toUpdate.get(c); + if (!update.eidsDiff.less.isEmpty() || update.eidsDiff.more.isEmpty()) { + E local = update.preElement; + ExternalIds weids = new ExternalIds(); + List ids = new ArrayList(update.eidsDiff.same); + ids.addAll(update.eidsDiff.less); + ids.addAll(helper.getPartOfExternalIdsE(local).getExternalId()); + weids.setExternalId(ids); + helper.setExternalIdsE(local,weids); + + PTCRISyncResult res = helper.update(update.posElement.getPutCode(), local); + result.put(ORCIDHelper.getActivityLocalKey(local, BigInteger.valueOf(c)),res); + } + handler.step(); + } + + // add the local works that had no match + // the progress handler must be moved to the helper due to bulk additions + handler.setCurrentStatus("ORCID_SYNC_EXPORT_ADDING",locals.size()); + List> res = helper.add(locals,handler); + + int pad = result.size(); + for (int i = 0; i < res.size(); i++) + result.put(ORCIDHelper.getActivityLocalKey(locals.get(i), BigInteger.valueOf(pad+i)),res.get(i)); + + handler.done(); + return result; + } + + /** + *

+ * Discovers new valid works in an ORCID profile given a set of known local + * CRIS productions. Creates creation notifications for each work group at + * ORCID (merged into as a single work by the {@link ORCIDWorkHelper helper} + * ) without matching local productions (i.e., those without shared + * {@link ExternalId external identifiers}). To import updates for works + * with shared external identifiers + * {@link #importWorkUpdates(ORCIDClient, List, ProgressHandler)} should be + * used instead. + *

+ * + *

+ * Currently, these creation notifications simply take the shape of ORCID + * works themselves (representing a merged work group). The group merging + * selects the meta-data of the preferred activity and the external + * identifiers of the whole group (see + * {@link ORCIDWorkHelper#group(Object)}). The selection of the + * meta-data from a group could be changed without affecting the correction + * of the procedure. + *

+ * + *

+ * Since the put-code attribute is used as a local key of each activity, it + * is null for these creation notifications (and not the put-code of the + * remote ORCID activity that gave origin to it). Since only the external + * identifiers of the local productions are used to search for matches, the + * remainder meta-data of the input local activities could be left null. + *

+ * + *

+ * ORCID activities without minimal quality are ignored by this procedure. + * Currently, the quality criteria forces the existence of external + * identifiers, the title, publication year and publication type (see + * {@link ORCIDWorkHelper#testMinimalQuality(ElementSummary)}). Works that do + * not match the criteria can be imported with + * {@link #importInvalid(ORCIDClient, List, ProgressHandler)}. Note that + * currently group merging simply collects the meta-data (other than the + * external identifiers) from the preferred activity, which is used in the + * quality assessment. + *

+ * + * @param client + * the ORCID client defining the CRIS Member API and user the + * profile to be managed + * @param locals + * the full list of local productions + * @param handler + * the progress handler responsible for receiving progress + * updates + * @return the list of new valid works found in the ORCID profile + * @throws OrcidClientException + * if the communication with ORCID fails when getting the + * activities summary + * @throws InterruptedException + * if the asynchronous GET process is interrupted + * @throws IllegalArgumentException + * if null arguments + */ + public static List importWorks(ORCIDClient client, List locals, ProgressHandler handler) + throws OrcidClientException, InterruptedException, IllegalArgumentException { + return importBase(new ORCIDWorkHelper(client), locals, Arrays.asList(WorkType.values()), handler); + } + + /** + *

+ * Discovers new valid funding activities in an ORCID profile given a set of + * known local CRIS funding entries. Creates creation notifications for each + * funding group at ORCID (merged into as a single funding entry by the + * {@link ORCIDFundingHelper helper} ) without matching local entries (i.e., + * those without shared {@link ExternalId external identifiers}). To import + * updates for funding activities with shared external identifiers + * {@link #importFundingUpdates(ORCIDClient, List, Collection, ProgressHandler)} + * should be used instead. + *

+ * + *

+ * Currently, these creation notifications simply take the shape of ORCID + * funding activities themselves (representing a merged activity group). The + * group merging selects the meta-data of the preferred activity and the + * external identifiers of the whole group (see + * {@link ORCIDFundingHelper#group(Object)}). The selection of the meta-data + * from a group could be changed without affecting the correction of the + * procedure. + *

+ * + *

+ * Since the put-code attribute is used as a local key of each activity, it + * is null for these creation notifications (and not the put-code of the + * remote ORCID activity that gave origin to it). Since only the external + * identifiers of the local funding entries are used to search for matches, + * the remainder meta-data of the input local activities could be left null. + *

+ * + *

+ * ORCID activities without minimal quality are ignored by this procedure. + * Currently, the quality criteria forces the existence of external + * identifiers, the title, publication year and publication type (see + * {@link ORCIDFundingHelper#testMinimalQuality(ElementSummary)}). Funding + * entries that do not match the criteria can be imported with + * {@link #importInvalid(ORCIDClient, List, ProgressHandler)}. Note that + * currently group merging simply collects the meta-data (other than the + * external identifiers) from the preferred activity, which is used in the + * quality assessment. + *

+ * + *

+ * A set of funding types can be provided to allow the independent + * synchronization of different types of entries. Local and remote + * activities outside the provided types are simply ignored (they are not + * considered invalid). + *

+ * * + * + * @param client + * the ORCID client defining the CRIS Member API and user the + * profile to be managed + * @param locals + * the full list of local funding entries + * @param handler + * the progress handler responsible for receiving progress + * updates + * @param types + * the types of ORCID funding activities that should be + * considered (others are simply ignored) + * @return the list of new valid funding activities found in the ORCID + * profile + * @throws OrcidClientException + * if the communication with ORCID fails when getting the + * activities summary + * @throws InterruptedException + * if the asynchronous GET process is interrupted + * @throws IllegalArgumentException + * if null arguments + */ + public static List importFundings(ORCIDClient client, List locals, Collection types, ProgressHandler handler) + throws OrcidClientException, InterruptedException, IllegalArgumentException { + return importBase(new ORCIDFundingHelper(client), locals, types, handler); + } + + /** + *

+ * Discovers new valid activities in an ORCID profile given a set of known + * local CRIS entries. Creates creation notifications for each activity + * group at ORCID (merged into as a single entry by the {@link ORCIDHelper + * helper} ) without matching local entries (i.e., those without shared + * {@link ExternalId external identifiers}). To import updates for + * activities with shared external identifiers + * {@link #importBase(ORCIDHelper, List, Collection, ProgressHandler)} + * should be used instead. + *

+ * + *

+ * Currently, these creation notifications simply take the shape of ORCID + * activities themselves (representing a merged activity group). The group + * merging selects the meta-data of the preferred activity and the external + * identifiers of the whole group (see + * {@link ORCIDHelper#group(ElementSummary)}). The selection of the + * meta-data from a group could be changed without affecting the correction + * of the procedure. + *

+ * + *

+ * Since the put-code attribute is used as a local key of each activity, it + * is null for these creation notifications (and not the put-code of the + * remote ORCID activity that gave origin to it). Since only the external + * identifiers of the local activities are used to search for matches, the + * remainder meta-data of the input local activities could be left null. + *

+ * + *

+ * ORCID activities without minimal quality are ignored by this procedure. + * Activities that do not match the criteria can be imported with + * {@link #importInvalid(ORCIDClient, List, ProgressHandler)}. Note that + * currently group merging simply collects the meta-data (other than the + * external identifiers) from the preferred activity, which is used in the + * quality assessment. + *

+ * + *

+ * A set of activity types can be provided to allow the independent + * synchronization of different types of entries. Local and remote + * activities outside the provided types are simply ignored (they are not + * considered invalid). + *

+ * + *

+ * This procedure performs a GET call to the API to obtain the summaries and + * an additional GET call for each activity identified as valid. Bulk GET + * requests are performed when supported. The procedure only fails if the + * initial GET fails. Asynchronous workers are used for getting the full + * activities. + *

+ * + * @param helper + * helper that encapsulates the ORCID client defining the CRIS + * Member API and user the profile to be managed + * @param locals + * the full list of local activities + * @param types + * the types of ORCID activities that should be considered + * (others are simply ignored) + * @param handler + * the progress handler responsible for receiving progress + * updates + * @return the list of new valid activities found in the ORCID profile + * @throws OrcidClientException + * if the communication with ORCID fails when getting the + * activities summary + * @throws InterruptedException + * if the asynchronous GET process is interrupted + * @throws IllegalArgumentException + * if null arguments + */ + private static > List importBase( + ORCIDHelper helper, List locals, + Collection types, ProgressHandler handler) + throws OrcidClientException, InterruptedException, IllegalArgumentException { + + if (helper == null || locals == null || handler == null) + throw new IllegalArgumentException("Null arguments."); + + if (types == null) + types = new HashSet(); + + handler.setCurrentStatus("ORCID_SYNC_IMPORT_STARTED"); + + List orcids = helper.getAllTypedSummaries(types); + + Map> toImport = new HashMap>(); + + // filter novel works only + List temp = new ArrayList(); + handler.setCurrentStatus("ORCID_SYNC_IMPORT_ITERATION",orcids.size()); + for (int c = 0; c != orcids.size(); c++) { + S mergedOrcidWork = orcids.get(c); + Map matchingWorks = helper.getSelfExternalIdsDiffS(mergedOrcidWork, locals); + if (matchingWorks.isEmpty() && helper.testMinimalQuality(mergedOrcidWork).isEmpty()) { + temp.add(mergedOrcidWork); + } + handler.step(); + } + + handler.setCurrentStatus("ORCID_SYNC_IMPORT_GETTING",temp.size()); + helper.getFulls(temp, toImport, handler); + + List results = new ArrayList(); + for (PTCRISyncResult r : toImport.values()) + if (r.act != null) + results.add(r.act); + else { + // TODO: r instanceof OrcidClientException + // meaning that the GET of a particular work failed + } + + handler.done(); + return new LinkedList(results); + } + + /** + *

+ * Counts new valid works in an ORCID profile given a set of + * known local CRIS productions, following the criteria of + * {@link #importWorks(ORCIDClient, List, ProgressHandler)} + * but is more efficient, generating less API calls. + *

+ * + * @see #importWorks(ORCIDClient, List, ProgressHandler) + * + * @param client + * the ORCID client defining the CRIS Member API and user the + * profile to be managed + * @param locals + * the full list of local productions + * @param handler + * the progress handler responsible for receiving progress + * updates + * @return the number of new valid works found in the ORCID + * profile + * @throws OrcidClientException + * if the communication with ORCID fails when getting the + * activities summary + * @throws IllegalArgumentException + * if null arguments + */ + public static Integer importWorkCounter(ORCIDClient client, List locals, ProgressHandler handler) + throws OrcidClientException, IllegalArgumentException { + return importCounterBase(new ORCIDWorkHelper(client), locals, Arrays.asList(WorkType.values()), handler); + } + + /** + * @deprecated Replaced by + * {@link #importWorkCounter(ORCIDClient, List, ProgressHandler)} + * + * @param client + * the ORCID client defining the CRIS Member API and user the + * profile to be managed + * @param locals + * the full list of local productions + * @param handler + * the progress handler responsible for receiving progress + * updates + * @return the number of new valid works found in the ORCID profile + * @throws OrcidClientException + * if the communication with ORCID fails when getting the + * activities summary + * @throws IllegalArgumentException + * if null arguments + */ + @Deprecated + public static Integer importCounter(ORCIDClient client, List locals, ProgressHandler handler) + throws OrcidClientException, IllegalArgumentException { + return importWorkCounter(client, locals, handler); + } + + /** + *

+ * Counts new valid funding activities in an ORCID profile given a set of + * known local CRIS funding entries, following the criteria of + * {@link #importFundings(ORCIDClient, List, Collection, ProgressHandler)} + * but is more efficient, generating less API calls. + *

+ * + * @see #importFundings(ORCIDClient, List, Collection, ProgressHandler) + * + * @param client + * the ORCID client defining the CRIS Member API and user the + * profile to be managed + * @param locals + * the full list of local funding entries + * @param types + * the types of ORCID funding entries that should be considered + * (others are simply ignored) + * @param handler + * the progress handler responsible for receiving progress + * updates + * @return the number of new valid funding activities found in the ORCID + * profile + * @throws OrcidClientException + * if the communication with ORCID fails when getting the + * activities summary + * @throws IllegalArgumentException + * if null arguments + */ + public static Integer importFundingCounter(ORCIDClient client, List locals, Collection types, ProgressHandler handler) + throws OrcidClientException, IllegalArgumentException { + return importCounterBase(new ORCIDFundingHelper(client), locals, types, handler); + } + + /** + *

+ * Counts new valid activities in an ORCID profile given a set of known + * local CRIS entries, following the criteria of + * {@link #importBase(ORCIDHelper, List, Collection, ProgressHandler)}. + *

+ * + *

+ * This procedure simply performs a GET call to the API to obtain the + * summaries, since the remainder meta-data is irrelevant, rendering it more + * efficient than + * {@link #importBase(ORCIDHelper, List, Collection, ProgressHandler)}. + *

+ * + * @see #importBase(ORCIDHelper, List, Collection, ProgressHandler) + * + * @param helper + * helper that encapsulates the ORCID client defining the CRIS + * Member API and user the profile to be managed + * @param locals + * the full list of local entries + * @param types + * the types of ORCID activities that should be considered + * (others are simply ignored) + * @param handler + * the progress handler responsible for receiving progress + * updates + * @return the number of new valid activities found in the ORCID profile + * @throws OrcidClientException + * if the communication with ORCID fails when getting the + * activities summary + * @throws IllegalArgumentException + * if null arguments + */ + private static > Integer importCounterBase( + ORCIDHelper helper, List locals, + Collection types, ProgressHandler handler) + throws OrcidClientException, IllegalArgumentException { + + if (helper == null || locals == null || handler == null) + throw new IllegalArgumentException("Null arguments."); + + if (types == null) + types = new HashSet(); + + handler.setCurrentStatus("ORCID_SYNC_IMPORT_COUNTER_STARTED"); + + List orcids = helper.getAllTypedSummaries(types); + + int counter = 0; + + // filter novel works only + handler.setCurrentStatus("ORCID_SYNC_IMPORT_COUNTER_ITERATION",orcids.size()); + for (int c = 0; c != orcids.size(); c++) { + S mergedOrcidWork = orcids.get(c); + Map matchingWorks = helper.getSelfExternalIdsDiffS(mergedOrcidWork, locals); + if (matchingWorks.isEmpty() && helper.testMinimalQuality(mergedOrcidWork).isEmpty()) { + counter++; + } + handler.step(); + } + + handler.done(); + return counter; + } + + /** + *

+ * Discovers new invalid works (that do not pass the quality criteria, see + * {@link ORCIDWorkHelper#testMinimalQuality(ElementSummary)}) in an ORCID + * profile given a set of known local CRIS entries, as well as the causes + * for invalidity (defined at {@link ORCIDWorkHelper}). Other than the + * criteria, the behavior is similar to that of + * {@link #importWorks(ORCIDClient, List, ProgressHandler)}. + * Note that currently group merging simply collects the meta-data (other + * than the external identifiers) from the preferred activity, which is used + * in the quality assessment. + *

+ * + * @see #importWorks(ORCIDClient, List, ProgressHandler) + * + * @param client + * the ORCID client defining the CRIS Member API and user the + * profile to be managed + * @param locals + * the full list of local works + * @param handler + * the progress handler responsible for receiving progress + * updates + * @return the list of new invalid works found in the ORCID profile + * @throws OrcidClientException + * if the communication with ORCID fails when getting the + * activities summary + * @throws InterruptedException + * if the asynchronous GET process is interrupted + * @throws IllegalArgumentException + * if null arguments + */ + public static Map> importInvalidWorks(ORCIDClient client, + List locals, ProgressHandler handler) + throws OrcidClientException, InterruptedException, IllegalArgumentException { + return importInvalidBase(new ORCIDWorkHelper(client), locals, + Arrays.asList(WorkType.values()), handler); + } + + /** + * @deprecated Replaced by + * {@link #importInvalidWorks(ORCIDClient, List, ProgressHandler)} + * + * @param client + * the ORCID client defining the CRIS Member API and user the + * profile to be managed + * @param locals + * the full list of local works + * @param handler + * the progress handler responsible for receiving progress + * updates + * @return the list of new invalid works found in the ORCID profile + * @throws OrcidClientException + * if the communication with ORCID fails when getting the + * activities summary + * @throws InterruptedException + * if the asynchronous GET process is interrupted + * @throws IllegalArgumentException + * if null arguments + */ + @Deprecated + public static Map> importInvalid(ORCIDClient client, + List locals, ProgressHandler handler) + throws OrcidClientException, InterruptedException, IllegalArgumentException { + return importInvalidWorks(client, locals, handler); + } + + /** + *

+ * Discovers new invalid funding activities (that do not pass the quality + * criteria, see + * {@link ORCIDFundingHelper#testMinimalQuality(ElementSummary)}) in an + * ORCID profile given a set of known local CRIS entries, as well as the + * causes for invalidity (defined at {@link ORCIDFundingHelper}). Other than + * the criteria, the behavior is similar to that of + * {@link #importFundings(ORCIDClient, List, Collection, ProgressHandler)}. + * Note that currently group merging simply collects the meta-data (other + * than the external identifiers) from the preferred activity, which is used + * in the quality assessment. + *

+ * + * @see #importFundings(ORCIDClient, List, Collection, ProgressHandler) + * + * @param client + * the ORCID client defining the CRIS Member API and user the + * profile to be managed + * @param locals + * the full list of local funding activities + * @param types + * the types of ORCID funding activities that should be + * considered (others are simply ignored) + * @param handler + * the progress handler responsible for receiving progress + * updates + * @return the list of new invalid funding activities found in the ORCID + * profile + * @throws OrcidClientException + * if the communication with ORCID fails when getting the + * activities summary + * @throws InterruptedException + * if the asynchronous GET process is interrupted + * @throws IllegalArgumentException + * if null arguments + */ + public static Map> importInvalidFundings( + ORCIDClient client, List locals, + Collection types, ProgressHandler handler) + throws OrcidClientException, InterruptedException, IllegalArgumentException { + return importInvalidBase(new ORCIDFundingHelper(client), locals, types, + handler); + } + + /** + *

+ * Discovers new invalid activities (that do not pass the quality criteria, + * see {@link ORCIDHelper#testMinimalQuality(ElementSummary)}) in an ORCID + * profile given a set of known local CRIS entries, as well as the causes + * for invalidity (defined at {@link ORCIDHelper}). Other than the criteria, + * the behavior is similar to that of + * {@link #importBase(ORCIDHelper, List, Collection, ProgressHandler)}. Note + * that currently group merging simply collects the meta-data (other than + * the external identifiers) from the preferred activity, which is used in + * the quality assessment. + *

+ * + *

+ * This procedure performs a GET call to the API to obtain the summaries and + * an additional GET call for each activity identified as invalid. Bulk GET + * requests are performed when supported. The procedure only fails if the + * initial GET fails. Asynchronous workers are used for getting the full + * activities. + *

+ * + * @see #importBase(ORCIDHelper, List, Collection, ProgressHandler) + * + * @param helper + * helper that encapsulates the ORCID client defining the CRIS + * Member API and user the profile to be managed + * @param locals + * the full list of local activities + * @param types + * the types of ORCID activities that should be considered + * (others are simply ignored) + * @param handler + * the progress handler responsible for receiving progress + * updates + * @return the list of new invalid activities found in the ORCID profile + * @throws OrcidClientException + * if the communication with ORCID fails when getting the + * activities summary + * @throws InterruptedException + * if the asynchronous GET process is interrupted + * @throws IllegalArgumentException + * if null arguments + */ + private static > Map> importInvalidBase( + ORCIDHelper helper, List locals, + Collection types, ProgressHandler handler) + throws OrcidClientException, InterruptedException, IllegalArgumentException { + + if (helper == null || locals == null || handler == null) + throw new IllegalArgumentException("Null arguments."); + + if (types == null) + types = new HashSet(); + + handler.setCurrentStatus("ORCID_SYNC_IMPORT_INVALID_STARTED"); + + List orcids = helper.getAllTypedSummaries(types); + + Map> invalidsToImport = new HashMap>(); + Map> toImport = new HashMap>(); + + // filter invalid works only + List temp = new ArrayList(); + handler.setCurrentStatus("ORCID_SYNC_IMPORT_INVALID_ITERATION",orcids.size()); + for (int c = 0; c != orcids.size(); c++) { + S mergedOrcidWork = orcids.get(c); + Map matchingWorks = helper.getSelfExternalIdsDiffS(mergedOrcidWork, locals); + Set invalids = helper.testMinimalQuality(mergedOrcidWork); + invalidsToImport.put(mergedOrcidWork.getPutCode(), invalids); + if (matchingWorks.isEmpty() && !invalids.isEmpty()) { + temp.add(mergedOrcidWork); + } + handler.step(); + } + + handler.setCurrentStatus("ORCID_SYNC_IMPORT_INVALID_GETTING",temp.size()); + helper.getFulls(temp, toImport, handler); + + Map> results = new HashMap>(); + for (BigInteger i : toImport.keySet()) + if (toImport.get(i).act != null) + results.put(toImport.get(i).act, invalidsToImport.get(i)); + else { + // TODO: r instanceof OrcidClientException + // meaning that the GET of a particular work failed + } + + handler.done(); + return results; + } + + /** + *

+ * Discovers updates to existing local CRIS productions in an ORCID + * profile. For each work group at ORCID (merged into as a + * single activity by the {@link ORCIDWorkHelper helper}), finds matching + * local entries (i.e., those with shared {@link ExternalId external + * identifiers}) and creates update notifications if not already up to date. + * To import works without shared external identifiers, + * {@link #importWorks(ORCIDClient, List, ProgressHandler)} + * should be used instead. + *

+ * + *

+ * These update notifications simply take the shape of ORCID activities + * themselves (representing a matching activity group). These works contain + * only the meta-data that needs to be updated locally. Currently, only the + * introduction of newly found external identifiers is considered (i.e., + * those that were already present in the local entry that is being updated + * are removed from the returned update). Thus, the remainder fields are + * returned null. Since only external identifiers are considered the quality + * criteria is not enforced on the remote ORCID activities. + *

+ * + *

+ * The local entries are tested to be up-to-date by simply checking whether + * they contain every external identifiers in the ORCID group (see + * {@link ORCIDHelper#hasNewSelfIDs(ElementSummary, ElementSummary)}. Thus + * the remainder meta-data of the local entries can be currently left null. + *

+ * + *

+ * The put-code attribute is used as a local key of each CRIS production. + * This means that the returned activities representing the updates have the + * put-code of the local entry that is to be updated (and not the put-code + * of the ORCID activity that gave origin to it). + *

+ * + * @param client + * the ORCID client defining the CRIS Member API and user the + * profile to be managed + * @param locals + * the full list of local productions + * @param handler + * the progress handler responsible for receiving progress + * updates + * @return the list of work updates found in the ORCID profile, pointing + * to the respective local activity + * @throws OrcidClientException + * if the communication with ORCID fails when getting the + * activities summary + * @throws IllegalArgumentException + * if null arguments + */ + public static List importWorkUpdates(ORCIDClient client, List locals, ProgressHandler handler) + throws OrcidClientException, IllegalArgumentException { + return importUpdatesBase(new ORCIDWorkHelper(client), locals, Arrays.asList(WorkType.values()), handler); + } + + /** + * @deprecated Replaced by {@link #importWorkUpdates(ORCIDClient, List, ProgressHandler)} + * + * @param client + * the ORCID client defining the CRIS Member API and user the + * profile to be managed + * @param locals + * the full list of local productions + * @param handler + * the progress handler responsible for receiving progress + * updates + * @return the list of work updates found in the ORCID profile, pointing + * to the respective local activity + * @throws OrcidClientException + * if the communication with ORCID fails when getting the + * activities summary + * @throws IllegalArgumentException + * if null arguments + */ + @Deprecated + public static List importUpdates(ORCIDClient client, List locals, ProgressHandler handler) + throws OrcidClientException, IllegalArgumentException { + return importWorkUpdates(client, locals, handler); + } + + /** + *

+ * Discovers updates to existing local CRIS funding activities in an ORCID + * profile. For each funding activity group at ORCID (merged into as a + * single activity by the {@link ORCIDFundingHelper helper}), finds matching + * local entries (i.e., those with shared {@link ExternalId external + * identifiers}) and creates update notifications if not already up to date. + * To import funding activities without shared external identifiers, + * {@link #importFundings(ORCIDClient, List, Collection, ProgressHandler)} + * should be used instead. + *

+ * + *

+ * These update notifications simply take the shape of ORCID activities + * themselves (representing a matching activity group). These works contain + * only the meta-data that needs to be updated locally. Currently, only the + * introduction of newly found external identifiers is considered (i.e., + * those that were already present in the local entry that is being updated + * are removed from the returned update). Thus, the remainder fields are + * returned null. Since only external identifiers are considered the quality + * criteria is not enforced on the remote ORCID activities. + *

+ * + *

+ * The local entries are tested to be up-to-date by simply checking whether + * they contain every external identifiers in the ORCID group (see + * {@link ORCIDHelper#hasNewSelfIDs(ElementSummary, ElementSummary)}. Thus + * the remainder meta-data of the local entries can be currently left null. + *

+ * + *

+ * A set of activity types can be provided to allow the independent + * synchronization of different types of entries. Local and remote + * activities outside the provided types are simply ignored (they are not + * considered invalid). + *

+ * + *

+ * The put-code attribute is used as a local key of each CRIS funding entry. + * This means that the returned activities representing the updates have the + * put-code of the local entry that is to be updated (and not the put-code + * of the ORCID activity that gave origin to it). + *

+ * + * @param client + * the ORCID client defining the CRIS Member API and user the + * profile to be managed + * @param locals + * the full list of local funding activities + * @param types + * the types of ORCID funding activities that should be + * considered (others are simply ignored) + * @param handler + * the progress handler responsible for receiving progress + * updates + * @return the list of funding updates found in the ORCID profile, pointing + * to the respective local activity + * @throws OrcidClientException + * if the communication with ORCID fails when getting the + * activities summary + * @throws IllegalArgumentException + * if null arguments + */ + public static List importFundingUpdates(ORCIDClient client, List locals, Collection types, ProgressHandler handler) + throws OrcidClientException, IllegalArgumentException { + return importUpdatesBase(new ORCIDFundingHelper(client), locals, types, handler); + } + + /** + *

+ * Discovers updates to existing local CRIS activities in an ORCID profile. + * For each activity group at ORCID (merged into as a single activity by the + * {@link ORCIDHelper helper}), finds matching local entries (i.e., those + * with shared {@link ExternalId external identifiers}) and creates update + * notifications if not already up to date. To import activities without + * shared external identifiers, + * {@link #importBase(ORCIDHelper, List, Collection, ProgressHandler)} + * should be used instead. + *

+ * + *

+ * These update notifications simply take the shape of ORCID activities + * themselves (representing a matching activity group). These works contain + * only the meta-data that needs to be updated locally, and the remainder + * fields are returned null. + *

+ * + *

+ * The local entries are tested to be up-to-date by simply checking whether + * they contain every external identifiers in the ORCID group (see + * {@link ORCIDHelper#hasNewSelfIDs(ElementSummary, ElementSummary)}. Thus + * the remainder meta-data of the local entries can be currently left null. + *

+ * + *

+ * A set of activity types can be provided to allow the independent + * synchronization of different types of entries. Local and remote + * activities outside the provided types are simply ignored (they are not + * considered invalid). + *

+ * + *

+ * The put-code attribute is used as a local key of each CRIS entry. This + * means that the returned activities representing the updates have the + * put-code of the local entry that is to be updated (and not the put-code + * of the ORCID activity that gave origin to it). + *

+ * + *

+ * This procedure simply performs a GET call to the API to obtain the + * summaries, since the remainder meta-data is irrelevant. + *

+ * + * @param helper + * helper that encapsulates the ORCID client defining the CRIS + * Member API and user the profile to be managed + * @param locals + * the full list of local activities + * @param types + * the types of ORCID activities that should be considered + * (others are simply ignored) + * @param handler + * the progress handler responsible for receiving progress + * updates + * @return the list of updates found in the ORCID profile, pointing to the + * respective local activity + * @throws OrcidClientException + * if the communication with ORCID fails when getting the + * activities summary + * @throws IllegalArgumentException + * if null arguments + */ + private static > List importUpdatesBase( + ORCIDHelper helper, List locals, + Collection types, ProgressHandler handler) + throws OrcidClientException, IllegalArgumentException { + + if (helper == null || locals == null || handler == null) + throw new IllegalArgumentException("Null arguments."); + + if (types == null) + types = new HashSet(); + + handler.setCurrentStatus("ORCID_SYNC_IMPORT_UPDATES_STARTED"); + + List orcids = helper.getAllTypedSummaries(types); + + List toUpdate = new LinkedList(); + + // filter already known works only + handler.setCurrentStatus("ORCID_SYNC_IMPORT_UPDATES_ITERATION",orcids.size()); + for (int c = 0; c != orcids.size(); c++) { + + S orcid = orcids.get(c); + Map matchingLocals = helper.getSelfExternalIdsDiffS(orcid, locals); + if (!matchingLocals.isEmpty()) { + for (E mathingLocal : matchingLocals.keySet()) { + if (!helper.hasNewSelfIDs(mathingLocal, orcid)) { + toUpdate.add(helper.createUpdate(mathingLocal, matchingLocals.get(mathingLocal))); + } + } + } + handler.step(); + } + + handler.done(); + return toUpdate; + } +} diff --git a/src/main/java/pt/ptcris/PTCRISyncResult.java b/src/main/java/pt/ptcris/PTCRISyncResult.java new file mode 100644 index 0000000..3819f13 --- /dev/null +++ b/src/main/java/pt/ptcris/PTCRISyncResult.java @@ -0,0 +1,189 @@ +/* + * Copyright (c) 2016, 2017 PTCRIS - FCT|FCCN and others. + * Licensed under MIT License + * http://ptcris.pt + * + * This copyright and license information (including a link to the full license) + * shall be included in its entirety in all copies or substantial portion of + * the software. + */ +package pt.ptcris; + +import java.math.BigInteger; + +import org.um.dsi.gavea.orcid.client.exception.OrcidClientException; +import org.um.dsi.gavea.orcid.model.common.ElementSummary; + +import pt.ptcris.exceptions.InvalidActivityException; + +/** + * A class that encapsulates the result of the synchronization procedures for a + * particular activity. Currently only the + * {@link PTCRISync#export(ORCIDClient, java.util.List, pt.ptcris.handlers.ProgressHandler) + * export} methods report these results. + */ +public final class PTCRISyncResult { + + public static final int GETOK = -1; + public static final int ADDOK = -5; + public static final int UPDATEOK = -10; + public static final int DELETEOK = -15; + public static final int UPTODATE = -20; + public static final int INVALID = -30; + public static final int CLIENTERROR = -40; + + /** + * Creates a successful "get" message with the assigned put-code. + * + * @param the activity type + * @param putcode the put-code of the get request + * @param element the retrieved activity + * @return an OK get message + */ + public static PTCRISyncResult ok_get(BigInteger putcode, E element) { + return new PTCRISyncResult(GETOK, element); + } + + /** + * Creates a successful "add" message with the assigned put-code. + * + * @param the activity type + * @param putcode the put-code of the newly added activity + * @return an OK add message + */ + public static PTCRISyncResult ok_add(BigInteger putcode) { + return new PTCRISyncResult(ADDOK, putcode); + } + + /** + * Creates a successful "update" message. + * + * @param the activity type + * @return an OK update message + */ + public static PTCRISyncResult ok_upd() { + return new PTCRISyncResult(UPDATEOK); + } + + /** + * Creates a successful "delete" message. + * + * @param the activity type + * @return an OK delete message + */ + public static PTCRISyncResult ok_del() { + return new PTCRISyncResult(DELETEOK); + } + + /** + * Creates an "already up-to-date" message. + * + * @param the activity type + * @return an already up to date message + */ + public static PTCRISyncResult uptodate() { + return new PTCRISyncResult(UPTODATE); + } + + /** + * Creates message reporting a failure at the ORCID API level. + * + * @param the activity type + * @param exception + * the ORCID client exception + * @return the resulting message + */ + public static PTCRISyncResult fail(OrcidClientException exception) { + return new PTCRISyncResult(CLIENTERROR, exception); + } + + /** + * Creates message reporting an invalid activity. + * + * @param the activity type + * @param exception + * the reasons for invalidity + * @return the resulting message + */ + public static PTCRISyncResult invalid(InvalidActivityException exception) { + return new PTCRISyncResult(INVALID, exception); + } + + public final int code; + public final Exception exception; + public final BigInteger putcode; + public final E act; + + /** + * Constructs a PTCRISync result with a result code, possible exception, + * possible assigned put-code and possible read activity. + * + * @param code + * the code that defines the outcome + * @param exception + * the exception containing additional information if + * unsuccessful (may be null) + * @param putcode + * the assigned put-code, if successful add (may be null) + * @param act + * a read activity (may be null) + */ + private PTCRISyncResult(int code, Exception exception, BigInteger putcode, + E act) { + this.code = code; + this.exception = exception; + this.putcode = putcode; + this.act = act; + } + + /** + * Constructs a PTCRISync result with a result code and an assigned + * put-code, used for additions. + * + * @param code + * the code that defines the outcome + * @param putcode + * the assigned put-code, if successful add + */ + private PTCRISyncResult(int code, BigInteger putcode) { + this(code, null, putcode, null); + } + + /** + * Constructs a PTCRISync result with a result code and an exception, used + * for unsuccessful results. + * + * @param code + * the code that defines the outcome + * @param exception + * the exception containing additional information if + * unsuccessful + */ + private PTCRISyncResult(int code, Exception exception) { + this(code, exception, null, null); + } + + /** + * Constructs a PTCRISync result with a success code. + * + * @param code + * the code that defines the outcome + */ + private PTCRISyncResult(int code) { + this(code, null, null, null); + } + + /** + * Constructs a PTCRISync result with a result code and an activity,, used + * for readings. + * + * @param code + * the code that defines the outcome + * @param activity + * the returned activity, if successfull read + */ + private PTCRISyncResult(int code, E act) { + this(code, null, null, act); + } + +} diff --git a/src/main/java/pt/ptcris/TempORCIDClient.java b/src/main/java/pt/ptcris/TempORCIDClient.java new file mode 100644 index 0000000..bf6fe57 --- /dev/null +++ b/src/main/java/pt/ptcris/TempORCIDClient.java @@ -0,0 +1,35 @@ +package pt.ptcris; + +import javax.ws.rs.core.Response; + +import org.um.dsi.gavea.orcid.client.OrcidAccessToken; +import org.um.dsi.gavea.orcid.client.OrcidOAuthClient; +import org.um.dsi.gavea.orcid.client.exception.OrcidClientException; +import org.um.dsi.gavea.orcid.model.activities.Fundings; + +/** + * @deprecated temporary class to be deleted once readFundingsSummary is added to the + * ORCID client. + */ +public class TempORCIDClient extends OrcidOAuthClient { + + private static final long serialVersionUID = 1L; + + public TempORCIDClient(String loginUri, String apiUri, String clientId, + String clientSecret, String redirectUri, boolean debugMode) { + super(loginUri, apiUri, clientId, clientSecret, redirectUri, debugMode); + } + + public Fundings readFundingsSummary(final OrcidAccessToken token) + throws OrcidClientException { + Response response = null; + try { + response = get("/fundings", token, null); + Fundings x = response.readEntity(Fundings.class); + return x; + } finally { + if (response != null) + response.close(); + } + } +} diff --git a/src/main/java/pt/ptcris/exceptions/InvalidActivityException.java b/src/main/java/pt/ptcris/exceptions/InvalidActivityException.java new file mode 100644 index 0000000..6a67aee --- /dev/null +++ b/src/main/java/pt/ptcris/exceptions/InvalidActivityException.java @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2016, 2017 PTCRIS - FCT|FCCN and others. + * Licensed under MIT License + * http://ptcris.pt + * + * This copyright and license information (including a link to the full license) + * shall be included in its entirety in all copies or substantial portion of + * the software. + */ +package pt.ptcris.exceptions; + +import java.util.Set; + +public class InvalidActivityException extends Exception { + private static final long serialVersionUID = 1L; + private static Set invalidResultTypes; + + public InvalidActivityException() { + // TODO Auto-generated constructor stub + } + + public InvalidActivityException(String message) { + super(message); + // TODO Auto-generated constructor stub + } + + public InvalidActivityException(Throwable cause) { + super(cause); + // TODO Auto-generated constructor stub + } + + public InvalidActivityException(String message, Throwable cause) { + super(message, cause); + // TODO Auto-generated constructor stub + } + + public InvalidActivityException(Set res) { + // TODO Auto-generated constructor stub + super(res.toString()); + invalidResultTypes = res; + } + + public Set getInvalidTypes() { + // TODO Auto-generated method stub + return invalidResultTypes; + } +} diff --git a/src/main/java/pt/ptcris/grouper/ActivityComparator.java b/src/main/java/pt/ptcris/grouper/ActivityComparator.java new file mode 100644 index 0000000..ed95167 --- /dev/null +++ b/src/main/java/pt/ptcris/grouper/ActivityComparator.java @@ -0,0 +1,74 @@ +/* + * Copyright (c) 2016, 2017 PTCRIS - FCT|FCCN and others. + * Licensed under MIT License + * http://ptcris.pt + * + * This copyright and license information (including a link to the full license) + * shall be included in its entirety in all copies or substantial portion of + * the software. + */ +package pt.ptcris.grouper; + +/** + * An activity comparator used by the grouper to creates groups of matching + * activities. Concrete implementations should be provided by the users through + * a {@link #compare(Object, Object)} that calculates a similarity + * metric between to activities, and a {@link #threshold()}. + * + * @param + * the type of activities being compared + */ +public abstract class ActivityComparator { + + /** + * A (non-inclusive) threshold on the similarity metric that defines + * matching activities. + * + * @return the threshold value + */ + abstract public int threshold(); + + /** + * Calculates a similarity metric between two activities. + * + * @param act1 + * one activity + * @param act2 + * other activity + * @return the similarity metric between the activities + */ + abstract public float compare(A act1, A act2); + + /** + * Tests whether two activities match, given the + * {@link #compare(Object, Object)} method and the + * {@link #threshold()}. + * + * @param act1 + * one activity + * @param act2 + * other activity + * @return whether the activities match + */ + private final boolean matches(A act1, A act2) { + return compare(act1, act2) > threshold(); + } + + /** + * Tests whether an activity belongs to a group, according to the + * {@link #compare(Object, Object)} criterion. + * + * @param act + * the activity to be tested for membership + * @param group + * the activity group + * @return whether the activity belongs to the group + */ + final boolean belongs(A act, ActivityGroup group) { + for (A act1 : group.getActivities()) + if (matches(act1, act)) + return true; + return false; + } + +} diff --git a/src/main/java/pt/ptcris/grouper/ActivityGroup.java b/src/main/java/pt/ptcris/grouper/ActivityGroup.java new file mode 100644 index 0000000..213b4ae --- /dev/null +++ b/src/main/java/pt/ptcris/grouper/ActivityGroup.java @@ -0,0 +1,69 @@ +/* + * Copyright (c) 2016, 2017 PTCRIS - FCT|FCCN and others. + * Licensed under MIT License + * http://ptcris.pt + * + * This copyright and license information (including a link to the full license) + * shall be included in its entirety in all copies or substantial portion of + * the software. + */ +package pt.ptcris.grouper; + +import java.util.HashSet; +import java.util.Set; + +/** + * Represents groups of matched activities. Currently, simply encapsulates a set of + * activities, there is no additional structure. + * + * @param + * the type of activities being grouped + */ +public class ActivityGroup { + private Set activities; + + /** + * Create a new singleton group. + * + * @param elem + * the singleton activity + */ + ActivityGroup(A elem) { + activities = new HashSet(); + activities.add(elem); + } + + /** + * Retrieves the activities belonging to the group. + * + * @return the activities of the group + */ + Set getActivities() { + if (activities == null) + activities = new HashSet(); + return activities; + } + + /** + * Adds a new (unique) activity to the group. Duplicates are ignored. + * + * @param activity + * the activity to be added + */ + void add(A activity) { + activities.add(activity); + } + + /** + * Merges the current group with another. Duplicates are ignored. + * + * @param group + * the group to be merged + */ + void merge(ActivityGroup group) { + for (A activity : group.getActivities()) { + activities.add(activity); + } + } + +} \ No newline at end of file diff --git a/src/main/java/pt/ptcris/grouper/GroupGenerator.java b/src/main/java/pt/ptcris/grouper/GroupGenerator.java new file mode 100644 index 0000000..870878a --- /dev/null +++ b/src/main/java/pt/ptcris/grouper/GroupGenerator.java @@ -0,0 +1,82 @@ +/* + * Copyright (c) 2016, 2017 PTCRIS - FCT|FCCN and others. + * Licensed under MIT License + * http://ptcris.pt + * + * This copyright and license information (including a link to the full license) + * shall be included in its entirety in all copies or substantial portion of + * the software. + */ +package pt.ptcris.grouper; + +import java.util.ArrayList; +import java.util.List; + +/** + * A generator that, provided the concrete {@link ActivityComparator activity + * comparator} iteratively groups works that are below the threshold as + * {@link ActivityGroup activity groups}. + * + * @param + * the type of activities being grouped + */ +public class GroupGenerator { + + private final List> groups = new ArrayList>(); + + private final ActivityComparator comparator; + + /** + * Creates a new activity group generator, provided a comparator that will + * determine whether activities match. + * + * @param comparator + * the activity comparator + */ + public GroupGenerator(ActivityComparator comparator) { + this.comparator = comparator; + } + + /** + * Adds an activity with the already existing groups. If the activity + * matches more than one group, then those groups are merged. If it matches + * none, a new group is created. + * + * @param act the activity to be added to the groups + */ + public void group(E act) { + List> belongsTo = new ArrayList>(); + + // determine to which existing groups the activity belongs to + for (ActivityGroup g : groups) { + if (comparator.belongs(act, g)) + belongsTo.add(g); + } + + // if it doesn't belong to any, create a new group + if (belongsTo.isEmpty()) { + ActivityGroup newGroup = new ActivityGroup(act); + groups.add(newGroup); + // otherwise merge all those groups + } else { + ActivityGroup base = belongsTo.get(0); + base.add(act); + + if (belongsTo.size() > 1) { + for (int i = 1; i < belongsTo.size(); i++) { + base.merge(belongsTo.get(i)); + groups.remove(belongsTo.get(i)); + } + } + } + } + + /** + * The activity groups generated so far. The order is currently meaningless. + * + * @return the groups + */ + public List> getGroups() { + return groups; + } +} diff --git a/src/main/java/pt/ptcris/handlers/ProgressHandler.java b/src/main/java/pt/ptcris/handlers/ProgressHandler.java new file mode 100644 index 0000000..38facd0 --- /dev/null +++ b/src/main/java/pt/ptcris/handlers/ProgressHandler.java @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2016, 2017 PTCRIS - FCT|FCCN and others. + * Licensed under MIT License + * http://ptcris.pt + * + * This copyright and license information (including a link to the full license) + * shall be included in its entirety in all copies or substantial portion of + * the software. + */ +package pt.ptcris.handlers; + +/** + * An interface for reporting the progress of the synchronization procedures and + * the comprising tasks. + */ +public interface ProgressHandler { + + /** + * Used to set the progress of a task, by using percentual values (between 0 + * and 100). It can be used to start a task, where progress = 0 + * + * @param progress + * the progress of the current task + */ + @Deprecated + public void setProgress(int progress); + + /** + * Used to set the text of the current task + * + * @param message + * the message to be sent to the progress handler + */ + public void setCurrentStatus(String message); + + public void setCurrentStatus(String message, int size); + + /** + * Used to send an error message to the progress handler + * + * @param message + * the error message to be sent to the progress handler + */ + public void sendError(String message); + + /** + * Used to set the current task as finalized + */ + public void done(); + + public void step(); + + public void step(int step); + +} diff --git a/src/main/java/pt/ptcris/utils/ExternalIdsDiff.java b/src/main/java/pt/ptcris/utils/ExternalIdsDiff.java new file mode 100644 index 0000000..904b78d --- /dev/null +++ b/src/main/java/pt/ptcris/utils/ExternalIdsDiff.java @@ -0,0 +1,97 @@ +/* + * Copyright (c) 2016, 2017 PTCRIS - FCT|FCCN and others. + * Licensed under MIT License + * http://ptcris.pt + * + * This copyright and license information (including a link to the full license) + * shall be included in its entirety in all copies or substantial portion of + * the software. + */ +package pt.ptcris.utils; + +import java.util.HashSet; +import java.util.LinkedList; +import java.util.List; +import java.util.Set; + +import org.um.dsi.gavea.orcid.model.common.ExternalId; +import org.um.dsi.gavea.orcid.model.common.ExternalIds; + +/** + * Calculates and stores the symmetric difference between two sets of + * {@link ExternalId external identifiers}. Useful to detect matching + * activities and potential updates. + */ +public final class ExternalIdsDiff { + + /** + * External identifiers removed from the first set. + */ + public final Set less = new HashSet(); + + /** + * External identifiers preserved in both sets. + */ + public final Set same = new HashSet(); + + /** + * External identifiers inserted in the second set. + */ + public final Set more = new HashSet(); + + /** + * Calculates and stores the symmetric difference between two sets of + * external identifiers. + * + * @param weids1 + * the first set of external identifiers + * @param weids2 + * the second set of external identifiers + */ + public ExternalIdsDiff(ExternalIds weids1, ExternalIds weids2) { + List eids1 = new LinkedList(); + List eids2 = new LinkedList(); + + if (weids1 != null) + for (ExternalId eid : weids1.getExternalId()) + eids1.add(eid); + + if (weids2 != null) + for (ExternalId eid : weids2.getExternalId()) + eids2.add(eid); + + calculateDifference(eids1, eids2); + } + + /** + * Calculates the symmetric difference between two sets of external + * identifiers, i.e., the set of removed, preserved and inserted + * identifiers. The algorithm to detected preserved identifiers is the same + * as the one implemented by the ORCID service to detect overlapping + * identifiers. Only considered duplicate if external identifiers have the + * same relationship and are not "part of". + * + * TODO: optimize + * + * @param eids1 + * a set of UIDs + * @param eids2 + * another set of UIDs + */ + private void calculateDifference(List eids1, List eids2) { + less.addAll(eids1); + more.addAll(eids2); + for (final ExternalId eid2 : eids2) { + for (final ExternalId eid1 : eids1) { + if (eid2.getExternalIdRelationship().equals(eid1.getExternalIdRelationship()) + && eid1.getExternalIdValue().equals(eid2.getExternalIdValue()) + && eid1.getExternalIdType().equals(eid2.getExternalIdType())) { + same.add(eid2); + less.remove(eid1); + more.remove(eid2); + } + } + } + } + +} diff --git a/src/main/java/pt/ptcris/utils/ORCIDAddWorker.java b/src/main/java/pt/ptcris/utils/ORCIDAddWorker.java new file mode 100644 index 0000000..6d54e3a --- /dev/null +++ b/src/main/java/pt/ptcris/utils/ORCIDAddWorker.java @@ -0,0 +1,71 @@ +/* + * Copyright (c) 2016, 2017 PTCRIS - FCT|FCCN and others. + * Licensed under MIT License + * http://ptcris.pt + * + * This copyright and license information (including a link to the full license) + * shall be included in its entirety in all copies or substantial portion of + * the software. + */ +package pt.ptcris.utils; + +import java.math.BigInteger; +import java.util.Map; + +import org.slf4j.Logger; +import org.slf4j.MDC; +import org.um.dsi.gavea.orcid.model.work.Work; + +import pt.ptcris.ORCIDClient; +import pt.ptcris.PTCRISyncResult; +import pt.ptcris.handlers.ProgressHandler; + +/** + * A worker thread that can be used to ADD works from ORCID. + * + * @see ORCIDWorker + */ +@Deprecated +class ORCIDAddWorker extends ORCIDWorker { + + private final Work work; + + /** + * A threaded worker that can be launched in parallel to ADD works with the + * ORCID API. The provided {@link ORCIDClient client} defines the + * communication channel. + * + * @param work + * the work that is to be add + * @param client + * the ORCID communication client + * @param cb + * the callback object to return results + * @param log + * a logger + * @throws NullPointerException + * if the work is null + */ + public ORCIDAddWorker(Work work, ORCIDClient client, Map> cb, Logger log, ProgressHandler handler) { + super(client, cb, log, handler); + if (work == null) + throw new NullPointerException("UPDATE: arguments must not be null."); + this.work = work; + } + + /** + * Adds a work to an ORCID profile. + */ + @Override + public void run() { + _log.debug("[addWork] " + new ORCIDWorkHelper(null).getTitleE(work)); + MDC.setContextMap(mdcCtxMap); + + final PTCRISyncResult res = client.addWork(work); + if (res.putcode == null) + callback(BigInteger.valueOf(0), res); + else + callback(res.putcode, res); + } + +} diff --git a/src/main/java/pt/ptcris/utils/ORCIDDelWorker.java b/src/main/java/pt/ptcris/utils/ORCIDDelWorker.java new file mode 100644 index 0000000..c15bd81 --- /dev/null +++ b/src/main/java/pt/ptcris/utils/ORCIDDelWorker.java @@ -0,0 +1,70 @@ +/* + * Copyright (c) 2016, 2017 PTCRIS - FCT|FCCN and others. + * Licensed under MIT License + * http://ptcris.pt + * + * This copyright and license information (including a link to the full license) + * shall be included in its entirety in all copies or substantial portion of + * the software. + */ +package pt.ptcris.utils; + +import java.math.BigInteger; +import java.util.Map; + +import org.slf4j.Logger; +import org.slf4j.MDC; +import org.um.dsi.gavea.orcid.model.work.Work; + +import pt.ptcris.ORCIDClient; +import pt.ptcris.PTCRISyncResult; +import pt.ptcris.handlers.ProgressHandler; + +/** + * A worker thread that can be used to DELETE works from ORCID. + * + * @see ORCIDWorker + */ +@Deprecated +class ORCIDDelWorker extends ORCIDWorker { + + private final BigInteger putcode; + + /** + * A threaded worker that can be launched in parallel to DELETE works with + * the ORCID API. The provided {@link ORCIDClient client} defines the + * communication channel. + * + * @param putcode + * the put-code of the work that is to be deleted + * @param client + * the ORCID communication client + * @param cb + * the callback object to return results + * @param log + * a logger + * @throws NullPointerException + * if the put-code is null + */ + public ORCIDDelWorker(BigInteger putcode, ORCIDClient client, Map> cb, Logger log, ProgressHandler handler) + throws NullPointerException { + super(client, cb, log, handler); + if (putcode == null) + throw new NullPointerException("DELETE: arguments must not be null."); + this.putcode = putcode; + } + + /** + * Removes a work from an ORCID profile. + */ + @Override + public void run() { + _log.debug("[deleteWork] " + putcode); + MDC.setContextMap(mdcCtxMap); + + PTCRISyncResult res = client.deleteWork(putcode); + + callback(putcode, res); + } + +} diff --git a/src/main/java/pt/ptcris/utils/ORCIDFundingHelper.java b/src/main/java/pt/ptcris/utils/ORCIDFundingHelper.java new file mode 100644 index 0000000..c3aa086 --- /dev/null +++ b/src/main/java/pt/ptcris/utils/ORCIDFundingHelper.java @@ -0,0 +1,377 @@ +/* + * Copyright (c) 2016, 2017 PTCRIS - FCT|FCCN and others. + * Licensed under MIT License + * http://ptcris.pt + * + * This copyright and license information (including a link to the full license) + * shall be included in its entirety in all copies or substantial portion of + * the software. + */ +package pt.ptcris.utils; +import java.math.BigInteger; +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import org.um.dsi.gavea.orcid.client.exception.OrcidClientException; +import org.um.dsi.gavea.orcid.model.activities.FundingGroup; +import org.um.dsi.gavea.orcid.model.common.ExternalId; +import org.um.dsi.gavea.orcid.model.common.ExternalIds; +import org.um.dsi.gavea.orcid.model.funding.Funding; +import org.um.dsi.gavea.orcid.model.funding.FundingSummary; +import org.um.dsi.gavea.orcid.model.funding.FundingType; + +import pt.ptcris.ORCIDClient; +import pt.ptcris.PTCRISyncResult; +import pt.ptcris.handlers.ProgressHandler; + +/** + * An helper to simplify the use of the low-level ORCID + * {@link pt.ptcris.ORCIDClient client}. + * + * Provides support for asynchronous communication with ORCID + * although it is only active for GET requests due to resource + * limitations. + */ +public final class ORCIDFundingHelper extends ORCIDHelper { + + /** + * Initializes the helper with a given ORCID client. + * + * @param orcidClient + * the ORCID client + */ + public ORCIDFundingHelper(ORCIDClient orcidClient) { + super(orcidClient,0,0); + } + + /* + * Client methods instantiated for ORCID funding activities. + */ + + /** {@inheritDoc} */ + @Override + protected List getSummariesClient() throws OrcidClientException { + assert client != null; + _log.debug("[getFundingSummaries]"+client.getUserId()); + return client.getFundingsSummary().getGroup(); + } + + /** {@inheritDoc} */ + @Override + protected PTCRISyncResult readClient(FundingSummary summary) { + assert client != null; + assert summary != null; + assert summary.getPutCode() != null; + _log.debug("[getFullFunding] "+summary.getPutCode()); + return client.getFunding(summary); + } + + /** {@inheritDoc} */ + @Override + protected Map> readClient( + List fundings) { + throw new UnsupportedOperationException("No support for bulk reading fundings."); + } + + /** {@inheritDoc} */ + @Override + protected ORCIDWorker readWorker(FundingSummary summary, Map> cb, ProgressHandler handler) { + assert client != null; + assert summary != null; + return new ORCIDGetFundingWorker(summary, client, cb, _log, handler); + } + + /** {@inheritDoc} */ + @Override + protected ORCIDWorker readWorker(List summaries, + Map> cb, ProgressHandler handler) { + throw new UnsupportedOperationException("No support for bulk reading fundings."); + } + + /** {@inheritDoc} */ + @Override + protected PTCRISyncResult addClient(Funding funding) { + assert client != null; + assert funding != null; + _log.debug("[addFunding] "+funding.getTitle()); + return client.addFunding(funding); + } + + /** {@inheritDoc} */ + @Override + protected List> addClient(List fundings) { + throw new UnsupportedOperationException("No support for bulk reading fundings."); + } + + /** {@inheritDoc} */ + @Override + protected PTCRISyncResult updateClient(BigInteger remotePutcode, Funding funding) { + assert client != null; + assert remotePutcode != null; + assert funding != null; + _log.debug("[updateFunding] "+remotePutcode); + return client.updateFunding(remotePutcode, funding); + } + + /** {@inheritDoc} */ + @Override + protected PTCRISyncResult deleteClient(BigInteger remotePutcode) { + assert client != null; + assert remotePutcode != null; + _log.debug("[deleteFunding] "+remotePutcode); + return client.deleteFunding(remotePutcode); + } + + /* + * Static methods instantiated for ORCID funding activities. + */ + + /** {@inheritDoc} */ + @Override + public ExternalIds getNonNullExternalIdsE (Funding funding) { + if (funding.getExternalIds() == null || funding.getExternalIds().getExternalId() == null) { + return new ExternalIds(new ArrayList()); + } else { + return funding.getExternalIds(); + } + } + + /** {@inheritDoc} */ + @Override + public ExternalIds getNonNullExternalIdsS (FundingSummary funding) { + if (funding.getExternalIds() == null || funding.getExternalIds().getExternalId() == null) { + return new ExternalIds(new ArrayList()); + } else { + return funding.getExternalIds(); + } + } + + /** {@inheritDoc} */ + @Override + public void setExternalIdsE(Funding funding, ExternalIds eids) { + assert funding != null; + if (eids == null) eids = new ExternalIds(new ArrayList()); + funding.setExternalIds(eids); + } + + /** {@inheritDoc} */ + @Override + public void setExternalIdsS(FundingSummary summary, ExternalIds eids) { + assert summary != null; + if (eids == null) eids = new ExternalIds(new ArrayList()); + summary.setExternalIds(eids); + } + + /** {@inheritDoc} */ + @Override + protected FundingType getTypeS(FundingSummary funding) { + assert funding != null; + return funding.getType(); + } + + /** + * {@inheritDoc} + * + * Funding types are always grant_number. + */ + protected boolean validExternalIdType(String eid) { + return eid.equals("grant_number"); + } + + /** {@inheritDoc} */ + @Override + protected String getTitleS(FundingSummary summary) { + assert summary != null; + if (summary.getTitle() == null) + return ""; + return summary.getTitle().getTitle(); + } + + /** {@inheritDoc} */ + @Override + protected String getYearS(FundingSummary summary) { + assert summary != null; + if (summary.getStartDate() == null + || summary.getStartDate().getYear() == null) + return null; + return summary.getStartDate().getYear().getValue(); + } + + /** {@inheritDoc} */ + @Override + protected List getGroupSummaries(FundingGroup group) { + assert group != null; + return group.getFundingSummary(); + } + + /** {@inheritDoc} */ + @Override + protected FundingSummary group(FundingGroup group) throws IllegalArgumentException { + assert group != null; + if (group.getFundingSummary() == null || group.getFundingSummary().isEmpty()) + throw new IllegalArgumentException("Can't merge empty group."); + + final FundingSummary preferred = group.getFundingSummary().get(0); + final FundingSummary dummy = cloneS(preferred); + + final List eids = getPartOfExternalIdsS(dummy).getExternalId(); + for (ExternalId id : group.getExternalIds().getExternalId()) { + final ExternalId eid = new ExternalId(); + eid.setExternalIdRelationship(id.getExternalIdRelationship()); + eid.setExternalIdType(id.getExternalIdType().toLowerCase()); + eid.setExternalIdValue(id.getExternalIdValue()); + eids.add(eid); + } + dummy.setExternalIds(new ExternalIds(eids)); + + return dummy; + } + + /** + * {@inheritDoc} + * + * The considered fields are: title, start date (year), funding type and + * part-of external identifiers. All this meta-data is available in funding + * summaries. + * + * TODO: contributors are not being considered as they are not contained in + * the summaries. + */ + @Override + protected boolean isMetaUpToDate(Funding preFunding, FundingSummary posFunding) { + assert preFunding != null; + assert posFunding != null; + + boolean res = true; + res &= identicalExternalIDs( + getPartOfExternalIdsE(preFunding), + getPartOfExternalIdsS(posFunding)); + res &= getTitleE(preFunding).equals(getTitleS(posFunding)); + res &= (getPubYearE(preFunding) == null && getYearS(posFunding) == null) + || (getPubYearE(preFunding) != null && getYearS(posFunding) != null + && getPubYearE(preFunding).equals(getYearS(posFunding))); + res &= (preFunding.getType() == null && posFunding.getType() == null) + || (preFunding.getType() != null && posFunding.getType() != null && preFunding + .getType().equals(posFunding.getType())); + return res; + } + + /** + * {@inheritDoc} + * + * The considered fields are: self external identifiers, title, start date + * (year), funding type and funding organization. The test also checks + * whether the external identifiers overlap with those of the coexisting + * funding entries. All this meta-data is available in funding summaries. + * + * TODO: contributors are not being considered as they are not contained in + * the summaries. + */ + @Override + protected Set testMinimalQuality(FundingSummary funding, Collection others) { + assert funding != null; + if (others == null) others = new ArrayList(); + + final Set res = new HashSet(); + if (getSelfExternalIdsS(funding).getExternalId().isEmpty()) + res.add(INVALID_EXTERNALIDENTIFIERS); + else for (ExternalId eid : getSelfExternalIdsS(funding).getExternalId()) + if (!validExternalIdType(eid.getExternalIdType())) res.add(INVALID_EXTERNALIDENTIFIERS); + if (funding.getTitle() == null) + res.add(INVALID_TITLE); + else if (funding.getTitle().getTitle() == null) + res.add(INVALID_TITLE); + if (funding.getType() == null) + res.add(INVALID_TYPE); + if (funding.getOrganization() == null) + res.add(INVALID_ORGANIZATION); + if (funding.getStartDate() == null) + res.add(INVALID_PUBLICATIONDATE); + else if (funding.getStartDate().getYear() == null) + res.add(INVALID_YEAR); + + Map fundingsDiffs = getSelfExternalIdsDiffS(funding, others); + for (Funding match : fundingsDiffs.keySet()) + if (match.getPutCode() != funding.getPutCode() && !fundingsDiffs.get(match).same.isEmpty()) + res.add(OVERLAPPING_EIDs); + + return res; + } + + /** {@inheritDoc} */ + @Override + public Funding createUpdate(Funding original, ExternalIdsDiff diff) { + assert original != null; + assert diff != null; + + Funding fundingUpdate = cloneE(original); + ExternalIds weids = new ExternalIds(); + List neids = new ArrayList(diff.more); + weids.setExternalId(neids); + ORCIDHelper.setWorkLocalKey(fundingUpdate, ORCIDHelper.getActivityLocalKey(original)); + fundingUpdate.setExternalIds(weids); + fundingUpdate.setTitle(null); + fundingUpdate.setType(null); + fundingUpdate.setStartDate(null); + fundingUpdate.setEndDate(null); + fundingUpdate.setOrganization(null); + return fundingUpdate; + } + + /** {@inheritDoc} */ + @Override + public FundingSummary cloneS(FundingSummary summary) { + assert summary != null; + + final FundingSummary dummy = new FundingSummary(); + copy(summary, dummy); + dummy.setStartDate(summary.getStartDate()); + dummy.setEndDate(summary.getEndDate()); + dummy.setOrganization(summary.getOrganization()); + dummy.setTitle(summary.getTitle()); + dummy.setType(summary.getType()); + dummy.setExternalIds(getNonNullExternalIdsS(summary)); + return dummy; + } + + /** {@inheritDoc} */ + @Override + public Funding cloneE(Funding funding) { + assert funding != null; + + final Funding dummy = new Funding(); + copy(funding, dummy); + dummy.setStartDate(funding.getStartDate()); + dummy.setEndDate(funding.getEndDate()); + dummy.setOrganization(funding.getOrganization()); + dummy.setTitle(funding.getTitle()); + dummy.setType(funding.getType()); + dummy.setAmount(funding.getAmount()); + dummy.setContributors(funding.getContributors()); + dummy.setShortDescription(funding.getShortDescription()); + dummy.setOrganizationDefinedType(funding.getOrganizationDefinedType()); + dummy.setUrl(funding.getUrl()); + dummy.setExternalIds(getNonNullExternalIdsE(funding)); + return dummy; + } + + /** {@inheritDoc} */ + @Override + protected FundingSummary summarize(Funding funding) { + assert funding != null; + + final FundingSummary dummy = new FundingSummary(); + copy(funding, dummy); + dummy.setOrganization(funding.getOrganization()); + dummy.setStartDate(funding.getStartDate()); + dummy.setEndDate(funding.getEndDate()); + dummy.setTitle(funding.getTitle()); + dummy.setType(funding.getType()); + dummy.setExternalIds(getNonNullExternalIdsE(funding)); + return dummy; + } +} diff --git a/src/main/java/pt/ptcris/utils/ORCIDGetBulkWorkWorker.java b/src/main/java/pt/ptcris/utils/ORCIDGetBulkWorkWorker.java new file mode 100644 index 0000000..86de0a1 --- /dev/null +++ b/src/main/java/pt/ptcris/utils/ORCIDGetBulkWorkWorker.java @@ -0,0 +1,80 @@ +/* + * Copyright (c) 2016, 2017 PTCRIS - FCT|FCCN and others. + * Licensed under MIT License + * http://ptcris.pt + * + * This copyright and license information (including a link to the full license) + * shall be included in its entirety in all copies or substantial portion of + * the software. + */ +package pt.ptcris.utils; + +import java.math.BigInteger; +import java.util.List; +import java.util.Map; + +import org.slf4j.Logger; +import org.slf4j.MDC; +import org.um.dsi.gavea.orcid.model.work.Work; +import org.um.dsi.gavea.orcid.model.work.WorkSummary; + +import pt.ptcris.ORCIDClient; +import pt.ptcris.PTCRISyncResult; +import pt.ptcris.handlers.ProgressHandler; + +/** + * A worker thread that can be used to read bulk works from ORCID. + * + * @see ORCIDWorker + */ +final class ORCIDGetBulkWorkWorker extends ORCIDWorker { + + private final List works; + + /** + * A threaded worker that can be launched in parallel to bulk read works + * with the ORCID API. The provided {@link ORCIDClient client} defines the + * communication channel. + * + * @see ORCIDHelper#readWorker(List, Map) + * + * @param works + * the list of work summaries specifying the full works to be + * retrieved + * @param client + * the ORCID communication client + * @param cb + * the callback object to return results + * @param log + * a logger + */ + public ORCIDGetBulkWorkWorker(List works, ORCIDClient client, Map> cb, Logger log, ProgressHandler handler) { + super(client, cb, log, handler); + + assert works != null && !works.isEmpty(); + + this.works = works; + } + + /** + * Retrieves a bulk of full works from an ORCID profile. + */ + @Override + public void run() { + try { + MDC.setContextMap(mdcCtxMap); + } catch (Exception e) {} // if the context is empty + + _log.debug("[getFullBulkWork] "+works.size()); + + final Map> fulls = client.getWorks(works); + handler.step(works.size()); + for (WorkSummary w : works) { + assert w.getPutCode() != null; + + PTCRISyncResult wrk = fulls.get(w.getPutCode()); + callback(w.getPutCode(), wrk); + } + } + +} diff --git a/src/main/java/pt/ptcris/utils/ORCIDGetFundingWorker.java b/src/main/java/pt/ptcris/utils/ORCIDGetFundingWorker.java new file mode 100644 index 0000000..a26601c --- /dev/null +++ b/src/main/java/pt/ptcris/utils/ORCIDGetFundingWorker.java @@ -0,0 +1,74 @@ +/* + * Copyright (c) 2016, 2017 PTCRIS - FCT|FCCN and others. + * Licensed under MIT License + * http://ptcris.pt + * + * This copyright and license information (including a link to the full license) + * shall be included in its entirety in all copies or substantial portion of + * the software. + */ +package pt.ptcris.utils; + +import java.math.BigInteger; +import java.util.Map; + +import org.slf4j.Logger; +import org.slf4j.MDC; +import org.um.dsi.gavea.orcid.model.funding.Funding; +import org.um.dsi.gavea.orcid.model.funding.FundingSummary; + +import pt.ptcris.ORCIDClient; +import pt.ptcris.PTCRISyncResult; +import pt.ptcris.handlers.ProgressHandler; + +/** + * A worker thread that can be used to GET funding entries from ORCID. + * + * @see ORCIDWorker + */ +final class ORCIDGetFundingWorker extends ORCIDWorker { + + private final FundingSummary funding; + + /** + * A threaded worker that can be launched in parallel to GET funding + * activities with the ORCID API. The provided {@link ORCIDClient client} + * defines the communication channel. + * + * @see ORCIDHelper#readWorker(org.um.dsi.gavea.orcid.model.common.ElementSummary, + * Map) + * + * @param funding + * the summary specifying the full funding to be retrieved + * @param client + * the ORCID communication client + * @param cb + * the callback object to return results + * @param log + * a logger + */ + public ORCIDGetFundingWorker(FundingSummary funding, ORCIDClient client, Map> cb, Logger log, ProgressHandler handler) { + super(client, cb, log, handler); + assert funding != null; + assert funding.getPutCode() != null; + + this.funding = funding; + } + + /** + * Retrieves a full funding activity from an ORCID profile. + */ + @Override + public void run() { + try { + MDC.setContextMap(mdcCtxMap); + } catch (Exception e) {} // if the context is empty + + _log.debug("[getFullFunding] "+funding.getPutCode()); + + final PTCRISyncResult full = client.getFunding(funding); + handler.step(); + callback(funding.getPutCode(), full); + } + +} diff --git a/src/main/java/pt/ptcris/utils/ORCIDGetWorkWorker.java b/src/main/java/pt/ptcris/utils/ORCIDGetWorkWorker.java new file mode 100644 index 0000000..3f65481 --- /dev/null +++ b/src/main/java/pt/ptcris/utils/ORCIDGetWorkWorker.java @@ -0,0 +1,73 @@ +/* + * Copyright (c) 2016, 2017 PTCRIS - FCT|FCCN and others. + * Licensed under MIT License + * http://ptcris.pt + * + * This copyright and license information (including a link to the full license) + * shall be included in its entirety in all copies or substantial portion of + * the software. + */ +package pt.ptcris.utils; + +import java.math.BigInteger; +import java.util.Map; + +import org.slf4j.Logger; +import org.slf4j.MDC; +import org.um.dsi.gavea.orcid.model.work.Work; +import org.um.dsi.gavea.orcid.model.work.WorkSummary; + +import pt.ptcris.ORCIDClient; +import pt.ptcris.PTCRISyncResult; +import pt.ptcris.handlers.ProgressHandler; + +/** + * A worker thread that can be used to GET works from ORCID. + * + * @see ORCIDWorker + */ +final class ORCIDGetWorkWorker extends ORCIDWorker { + + private final WorkSummary work; + + /** + * A threaded worker that can be launched in parallel to GET works with the + * ORCID API. The provided {@link ORCIDClient client} defines the + * communication channel. + * + * @see ORCIDHelper#readWorker(org.um.dsi.gavea.orcid.model.common.ElementSummary, Map) + * + * @param work + * the summary specifying the full work to be retrieved + * @param client + * the ORCID communication client + * @param cb + * the callback object to return results + * @param log + * a logger + */ + public ORCIDGetWorkWorker(WorkSummary work, ORCIDClient client, Map> cb, Logger log, ProgressHandler handler) { + super(client, cb, log, handler); + assert work != null; + assert work.getPutCode() != null; + + this.work = work; + } + + /** + * Retrieves a full work from an ORCID profile. + */ + @Override + public void run() { + try { + MDC.setContextMap(mdcCtxMap); + } catch (Exception e) {} // if the context is empty + + _log.debug("[getFullWork] " + work.getPutCode()); + + final PTCRISyncResult full = client.getWork(work); + handler.step(); + callback(work.getPutCode(), full); + } + +} diff --git a/src/main/java/pt/ptcris/utils/ORCIDHelper.java b/src/main/java/pt/ptcris/utils/ORCIDHelper.java new file mode 100644 index 0000000..ac060b2 --- /dev/null +++ b/src/main/java/pt/ptcris/utils/ORCIDHelper.java @@ -0,0 +1,1114 @@ +/* + * Copyright (c) 2016, 2017 PTCRIS - FCT|FCCN and others. + * Licensed under MIT License + * http://ptcris.pt + * + * This copyright and license information (including a link to the full license) + * shall be included in its entirety in all copies or substantial portion of + * the software. + */ +package pt.ptcris.utils; + +import java.math.BigInteger; +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashMap; +import java.util.HashSet; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.TimeUnit; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.um.dsi.gavea.orcid.client.exception.OrcidClientException; +import org.um.dsi.gavea.orcid.model.activities.FundingGroup; +import org.um.dsi.gavea.orcid.model.activities.WorkGroup; +import org.um.dsi.gavea.orcid.model.common.ClientId; +import org.um.dsi.gavea.orcid.model.common.ElementSummary; +import org.um.dsi.gavea.orcid.model.common.ExternalId; +import org.um.dsi.gavea.orcid.model.common.ExternalIds; +import org.um.dsi.gavea.orcid.model.common.RelationshipType; +import org.um.dsi.gavea.orcid.model.funding.Funding; +import org.um.dsi.gavea.orcid.model.funding.FundingSummary; +import org.um.dsi.gavea.orcid.model.funding.FundingType; +import org.um.dsi.gavea.orcid.model.work.Work; +import org.um.dsi.gavea.orcid.model.work.WorkSummary; +import org.um.dsi.gavea.orcid.model.work.WorkType; + +import pt.ptcris.ORCIDClient; +import pt.ptcris.PTCRISyncResult; +import pt.ptcris.exceptions.InvalidActivityException; +import pt.ptcris.handlers.ProgressHandler; + +/** + * An abstract helper to help manage ORCID activities and simplify the usage of + * the low-level ORCID {@link pt.ptcris.ORCIDClient client}. Supports bulk + * requests when available. The concrete ORCID activities to be managed by the + * helper are expected to support {@link ExternalIds external identifiers}. + * + * Provides support for asynchronous communication with ORCID although it is + * only active for GET requests due to resource limitations. + * + * @param + * The class of ORCID activities being synchronized + * @param + * The class of ORCID activity summaries + * @param + * The class of ORCID activity groups + * @param + * The class of ORCID activity types + */ +public abstract class ORCIDHelper> { + + /** + * Creates a static (i.e., no server connection) ORCID helper to manage work + * activities. + * + * @return the ORCID work helper + */ + public static ORCIDHelper factoryStaticWorks() { + return new ORCIDWorkHelper(null); + } + + /** + * Creates a static (i.e., no server connection) ORCID helper to manage + * funding activities. + * + * @return the ORCID funding helper + */ + public static ORCIDHelper factoryStaticFundings() { + return new ORCIDFundingHelper(null); + } + + public static final String INVALID_EXTERNALIDENTIFIERS = "ExternalIdentifiers"; + public static final String INVALID_TITLE = "Title"; + public static final String INVALID_PUBLICATIONDATE = "PublicationDate"; + public static final String INVALID_YEAR = "Year"; + public static final String INVALID_TYPE = "Type"; + public static final String INVALID_ORGANIZATION = "Organization"; + public static final String OVERLAPPING_EIDs = "OverlappingEIDs"; + + protected final int bulk_size_add; + protected final int bulk_size_get; + + protected static final Logger _log = LoggerFactory.getLogger(ORCIDHelper.class); + + /** + * The client used to communicate with ORCID. Defines the ORCID user profile + * being managed and the Member API id being user to source activities. + */ + public final ORCIDClient client; + + protected ExecutorService executor; + + /** + * Initializes the helper with a given ORCID client, which defines whether + * asynchronous calls will be performed, and sets whether bulk ORCID + * commands are available and with which size. + * + * @param orcidClient + * the ORCID client + * @param bulk_size_add + * number of activities per bulk add request + * @param bulk_size_get + * number of activities per bulk get request + */ + public ORCIDHelper(ORCIDClient orcidClient, int bulk_size_add, + int bulk_size_get) { + this.client = orcidClient; + this.bulk_size_add = bulk_size_add; + this.bulk_size_get = bulk_size_get; + if (client != null && client.threads() > 1) + executor = Executors.newFixedThreadPool(client.threads()); + } + + /* + * Generic client methods to be instantiated for concrete ORCID activity + * types. + */ + + /** + * Retrieve all ORCID activity groups through the ORCID client. + * + * @return the remote ORCID activities + * @throws OrcidClientException + * if the communication with ORCID fails + */ + protected abstract List getSummariesClient() throws OrcidClientException; + + /** + * Retrieves through the ORCID client a single full activity for which the + * summary is provided. If the communication with ORCID fails, the exception + * is embedded in a failed {@link PTCRISyncResult}. + * + * @param summary + * the ORCID activity summary for which to read the full ORCID + * activity + * @return the remote full ORCID activity + */ + protected abstract PTCRISyncResult readClient(S summary); + + /** + * Retrieves through the ORCID client every full activity for which + * summaries are provided. If the communication with ORCID fails, the + * exception is embedded in a failed {@link PTCRISyncResult}. Should + * generate bulk requests. + * + * @param summaries + * the ORCID activity summaries for which to read full ORCID + * activities + * @return the remote full ORCID activities + */ + protected abstract Map> readClient(List summaries); + + /** + * Creates a worker to asynchronously read a single full activity for which + * the summary is provided. If the communication with ORCID fails, the + * exception is embedded in a failed {@link PTCRISyncResult}. + * + * @param summary + * the ORCID activity summary for which to read the full ORCID + * activity + * @param cb + * the callback on which to report results + * @param handler + * a handler to report progress + * @return the get worker + */ + protected abstract ORCIDWorker readWorker(S summary, Map> cb, ProgressHandler handler); + + /** + * Creates a worker to asynchronously read full activities for which the + * summaries are provided. If the communication with ORCID fails, the + * exception is embedded in a failed {@link PTCRISyncResult}. Should + * generate bulk requests. + * + * @param summaries + * the ORCID activity summaries for which to read the full ORCID + * activities + * @param cb + * the callback on which to report results + * @param handler + * a handler to report progress + * @return the get worker + */ + protected abstract ORCIDWorker readWorker(List summaries, Map> cb, ProgressHandler handler); + + /** + * Adds through the ORCID client a new full activity. If the communication + * with ORCID fails, the exception is embedded in a failed + * {@link PTCRISyncResult}. + * + * @param activity + * the full ORCID activity to be added + * @return the result of the operation + */ + protected abstract PTCRISyncResult addClient(E activity); + + /** + * Adds through the ORCID client a set of new full activities. If the + * communication with ORCID fails, the exception is embedded in a failed + * {@link PTCRISyncResult}. + * + * @param activities + * the full ORCID activities to be added + * @return the result of the operation + */ + protected abstract List> addClient(List activities); + + /** + * Updates through the ORCID client a remote activity. If the communication + * with ORCID fails, the exception is embedded in a failed + * {@link PTCRISyncResult}. + * + * @param remotePutcode + * the put-code of the remote ORCID activity + * @param activity + * the new state of the ORCID activity + * @return the result of the operation + */ + protected abstract PTCRISyncResult updateClient(BigInteger remotePutcode, E activity); + + /** + * Deletes through the ORCID client a remote activity. If the communication + * with ORCID fails, the exception is embedded in a failed + * {@link PTCRISyncResult}. + * + * @param remotePutcode + * the put-code of the remote ORCID activity + * @return the result of the operation + */ + protected abstract PTCRISyncResult deleteClient(BigInteger remotePutcode); + + /* + * Helper client methods that build on the generic methods. + */ + + /** + * Retrieves the entire set of activity summaries from the set ORCID profile + * that have at least an external identifier set. Merges each ORCID group + * into a single summary, following {@link #group(Object)}. + * + * @return the set of ORCID activity summaries in the defined ORCID profile + * @throws OrcidClientException + * if the communication with ORCID fails + */ + private final List getAllSummaries() throws OrcidClientException { + final List fundSummaryList = new LinkedList(); + final List fundGroupList = getSummariesClient(); + for (G group : fundGroupList) + fundSummaryList.add(group(group)); + return fundSummaryList; + } + + /** + * Retrieves the entire set of activity summaries of given types from the + * set ORCID profile that have at least an external identifier set. Merges + * each ORCID group into a single summary, following {@link #group(Object)}. + * + * @param types + * the ORCID types of the activities to be retrieved (may be null) + * @return the set of ORCID activity summaries in the defined ORCID profile + * @throws OrcidClientException + * if the communication with ORCID fails + */ + public final List getAllTypedSummaries(Collection types) + throws OrcidClientException { + List res = new ArrayList(); + if (types != null) + for (S r : getAllSummaries()) + if (types.contains(getTypeS(r))) + res.add(r); + return res; + } + + /** + * Retrieves the entire set (i.e., not merged) of activity summaries in the + * ORCID profile whose source is the Member API id defined in the ORCID + * client. + * + * @return the set of ORCID activity summaries in the ORCID profile for the + * defined source + * @throws OrcidClientException + * if the communication with ORCID fails + */ + public final List getSourcedSummaries() throws OrcidClientException { + final String sourceClientID = client.getClientId(); + + final List summaryList = new LinkedList(); + final List groupList = getSummariesClient(); + + for (G group : groupList) { + for (S summary : getGroupSummaries(group)) { + final ClientId client = summary.getSource().getSourceClientId(); + // may be null is entry added by the user + if (client != null + && client.getUriPath().equals(sourceClientID)) { + summaryList.add(summary); + } + } + } + return summaryList; + } + + /** + * Reads a full ORCID activity from an ORCID profile and adds it to a + * callback map. The resulting activity contains every external identifier + * set in the input activity summary, because the summary resulted from the + * merging of a group, but the retrieved full activity is a single activity. + * It also clears the put-code, since at this level they represent the local + * identifier. If possible the number of threads is higher than 1, process + * is asynchronous. If the list is not a singleton, a bulk request will be + * performed if supported for the concrete ORCID activity type. If the + * communication with ORCID fails for any activity, the exceptions are + * embedded in failed {@link PTCRISyncResult}. + * + * @see #readClient(List) + * + * @param summaries + * the ORCID activity summaries representing the merged groups + * @param cb + * the callback object + * @param handler + * the handler to report progress + * @throws InterruptedException + * if the asynchronous GET process is interrupted + */ + public final void getFulls(List summaries, + Map> cb, ProgressHandler handler) + throws InterruptedException { + if (cb == null) + throw new IllegalArgumentException("Null callback map."); + if (summaries == null || summaries.isEmpty()) + return; + + if (client.threads() > 1 && cb != null) { + for (int i = 0; i < summaries.size();) { + if (bulk_size_get > 1) { + List putcodes = new ArrayList(); + for (int j = 0; j < bulk_size_get && i < summaries.size(); j++) { + putcodes.add(summaries.get(i)); + i++; + } + final ORCIDWorker worker = readWorker(putcodes, cb, handler); + executor.execute(worker); + } else { + final ORCIDWorker worker = readWorker(summaries.get(i), cb, handler); + executor.execute(worker); + i++; + } + } + } else { + Map> fulls = new HashMap>(); + for (int i = 0; i < summaries.size();) { + if (bulk_size_get > 1) { + List putcodes = new ArrayList(); + for (int j = 0; j < bulk_size_get && i < summaries.size(); j++) { + putcodes.add(summaries.get(i)); + i++; + } + fulls.putAll(readClient(putcodes)); + if (handler!=null) handler.step(putcodes.size()); + } else { + fulls.put(summaries.get(i).getPutCode(), + readClient(summaries.get(i))); + if (handler!=null) handler.step(); + i++; + } + } + cb.putAll(fulls); + } + waitWorkers(); + } + + /** + * Synchronously adds an activity to an ORCID profile. The OK result + * includes the newly assigned put-code. If the communication with ORCID + * fails, the exception is embedded in a failed {@link PTCRISyncResult}. + * + * @see #addClient(ElementSummary) + * + * @param activity + * the ORCID activity to be added + * @return the result of the ORCID call + */ + private final PTCRISyncResult add(E activity) { + assert activity != null; + + // remove any put-code otherwise ORCID will throw an error + final E clone = cloneE(activity); + clone.setPutCode(null); + + return addClient(clone); + } + + /** + * Synchronously adds a list of activities to an ORCID profile. A list of + * results is returned, one for each input activity. The OK result includes + * the newly assigned put-code. If the communication with ORCID fails, the + * exception is embedded in a failed {@link PTCRISyncResult}. If the overall + * communication fails, the result is replicated for each input. + * + * @see #addClient(List) + * + * @param activities + * the new ORCID activities to be added + * @return the results of the ORCID call for each input activity + */ + private final List> add(Collection activities) { + assert activities != null; + + List clones = new ArrayList(); + // remove any put-code otherwise ORCID will throw an error + for (E activity : activities) { + final E clone = cloneE(activity); + clone.setPutCode(null); + clones.add(clone); + } + + return addClient(clones); + } + + /** + * Synchronously adds a list of activities to an ORCID profile, either + * through atomic or bulk calls if available. A list of results is returned, + * one for each input activity. The OK result includes the newly assigned + * put-code. If the communication with ORCID fails, the exception is + * embedded in a failed {@link PTCRISyncResult}. If the overall + * communication fails, the result is replicated for each input. + * + * @param activities + * the new ORCID activities to be added + * @param handler + * the handler to report progress + * @return the results of the ORCID call for each input activity + */ + public final List> add(List activities, ProgressHandler handler) { + List> res = new ArrayList>(); + if (activities == null || activities.isEmpty()) + return new ArrayList>(); + + for (int c = 0; c != activities.size();) { + if (bulk_size_add > 1) { + List tmp = new ArrayList(); + for (int j = 0; j < bulk_size_add && c < activities.size(); j++) { + tmp.add(activities.get(c)); + c++; + } + res.addAll(this.add(tmp)); + if (handler!=null) handler.step(tmp.size()); + } else { + E local = activities.get(c); + res.add(this.add(local)); + if (handler!=null) handler.step(); + c++; + } + } + return res; + } + + /** + * Synchronously updates an activity to an ORCID profile. If the + * communication with ORCID fails, the exception is embedded in a failed + * {@link PTCRISyncResult}. + * + * @see #updateClient(BigInteger, ElementSummary) + * + * @param remotePutcode + * the put-code of the remote ORCID activity that will be updated + * @param updated + * the new state of the activity that will be updated + * @return the result of the ORCID call + */ + public final PTCRISyncResult update(BigInteger remotePutcode, E updated) { + if (remotePutcode == null || updated == null) + throw new IllegalArgumentException("Can't update null activity."); + + final E clone = cloneE(updated); + // set the remote put-code + clone.setPutCode(remotePutcode); + + return updateClient(remotePutcode, clone); + } + + /** + * Synchronously deletes an activity from an ORCID profile. If the + * communication with ORCID fails, the exception is embedded in a failed + * {@link PTCRISyncResult}. + * + * @see #deleteClient(BigInteger) + * + * @param putcode + * the remote put-code of the ORCID activity to be deleted + * @return the outcome of the delete request + */ + public final PTCRISyncResult delete(BigInteger putcode) { + if (putcode == null) + throw new IllegalArgumentException("Can't delete null activity."); + + return deleteClient(putcode); + } + + /** + * Deletes the entire set of activity summaries in the ORCID profile whose + * source is the Member API id defined in the ORCID client. + * + * @throws OrcidClientException + * if the communication with ORCID fails + */ + public final void deleteAllSourced() throws OrcidClientException { + final List summaryList = getSourcedSummaries(); + + for (S summary : summaryList) { + delete(summary.getPutCode()); + } + } + + /** + * Waits for all active asynchronous workers communicating with ORCID to + * finish (if multi-threading is enabled, otherwise it is always true). + * + * @return whether the workers finished before the timeout + * @throws InterruptedException + * if the process was interrupted + */ + private final boolean waitWorkers() throws InterruptedException { + if (client.threads() <= 1) + return true; + + executor.shutdown(); + final boolean timeout = executor + .awaitTermination(100, TimeUnit.SECONDS); + executor = Executors.newFixedThreadPool(client.threads()); + return timeout; + } + + /* + * Generic static methods to be instantiated for concrete ORCID activity + * types. + */ + + /** + * Returns the non-null external identifiers of an activity (null becomes + * empty list). Cannot rely on + * {@link #getNonNullExternalIdsS(ElementSummary)} because + * {@link #summarize(ElementSummary)} itself calls this method. + * + * @param activity + * the ORCID activity from which to retrieve the external + * identifiers + * @return the non-null external identifiers + */ + public abstract ExternalIds getNonNullExternalIdsE(E activity); + + /** + * Returns the non-null external identifiers of an activity summary (null + * becomes empty list). + * + * @param summary + * the ORCID activity summary from which to retrieve the external + * identifiers + * @return the non-null external identifiers + */ + public abstract ExternalIds getNonNullExternalIdsS(S summary); + + /** + * Assigns a set of external identifiers to an activity. + * + * @param activity + * the ORCID activity to which to assign the external identifiers + * @param eids + * the external identifiers to be assigned + */ + public abstract void setExternalIdsE(E activity, ExternalIds eids); + + /** + * Assigns a set of external identifiers to an activity summary. + * + * @param summary + * the ORCID activity summary to which to assign the external + * identifiers + * @param eids + * the external identifiers to be assigned + */ + public abstract void setExternalIdsS(S summary, ExternalIds eids); + + /** + * Retrieves the type of an activity summary. + * + * @param summary + * the ORCID activity summary + * @return the summary's type + */ + protected abstract T getTypeS(S summary); + + /** + * Tests whether a given external identifier type name is valid. + * + * @param eid + * a potential external identifier type name + * @return whether the string is a valid external identifier type + */ + protected abstract boolean validExternalIdType(String eid); + + /** + * Retrieves the title of an activity summary. + * + * @param summary + * the ORCID activity summary + * @return the summary's title if defined, empty string otherwise + */ + protected abstract String getTitleS(S summary); + + /** + * Retrieves the publication year of an activity summary. + * + * @param summary + * the ORCID activity summary + * @return the summary's publication year, may be null + */ + protected abstract String getYearS(S summary); + + /** + * Retrieve the activity summaries that compose an activity group. + * + * @param group + * the ORCID group from which to retrieve the ORCID activity + * summaries + * @return the OCRID activity summaries contained in the group + */ + protected abstract List getGroupSummaries(G group); + + /** + * Merges an activity group into a single activity summary. Simply selects + * the meta-data (including part-of external identifiers) from the first + * activity of the group (i.e., the preferred one) and assigns it any extra + * (self) external identifiers from the remainder activities. These + * remainder identifiers are the ones grouped by ORCID. + * + * @param group + * the activity group to be merged + * @return the resulting activity summary + * @throws IllegalArgumentException + * if the group is empty + */ + protected abstract S group(G group) throws IllegalArgumentException; + + /** + * Checks whether an activity is already up to date regarding another one, + * considering meta-data other than the self external identifiers. Uses only + * meta-data is available in activity summaries. + * + * @param preElement + * the potentially out of date ORCID activity + * @param posElement + * the up to date ORCID activity + * @return true if the considered meta-data is the same, false otherwise. + */ + protected abstract boolean isMetaUpToDate(E preElement, S posElement); + + /** + * Tests whether an activity summary has minimal quality to be synchronized, + * by inspecting its meta-data and that of coexisting activities, and + * returns the detected invalid fields. Only uses meta-data available in + * activity summaries. Coexisting activity may be used to test for overlaps. + * + * TODO: contributors are not being considered as they are not contained in + * the summaries. + * + * @param summary + * the ORCID activity summary to test for quality + * @param others + * other coexisting activities + * @return the set of invalid meta-data, empty if valid + */ + protected abstract Set testMinimalQuality(S summary, Collection others); + + /** + * Creates an update to an activity given the difference on meta-data. + * Essentially creates an activity with the same put-code as the original + * activity and with the new meta-data that must be assigned to it. + * Currently, only new external identifiers are considered. + * + * @param original + * the original ORCID activity + * @param diff + * the difference on external identifiers + * @return the update to be applied to the ORCID activity + */ + public abstract E createUpdate(E original, ExternalIdsDiff diff); + + /** + * Clones an activity summary. + * + * @param summary + * the ORCID activity summary to be cloned + * @return the cloned ORCID activity summary + */ + protected abstract S cloneS(S summary); + + /** + * Clones an activity. + * + * @param activity + * the ORCID activity to be cloned + * @return the cloned ORCID activity + */ + protected abstract E cloneE(E activity); + + /** + * Summarizes an activity into an activity summary. Most methods on + * activities rely on this to re-use methods on activity summaries. + * + * @param activity + * the ORCID activity to be summarized + * @return the corresponding ORCID activity summary + */ + protected abstract S summarize(E activity); + + /* + * Helper static methods that build on the generic methods. + */ + + /** + * Retrieves the local key of an activity, currently assumed to be stored in + * the put-code field. + * + * @param activity + * the ORCID activity from which to get the local key + * @return the local key + */ + public static BigInteger getActivityLocalKey(ElementSummary activity) { + if (activity == null) + throw new IllegalArgumentException("Null element."); + + return activity.getPutCode(); + } + + /** + * Retrieves the local key of an activity, currently assumed to be stored in + * the put-code field. If empty, returns a default value. + * + * @param activity + * the ORCID activity from which to get the local key + * @param defaultValue + * a default value in case the put-code is empty + * @return the local key + */ + public static BigInteger getActivityLocalKey(ElementSummary activity, BigInteger defaultValue) { + if (activity == null) + throw new IllegalArgumentException("Null element."); + + BigInteger putCode = getActivityLocalKey(activity); + if (putCode == null) + putCode = defaultValue; + + return putCode; + } + + /** + * Assign a local key to an activity, currently assumed to be stored in the + * put-code field. + * + * @param activity + * the activity to which to set the local key + * @param key + * the local key + */ + protected static void setWorkLocalKey(ElementSummary activity, BigInteger key) { + if (activity == null) + throw new IllegalArgumentException("Null element."); + + activity.setPutCode(key); + } + + /** + * Clears (sets to null) the local key of an activity, currently assumed to + * be stored in the put-code field. + * + * @param activity + * the activity to which to clear the local key + */ + public static void cleanWorkLocalKey(ElementSummary activity) { + if (activity == null) + throw new IllegalArgumentException("Null element."); + + activity.setPutCode(null); + } + + /** + * Copies all meta-data from an activity summary into another. + * + * @param from + * the source summary + * @param to + * the target summary + */ + protected static void copy(ElementSummary from, ElementSummary to) { + assert from != null; + assert to != null; + + to.setCreatedDate(from.getCreatedDate()); + to.setDisplayIndex(from.getDisplayIndex()); + to.setLastModifiedDate(from.getLastModifiedDate()); + to.setPath(from.getPath()); + to.setPutCode(from.getPutCode()); + to.setSource(from.getSource()); + to.setVisibility(from.getVisibility()); + } + + /** + * Retrieves the type of an activity. Build on + * {@link #getTypeS(ElementSummary)}. + * + * @param activity + * the ORCID activity + * @return the activity's type + */ + public final T getTypeE(E activity) { + return getTypeS(summarize(activity)); + } + + /** + * Retrieves the title of an activity. Builds on + * {@link #getTitleS(ElementSummary)}. + * + * @param activity + * the ORCID activity + * @return the activity's title if defined, empty string otherwise + */ + protected final String getTitleE(E activity) { + return getTitleS(summarize(activity)); + } + + /** + * Retrieves the publication year of an activity. Builds on + * {@link #getYearS(ElementSummary)}. + * + * @param activity + * the ORCID activity + * @return the activity's publication year, may be null + */ + protected final String getPubYearE(E activity) { + return getYearS(summarize(activity)); + } + + /** + * Returns the non-null part-of external identifiers of an activity summary + * (null becomes empty list). + * + * @param summary + * the ORCID activity summary from which to retrieve the external + * identifiers + * @return the non-null part-of external identifiers + */ + protected final ExternalIds getPartOfExternalIdsS(S summary) { + if (summary == null) + throw new IllegalArgumentException("Null element."); + + List res = new ArrayList(); + for (ExternalId eid : getNonNullExternalIdsS(summary).getExternalId()) + if (eid.getExternalIdRelationship() == RelationshipType.PART_OF) + res.add(eid); + return new ExternalIds(res); + } + + /** + * Returns the non-null part-of external identifiers of an activity (null + * becomes empty list). Builds on + * {@link #getPartOfExternalIdsS(ElementSummary)}. + * + * @param activity + * the ORCID activity from which to retrieve the external + * identifiers + * @return the non-null part-of external identifiers + */ + public final ExternalIds getPartOfExternalIdsE(E activity) { + return getPartOfExternalIdsS(summarize(activity)); + } + + /** + * Returns the non-null self external identifiers of an activity summary + * (null becomes empty list). + * + * @param summary + * the ORCID activity summary from which to retrieve the external + * identifiers + * @return the non-null self external identifiers + */ + protected final ExternalIds getSelfExternalIdsS(S summary) { + if (summary == null) + throw new IllegalArgumentException("Null element."); + + List res = new ArrayList(); + for (ExternalId eid : getNonNullExternalIdsS(summary).getExternalId()) + if (eid.getExternalIdRelationship() == RelationshipType.SELF) + res.add(eid); + return new ExternalIds(res); + } + + /** + * Returns the non-null self external identifiers of an activity (null + * becomes empty list). Builds on + * {@link #getSelfExternalIdsS(ElementSummary)}. + * + * @param activity + * the ORCID activity from which to retrieve the external + * identifiers + * @return the non-null self external identifiers + */ + public final ExternalIds getSelfExternalIdsE(E activity) { + return getSelfExternalIdsS(summarize(activity)); + } + + /** + * Calculates the symmetric difference of self {@link ExternalId external + * identifiers} between an activity summary and a set of activities. + * Elements that do not match (i.e., no identifier is common) are ignored. + * + * @param summary + * the activity summary to be compared with other activities + * @param activities + * the set of activities against which the activity summary is + * compared + * @return The symmetric difference of self external identifiers between the + * summary and other activities + */ + public final Map getSelfExternalIdsDiffS(S summary, Collection activities) { + if (summary == null) + throw new IllegalArgumentException("Null element."); + if (activities == null) + activities = new HashSet(); + + final Map matches = new HashMap(); + for (E match : activities) { + final ExternalIdsDiff diff = new ExternalIdsDiff( + getSelfExternalIdsE(match), getSelfExternalIdsS(summary)); + if (!diff.same.isEmpty()) + matches.put(match, diff); + } + return matches; + } + + /** + * Tests whether two sets of (non-exclusively self or part-of) external + * identifiers are identical. + * + * @param eids1 + * the first set of external identifiers + * @param eids2 + * the second set of external identifiers + * @return whether the external identifiers are identical + */ + protected static boolean identicalExternalIDs(ExternalIds eids1, + ExternalIds eids2) { + assert eids1 != null; + assert eids2 != null; + + final ExternalIdsDiff diff = new ExternalIdsDiff(eids1, eids2); + return diff.more.isEmpty() && diff.less.isEmpty(); + } + + /** + * Checks whether an activity is already up to date regarding another one + * regarding self {@link ExternalId external identifiers}. + * + * This test is expected to be used by the import algorithms, where only new + * self external identifiers are to be considered. + * + * @param preElement + * the potentially out of date ORCID activity + * @param posElement + * the up to date ORCID activity + * @return true if all the self external identifiers between the two + * activities are the same, false otherwise + */ + public final boolean hasNewSelfIDs(E preElement, S posElement) { + if (preElement == null || posElement == null) + throw new IllegalArgumentException("Null element."); + + final ExternalIdsDiff diff = new ExternalIdsDiff( + getSelfExternalIdsE(preElement), + getSelfExternalIdsS(posElement)); + + return diff.more.isEmpty(); + } + + /** + * Checks whether an activity is already up to date regarding another one, + * considering the self {@link ExternalIdentifier external identifiers}. + * + * @param preElement + * the potentially out of date ORCID activity + * @param posElement + * the up to date ORCID activity + * @return true if all the self external identifiers are the same, false + * otherwise. + */ + private final boolean isSelfExternalIDsUpToDate(E preElement, S posElement) { + assert preElement != null; + assert posElement != null; + + return identicalExternalIDs(getSelfExternalIdsE(preElement), + getSelfExternalIdsS(posElement)); + } + + /** + * Checks whether an activity is already up to date regarding another one, + * considering the self {@link ExternalId external identifiers} and + * additional meta-data. Only meta-data existent in the activity summaries + * is conside + * + * This test is expected to be used by the export algorithms, where the + * meta-data is expected to be up-to-date on the remote profile. + * + * @param preElement + * the potentially out of date ORCID activity + * @param posElement + * the up to date ORCID activity + * @return true if all the self external identifiers and the meta-data + * between the two activities are the same, false otherwise + */ + public final boolean isUpToDateS(E preElement, S posElement) { + if (preElement == null || posElement == null) + throw new IllegalArgumentException("Null element."); + + return isSelfExternalIDsUpToDate(preElement, posElement) + && isMetaUpToDate(preElement, posElement); + } + + /** + * Checks whether an activity is already up to date regarding another one, + * considering the self {@link ExternalId external identifiers} and + * additional meta-data. Only meta-data existent in the activity summaries + * is considered. Builds on + * {@link #isUpToDateS(ElementSummary, ElementSummary)}. + * + * This test is expected to be used by the export algorithms, where the + * meta-data is expected to be up-to-date on the remote profile. + * + * @param preElement + * the potentially out of date ORCID activity + * @param posElement + * the up to date ORCID activity + * @return true if all the self external identifiers and the meta-data + * between the two activities are the same, false otherwise + */ + public final boolean isUpToDateE(E preElement, E posElement) { + if (preElement == null || posElement == null) + throw new IllegalArgumentException("Null element."); + + return isUpToDateS(preElement, summarize(posElement)); + } + + /** + * Tests whether an activity has minimal quality to be synchronized, by + * inspecting its meta-data. Throws an exception if the test fails. Only + * meta-data available in activity summaries is considered. + * + * TODO: contributors are not being considered as they are not contained in + * the summaries. + * + * @param activity + * the activity to test for quality + * @param others + * other coexisting activities + * @throws InvalidActivityException + * if the quality test fails, containing the reasons for failing + */ + public final void tryMinimalQualityE(E activity, Collection others) + throws InvalidActivityException { + if (activity == null) + throw new IllegalArgumentException("Null activity."); + if (others == null) + others = new HashSet(); + + Set invs = testMinimalQuality(summarize(activity), others); + if (!invs.isEmpty()) { + throw new InvalidActivityException(invs); + } + } + + /** + * Tests whether an activity summary has minimal quality to be synchronized, + * by inspecting its meta-data and that of coexisting activities, and + * returns the detected invalid fields. Only uses meta-data available in + * activity summaries. Builds on + * {@link #testMinimalQuality(ElementSummary, Collection)}. + * + * TODO: contributors are not being considered as they are not contained in + * the summaries. + * + * @param summary + * the ORCID activity summary to test for quality + * @return the set of invalid meta-data, empty if valid + */ + public final Set testMinimalQuality(S summary) { + return testMinimalQuality(summary, new HashSet()); + } + +} diff --git a/src/main/java/pt/ptcris/utils/ORCIDUpdWorker.java b/src/main/java/pt/ptcris/utils/ORCIDUpdWorker.java new file mode 100644 index 0000000..ca196c6 --- /dev/null +++ b/src/main/java/pt/ptcris/utils/ORCIDUpdWorker.java @@ -0,0 +1,75 @@ +/* + * Copyright (c) 2016, 2017 PTCRIS - FCT|FCCN and others. + * Licensed under MIT License + * http://ptcris.pt + * + * This copyright and license information (including a link to the full license) + * shall be included in its entirety in all copies or substantial portion of + * the software. + */ +package pt.ptcris.utils; + +import java.math.BigInteger; +import java.security.InvalidParameterException; +import java.util.Map; + +import org.slf4j.Logger; +import org.slf4j.MDC; +import org.um.dsi.gavea.orcid.model.work.Work; + +import pt.ptcris.ORCIDClient; +import pt.ptcris.PTCRISyncResult; +import pt.ptcris.handlers.ProgressHandler; + +/** + * A worker thread that can be used to UPDATE works from ORCID. + * + * @see ORCIDWorker + */ +@Deprecated +class ORCIDUpdWorker extends ORCIDWorker { + + private final Work work; + + /** + * A threaded worker that can be launched in parallel to UPDATE works with + * the ORCID API. The provided {@link ORCIDClient client} defines the + * communication channel. + * + * @param work + * the work that is to be updated + * @param client + * the ORCID communication client + * @param cb + * the callback object to return results + * @param log + * a logger + * @throws InvalidParameterException + * if the work's put-code is undefined + * @throws InvalidParameterException + * if the work is null + */ + public ORCIDUpdWorker(Work work, ORCIDClient client, Map> cb, Logger log, ProgressHandler handler) + throws NullPointerException, InvalidParameterException { + super(client, cb, log, handler); + if (work == null) + throw new NullPointerException("UPDATE: arguments must not be null."); + if (work.getPutCode() == null) + throw new InvalidParameterException("UPDATE: Work must have a put-code defined."); + this.work = work; + } + + /** + * Updates a work in an ORCID profile. + */ + @Override + public void run() { + _log.debug("[updateWork] " + work.getPutCode()); + MDC.setContextMap(mdcCtxMap); + + final PTCRISyncResult res = client.updateWork(work.getPutCode(), work); + + callback(work.getPutCode(), res); + } + +} diff --git a/src/main/java/pt/ptcris/utils/ORCIDWorkHelper.java b/src/main/java/pt/ptcris/utils/ORCIDWorkHelper.java new file mode 100644 index 0000000..0d0a9b6 --- /dev/null +++ b/src/main/java/pt/ptcris/utils/ORCIDWorkHelper.java @@ -0,0 +1,417 @@ +/* + * Copyright (c) 2016, 2017 PTCRIS - FCT|FCCN and others. + * Licensed under MIT License + * http://ptcris.pt + * + * This copyright and license information (including a link to the full license) + * shall be included in its entirety in all copies or substantial portion of + * the software. + */ +package pt.ptcris.utils; + +import java.math.BigInteger; +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import org.um.dsi.gavea.orcid.client.exception.OrcidClientException; +import org.um.dsi.gavea.orcid.model.activities.WorkGroup; +import org.um.dsi.gavea.orcid.model.common.ExternalId; +import org.um.dsi.gavea.orcid.model.common.ExternalIds; +import org.um.dsi.gavea.orcid.model.work.Work; +import org.um.dsi.gavea.orcid.model.work.WorkSummary; +import org.um.dsi.gavea.orcid.model.work.WorkType; + +import pt.ptcris.ORCIDClient; +import pt.ptcris.PTCRISyncResult; +import pt.ptcris.handlers.ProgressHandler; + +/** + * An helper to simplify the use of the low-level ORCID + * {@link pt.ptcris.ORCIDClient client}. + * + * Provides support for asynchronous communication with ORCID although it is + * only active for GET requests due to resource limitations. + */ +public final class ORCIDWorkHelper extends ORCIDHelper { + + enum EIdType { + OTHER_ID("other-id"), AGR("agr"), ARXIV("arxiv"), ASIN("asin"), + BIBCODE("bibcode"), CBA("cba"), CIT("cit"), CTX("ctx"), DOI("doi"), + EID("eid"), ETHOS("ethos"), HANDLE("handle"), HIR("hir"), ISBN("isbn"), + ISSN("issn"), JFM("jfm"), JSTOR("jstor"), LCCN("lccn"), MR("mr"), + OCLC("oclc"), OL("ol"), OSTI("osti"), PAT("pat"), PMC("pmc"), + PMID("pmid"), RFC("rfc"), SOURCE_WORK_ID("source-work-id"), + SSRN("ssrn"), URI("uri"), URN("urn"), WOSUID("wosuid"), ZBL("zbl"), + CIENCIAIUL("cienciaiul"), LENSID("lensid"), PDB("pdb"), KUID("kuid"), + ASIN_TLD("asin-tld"); + + public final String value; + + private EIdType(String value) { + this.value = value; + } + } + + /** + * Initializes the helper with a given ORCID client. + * + * @param orcidClient + * the ORCID client + */ + public ORCIDWorkHelper(ORCIDClient orcidClient) { + super(orcidClient, 100, 50); + } + + /* + * Client methods instantiated for ORCID work activities. + */ + + /** {@inheritDoc} */ + @Override + protected List getSummariesClient() throws OrcidClientException { + assert client != null; + _log.debug("[getWorkSummaries] "+client.getUserId()); + return client.getWorksSummary().getGroup(); + } + + /** {@inheritDoc} */ + @Override + protected PTCRISyncResult readClient(WorkSummary work) { + assert client != null; + assert work != null; + assert work.getPutCode() != null; + _log.debug("[getFullWork] "+work.getPutCode()); + return client.getWork(work); + } + + /** {@inheritDoc} */ + @Override + protected Map> readClient(List summaries) { + assert client != null; + if (summaries == null || summaries.isEmpty()) + return new HashMap>(); + _log.debug("[getFullBulkWork] "+summaries.size()); + return client.getWorks(summaries); + } + + /** {@inheritDoc} */ + @Override + protected ORCIDWorker readWorker(WorkSummary summary, Map> cb, ProgressHandler handler) { + assert client != null; + assert cb != null; + assert summary != null; + return new ORCIDGetWorkWorker(summary, client, cb, _log, handler); + } + + /** {@inheritDoc} */ + @Override + protected ORCIDWorker readWorker(List summaries, + Map> cb, ProgressHandler handler) { + assert client != null; + assert cb != null; + if (summaries == null) + summaries = new ArrayList(); + return new ORCIDGetBulkWorkWorker(summaries, client, cb, _log, handler); + } + + /** {@inheritDoc} */ + @Override + protected PTCRISyncResult addClient(Work work) { + assert client != null; + _log.debug("[addWork] "+work.getTitle()); + return client.addWork(work); + } + + /** {@inheritDoc} */ + @Override + protected List> addClient(List works) { + assert client != null; + _log.debug("[addBulkWork] "+works.size()); + if (works == null || works.isEmpty()) + return new ArrayList>(); + return client.addWorks(works); + } + + /** {@inheritDoc} */ + @Override + protected PTCRISyncResult updateClient(BigInteger remotePutcode, Work work) { + assert client != null; + assert remotePutcode != null; + assert work != null; + _log.debug("[updateWork] "+remotePutcode); + return client.updateWork(remotePutcode, work); + } + + /** {@inheritDoc} */ + @Override + protected PTCRISyncResult deleteClient(BigInteger remotePutcode) { + assert client != null; + assert remotePutcode != null; + _log.debug("[deleteWork] "+remotePutcode); + return client.deleteWork(remotePutcode); + } + + /* + * Static methods instantiated for ORCID work activities. + */ + + /** {@inheritDoc} */ + @Override + public ExternalIds getNonNullExternalIdsE(Work work) { + if (work.getExternalIds() == null || work.getExternalIds().getExternalId() == null) { + return new ExternalIds(new ArrayList()); + } else { + return work.getExternalIds(); + } + } + + /** {@inheritDoc} */ + @Override + public ExternalIds getNonNullExternalIdsS(WorkSummary summary) { + if (summary.getExternalIds() == null || summary.getExternalIds().getExternalId() == null) { + return new ExternalIds(new ArrayList()); + } else { + return summary.getExternalIds(); + } + } + + /** {@inheritDoc} */ + @Override + public void setExternalIdsE(Work work, ExternalIds eids) { + assert work != null; + if (eids == null) eids = new ExternalIds(new ArrayList()); + work.setExternalIds(eids); + } + + /** {@inheritDoc} */ + @Override + public void setExternalIdsS(WorkSummary summary, ExternalIds eids) { + assert summary != null; + if (eids == null) eids = new ExternalIds(new ArrayList()); + summary.setExternalIds(eids); + } + + /** {@inheritDoc} */ + @Override + protected WorkType getTypeS(WorkSummary summary) { + assert summary != null; + return summary.getType(); + } + + /** + * {@inheritDoc} + * + * Elements of the enum {@link EIdType} take the shape of upper-case valid + * EId types, with slashes replaced by underscores. + */ + @Override + protected boolean validExternalIdType(String eid) { + try { + EIdType.valueOf(eid.replace('-', '_').toUpperCase()); + return true; + } catch (Exception e) { + return false; + } + } + + /** {@inheritDoc} */ + @Override + protected String getTitleS(WorkSummary summary) { + assert summary != null; + if (summary.getTitle() == null) + return ""; + return summary.getTitle().getTitle(); + } + + /** {@inheritDoc} */ + @Override + protected String getYearS(WorkSummary summary) { + assert summary != null; + if (summary.getPublicationDate() == null + || summary.getPublicationDate().getYear() == null) + return null; + return summary.getPublicationDate().getYear().getValue(); + } + + /** {@inheritDoc} */ + @Override + protected List getGroupSummaries(WorkGroup group) { + assert group != null; + return group.getWorkSummary(); + } + + /** {@inheritDoc} */ + @Override + protected WorkSummary group(WorkGroup group) throws IllegalArgumentException { + assert group != null; + if (group.getWorkSummary() == null || group.getWorkSummary().isEmpty()) + throw new IllegalArgumentException("Can't merge empty group."); + + final WorkSummary preferred = group.getWorkSummary().get(0); + final WorkSummary dummy = cloneS(preferred); + + final List eids = getPartOfExternalIdsS(dummy) + .getExternalId(); + for (ExternalId id : group.getExternalIds().getExternalId()) { + final ExternalId eid = new ExternalId(); + eid.setExternalIdRelationship(id.getExternalIdRelationship()); + eid.setExternalIdType(id.getExternalIdType().toLowerCase()); + eid.setExternalIdValue(id.getExternalIdValue()); + eids.add(eid); + } + dummy.setExternalIds(new ExternalIds(eids)); + + return dummy; + } + + /** + * {@inheritDoc} + * + * The considered fields are: title, publication date (year), work type and + * part-of external identifiers. All this meta-data is available in work + * summaries. + * + * TODO: contributors are not being considered as they are not contained in + * the summaries. + */ + @Override + protected boolean isMetaUpToDate(Work preWork, WorkSummary posWork) { + assert preWork != null; + assert posWork != null; + + boolean res = true; + res &= identicalExternalIDs(getPartOfExternalIdsE(preWork), + getPartOfExternalIdsS(posWork)); + res &= getTitleE(preWork).equals(getTitleS(posWork)); + res &= (getPubYearE(preWork) == null && getYearS(posWork) == null) + || (getPubYearE(preWork) != null + && getYearS(posWork) != null && getPubYearE(preWork) + .equals(getYearS(posWork))); + res &= (preWork.getType() == null && posWork.getType() == null) + || (preWork.getType() != null && posWork.getType() != null && preWork + .getType().equals(posWork.getType())); + return res; + } + + /** + * {@inheritDoc} + * + * The considered fields are: self external identifiers, title, publication + * date (year) and work type. The test also checks whether the external + * identifiers overlap with those of the coexisting works. All this + * meta-data is available in work summaries. The publication date is not + * necessary for data sets and research techniques. + * + * TODO: contributors are not being considered as they are not contained in + * the summaries. + */ + @Override + protected Set testMinimalQuality(WorkSummary work, Collection others) { + assert work != null; + if (others == null) others = new ArrayList(); + + final Set res = new HashSet(); + if (getSelfExternalIdsS(work).getExternalId().isEmpty()) + res.add(INVALID_EXTERNALIDENTIFIERS); + else + for (ExternalId eid : getSelfExternalIdsS(work).getExternalId()) + if (!validExternalIdType(eid.getExternalIdType())) + res.add(INVALID_EXTERNALIDENTIFIERS); + if (work.getTitle() == null) + res.add(INVALID_TITLE); + else if (work.getTitle().getTitle() == null) + res.add(INVALID_TITLE); + if (work.getType() == null) + res.add(INVALID_TYPE); + if (work.getType() == null + || (work.getType() != WorkType.DATA_SET && work.getType() != WorkType.RESEARCH_TECHNIQUE)) { + if (work.getPublicationDate() == null) + res.add(INVALID_PUBLICATIONDATE); + else if (work.getPublicationDate().getYear() == null) + res.add(INVALID_YEAR); + } + Map worksDiffs = getSelfExternalIdsDiffS(work, + others); + for (Work match : worksDiffs.keySet()) + if (match.getPutCode() != work.getPutCode() + && !worksDiffs.get(match).same.isEmpty()) + res.add(OVERLAPPING_EIDs); + + return res; + } + + /** {@inheritDoc} */ + @Override + public Work createUpdate(Work original, ExternalIdsDiff diff) { + assert original != null; + assert diff != null; + + Work workUpdate = cloneE(original); + ExternalIds weids = new ExternalIds(); + List neids = new ArrayList(diff.more); + weids.setExternalId(neids); + ORCIDHelper.setWorkLocalKey(workUpdate, + ORCIDHelper.getActivityLocalKey(original)); + workUpdate.setExternalIds(weids); + workUpdate.setTitle(null); + workUpdate.setType(null); + workUpdate.setPublicationDate(null); + return workUpdate; + } + + /** {@inheritDoc} */ + @Override + public WorkSummary cloneS(WorkSummary summary) { + assert summary != null; + + final WorkSummary dummy = new WorkSummary(); + copy(summary, dummy); + dummy.setPublicationDate(summary.getPublicationDate()); + dummy.setTitle(summary.getTitle()); + dummy.setType(summary.getType()); + dummy.setExternalIds(getNonNullExternalIdsS(summary)); + return dummy; + } + + /** {@inheritDoc} */ + @Override + public Work cloneE(Work work) { + assert work != null; + + final Work dummy = new Work(); + copy(work, dummy); + dummy.setPublicationDate(work.getPublicationDate()); + dummy.setTitle(work.getTitle()); + dummy.setType(work.getType()); + dummy.setExternalIds(getNonNullExternalIdsE(work)); + dummy.setContributors(work.getContributors()); + + dummy.setCitation(work.getCitation()); + dummy.setContributors(work.getContributors()); + dummy.setCountry(work.getCountry()); + dummy.setJournalTitle(work.getJournalTitle()); + dummy.setLanguageCode(work.getLanguageCode()); + dummy.setShortDescription(work.getShortDescription()); + dummy.setUrl(work.getUrl()); + return dummy; + } + + /** {@inheritDoc} */ + @Override + protected WorkSummary summarize(Work work) { + assert work != null; + + final WorkSummary dummy = new WorkSummary(); + copy(work, dummy); + dummy.setPublicationDate(work.getPublicationDate()); + dummy.setTitle(work.getTitle()); + dummy.setType(work.getType()); + dummy.setExternalIds(getNonNullExternalIdsE(work)); + return dummy; + } +} diff --git a/src/main/java/pt/ptcris/utils/ORCIDWorker.java b/src/main/java/pt/ptcris/utils/ORCIDWorker.java new file mode 100644 index 0000000..1e02231 --- /dev/null +++ b/src/main/java/pt/ptcris/utils/ORCIDWorker.java @@ -0,0 +1,71 @@ +/* + * Copyright (c) 2016, 2017 PTCRIS - FCT|FCCN and others. + * Licensed under MIT License + * http://ptcris.pt + * + * This copyright and license information (including a link to the full license) + * shall be included in its entirety in all copies or substantial portion of + * the software. + */ +package pt.ptcris.utils; + +import java.math.BigInteger; +import java.util.Map; + +import org.slf4j.Logger; +import org.slf4j.MDC; +import org.um.dsi.gavea.orcid.model.common.ElementSummary; + +import pt.ptcris.ORCIDClient; +import pt.ptcris.PTCRISyncResult; +import pt.ptcris.handlers.ProgressHandler; + +/** + * An abstract worker that can be used to parallelize calls to the ORCID API. A + * {@link ORCIDClient client} should be provided to establish the communication + * with the Member API, including the user profile being managed and the Member + * API id being user to source activities. Communication is performed via callback. + */ +abstract class ORCIDWorker extends Thread { + + protected final Logger _log; + protected final Map> cb; + protected final ORCIDClient client; + protected final ProgressHandler handler; + protected final Map mdcCtxMap; + + /** + * A threaded worker that can be launched in parallel to communicate with + * the ORCID API. The provided {@link ORCIDClient client} defines the + * communication channel. + * + * @param client + * the ORCID communication client + * @param cb + * the callback object to return results + * @param _log + * a logger + */ + ORCIDWorker(ORCIDClient client, Map> cb, Logger _log, ProgressHandler handler) { + assert client != null; + assert cb != null; + assert handler != null; + + this.handler = handler; + this.client = client; + this.cb = cb; + this._log = _log; + this.mdcCtxMap = MDC.getCopyOfContextMap(); + } + + /** + * Calls back the owner with a result. + * + * @param res + * the result to return + */ + protected void callback(BigInteger id, PTCRISyncResult res) { + cb.put(id, res); + } + +} diff --git a/src/main/java/pt/ptcris/utils/UpdateRecord.java b/src/main/java/pt/ptcris/utils/UpdateRecord.java new file mode 100644 index 0000000..fa6e274 --- /dev/null +++ b/src/main/java/pt/ptcris/utils/UpdateRecord.java @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2016, 2017 PTCRIS - FCT|FCCN and others. + * Licensed under MIT License + * http://ptcris.pt + * + * This copyright and license information (including a link to the full license) + * shall be included in its entirety in all copies or substantial portion of + * the software. + */ +package pt.ptcris.utils; + +import org.um.dsi.gavea.orcid.model.common.ElementSummary; +import org.um.dsi.gavea.orcid.model.common.ExternalId; + +/** + * An helper class that stores two versions of the same {@link ElementSummary + * activity}, as well as the {@link ExternalIdsDiff difference} between their + * {@link ExternalId external identifiers}. + */ +public final class UpdateRecord { + + public final E preElement; + public final S posElement; + public final ExternalIdsDiff eidsDiff; + + /** + * Constructs an object containing two versions of an activity and the + * difference between their {@link ExternalId external identifiers}. The + * updated version is assumed to be only a summary, since the contained + * information is sufficient for the synchronization procedures. + * + * @param preActivity + * the current version of the activity + * @param posActivity + * the updated version of the activity + * @param eidsDiff + * the difference between the identifiers + */ + public UpdateRecord(E preActivity, S posActivity, ExternalIdsDiff eidsDiff) { + if (preActivity == null || posActivity == null || eidsDiff == null) + throw new IllegalArgumentException("Null arguments."); + this.preElement = preActivity; + this.posElement = posActivity; + this.eidsDiff = eidsDiff; + } + +} diff --git a/src/test/java/pt/ptcris/test/PTCRISExample.java b/src/test/java/pt/ptcris/test/PTCRISExample.java new file mode 100644 index 0000000..5720d9c --- /dev/null +++ b/src/test/java/pt/ptcris/test/PTCRISExample.java @@ -0,0 +1,170 @@ +/* + * Copyright (c) 2016, 2017 PTCRIS - FCT|FCCN and others. + * Licensed under MIT License + * http://ptcris.pt + * + * This copyright and license information (including a link to the full license) + * shall be included in its entirety in all copies or substantial portion of + * the software. + */ +package pt.ptcris.test; + +import java.math.BigInteger; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.logging.ConsoleHandler; +import java.util.logging.Level; +import java.util.logging.Logger; +import java.util.logging.SimpleFormatter; + +import org.um.dsi.gavea.orcid.client.exception.OrcidClientException; +import org.um.dsi.gavea.orcid.model.common.ExternalId; +import org.um.dsi.gavea.orcid.model.common.ExternalIds; +import org.um.dsi.gavea.orcid.model.common.RelationshipType; +import org.um.dsi.gavea.orcid.model.work.Work; +import org.um.dsi.gavea.orcid.model.work.WorkTitle; +import org.um.dsi.gavea.orcid.model.work.WorkType; + +import pt.ptcris.ORCIDClient; +import pt.ptcris.PTCRISync; +import pt.ptcris.PTCRISyncResult; +import pt.ptcris.test.TestClients.Profile; + +/** + * A class that exemplifies the use of the various PTCRISync synchronization + * procedures. + */ +public class PTCRISExample { + + @SuppressWarnings("unused") + public static void main(String[] args) throws OrcidClientException, InterruptedException { + // log the results to the console + ConsoleHandler handler = new ConsoleHandler(); + handler.setFormatter(new SimpleFormatter()); + handler.setLevel(Level.ALL); + Logger.getLogger(Tester.class.getName()).setLevel(Level.ALL); + Logger.getLogger(Tester.class.getName()).addHandler(handler); + Tester progressHandler = new Tester(); + + progressHandler.setCurrentStatus(PTCRISExample.class.getName()+" start"); + + // use one of the user profiles from the sandbox + Profile profile = Profile.ONEVALIDWORKS; + + // fixture works, representing those from other sources + List fixtureWorks = new LinkedList(); + + // get a external source client for the user profile + ORCIDClient externalClient = TestClients.getExternalClient(profile); + + // add some works with an external source as a fixture + for (Work work : fixtureWorks) + externalClient.addWork(work); + + // get a local CRIS client for the user profile + ORCIDClient crisClient = TestClients.getCRISClient(profile); + + // the complete list of local works + List localWorks = new LinkedList(); + localWorks.add(work0()); + localWorks.add(work1()); + localWorks.add(work2()); + + // the list of local works that are to be exported + List exportWorks = new LinkedList(); + exportWorks.add(work1()); + exportWorks.add(work2()); + + // export the local works that are to by synchronized + Map> exportResult = PTCRISync.exportWorks(crisClient, localWorks, progressHandler); + // import new valid works found in the user profile + List worksToImport = PTCRISync.importWorks(crisClient, localWorks, progressHandler); + // import work updates found in the user profile + List updatesToImport = PTCRISync.importWorkUpdates(crisClient, localWorks, progressHandler); + + // count the new works found in the user profile + int worksToImportCount = PTCRISync.importWorkCounter(crisClient, localWorks, progressHandler); + // import new invalid works found in the user profile + Map> worksToImportInvalid = PTCRISync.importInvalidWorks(crisClient, localWorks, progressHandler); + + progressHandler.setCurrentStatus(PTCRISExample.class.getName()+" end"); + + } + + private static Work work0() { + Work work = new Work(); + WorkTitle title = new WorkTitle(); + title.setTitle("Yet Another Work Updated Once"); + work.setTitle(title); + + ExternalId e = new ExternalId(); + e.setExternalIdRelationship(RelationshipType.SELF); + e.setExternalIdValue("3000"); + e.setExternalIdType("DOI"); + + ExternalIds uids = new ExternalIds(); + + uids.getExternalId().add(e); + + work.setExternalIds(uids); + + work.setType(WorkType.CONFERENCE_PAPER); + + return work; + } + + private static Work work1() { + Work work = new Work(); + WorkTitle title = new WorkTitle(); + title.setTitle("A Work Updated Once"); + work.setTitle(title); + + ExternalId e = new ExternalId(); + e.setExternalIdRelationship(RelationshipType.SELF); + e.setExternalIdValue("4000"); + e.setExternalIdType("EID"); + + ExternalId e1 = new ExternalId(); + e1.setExternalIdRelationship(RelationshipType.SELF); + e1.setExternalIdValue("00001"); + e1.setExternalIdType("DOI"); + + ExternalIds uids = new ExternalIds(); + + uids.getExternalId().add(e); + uids.getExternalId().add(e1); + + work.setExternalIds(uids); + + work.setType(WorkType.CONFERENCE_PAPER); + + return work; + } + + private static Work work2() { + Work work = new Work(); + WorkTitle title = new WorkTitle(); + title.setTitle("Another Work Updated Twice"); + work.setTitle(title); + + ExternalId e = new ExternalId(); + e.setExternalIdRelationship(RelationshipType.SELF); + // avoids conflicts + e.setExternalIdValue(String.valueOf(System.currentTimeMillis())); + + e.setExternalIdType("DOI"); + + ExternalIds uids = new ExternalIds(); + + uids.getExternalId().add(e); + + work.setExternalIds(uids); + + work.setType(WorkType.JOURNAL_ARTICLE); + + return work; + } + +} diff --git a/src/test/java/pt/ptcris/test/TestClients.java b/src/test/java/pt/ptcris/test/TestClients.java new file mode 100644 index 0000000..8b05075 --- /dev/null +++ b/src/test/java/pt/ptcris/test/TestClients.java @@ -0,0 +1,127 @@ +/* + * Copyright (c) 2016, 2017 PTCRIS - FCT|FCCN and others. + * Licensed under MIT License + * http://ptcris.pt + * + * This copyright and license information (including a link to the full license) + * shall be included in its entirety in all copies or substantial portion of + * the software. + */ +package pt.ptcris.test; + +import org.um.dsi.gavea.orcid.client.OrcidAccessToken; + +import pt.ptcris.ORCIDClient; +import pt.ptcris.ORCIDClientImpl; + +/** + * Helper class defining a set of sandbox ORCID profiles, with varied + * user-inserted productions, that can be used for testing. It also contains + * access tokens for two different Member API clients, that can represent the + * local CRIS service and an external source. + */ +public final class TestClients { + + /** + * The user profiles registered in the sandbox. + */ + public enum Profile { + ZEROVALIDWORKS(0), ONEVALIDWORKS(1), TWOVALIDWORKS(2), EMPTYWORKS(3); + + private final int value; + + private Profile(int value) { + this.value = value; + } + } + + private static final String orcid_login_uri = "https://sandbox.orcid.org"; + private static final String orcid_api_uri = "https://api.sandbox.orcid.org/"; + private static final String orcid_redirect_uri = "https://developers.google.com/oauthplayground"; + + private static final String cris_client_id = "APP-X7DMY3AKDXK34RVS"; + private static final String cris_client_secret = "d622a047-deef-4368-a1e8-223101911563"; + private static final String external_client_id = "APP-JFDCD0I82SXO91F9"; + private static final String external_client_secret = "a205bf62-e4b1-4d22-8a4b-2395e493358a"; + + private static final String[] profiles = { "0000-0002-4464-361X", + "0000-0002-9007-3574", "0000-0002-5507-2082", "0000-0002-9055-9726" }; + + private static final String[] cris_profile_secrets = { + "dd90ad6f-3ec2-4a0a-8762-725f95389b22", + "4161f065-be8a-4736-b550-cde398028128", + "c8962118-bd00-4bd2-8784-8b7bf0c3b84b", + "7421f8d5-3173-4344-994e-e669d991c1d9" }; + private static final String[] external_profile_secrets = { + "ba052ca1-b65b-41d4-969a-bc97a0f67386", + "f0b19290-0acf-4b35-b0c3-9da74d6be805", + "59e45d2f-d7e0-47fa-b6a1-31e0066781f3", + "ac790728-36d6-455d-9469-deb6fbaf0589" }; + + /** + * Retrieves an ORCID client for a given user profile using the local CRIS + * Member API client id. + * + * @param profile + * the ORCID user profile + * @return the client for the local CRIS source to manage the user profile + */ + public static ORCIDClient getCRISClient(Profile profile) { + ORCIDClientImpl orcidClient = new ORCIDClientImpl( + orcid_login_uri, orcid_api_uri, cris_client_id, cris_client_secret, orcid_redirect_uri, + TestClients.getCRISAccessToken(profile.value)); + return orcidClient; + } + + /** + * Retrieves an ORCID client for a given user profile using the a Member API + * client id that is not the local CRIS (used to simulate an external + * source). + * + * @param profile + * the ORCID user profile + * @return the client for the external source to manage the user profile + */ + public static ORCIDClient getExternalClient(Profile profile) { + ORCIDClientImpl orcidClient = new ORCIDClientImpl( + orcid_login_uri, orcid_api_uri, external_client_id, external_client_secret, orcid_redirect_uri, + TestClients.getExternalAccessToken(profile.value)); + return orcidClient; + } + + /** + * Retrieves the access token to a given user profile for the external + * source Member API client id. + * + * @param i + * the user profile + * @return the access token for the external source to manage the user + * profile + */ + private static OrcidAccessToken getCRISAccessToken(int i) { + OrcidAccessToken orcidToken = new OrcidAccessToken(); + + orcidToken.setAccess_token(cris_profile_secrets[i]); + orcidToken.setOrcid(profiles[i]); + + return orcidToken; + } + + /** + * Retrieves the access token to a given user profile for the local CRIS + * Member API client id. + * + * @param i + * the user profile + * @return the access token for local CRIS to manage the user profile + */ + private static OrcidAccessToken getExternalAccessToken(int i) { + OrcidAccessToken orcidToken = new OrcidAccessToken(); + + orcidToken.setAccess_token(external_profile_secrets[i]); + orcidToken.setOrcid(profiles[i]); + + return orcidToken; + } + +} diff --git a/src/test/java/pt/ptcris/test/TestHelper.java b/src/test/java/pt/ptcris/test/TestHelper.java new file mode 100644 index 0000000..92d0415 --- /dev/null +++ b/src/test/java/pt/ptcris/test/TestHelper.java @@ -0,0 +1,357 @@ +/* + * Copyright (c) 2016, 2017 PTCRIS - FCT|FCCN and others. + * Licensed under MIT License + * http://ptcris.pt + * + * This copyright and license information (including a link to the full license) + * shall be included in its entirety in all copies or substantial portion of + * the software. + */ +package pt.ptcris.test; + +import java.math.BigInteger; +import java.util.logging.ConsoleHandler; +import java.util.logging.Level; +import java.util.logging.Logger; +import java.util.logging.SimpleFormatter; + +import org.um.dsi.gavea.orcid.model.common.ElementSummary; +import org.um.dsi.gavea.orcid.model.common.ExternalId; +import org.um.dsi.gavea.orcid.model.common.ExternalIds; +import org.um.dsi.gavea.orcid.model.common.FuzzyDate; +import org.um.dsi.gavea.orcid.model.common.Iso3166Country; +import org.um.dsi.gavea.orcid.model.common.OrganizationAddress; +import org.um.dsi.gavea.orcid.model.common.FuzzyDate.Year; +import org.um.dsi.gavea.orcid.model.common.Organization; +import org.um.dsi.gavea.orcid.model.common.RelationshipType; +import org.um.dsi.gavea.orcid.model.funding.Funding; +import org.um.dsi.gavea.orcid.model.funding.FundingTitle; +import org.um.dsi.gavea.orcid.model.funding.FundingType; +import org.um.dsi.gavea.orcid.model.work.Work; +import org.um.dsi.gavea.orcid.model.work.WorkTitle; +import org.um.dsi.gavea.orcid.model.work.WorkType; + +import pt.ptcris.handlers.ProgressHandler; +import pt.ptcris.utils.ORCIDHelper; + +public class TestHelper { + + private static Tester progressHandler; + + public static Work work(BigInteger key, String meta) { + Work work = new Work(); + + ExternalIds uids = new ExternalIds(); + work.setExternalIds(uids); + + work.setPutCode(key); + + if (meta != null) { + WorkTitle title = new WorkTitle(); + title.setTitle("Meta-data " + meta); + work.setTitle(title); + + if (meta.equals("0")) + work.setType(WorkType.JOURNAL_ARTICLE); + else + work.setType(WorkType.CONFERENCE_PAPER); + + FuzzyDate date = new FuzzyDate(new Year("201" + meta.charAt(meta.length()-1)), null, null); + work.setPublicationDate(date); + + } + + return work; + } + + public static Work workDOI(BigInteger key, String meta, String doi) { + Work work = work(key, meta); + + ExternalId e1 = new ExternalId(); + e1.setExternalIdRelationship(RelationshipType.SELF); + e1.setExternalIdValue(doi); + e1.setExternalIdType("doi"); + + work.getExternalIds().getExternalId().add(e1); + + return work; + } + + public static Work workUnk(BigInteger key, String meta, String doi) { + Work work = work(key, meta); + + ExternalId e1 = new ExternalId(); + e1.setExternalIdRelationship(RelationshipType.SELF); + e1.setExternalIdValue(doi); + e1.setExternalIdType("ukn"); + + work.getExternalIds().getExternalId().add(e1); + + return work; + } + + public static Work workDOIUnk(BigInteger key, String meta, String doi, String eid) { + Work work = workDOI(key, meta, doi); + + ExternalId e = new ExternalId(); + e.setExternalIdRelationship(RelationshipType.SELF); + e.setExternalIdValue(eid); + e.setExternalIdType("wosuid-"); + + work.getExternalIds().getExternalId().add(e); + return work; + } + + public static Work workOtherOtherDOI(BigInteger key, String meta, String doi, String eid, String eid2) { + Work work = workDOI(key, meta, doi); + + ExternalId e = new ExternalId(); + e.setExternalIdRelationship(RelationshipType.SELF); + e.setExternalIdValue(eid); + e.setExternalIdType("other-id"); + + work.getExternalIds().getExternalId().add(e); + + ExternalId e1 = new ExternalId(); + e1.setExternalIdRelationship(RelationshipType.SELF); + e1.setExternalIdValue(eid2); + e1.setExternalIdType("other-id"); + + work.getExternalIds().getExternalId().add(e1); + + return work; + } + + public static Work workHANDLE(BigInteger key, String meta, String handle) { + Work work = work(key, meta); + + ExternalId e1 = new ExternalId(); + e1.setExternalIdRelationship(RelationshipType.SELF); + e1.setExternalIdValue(handle); + e1.setExternalIdType("handle"); + + work.getExternalIds().getExternalId().add(e1); + + +// ExternalId e2 = new ExternalId(); +// e2.setExternalIdRelationship(RelationshipType.PART_OF); +// e2.setExternalIdValue("11111"); +// e2.setExternalIdType("isbn"); +// +// work.getExternalIds().getExternalId().add(e2); + + return work; + } + + public static Work workDOIEID(BigInteger key, String meta, String doi, String eid) { + Work work = workDOI(key, meta, doi); + + ExternalId e = new ExternalId(); + e.setExternalIdRelationship(RelationshipType.SELF); + e.setExternalIdValue(eid); + e.setExternalIdType("eid"); + + work.getExternalIds().getExternalId().add(e); + return work; + } + + public static Work workDOIHANDLE(BigInteger key, String meta, String doi, String handle) { + Work work = workDOI(key, meta, doi); + + ExternalId e = new ExternalId(); + e.setExternalIdRelationship(RelationshipType.SELF); + e.setExternalIdValue(handle); + e.setExternalIdType("handle"); + + work.getExternalIds().getExternalId().add(e); + + ExternalId e2 = new ExternalId(); + e2.setExternalIdRelationship(RelationshipType.PART_OF); + e2.setExternalIdValue("11111"); + e2.setExternalIdType("isbn"); + + work.getExternalIds().getExternalId().add(e2); + + return work; + } + + public static Work workEIDHANDLE(BigInteger key, String meta, String eid, String handle) { + Work work = workHANDLE(key, meta, handle); + + ExternalId e = new ExternalId(); + e.setExternalIdRelationship(RelationshipType.SELF); + e.setExternalIdValue(eid); + e.setExternalIdType("eid"); + + work.getExternalIds().getExternalId().add(e); + + return work; + } + + public static Work workDOIEIDHANDLE(BigInteger key, String meta, String doi, String eid, String handle) { + Work work = workDOIEID(key, meta, doi, eid); + + ExternalId e2 = new ExternalId(); + e2.setExternalIdRelationship(RelationshipType.SELF); + e2.setExternalIdValue(handle); + e2.setExternalIdType("handle"); + + ExternalId e3 = new ExternalId(); + e3.setExternalIdRelationship(RelationshipType.PART_OF); + e3.setExternalIdValue("11111"); + e3.setExternalIdType("isbn"); + work.getExternalIds().getExternalId().add(e3); + + work.getExternalIds().getExternalId().add(e2); + + return work; + } + + public static Work workDOIDOIEIDHANDLE(BigInteger key, String meta, String doi1, String doi2, String eid, String handle) { + Work work = workDOIEIDHANDLE(key, meta, doi1, eid, handle); + + ExternalId e1 = new ExternalId(); + e1.setExternalIdRelationship(RelationshipType.SELF); + e1.setExternalIdValue(doi2); + e1.setExternalIdType("doi"); + + work.getExternalIds().getExternalId().add(e1); + + return work; + } + + public static Funding funding(BigInteger key, String meta) { + Funding work = new Funding(); + + ExternalIds uids = new ExternalIds(); + work.setExternalIds(uids); + + work.setPutCode(key); + + if (meta != null) { + FundingTitle title = new FundingTitle(); + title.setTitle("Meta-data " + meta); + work.setTitle(title); + + work.setOrganization(new Organization("Agency", new OrganizationAddress("Braga",null,Iso3166Country.PT), null)); + + if (meta.equals("0")) + work.setType(FundingType.CONTRACT); + else + work.setType(FundingType.GRANT); + + FuzzyDate date = new FuzzyDate(new Year("201" + meta.charAt(meta.length()-1)), null, null); + work.setStartDate(date); + + } + + return work; + } + + public static Funding fundingNmb(BigInteger key, String meta, String doi) { + Funding work = funding(key, meta); + + ExternalId e1 = new ExternalId(); + e1.setExternalIdRelationship(RelationshipType.SELF); + e1.setExternalIdValue(doi); + e1.setExternalIdType("grant_number"); + + work.getExternalIds().getExternalId().add(e1); + + return work; + } + + public static Funding fundingNmbNmb(BigInteger key, String meta, String doi1, String doi2) { + Funding work = fundingNmb(key, meta, doi1); + + ExternalId e1 = new ExternalId(); + e1.setExternalIdRelationship(RelationshipType.SELF); + e1.setExternalIdValue(doi2); + e1.setExternalIdType("grant_number"); + + work.getExternalIds().getExternalId().add(e1); + + return work; + } + + public static Funding fundingNmbNmbNmb(BigInteger key, String meta, String doi1, String doi2, String doi3) { + Funding work = fundingNmbNmb(key, meta, doi1, doi2); + + ExternalId e1 = new ExternalId(); + e1.setExternalIdRelationship(RelationshipType.SELF); + e1.setExternalIdValue(doi3); + e1.setExternalIdType("grant_number"); + work.getExternalIds().getExternalId().add(e1); + + ExternalId e3 = new ExternalId(); + e3.setExternalIdRelationship(RelationshipType.PART_OF); + e3.setExternalIdValue("11111"); + e3.setExternalIdType("grant_number"); + work.getExternalIds().getExternalId().add(e3); + + return work; + } + + public static Funding fundingNmbNmbNmbNmb(BigInteger key, String meta, String doi1, String doi2, String doi3, String doi4) { + Funding work = fundingNmbNmbNmb(key, meta, doi1, doi2, doi3); + + ExternalId e1 = new ExternalId(); + e1.setExternalIdRelationship(RelationshipType.SELF); + e1.setExternalIdValue(doi4); + e1.setExternalIdType("grant_number"); + + work.getExternalIds().getExternalId().add(e1); + + return work; + } + + public static Funding fundingIgn(BigInteger key, String meta, String nmb) { + Funding work = new Funding(); + + ExternalIds uids = new ExternalIds(); + work.setExternalIds(uids); + + work.setPutCode(key); + + if (meta != null) { + FundingTitle title = new FundingTitle(); + title.setTitle("Meta-data " + meta); + work.setTitle(title); + + work.setOrganization(new Organization("Agency", new OrganizationAddress("Braga",null,Iso3166Country.PT), null)); + + if (meta.equals("0")) + work.setType(FundingType.AWARD); + + FuzzyDate date = new FuzzyDate(new Year("201" + meta.charAt(meta.length()-1)), null, null); + work.setStartDate(date); + + } + + ExternalId e1 = new ExternalId(); + e1.setExternalIdRelationship(RelationshipType.SELF); + e1.setExternalIdValue(nmb); + e1.setExternalIdType("grant_number"); + work.getExternalIds().getExternalId().add(e1); + + return work; + } + + + public static ProgressHandler handler() { + if (progressHandler == null) { + ConsoleHandler handler = new ConsoleHandler(); + handler.setFormatter(new SimpleFormatter()); + handler.setLevel(Level.ALL); + Logger.getLogger(Tester.class.getName()).setLevel(Level.ALL); + Logger.getLogger(Tester.class.getName()).addHandler(handler); + progressHandler = new Tester(); + } + return progressHandler; + } + + public static > void cleanUp(ORCIDHelper helper) throws Exception { + helper.deleteAllSourced(); + } + +} diff --git a/src/test/java/pt/ptcris/test/Tester.java b/src/test/java/pt/ptcris/test/Tester.java new file mode 100644 index 0000000..768be81 --- /dev/null +++ b/src/test/java/pt/ptcris/test/Tester.java @@ -0,0 +1,76 @@ +/* + * Copyright (c) 2016, 2017 PTCRIS - FCT|FCCN and others. + * Licensed under MIT License + * http://ptcris.pt + * + * This copyright and license information (including a link to the full license) + * shall be included in its entirety in all copies or substantial portion of + * the software. + */ +package pt.ptcris.test; + +import java.util.logging.Level; +import java.util.logging.Logger; + +import pt.ptcris.handlers.ProgressHandler; + +/** + * A simple implementation of the progress handler to log the execution of + * PTCRISync procedures. + */ +public class Tester implements ProgressHandler { + private static Logger logger = Logger.getLogger(Tester.class.getName()); + private int max; + private int step; + + /** {@inheritDoc} */ + @Override + public void setProgress(int progress) { + logger.fine("Current progress: " + progress + "%"); + } + + /** {@inheritDoc} */ + @Override + public void setCurrentStatus(String message) { + logger.fine("Task: " + message); + } + + /** {@inheritDoc} */ + @Override + public void setCurrentStatus(String message, int n) { + max = n; + step = 0; + logger.fine("Task: " + message + " (" + n + ")"); + progress(); + } + + /** {@inheritDoc} */ + @Override + public void sendError(String message) { + logger.log(Level.SEVERE, "ERROR: " + message); + } + + /** {@inheritDoc} */ + @Override + public void done() { + logger.fine("Done."); + } + + /** {@inheritDoc} */ + @Override + public void step() { + step++; + progress(); + } + + /** {@inheritDoc} */ + @Override + public void step(int s) { + step+=s; + progress(); + } + + private void progress() { + setProgress((step*100)/max); + } +} diff --git a/src/test/java/pt/ptcris/test/grouper/GrouperTest.java b/src/test/java/pt/ptcris/test/grouper/GrouperTest.java new file mode 100644 index 0000000..fc247ba --- /dev/null +++ b/src/test/java/pt/ptcris/test/grouper/GrouperTest.java @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2016, 2017 PTCRIS - FCT|FCCN and others. + * Licensed under MIT License + * http://ptcris.pt + * + * This copyright and license information (including a link to the full license) + * shall be included in its entirety in all copies or substantial portion of + * the software. + */ +package pt.ptcris.test.grouper; + +import static org.junit.Assert.*; + +import java.math.BigInteger; +import java.util.ArrayList; +import java.util.List; + +import org.um.dsi.gavea.orcid.model.work.Work; + +import pt.ptcris.PTCRISGrouper; +import pt.ptcris.grouper.ActivityGroup; +import pt.ptcris.test.TestHelper; + +public class GrouperTest { + public static void main(String[] args) { + Work work1 = TestHelper.workDOIEID(BigInteger.valueOf(1), "1", "1", "1"); + Work work2 = TestHelper.workDOIEID(BigInteger.valueOf(2), "1", "0", "0"); + Work work3 = TestHelper.workDOIEID(BigInteger.valueOf(3), "1", "1", "0"); + Work work4 = TestHelper.workDOIEID(BigInteger.valueOf(4), "1", "4", "3"); + Work work5 = TestHelper.workDOIEID(BigInteger.valueOf(5), "1", "4", "5"); + Work work6 = TestHelper.work(BigInteger.valueOf(6), "1"); + Work work7 = TestHelper.work(BigInteger.valueOf(7), "2"); + + List works = new ArrayList(); + works.add(work1); + works.add(work2); + works.add(work3); + works.add(work4); + works.add(work5); + works.add(work6); + works.add(work7); + + List> groups = PTCRISGrouper.group(works, new StdWorkComparator()); + + assertEquals(groups.size(), 4); + + return; + } +} diff --git a/src/test/java/pt/ptcris/test/grouper/IntegerComparator.java b/src/test/java/pt/ptcris/test/grouper/IntegerComparator.java new file mode 100644 index 0000000..18c787b --- /dev/null +++ b/src/test/java/pt/ptcris/test/grouper/IntegerComparator.java @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2016, 2017 PTCRIS - FCT|FCCN and others. + * Licensed under MIT License + * http://ptcris.pt + * + * This copyright and license information (including a link to the full license) + * shall be included in its entirety in all copies or substantial portion of + * the software. + */ +package pt.ptcris.test.grouper; + +import static org.junit.Assert.assertEquals; + +import java.util.Arrays; +import java.util.List; + +import pt.ptcris.PTCRISGrouper; +import pt.ptcris.grouper.ActivityComparator; +import pt.ptcris.grouper.ActivityGroup; + +/** + * An integer comparator, shows that activities can be generic objects. + * + */ +public class IntegerComparator extends ActivityComparator { + + @Override + public int threshold() { + return 90; + } + + @Override + public float compare(Integer i1, Integer i2) { + float res = Math.abs(i1-i2); + res = res / ((i1+i2)/2); + res = 100*(1-res); + return res; + } + + public static void main(String[] args) { + Integer[] is = {50, 70, 75, 51, 73, 42}; + + List> groups = PTCRISGrouper.group(Arrays.asList(is), new IntegerComparator()); + + assertEquals(groups.size(), 3); + } + +} diff --git a/src/test/java/pt/ptcris/test/grouper/StdWorkComparator.java b/src/test/java/pt/ptcris/test/grouper/StdWorkComparator.java new file mode 100644 index 0000000..a5070c2 --- /dev/null +++ b/src/test/java/pt/ptcris/test/grouper/StdWorkComparator.java @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2016, 2017 PTCRIS - FCT|FCCN and others. + * Licensed under MIT License + * http://ptcris.pt + * + * This copyright and license information (including a link to the full license) + * shall be included in its entirety in all copies or substantial portion of + * the software. + */ +package pt.ptcris.test.grouper; + +import org.um.dsi.gavea.orcid.model.work.Work; + +import pt.ptcris.grouper.ActivityComparator; +import pt.ptcris.utils.ExternalIdsDiff; +import pt.ptcris.utils.ORCIDHelper; + +/** + * A work comparator whose behavior should be the same as the standard ORCID + * grouper: works are considered similar if they share any external identifier. + * + */ +public class StdWorkComparator extends ActivityComparator { + + @Override + public int threshold() { + return 0; + } + + @Override + public float compare(Work w1, Work w2) { + ExternalIdsDiff diff = new ExternalIdsDiff( + ORCIDHelper.factoryStaticWorks().getSelfExternalIdsE(w1), + ORCIDHelper.factoryStaticWorks().getSelfExternalIdsE(w2)); + return diff.same.size(); + } + +} diff --git a/src/test/java/pt/ptcris/test/scenarios/AllScenarios.java b/src/test/java/pt/ptcris/test/scenarios/AllScenarios.java new file mode 100644 index 0000000..dd85792 --- /dev/null +++ b/src/test/java/pt/ptcris/test/scenarios/AllScenarios.java @@ -0,0 +1,71 @@ +/* + * Copyright (c) 2016, 2017 PTCRIS - FCT|FCCN and others. + * Licensed under MIT License + * http://ptcris.pt + * + * This copyright and license information (including a link to the full license) + * shall be included in its entirety in all copies or substantial portion of + * the software. + */ +package pt.ptcris.test.scenarios; + +import org.junit.runner.RunWith; +import org.junit.runners.Suite; + +/** + * Run every scenarios defined in version 0.5 of the PTCRISync specification, + * as well as additional ones dealing with technical issues. + * + * @see ScenarioFunding + */ +@RunWith(Suite.class) +@Suite.SuiteClasses({ + Scenario01.class, + Scenario02.class, + Scenario03.class, + Scenario04.class, + Scenario05.class, + Scenario06.class, + Scenario07.class, + Scenario08.class, + Scenario09.class, + Scenario10.class, + Scenario11.class, + Scenario12.class, + Scenario13.class, + Scenario14.class, + Scenario15.class, + Scenario16.class, + Scenario17.class, + Scenario18.class, + Scenario19.class, + Scenario20.class, + ScenarioInvalidLocal1.class, + ScenarioInvalidLocal2.class, + ScenarioF01.class, + ScenarioF02.class, + ScenarioF03.class, + ScenarioF04.class, + ScenarioF05.class, + ScenarioF06.class, + ScenarioF07.class, + ScenarioF08.class, + ScenarioF09.class, + ScenarioF10.class, + ScenarioF11.class, + ScenarioF12.class, + ScenarioF13.class, + ScenarioF14.class, + ScenarioF15.class, + ScenarioF16.class, + ScenarioF17.class, + ScenarioF18.class, + ScenarioF19.class, + ScenarioF20.class, + ScenarioFIgnoredTypes.class, + ScenarioFInvalidLocal.class, +// ScenarioPerformance.class, +// ScenarioPerformance2.class +}) + +public class AllScenarios {} \ No newline at end of file diff --git a/src/test/java/pt/ptcris/test/scenarios/Scenario.java b/src/test/java/pt/ptcris/test/scenarios/Scenario.java new file mode 100644 index 0000000..6dece5d --- /dev/null +++ b/src/test/java/pt/ptcris/test/scenarios/Scenario.java @@ -0,0 +1,331 @@ +/* + * Copyright (c) 2016, 2017 PTCRIS - FCT|FCCN and others. + * Licensed under MIT License + * http://ptcris.pt + * + * This copyright and license information (including a link to the full license) + * shall be included in its entirety in all copies or substantial portion of + * the software. + */ +package pt.ptcris.test.scenarios; + +import static org.junit.Assert.*; + +import java.math.BigInteger; +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.um.dsi.gavea.orcid.client.exception.OrcidClientException; +import org.um.dsi.gavea.orcid.model.activities.WorkGroup; +import org.um.dsi.gavea.orcid.model.work.Work; +import org.um.dsi.gavea.orcid.model.work.WorkSummary; +import org.um.dsi.gavea.orcid.model.work.WorkType; + +import pt.ptcris.PTCRISync; +import pt.ptcris.PTCRISyncResult; +import pt.ptcris.handlers.ProgressHandler; +import pt.ptcris.test.TestHelper; +import pt.ptcris.utils.ORCIDHelper; +import pt.ptcris.utils.ORCIDWorkHelper; + +/** + * Represents a scenario as defined in the PTCRISync specification. Each + * scenario consists of a pre-state for the CRIS and ORCID profiles, an update + * on either profile and the result of running the import and/or export + * procedures to restore consistency. + * + * TODO: Scenarios with notifications in the pre-state (7 and 16) must be + * handled with caution, since modifications are not explicit in the current + * version of the system. + * + * TODO: Scenarios that consider the promotion/demotion of preferred works (10 + * and 11) are not to be tested programmatically as they cannot be selected this + * way. + * + * @see https://ptcris.pt/hub-ptcris/ + */ +public abstract class Scenario { + private List localWorks, exportWorks; + private static ORCIDHelper externalClient, crisClient; + + @Before + public void setUpClass() throws Exception { + crisClient = crisClient(); + externalClient = externalClient(); + TestHelper.cleanUp(crisClient); + TestHelper.cleanUp(externalClient); + externalClient.add(setupORCIDExternalWorks(),null); + crisClient.add(setupORCIDCRISWorks(),null); + this.localWorks = setupLocalWorks(); + this.exportWorks = exportLocalWorks(); + this.localWorks.addAll(this.exportWorks); + } + + @Test + public void test() throws OrcidClientException, InterruptedException { + ProgressHandler handler = TestHelper.handler(); + + handler.setCurrentStatus(this.getClass().getName() + " start"); + long startTime = System.currentTimeMillis(); + Map> codes = PTCRISync.exportWorks(crisClient.client, exportWorks, handler); + + List worksToImport = PTCRISync.importWorks(crisClient.client, localWorks, handler); + List worksToUpdate = PTCRISync.importWorkUpdates(crisClient.client, localWorks, handler); + Map> worksToInvalid = PTCRISync.importInvalidWorks( + crisClient.client, localWorks, handler); + int worksToImportCounter = PTCRISync.importWorkCounter(crisClient.client, localWorks, handler); + long time = System.currentTimeMillis() - startTime; + handler.setCurrentStatus(this.getClass().getName() + ": " + time + "ms"); + + List allImports = new ArrayList(worksToImport); + allImports.addAll(worksToUpdate); + localWorks.addAll(allImports); + + List expectedLocal = expectedImportedWorks(); + List expectedInvalid = expectedImportedInvalidWorks(); + List expectedORCID = expectedORCIDCRISWorks(); + List sourcedORCID = crisClient.getSourcedSummaries(); + + assertEquals(worksToImport.size(), worksToImportCounter); + + assertEquals(expectedLocal.size(), allImports.size()); + assertTrue(correctImports(expectedLocal, allImports)); + + assertEquals(expectedInvalid.size(), worksToInvalid.size()); + assertTrue(correctInvalids(worksToInvalid)); + assertTrue(correctImports(expectedInvalid, worksToInvalid.keySet())); + + assertEquals(expectedORCID.size(), sourcedORCID.size()); + assertTrue(correctCodes(codes)); + assertTrue(correctExport(expectedORCID, sourcedORCID)); + } + + @After + public void tearDownClass() throws Exception { + TestHelper.cleanUp(crisClient); + TestHelper.cleanUp(externalClient); + } + + /** + * Defines the CRIS-sourced ORCID works for the fixture of the scenario, + * i.e., the works that initially exist in the user profile added by the + * CRIS. + * + * @return the set of CRIS works for the fixture + */ + List setupORCIDCRISWorks() { + return new ArrayList(); + } + + /** + * Defines the non CRIS-sourced ORCID works for the fixture of the scenario, + * i.e., the works that initially exist in the user profile added by other + * external sources. + * + * @return the external works for the fixture + */ + List setupORCIDExternalWorks() { + return new ArrayList(); + } + + /** + * Defines the local CRIS works that are not to be exported. The import + * tests will additionally consider those set to be + * {@link #exportLocalWorks() exported}. + * + * @return the local works that is not to be exported + */ + List setupLocalWorks() { + return new ArrayList(); + } + + /** + * Defines the local CRIS works that are to be exported. The import tests + * will additionally consider those not set to be {@link #setupLocalWorks() + * exported}. + * + * @return the local works that is to be exported + */ + List exportLocalWorks() { + return new ArrayList(); + } + + /** + * The CRIS-source works that are expected to be in ORCID after the + * {@link PTCRISync#export(pt.ptcris.ORCIDClient, List, ProgressHandler) + * export} synchronization procedure. + * + * @return the expected CRIS-source works + */ + List expectedORCIDCRISWorks() { + return new ArrayList(); + } + + /** + * The expected outcome for each of the works that were to be exported for + * the + * {@link PTCRISync#export(pt.ptcris.ORCIDClient, List, ProgressHandler) + * export} synchronization procedure. + * + * @param putcode + * the put-code of a work provided by {#link + * {@link #exportLocalWorks()} + * @return the expected CRIS-source works + */ + Set expectedExportCodes(BigInteger putcode) { + Set res = new HashSet(); + res.add(PTCRISyncResult.ADDOK); + return res; + } + + /** + * The new works that are expected to be detected in ORCID by the + * {@link PTCRISync#importNews(pt.ptcris.ORCIDClient, List, ProgressHandler) + * import} synchronization procedure. + * + * @return the expected CRIS-source works + */ + List expectedImportedWorks() { + return new ArrayList(); + } + + /** + * The new invalid works that are expected to be detected in ORCID by the + * {@link PTCRISync#importInvalid(pt.ptcris.ORCIDClient, List, ProgressHandler) + * import invalid} synchronization procedure. + * + * @return the expected CRIS-source works + */ + List expectedImportedInvalidWorks() { + return new ArrayList(); + } + + /** + * The expected invalidity reasons for the new invalid works detected in + * ORCID by the + * {@link PTCRISync#importInvalid(pt.ptcris.ORCIDClient, List, ProgressHandler) + * import invalid} synchronization procedure. + * + * @param putcode + * the put-code of a work returned by {#link + * {@link #expectedImportedInvalidWorks()} + * @return the expected reasons for invalidity + */ + Set expectedInvalidCodes(BigInteger putcode) { + return new HashSet(); + } + + /** + * Sets the client to use as the CRIS source. + * + * @return the CRIS source client + */ + abstract ORCIDHelper crisClient(); + + /** + * Sets the client to use as an external ORCID source. + * + * @return the external source client + */ + abstract ORCIDHelper externalClient(); + + /** + * Tests whether the effectively exported works are the ones expected. + * + * @param exported + * the effectively exported works + * @param expected + * the expected works + * @return whether the exported works were the expected + */ + private static boolean correctExport(Collection exported, Collection expected) { + Set ws1 = new HashSet(exported); + Set ws2 = new HashSet(expected); + + for (Work work1 : exported) { + Iterator it = expected.iterator(); + boolean found = false; + while (it.hasNext() && !found) { + WorkSummary work2 = it.next(); + if (new ORCIDWorkHelper(null).isUpToDateS(work1, work2)) { + ws1.remove(work1); + ws2.remove(work2); + found = true; + } + } + } + return ws1.isEmpty() && ws2.isEmpty(); + } + + /** + * Tests whether the effectively export outcomes are the ones + * expected according to {@link #expectedExportCodes(BigInteger)}. + * + * @param reasons + * the effectively export outcome + * @return whether the export outcome was the expected + */ + private boolean correctCodes(Map> results) { + for (BigInteger id : results.keySet()) + if (!expectedExportCodes(id).contains(results.get(id).code)) { + TestHelper.handler().sendError("Was "+results.get(id).code); + return false; + } + return true; + } + + /** + * Tests whether the effectively imported works are the ones expected. + * + * @param expected + * the effectively imported works + * @param imported + * the expected works + * @return whether the imported works were the expected + */ + private static boolean correctImports(Collection expected, Collection imported) { + Set ws1 = new HashSet(expected); + Set ws2 = new HashSet(imported); + + for (Work work1 : expected) { + BigInteger localKey1 = ORCIDHelper.getActivityLocalKey(work1); + Iterator it = ws2.iterator(); + boolean found = false; + while (it.hasNext() && !found) { + Work work2 = it.next(); + BigInteger localKey2 = ORCIDHelper.getActivityLocalKey(work2); + if (new ORCIDWorkHelper(null).isUpToDateE(work1, work2) + && ((localKey1 == null && localKey2 == null) || (localKey1.equals(localKey2)))) { + ws1.remove(work1); + ws2.remove(work2); + found = true; + } + } + } + return ws1.isEmpty() && ws2.isEmpty(); + } + + /** + * Tests whether the effectively imported invalidity reasons are the ones + * expected according to {@link #expectedInvalidCodes(BigInteger)}. + * + * @param reasons + * the effectively imported reasons for invalidity + * @return whether the invalidity reasons were the expected + */ + private boolean correctInvalids(Map> codes) { + for (Work work : codes.keySet()) + if (!codes.get(work).equals(expectedInvalidCodes(work.getPutCode()))) + return false; + return true; + } + +} diff --git a/src/test/java/pt/ptcris/test/scenarios/Scenario01.java b/src/test/java/pt/ptcris/test/scenarios/Scenario01.java new file mode 100644 index 0000000..042f9dc --- /dev/null +++ b/src/test/java/pt/ptcris/test/scenarios/Scenario01.java @@ -0,0 +1,85 @@ +/* + * Copyright (c) 2016, 2017 PTCRIS - FCT|FCCN and others. + * Licensed under MIT License + * http://ptcris.pt + * + * This copyright and license information (including a link to the full license) + * shall be included in its entirety in all copies or substantial portion of + * the software. + */ +package pt.ptcris.test.scenarios; + +import java.math.BigInteger; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +import org.um.dsi.gavea.orcid.model.work.Work; + +import pt.ptcris.test.TestHelper; +import pt.ptcris.test.TestClients; +import pt.ptcris.test.TestClients.Profile; +import pt.ptcris.utils.ORCIDHelper; +import pt.ptcris.utils.ORCIDWorkHelper; + +/** + * Scenario 1 of the PTCRISync specification v0.4.3, tests import. + * + * Features: + * creation notification + * + * TODO: this scenario does not exactly represent the one from the specification + * as this would require that the fixture work was set as the preferred, which + * is impossible programmatically. This does not affect the scenario and one of + * the user-sourced is selected instead. + * + * @see Scenario + */ +public class Scenario01 extends Scenario { + + /** {@inheritDoc} */ + @Override + List setupORCIDExternalWorks() { + List works = new ArrayList(); + works.add(TestHelper.workDOIEID(null, "0", "0", "0")); + return works; + } + + /** {@inheritDoc} */ + @Override + List expectedImportedWorks() { + List works = new ArrayList(); + works.add(TestHelper.workDOIEIDHANDLE(null, "1", "0", "0", "1")); + return works; + } + + /** {@inheritDoc} */ + @Override + List expectedImportedInvalidWorks() { + List works = new ArrayList(); + works.add(TestHelper.work(null, "0")); + return works; + } + + /** {@inheritDoc} */ + @Override + Set expectedInvalidCodes(BigInteger putCode) { + Set res = new HashSet(); + res.add(ORCIDHelper.INVALID_EXTERNALIDENTIFIERS); + return res; + } + + /** {@inheritDoc} */ + @Override + ORCIDWorkHelper crisClient() { + return new ORCIDWorkHelper(TestClients.getCRISClient(Profile.ONEVALIDWORKS)); + } + + /** {@inheritDoc} */ + @Override + ORCIDWorkHelper externalClient() { + return new ORCIDWorkHelper(TestClients.getExternalClient(Profile.ONEVALIDWORKS)); + } + +} diff --git a/src/test/java/pt/ptcris/test/scenarios/Scenario02.java b/src/test/java/pt/ptcris/test/scenarios/Scenario02.java new file mode 100644 index 0000000..b38fab4 --- /dev/null +++ b/src/test/java/pt/ptcris/test/scenarios/Scenario02.java @@ -0,0 +1,93 @@ +/* + * Copyright (c) 2016, 2017 PTCRIS - FCT|FCCN and others. + * Licensed under MIT License + * http://ptcris.pt + * + * This copyright and license information (including a link to the full license) + * shall be included in its entirety in all copies or substantial portion of + * the software. + */ +package pt.ptcris.test.scenarios; + +import java.math.BigInteger; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +import org.um.dsi.gavea.orcid.model.work.Work; + +import pt.ptcris.test.TestHelper; +import pt.ptcris.test.TestClients; +import pt.ptcris.test.TestClients.Profile; +import pt.ptcris.utils.ORCIDHelper; +import pt.ptcris.utils.ORCIDWorkHelper; + +/** + * Scenario 2 of the PTCRISync specification v0.4.3, tests import. + * + * Features: + * modification notifications with {same,more} + * + * TODO: this scenario does not exactly represent the one from the specification + * as this would require that the fixture work was set as the preferred, which + * is impossible programmatically. This does not affect the scenario and one of + * the user-sourced is selected instead. + * + * @see Scenario + */ +public class Scenario02 extends Scenario { + + /** {@inheritDoc} */ + @Override + List setupORCIDExternalWorks() { + List works = new ArrayList(); + works.add(TestHelper.workDOIEID(null, "0", "0", "0")); + works.add(TestHelper.workDOIHANDLE(null, "1", "1", "1")); + return works; + } + + /** {@inheritDoc} */ + @Override + List setupLocalWorks() { + List works = new ArrayList(); + works.add(TestHelper.workDOIEIDHANDLE(BigInteger.valueOf(2), "0", "0", "0", "1")); + return works; + } + + /** {@inheritDoc} */ + @Override + List expectedImportedWorks() { + List works = new ArrayList(); + works.add(TestHelper.workDOI(BigInteger.valueOf(2), null, "1")); + return works; + } + + /** {@inheritDoc} */ + @Override + List expectedImportedInvalidWorks() { + List works = new ArrayList(); + works.add(TestHelper.work(null, "0")); + return works; + } + + /** {@inheritDoc} */ + @Override + Set expectedInvalidCodes(BigInteger putCode) { + Set res = new HashSet(); + res.add(ORCIDHelper.INVALID_EXTERNALIDENTIFIERS); + return res; + } + + /** {@inheritDoc} */ + @Override + ORCIDWorkHelper crisClient() { + return new ORCIDWorkHelper(TestClients.getCRISClient(Profile.ONEVALIDWORKS)); + } + + /** {@inheritDoc} */ + @Override + ORCIDWorkHelper externalClient() { + return new ORCIDWorkHelper(TestClients.getExternalClient(Profile.ONEVALIDWORKS)); + } +} diff --git a/src/test/java/pt/ptcris/test/scenarios/Scenario03.java b/src/test/java/pt/ptcris/test/scenarios/Scenario03.java new file mode 100644 index 0000000..1fbaed9 --- /dev/null +++ b/src/test/java/pt/ptcris/test/scenarios/Scenario03.java @@ -0,0 +1,85 @@ +/* + * Copyright (c) 2016, 2017 PTCRIS - FCT|FCCN and others. + * Licensed under MIT License + * http://ptcris.pt + * + * This copyright and license information (including a link to the full license) + * shall be included in its entirety in all copies or substantial portion of + * the software. + */ +package pt.ptcris.test.scenarios; + +import java.math.BigInteger; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +import org.um.dsi.gavea.orcid.model.work.Work; + +import pt.ptcris.test.TestHelper; +import pt.ptcris.test.TestClients; +import pt.ptcris.test.TestClients.Profile; +import pt.ptcris.utils.ORCIDHelper; +import pt.ptcris.utils.ORCIDWorkHelper; + +/** + * Scenario 3 of the PTCRISync specification v0.4.3, tests import. + * + * Features: + * + * TODO: this scenario does not exactly represent the one from the specification + * as this would require that the fixture work was set as the preferred, which + * is impossible programmatically. This does not affect the scenario and one of + * the user-sourced is selected instead. + * + * @see Scenario + */ +public class Scenario03 extends Scenario { + + /** {@inheritDoc} */ + @Override + List setupORCIDExternalWorks() { + List works = new ArrayList(); + works.add(TestHelper.workDOIEID(null, "0", "0", "0")); + works.add(TestHelper.workDOIHANDLE(null, "1", "1", "1")); + return works; + } + + /** {@inheritDoc} */ + @Override + List setupLocalWorks() { + List works = new ArrayList(); + works.add(TestHelper.workDOIDOIEIDHANDLE(BigInteger.valueOf(2), "0", "0", "1", "0", "1")); + return works; + } + + /** {@inheritDoc} */ + @Override + List expectedImportedInvalidWorks() { + List works = new ArrayList(); + works.add(TestHelper.work(null, "0")); + return works; + } + + /** {@inheritDoc} */ + @Override + Set expectedInvalidCodes(BigInteger putCode) { + Set res = new HashSet(); + res.add(ORCIDHelper.INVALID_EXTERNALIDENTIFIERS); + return res; + } + + /** {@inheritDoc} */ + @Override + ORCIDWorkHelper crisClient() { + return new ORCIDWorkHelper(TestClients.getCRISClient(Profile.ONEVALIDWORKS)); + } + + /** {@inheritDoc} */ + @Override + ORCIDWorkHelper externalClient() { + return new ORCIDWorkHelper(TestClients.getExternalClient(Profile.ONEVALIDWORKS)); + } + +} diff --git a/src/test/java/pt/ptcris/test/scenarios/Scenario04.java b/src/test/java/pt/ptcris/test/scenarios/Scenario04.java new file mode 100644 index 0000000..e606d9a --- /dev/null +++ b/src/test/java/pt/ptcris/test/scenarios/Scenario04.java @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2016, 2017 PTCRIS - FCT|FCCN and others. + * Licensed under MIT License + * http://ptcris.pt + * + * This copyright and license information (including a link to the full license) + * shall be included in its entirety in all copies or substantial portion of + * the software. + */ +package pt.ptcris.test.scenarios; + +import java.math.BigInteger; +import java.util.ArrayList; +import java.util.List; + +import org.um.dsi.gavea.orcid.model.work.Work; + +import pt.ptcris.test.TestHelper; +import pt.ptcris.test.TestClients; +import pt.ptcris.test.TestClients.Profile; +import pt.ptcris.utils.ORCIDWorkHelper; + +/** + * Scenario 4 of the PTCRISync specification v0.4.3, tests import. + * + * Features: + * + * TODO: this scenario does not exactly represent the one from the specification + * as this would require that the fixture work was set as the preferred, which + * is impossible programmatically. This does not affect the scenario and one of + * the user-sourced is selected instead. + * + * @see Scenario + */ +public class Scenario04 extends Scenario { + + /** {@inheritDoc} */ + @Override + List setupORCIDExternalWorks() { + List works = new ArrayList(); + works.add(TestHelper.workDOIEID(null, "0", "0", "0")); + return works; + } + + /** {@inheritDoc} */ + @Override + List setupLocalWorks() { + List works = new ArrayList(); + works.add(TestHelper.workDOIDOIEIDHANDLE(BigInteger.valueOf(2), "0", "0", "1", "0", "1")); + return works; + } + + /** {@inheritDoc} */ + @Override + ORCIDWorkHelper crisClient() { + return new ORCIDWorkHelper(TestClients.getCRISClient(Profile.TWOVALIDWORKS)); + } + + /** {@inheritDoc} */ + @Override + ORCIDWorkHelper externalClient() { + return new ORCIDWorkHelper(TestClients.getExternalClient(Profile.TWOVALIDWORKS)); + } +} diff --git a/src/test/java/pt/ptcris/test/scenarios/Scenario05.java b/src/test/java/pt/ptcris/test/scenarios/Scenario05.java new file mode 100644 index 0000000..000ade3 --- /dev/null +++ b/src/test/java/pt/ptcris/test/scenarios/Scenario05.java @@ -0,0 +1,73 @@ +/* + * Copyright (c) 2016, 2017 PTCRIS - FCT|FCCN and others. + * Licensed under MIT License + * http://ptcris.pt + * + * This copyright and license information (including a link to the full license) + * shall be included in its entirety in all copies or substantial portion of + * the software. + */ +package pt.ptcris.test.scenarios; + +import java.math.BigInteger; +import java.util.ArrayList; +import java.util.List; + +import org.um.dsi.gavea.orcid.model.work.Work; + +import pt.ptcris.test.TestHelper; +import pt.ptcris.test.TestClients; +import pt.ptcris.test.TestClients.Profile; +import pt.ptcris.utils.ORCIDWorkHelper; + +/** + * Scenario 5 of the PTCRISync specification v0.4.3, tests import. + * + * Features: + * creation notification + * + * TODO: this scenario does not exactly represent the one from the specification + * as this would require that the fixture work was set as the preferred, which + * is impossible programmatically. This does not affect the scenario and one of + * the user-sourced is selected instead. + * + * @see Scenario + */ +public class Scenario05 extends Scenario { + + /** {@inheritDoc} */ + @Override + List setupORCIDExternalWorks() { + List works = new ArrayList(); + works.add(TestHelper.workDOIEID(null, "0", "0", "0")); + return works; + } + + /** {@inheritDoc} */ + @Override + List setupLocalWorks() { + List works = new ArrayList(); + works.add(TestHelper.workDOIEIDHANDLE(BigInteger.valueOf(2), "0", "0", "0", "1")); + return works; + } + + /** {@inheritDoc} */ + @Override + List expectedImportedWorks() { + List works = new ArrayList(); + works.add(TestHelper.workDOI(null, "1", "1")); + return works; + } + + /** {@inheritDoc} */ + @Override + ORCIDWorkHelper crisClient() { + return new ORCIDWorkHelper(TestClients.getCRISClient(Profile.TWOVALIDWORKS)); + } + + /** {@inheritDoc} */ + @Override + ORCIDWorkHelper externalClient() { + return new ORCIDWorkHelper(TestClients.getExternalClient(Profile.TWOVALIDWORKS)); + } +} diff --git a/src/test/java/pt/ptcris/test/scenarios/Scenario06.java b/src/test/java/pt/ptcris/test/scenarios/Scenario06.java new file mode 100644 index 0000000..6dfddc3 --- /dev/null +++ b/src/test/java/pt/ptcris/test/scenarios/Scenario06.java @@ -0,0 +1,79 @@ +/* + * Copyright (c) 2016, 2017 PTCRIS - FCT|FCCN and others. + * Licensed under MIT License + * http://ptcris.pt + * + * This copyright and license information (including a link to the full license) + * shall be included in its entirety in all copies or substantial portion of + * the software. + */ +package pt.ptcris.test.scenarios; + +import java.math.BigInteger; +import java.util.ArrayList; +import java.util.List; + +import org.um.dsi.gavea.orcid.model.work.Work; + +import pt.ptcris.test.TestHelper; +import pt.ptcris.test.TestClients; +import pt.ptcris.test.TestClients.Profile; +import pt.ptcris.utils.ORCIDWorkHelper; + +/** + * Scenario 6 of the PTCRISync specification v0.4.3, tests import. + * + * Features: + * modification notifications with {same,more} + * + * TODO: this scenario does not exactly represent the one from the specification + * as this would require that the fixture work was set as the preferred, which + * is impossible programmatically. This does not affect the scenario and one of + * the user-sourced is selected instead. + * + * @see Scenario + */ +public class Scenario06 extends Scenario { + + /** {@inheritDoc} */ + @Override + List setupORCIDExternalWorks() { + List works = new ArrayList(); + works.add(TestHelper.workDOIEID(null, "0", "0", "0")); + works.add(TestHelper.workDOIHANDLE(null, "1", "1", "1")); + return works; + } + + /** {@inheritDoc} */ + @Override + List setupLocalWorks() { + List works = new ArrayList(); + works.add(TestHelper.workDOIEIDHANDLE(BigInteger.valueOf(2), "0", "0", "0", "1")); + works.add(TestHelper.workDOI(BigInteger.valueOf(1), "1", "1")); + return works; + } + + /** {@inheritDoc} */ + @Override + List expectedImportedWorks() { + List works = new ArrayList(); + Work w = TestHelper.workDOIEIDHANDLE(BigInteger.valueOf(1), null, "0", "0", "1"); + w.setExternalIds(new ORCIDWorkHelper(null).getSelfExternalIdsE(w)); + works.add(w); + works.add(TestHelper.workDOI(BigInteger.valueOf(2), null, "1")); + return works; + } + + /** {@inheritDoc} */ + @Override + ORCIDWorkHelper crisClient() { + return new ORCIDWorkHelper(TestClients.getCRISClient(Profile.TWOVALIDWORKS)); + } + + /** {@inheritDoc} */ + @Override + ORCIDWorkHelper externalClient() { + return new ORCIDWorkHelper(TestClients.getExternalClient(Profile.TWOVALIDWORKS)); + } + +} diff --git a/src/test/java/pt/ptcris/test/scenarios/Scenario07.java b/src/test/java/pt/ptcris/test/scenarios/Scenario07.java new file mode 100644 index 0000000..66082b7 --- /dev/null +++ b/src/test/java/pt/ptcris/test/scenarios/Scenario07.java @@ -0,0 +1,71 @@ +/* + * Copyright (c) 2016, 2017 PTCRIS - FCT|FCCN and others. + * Licensed under MIT License + * http://ptcris.pt + * + * This copyright and license information (including a link to the full license) + * shall be included in its entirety in all copies or substantial portion of + * the software. + */ +package pt.ptcris.test.scenarios; + +import java.math.BigInteger; +import java.util.ArrayList; +import java.util.List; + +import org.um.dsi.gavea.orcid.model.work.Work; + +import pt.ptcris.test.TestHelper; +import pt.ptcris.test.TestClients; +import pt.ptcris.test.TestClients.Profile; +import pt.ptcris.utils.ORCIDWorkHelper; + +/** + * Scenario 7 of the PTCRISync specification v0.4.3, tests import. + * + * Features: + * modification notifications at the pre-state + * + * TODO: this scenario does not exactly represent the one from the specification + * since notifications are not passed to the procedures, thus notifications at + * pre-state cannot be represented. + * + * TODO: this scenario does not exactly represent the one from the specification + * as this would require that the fixture work was set as the preferred, which + * is impossible programmatically. This does not affect the scenario and one of + * the user-sourced is selected instead. + * + * @see Scenario + */ +public class Scenario07 extends Scenario { + + /** {@inheritDoc} */ + @Override + List setupORCIDExternalWorks() { + List works = new ArrayList(); + works.add(TestHelper.workDOIEID(null, "0", "0", "0")); + return works; + } + + /** {@inheritDoc} */ + @Override + List setupLocalWorks() { + List works = new ArrayList(); + works.add(TestHelper.workDOI(BigInteger.valueOf(1), "1", "1")); + works.add(TestHelper.workDOIEIDHANDLE(BigInteger.valueOf(2), "0", "0", "0", "1")); + return works; + } + + /** {@inheritDoc} */ + @Override + ORCIDWorkHelper crisClient() { + return new ORCIDWorkHelper(TestClients.getCRISClient(Profile.TWOVALIDWORKS)); + } + + /** {@inheritDoc} */ + @Override + ORCIDWorkHelper externalClient() { + return new ORCIDWorkHelper(TestClients.getExternalClient(Profile.TWOVALIDWORKS)); + } + +} diff --git a/src/test/java/pt/ptcris/test/scenarios/Scenario08.java b/src/test/java/pt/ptcris/test/scenarios/Scenario08.java new file mode 100644 index 0000000..1f4e8f2 --- /dev/null +++ b/src/test/java/pt/ptcris/test/scenarios/Scenario08.java @@ -0,0 +1,82 @@ +/* + * Copyright (c) 2016, 2017 PTCRIS - FCT|FCCN and others. + * Licensed under MIT License + * http://ptcris.pt + * + * This copyright and license information (including a link to the full license) + * shall be included in its entirety in all copies or substantial portion of + * the software. + */ +package pt.ptcris.test.scenarios; + +import java.math.BigInteger; +import java.util.ArrayList; +import java.util.List; + +import org.um.dsi.gavea.orcid.model.work.Work; + +import pt.ptcris.test.TestHelper; +import pt.ptcris.test.TestClients; +import pt.ptcris.test.TestClients.Profile; +import pt.ptcris.utils.ORCIDWorkHelper; + +/** + * Scenario 8 of the PTCRISync specification v0.4.3, tests export. + * + * Features: + * export add + * + * TODO: this scenario does not exactly represent the one from the specification + * as this would require that the fixture work was set as the preferred, which + * is impossible programmatically. This does not affect the scenario and one of + * the user-sourced is selected instead. + * + * @see Scenario + */ +public class Scenario08 extends Scenario { + + /** {@inheritDoc} */ + @Override + List setupORCIDExternalWorks() { + List works = new ArrayList(); + works.add(TestHelper.workDOIEID(BigInteger.valueOf(2), "0", "0", "0")); + return works; + } + + /** {@inheritDoc} */ + @Override + List setupLocalWorks() { + List works = new ArrayList(); + works.add(TestHelper.workDOI(BigInteger.valueOf(1), "1", "1")); + return works; + } + + /** {@inheritDoc} */ + @Override + List exportLocalWorks() { + List works = new ArrayList(); + works.add(TestHelper.workDOIEIDHANDLE(BigInteger.valueOf(2),"0", "0", "0", "1")); + return works; + } + + /** {@inheritDoc} */ + @Override + List expectedORCIDCRISWorks() { + List works = new ArrayList(); + works.add(TestHelper.workDOIEIDHANDLE(BigInteger.valueOf(2),"0", "0", "0", "1")); + return works; + } + + /** {@inheritDoc} */ + @Override + ORCIDWorkHelper crisClient() { + return new ORCIDWorkHelper(TestClients.getCRISClient(Profile.TWOVALIDWORKS)); + } + + /** {@inheritDoc} */ + @Override + ORCIDWorkHelper externalClient() { + return new ORCIDWorkHelper(TestClients.getExternalClient(Profile.TWOVALIDWORKS)); + } + +} diff --git a/src/test/java/pt/ptcris/test/scenarios/Scenario09.java b/src/test/java/pt/ptcris/test/scenarios/Scenario09.java new file mode 100644 index 0000000..61b0224 --- /dev/null +++ b/src/test/java/pt/ptcris/test/scenarios/Scenario09.java @@ -0,0 +1,82 @@ +/* + * Copyright (c) 2016, 2017 PTCRIS - FCT|FCCN and others. + * Licensed under MIT License + * http://ptcris.pt + * + * This copyright and license information (including a link to the full license) + * shall be included in its entirety in all copies or substantial portion of + * the software. + */ +package pt.ptcris.test.scenarios; + +import java.math.BigInteger; +import java.util.ArrayList; +import java.util.List; + +import org.um.dsi.gavea.orcid.model.work.Work; + +import pt.ptcris.test.TestHelper; +import pt.ptcris.test.TestClients; +import pt.ptcris.test.TestClients.Profile; +import pt.ptcris.utils.ORCIDWorkHelper; + +/** + * Scenario 9 of the PTCRISync specification v0.4.3, tests export. + * + * Features: + * export add + * + * TODO: this scenario does not exactly represent the one from the specification + * as this would require that the fixture work was set as the preferred, which + * is impossible programmatically. This does not affect the scenario and one of + * the user-sourced is selected instead. + * + * @see Scenario + */ +public class Scenario09 extends Scenario { + + /** {@inheritDoc} */ + @Override + List setupORCIDExternalWorks() { + List works = new ArrayList(); + works.add(TestHelper.workDOIEID(BigInteger.valueOf(2), "0", "0", "0")); + return works; + } + + /** {@inheritDoc} */ + @Override + List setupLocalWorks() { + List works = new ArrayList(); + works.add(TestHelper.workDOI(BigInteger.valueOf(1), "1", "1")); + return works; + } + + /** {@inheritDoc} */ + @Override + List exportLocalWorks() { + List works = new ArrayList(); + works.add(TestHelper.workDOIEIDHANDLE(BigInteger.valueOf(2),"0","0","0", "1")); + return works; + } + + /** {@inheritDoc} */ + @Override + List expectedORCIDCRISWorks() { + List works = new ArrayList(); + works.add(TestHelper.workDOIEIDHANDLE(BigInteger.valueOf(2),"0","0","0", "1")); + return works; + } + + /** {@inheritDoc} */ + @Override + ORCIDWorkHelper crisClient() { + return new ORCIDWorkHelper(TestClients.getCRISClient(Profile.TWOVALIDWORKS)); + } + + /** {@inheritDoc} */ + @Override + ORCIDWorkHelper externalClient() { + return new ORCIDWorkHelper(TestClients.getExternalClient(Profile.TWOVALIDWORKS)); + } + +} diff --git a/src/test/java/pt/ptcris/test/scenarios/Scenario10.java b/src/test/java/pt/ptcris/test/scenarios/Scenario10.java new file mode 100644 index 0000000..95d65f2 --- /dev/null +++ b/src/test/java/pt/ptcris/test/scenarios/Scenario10.java @@ -0,0 +1,76 @@ +/* + * Copyright (c) 2016, 2017 PTCRIS - FCT|FCCN and others. + * Licensed under MIT License + * http://ptcris.pt + * + * This copyright and license information (including a link to the full license) + * shall be included in its entirety in all copies or substantial portion of + * the software. + */ +package pt.ptcris.test.scenarios; + +import java.math.BigInteger; +import java.util.ArrayList; +import java.util.List; + +import org.um.dsi.gavea.orcid.model.work.Work; + +import pt.ptcris.test.TestHelper; +import pt.ptcris.test.TestClients; +import pt.ptcris.test.TestClients.Profile; +import pt.ptcris.utils.ORCIDWorkHelper; + +/** + * Scenario 10 of the PTCRISync specification v0.4.3, tests export. + * + * Features: + * export rem + * preferred consequences + * + * TODO: this scenario does not exactly represent the one from the specification + * as this would require that the fixture work was set as the preferred, which + * is impossible programmatically. This affects the scenario since its goal + * is to depict the promotion of a work to preferred. + * + * @see Scenario + */ +public class Scenario10 extends Scenario { + + /** {@inheritDoc} */ + @Override + List setupORCIDCRISWorks() { + List works = new ArrayList(); + works.add(TestHelper.workDOIEIDHANDLE(null,"0","0","0", "1")); + return works; + } + + /** {@inheritDoc} */ + @Override + List setupORCIDExternalWorks() { + List works = new ArrayList(); + works.add(TestHelper.workDOIEID(BigInteger.valueOf(2), "0", "0", "0")); + return works; + } + + /** {@inheritDoc} */ + @Override + List setupLocalWorks() { + List works = new ArrayList(); + works.add(TestHelper.workDOI(BigInteger.valueOf(1), "1", "1")); + works.add(TestHelper.workDOIEIDHANDLE(BigInteger.valueOf(2),"0","0","0", "1")); + return works; + } + + /** {@inheritDoc} */ + @Override + ORCIDWorkHelper crisClient() { + return new ORCIDWorkHelper(TestClients.getCRISClient(Profile.TWOVALIDWORKS)); + } + + /** {@inheritDoc} */ + @Override + ORCIDWorkHelper externalClient() { + return new ORCIDWorkHelper(TestClients.getExternalClient(Profile.TWOVALIDWORKS)); + } + +} diff --git a/src/test/java/pt/ptcris/test/scenarios/Scenario11.java b/src/test/java/pt/ptcris/test/scenarios/Scenario11.java new file mode 100644 index 0000000..9bda308 --- /dev/null +++ b/src/test/java/pt/ptcris/test/scenarios/Scenario11.java @@ -0,0 +1,100 @@ +/* + * Copyright (c) 2016, 2017 PTCRIS - FCT|FCCN and others. + * Licensed under MIT License + * http://ptcris.pt + * + * This copyright and license information (including a link to the full license) + * shall be included in its entirety in all copies or substantial portion of + * the software. + */ +package pt.ptcris.test.scenarios; + +import java.math.BigInteger; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +import org.um.dsi.gavea.orcid.model.work.Work; + +import pt.ptcris.PTCRISyncResult; +import pt.ptcris.test.TestHelper; +import pt.ptcris.test.TestClients; +import pt.ptcris.test.TestClients.Profile; +import pt.ptcris.utils.ORCIDWorkHelper; + +/** + * Scenario 11 of the PTCRISync specification v0.4.3, tests export. + * + * Features: + * export update with {same} + * + * TODO: this scenario does not exactly represent the one from the specification + * as this would require that the fixture work was set as the preferred, which + * is impossible programmatically. This affects the scenario since its goal + * is to depict the promotion of a work to preferred. + * + * @see Scenario + */ +public class Scenario11 extends Scenario { + + /** {@inheritDoc} */ + @Override + List setupORCIDCRISWorks() { + List works = new ArrayList(); + works.add(TestHelper.workDOIEIDHANDLE(BigInteger.valueOf(2), "0", "0", "0", "1")); + return works; + } + + /** {@inheritDoc} */ + @Override + List setupORCIDExternalWorks() { + List works = new ArrayList(); + works.add(TestHelper.workDOIEID(BigInteger.valueOf(2), "0", "0", "0")); + return works; + } + + /** {@inheritDoc} */ + @Override + List setupLocalWorks() { + List works = new ArrayList(); + works.add(TestHelper.workDOI(BigInteger.valueOf(1), "1", "1")); + return works; + } + + /** {@inheritDoc} */ + @Override + List exportLocalWorks() { + List works = new ArrayList(); + works.add(TestHelper.workDOIEIDHANDLE(BigInteger.valueOf(2), "3", "0", "0", "1")); + return works; + } + + /** {@inheritDoc} */ + @Override + List expectedORCIDCRISWorks() { + List works = new ArrayList(); + works.add(TestHelper.workDOIEIDHANDLE(BigInteger.valueOf(2), "3", "0", "0", "1")); + return works; + } + + /** {@inheritDoc} */ + Set expectedExportCodes(BigInteger putcode) { + Set res = new HashSet(); + res.add(PTCRISyncResult.UPDATEOK); + return res; + } + + /** {@inheritDoc} */ + @Override + ORCIDWorkHelper crisClient() { + return new ORCIDWorkHelper(TestClients.getCRISClient(Profile.TWOVALIDWORKS)); + } + + /** {@inheritDoc} */ + @Override + ORCIDWorkHelper externalClient() { + return new ORCIDWorkHelper(TestClients.getExternalClient(Profile.TWOVALIDWORKS)); + } + +} diff --git a/src/test/java/pt/ptcris/test/scenarios/Scenario12.java b/src/test/java/pt/ptcris/test/scenarios/Scenario12.java new file mode 100644 index 0000000..f02e57d --- /dev/null +++ b/src/test/java/pt/ptcris/test/scenarios/Scenario12.java @@ -0,0 +1,89 @@ +/* + * Copyright (c) 2016, 2017 PTCRIS - FCT|FCCN and others. + * Licensed under MIT License + * http://ptcris.pt + * + * This copyright and license information (including a link to the full license) + * shall be included in its entirety in all copies or substantial portion of + * the software. + */ +package pt.ptcris.test.scenarios; + +import java.math.BigInteger; +import java.util.ArrayList; +import java.util.List; + +import org.um.dsi.gavea.orcid.model.work.Work; + +import pt.ptcris.test.TestHelper; +import pt.ptcris.test.TestClients; +import pt.ptcris.test.TestClients.Profile; +import pt.ptcris.utils.ORCIDWorkHelper; + +/** + * Scenario 12 of the PTCRISync specification v0.4.3, tests export and import. + * + * Features: + * export breaks import + * export add + * modification notifications with {same,more} + * + * @see Scenario + */ +public class Scenario12 extends Scenario { + + /** {@inheritDoc} */ + @Override + List setupORCIDExternalWorks() { + List works = new ArrayList(); + works.add(TestHelper.workDOIEID(null, "0", "0", "0")); + return works; + } + + /** {@inheritDoc} */ + @Override + List setupLocalWorks() { + List works = new ArrayList(); + works.add(TestHelper.workDOI(BigInteger.valueOf(1), "1", "1")); + return works; + } + + /** {@inheritDoc} */ + @Override + List exportLocalWorks() { + List works = new ArrayList(); + works.add(TestHelper.workDOIDOIEIDHANDLE(BigInteger.valueOf(2), "0", "0", "1", "0", "1")); + return works; + } + + /** {@inheritDoc} */ + @Override + List expectedORCIDCRISWorks() { + List works = new ArrayList(); + works.add(TestHelper.workDOIDOIEIDHANDLE(BigInteger.valueOf(2), "0", "0", "1", "0", "1")); + return works; + } + + /** {@inheritDoc} */ + @Override + List expectedImportedWorks() { + List works = new ArrayList(); + Work w = TestHelper.workDOIEIDHANDLE(BigInteger.valueOf(1), null, "0", "0", "1"); + w.setExternalIds(new ORCIDWorkHelper(null).getSelfExternalIdsE(w)); + works.add(w); + return works; + } + + /** {@inheritDoc} */ + @Override + ORCIDWorkHelper crisClient() { + return new ORCIDWorkHelper(TestClients.getCRISClient(Profile.TWOVALIDWORKS)); + } + + /** {@inheritDoc} */ + @Override + ORCIDWorkHelper externalClient() { + return new ORCIDWorkHelper(TestClients.getExternalClient(Profile.TWOVALIDWORKS)); + } + +} diff --git a/src/test/java/pt/ptcris/test/scenarios/Scenario13.java b/src/test/java/pt/ptcris/test/scenarios/Scenario13.java new file mode 100644 index 0000000..5190afb --- /dev/null +++ b/src/test/java/pt/ptcris/test/scenarios/Scenario13.java @@ -0,0 +1,118 @@ +/* + * Copyright (c) 2016, 2017 PTCRIS - FCT|FCCN and others. + * Licensed under MIT License + * http://ptcris.pt + * + * This copyright and license information (including a link to the full license) + * shall be included in its entirety in all copies or substantial portion of + * the software. + */ +package pt.ptcris.test.scenarios; + +import java.math.BigInteger; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +import org.um.dsi.gavea.orcid.model.work.Work; + +import pt.ptcris.PTCRISyncResult; +import pt.ptcris.test.TestHelper; +import pt.ptcris.test.TestClients; +import pt.ptcris.test.TestClients.Profile; +import pt.ptcris.utils.ORCIDHelper; +import pt.ptcris.utils.ORCIDWorkHelper; + +/** + * Scenario 13 of the PTCRISync specification v0.4.3, tests export and import. + * + * Features: + * export breaks import + * export del + * export update {same,more} + * modification notifications with {same,more} + * + * @see Scenario + */ +public class Scenario13 extends Scenario { + + /** {@inheritDoc} */ + @Override + List setupORCIDCRISWorks() { + List works = new ArrayList(); + works.add(TestHelper.workDOI(null, "3", "0")); + works.add(TestHelper.workHANDLE(null, "1", "1")); + return works; + } + + /** {@inheritDoc} */ + @Override + List setupLocalWorks() { + List works = new ArrayList(); + works.add(TestHelper.workHANDLE(BigInteger.valueOf(1), "1", "1")); + return works; + } + + /** {@inheritDoc} */ + @Override + List exportLocalWorks() { + List works = new ArrayList(); + works.add(TestHelper.workDOIHANDLE(BigInteger.valueOf(2), "3", "0", "1")); + return works; + } + + /** {@inheritDoc} */ + @Override + List expectedORCIDCRISWorks() { + List works = new ArrayList(); + works.add(TestHelper.workDOIHANDLE(BigInteger.valueOf(2), "3", "0", "1")); + return works; + } + + /** {@inheritDoc} */ + @Override + List expectedImportedWorks() { + List works = new ArrayList(); + works.add(TestHelper.workDOI(BigInteger.valueOf(1), null, "0")); + return works; + } + + /** {@inheritDoc} */ + @Override + List expectedImportedInvalidWorks() { + List works = new ArrayList(); + Work work = TestHelper.workDOI(null, "1", "I2"); + work.setPublicationDate(null); + works.add(work); + return works; + } + + /** {@inheritDoc} */ + @Override + Set expectedInvalidCodes(BigInteger putCode) { + Set res = new HashSet(); + res.add(ORCIDHelper.INVALID_PUBLICATIONDATE); + return res; + } + + /** {@inheritDoc} */ + Set expectedExportCodes(BigInteger putcode) { + Set res = new HashSet(); + res.add(PTCRISyncResult.UPDATEOK); + return res; + } + + /** {@inheritDoc} */ + @Override + ORCIDWorkHelper crisClient() { + return new ORCIDWorkHelper(TestClients.getCRISClient(Profile.ZEROVALIDWORKS)); + } + + /** {@inheritDoc} */ + @Override + ORCIDWorkHelper externalClient() { + return new ORCIDWorkHelper(TestClients.getExternalClient(Profile.ZEROVALIDWORKS)); + } + +} diff --git a/src/test/java/pt/ptcris/test/scenarios/Scenario14.java b/src/test/java/pt/ptcris/test/scenarios/Scenario14.java new file mode 100644 index 0000000..7972ead --- /dev/null +++ b/src/test/java/pt/ptcris/test/scenarios/Scenario14.java @@ -0,0 +1,104 @@ +/* + * Copyright (c) 2016, 2017 PTCRIS - FCT|FCCN and others. + * Licensed under MIT License + * http://ptcris.pt + * + * This copyright and license information (including a link to the full license) + * shall be included in its entirety in all copies or substantial portion of + * the software. + */ +package pt.ptcris.test.scenarios; + +import java.math.BigInteger; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +import org.um.dsi.gavea.orcid.model.work.Work; + +import pt.ptcris.PTCRISyncResult; +import pt.ptcris.test.TestHelper; +import pt.ptcris.test.TestClients; +import pt.ptcris.test.TestClients.Profile; +import pt.ptcris.utils.ORCIDHelper; +import pt.ptcris.utils.ORCIDWorkHelper; + +/** + * Scenario 14 of the PTCRISync specification v0.4.3, tests export. + * + * Features: + * export fixes import + * export add + * export update {same,less} + * + * @see Scenario + */ +public class Scenario14 extends Scenario { + + /** {@inheritDoc} */ + @Override + List setupORCIDCRISWorks() { + List works = new ArrayList(); + works.add(TestHelper.workDOIHANDLE(null, "3", "0", "1")); + return works; + } + + /** {@inheritDoc} */ + @Override + List exportLocalWorks() { + List works = new ArrayList(); + works.add(TestHelper.workDOI(BigInteger.valueOf(2), "3", "0")); + works.add(TestHelper.workHANDLE(BigInteger.valueOf(1), "1", "1")); + return works; + } + + /** {@inheritDoc} */ + @Override + List expectedORCIDCRISWorks() { + List works = new ArrayList(); + works.add(TestHelper.workDOI(BigInteger.valueOf(2), "3", "0")); + works.add(TestHelper.workHANDLE(BigInteger.valueOf(1), "1", "1")); + return works; + } + + /** {@inheritDoc} */ + @Override + List expectedImportedInvalidWorks() { + List works = new ArrayList(); + Work work = TestHelper.workDOI(null, "1", "I2"); + work.setPublicationDate(null); + works.add(work); + return works; + } + + /** {@inheritDoc} */ + @Override + Set expectedInvalidCodes(BigInteger putCode) { + Set res = new HashSet(); + res.add(ORCIDHelper.INVALID_PUBLICATIONDATE); + return res; + } + + /** {@inheritDoc} */ + Set expectedExportCodes(BigInteger putcode) { + Set res = new HashSet(); + res.add(PTCRISyncResult.ADDOK); + res.add(PTCRISyncResult.UPDATEOK); + return res; + } + + /** {@inheritDoc} */ + @Override + ORCIDWorkHelper crisClient() { + return new ORCIDWorkHelper( + TestClients.getCRISClient(Profile.ZEROVALIDWORKS)); + } + + /** {@inheritDoc} */ + @Override + ORCIDWorkHelper externalClient() { + return new ORCIDWorkHelper(TestClients.getExternalClient(Profile.ZEROVALIDWORKS)); + } + +} diff --git a/src/test/java/pt/ptcris/test/scenarios/Scenario15.java b/src/test/java/pt/ptcris/test/scenarios/Scenario15.java new file mode 100644 index 0000000..97062db --- /dev/null +++ b/src/test/java/pt/ptcris/test/scenarios/Scenario15.java @@ -0,0 +1,82 @@ +/* + * Copyright (c) 2016, 2017 PTCRIS - FCT|FCCN and others. + * Licensed under MIT License + * http://ptcris.pt + * + * This copyright and license information (including a link to the full license) + * shall be included in its entirety in all copies or substantial portion of + * the software. + */ +package pt.ptcris.test.scenarios; + +import java.math.BigInteger; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +import org.um.dsi.gavea.orcid.model.work.Work; + +import pt.ptcris.test.TestHelper; +import pt.ptcris.test.TestClients; +import pt.ptcris.test.TestClients.Profile; +import pt.ptcris.utils.ORCIDHelper; +import pt.ptcris.utils.ORCIDWorkHelper; + +/** + * Scenario 15 of the PTCRISync specification v0.4.3, tests import. + * + * Features: + * modification notifications with {same,more,less} + * + * @see Scenario + */ +public class Scenario15 extends Scenario { + + /** {@inheritDoc} */ + @Override + List setupLocalWorks() { + List works = new ArrayList(); + works.add(TestHelper.workDOIEID(BigInteger.valueOf(1), "1", "0", "0")); + return works; + } + + /** {@inheritDoc} */ + @Override + List expectedImportedWorks() { + List works = new ArrayList(); + Work w = TestHelper.workHANDLE(BigInteger.valueOf(1), null, "1"); + w.setExternalIds(new ORCIDWorkHelper(null).getSelfExternalIdsE(w)); + works.add(w); + return works; + } + + /** {@inheritDoc} */ + @Override + List expectedImportedInvalidWorks() { + List works = new ArrayList(); + works.add(TestHelper.work(null, "0")); + return works; + } + + /** {@inheritDoc} */ + @Override + Set expectedInvalidCodes(BigInteger putCode) { + Set res = new HashSet(); + res.add(ORCIDHelper.INVALID_EXTERNALIDENTIFIERS); + return res; + } + + /** {@inheritDoc} */ + @Override + ORCIDWorkHelper crisClient() { + return new ORCIDWorkHelper(TestClients.getCRISClient(Profile.ONEVALIDWORKS)); + } + + /** {@inheritDoc} */ + @Override + ORCIDWorkHelper externalClient() { + return new ORCIDWorkHelper(TestClients.getExternalClient(Profile.ONEVALIDWORKS)); + } + +} diff --git a/src/test/java/pt/ptcris/test/scenarios/Scenario16.java b/src/test/java/pt/ptcris/test/scenarios/Scenario16.java new file mode 100644 index 0000000..8b61c0f --- /dev/null +++ b/src/test/java/pt/ptcris/test/scenarios/Scenario16.java @@ -0,0 +1,96 @@ +/* + * Copyright (c) 2016, 2017 PTCRIS - FCT|FCCN and others. + * Licensed under MIT License + * http://ptcris.pt + * + * This copyright and license information (including a link to the full license) + * shall be included in its entirety in all copies or substantial portion of + * the software. + */ +package pt.ptcris.test.scenarios; + +import java.math.BigInteger; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +import org.um.dsi.gavea.orcid.model.work.Work; + +import pt.ptcris.test.TestHelper; +import pt.ptcris.test.TestClients; +import pt.ptcris.test.TestClients.Profile; +import pt.ptcris.utils.ORCIDHelper; +import pt.ptcris.utils.ORCIDWorkHelper; + +/** + * Scenario 16 of the PTCRISync specification v0.4.3, tests import. + * + * Features: + * modification notifications at pre-state + * multiple modification notifications + * modification notifications with {same,more,less} + * + * @see Scenario + */ +public class Scenario16 extends Scenario { + + /** {@inheritDoc} */ + @Override + List setupORCIDExternalWorks() { + List works = new ArrayList(); + works.add(TestHelper.workEIDHANDLE(null, "3", "0", "0")); + return works; + } + + /** {@inheritDoc} */ + @Override + List setupLocalWorks() { + List works = new ArrayList(); + works.add(TestHelper.workDOIEID(BigInteger.valueOf(1), "1", "0", "0")); + return works; + } + + /** {@inheritDoc} */ + @Override + List expectedImportedWorks() { + List works = new ArrayList(); + Work w = TestHelper.workHANDLE(BigInteger.valueOf(1), null, "0"); + w.setExternalIds(new ORCIDWorkHelper(null).getSelfExternalIdsE(w)); + works.add(w); + Work w1 = TestHelper.workHANDLE(BigInteger.valueOf(1), null, "1"); + w1.setExternalIds(new ORCIDWorkHelper(null).getSelfExternalIdsE(w1)); + works.add(w1); + return works; + } + + /** {@inheritDoc} */ + @Override + List expectedImportedInvalidWorks() { + List works = new ArrayList(); + works.add(TestHelper.work(null, "0")); + return works; + } + + /** {@inheritDoc} */ + @Override + Set expectedInvalidCodes(BigInteger putCode) { + Set res = new HashSet(); + res.add(ORCIDHelper.INVALID_EXTERNALIDENTIFIERS); + return res; + } + + /** {@inheritDoc} */ + @Override + ORCIDWorkHelper crisClient() { + return new ORCIDWorkHelper(TestClients.getCRISClient(Profile.ONEVALIDWORKS)); + } + + /** {@inheritDoc} */ + @Override + ORCIDWorkHelper externalClient() { + return new ORCIDWorkHelper( + TestClients.getExternalClient(Profile.ONEVALIDWORKS)); + } + +} diff --git a/src/test/java/pt/ptcris/test/scenarios/Scenario17.java b/src/test/java/pt/ptcris/test/scenarios/Scenario17.java new file mode 100644 index 0000000..f42f2fa --- /dev/null +++ b/src/test/java/pt/ptcris/test/scenarios/Scenario17.java @@ -0,0 +1,107 @@ +/* + * Copyright (c) 2016, 2017 PTCRIS - FCT|FCCN and others. + * Licensed under MIT License + * http://ptcris.pt + * + * This copyright and license information (including a link to the full license) + * shall be included in its entirety in all copies or substantial portion of + * the software. + */ +package pt.ptcris.test.scenarios; + +import java.math.BigInteger; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +import org.um.dsi.gavea.orcid.model.work.Work; + +import pt.ptcris.PTCRISyncResult; +import pt.ptcris.test.TestHelper; +import pt.ptcris.test.TestClients; +import pt.ptcris.test.TestClients.Profile; +import pt.ptcris.utils.ORCIDHelper; +import pt.ptcris.utils.ORCIDWorkHelper; + +/** + * Scenario 17 of the PTCRISync specification v0.4.3, tests export and import. + * + * Features: + * creation notifications at pre-state + * export updates with {less,same,more} + * + * @see Scenario + */ +public class Scenario17 extends Scenario { + + /** {@inheritDoc} */ + @Override + List setupORCIDCRISWorks() { + List works = new ArrayList(); + works.add(TestHelper.workDOIHANDLE(null, "3", "0", "1")); + return works; + } + + /** {@inheritDoc} */ + @Override + List setupORCIDExternalWorks() { + List works = new ArrayList(); + works.add(TestHelper.workHANDLE(null, "1", "0")); + return works; + } + + /** {@inheritDoc} */ + @Override + List exportLocalWorks() { + List works = new ArrayList(); + works.add(TestHelper.workDOIHANDLE(BigInteger.valueOf(2), "3", "0", "0")); + return works; + } + + /** {@inheritDoc} */ + @Override + List expectedORCIDCRISWorks() { + List works = new ArrayList(); + works.add(TestHelper.workDOIHANDLE(null, "3", "0", "0")); + return works; + } + + /** {@inheritDoc} */ + @Override + List expectedImportedInvalidWorks() { + List works = new ArrayList(); + Work work = TestHelper.workDOI(null, "1", "I2"); + work.setPublicationDate(null); + works.add(work); + return works; + } + + /** {@inheritDoc} */ + @Override + Set expectedInvalidCodes(BigInteger putCode) { + Set res = new HashSet(); + res.add(ORCIDHelper.INVALID_PUBLICATIONDATE); + return res; + } + + /** {@inheritDoc} */ + Set expectedExportCodes(BigInteger putcode) { + Set res = new HashSet(); + res.add(PTCRISyncResult.UPDATEOK); + return res; + } + + /** {@inheritDoc} */ + @Override + ORCIDWorkHelper crisClient() { + return new ORCIDWorkHelper(TestClients.getCRISClient(Profile.ZEROVALIDWORKS)); + } + + /** {@inheritDoc} */ + @Override + ORCIDWorkHelper externalClient() { + return new ORCIDWorkHelper(TestClients.getExternalClient(Profile.ZEROVALIDWORKS)); + } + +} diff --git a/src/test/java/pt/ptcris/test/scenarios/Scenario18.java b/src/test/java/pt/ptcris/test/scenarios/Scenario18.java new file mode 100644 index 0000000..20053f0 --- /dev/null +++ b/src/test/java/pt/ptcris/test/scenarios/Scenario18.java @@ -0,0 +1,104 @@ +/* + * Copyright (c) 2016, 2017 PTCRIS - FCT|FCCN and others. + * Licensed under MIT License + * http://ptcris.pt + * + * This copyright and license information (including a link to the full license) + * shall be included in its entirety in all copies or substantial portion of + * the software. + */ +package pt.ptcris.test.scenarios; + +import java.math.BigInteger; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +import org.um.dsi.gavea.orcid.model.work.Work; + +import pt.ptcris.PTCRISyncResult; +import pt.ptcris.test.TestHelper; +import pt.ptcris.test.TestClients; +import pt.ptcris.test.TestClients.Profile; +import pt.ptcris.utils.ORCIDHelper; +import pt.ptcris.utils.ORCIDWorkHelper; + +/** + * Scenario 18 of the PTCRISync specification v0.4.3, tests export. + * + * Features: + * export fixes import + * export updates with {less,same,more} + * + * @see Scenario + */ +public class Scenario18 extends Scenario { + + /** {@inheritDoc} */ + @Override + List setupORCIDCRISWorks() { + List works = new ArrayList(); + works.add(TestHelper.workDOIHANDLE(null, "3", "0", "1")); + works.add(TestHelper.workDOIHANDLE(null, "3", "1", "0")); + return works; + } + + /** {@inheritDoc} */ + @Override + List exportLocalWorks() { + List works = new ArrayList(); + works.add(TestHelper.workDOIHANDLE(BigInteger.valueOf(1), "3", "1", "1")); + works.add(TestHelper.workDOIHANDLE(BigInteger.valueOf(2), "3", "0", "0")); + return works; + } + + /** {@inheritDoc} */ + @Override + List expectedORCIDCRISWorks() { + List works = new ArrayList(); + works.add(TestHelper.workDOIHANDLE(null, "3", "1", "1")); + works.add(TestHelper.workDOIHANDLE(null, "3", "0", "0")); + return works; + } + + /** {@inheritDoc} */ + @Override + List expectedImportedInvalidWorks() { + List works = new ArrayList(); + Work work = TestHelper.workDOI(null, "1", "I2"); + work.setPublicationDate(null); + works.add(work); + return works; + } + + /** {@inheritDoc} */ + @Override + Set expectedInvalidCodes(BigInteger putCode) { + Set res = new HashSet(); + res.add(ORCIDHelper.INVALID_PUBLICATIONDATE); + return res; + } + + /** {@inheritDoc} */ + Set expectedExportCodes(BigInteger putcode) { + Set res = new HashSet(); + res.add(PTCRISyncResult.UPDATEOK); + return res; + } + + /** {@inheritDoc} */ + @Override + ORCIDWorkHelper crisClient() { + return new ORCIDWorkHelper( + TestClients.getCRISClient(Profile.ZEROVALIDWORKS)); + } + + /** {@inheritDoc} */ + @Override + ORCIDWorkHelper externalClient() { + return new ORCIDWorkHelper( + TestClients.getExternalClient(Profile.ZEROVALIDWORKS)); + } + +} diff --git a/src/test/java/pt/ptcris/test/scenarios/Scenario19.java b/src/test/java/pt/ptcris/test/scenarios/Scenario19.java new file mode 100644 index 0000000..7fe0e6b --- /dev/null +++ b/src/test/java/pt/ptcris/test/scenarios/Scenario19.java @@ -0,0 +1,104 @@ +/* + * Copyright (c) 2016, 2017 PTCRIS - FCT|FCCN and others. + * Licensed under MIT License + * http://ptcris.pt + * + * This copyright and license information (including a link to the full license) + * shall be included in its entirety in all copies or substantial portion of + * the software. + */ +package pt.ptcris.test.scenarios; + +import java.math.BigInteger; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +import org.um.dsi.gavea.orcid.model.work.Work; + +import pt.ptcris.PTCRISyncResult; +import pt.ptcris.test.TestHelper; +import pt.ptcris.test.TestClients; +import pt.ptcris.test.TestClients.Profile; +import pt.ptcris.utils.ORCIDHelper; +import pt.ptcris.utils.ORCIDWorkHelper; + +/** + * Scenario 19 of the PTCRISync specification v0.4.3, tests export. + * + * Features: + * export updates with {same} + * + * @see Scenario + */ +public class Scenario19 extends Scenario { + + /** {@inheritDoc} */ + @Override + List setupORCIDCRISWorks() { + List works = new ArrayList(); + works.add(TestHelper.workDOIEIDHANDLE(null, "1", "1", "0", "0")); + return works; + } + + /** {@inheritDoc} */ + @Override + List exportLocalWorks() { + List works = new ArrayList(); + works.add(TestHelper.workDOIEIDHANDLE(BigInteger.valueOf(0), "1", "1", + "0", "0")); + return works; + } + + /** {@inheritDoc} */ + @Override + List expectedORCIDCRISWorks() { + List works = new ArrayList(); + works.add(TestHelper.workDOIEIDHANDLE(null, "1", "1", "0", "0")); + return works; + } + + /** {@inheritDoc} */ + Set expectedExportCodes(BigInteger putcode) { + Set res = new HashSet(); + if (putcode.equals(BigInteger.valueOf(0))) + res.add(PTCRISyncResult.UPTODATE); + else + res.add(PTCRISyncResult.ADDOK); + return res; + } + + /** {@inheritDoc} */ + @Override + List expectedImportedInvalidWorks() { + List works = new ArrayList(); + Work work = TestHelper.workDOI(null, "1", "I2"); + work.setPublicationDate(null); + works.add(work); + return works; + } + + /** {@inheritDoc} */ + @Override + Set expectedInvalidCodes(BigInteger putCode) { + Set res = new HashSet(); + res.add(ORCIDHelper.INVALID_PUBLICATIONDATE); + return res; + } + + /** {@inheritDoc} */ + @Override + ORCIDWorkHelper crisClient() { + return new ORCIDWorkHelper( + TestClients.getCRISClient(Profile.ZEROVALIDWORKS)); + } + + /** {@inheritDoc} */ + @Override + ORCIDWorkHelper externalClient() { + return new ORCIDWorkHelper( + TestClients.getExternalClient(Profile.ZEROVALIDWORKS)); + } + +} diff --git a/src/test/java/pt/ptcris/test/scenarios/Scenario20.java b/src/test/java/pt/ptcris/test/scenarios/Scenario20.java new file mode 100644 index 0000000..f283e8f --- /dev/null +++ b/src/test/java/pt/ptcris/test/scenarios/Scenario20.java @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2016, 2017 PTCRIS - FCT|FCCN and others. + * Licensed under MIT License + * http://ptcris.pt + * + * This copyright and license information (including a link to the full license) + * shall be included in its entirety in all copies or substantial portion of + * the software. + */ +package pt.ptcris.test.scenarios; + +import pt.ptcris.test.TestClients; +import pt.ptcris.test.TestClients.Profile; +import pt.ptcris.utils.ORCIDWorkHelper; + +/** + * Scenario 20 of the PTCRISync specification v0.4.3, tests export. + * + * Features: empty profile + * + * @see Scenario + */ +public class Scenario20 extends Scenario { + + /** {@inheritDoc} */ + @Override + ORCIDWorkHelper crisClient() { + return new ORCIDWorkHelper(TestClients.getCRISClient(Profile.EMPTYWORKS)); + } + + /** {@inheritDoc} */ + @Override + ORCIDWorkHelper externalClient() { + return new ORCIDWorkHelper( + TestClients.getExternalClient(Profile.EMPTYWORKS)); + } + +} diff --git a/src/test/java/pt/ptcris/test/scenarios/ScenarioF01.java b/src/test/java/pt/ptcris/test/scenarios/ScenarioF01.java new file mode 100644 index 0000000..7224b16 --- /dev/null +++ b/src/test/java/pt/ptcris/test/scenarios/ScenarioF01.java @@ -0,0 +1,85 @@ +/* +r * Copyright (c) 2016, 2017 PTCRIS - FCT|FCCN and others. + * Licensed under MIT License + * http://ptcris.pt + * + * This copyright and license information (including a link to the full license) + * shall be included in its entirety in all copies or substantial portion of + * the software. + */ +package pt.ptcris.test.scenarios; + +import java.math.BigInteger; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +import org.um.dsi.gavea.orcid.model.funding.Funding; + +import pt.ptcris.test.TestHelper; +import pt.ptcris.test.TestClients; +import pt.ptcris.test.TestClients.Profile; +import pt.ptcris.utils.ORCIDFundingHelper; +import pt.ptcris.utils.ORCIDHelper; + +/** + * Scenario 1 of the PTCRISync specification v0.4.3, tests import. + * + * Features: + * creation notification + * + * TODO: this scenario does not exactly represent the one from the specification + * as this would require that the fixture work was set as the preferred, which + * is impossible programmatically. This does not affect the scenario and one of + * the user-sourced is selected instead. + * + * @see Scenario + */ +public class ScenarioF01 extends ScenarioFunding { + + /** {@inheritDoc} */ + @Override + List setupORCIDExternalFundings() { + List works = new ArrayList(); + works.add(TestHelper.fundingNmbNmb(null, "0", "0", "2")); + return works; + } + + /** {@inheritDoc} */ + @Override + List expectedImportedFundings() { + List works = new ArrayList(); + works.add(TestHelper.fundingNmbNmbNmb(null, "1", "0", "2", "1")); + return works; + } + + /** {@inheritDoc} */ + @Override + List expectedImportedInvalidFundings() { + List works = new ArrayList(); + works.add(TestHelper.funding(null, "0")); + return works; + } + + /** {@inheritDoc} */ + @Override + Set expectedInvalidCodes(BigInteger putCode) { + Set res = new HashSet(); + res.add(ORCIDHelper.INVALID_EXTERNALIDENTIFIERS); + return res; + } + + /** {@inheritDoc} */ + @Override + ORCIDFundingHelper crisClient() { + return new ORCIDFundingHelper(TestClients.getCRISClient(Profile.ONEVALIDWORKS)); + } + + /** {@inheritDoc} */ + @Override + ORCIDFundingHelper externalClient() { + return new ORCIDFundingHelper(TestClients.getExternalClient(Profile.ONEVALIDWORKS)); + } + +} diff --git a/src/test/java/pt/ptcris/test/scenarios/ScenarioF02.java b/src/test/java/pt/ptcris/test/scenarios/ScenarioF02.java new file mode 100644 index 0000000..2e64b82 --- /dev/null +++ b/src/test/java/pt/ptcris/test/scenarios/ScenarioF02.java @@ -0,0 +1,93 @@ +/* + * Copyright (c) 2016, 2017 PTCRIS - FCT|FCCN and others. + * Licensed under MIT License + * http://ptcris.pt + * + * This copyright and license information (including a link to the full license) + * shall be included in its entirety in all copies or substantial portion of + * the software. + */ +package pt.ptcris.test.scenarios; + +import java.math.BigInteger; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +import org.um.dsi.gavea.orcid.model.funding.Funding; + +import pt.ptcris.test.TestHelper; +import pt.ptcris.test.TestClients; +import pt.ptcris.test.TestClients.Profile; +import pt.ptcris.utils.ORCIDFundingHelper; +import pt.ptcris.utils.ORCIDHelper; + +/** + * Scenario 2 of the PTCRISync specification v0.4.3, tests import. + * + * Features: + * modification notifications with {same,more} + * + * TODO: this scenario does not exactly represent the one from the specification + * as this would require that the fixture funding was set as the preferred, which + * is impossible programmatically. This does not affect the scenario and one of + * the user-sourced is selected instead. + * + * @see Scenario + */ +public class ScenarioF02 extends ScenarioFunding { + + /** {@inheritDoc} */ + @Override + List setupORCIDExternalFundings() { + List fundings = new ArrayList(); + fundings.add(TestHelper.fundingNmbNmb(null, "0", "0", "2")); + fundings.add(TestHelper.fundingNmbNmb(null, "1", "1", "3")); + return fundings; + } + + /** {@inheritDoc} */ + @Override + List setupLocalFundings() { + List fundings = new ArrayList(); + fundings.add(TestHelper.fundingNmbNmbNmb(BigInteger.valueOf(2), "0", "0", "2", "3")); + return fundings; + } + + /** {@inheritDoc} */ + @Override + List expectedImportedFundings() { + List fundings = new ArrayList(); + fundings.add(TestHelper.fundingNmb(BigInteger.valueOf(2), null, "1")); + return fundings; + } + + /** {@inheritDoc} */ + @Override + List expectedImportedInvalidFundings() { + List fundings = new ArrayList(); + fundings.add(TestHelper.funding(null, "0")); + return fundings; + } + + /** {@inheritDoc} */ + @Override + Set expectedInvalidCodes(BigInteger putCode) { + Set res = new HashSet(); + res.add(ORCIDHelper.INVALID_EXTERNALIDENTIFIERS); + return res; + } + + /** {@inheritDoc} */ + @Override + ORCIDFundingHelper crisClient() { + return new ORCIDFundingHelper(TestClients.getCRISClient(Profile.ONEVALIDWORKS)); + } + + /** {@inheritDoc} */ + @Override + ORCIDFundingHelper externalClient() { + return new ORCIDFundingHelper(TestClients.getExternalClient(Profile.ONEVALIDWORKS)); + } +} diff --git a/src/test/java/pt/ptcris/test/scenarios/ScenarioF03.java b/src/test/java/pt/ptcris/test/scenarios/ScenarioF03.java new file mode 100644 index 0000000..df9a2bf --- /dev/null +++ b/src/test/java/pt/ptcris/test/scenarios/ScenarioF03.java @@ -0,0 +1,85 @@ +/* + * Copyright (c) 2016, 2017 PTCRIS - FCT|FCCN and others. + * Licensed under MIT License + * http://ptcris.pt + * + * This copyright and license information (including a link to the full license) + * shall be included in its entirety in all copies or substantial portion of + * the software. + */ +package pt.ptcris.test.scenarios; + +import java.math.BigInteger; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +import org.um.dsi.gavea.orcid.model.funding.Funding; + +import pt.ptcris.test.TestHelper; +import pt.ptcris.test.TestClients; +import pt.ptcris.test.TestClients.Profile; +import pt.ptcris.utils.ORCIDFundingHelper; +import pt.ptcris.utils.ORCIDHelper; + +/** + * Scenario 3 of the PTCRISync specification v0.4.3, tests import. + * + * Features: + * + * TODO: this scenario does not exactly represent the one from the specification + * as this would require that the fixture funding was set as the preferred, which + * is impossible programmatically. This does not affect the scenario and one of + * the user-sourced is selected instead. + * + * @see Scenario + */ +public class ScenarioF03 extends ScenarioFunding { + + /** {@inheritDoc} */ + @Override + List setupORCIDExternalFundings() { + List fundings = new ArrayList(); + fundings.add(TestHelper.fundingNmbNmb(null, "0", "0", "2")); + fundings.add(TestHelper.fundingNmbNmb(null, "1", "1", "3")); + return fundings; + } + + /** {@inheritDoc} */ + @Override + List setupLocalFundings() { + List fundings = new ArrayList(); + fundings.add(TestHelper.fundingNmbNmbNmbNmb(BigInteger.valueOf(2), "0", "0", "1", "2", "3")); + return fundings; + } + + /** {@inheritDoc} */ + @Override + List expectedImportedInvalidFundings() { + List fundings = new ArrayList(); + fundings.add(TestHelper.funding(null, "0")); + return fundings; + } + + /** {@inheritDoc} */ + @Override + Set expectedInvalidCodes(BigInteger putCode) { + Set res = new HashSet(); + res.add(ORCIDHelper.INVALID_EXTERNALIDENTIFIERS); + return res; + } + + /** {@inheritDoc} */ + @Override + ORCIDFundingHelper crisClient() { + return new ORCIDFundingHelper(TestClients.getCRISClient(Profile.ONEVALIDWORKS)); + } + + /** {@inheritDoc} */ + @Override + ORCIDFundingHelper externalClient() { + return new ORCIDFundingHelper(TestClients.getExternalClient(Profile.ONEVALIDWORKS)); + } + +} diff --git a/src/test/java/pt/ptcris/test/scenarios/ScenarioF04.java b/src/test/java/pt/ptcris/test/scenarios/ScenarioF04.java new file mode 100644 index 0000000..fe24707 --- /dev/null +++ b/src/test/java/pt/ptcris/test/scenarios/ScenarioF04.java @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2016, 2017 PTCRIS - FCT|FCCN and others. + * Licensed under MIT License + * http://ptcris.pt + * + * This copyright and license information (including a link to the full license) + * shall be included in its entirety in all copies or substantial portion of + * the software. + */ +package pt.ptcris.test.scenarios; + +import java.math.BigInteger; +import java.util.ArrayList; +import java.util.List; + +import org.um.dsi.gavea.orcid.model.funding.Funding; + +import pt.ptcris.test.TestHelper; +import pt.ptcris.test.TestClients; +import pt.ptcris.test.TestClients.Profile; +import pt.ptcris.utils.ORCIDFundingHelper; + +/** + * Scenario 4 of the PTCRISync specification v0.4.3, tests import. + * + * Features: + * + * TODO: this scenario does not exactly represent the one from the specification + * as this would require that the fixture work was set as the preferred, which + * is impossible programmatically. This does not affect the scenario and one of + * the user-sourced is selected instead. + * + * @see ScenarioFunding + */ +public class ScenarioF04 extends ScenarioFunding { + + /** {@inheritDoc} */ + @Override + List setupORCIDExternalFundings() { + List works = new ArrayList(); + works.add(TestHelper.fundingNmbNmb(null, "0", "0", "1")); + return works; + } + + /** {@inheritDoc} */ + @Override + List setupLocalFundings() { + List works = new ArrayList(); + works.add(TestHelper.fundingNmbNmbNmbNmb(BigInteger.valueOf(2), "0", "0", "2", "1", "3")); + return works; + } + + /** {@inheritDoc} */ + @Override + ORCIDFundingHelper crisClient() { + return new ORCIDFundingHelper(TestClients.getCRISClient(Profile.TWOVALIDWORKS)); + } + + /** {@inheritDoc} */ + @Override + ORCIDFundingHelper externalClient() { + return new ORCIDFundingHelper(TestClients.getExternalClient(Profile.TWOVALIDWORKS)); + } +} diff --git a/src/test/java/pt/ptcris/test/scenarios/ScenarioF05.java b/src/test/java/pt/ptcris/test/scenarios/ScenarioF05.java new file mode 100644 index 0000000..917d937 --- /dev/null +++ b/src/test/java/pt/ptcris/test/scenarios/ScenarioF05.java @@ -0,0 +1,73 @@ +/* + * Copyright (c) 2016, 2017 PTCRIS - FCT|FCCN and others. + * Licensed under MIT License + * http://ptcris.pt + * + * This copyright and license information (including a link to the full license) + * shall be included in its entirety in all copies or substantial portion of + * the software. + */ +package pt.ptcris.test.scenarios; + +import java.math.BigInteger; +import java.util.ArrayList; +import java.util.List; + +import org.um.dsi.gavea.orcid.model.funding.Funding; + +import pt.ptcris.test.TestHelper; +import pt.ptcris.test.TestClients; +import pt.ptcris.test.TestClients.Profile; +import pt.ptcris.utils.ORCIDFundingHelper; + +/** + * Scenario 5 of the PTCRISync specification v0.4.3, tests import. + * + * Features: + * creation notification + * + * TODO: this scenario does not exactly represent the one from the specification + * as this would require that the fixture work was set as the preferred, which + * is impossible programmatically. This does not affect the scenario and one of + * the user-sourced is selected instead. + * + * @see Scenario + */ +public class ScenarioF05 extends ScenarioFunding { + + /** {@inheritDoc} */ + @Override + List setupORCIDExternalFundings() { + List works = new ArrayList(); + works.add(TestHelper.fundingNmbNmb(null, "0", "0", "3")); + return works; + } + + /** {@inheritDoc} */ + @Override + List setupLocalFundings() { + List works = new ArrayList(); + works.add(TestHelper.fundingNmbNmbNmb(BigInteger.valueOf(2), "0", "0", "3", "1")); + return works; + } + + /** {@inheritDoc} */ + @Override + List expectedImportedFundings() { + List works = new ArrayList(); + works.add(TestHelper.fundingNmb(null, "1", "2")); + return works; + } + + /** {@inheritDoc} */ + @Override + ORCIDFundingHelper crisClient() { + return new ORCIDFundingHelper(TestClients.getCRISClient(Profile.TWOVALIDWORKS)); + } + + /** {@inheritDoc} */ + @Override + ORCIDFundingHelper externalClient() { + return new ORCIDFundingHelper(TestClients.getExternalClient(Profile.TWOVALIDWORKS)); + } +} diff --git a/src/test/java/pt/ptcris/test/scenarios/ScenarioF06.java b/src/test/java/pt/ptcris/test/scenarios/ScenarioF06.java new file mode 100644 index 0000000..39fe785 --- /dev/null +++ b/src/test/java/pt/ptcris/test/scenarios/ScenarioF06.java @@ -0,0 +1,79 @@ +/* + * Copyright (c) 2016, 2017 PTCRIS - FCT|FCCN and others. + * Licensed under MIT License + * http://ptcris.pt + * + * This copyright and license information (including a link to the full license) + * shall be included in its entirety in all copies or substantial portion of + * the software. + */ +package pt.ptcris.test.scenarios; + +import java.math.BigInteger; +import java.util.ArrayList; +import java.util.List; + +import org.um.dsi.gavea.orcid.model.funding.Funding; + +import pt.ptcris.test.TestHelper; +import pt.ptcris.test.TestClients; +import pt.ptcris.test.TestClients.Profile; +import pt.ptcris.utils.ORCIDFundingHelper; + +/** + * Scenario 6 of the PTCRISync specification v0.4.3, tests import. + * + * Features: + * modification notifications with {same,more} + * + * TODO: this scenario does not exactly represent the one from the specification + * as this would require that the fixture work was set as the preferred, which + * is impossible programmatically. This does not affect the scenario and one of + * the user-sourced is selected instead. + * + * @see Scenario + */ +public class ScenarioF06 extends ScenarioFunding { + + /** {@inheritDoc} */ + @Override + List setupORCIDExternalFundings() { + List works = new ArrayList(); + works.add(TestHelper.fundingNmbNmb(null, "0", "0", "3")); + works.add(TestHelper.fundingNmbNmb(null, "1", "2", "1")); + return works; + } + + /** {@inheritDoc} */ + @Override + List setupLocalFundings() { + List works = new ArrayList(); + works.add(TestHelper.fundingNmbNmbNmb(BigInteger.valueOf(2), "0", "0", "3", "1")); + works.add(TestHelper.fundingNmb(BigInteger.valueOf(1), "1", "2")); + return works; + } + + /** {@inheritDoc} */ + @Override + List expectedImportedFundings() { + List works = new ArrayList(); + Funding w = TestHelper.fundingNmbNmbNmb(BigInteger.valueOf(1), null, "0", "3", "1"); + w.setExternalIds(new ORCIDFundingHelper(null).getSelfExternalIdsE(w)); + works.add(w); + works.add(TestHelper.fundingNmb(BigInteger.valueOf(2), null, "2")); + return works; + } + + /** {@inheritDoc} */ + @Override + ORCIDFundingHelper crisClient() { + return new ORCIDFundingHelper(TestClients.getCRISClient(Profile.TWOVALIDWORKS)); + } + + /** {@inheritDoc} */ + @Override + ORCIDFundingHelper externalClient() { + return new ORCIDFundingHelper(TestClients.getExternalClient(Profile.TWOVALIDWORKS)); + } + +} diff --git a/src/test/java/pt/ptcris/test/scenarios/ScenarioF07.java b/src/test/java/pt/ptcris/test/scenarios/ScenarioF07.java new file mode 100644 index 0000000..7ae8472 --- /dev/null +++ b/src/test/java/pt/ptcris/test/scenarios/ScenarioF07.java @@ -0,0 +1,71 @@ +/* + * Copyright (c) 2016, 2017 PTCRIS - FCT|FCCN and others. + * Licensed under MIT License + * http://ptcris.pt + * + * This copyright and license information (including a link to the full license) + * shall be included in its entirety in all copies or substantial portion of + * the software. + */ +package pt.ptcris.test.scenarios; + +import java.math.BigInteger; +import java.util.ArrayList; +import java.util.List; + +import org.um.dsi.gavea.orcid.model.funding.Funding; + +import pt.ptcris.test.TestHelper; +import pt.ptcris.test.TestClients; +import pt.ptcris.test.TestClients.Profile; +import pt.ptcris.utils.ORCIDFundingHelper; + +/** + * Scenario 7 of the PTCRISync specification v0.4.3, tests import. + * + * Features: + * modification notifications at the pre-state + * + * TODO: this scenario does not exactly represent the one from the specification + * since notifications are not passed to the procedures, thus notifications at + * pre-state cannot be represented. + * + * TODO: this scenario does not exactly represent the one from the specification + * as this would require that the fixture work was set as the preferred, which + * is impossible programmatically. This does not affect the scenario and one of + * the user-sourced is selected instead. + * + * @see Scenario + */ +public class ScenarioF07 extends ScenarioFunding { + + /** {@inheritDoc} */ + @Override + List setupORCIDExternalFundings() { + List works = new ArrayList(); + works.add(TestHelper.fundingNmbNmb(null, "0", "0", "3")); + return works; + } + + /** {@inheritDoc} */ + @Override + List setupLocalFundings() { + List works = new ArrayList(); + works.add(TestHelper.fundingNmb(BigInteger.valueOf(1), "1", "2")); + works.add(TestHelper.fundingNmbNmbNmb(BigInteger.valueOf(2), "0", "0", "3", "1")); + return works; + } + + /** {@inheritDoc} */ + @Override + ORCIDFundingHelper crisClient() { + return new ORCIDFundingHelper(TestClients.getCRISClient(Profile.TWOVALIDWORKS)); + } + + /** {@inheritDoc} */ + @Override + ORCIDFundingHelper externalClient() { + return new ORCIDFundingHelper(TestClients.getExternalClient(Profile.TWOVALIDWORKS)); + } + +} diff --git a/src/test/java/pt/ptcris/test/scenarios/ScenarioF08.java b/src/test/java/pt/ptcris/test/scenarios/ScenarioF08.java new file mode 100644 index 0000000..c84aa85 --- /dev/null +++ b/src/test/java/pt/ptcris/test/scenarios/ScenarioF08.java @@ -0,0 +1,82 @@ +/* + * Copyright (c) 2016, 2017 PTCRIS - FCT|FCCN and others. + * Licensed under MIT License + * http://ptcris.pt + * + * This copyright and license information (including a link to the full license) + * shall be included in its entirety in all copies or substantial portion of + * the software. + */ +package pt.ptcris.test.scenarios; + +import java.math.BigInteger; +import java.util.ArrayList; +import java.util.List; + +import org.um.dsi.gavea.orcid.model.funding.Funding; + +import pt.ptcris.test.TestHelper; +import pt.ptcris.test.TestClients; +import pt.ptcris.test.TestClients.Profile; +import pt.ptcris.utils.ORCIDFundingHelper; + +/** + * Scenario 8 of the PTCRISync specification v0.4.3, tests export. + * + * Features: + * export add + * + * TODO: this scenario does not exactly represent the one from the specification + * as this would require that the fixture funding was set as the preferred, which + * is impossible programmatically. This does not affect the scenario and one of + * the user-sourced is selected instead. + * + * @see Scenario + */ +public class ScenarioF08 extends ScenarioFunding { + + /** {@inheritDoc} */ + @Override + List setupORCIDExternalFundings() { + List fundings = new ArrayList(); + fundings.add(TestHelper.fundingNmbNmb(BigInteger.valueOf(2), "0", "0", "3")); + return fundings; + } + + /** {@inheritDoc} */ + @Override + List setupLocalFundings() { + List fundings = new ArrayList(); + fundings.add(TestHelper.fundingNmb(BigInteger.valueOf(1), "1", "2")); + return fundings; + } + + /** {@inheritDoc} */ + @Override + List exportLocalFundings() { + List fundings = new ArrayList(); + fundings.add(TestHelper.fundingNmbNmbNmb(BigInteger.valueOf(2),"0", "0", "3", "1")); + return fundings; + } + + /** {@inheritDoc} */ + @Override + List expectedORCIDCRISFundings() { + List fundings = new ArrayList(); + fundings.add(TestHelper.fundingNmbNmbNmb(BigInteger.valueOf(2),"0", "0", "3", "1")); + return fundings; + } + + /** {@inheritDoc} */ + @Override + ORCIDFundingHelper crisClient() { + return new ORCIDFundingHelper(TestClients.getCRISClient(Profile.TWOVALIDWORKS)); + } + + /** {@inheritDoc} */ + @Override + ORCIDFundingHelper externalClient() { + return new ORCIDFundingHelper(TestClients.getExternalClient(Profile.TWOVALIDWORKS)); + } + +} diff --git a/src/test/java/pt/ptcris/test/scenarios/ScenarioF09.java b/src/test/java/pt/ptcris/test/scenarios/ScenarioF09.java new file mode 100644 index 0000000..f3b632f --- /dev/null +++ b/src/test/java/pt/ptcris/test/scenarios/ScenarioF09.java @@ -0,0 +1,82 @@ +/* + * Copyright (c) 2016, 2017 PTCRIS - FCT|FCCN and others. + * Licensed under MIT License + * http://ptcris.pt + * + * This copyright and license information (including a link to the full license) + * shall be included in its entirety in all copies or substantial portion of + * the software. + */ +package pt.ptcris.test.scenarios; + +import java.math.BigInteger; +import java.util.ArrayList; +import java.util.List; + +import org.um.dsi.gavea.orcid.model.funding.Funding; + +import pt.ptcris.test.TestHelper; +import pt.ptcris.test.TestClients; +import pt.ptcris.test.TestClients.Profile; +import pt.ptcris.utils.ORCIDFundingHelper; + +/** + * Scenario 9 of the PTCRISync specification v0.4.3, tests export. + * + * Features: + * export add + * + * TODO: this scenario does not exactly represent the one from the specification + * as this would require that the fixture funding was set as the preferred, which + * is impossible programmatically. This does not affect the scenario and one of + * the user-sourced is selected instead. + * + * @see Scenario + */ +public class ScenarioF09 extends ScenarioFunding { + + /** {@inheritDoc} */ + @Override + List setupORCIDExternalFundings() { + List fundings = new ArrayList(); + fundings.add(TestHelper.fundingNmbNmb(BigInteger.valueOf(2), "0", "0", "3")); + return fundings; + } + + /** {@inheritDoc} */ + @Override + List setupLocalFundings() { + List fundings = new ArrayList(); + fundings.add(TestHelper.fundingNmb(BigInteger.valueOf(1), "1", "2")); + return fundings; + } + + /** {@inheritDoc} */ + @Override + List exportLocalFundings() { + List fundings = new ArrayList(); + fundings.add(TestHelper.fundingNmbNmbNmb(BigInteger.valueOf(2),"0","0","3","1")); + return fundings; + } + + /** {@inheritDoc} */ + @Override + List expectedORCIDCRISFundings() { + List fundings = new ArrayList(); + fundings.add(TestHelper.fundingNmbNmbNmb(BigInteger.valueOf(2),"0","0","3","1")); + return fundings; + } + + /** {@inheritDoc} */ + @Override + ORCIDFundingHelper crisClient() { + return new ORCIDFundingHelper(TestClients.getCRISClient(Profile.TWOVALIDWORKS)); + } + + /** {@inheritDoc} */ + @Override + ORCIDFundingHelper externalClient() { + return new ORCIDFundingHelper(TestClients.getExternalClient(Profile.TWOVALIDWORKS)); + } + +} diff --git a/src/test/java/pt/ptcris/test/scenarios/ScenarioF10.java b/src/test/java/pt/ptcris/test/scenarios/ScenarioF10.java new file mode 100644 index 0000000..8a01e5a --- /dev/null +++ b/src/test/java/pt/ptcris/test/scenarios/ScenarioF10.java @@ -0,0 +1,76 @@ +/* + * Copyright (c) 2016, 2017 PTCRIS - FCT|FCCN and others. + * Licensed under MIT License + * http://ptcris.pt + * + * This copyright and license information (including a link to the full license) + * shall be included in its entirety in all copies or substantial portion of + * the software. + */ +package pt.ptcris.test.scenarios; + +import java.math.BigInteger; +import java.util.ArrayList; +import java.util.List; + +import org.um.dsi.gavea.orcid.model.funding.Funding; + +import pt.ptcris.test.TestHelper; +import pt.ptcris.test.TestClients; +import pt.ptcris.test.TestClients.Profile; +import pt.ptcris.utils.ORCIDFundingHelper; + +/** + * Scenario 10 of the PTCRISync specification v0.4.3, tests export. + * + * Features: + * export rem + * preferred consequences + * + * TODO: this scenario does not exactly represent the one from the specification + * as this would require that the fixture funding was set as the preferred, which + * is impossible programmatically. This affects the scenario since its goal + * is to depict the promotion of a funding to preferred. + * + * @see Scenario + */ +public class ScenarioF10 extends ScenarioFunding { + + /** {@inheritDoc} */ + @Override + List setupORCIDCRISFundings() { + List fundings = new ArrayList(); + fundings.add(TestHelper.fundingNmbNmbNmb (null,"0","0","2", "1")); + return fundings; + } + + /** {@inheritDoc} */ + @Override + List setupORCIDExternalFundings() { + List fundings = new ArrayList(); + fundings.add(TestHelper.fundingNmbNmb(BigInteger.valueOf(2), "0", "0", "3")); + return fundings; + } + + /** {@inheritDoc} */ + @Override + List setupLocalFundings() { + List fundings = new ArrayList(); + fundings.add(TestHelper.fundingNmb(BigInteger.valueOf(1), "1", "2")); + fundings.add(TestHelper.fundingNmbNmbNmb(BigInteger.valueOf(2),"0","0","3", "1")); + return fundings; + } + + /** {@inheritDoc} */ + @Override + ORCIDFundingHelper crisClient() { + return new ORCIDFundingHelper(TestClients.getCRISClient(Profile.TWOVALIDWORKS)); + } + + /** {@inheritDoc} */ + @Override + ORCIDFundingHelper externalClient() { + return new ORCIDFundingHelper(TestClients.getExternalClient(Profile.TWOVALIDWORKS)); + } + +} diff --git a/src/test/java/pt/ptcris/test/scenarios/ScenarioF11.java b/src/test/java/pt/ptcris/test/scenarios/ScenarioF11.java new file mode 100644 index 0000000..8aa8440 --- /dev/null +++ b/src/test/java/pt/ptcris/test/scenarios/ScenarioF11.java @@ -0,0 +1,100 @@ +/* + * Copyright (c) 2016, 2017 PTCRIS - FCT|FCCN and others. + * Licensed under MIT License + * http://ptcris.pt + * + * This copyright and license information (including a link to the full license) + * shall be included in its entirety in all copies or substantial portion of + * the software. + */ +package pt.ptcris.test.scenarios; + +import java.math.BigInteger; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +import org.um.dsi.gavea.orcid.model.funding.Funding; + +import pt.ptcris.PTCRISyncResult; +import pt.ptcris.test.TestHelper; +import pt.ptcris.test.TestClients; +import pt.ptcris.test.TestClients.Profile; +import pt.ptcris.utils.ORCIDFundingHelper; + +/** + * Scenario 11 of the PTCRISync specification v0.4.3, tests export. + * + * Features: + * export update with {same} + * + * TODO: this scenario does not exactly represent the one from the specification + * as this would require that the fixture funding was set as the preferred, which + * is impossible programmatically. This affects the scenario since its goal + * is to depict the promotion of a funding to preferred. + * + * @see Scenario + */ +public class ScenarioF11 extends ScenarioFunding { + + /** {@inheritDoc} */ + @Override + List setupORCIDCRISFundings() { + List fundings = new ArrayList(); + fundings.add(TestHelper.fundingNmbNmbNmb(BigInteger.valueOf(2), "0", "0", "3", "1")); + return fundings; + } + + /** {@inheritDoc} */ + @Override + List setupORCIDExternalFundings() { + List fundings = new ArrayList(); + fundings.add(TestHelper.fundingNmbNmb(BigInteger.valueOf(2), "0", "0", "3")); + return fundings; + } + + /** {@inheritDoc} */ + @Override + List setupLocalFundings() { + List fundings = new ArrayList(); + fundings.add(TestHelper.fundingNmb(BigInteger.valueOf(1), "1", "2")); + return fundings; + } + + /** {@inheritDoc} */ + @Override + List exportLocalFundings() { + List fundings = new ArrayList(); + fundings.add(TestHelper.fundingNmbNmbNmb(BigInteger.valueOf(2), "3", "0", "3", "1")); + return fundings; + } + + /** {@inheritDoc} */ + @Override + List expectedORCIDCRISFundings() { + List fundings = new ArrayList(); + fundings.add(TestHelper.fundingNmbNmbNmb(BigInteger.valueOf(2), "3", "0", "3", "1")); + return fundings; + } + + /** {@inheritDoc} */ + Set expectedExportCodes(BigInteger putcode) { + Set res = new HashSet(); + res.add(PTCRISyncResult.UPDATEOK); + return res; + } + + /** {@inheritDoc} */ + @Override + ORCIDFundingHelper crisClient() { + return new ORCIDFundingHelper(TestClients.getCRISClient(Profile.TWOVALIDWORKS)); + } + + /** {@inheritDoc} */ + @Override + ORCIDFundingHelper externalClient() { + return new ORCIDFundingHelper(TestClients.getExternalClient(Profile.TWOVALIDWORKS)); + } + +} diff --git a/src/test/java/pt/ptcris/test/scenarios/ScenarioF12.java b/src/test/java/pt/ptcris/test/scenarios/ScenarioF12.java new file mode 100644 index 0000000..69d9f2f --- /dev/null +++ b/src/test/java/pt/ptcris/test/scenarios/ScenarioF12.java @@ -0,0 +1,92 @@ +/* + * Copyright (c) 2016, 2017 PTCRIS - FCT|FCCN and others. + * Licensed under MIT License + * http://ptcris.pt + * + * This copyright and license information (including a link to the full license) + * shall be included in its entirety in all copies or substantial portion of + * the software. + */ +package pt.ptcris.test.scenarios; + +import java.math.BigInteger; +import java.util.ArrayList; +import java.util.List; + +import org.um.dsi.gavea.orcid.model.funding.Funding; + +import pt.ptcris.test.TestHelper; +import pt.ptcris.test.TestClients; +import pt.ptcris.test.TestClients.Profile; +import pt.ptcris.utils.ORCIDFundingHelper; + +/** + * Scenario 12 of the PTCRISync specification v0.4.3, tests export and import. + * + * Features: export breaks import export add modification notifications with + * {same,more} + * + * @see ScenarioFunding + */ +public class ScenarioF12 extends ScenarioFunding { + + /** {@inheritDoc} */ + @Override + List setupORCIDExternalFundings() { + List fundings = new ArrayList(); + fundings.add(TestHelper.fundingNmbNmb(null, "0", "0", "3")); + return fundings; + } + + /** {@inheritDoc} */ + @Override + List setupLocalFundings() { + List fundings = new ArrayList(); + fundings.add(TestHelper.fundingNmb(BigInteger.valueOf(1), "1", "2")); + return fundings; + } + + /** {@inheritDoc} */ + @Override + List exportLocalFundings() { + List fundings = new ArrayList(); + fundings.add(TestHelper.fundingNmbNmbNmbNmb(BigInteger.valueOf(2), + "0", "0", "2", "3", "1")); + return fundings; + } + + /** {@inheritDoc} */ + @Override + List expectedORCIDCRISFundings() { + List fundings = new ArrayList(); + fundings.add(TestHelper.fundingNmbNmbNmbNmb(BigInteger.valueOf(2), + "0", "0", "2", "3", "1")); + return fundings; + } + + /** {@inheritDoc} */ + @Override + List expectedImportedFundings() { + List fundings = new ArrayList(); + Funding w = TestHelper.fundingNmbNmbNmb(BigInteger.valueOf(1), null, + "0", "3", "1"); + w.setExternalIds(new ORCIDFundingHelper(null).getSelfExternalIdsE(w)); + fundings.add(w); + return fundings; + } + + /** {@inheritDoc} */ + @Override + ORCIDFundingHelper crisClient() { + return new ORCIDFundingHelper( + TestClients.getCRISClient(Profile.TWOVALIDWORKS)); + } + + /** {@inheritDoc} */ + @Override + ORCIDFundingHelper externalClient() { + return new ORCIDFundingHelper( + TestClients.getExternalClient(Profile.TWOVALIDWORKS)); + } + +} diff --git a/src/test/java/pt/ptcris/test/scenarios/ScenarioF13.java b/src/test/java/pt/ptcris/test/scenarios/ScenarioF13.java new file mode 100644 index 0000000..d42c462 --- /dev/null +++ b/src/test/java/pt/ptcris/test/scenarios/ScenarioF13.java @@ -0,0 +1,118 @@ +/* + * Copyright (c) 2016, 2017 PTCRIS - FCT|FCCN and others. + * Licensed under MIT License + * http://ptcris.pt + * + * This copyright and license information (including a link to the full license) + * shall be included in its entirety in all copies or substantial portion of + * the software. + */ +package pt.ptcris.test.scenarios; + +import java.math.BigInteger; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +import org.um.dsi.gavea.orcid.model.funding.Funding; + +import pt.ptcris.PTCRISyncResult; +import pt.ptcris.test.TestHelper; +import pt.ptcris.test.TestClients; +import pt.ptcris.test.TestClients.Profile; +import pt.ptcris.utils.ORCIDHelper; +import pt.ptcris.utils.ORCIDFundingHelper; + +/** + * Scenario 13 of the PTCRISync specification v0.4.3, tests export and import. + * + * Features: + * export breaks import + * export del + * export update {same,more} + * modification notifications with {same,more} + * + * @see Scenario + */ +public class ScenarioF13 extends ScenarioFunding { + + /** {@inheritDoc} */ + @Override + List setupORCIDCRISFundings() { + List fundings = new ArrayList(); + fundings.add(TestHelper.fundingNmb(null, "3", "0")); + fundings.add(TestHelper.fundingNmb(null, "1", "1")); + return fundings; + } + + /** {@inheritDoc} */ + @Override + List setupLocalFundings() { + List fundings = new ArrayList(); + fundings.add(TestHelper.fundingNmb(BigInteger.valueOf(1), "1", "1")); + return fundings; + } + + /** {@inheritDoc} */ + @Override + List exportLocalFundings() { + List fundings = new ArrayList(); + fundings.add(TestHelper.fundingNmbNmb(BigInteger.valueOf(2), "3", "0", "1")); + return fundings; + } + + /** {@inheritDoc} */ + @Override + List expectedORCIDCRISFundings() { + List fundings = new ArrayList(); + fundings.add(TestHelper.fundingNmbNmb(BigInteger.valueOf(2), "3", "0", "1")); + return fundings; + } + + /** {@inheritDoc} */ + @Override + List expectedImportedFundings() { + List fundings = new ArrayList(); + fundings.add(TestHelper.fundingNmb(BigInteger.valueOf(1), null, "0")); + return fundings; + } + + /** {@inheritDoc} */ + @Override + List expectedImportedInvalidFundings() { + List fundings = new ArrayList(); + Funding funding = TestHelper.fundingNmb(null, "1", "I2"); + funding.setStartDate(null); + fundings.add(funding); + return fundings; + } + + /** {@inheritDoc} */ + @Override + Set expectedInvalidCodes(BigInteger putCode) { + Set res = new HashSet(); + res.add(ORCIDHelper.INVALID_PUBLICATIONDATE); + return res; + } + + /** {@inheritDoc} */ + Set expectedExportCodes(BigInteger putcode) { + Set res = new HashSet(); + res.add(PTCRISyncResult.UPDATEOK); + return res; + } + + /** {@inheritDoc} */ + @Override + ORCIDFundingHelper crisClient() { + return new ORCIDFundingHelper(TestClients.getCRISClient(Profile.ZEROVALIDWORKS)); + } + + /** {@inheritDoc} */ + @Override + ORCIDFundingHelper externalClient() { + return new ORCIDFundingHelper(TestClients.getExternalClient(Profile.ZEROVALIDWORKS)); + } + +} diff --git a/src/test/java/pt/ptcris/test/scenarios/ScenarioF14.java b/src/test/java/pt/ptcris/test/scenarios/ScenarioF14.java new file mode 100644 index 0000000..77aae63 --- /dev/null +++ b/src/test/java/pt/ptcris/test/scenarios/ScenarioF14.java @@ -0,0 +1,104 @@ +/* + * Copyright (c) 2016, 2017 PTCRIS - FCT|FCCN and others. + * Licensed under MIT License + * http://ptcris.pt + * + * This copyright and license information (including a link to the full license) + * shall be included in its entirety in all copies or substantial portion of + * the software. + */ +package pt.ptcris.test.scenarios; + +import java.math.BigInteger; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +import org.um.dsi.gavea.orcid.model.funding.Funding; + +import pt.ptcris.PTCRISyncResult; +import pt.ptcris.test.TestHelper; +import pt.ptcris.test.TestClients; +import pt.ptcris.test.TestClients.Profile; +import pt.ptcris.utils.ORCIDHelper; +import pt.ptcris.utils.ORCIDFundingHelper; + +/** + * Scenario 14 of the PTCRISync specification v0.4.3, tests export. + * + * Features: + * export fixes import + * export add + * export update {same,less} + * + * @see Scenario + */ +public class ScenarioF14 extends ScenarioFunding { + + /** {@inheritDoc} */ + @Override + List setupORCIDCRISFundings() { + List fundings = new ArrayList(); + fundings.add(TestHelper.fundingNmbNmb(null, "3", "0", "1")); + return fundings; + } + + /** {@inheritDoc} */ + @Override + List exportLocalFundings() { + List fundings = new ArrayList(); + fundings.add(TestHelper.fundingNmb(BigInteger.valueOf(2), "3", "0")); + fundings.add(TestHelper.fundingNmb(BigInteger.valueOf(1), "1", "1")); + return fundings; + } + + /** {@inheritDoc} */ + @Override + List expectedORCIDCRISFundings() { + List fundings = new ArrayList(); + fundings.add(TestHelper.fundingNmb(BigInteger.valueOf(2), "3", "0")); + fundings.add(TestHelper.fundingNmb(BigInteger.valueOf(1), "1", "1")); + return fundings; + } + + /** {@inheritDoc} */ + @Override + List expectedImportedInvalidFundings() { + List fundings = new ArrayList(); + Funding funding = TestHelper.fundingNmb(null, "1", "I2"); + funding.setStartDate(null); + fundings.add(funding); + return fundings; + } + + /** {@inheritDoc} */ + @Override + Set expectedInvalidCodes(BigInteger putCode) { + Set res = new HashSet(); + res.add(ORCIDHelper.INVALID_PUBLICATIONDATE); + return res; + } + + /** {@inheritDoc} */ + Set expectedExportCodes(BigInteger putcode) { + Set res = new HashSet(); + res.add(PTCRISyncResult.ADDOK); + res.add(PTCRISyncResult.UPDATEOK); + return res; + } + + /** {@inheritDoc} */ + @Override + ORCIDFundingHelper crisClient() { + return new ORCIDFundingHelper( + TestClients.getCRISClient(Profile.ZEROVALIDWORKS)); + } + + /** {@inheritDoc} */ + @Override + ORCIDFundingHelper externalClient() { + return new ORCIDFundingHelper(TestClients.getExternalClient(Profile.ZEROVALIDWORKS)); + } + +} diff --git a/src/test/java/pt/ptcris/test/scenarios/ScenarioF15.java b/src/test/java/pt/ptcris/test/scenarios/ScenarioF15.java new file mode 100644 index 0000000..e127609 --- /dev/null +++ b/src/test/java/pt/ptcris/test/scenarios/ScenarioF15.java @@ -0,0 +1,82 @@ +/* + * Copyright (c) 2016, 2017 PTCRIS - FCT|FCCN and others. + * Licensed under MIT License + * http://ptcris.pt + * + * This copyright and license information (including a link to the full license) + * shall be included in its entirety in all copies or substantial portion of + * the software. + */ +package pt.ptcris.test.scenarios; + +import java.math.BigInteger; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +import org.um.dsi.gavea.orcid.model.funding.Funding; + +import pt.ptcris.test.TestHelper; +import pt.ptcris.test.TestClients; +import pt.ptcris.test.TestClients.Profile; +import pt.ptcris.utils.ORCIDHelper; +import pt.ptcris.utils.ORCIDFundingHelper; + +/** + * Scenario 15 of the PTCRISync specification v0.4.3, tests import. + * + * Features: + * modification notifications with {same,more,less} + * + * @see Scenario + */ +public class ScenarioF15 extends ScenarioFunding { + + /** {@inheritDoc} */ + @Override + List setupLocalFundings() { + List fundings = new ArrayList(); + fundings.add(TestHelper.fundingNmbNmb(BigInteger.valueOf(1), "1", "0", "2")); + return fundings; + } + + /** {@inheritDoc} */ + @Override + List expectedImportedFundings() { + List fundings = new ArrayList(); + Funding w = TestHelper.fundingNmb(BigInteger.valueOf(1), null, "1"); + w.setExternalIds(new ORCIDFundingHelper(null).getSelfExternalIdsE(w)); + fundings.add(w); + return fundings; + } + + /** {@inheritDoc} */ + @Override + List expectedImportedInvalidFundings() { + List fundings = new ArrayList(); + fundings.add(TestHelper.funding(null, "0")); + return fundings; + } + + /** {@inheritDoc} */ + @Override + Set expectedInvalidCodes(BigInteger putCode) { + Set res = new HashSet(); + res.add(ORCIDHelper.INVALID_EXTERNALIDENTIFIERS); + return res; + } + + /** {@inheritDoc} */ + @Override + ORCIDFundingHelper crisClient() { + return new ORCIDFundingHelper(TestClients.getCRISClient(Profile.ONEVALIDWORKS)); + } + + /** {@inheritDoc} */ + @Override + ORCIDFundingHelper externalClient() { + return new ORCIDFundingHelper(TestClients.getExternalClient(Profile.ONEVALIDWORKS)); + } + +} diff --git a/src/test/java/pt/ptcris/test/scenarios/ScenarioF16.java b/src/test/java/pt/ptcris/test/scenarios/ScenarioF16.java new file mode 100644 index 0000000..310c685 --- /dev/null +++ b/src/test/java/pt/ptcris/test/scenarios/ScenarioF16.java @@ -0,0 +1,96 @@ +/* + * Copyright (c) 2016, 2017 PTCRIS - FCT|FCCN and others. + * Licensed under MIT License + * http://ptcris.pt + * + * This copyright and license information (including a link to the full license) + * shall be included in its entirety in all copies or substantial portion of + * the software. + */ +package pt.ptcris.test.scenarios; + +import java.math.BigInteger; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +import org.um.dsi.gavea.orcid.model.funding.Funding; + +import pt.ptcris.test.TestHelper; +import pt.ptcris.test.TestClients; +import pt.ptcris.test.TestClients.Profile; +import pt.ptcris.utils.ORCIDHelper; +import pt.ptcris.utils.ORCIDFundingHelper; + +/** + * Scenario 16 of the PTCRISync specification v0.4.3, tests import. + * + * Features: + * modification notifications at pre-state + * multiple modification notifications + * modification notifications with {same,more,less} + * + * @see Scenario + */ +public class ScenarioF16 extends ScenarioFunding { + + /** {@inheritDoc} */ + @Override + List setupORCIDExternalFundings() { + List fundings = new ArrayList(); + fundings.add(TestHelper.fundingNmbNmb(null, "3", "3", "2")); + return fundings; + } + + /** {@inheritDoc} */ + @Override + List setupLocalFundings() { + List fundings = new ArrayList(); + fundings.add(TestHelper.fundingNmbNmb(BigInteger.valueOf(1), "1", "0", "3")); + return fundings; + } + + /** {@inheritDoc} */ + @Override + List expectedImportedFundings() { + List fundings = new ArrayList(); + Funding w = TestHelper.fundingNmb(BigInteger.valueOf(1), null, "2"); + w.setExternalIds(new ORCIDFundingHelper(null).getSelfExternalIdsE(w)); + fundings.add(w); + Funding w1 = TestHelper.fundingNmb(BigInteger.valueOf(1), null, "1"); + w1.setExternalIds(new ORCIDFundingHelper(null).getSelfExternalIdsE(w1)); + fundings.add(w1); + return fundings; + } + + /** {@inheritDoc} */ + @Override + List expectedImportedInvalidFundings() { + List fundings = new ArrayList(); + fundings.add(TestHelper.funding(null, "0")); + return fundings; + } + + /** {@inheritDoc} */ + @Override + Set expectedInvalidCodes(BigInteger putCode) { + Set res = new HashSet(); + res.add(ORCIDHelper.INVALID_EXTERNALIDENTIFIERS); + return res; + } + + /** {@inheritDoc} */ + @Override + ORCIDFundingHelper crisClient() { + return new ORCIDFundingHelper(TestClients.getCRISClient(Profile.ONEVALIDWORKS)); + } + + /** {@inheritDoc} */ + @Override + ORCIDFundingHelper externalClient() { + return new ORCIDFundingHelper( + TestClients.getExternalClient(Profile.ONEVALIDWORKS)); + } + +} diff --git a/src/test/java/pt/ptcris/test/scenarios/ScenarioF17.java b/src/test/java/pt/ptcris/test/scenarios/ScenarioF17.java new file mode 100644 index 0000000..0bf8be5 --- /dev/null +++ b/src/test/java/pt/ptcris/test/scenarios/ScenarioF17.java @@ -0,0 +1,107 @@ +/* + * Copyright (c) 2016, 2017 PTCRIS - FCT|FCCN and others. + * Licensed under MIT License + * http://ptcris.pt + * + * This copyright and license information (including a link to the full license) + * shall be included in its entirety in all copies or substantial portion of + * the software. + */ +package pt.ptcris.test.scenarios; + +import java.math.BigInteger; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +import org.um.dsi.gavea.orcid.model.funding.Funding; + +import pt.ptcris.PTCRISyncResult; +import pt.ptcris.test.TestHelper; +import pt.ptcris.test.TestClients; +import pt.ptcris.test.TestClients.Profile; +import pt.ptcris.utils.ORCIDHelper; +import pt.ptcris.utils.ORCIDFundingHelper; + +/** + * Scenario 17 of the PTCRISync specification v0.4.3, tests export and import. + * + * Features: + * creation notifications at pre-state + * export updates with {less,same,more} + * + * @see Scenario + */ +public class ScenarioF17 extends ScenarioFunding { + + /** {@inheritDoc} */ + @Override + List setupORCIDCRISFundings() { + List fundings = new ArrayList(); + fundings.add(TestHelper.fundingNmbNmb(null, "3", "0", "1")); + return fundings; + } + + /** {@inheritDoc} */ + @Override + List setupORCIDExternalFundings() { + List fundings = new ArrayList(); + fundings.add(TestHelper.fundingNmb(null, "1", "2")); + return fundings; + } + + /** {@inheritDoc} */ + @Override + List exportLocalFundings() { + List fundings = new ArrayList(); + fundings.add(TestHelper.fundingNmbNmb(BigInteger.valueOf(2), "3", "0", "2")); + return fundings; + } + + /** {@inheritDoc} */ + @Override + List expectedORCIDCRISFundings() { + List fundings = new ArrayList(); + fundings.add(TestHelper.fundingNmbNmb(null, "3", "0", "2")); + return fundings; + } + + /** {@inheritDoc} */ + @Override + List expectedImportedInvalidFundings() { + List fundings = new ArrayList(); + Funding funding = TestHelper.fundingNmb(null, "1", "I2"); + funding.setStartDate(null); + fundings.add(funding); + return fundings; + } + + /** {@inheritDoc} */ + @Override + Set expectedInvalidCodes(BigInteger putCode) { + Set res = new HashSet(); + res.add(ORCIDHelper.INVALID_PUBLICATIONDATE); + return res; + } + + /** {@inheritDoc} */ + Set expectedExportCodes(BigInteger putcode) { + Set res = new HashSet(); + res.add(PTCRISyncResult.UPDATEOK); + return res; + } + + /** {@inheritDoc} */ + @Override + ORCIDFundingHelper crisClient() { + return new ORCIDFundingHelper(TestClients.getCRISClient(Profile.ZEROVALIDWORKS)); + } + + /** {@inheritDoc} */ + @Override + ORCIDFundingHelper externalClient() { + return new ORCIDFundingHelper(TestClients.getExternalClient(Profile.ZEROVALIDWORKS)); + } + +} diff --git a/src/test/java/pt/ptcris/test/scenarios/ScenarioF18.java b/src/test/java/pt/ptcris/test/scenarios/ScenarioF18.java new file mode 100644 index 0000000..7950b42 --- /dev/null +++ b/src/test/java/pt/ptcris/test/scenarios/ScenarioF18.java @@ -0,0 +1,104 @@ +/* + * Copyright (c) 2016, 2017 PTCRIS - FCT|FCCN and others. + * Licensed under MIT License + * http://ptcris.pt + * + * This copyright and license information (including a link to the full license) + * shall be included in its entirety in all copies or substantial portion of + * the software. + */ +package pt.ptcris.test.scenarios; + +import java.math.BigInteger; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +import org.um.dsi.gavea.orcid.model.funding.Funding; + +import pt.ptcris.PTCRISyncResult; +import pt.ptcris.test.TestHelper; +import pt.ptcris.test.TestClients; +import pt.ptcris.test.TestClients.Profile; +import pt.ptcris.utils.ORCIDHelper; +import pt.ptcris.utils.ORCIDFundingHelper; + +/** + * Scenario 18 of the PTCRISync specification v0.4.3, tests export. + * + * Features: + * export fixes import + * export updates with {less,same,more} + * + * @see Scenario + */ +public class ScenarioF18 extends ScenarioFunding { + + /** {@inheritDoc} */ + @Override + List setupORCIDCRISFundings() { + List fundings = new ArrayList(); + fundings.add(TestHelper.fundingNmbNmb(null, "3", "0", "1")); + fundings.add(TestHelper.fundingNmbNmb(null, "3", "2", "3")); + return fundings; + } + + /** {@inheritDoc} */ + @Override + List exportLocalFundings() { + List fundings = new ArrayList(); + fundings.add(TestHelper.fundingNmbNmb(BigInteger.valueOf(1), "3", "2", "1")); + fundings.add(TestHelper.fundingNmbNmb(BigInteger.valueOf(2), "3", "0", "3")); + return fundings; + } + + /** {@inheritDoc} */ + @Override + List expectedORCIDCRISFundings() { + List fundings = new ArrayList(); + fundings.add(TestHelper.fundingNmbNmb(null, "3", "2", "1")); + fundings.add(TestHelper.fundingNmbNmb(null, "3", "0", "3")); + return fundings; + } + + /** {@inheritDoc} */ + @Override + List expectedImportedInvalidFundings() { + List fundings = new ArrayList(); + Funding funding = TestHelper.fundingNmb(null, "1", "I2"); + funding.setStartDate(null); + fundings.add(funding); + return fundings; + } + + /** {@inheritDoc} */ + @Override + Set expectedInvalidCodes(BigInteger putCode) { + Set res = new HashSet(); + res.add(ORCIDHelper.INVALID_PUBLICATIONDATE); + return res; + } + + /** {@inheritDoc} */ + Set expectedExportCodes(BigInteger putcode) { + Set res = new HashSet(); + res.add(PTCRISyncResult.UPDATEOK); + return res; + } + + /** {@inheritDoc} */ + @Override + ORCIDFundingHelper crisClient() { + return new ORCIDFundingHelper( + TestClients.getCRISClient(Profile.ZEROVALIDWORKS)); + } + + /** {@inheritDoc} */ + @Override + ORCIDFundingHelper externalClient() { + return new ORCIDFundingHelper( + TestClients.getExternalClient(Profile.ZEROVALIDWORKS)); + } + +} diff --git a/src/test/java/pt/ptcris/test/scenarios/ScenarioF19.java b/src/test/java/pt/ptcris/test/scenarios/ScenarioF19.java new file mode 100644 index 0000000..069c813 --- /dev/null +++ b/src/test/java/pt/ptcris/test/scenarios/ScenarioF19.java @@ -0,0 +1,104 @@ +/* + * Copyright (c) 2016, 2017 PTCRIS - FCT|FCCN and others. + * Licensed under MIT License + * http://ptcris.pt + * + * This copyright and license information (including a link to the full license) + * shall be included in its entirety in all copies or substantial portion of + * the software. + */ +package pt.ptcris.test.scenarios; + +import java.math.BigInteger; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +import org.um.dsi.gavea.orcid.model.funding.Funding; + +import pt.ptcris.PTCRISyncResult; +import pt.ptcris.test.TestHelper; +import pt.ptcris.test.TestClients; +import pt.ptcris.test.TestClients.Profile; +import pt.ptcris.utils.ORCIDHelper; +import pt.ptcris.utils.ORCIDFundingHelper; + +/** + * Scenario 19 of the PTCRISync specification v0.4.3, tests export. + * + * Features: + * export updates with {same} + * + * @see Scenario + */ +public class ScenarioF19 extends ScenarioFunding { + + /** {@inheritDoc} */ + @Override + List setupORCIDCRISFundings() { + List fundings = new ArrayList(); + fundings.add(TestHelper.fundingNmbNmbNmb(null, "1", "1", "0", "2")); + return fundings; + } + + /** {@inheritDoc} */ + @Override + List exportLocalFundings() { + List fundings = new ArrayList(); + fundings.add(TestHelper.fundingNmbNmbNmb(BigInteger.valueOf(0), "1", "1", + "0", "2")); + return fundings; + } + + /** {@inheritDoc} */ + @Override + List expectedORCIDCRISFundings() { + List fundings = new ArrayList(); + fundings.add(TestHelper.fundingNmbNmbNmb(null, "1", "1", "0", "2")); + return fundings; + } + + /** {@inheritDoc} */ + Set expectedExportCodes(BigInteger putcode) { + Set res = new HashSet(); + if (putcode.equals(BigInteger.valueOf(0))) + res.add(PTCRISyncResult.UPTODATE); + else + res.add(PTCRISyncResult.ADDOK); + return res; + } + + /** {@inheritDoc} */ + @Override + List expectedImportedInvalidFundings() { + List fundings = new ArrayList(); + Funding funding = TestHelper.fundingNmb(null, "1", "I2"); + funding.setStartDate(null); + fundings.add(funding); + return fundings; + } + + /** {@inheritDoc} */ + @Override + Set expectedInvalidCodes(BigInteger putCode) { + Set res = new HashSet(); + res.add(ORCIDHelper.INVALID_PUBLICATIONDATE); + return res; + } + + /** {@inheritDoc} */ + @Override + ORCIDFundingHelper crisClient() { + return new ORCIDFundingHelper( + TestClients.getCRISClient(Profile.ZEROVALIDWORKS)); + } + + /** {@inheritDoc} */ + @Override + ORCIDFundingHelper externalClient() { + return new ORCIDFundingHelper( + TestClients.getExternalClient(Profile.ZEROVALIDWORKS)); + } + +} diff --git a/src/test/java/pt/ptcris/test/scenarios/ScenarioF20.java b/src/test/java/pt/ptcris/test/scenarios/ScenarioF20.java new file mode 100644 index 0000000..9190715 --- /dev/null +++ b/src/test/java/pt/ptcris/test/scenarios/ScenarioF20.java @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2016, 2017 PTCRIS - FCT|FCCN and others. + * Licensed under MIT License + * http://ptcris.pt + * + * This copyright and license information (including a link to the full license) + * shall be included in its entirety in all copies or substantial portion of + * the software. + */ +package pt.ptcris.test.scenarios; + +import pt.ptcris.test.TestClients; +import pt.ptcris.test.TestClients.Profile; +import pt.ptcris.utils.ORCIDFundingHelper; + +/** + * Scenario 20 of the PTCRISync specification v0.4.3, tests export. + * + * Features: empty profile + * + * @see Scenario + */ +public class ScenarioF20 extends ScenarioFunding { + + /** {@inheritDoc} */ + @Override + ORCIDFundingHelper crisClient() { + return new ORCIDFundingHelper(TestClients.getCRISClient(Profile.EMPTYWORKS)); + } + + /** {@inheritDoc} */ + @Override + ORCIDFundingHelper externalClient() { + return new ORCIDFundingHelper( + TestClients.getExternalClient(Profile.EMPTYWORKS)); + } + +} diff --git a/src/test/java/pt/ptcris/test/scenarios/ScenarioFIgnoredTypes.java b/src/test/java/pt/ptcris/test/scenarios/ScenarioFIgnoredTypes.java new file mode 100644 index 0000000..32656ad --- /dev/null +++ b/src/test/java/pt/ptcris/test/scenarios/ScenarioFIgnoredTypes.java @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2016, 2017 PTCRIS - FCT|FCCN and others. + * Licensed under MIT License + * http://ptcris.pt + * + * This copyright and license information (including a link to the full license) + * shall be included in its entirety in all copies or substantial portion of + * the software. + */ +package pt.ptcris.test.scenarios; + +import java.math.BigInteger; +import java.util.ArrayList; +import java.util.List; + +import org.um.dsi.gavea.orcid.model.funding.Funding; + +import pt.ptcris.test.TestClients; +import pt.ptcris.test.TestHelper; +import pt.ptcris.test.TestClients.Profile; +import pt.ptcris.utils.ORCIDFundingHelper; + +/** + * Scenario 20 of the PTCRISync specification v0.4.3, tests export. + * + * Features: empty profile + * + * @see Scenario + */ +public class ScenarioFIgnoredTypes extends ScenarioFunding { + + + /** {@inheritDoc} */ + @Override + List exportLocalFundings() { + List res = new ArrayList(); + res.add(TestHelper.fundingIgn(BigInteger.valueOf(2), "0", "0")); + res.add(TestHelper.fundingIgn(BigInteger.valueOf(3), "1", "1")); + return res; + } + + /** {@inheritDoc} */ + @Override + ORCIDFundingHelper crisClient() { + return new ORCIDFundingHelper(TestClients.getCRISClient(Profile.EMPTYWORKS)); + } + + /** {@inheritDoc} */ + @Override + ORCIDFundingHelper externalClient() { + return new ORCIDFundingHelper( + TestClients.getExternalClient(Profile.EMPTYWORKS)); + } + +} diff --git a/src/test/java/pt/ptcris/test/scenarios/ScenarioFInvalidLocal.java b/src/test/java/pt/ptcris/test/scenarios/ScenarioFInvalidLocal.java new file mode 100644 index 0000000..4784535 --- /dev/null +++ b/src/test/java/pt/ptcris/test/scenarios/ScenarioFInvalidLocal.java @@ -0,0 +1,90 @@ +/* + * Copyright (c) 2016, 2017 PTCRIS - FCT|FCCN and others. + * Licensed under MIT License + * http://ptcris.pt + * + * This copyright and license information (including a link to the full license) + * shall be included in its entirety in all copies or substantial portion of + * the software. + */ +package pt.ptcris.test.scenarios; + +import java.math.BigInteger; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +import org.um.dsi.gavea.orcid.model.funding.Funding; + +import pt.ptcris.PTCRISyncResult; +import pt.ptcris.test.TestHelper; +import pt.ptcris.test.TestClients; +import pt.ptcris.test.TestClients.Profile; +import pt.ptcris.utils.ORCIDHelper; +import pt.ptcris.utils.ORCIDFundingHelper; + +public class ScenarioFInvalidLocal extends ScenarioFunding { + + /** {@inheritDoc} */ + @Override + List setupLocalFundings() { + List fundings = new ArrayList(); + fundings.add(TestHelper.fundingNmb(BigInteger.valueOf(1), "1", "1")); + return fundings; + } + + /** {@inheritDoc} */ + @Override + List exportLocalFundings() { + List fundings = new ArrayList(); + fundings.add(TestHelper.fundingNmbNmb(BigInteger.valueOf(2), null, "0", + "1")); + fundings.add(TestHelper.funding(BigInteger.valueOf(3), "3")); + return fundings; + } + + /** {@inheritDoc} */ + Set expectedExportCodes(BigInteger putcode) { + Set res = new HashSet(); + if (putcode.equals(BigInteger.valueOf(2)) + || putcode.equals(BigInteger.valueOf(3))) + res.add(PTCRISyncResult.INVALID); + else + res.add(PTCRISyncResult.ADDOK); + return res; + } + + /** {@inheritDoc} */ + @Override + List expectedImportedInvalidFundings() { + List fundings = new ArrayList(); + Funding funding = TestHelper.fundingNmb(null, "1", "I2"); + funding.setStartDate(null); + fundings.add(funding); + return fundings; + } + + /** {@inheritDoc} */ + @Override + Set expectedInvalidCodes(BigInteger putCode) { + Set res = new HashSet(); + res.add(ORCIDHelper.INVALID_PUBLICATIONDATE); + return res; + } + + /** {@inheritDoc} */ + @Override + ORCIDFundingHelper crisClient() { + return new ORCIDFundingHelper( + TestClients.getCRISClient(Profile.ZEROVALIDWORKS)); + } + + /** {@inheritDoc} */ + @Override + ORCIDFundingHelper externalClient() { + return new ORCIDFundingHelper( + TestClients.getExternalClient(Profile.ZEROVALIDWORKS)); + } + +} diff --git a/src/test/java/pt/ptcris/test/scenarios/ScenarioFunding.java b/src/test/java/pt/ptcris/test/scenarios/ScenarioFunding.java new file mode 100644 index 0000000..e0f2075 --- /dev/null +++ b/src/test/java/pt/ptcris/test/scenarios/ScenarioFunding.java @@ -0,0 +1,344 @@ +/* + * Copyright (c) 2016, 2017 PTCRIS - FCT|FCCN and others. + * Licensed under MIT License + * http://ptcris.pt + * + * This copyright and license information (including a link to the full license) + * shall be included in its entirety in all copies or substantial portion of + * the software. + */ +package pt.ptcris.test.scenarios; + +import static org.junit.Assert.*; + +import java.math.BigInteger; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.um.dsi.gavea.orcid.client.exception.OrcidClientException; +import org.um.dsi.gavea.orcid.model.activities.FundingGroup; +import org.um.dsi.gavea.orcid.model.funding.Funding; +import org.um.dsi.gavea.orcid.model.funding.FundingSummary; +import org.um.dsi.gavea.orcid.model.funding.FundingType; + +import pt.ptcris.PTCRISync; +import pt.ptcris.PTCRISyncResult; +import pt.ptcris.handlers.ProgressHandler; +import pt.ptcris.test.TestHelper; +import pt.ptcris.utils.ORCIDFundingHelper; +import pt.ptcris.utils.ORCIDHelper; + +/** + * Represents a scenario as defined in the PTCRISync specification. Each + * scenario consists of a pre-state for the CRIS and ORCID profiles, an update + * on either profile and the result of running the import and/or export + * procedures to restore consistency. + * + * TODO: Scenarios with notifications in the pre-state (7 and 16) must be + * handled with caution, since modifications are not explicit in the current + * version of the system. + * + * TODO: Scenarios that consider the promotion/demotion of preferred fundings + * (10 and 11) are not to be tested programmatically as they cannot be selected + * this way. + * + * @see https://ptcris.pt/hub-ptcris/ + */ +public abstract class ScenarioFunding { + private List localFundings, exportFundings; + private static ORCIDHelper externalClient, + crisClient; + + @Before + public void setUpClass() throws Exception { + crisClient = crisClient(); + externalClient = externalClient(); + TestHelper.cleanUp(crisClient); + TestHelper.cleanUp(externalClient); + externalClient.add(setupORCIDExternalFundings(), null); + crisClient.add(setupORCIDCRISFundings(), null); + this.localFundings = setupLocalFundings(); + this.exportFundings = exportLocalFundings(); + this.localFundings.addAll(this.exportFundings); + } + + @Test + public void test() throws OrcidClientException, InterruptedException { + ProgressHandler handler = TestHelper.handler(); + + handler.setCurrentStatus(this.getClass().getName() + " start"); + long startTime = System.currentTimeMillis(); + FundingType[] types = {FundingType.CONTRACT, FundingType.GRANT}; + Map> codes = PTCRISync.exportFundings(crisClient.client, exportFundings, Arrays.asList(types), handler); + List fundingsToImport = PTCRISync.importFundings( + crisClient.client, localFundings, Arrays.asList(types), handler); + List fundingsToUpdate = PTCRISync.importFundingUpdates( + crisClient.client, localFundings, Arrays.asList(types), handler); + Map> fundingsToInvalid = PTCRISync + .importInvalidFundings(crisClient.client, localFundings, Arrays.asList(types), handler); + int fundingsToImportCounter = PTCRISync.importFundingCounter( + crisClient.client, localFundings, Arrays.asList(types), handler); + long time = System.currentTimeMillis() - startTime; + handler.setCurrentStatus(this.getClass().getName() + ": " + time + "ms"); + + List allImports = new ArrayList(fundingsToImport); + allImports.addAll(fundingsToUpdate); + localFundings.addAll(allImports); + + List expectedLocal = expectedImportedFundings(); + List expectedInvalid = expectedImportedInvalidFundings(); + List expectedORCID = expectedORCIDCRISFundings(); + List sourcedORCID = crisClient.getSourcedSummaries(); + + assertEquals(fundingsToImport.size(), fundingsToImportCounter); + + assertEquals(expectedLocal.size(), allImports.size()); + assertTrue(correctImports(expectedLocal, allImports)); + + assertEquals(expectedInvalid.size(), fundingsToInvalid.size()); + assertTrue(correctInvalids(fundingsToInvalid)); + assertTrue(correctImports(expectedInvalid, fundingsToInvalid.keySet())); + + assertEquals(expectedORCID.size(), sourcedORCID.size()); + assertTrue(correctCodes(codes)); + assertTrue(correctExport(expectedORCID, sourcedORCID)); + } + + @After + public void tearDownClass() throws Exception { + TestHelper.cleanUp(crisClient); + TestHelper.cleanUp(externalClient); + } + + /** + * Defines the CRIS-sourced ORCID fundings for the fixture of the scenario, + * i.e., the fundings that initially exist in the user profile added by the + * CRIS. + * + * @return the set of CRIS fundings for the fixture + */ + List setupORCIDCRISFundings() { + return new ArrayList(); + } + + /** + * Defines the non CRIS-sourced ORCID fundings for the fixture of the + * scenario, i.e., the fundings that initially exist in the user profile + * added by other external sources. + * + * @return the external fundings for the fixture + */ + List setupORCIDExternalFundings() { + return new ArrayList(); + } + + /** + * Defines the local CRIS fundings that are not to be exported. The import + * tests will additionally consider those set to be + * {@link #exportLocalFundings() exported}. + * + * @return the local fundings that is not to be exported + */ + List setupLocalFundings() { + return new ArrayList(); + } + + /** + * Defines the local CRIS fundings that are to be exported. The import tests + * will additionally consider those not set to be + * {@link #setupLocalFundings() exported}. + * + * @return the local fundings that is to be exported + */ + List exportLocalFundings() { + return new ArrayList(); + } + + /** + * The CRIS-source fundings that are expected to be in ORCID after the + * {@link PTCRISync#export(pt.ptcris.ORCIDClient, List, ProgressHandler) + * export} synchronization procedure. + * + * @return the expected CRIS-source fundings + */ + List expectedORCIDCRISFundings() { + return new ArrayList(); + } + + /** + * The expected outcome for each of the fundings that were to be exported + * for the + * {@link PTCRISync#export(pt.ptcris.ORCIDClient, List, ProgressHandler) + * export} synchronization procedure. + * + * @param putcode + * the put-code of a funding provided by {#link + * {@link #exportLocalFundings()} + * @return the expected CRIS-source fundings + */ + Set expectedExportCodes(BigInteger putcode) { + Set res = new HashSet(); + res.add(PTCRISyncResult.ADDOK); + return res; + } + + /** + * The new fundings that are expected to be detected in ORCID by the + * {@link PTCRISync#importFundings(pt.ptcris.ORCIDClient, List, ProgressHandler) + * import} synchronization procedure. + * + * @return the expected CRIS-source fundings + */ + List expectedImportedFundings() { + return new ArrayList(); + } + + /** + * The new invalid fundings that are expected to be detected in ORCID by the + * {@link PTCRISync#importInvalid(pt.ptcris.ORCIDClient, List, ProgressHandler) + * import invalid} synchronization procedure. + * + * @return the expected CRIS-source fundings + */ + List expectedImportedInvalidFundings() { + return new ArrayList(); + } + + /** + * The expected invalidity reasons for the new invalid fundings detected in + * ORCID by the + * {@link PTCRISync#importInvalid(pt.ptcris.ORCIDClient, List, ProgressHandler) + * import invalid} synchronization procedure. + * + * @param putcode + * the put-code of a funding returned by {#link + * {@link #expectedImportedInvalidFundings()} + * @return the expected reasons for invalidity + */ + Set expectedInvalidCodes(BigInteger putcode) { + return new HashSet(); + } + + /** + * Sets the client to use as the CRIS source. + * + * @return the CRIS source client + */ + abstract ORCIDHelper crisClient(); + + /** + * Sets the client to use as an external ORCID source. + * + * @return the external source client + */ + abstract ORCIDHelper externalClient(); + + /** + * Tests whether the effectively exported fundings are the ones expected. + * + * @param exported + * the effectively exported fundings + * @param expected + * the expected fundings + * @return whether the exported fundings were the expected + */ + private static boolean correctExport(Collection exported, + Collection expected) { + Set ws1 = new HashSet(exported); + Set ws2 = new HashSet(expected); + + for (Funding funding1 : exported) { + Iterator it = expected.iterator(); + boolean found = false; + while (it.hasNext() && !found) { + FundingSummary funding2 = it.next(); + if (new ORCIDFundingHelper(null) + .isUpToDateS(funding1, funding2)) { + ws1.remove(funding1); + ws2.remove(funding2); + found = true; + } + } + } + return ws1.isEmpty() && ws2.isEmpty(); + } + + /** + * Tests whether the effectively export outcomes are the ones expected + * according to {@link #expectedExportCodes(BigInteger)}. + * + * @param reasons + * the effectively export outcome + * @return whether the export outcome was the expected + */ + private boolean correctCodes(Map> results) { + for (BigInteger id : results.keySet()) + if (!expectedExportCodes(id).contains(results.get(id).code)) { + TestHelper.handler().sendError("Was " + results.get(id).code); + return false; + } + return true; + } + + /** + * Tests whether the effectively imported fundings are the ones expected. + * + * @param expected + * the effectively imported fundings + * @param imported + * the expected fundings + * @return whether the imported fundings were the expected + */ + private static boolean correctImports(Collection expected, + Collection imported) { + Set ws1 = new HashSet(expected); + Set ws2 = new HashSet(imported); + + for (Funding funding1 : expected) { + BigInteger localKey1 = ORCIDHelper.getActivityLocalKey(funding1); + Iterator it = ws2.iterator(); + boolean found = false; + while (it.hasNext() && !found) { + Funding funding2 = it.next(); + BigInteger localKey2 = ORCIDHelper + .getActivityLocalKey(funding2); + if (new ORCIDFundingHelper(null) + .isUpToDateE(funding1, funding2) + && ((localKey1 == null && localKey2 == null) || (localKey1 + .equals(localKey2)))) { + ws1.remove(funding1); + ws2.remove(funding2); + found = true; + } + } + } + return ws1.isEmpty() && ws2.isEmpty(); + } + + /** + * Tests whether the effectively imported invalidity reasons are the ones + * expected according to {@link #expectedInvalidCodes(BigInteger)}. + * + * @param reasons + * the effectively imported reasons for invalidity + * @return whether the invalidity reasons were the expected + */ + private boolean correctInvalids(Map> codes) { + for (Funding funding : codes.keySet()) + if (!codes.get(funding).equals( + expectedInvalidCodes(funding.getPutCode()))) + return false; + return true; + } + +} diff --git a/src/test/java/pt/ptcris/test/scenarios/ScenarioInvalidLocal1.java b/src/test/java/pt/ptcris/test/scenarios/ScenarioInvalidLocal1.java new file mode 100644 index 0000000..0bb1f35 --- /dev/null +++ b/src/test/java/pt/ptcris/test/scenarios/ScenarioInvalidLocal1.java @@ -0,0 +1,77 @@ +/* + * Copyright (c) 2016, 2017 PTCRIS - FCT|FCCN and others. + * Licensed under MIT License + * http://ptcris.pt + * + * This copyright and license information (including a link to the full license) + * shall be included in its entirety in all copies or substantial portion of + * the software. + */ +package pt.ptcris.test.scenarios; + +import java.math.BigInteger; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +import org.um.dsi.gavea.orcid.model.work.Work; + +import pt.ptcris.PTCRISyncResult; +import pt.ptcris.test.TestHelper; +import pt.ptcris.test.TestClients; +import pt.ptcris.test.TestClients.Profile; +import pt.ptcris.utils.ORCIDHelper; +import pt.ptcris.utils.ORCIDWorkHelper; + +public class ScenarioInvalidLocal1 extends Scenario { + + /** {@inheritDoc} */ + @Override + List exportLocalWorks() { + List works = new ArrayList(); + works.add(TestHelper.workDOIHANDLE(BigInteger.valueOf(2), "3", "0", "1")); + works.add(TestHelper.workDOIHANDLE(BigInteger.valueOf(3), "3", "1", "1")); + return works; + } + + /** {@inheritDoc} */ + Set expectedExportCodes(BigInteger putcode) { + Set res = new HashSet(); + res.add(PTCRISyncResult.INVALID); + return res; + } + + /** {@inheritDoc} */ + @Override + List expectedImportedInvalidWorks() { + List works = new ArrayList(); + Work work = TestHelper.workDOI(null, "1", "I2"); + work.setPublicationDate(null); + works.add(work); + return works; + } + + /** {@inheritDoc} */ + @Override + Set expectedInvalidCodes(BigInteger putCode) { + Set res = new HashSet(); + res.add(ORCIDHelper.INVALID_PUBLICATIONDATE); + return res; + } + + /** {@inheritDoc} */ + @Override + ORCIDWorkHelper crisClient() { + return new ORCIDWorkHelper( + TestClients.getCRISClient(Profile.ZEROVALIDWORKS)); + } + + /** {@inheritDoc} */ + @Override + ORCIDWorkHelper externalClient() { + return new ORCIDWorkHelper( + TestClients.getExternalClient(Profile.ZEROVALIDWORKS)); + } + +} diff --git a/src/test/java/pt/ptcris/test/scenarios/ScenarioInvalidLocal2.java b/src/test/java/pt/ptcris/test/scenarios/ScenarioInvalidLocal2.java new file mode 100644 index 0000000..57555d2 --- /dev/null +++ b/src/test/java/pt/ptcris/test/scenarios/ScenarioInvalidLocal2.java @@ -0,0 +1,90 @@ +/* + * Copyright (c) 2016, 2017 PTCRIS - FCT|FCCN and others. + * Licensed under MIT License + * http://ptcris.pt + * + * This copyright and license information (including a link to the full license) + * shall be included in its entirety in all copies or substantial portion of + * the software. + */ +package pt.ptcris.test.scenarios; + +import java.math.BigInteger; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +import org.um.dsi.gavea.orcid.model.work.Work; + +import pt.ptcris.PTCRISyncResult; +import pt.ptcris.test.TestHelper; +import pt.ptcris.test.TestClients; +import pt.ptcris.test.TestClients.Profile; +import pt.ptcris.utils.ORCIDHelper; +import pt.ptcris.utils.ORCIDWorkHelper; + +public class ScenarioInvalidLocal2 extends Scenario { + + /** {@inheritDoc} */ + @Override + List setupLocalWorks() { + List works = new ArrayList(); + works.add(TestHelper.workHANDLE(BigInteger.valueOf(1), "1", "1")); + return works; + } + + /** {@inheritDoc} */ + @Override + List exportLocalWorks() { + List works = new ArrayList(); + works.add(TestHelper.workDOIHANDLE(BigInteger.valueOf(2), null, "0", + "1")); + works.add(TestHelper.work(BigInteger.valueOf(3), "3")); + return works; + } + + /** {@inheritDoc} */ + Set expectedExportCodes(BigInteger putcode) { + Set res = new HashSet(); + if (putcode.equals(BigInteger.valueOf(2)) + || putcode.equals(BigInteger.valueOf(3))) + res.add(PTCRISyncResult.INVALID); + else + res.add(PTCRISyncResult.ADDOK); + return res; + } + + /** {@inheritDoc} */ + @Override + List expectedImportedInvalidWorks() { + List works = new ArrayList(); + Work work = TestHelper.workDOI(null, "1", "I2"); + work.setPublicationDate(null); + works.add(work); + return works; + } + + /** {@inheritDoc} */ + @Override + Set expectedInvalidCodes(BigInteger putCode) { + Set res = new HashSet(); + res.add(ORCIDHelper.INVALID_PUBLICATIONDATE); + return res; + } + + /** {@inheritDoc} */ + @Override + ORCIDWorkHelper crisClient() { + return new ORCIDWorkHelper( + TestClients.getCRISClient(Profile.ZEROVALIDWORKS)); + } + + /** {@inheritDoc} */ + @Override + ORCIDWorkHelper externalClient() { + return new ORCIDWorkHelper( + TestClients.getExternalClient(Profile.ZEROVALIDWORKS)); + } + +} diff --git a/src/test/java/pt/ptcris/test/scenarios/ScenarioPerformance.java b/src/test/java/pt/ptcris/test/scenarios/ScenarioPerformance.java new file mode 100644 index 0000000..581d859 --- /dev/null +++ b/src/test/java/pt/ptcris/test/scenarios/ScenarioPerformance.java @@ -0,0 +1,128 @@ +/* + * Copyright (c) 2016, 2017 PTCRIS - FCT|FCCN and others. + * Licensed under MIT License + * http://ptcris.pt + * + * This copyright and license information (including a link to the full license) + * shall be included in its entirety in all copies or substantial portion of + * the software. + */ +package pt.ptcris.test.scenarios; + +import java.math.BigInteger; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +import org.um.dsi.gavea.orcid.model.work.Work; + +import pt.ptcris.PTCRISyncResult; +import pt.ptcris.test.TestHelper; +import pt.ptcris.test.TestClients; +import pt.ptcris.test.TestClients.Profile; +import pt.ptcris.utils.ORCIDHelper; +import pt.ptcris.utils.ORCIDWorkHelper; + +public class ScenarioPerformance extends Scenario { + + int k = 75; + int _i = k, _j = _i + 2*k, _k = _j + k, _l = _k + k; + + /** {@inheritDoc} */ + @Override + List setupORCIDCRISWorks() { + List works = new ArrayList(); + for (int i = _i; i<_k; i++) + works.add(TestHelper.workDOI(BigInteger.valueOf(i), "PTCRIS "+i, i+"")); + + return works; + } + + /** {@inheritDoc} */ + @Override + List setupORCIDExternalWorks() { + List works = new ArrayList(); + for (int i = _i; i<_j; i++) + works.add(TestHelper.workDOI(null, "External source "+i, i+"")); + for (int i = _j; i<_l; i++) + works.add(TestHelper.workDOIHANDLE(null, "External source "+i, i+"", i+"")); + return works; + } + + /** {@inheritDoc} */ + List exportLocalWorks() { + List works = new ArrayList(); + for (int i = 0; i < _j; i++) + works.add(TestHelper.workDOI(BigInteger.valueOf(i), "PTCRIS "+i, i+"")); + for (int i = _j; i < _k; i++) + works.add(TestHelper.workDOI(BigInteger.valueOf(i), "PTCRIS' "+i, i+"")); + + return works; + } + + + /** {@inheritDoc} */ + @Override + List expectedImportedWorks() { + List works = new ArrayList(); + + for (int i = _j; i<_k; i++) + works.add(TestHelper.workHANDLE(BigInteger.valueOf(i), null, i+"")); + for (int i = _k; i<_l; i++) + works.add(TestHelper.workDOIHANDLE(null, "External source "+i, i+"", i+"")); + + return works; + } + + /** {@inheritDoc} */ + @Override + List expectedImportedInvalidWorks() { + List works = new ArrayList(); + Work work = TestHelper.workDOI(null, "1", "I2"); + work.setPublicationDate(null); + works.add(work); + return works; + } + + /** {@inheritDoc} */ + @Override + Set expectedInvalidCodes(BigInteger putCode) { + Set res = new HashSet(); + res.add(ORCIDHelper.INVALID_PUBLICATIONDATE); + return res; + } + + /** {@inheritDoc} */ + @Override + ORCIDWorkHelper crisClient() { + return new ORCIDWorkHelper( + TestClients.getCRISClient(Profile.ZEROVALIDWORKS)); + } + + /** {@inheritDoc} */ + @Override + ORCIDWorkHelper externalClient() { + return new ORCIDWorkHelper( + TestClients.getExternalClient(Profile.ZEROVALIDWORKS)); + } + + + /** {@inheritDoc} */ + List expectedORCIDCRISWorks() { + return exportLocalWorks(); + } + + /** {@inheritDoc} */ + Set expectedExportCodes(BigInteger putcode) { + Set res = new HashSet(); + res.add(PTCRISyncResult.ADDOK); + res.add(PTCRISyncResult.UPTODATE); + res.add(PTCRISyncResult.UPDATEOK); + return res; + } + + + + +} diff --git a/src/test/java/pt/ptcris/test/scenarios/ScenarioPerformance2.java b/src/test/java/pt/ptcris/test/scenarios/ScenarioPerformance2.java new file mode 100644 index 0000000..62f17b7 --- /dev/null +++ b/src/test/java/pt/ptcris/test/scenarios/ScenarioPerformance2.java @@ -0,0 +1,166 @@ +/* + * Copyright (c) 2016, 2017 PTCRIS - FCT|FCCN and others. + * Licensed under MIT License + * http://ptcris.pt + * + * This copyright and license information (including a link to the full license) + * shall be included in its entirety in all copies or substantial portion of + * the software. + */ +package pt.ptcris.test.scenarios; + +import java.math.BigInteger; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +import org.um.dsi.gavea.orcid.model.work.Work; + +import pt.ptcris.test.TestHelper; +import pt.ptcris.test.TestClients; +import pt.ptcris.test.TestClients.Profile; +import pt.ptcris.utils.ORCIDHelper; +import pt.ptcris.utils.ORCIDWorkHelper; + +public class ScenarioPerformance2 extends Scenario { + + /** {@inheritDoc} */ + @Override + List setupORCIDCRISWorks() { + List works = new ArrayList(); + works.add(TestHelper.workDOI(null, "0", "20")); + works.add(TestHelper.workDOI(null, "1", "21")); + works.add(TestHelper.workDOI(null, "2", "22")); + works.add(TestHelper.workDOI(null, "3", "23")); + works.add(TestHelper.workDOI(null, "4", "24")); + works.add(TestHelper.workDOI(null, "5", "25")); + works.add(TestHelper.workDOI(null, "6", "26")); + works.add(TestHelper.workDOI(null, "7", "27")); + works.add(TestHelper.workDOI(null, "8", "28")); + works.add(TestHelper.workDOI(null, "9", "29")); + works.add(TestHelper.workDOI(null, "0", "30")); + works.add(TestHelper.workDOI(null, "1", "31")); + works.add(TestHelper.workDOI(null, "2", "32")); + works.add(TestHelper.workDOI(null, "3", "33")); + works.add(TestHelper.workDOI(null, "4", "34")); + works.add(TestHelper.workDOI(null, "5", "35")); + works.add(TestHelper.workDOI(null, "6", "36")); + works.add(TestHelper.workDOI(null, "7", "37")); + works.add(TestHelper.workDOI(null, "8", "38")); + works.add(TestHelper.workDOI(null, "9", "39")); + works.add(TestHelper.workDOI(null, "9", "299")); + return works; + } + + /** {@inheritDoc} */ + @Override + List setupORCIDExternalWorks() { + List works = new ArrayList(); + works.add(TestHelper.workDOI(null, "0", "0")); + works.add(TestHelper.workDOI(null, "1", "1")); + works.add(TestHelper.workDOI(null, "2", "2")); + works.add(TestHelper.workDOI(null, "3", "3")); + works.add(TestHelper.workDOI(null, "4", "4")); + works.add(TestHelper.workDOI(null, "5", "5")); + works.add(TestHelper.workDOI(null, "6", "6")); + works.add(TestHelper.workDOI(null, "7", "7")); + works.add(TestHelper.workDOI(null, "8", "8")); + works.add(TestHelper.workDOI(null, "9", "9")); + works.add(TestHelper.workDOI(null, "0", "10")); + works.add(TestHelper.workDOI(null, "1", "11")); + works.add(TestHelper.workDOI(null, "2", "12")); + works.add(TestHelper.workDOI(null, "3", "13")); + works.add(TestHelper.workDOI(null, "4", "14")); + works.add(TestHelper.workDOI(null, "5", "15")); + works.add(TestHelper.workDOI(null, "6", "16")); + works.add(TestHelper.workDOI(null, "7", "17")); + works.add(TestHelper.workDOI(null, "8", "18")); + works.add(TestHelper.workDOI(null, "9", "19")); + works.add(TestHelper.workDOI(null, "0", "20")); + works.add(TestHelper.workDOI(null, "1", "21")); + works.add(TestHelper.workDOI(null, "2", "22")); + works.add(TestHelper.workDOI(null, "3", "23")); + works.add(TestHelper.workDOI(null, "4", "24")); + works.add(TestHelper.workDOI(null, "5", "25")); + works.add(TestHelper.workDOI(null, "6", "26")); + works.add(TestHelper.workDOI(null, "7", "27")); + works.add(TestHelper.workDOI(null, "8", "28")); + works.add(TestHelper.workDOI(null, "9", "29")); + for (int i = 100; i<=300; i++) + works.add(TestHelper.workDOI(null, i+"", i+"")); + return works; + } + + /** {@inheritDoc} */ + @Override + List expectedImportedWorks() { + List works = new ArrayList(); + works.add(TestHelper.workDOI(null, "0", "0")); + works.add(TestHelper.workDOI(null, "1", "1")); + works.add(TestHelper.workDOI(null, "2", "2")); + works.add(TestHelper.workDOI(null, "3", "3")); + works.add(TestHelper.workDOI(null, "4", "4")); + works.add(TestHelper.workDOI(null, "5", "5")); + works.add(TestHelper.workDOI(null, "6", "6")); + works.add(TestHelper.workDOI(null, "7", "7")); + works.add(TestHelper.workDOI(null, "8", "8")); + works.add(TestHelper.workDOI(null, "9", "9")); + works.add(TestHelper.workDOI(null, "0", "10")); + works.add(TestHelper.workDOI(null, "1", "11")); + works.add(TestHelper.workDOI(null, "2", "12")); + works.add(TestHelper.workDOI(null, "3", "13")); + works.add(TestHelper.workDOI(null, "4", "14")); + works.add(TestHelper.workDOI(null, "5", "15")); + works.add(TestHelper.workDOI(null, "6", "16")); + works.add(TestHelper.workDOI(null, "7", "17")); + works.add(TestHelper.workDOI(null, "8", "18")); + works.add(TestHelper.workDOI(null, "9", "19")); + works.add(TestHelper.workDOI(null, "0", "20")); + works.add(TestHelper.workDOI(null, "1", "21")); + works.add(TestHelper.workDOI(null, "2", "22")); + works.add(TestHelper.workDOI(null, "3", "23")); + works.add(TestHelper.workDOI(null, "4", "24")); + works.add(TestHelper.workDOI(null, "5", "25")); + works.add(TestHelper.workDOI(null, "6", "26")); + works.add(TestHelper.workDOI(null, "7", "27")); + works.add(TestHelper.workDOI(null, "8", "28")); + works.add(TestHelper.workDOI(null, "9", "29")); + for (int i = 100; i<=300; i++) + works.add(TestHelper.workDOI(null, i+"", i+"")); + return works; + } + + /** {@inheritDoc} */ + @Override + List expectedImportedInvalidWorks() { + List works = new ArrayList(); + Work work = TestHelper.workDOI(null, "1", "I2"); + work.setPublicationDate(null); + works.add(work); + return works; + } + + /** {@inheritDoc} */ + @Override + Set expectedInvalidCodes(BigInteger putCode) { + Set res = new HashSet(); + res.add(ORCIDHelper.INVALID_PUBLICATIONDATE); + return res; + } + + /** {@inheritDoc} */ + @Override + ORCIDWorkHelper crisClient() { + return new ORCIDWorkHelper( + TestClients.getCRISClient(Profile.ZEROVALIDWORKS)); + } + + /** {@inheritDoc} */ + @Override + ORCIDWorkHelper externalClient() { + return new ORCIDWorkHelper( + TestClients.getExternalClient(Profile.ZEROVALIDWORKS)); + } + +} diff --git a/target/classes/META-INF/MANIFEST.MF b/target/classes/META-INF/MANIFEST.MF new file mode 100644 index 0000000..7a49da0 --- /dev/null +++ b/target/classes/META-INF/MANIFEST.MF @@ -0,0 +1,5 @@ +Manifest-Version: 1.0 +Built-By: Luᅢᆳs +Build-Jdk: 1.8.0_92 +Created-By: Maven Integration for Eclipse + diff --git a/target/classes/META-INF/maven/pt.ptcris/ptcrisync/pom.properties b/target/classes/META-INF/maven/pt.ptcris/ptcrisync/pom.properties new file mode 100644 index 0000000..304128f --- /dev/null +++ b/target/classes/META-INF/maven/pt.ptcris/ptcrisync/pom.properties @@ -0,0 +1,7 @@ +#Generated by Maven Integration for Eclipse +#Tue Jul 04 11:38:26 BST 2017 +version=0.0.1 +groupId=pt.ptcris +m2e.projectName=ptcrisync-1.0 +m2e.projectLocation=C\:\\Lixo\\Versao 1 +artifactId=ptcrisync diff --git a/target/classes/META-INF/maven/pt.ptcris/ptcrisync/pom.xml b/target/classes/META-INF/maven/pt.ptcris/ptcrisync/pom.xml new file mode 100644 index 0000000..20da392 --- /dev/null +++ b/target/classes/META-INF/maven/pt.ptcris/ptcrisync/pom.xml @@ -0,0 +1,73 @@ + + 4.0.0 + pt.ptcris + ptcrisync + 0.0.1 + + + UTF-8 + 1.8 + 2.0 + 1.1.9 + 4.12 + + + + + + org.um.dsi.gavea + degois-orcid-client + ${orcid-api-client.version} + + + + ch.qos.logback + logback-classic + ${logback-version} + compile + + + + junit + junit + ${junit.version} + + + + + + + + + org.apache.maven.plugins + maven-jar-plugin + 3.0.0 + + ${java.version} + ${java.version} + + + + maven-compiler-plugin + 3.3 + + ${java.version} + ${java.version} + + + + true + maven-deploy-plugin + 2.8.2 + + true + + + + + + + PTCRISync + This project aims to help the synchronization between ORCID and local systems. + From cabf0c6556b1f93a59ed8f3f2f98bf1b0929220d Mon Sep 17 00:00:00 2001 From: lpedro Date: Fri, 14 Jul 2017 09:55:58 +0000 Subject: [PATCH 02/16] C4382 --- .settings/org.eclipse.core.resources.prefs | 4 +++ .settings/org.eclipse.jdt.core.prefs | 2 ++ .settings/org.eclipse.wst.common.component | 5 +++ ....eclipse.wst.common.project.facet.core.xml | 5 +++ .settings/org.eclipse.wst.validation.prefs | 2 ++ pom.xml | 2 +- src/main/java/pt/ptcris/ORCIDClientImpl.java | 8 ++--- src/main/java/pt/ptcris/TempORCIDClient.java | 35 ------------------- .../java/pt/ptcris/grouper/ActivityGroup.java | 2 +- .../pt/ptcris/grouper/GroupGenerator.java | 2 +- .../pt/ptcris/utils/ORCIDFundingHelper.java | 4 +-- .../java/pt/ptcris/utils/ORCIDHelper.java | 4 +-- .../java/pt/ptcris/utils/ORCIDWorkHelper.java | 6 ++-- 13 files changed, 32 insertions(+), 49 deletions(-) create mode 100644 .settings/org.eclipse.core.resources.prefs create mode 100644 .settings/org.eclipse.wst.common.component create mode 100644 .settings/org.eclipse.wst.common.project.facet.core.xml create mode 100644 .settings/org.eclipse.wst.validation.prefs delete mode 100644 src/main/java/pt/ptcris/TempORCIDClient.java diff --git a/.settings/org.eclipse.core.resources.prefs b/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 0000000..4c28b1a --- /dev/null +++ b/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,4 @@ +eclipse.preferences.version=1 +encoding//src/main/java=UTF-8 +encoding//src/test/java=UTF-8 +encoding/=UTF-8 diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs index ace45ce..d50689a 100644 --- a/.settings/org.eclipse.jdt.core.prefs +++ b/.settings/org.eclipse.jdt.core.prefs @@ -9,4 +9,6 @@ org.eclipse.jdt.core.compiler.debug.localVariable=generate org.eclipse.jdt.core.compiler.debug.sourceFile=generate org.eclipse.jdt.core.compiler.problem.assertIdentifier=error org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning org.eclipse.jdt.core.compiler.source=1.8 +org.eclipse.objectteams.otdt.compiler.option.pure_java=enabled diff --git a/.settings/org.eclipse.wst.common.component b/.settings/org.eclipse.wst.common.component new file mode 100644 index 0000000..50c1a1f --- /dev/null +++ b/.settings/org.eclipse.wst.common.component @@ -0,0 +1,5 @@ + + + + + diff --git a/.settings/org.eclipse.wst.common.project.facet.core.xml b/.settings/org.eclipse.wst.common.project.facet.core.xml new file mode 100644 index 0000000..6302d3e --- /dev/null +++ b/.settings/org.eclipse.wst.common.project.facet.core.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/.settings/org.eclipse.wst.validation.prefs b/.settings/org.eclipse.wst.validation.prefs new file mode 100644 index 0000000..6f1cba6 --- /dev/null +++ b/.settings/org.eclipse.wst.validation.prefs @@ -0,0 +1,2 @@ +disabled=06target +eclipse.preferences.version=1 diff --git a/pom.xml b/pom.xml index 20da392..31dfb3c 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ 4.0.0 pt.ptcris ptcrisync - 0.0.1 + 1.0 UTF-8 diff --git a/src/main/java/pt/ptcris/ORCIDClientImpl.java b/src/main/java/pt/ptcris/ORCIDClientImpl.java index c8060a3..a0ac02d 100644 --- a/src/main/java/pt/ptcris/ORCIDClientImpl.java +++ b/src/main/java/pt/ptcris/ORCIDClientImpl.java @@ -17,6 +17,7 @@ import java.util.Map; import org.um.dsi.gavea.orcid.client.OrcidAccessToken; +import org.um.dsi.gavea.orcid.client.OrcidOAuthClient; import org.um.dsi.gavea.orcid.client.exception.OrcidClientException; import org.um.dsi.gavea.orcid.model.activities.ActivitiesSummary; import org.um.dsi.gavea.orcid.model.activities.Fundings; @@ -45,7 +46,7 @@ public class ORCIDClientImpl implements ORCIDClient { private final OrcidAccessToken orcidToken; - private final TempORCIDClient orcidClient; + private final OrcidOAuthClient orcidClient; private final String clientId; private final int threads; @@ -147,8 +148,7 @@ public ORCIDClientImpl(String loginUri, String apiUri, String clientId, this.orcidToken = orcidToken; this.clientId = clientId; this.threads = threads; - this.orcidClient = new TempORCIDClient(loginUri, apiUri, clientId, - clientSecret, redirectUri, debugMode); + this.orcidClient = new OrcidOAuthClient(loginUri, apiUri, clientId, clientSecret, redirectUri, debugMode); } /** @@ -188,7 +188,7 @@ public Works getWorksSummary() throws OrcidClientException { */ @Override public Fundings getFundingsSummary() throws OrcidClientException { - return orcidClient.readFundingsSummary(orcidToken); + return orcidClient.readFundingSummary(orcidToken); } /** diff --git a/src/main/java/pt/ptcris/TempORCIDClient.java b/src/main/java/pt/ptcris/TempORCIDClient.java deleted file mode 100644 index bf6fe57..0000000 --- a/src/main/java/pt/ptcris/TempORCIDClient.java +++ /dev/null @@ -1,35 +0,0 @@ -package pt.ptcris; - -import javax.ws.rs.core.Response; - -import org.um.dsi.gavea.orcid.client.OrcidAccessToken; -import org.um.dsi.gavea.orcid.client.OrcidOAuthClient; -import org.um.dsi.gavea.orcid.client.exception.OrcidClientException; -import org.um.dsi.gavea.orcid.model.activities.Fundings; - -/** - * @deprecated temporary class to be deleted once readFundingsSummary is added to the - * ORCID client. - */ -public class TempORCIDClient extends OrcidOAuthClient { - - private static final long serialVersionUID = 1L; - - public TempORCIDClient(String loginUri, String apiUri, String clientId, - String clientSecret, String redirectUri, boolean debugMode) { - super(loginUri, apiUri, clientId, clientSecret, redirectUri, debugMode); - } - - public Fundings readFundingsSummary(final OrcidAccessToken token) - throws OrcidClientException { - Response response = null; - try { - response = get("/fundings", token, null); - Fundings x = response.readEntity(Fundings.class); - return x; - } finally { - if (response != null) - response.close(); - } - } -} diff --git a/src/main/java/pt/ptcris/grouper/ActivityGroup.java b/src/main/java/pt/ptcris/grouper/ActivityGroup.java index 213b4ae..cec3da4 100644 --- a/src/main/java/pt/ptcris/grouper/ActivityGroup.java +++ b/src/main/java/pt/ptcris/grouper/ActivityGroup.java @@ -38,7 +38,7 @@ public class ActivityGroup { * * @return the activities of the group */ - Set getActivities() { + public Set getActivities() { if (activities == null) activities = new HashSet(); return activities; diff --git a/src/main/java/pt/ptcris/grouper/GroupGenerator.java b/src/main/java/pt/ptcris/grouper/GroupGenerator.java index 870878a..08512f8 100644 --- a/src/main/java/pt/ptcris/grouper/GroupGenerator.java +++ b/src/main/java/pt/ptcris/grouper/GroupGenerator.java @@ -17,7 +17,7 @@ * comparator} iteratively groups works that are below the threshold as * {@link ActivityGroup activity groups}. * - * @param + * @param * the type of activities being grouped */ public class GroupGenerator { diff --git a/src/main/java/pt/ptcris/utils/ORCIDFundingHelper.java b/src/main/java/pt/ptcris/utils/ORCIDFundingHelper.java index c3aa086..73cec44 100644 --- a/src/main/java/pt/ptcris/utils/ORCIDFundingHelper.java +++ b/src/main/java/pt/ptcris/utils/ORCIDFundingHelper.java @@ -272,7 +272,7 @@ protected boolean isMetaUpToDate(Funding preFunding, FundingSummary posFunding) * the summaries. */ @Override - protected Set testMinimalQuality(FundingSummary funding, Collection others) { + public Set testMinimalQuality(FundingSummary funding, Collection others) { assert funding != null; if (others == null) others = new ArrayList(); @@ -361,7 +361,7 @@ public Funding cloneE(Funding funding) { /** {@inheritDoc} */ @Override - protected FundingSummary summarize(Funding funding) { + public FundingSummary summarize(Funding funding) { assert funding != null; final FundingSummary dummy = new FundingSummary(); diff --git a/src/main/java/pt/ptcris/utils/ORCIDHelper.java b/src/main/java/pt/ptcris/utils/ORCIDHelper.java index ac060b2..de253bf 100644 --- a/src/main/java/pt/ptcris/utils/ORCIDHelper.java +++ b/src/main/java/pt/ptcris/utils/ORCIDHelper.java @@ -686,7 +686,7 @@ private final boolean waitWorkers() throws InterruptedException { * other coexisting activities * @return the set of invalid meta-data, empty if valid */ - protected abstract Set testMinimalQuality(S summary, Collection others); + public abstract Set testMinimalQuality(S summary, Collection others); /** * Creates an update to an activity given the difference on meta-data. @@ -728,7 +728,7 @@ private final boolean waitWorkers() throws InterruptedException { * the ORCID activity to be summarized * @return the corresponding ORCID activity summary */ - protected abstract S summarize(E activity); + public abstract S summarize(E activity); /* * Helper static methods that build on the generic methods. diff --git a/src/main/java/pt/ptcris/utils/ORCIDWorkHelper.java b/src/main/java/pt/ptcris/utils/ORCIDWorkHelper.java index 0d0a9b6..d26d8c7 100644 --- a/src/main/java/pt/ptcris/utils/ORCIDWorkHelper.java +++ b/src/main/java/pt/ptcris/utils/ORCIDWorkHelper.java @@ -311,7 +311,7 @@ && getYearS(posWork) != null && getPubYearE(preWork) * the summaries. */ @Override - protected Set testMinimalQuality(WorkSummary work, Collection others) { + public Set testMinimalQuality(WorkSummary work, Collection others) { assert work != null; if (others == null) others = new ArrayList(); @@ -403,9 +403,9 @@ public Work cloneE(Work work) { /** {@inheritDoc} */ @Override - protected WorkSummary summarize(Work work) { + public WorkSummary summarize(Work work) { assert work != null; - + final WorkSummary dummy = new WorkSummary(); copy(work, dummy); dummy.setPublicationDate(work.getPublicationDate()); From 28d97c380d1dade3341e6e21dee02d9bdda31878 Mon Sep 17 00:00:00 2001 From: lpedro Date: Tue, 29 Aug 2017 13:49:45 +0000 Subject: [PATCH 03/16] C4442 --- src/main/java/pt/ptcris/ORCIDClientImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/pt/ptcris/ORCIDClientImpl.java b/src/main/java/pt/ptcris/ORCIDClientImpl.java index a0ac02d..b041754 100644 --- a/src/main/java/pt/ptcris/ORCIDClientImpl.java +++ b/src/main/java/pt/ptcris/ORCIDClientImpl.java @@ -188,7 +188,7 @@ public Works getWorksSummary() throws OrcidClientException { */ @Override public Fundings getFundingsSummary() throws OrcidClientException { - return orcidClient.readFundingSummary(orcidToken); + return orcidClient.readFundingsSummary(orcidToken); } /** From 94f698e38d9b8b1139d020e64e806146591da81a Mon Sep 17 00:00:00 2001 From: lpedro Date: Thu, 31 Aug 2017 11:54:57 +0000 Subject: [PATCH 04/16] C4458 --- src/main/java/pt/ptcris/ORCIDClientImpl.java | 3 +- .../java/pt/ptcris/utils/ExternalIdsDiff.java | 5 +- .../pt/ptcris/utils/ORCIDFundingHelper.java | 31 +++--- .../java/pt/ptcris/utils/ORCIDHelper.java | 99 +++++++++++++------ .../java/pt/ptcris/utils/ORCIDWorkHelper.java | 24 ++--- src/test/java/pt/ptcris/test/TestHelper.java | 8 +- src/test/java/pt/ptcris/test/Tester.java | 3 +- .../pt/ptcris/test/grouper/GrouperTest.java | 2 +- target/classes/META-INF/MANIFEST.MF | 4 +- .../maven/pt.ptcris/ptcrisync/pom.properties | 6 +- .../maven/pt.ptcris/ptcrisync/pom.xml | 2 +- 11 files changed, 120 insertions(+), 67 deletions(-) diff --git a/src/main/java/pt/ptcris/ORCIDClientImpl.java b/src/main/java/pt/ptcris/ORCIDClientImpl.java index b041754..7149632 100644 --- a/src/main/java/pt/ptcris/ORCIDClientImpl.java +++ b/src/main/java/pt/ptcris/ORCIDClientImpl.java @@ -148,7 +148,8 @@ public ORCIDClientImpl(String loginUri, String apiUri, String clientId, this.orcidToken = orcidToken; this.clientId = clientId; this.threads = threads; - this.orcidClient = new OrcidOAuthClient(loginUri, apiUri, clientId, clientSecret, redirectUri, debugMode); + this.orcidClient = new OrcidOAuthClient(loginUri, apiUri, clientId, + clientSecret, redirectUri, debugMode); } /** diff --git a/src/main/java/pt/ptcris/utils/ExternalIdsDiff.java b/src/main/java/pt/ptcris/utils/ExternalIdsDiff.java index 904b78d..765e631 100644 --- a/src/main/java/pt/ptcris/utils/ExternalIdsDiff.java +++ b/src/main/java/pt/ptcris/utils/ExternalIdsDiff.java @@ -71,7 +71,10 @@ public ExternalIdsDiff(ExternalIds weids1, ExternalIds weids2) { * identifiers. Only considered duplicate if external identifiers have the * same relationship and are not "part of". * - * TODO: optimize + * TODO: the URLs assigned to the external identifiers are being ignored; + * this means that ids with different URLs are considered the same; also, + * the selection of the id to "same" when there is a match is arbitrary. + * TODO: optimize. * * @param eids1 * a set of UIDs diff --git a/src/main/java/pt/ptcris/utils/ORCIDFundingHelper.java b/src/main/java/pt/ptcris/utils/ORCIDFundingHelper.java index 73cec44..5dc70c9 100644 --- a/src/main/java/pt/ptcris/utils/ORCIDFundingHelper.java +++ b/src/main/java/pt/ptcris/utils/ORCIDFundingHelper.java @@ -219,13 +219,8 @@ protected FundingSummary group(FundingGroup group) throws IllegalArgumentExcepti final FundingSummary dummy = cloneS(preferred); final List eids = getPartOfExternalIdsS(dummy).getExternalId(); - for (ExternalId id : group.getExternalIds().getExternalId()) { - final ExternalId eid = new ExternalId(); - eid.setExternalIdRelationship(id.getExternalIdRelationship()); - eid.setExternalIdType(id.getExternalIdType().toLowerCase()); - eid.setExternalIdValue(id.getExternalIdValue()); - eids.add(eid); - } + for (ExternalId id : group.getExternalIds().getExternalId()) + eids.add(clone(id)); dummy.setExternalIds(new ExternalIds(eids)); return dummy; @@ -235,8 +230,8 @@ protected FundingSummary group(FundingGroup group) throws IllegalArgumentExcepti * {@inheritDoc} * * The considered fields are: title, start date (year), funding type and - * part-of external identifiers. All this meta-data is available in funding - * summaries. + * part-of external identifiers (excluding URLs). All this meta-data is + * available in funding summaries. * * TODO: contributors are not being considered as they are not contained in * the summaries. @@ -287,13 +282,23 @@ else if (funding.getTitle().getTitle() == null) res.add(INVALID_TITLE); if (funding.getType() == null) res.add(INVALID_TYPE); - if (funding.getOrganization() == null) + if (funding.getOrganization() == null + || funding.getOrganization().getAddress() == null + || funding.getOrganization().getAddress().getCity() == null + || funding.getOrganization().getAddress().getCountry() == null) res.add(INVALID_ORGANIZATION); if (funding.getStartDate() == null) res.add(INVALID_PUBLICATIONDATE); - else if (funding.getStartDate().getYear() == null) - res.add(INVALID_YEAR); - + else { + if (!testQualityFuzzyDate(funding.getStartDate())) + res.add(INVALID_PUBLICATIONDATE); + if (funding.getStartDate().getYear() == null) + res.add(INVALID_YEAR); + } + + if (funding.getEndDate() != null && !!testQualityFuzzyDate(funding.getEndDate())) + res.add(INVALID_PUBLICATIONDATE); + Map fundingsDiffs = getSelfExternalIdsDiffS(funding, others); for (Funding match : fundingsDiffs.keySet()) if (match.getPutCode() != funding.getPutCode() && !fundingsDiffs.get(match).same.isEmpty()) diff --git a/src/main/java/pt/ptcris/utils/ORCIDHelper.java b/src/main/java/pt/ptcris/utils/ORCIDHelper.java index de253bf..56014b0 100644 --- a/src/main/java/pt/ptcris/utils/ORCIDHelper.java +++ b/src/main/java/pt/ptcris/utils/ORCIDHelper.java @@ -31,6 +31,7 @@ import org.um.dsi.gavea.orcid.model.common.ElementSummary; import org.um.dsi.gavea.orcid.model.common.ExternalId; import org.um.dsi.gavea.orcid.model.common.ExternalIds; +import org.um.dsi.gavea.orcid.model.common.FuzzyDate; import org.um.dsi.gavea.orcid.model.common.RelationshipType; import org.um.dsi.gavea.orcid.model.funding.Funding; import org.um.dsi.gavea.orcid.model.funding.FundingSummary; @@ -92,10 +93,10 @@ public static ORCIDHelper fa public static final String INVALID_ORGANIZATION = "Organization"; public static final String OVERLAPPING_EIDs = "OverlappingEIDs"; - protected final int bulk_size_add; - protected final int bulk_size_get; + final int bulk_size_add; + final int bulk_size_get; - protected static final Logger _log = LoggerFactory.getLogger(ORCIDHelper.class); + static final Logger _log = LoggerFactory.getLogger(ORCIDHelper.class); /** * The client used to communicate with ORCID. Defines the ORCID user profile @@ -103,7 +104,7 @@ public static ORCIDHelper fa */ public final ORCIDClient client; - protected ExecutorService executor; + ExecutorService executor; /** * Initializes the helper with a given ORCID client, which defines whether @@ -138,7 +139,7 @@ public ORCIDHelper(ORCIDClient orcidClient, int bulk_size_add, * @throws OrcidClientException * if the communication with ORCID fails */ - protected abstract List getSummariesClient() throws OrcidClientException; + abstract List getSummariesClient() throws OrcidClientException; /** * Retrieves through the ORCID client a single full activity for which the @@ -150,7 +151,7 @@ public ORCIDHelper(ORCIDClient orcidClient, int bulk_size_add, * activity * @return the remote full ORCID activity */ - protected abstract PTCRISyncResult readClient(S summary); + abstract PTCRISyncResult readClient(S summary); /** * Retrieves through the ORCID client every full activity for which @@ -163,7 +164,7 @@ public ORCIDHelper(ORCIDClient orcidClient, int bulk_size_add, * activities * @return the remote full ORCID activities */ - protected abstract Map> readClient(List summaries); + abstract Map> readClient(List summaries); /** * Creates a worker to asynchronously read a single full activity for which @@ -179,7 +180,7 @@ public ORCIDHelper(ORCIDClient orcidClient, int bulk_size_add, * a handler to report progress * @return the get worker */ - protected abstract ORCIDWorker readWorker(S summary, Map> cb, ProgressHandler handler); + abstract ORCIDWorker readWorker(S summary, Map> cb, ProgressHandler handler); /** * Creates a worker to asynchronously read full activities for which the @@ -196,7 +197,7 @@ public ORCIDHelper(ORCIDClient orcidClient, int bulk_size_add, * a handler to report progress * @return the get worker */ - protected abstract ORCIDWorker readWorker(List summaries, Map> cb, ProgressHandler handler); + abstract ORCIDWorker readWorker(List summaries, Map> cb, ProgressHandler handler); /** * Adds through the ORCID client a new full activity. If the communication @@ -207,7 +208,7 @@ public ORCIDHelper(ORCIDClient orcidClient, int bulk_size_add, * the full ORCID activity to be added * @return the result of the operation */ - protected abstract PTCRISyncResult addClient(E activity); + abstract PTCRISyncResult addClient(E activity); /** * Adds through the ORCID client a set of new full activities. If the @@ -218,7 +219,7 @@ public ORCIDHelper(ORCIDClient orcidClient, int bulk_size_add, * the full ORCID activities to be added * @return the result of the operation */ - protected abstract List> addClient(List activities); + abstract List> addClient(List activities); /** * Updates through the ORCID client a remote activity. If the communication @@ -231,7 +232,7 @@ public ORCIDHelper(ORCIDClient orcidClient, int bulk_size_add, * the new state of the ORCID activity * @return the result of the operation */ - protected abstract PTCRISyncResult updateClient(BigInteger remotePutcode, E activity); + abstract PTCRISyncResult updateClient(BigInteger remotePutcode, E activity); /** * Deletes through the ORCID client a remote activity. If the communication @@ -242,7 +243,7 @@ public ORCIDHelper(ORCIDClient orcidClient, int bulk_size_add, * the put-code of the remote ORCID activity * @return the result of the operation */ - protected abstract PTCRISyncResult deleteClient(BigInteger remotePutcode); + abstract PTCRISyncResult deleteClient(BigInteger remotePutcode); /* * Helper client methods that build on the generic methods. @@ -604,7 +605,7 @@ private final boolean waitWorkers() throws InterruptedException { * the ORCID activity summary * @return the summary's type */ - protected abstract T getTypeS(S summary); + abstract T getTypeS(S summary); /** * Tests whether a given external identifier type name is valid. @@ -613,7 +614,7 @@ private final boolean waitWorkers() throws InterruptedException { * a potential external identifier type name * @return whether the string is a valid external identifier type */ - protected abstract boolean validExternalIdType(String eid); + abstract boolean validExternalIdType(String eid); /** * Retrieves the title of an activity summary. @@ -622,7 +623,7 @@ private final boolean waitWorkers() throws InterruptedException { * the ORCID activity summary * @return the summary's title if defined, empty string otherwise */ - protected abstract String getTitleS(S summary); + abstract String getTitleS(S summary); /** * Retrieves the publication year of an activity summary. @@ -631,7 +632,7 @@ private final boolean waitWorkers() throws InterruptedException { * the ORCID activity summary * @return the summary's publication year, may be null */ - protected abstract String getYearS(S summary); + abstract String getYearS(S summary); /** * Retrieve the activity summaries that compose an activity group. @@ -641,7 +642,7 @@ private final boolean waitWorkers() throws InterruptedException { * summaries * @return the OCRID activity summaries contained in the group */ - protected abstract List getGroupSummaries(G group); + abstract List getGroupSummaries(G group); /** * Merges an activity group into a single activity summary. Simply selects @@ -656,7 +657,7 @@ private final boolean waitWorkers() throws InterruptedException { * @throws IllegalArgumentException * if the group is empty */ - protected abstract S group(G group) throws IllegalArgumentException; + abstract S group(G group) throws IllegalArgumentException; /** * Checks whether an activity is already up to date regarding another one, @@ -669,7 +670,7 @@ private final boolean waitWorkers() throws InterruptedException { * the up to date ORCID activity * @return true if the considered meta-data is the same, false otherwise. */ - protected abstract boolean isMetaUpToDate(E preElement, S posElement); + abstract boolean isMetaUpToDate(E preElement, S posElement); /** * Tests whether an activity summary has minimal quality to be synchronized, @@ -709,7 +710,7 @@ private final boolean waitWorkers() throws InterruptedException { * the ORCID activity summary to be cloned * @return the cloned ORCID activity summary */ - protected abstract S cloneS(S summary); + abstract S cloneS(S summary); /** * Clones an activity. @@ -718,7 +719,7 @@ private final boolean waitWorkers() throws InterruptedException { * the ORCID activity to be cloned * @return the cloned ORCID activity */ - protected abstract E cloneE(E activity); + abstract E cloneE(E activity); /** * Summarizes an activity into an activity summary. Most methods on @@ -779,7 +780,7 @@ public static BigInteger getActivityLocalKey(ElementSummary activity, BigInteger * @param key * the local key */ - protected static void setWorkLocalKey(ElementSummary activity, BigInteger key) { + static void setWorkLocalKey(ElementSummary activity, BigInteger key) { if (activity == null) throw new IllegalArgumentException("Null element."); @@ -808,7 +809,7 @@ public static void cleanWorkLocalKey(ElementSummary activity) { * @param to * the target summary */ - protected static void copy(ElementSummary from, ElementSummary to) { + static void copy(ElementSummary from, ElementSummary to) { assert from != null; assert to != null; @@ -821,6 +822,24 @@ protected static void copy(ElementSummary from, ElementSummary to) { to.setVisibility(from.getVisibility()); } + /** + * Clones an external identifier. + * + * @param id + * the identifier to be clones + * @return the clone + */ + static ExternalId clone(ExternalId id) { + assert id != null; + + final ExternalId eid = new ExternalId(); + eid.setExternalIdRelationship(id.getExternalIdRelationship()); + eid.setExternalIdType(id.getExternalIdType().toLowerCase()); + eid.setExternalIdValue(id.getExternalIdValue()); + eid.setExternalIdUrl(id.getExternalIdUrl()); + return eid; + } + /** * Retrieves the type of an activity. Build on * {@link #getTypeS(ElementSummary)}. @@ -841,7 +860,7 @@ public final T getTypeE(E activity) { * the ORCID activity * @return the activity's title if defined, empty string otherwise */ - protected final String getTitleE(E activity) { + final String getTitleE(E activity) { return getTitleS(summarize(activity)); } @@ -853,7 +872,7 @@ protected final String getTitleE(E activity) { * the ORCID activity * @return the activity's publication year, may be null */ - protected final String getPubYearE(E activity) { + final String getPubYearE(E activity) { return getYearS(summarize(activity)); } @@ -866,7 +885,7 @@ protected final String getPubYearE(E activity) { * identifiers * @return the non-null part-of external identifiers */ - protected final ExternalIds getPartOfExternalIdsS(S summary) { + final ExternalIds getPartOfExternalIdsS(S summary) { if (summary == null) throw new IllegalArgumentException("Null element."); @@ -900,7 +919,7 @@ public final ExternalIds getPartOfExternalIdsE(E activity) { * identifiers * @return the non-null self external identifiers */ - protected final ExternalIds getSelfExternalIdsS(S summary) { + final ExternalIds getSelfExternalIdsS(S summary) { if (summary == null) throw new IllegalArgumentException("Null element."); @@ -958,13 +977,16 @@ public final Map getSelfExternalIdsDiffS(S summary, Collecti * Tests whether two sets of (non-exclusively self or part-of) external * identifiers are identical. * + * TODO: the URLs assigned to the external ids are not being considered in + * this comparison. + * * @param eids1 * the first set of external identifiers * @param eids2 * the second set of external identifiers * @return whether the external identifiers are identical */ - protected static boolean identicalExternalIDs(ExternalIds eids1, + static boolean identicalExternalIDs(ExternalIds eids1, ExternalIds eids2) { assert eids1 != null; assert eids2 != null; @@ -1001,6 +1023,7 @@ public final boolean hasNewSelfIDs(E preElement, S posElement) { /** * Checks whether an activity is already up to date regarding another one, * considering the self {@link ExternalIdentifier external identifiers}. + * This comparison disregards the URLs assigned to the identifiers. * * @param preElement * the potentially out of date ORCID activity @@ -1111,4 +1134,22 @@ public final Set testMinimalQuality(S summary) { return testMinimalQuality(summary, new HashSet()); } + /** + * Tests whether a date is well constructed. + * + * @param date + * the date to be tested + * @return whether the date is well formed + */ + static boolean testQualityFuzzyDate(FuzzyDate date) { + if (date.getYear() != null && date.getYear().getValue().length() != 4) + return false; + if (date.getMonth() != null && date.getMonth().getValue().length() != 2) + return false; + if (date.getDay() != null && date.getDay().getValue().length() != 2) + return false; + + return true; + } + } diff --git a/src/main/java/pt/ptcris/utils/ORCIDWorkHelper.java b/src/main/java/pt/ptcris/utils/ORCIDWorkHelper.java index d26d8c7..7373a9d 100644 --- a/src/main/java/pt/ptcris/utils/ORCIDWorkHelper.java +++ b/src/main/java/pt/ptcris/utils/ORCIDWorkHelper.java @@ -257,13 +257,8 @@ protected WorkSummary group(WorkGroup group) throws IllegalArgumentException { final List eids = getPartOfExternalIdsS(dummy) .getExternalId(); - for (ExternalId id : group.getExternalIds().getExternalId()) { - final ExternalId eid = new ExternalId(); - eid.setExternalIdRelationship(id.getExternalIdRelationship()); - eid.setExternalIdType(id.getExternalIdType().toLowerCase()); - eid.setExternalIdValue(id.getExternalIdValue()); - eids.add(eid); - } + for (ExternalId id : group.getExternalIds().getExternalId()) + eids.add(clone(id)); dummy.setExternalIds(new ExternalIds(eids)); return dummy; @@ -273,8 +268,8 @@ protected WorkSummary group(WorkGroup group) throws IllegalArgumentException { * {@inheritDoc} * * The considered fields are: title, publication date (year), work type and - * part-of external identifiers. All this meta-data is available in work - * summaries. + * part-of external identifiers (excluding URLs). All this meta-data is + * available in work summaries. * * TODO: contributors are not being considered as they are not contained in * the summaries. @@ -332,8 +327,13 @@ else if (work.getTitle().getTitle() == null) || (work.getType() != WorkType.DATA_SET && work.getType() != WorkType.RESEARCH_TECHNIQUE)) { if (work.getPublicationDate() == null) res.add(INVALID_PUBLICATIONDATE); - else if (work.getPublicationDate().getYear() == null) - res.add(INVALID_YEAR); + else { + if (!testQualityFuzzyDate(work.getPublicationDate())) + res.add(INVALID_PUBLICATIONDATE); + if (work.getPublicationDate().getYear() == null) + res.add(INVALID_YEAR); + } + // TODO: months and days must have two characters; but these are optional; should it be tested here? } Map worksDiffs = getSelfExternalIdsDiffS(work, others); @@ -405,7 +405,7 @@ public Work cloneE(Work work) { @Override public WorkSummary summarize(Work work) { assert work != null; - + final WorkSummary dummy = new WorkSummary(); copy(work, dummy); dummy.setPublicationDate(work.getPublicationDate()); diff --git a/src/test/java/pt/ptcris/test/TestHelper.java b/src/test/java/pt/ptcris/test/TestHelper.java index 92d0415..f17c5e0 100644 --- a/src/test/java/pt/ptcris/test/TestHelper.java +++ b/src/test/java/pt/ptcris/test/TestHelper.java @@ -19,6 +19,8 @@ import org.um.dsi.gavea.orcid.model.common.ExternalId; import org.um.dsi.gavea.orcid.model.common.ExternalIds; import org.um.dsi.gavea.orcid.model.common.FuzzyDate; +import org.um.dsi.gavea.orcid.model.common.FuzzyDate.Day; +import org.um.dsi.gavea.orcid.model.common.FuzzyDate.Month; import org.um.dsi.gavea.orcid.model.common.Iso3166Country; import org.um.dsi.gavea.orcid.model.common.OrganizationAddress; import org.um.dsi.gavea.orcid.model.common.FuzzyDate.Year; @@ -56,7 +58,7 @@ public static Work work(BigInteger key, String meta) { else work.setType(WorkType.CONFERENCE_PAPER); - FuzzyDate date = new FuzzyDate(new Year("201" + meta.charAt(meta.length()-1)), null, null); + FuzzyDate date = new FuzzyDate(new Year("201" + meta.charAt(meta.length()-1)), new Month("03"), new Day("21")); work.setPublicationDate(date); } @@ -240,7 +242,7 @@ public static Funding funding(BigInteger key, String meta) { else work.setType(FundingType.GRANT); - FuzzyDate date = new FuzzyDate(new Year("201" + meta.charAt(meta.length()-1)), null, null); + FuzzyDate date = new FuzzyDate(new Year("201" + meta.charAt(meta.length()-1)), new Month("02"), null); work.setStartDate(date); } @@ -323,7 +325,7 @@ public static Funding fundingIgn(BigInteger key, String meta, String nmb) { if (meta.equals("0")) work.setType(FundingType.AWARD); - FuzzyDate date = new FuzzyDate(new Year("201" + meta.charAt(meta.length()-1)), null, null); + FuzzyDate date = new FuzzyDate(new Year("201" + meta.charAt(meta.length()-1)), new Month("02"), null); work.setStartDate(date); } diff --git a/src/test/java/pt/ptcris/test/Tester.java b/src/test/java/pt/ptcris/test/Tester.java index 768be81..6785c07 100644 --- a/src/test/java/pt/ptcris/test/Tester.java +++ b/src/test/java/pt/ptcris/test/Tester.java @@ -71,6 +71,7 @@ public void step(int s) { } private void progress() { - setProgress((step*100)/max); + if (max > 0) + setProgress((step*100)/max); } } diff --git a/src/test/java/pt/ptcris/test/grouper/GrouperTest.java b/src/test/java/pt/ptcris/test/grouper/GrouperTest.java index fc247ba..df77efa 100644 --- a/src/test/java/pt/ptcris/test/grouper/GrouperTest.java +++ b/src/test/java/pt/ptcris/test/grouper/GrouperTest.java @@ -41,7 +41,7 @@ public static void main(String[] args) { works.add(work7); List> groups = PTCRISGrouper.group(works, new StdWorkComparator()); - + groups.get(0).getActivities(); assertEquals(groups.size(), 4); return; diff --git a/target/classes/META-INF/MANIFEST.MF b/target/classes/META-INF/MANIFEST.MF index 7a49da0..d04c087 100644 --- a/target/classes/META-INF/MANIFEST.MF +++ b/target/classes/META-INF/MANIFEST.MF @@ -1,5 +1,5 @@ Manifest-Version: 1.0 -Built-By: Luᅢᆳs -Build-Jdk: 1.8.0_92 +Built-By: lpedro +Build-Jdk: 1.8.0_131 Created-By: Maven Integration for Eclipse diff --git a/target/classes/META-INF/maven/pt.ptcris/ptcrisync/pom.properties b/target/classes/META-INF/maven/pt.ptcris/ptcrisync/pom.properties index 304128f..b0a1178 100644 --- a/target/classes/META-INF/maven/pt.ptcris/ptcrisync/pom.properties +++ b/target/classes/META-INF/maven/pt.ptcris/ptcrisync/pom.properties @@ -1,7 +1,7 @@ #Generated by Maven Integration for Eclipse -#Tue Jul 04 11:38:26 BST 2017 -version=0.0.1 +#Thu Aug 31 12:44:52 BST 2017 +version=1.0 groupId=pt.ptcris m2e.projectName=ptcrisync-1.0 -m2e.projectLocation=C\:\\Lixo\\Versao 1 +m2e.projectLocation=C\:\\Projectos\\DeGois_Online_Desenvolvimento\\PTCRISync\\VersaoV1 artifactId=ptcrisync diff --git a/target/classes/META-INF/maven/pt.ptcris/ptcrisync/pom.xml b/target/classes/META-INF/maven/pt.ptcris/ptcrisync/pom.xml index 20da392..31dfb3c 100644 --- a/target/classes/META-INF/maven/pt.ptcris/ptcrisync/pom.xml +++ b/target/classes/META-INF/maven/pt.ptcris/ptcrisync/pom.xml @@ -3,7 +3,7 @@ 4.0.0 pt.ptcris ptcrisync - 0.0.1 + 1.0 UTF-8 From c1b33fc382bc291346e9f853c47b13a5dd0b402d Mon Sep 17 00:00:00 2001 From: lpedro Date: Thu, 7 Sep 2017 14:50:56 +0000 Subject: [PATCH 05/16] C4524 --- src/main/java/pt/ptcris/utils/ORCIDFundingHelper.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/pt/ptcris/utils/ORCIDFundingHelper.java b/src/main/java/pt/ptcris/utils/ORCIDFundingHelper.java index 5dc70c9..79a446e 100644 --- a/src/main/java/pt/ptcris/utils/ORCIDFundingHelper.java +++ b/src/main/java/pt/ptcris/utils/ORCIDFundingHelper.java @@ -296,7 +296,7 @@ else if (funding.getTitle().getTitle() == null) res.add(INVALID_YEAR); } - if (funding.getEndDate() != null && !!testQualityFuzzyDate(funding.getEndDate())) + if (funding.getEndDate() != null && !testQualityFuzzyDate(funding.getEndDate())) res.add(INVALID_PUBLICATIONDATE); Map fundingsDiffs = getSelfExternalIdsDiffS(funding, others); From ee074bb8079209b6b60bdf46f014366df68c67a8 Mon Sep 17 00:00:00 2001 From: "pedro.lopes" Date: Thu, 21 Sep 2017 11:39:08 +0000 Subject: [PATCH 06/16] C4538 --- src/main/java/pt/ptcris/grouper/ActivityComparator.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/pt/ptcris/grouper/ActivityComparator.java b/src/main/java/pt/ptcris/grouper/ActivityComparator.java index ed95167..7447781 100644 --- a/src/main/java/pt/ptcris/grouper/ActivityComparator.java +++ b/src/main/java/pt/ptcris/grouper/ActivityComparator.java @@ -51,7 +51,7 @@ public abstract class ActivityComparator { * @return whether the activities match */ private final boolean matches(A act1, A act2) { - return compare(act1, act2) > threshold(); + return compare(act1, act2) >= threshold(); } /** From 912b24c4597f8e5ef9a8eebb6a0626f52355989c Mon Sep 17 00:00:00 2001 From: lpedro Date: Mon, 11 Dec 2017 11:22:16 +0000 Subject: [PATCH 07/16] C4611 --- src/main/java/pt/ptcris/utils/ORCIDWorkHelper.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/pt/ptcris/utils/ORCIDWorkHelper.java b/src/main/java/pt/ptcris/utils/ORCIDWorkHelper.java index 7373a9d..1765c89 100644 --- a/src/main/java/pt/ptcris/utils/ORCIDWorkHelper.java +++ b/src/main/java/pt/ptcris/utils/ORCIDWorkHelper.java @@ -48,7 +48,7 @@ enum EIdType { PMID("pmid"), RFC("rfc"), SOURCE_WORK_ID("source-work-id"), SSRN("ssrn"), URI("uri"), URN("urn"), WOSUID("wosuid"), ZBL("zbl"), CIENCIAIUL("cienciaiul"), LENSID("lensid"), PDB("pdb"), KUID("kuid"), - ASIN_TLD("asin-tld"); + ASIN_TLD("asin-tld"), AUTHENTICUSID("authenticusid"), RRID("rrid"); public final String value; From e319bd01d9f8b948b175f024f4a1e887734597cc Mon Sep 17 00:00:00 2001 From: Luis Pedro Date: Tue, 20 Feb 2018 09:40:31 +0000 Subject: [PATCH 08/16] C4741 --- .../classes/META-INF/maven/pt.ptcris/ptcrisync/pom.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target/classes/META-INF/maven/pt.ptcris/ptcrisync/pom.properties b/target/classes/META-INF/maven/pt.ptcris/ptcrisync/pom.properties index b0a1178..3897d1b 100644 --- a/target/classes/META-INF/maven/pt.ptcris/ptcrisync/pom.properties +++ b/target/classes/META-INF/maven/pt.ptcris/ptcrisync/pom.properties @@ -1,5 +1,5 @@ #Generated by Maven Integration for Eclipse -#Thu Aug 31 12:44:52 BST 2017 +#Thu Feb 15 14:44:07 GMT 2018 version=1.0 groupId=pt.ptcris m2e.projectName=ptcrisync-1.0 From 3a5bbc714636645ec2b8926abf00e756b6955e41 Mon Sep 17 00:00:00 2001 From: Luis Pedro Date: Wed, 12 Sep 2018 13:10:51 +0000 Subject: [PATCH 09/16] C5001 --- src/main/java/pt/ptcris/utils/ORCIDWorkHelper.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/pt/ptcris/utils/ORCIDWorkHelper.java b/src/main/java/pt/ptcris/utils/ORCIDWorkHelper.java index 1765c89..67022fc 100644 --- a/src/main/java/pt/ptcris/utils/ORCIDWorkHelper.java +++ b/src/main/java/pt/ptcris/utils/ORCIDWorkHelper.java @@ -40,8 +40,8 @@ public final class ORCIDWorkHelper extends ORCIDHelper { enum EIdType { - OTHER_ID("other-id"), AGR("agr"), ARXIV("arxiv"), ASIN("asin"), - BIBCODE("bibcode"), CBA("cba"), CIT("cit"), CTX("ctx"), DOI("doi"), + OTHER_ID("other-id"), AGR("agr"), ARXIV("arxiv"), ARK("ark"), ASIN("asin"), + BIBCODE("bibcode"), CBA("cba"), CIT("cit"), CTX("ctx"), DNB("dnb"), DOI("doi"), EID("eid"), ETHOS("ethos"), HANDLE("handle"), HIR("hir"), ISBN("isbn"), ISSN("issn"), JFM("jfm"), JSTOR("jstor"), LCCN("lccn"), MR("mr"), OCLC("oclc"), OL("ol"), OSTI("osti"), PAT("pat"), PMC("pmc"), From 155155e86a15c106ec6507bcb236863b125a7e7a Mon Sep 17 00:00:00 2001 From: Luis Pedro Date: Tue, 18 Sep 2018 12:35:55 +0000 Subject: [PATCH 10/16] C5009 --- src/main/java/pt/ptcris/ORCIDClientImpl.java | 44 ++++++++++---------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/src/main/java/pt/ptcris/ORCIDClientImpl.java b/src/main/java/pt/ptcris/ORCIDClientImpl.java index 7149632..a64535c 100644 --- a/src/main/java/pt/ptcris/ORCIDClientImpl.java +++ b/src/main/java/pt/ptcris/ORCIDClientImpl.java @@ -23,12 +23,11 @@ import org.um.dsi.gavea.orcid.model.activities.Fundings; import org.um.dsi.gavea.orcid.model.activities.Works; import org.um.dsi.gavea.orcid.model.bulk.Bulk; -import org.um.dsi.gavea.orcid.model.common.ElementSummary; -import org.um.dsi.gavea.orcid.model.work.Work; -import org.um.dsi.gavea.orcid.model.work.WorkSummary; import org.um.dsi.gavea.orcid.model.error.Error; import org.um.dsi.gavea.orcid.model.funding.Funding; import org.um.dsi.gavea.orcid.model.funding.FundingSummary; +import org.um.dsi.gavea.orcid.model.work.Work; +import org.um.dsi.gavea.orcid.model.work.WorkSummary; import pt.ptcris.utils.ORCIDFundingHelper; import pt.ptcris.utils.ORCIDHelper; @@ -199,10 +198,10 @@ public Fundings getFundingsSummary() throws OrcidClientException { public PTCRISyncResult getWork(WorkSummary putcode) { PTCRISyncResult res; try { - Work fund = orcidClient.readWork(orcidToken, putcode.getPutCode() + Work work = orcidClient.readWork(orcidToken, putcode.getPutCode() .toString()); - finalizeGet(fund, putcode); - res = PTCRISyncResult.ok_get(putcode.getPutCode(), fund); + finalizeGet(work, putcode); + res = PTCRISyncResult.ok_get(putcode.getPutCode(), work); } catch (OrcidClientException e) { res = PTCRISyncResult.fail(e); } @@ -232,25 +231,26 @@ public PTCRISyncResult getFunding(FundingSummary putcode) { @Override public Map> getWorks(List summaries) { List pcs = new ArrayList(); - for (ElementSummary i : summaries) + for (WorkSummary i : summaries) pcs.add(i.getPutCode().toString()); Map> res = new HashMap>(); try { - List bulk = orcidClient.readWorks(orcidToken, pcs) - .getWorkOrError(); + List bulk = orcidClient.readWorks(orcidToken, pcs).getWorkOrError(); + // no guarantee that the bulk results are ordered as the request + Map bulkWs = new HashMap(); + for (Serializable w : bulk) + if (w instanceof Work) + bulkWs.put(((Work) w).getPutCode(), (Work) w); for (int i = 0; i < summaries.size(); i++) { - Serializable w = bulk.get(i); - if (w instanceof Work) { - finalizeGet((Work) w, summaries.get(i)); - res.put(summaries.get(i).getPutCode(), PTCRISyncResult.ok_get( - summaries.get(i).getPutCode(), (Work) w)); + WorkSummary s = summaries.get(i); + Work w = bulkWs.get(s.getPutCode()); + if (w != null) { + finalizeGet(w, s); + res.put(s.getPutCode(), PTCRISyncResult.ok_get(s.getPutCode(), w)); } else { - Error err = (Error) w; - OrcidClientException e = new OrcidClientException( - err.getResponseCode(), err.getUserMessage(), - err.getErrorCode(), err.getDeveloperMessage()); - res.put(summaries.get(i).getPutCode(), - PTCRISyncResult.fail(e)); + // errors have no putcode information, cannot guarantee error message matching + OrcidClientException e = new OrcidClientException(); + res.put(s.getPutCode(),PTCRISyncResult.fail(e)); } } } catch (OrcidClientException e1) { @@ -399,7 +399,7 @@ public int threads() { private static void finalizeGet(Work full, WorkSummary summary) { // External ids are not inherited... full.setExternalIds(new ORCIDWorkHelper(null) - .getNonNullExternalIdsS((WorkSummary) summary)); + .getNonNullExternalIdsS(summary)); ORCIDHelper.cleanWorkLocalKey(full); } @@ -416,7 +416,7 @@ private static void finalizeGet(Work full, WorkSummary summary) { */ private static void finalizeGet(Funding full, FundingSummary summary) { full.setExternalIds(new ORCIDFundingHelper(null) - .getNonNullExternalIdsS((FundingSummary) summary)); + .getNonNullExternalIdsS(summary)); ORCIDHelper.cleanWorkLocalKey(full); } From 6b6fbf5436a8c6eb4d4574afef0f6e6479e7f683 Mon Sep 17 00:00:00 2001 From: Luis Pedro Date: Wed, 17 Oct 2018 12:24:43 +0000 Subject: [PATCH 11/16] C5081 --- .classpath | 1 + .settings/org.eclipse.jdt.core.prefs | 1 + 2 files changed, 2 insertions(+) diff --git a/.classpath b/.classpath index e474853..84674e0 100644 --- a/.classpath +++ b/.classpath @@ -10,6 +10,7 @@ + diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs index d50689a..0431c3d 100644 --- a/.settings/org.eclipse.jdt.core.prefs +++ b/.settings/org.eclipse.jdt.core.prefs @@ -10,5 +10,6 @@ org.eclipse.jdt.core.compiler.debug.sourceFile=generate org.eclipse.jdt.core.compiler.problem.assertIdentifier=error org.eclipse.jdt.core.compiler.problem.enumIdentifier=error org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning +org.eclipse.jdt.core.compiler.release=disabled org.eclipse.jdt.core.compiler.source=1.8 org.eclipse.objectteams.otdt.compiler.option.pure_java=enabled From d01b15b4011ecf26972c3d17c0d067732e34c8b9 Mon Sep 17 00:00:00 2001 From: Luis Pedro Date: Thu, 24 Jan 2019 15:12:30 +0000 Subject: [PATCH 12/16] C5298 --- src/main/java/pt/ptcris/utils/ORCIDHelper.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/pt/ptcris/utils/ORCIDHelper.java b/src/main/java/pt/ptcris/utils/ORCIDHelper.java index 56014b0..630db86 100644 --- a/src/main/java/pt/ptcris/utils/ORCIDHelper.java +++ b/src/main/java/pt/ptcris/utils/ORCIDHelper.java @@ -36,6 +36,7 @@ import org.um.dsi.gavea.orcid.model.funding.Funding; import org.um.dsi.gavea.orcid.model.funding.FundingSummary; import org.um.dsi.gavea.orcid.model.funding.FundingType; +import org.um.dsi.gavea.orcid.model.person.externalidentifier.ExternalIdentifier; import org.um.dsi.gavea.orcid.model.work.Work; import org.um.dsi.gavea.orcid.model.work.WorkSummary; import org.um.dsi.gavea.orcid.model.work.WorkType; @@ -835,7 +836,7 @@ static ExternalId clone(ExternalId id) { final ExternalId eid = new ExternalId(); eid.setExternalIdRelationship(id.getExternalIdRelationship()); eid.setExternalIdType(id.getExternalIdType().toLowerCase()); - eid.setExternalIdValue(id.getExternalIdValue()); + eid.setExternalIdValue(id.getExternalIdValue().replaceAll("\\p{C}", "").trim()); eid.setExternalIdUrl(id.getExternalIdUrl()); return eid; } From c0de7680312e6f9a2162da20c1ae7171e34e183e Mon Sep 17 00:00:00 2001 From: Luis Pedro Date: Wed, 3 Jul 2019 13:44:58 +0000 Subject: [PATCH 13/16] C5563 --- .settings/org.eclipse.jdt.core.prefs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs index 0431c3d..8d6983d 100644 --- a/.settings/org.eclipse.jdt.core.prefs +++ b/.settings/org.eclipse.jdt.core.prefs @@ -8,8 +8,10 @@ org.eclipse.jdt.core.compiler.debug.lineNumber=generate org.eclipse.jdt.core.compiler.debug.localVariable=generate org.eclipse.jdt.core.compiler.debug.sourceFile=generate org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled org.eclipse.jdt.core.compiler.problem.enumIdentifier=error org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning +org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore org.eclipse.jdt.core.compiler.release=disabled org.eclipse.jdt.core.compiler.source=1.8 org.eclipse.objectteams.otdt.compiler.option.pure_java=enabled From 90d58d16147a168953aa7baecba65943bd7fff7c Mon Sep 17 00:00:00 2001 From: Ricardo Pereira Date: Wed, 2 Dec 2020 16:23:56 +0000 Subject: [PATCH 14/16] eclipse stuff removed --- .classpath | 28 ------- .gitignore | 19 +++++ .project | 37 ---------- .settings/org.eclipse.core.resources.prefs | 4 - .settings/org.eclipse.jdt.core.prefs | 17 ----- .settings/org.eclipse.wst.common.component | 5 -- ....eclipse.wst.common.project.facet.core.xml | 5 -- .settings/org.eclipse.wst.validation.prefs | 2 - target/classes/META-INF/MANIFEST.MF | 5 -- .../maven/pt.ptcris/ptcrisync/pom.properties | 7 -- .../maven/pt.ptcris/ptcrisync/pom.xml | 73 ------------------- 11 files changed, 19 insertions(+), 183 deletions(-) delete mode 100644 .classpath create mode 100644 .gitignore delete mode 100644 .project delete mode 100644 .settings/org.eclipse.core.resources.prefs delete mode 100644 .settings/org.eclipse.jdt.core.prefs delete mode 100644 .settings/org.eclipse.wst.common.component delete mode 100644 .settings/org.eclipse.wst.common.project.facet.core.xml delete mode 100644 .settings/org.eclipse.wst.validation.prefs delete mode 100644 target/classes/META-INF/MANIFEST.MF delete mode 100644 target/classes/META-INF/maven/pt.ptcris/ptcrisync/pom.properties delete mode 100644 target/classes/META-INF/maven/pt.ptcris/ptcrisync/pom.xml diff --git a/.classpath b/.classpath deleted file mode 100644 index 84674e0..0000000 --- a/.classpath +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..2b2d12c --- /dev/null +++ b/.gitignore @@ -0,0 +1,19 @@ +# Java related +target/** +*.jar +*.war +*.ear +*.class + +# eclipse specific +.project +.metadata +bin/** +tmp/** +tmp/**/* +*.tmp +*.bak +*.swp +.classpath +.settings/ +.loadpath diff --git a/.project b/.project deleted file mode 100644 index 13e7316..0000000 --- a/.project +++ /dev/null @@ -1,37 +0,0 @@ - - - ptcrisync-1.0 - - - - - - org.eclipse.wst.common.project.facet.core.builder - - - - - org.eclipse.jdt.core.javabuilder - - - - - org.eclipse.wst.validation.validationbuilder - - - - - org.eclipse.m2e.core.maven2Builder - - - - - - org.eclipse.jem.workbench.JavaEMFNature - org.eclipse.wst.common.modulecore.ModuleCoreNature - org.eclipse.m2e.core.maven2Nature - org.eclipse.jdt.core.javanature - com.jaspersoft.studio.babel.editor.rbeNature - org.eclipse.wst.common.project.facet.core.nature - - diff --git a/.settings/org.eclipse.core.resources.prefs b/.settings/org.eclipse.core.resources.prefs deleted file mode 100644 index 4c28b1a..0000000 --- a/.settings/org.eclipse.core.resources.prefs +++ /dev/null @@ -1,4 +0,0 @@ -eclipse.preferences.version=1 -encoding//src/main/java=UTF-8 -encoding//src/test/java=UTF-8 -encoding/=UTF-8 diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index 8d6983d..0000000 --- a/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,17 +0,0 @@ -eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 -org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.compliance=1.8 -org.eclipse.jdt.core.compiler.debug.lineNumber=generate -org.eclipse.jdt.core.compiler.debug.localVariable=generate -org.eclipse.jdt.core.compiler.debug.sourceFile=generate -org.eclipse.jdt.core.compiler.problem.assertIdentifier=error -org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled -org.eclipse.jdt.core.compiler.problem.enumIdentifier=error -org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning -org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore -org.eclipse.jdt.core.compiler.release=disabled -org.eclipse.jdt.core.compiler.source=1.8 -org.eclipse.objectteams.otdt.compiler.option.pure_java=enabled diff --git a/.settings/org.eclipse.wst.common.component b/.settings/org.eclipse.wst.common.component deleted file mode 100644 index 50c1a1f..0000000 --- a/.settings/org.eclipse.wst.common.component +++ /dev/null @@ -1,5 +0,0 @@ - - - - - diff --git a/.settings/org.eclipse.wst.common.project.facet.core.xml b/.settings/org.eclipse.wst.common.project.facet.core.xml deleted file mode 100644 index 6302d3e..0000000 --- a/.settings/org.eclipse.wst.common.project.facet.core.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - - diff --git a/.settings/org.eclipse.wst.validation.prefs b/.settings/org.eclipse.wst.validation.prefs deleted file mode 100644 index 6f1cba6..0000000 --- a/.settings/org.eclipse.wst.validation.prefs +++ /dev/null @@ -1,2 +0,0 @@ -disabled=06target -eclipse.preferences.version=1 diff --git a/target/classes/META-INF/MANIFEST.MF b/target/classes/META-INF/MANIFEST.MF deleted file mode 100644 index d04c087..0000000 --- a/target/classes/META-INF/MANIFEST.MF +++ /dev/null @@ -1,5 +0,0 @@ -Manifest-Version: 1.0 -Built-By: lpedro -Build-Jdk: 1.8.0_131 -Created-By: Maven Integration for Eclipse - diff --git a/target/classes/META-INF/maven/pt.ptcris/ptcrisync/pom.properties b/target/classes/META-INF/maven/pt.ptcris/ptcrisync/pom.properties deleted file mode 100644 index 3897d1b..0000000 --- a/target/classes/META-INF/maven/pt.ptcris/ptcrisync/pom.properties +++ /dev/null @@ -1,7 +0,0 @@ -#Generated by Maven Integration for Eclipse -#Thu Feb 15 14:44:07 GMT 2018 -version=1.0 -groupId=pt.ptcris -m2e.projectName=ptcrisync-1.0 -m2e.projectLocation=C\:\\Projectos\\DeGois_Online_Desenvolvimento\\PTCRISync\\VersaoV1 -artifactId=ptcrisync diff --git a/target/classes/META-INF/maven/pt.ptcris/ptcrisync/pom.xml b/target/classes/META-INF/maven/pt.ptcris/ptcrisync/pom.xml deleted file mode 100644 index 31dfb3c..0000000 --- a/target/classes/META-INF/maven/pt.ptcris/ptcrisync/pom.xml +++ /dev/null @@ -1,73 +0,0 @@ - - 4.0.0 - pt.ptcris - ptcrisync - 1.0 - - - UTF-8 - 1.8 - 2.0 - 1.1.9 - 4.12 - - - - - - org.um.dsi.gavea - degois-orcid-client - ${orcid-api-client.version} - - - - ch.qos.logback - logback-classic - ${logback-version} - compile - - - - junit - junit - ${junit.version} - - - - - - - - - org.apache.maven.plugins - maven-jar-plugin - 3.0.0 - - ${java.version} - ${java.version} - - - - maven-compiler-plugin - 3.3 - - ${java.version} - ${java.version} - - - - true - maven-deploy-plugin - 2.8.2 - - true - - - - - - - PTCRISync - This project aims to help the synchronization between ORCID and local systems. - From f692593cebb01c764f50bbf9d5cca0d16863466a Mon Sep 17 00:00:00 2001 From: Ricardo Pereira Date: Thu, 26 Aug 2021 10:57:04 +0100 Subject: [PATCH 15/16] HAL added to enum --- src/main/java/pt/ptcris/utils/ORCIDWorkHelper.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/pt/ptcris/utils/ORCIDWorkHelper.java b/src/main/java/pt/ptcris/utils/ORCIDWorkHelper.java index 67022fc..540eb26 100644 --- a/src/main/java/pt/ptcris/utils/ORCIDWorkHelper.java +++ b/src/main/java/pt/ptcris/utils/ORCIDWorkHelper.java @@ -48,7 +48,7 @@ enum EIdType { PMID("pmid"), RFC("rfc"), SOURCE_WORK_ID("source-work-id"), SSRN("ssrn"), URI("uri"), URN("urn"), WOSUID("wosuid"), ZBL("zbl"), CIENCIAIUL("cienciaiul"), LENSID("lensid"), PDB("pdb"), KUID("kuid"), - ASIN_TLD("asin-tld"), AUTHENTICUSID("authenticusid"), RRID("rrid"); + ASIN_TLD("asin-tld"), AUTHENTICUSID("authenticusid"), RRID("rrid"), HAL("hal"); public final String value; From 01d6defb2d9f6ff975a82a2dc8480c865a2ffd74 Mon Sep 17 00:00:00 2001 From: Ricardo Pereira Date: Tue, 30 Nov 2021 16:26:14 +0000 Subject: [PATCH 16/16] merge ORCID API_v3.0 into master --- pom.xml | 4 +- src/main/java/pt/ptcris/PTCRISync.java | 91 +++++++++++++++++-- .../pt/ptcris/utils/ORCIDFundingHelper.java | 4 +- .../java/pt/ptcris/utils/ORCIDHelper.java | 55 +++++++++-- .../java/pt/ptcris/utils/ORCIDWorkHelper.java | 20 +++- .../java/pt/ptcris/test/PTCRISExample.java | 12 +-- src/test/java/pt/ptcris/test/TestClients.java | 25 ++--- src/test/java/pt/ptcris/test/TestHelper.java | 59 ++++++------ .../pt/ptcris/test/scenarios/Scenario.java | 5 +- .../test/scenarios/ScenarioFunding.java | 5 +- 10 files changed, 208 insertions(+), 72 deletions(-) diff --git a/pom.xml b/pom.xml index 31dfb3c..63541fb 100644 --- a/pom.xml +++ b/pom.xml @@ -3,12 +3,12 @@ 4.0.0 pt.ptcris ptcrisync - 1.0 + 1.1 UTF-8 1.8 - 2.0 + 3.0 1.1.9 4.12 diff --git a/src/main/java/pt/ptcris/PTCRISync.java b/src/main/java/pt/ptcris/PTCRISync.java index 1d65aca..5b202d4 100644 --- a/src/main/java/pt/ptcris/PTCRISync.java +++ b/src/main/java/pt/ptcris/PTCRISync.java @@ -24,11 +24,12 @@ import org.um.dsi.gavea.orcid.model.common.ElementSummary; import org.um.dsi.gavea.orcid.model.common.ExternalId; import org.um.dsi.gavea.orcid.model.common.ExternalIds; +import org.um.dsi.gavea.orcid.model.common.FundingType; +import org.um.dsi.gavea.orcid.model.common.WorkType; import org.um.dsi.gavea.orcid.model.funding.Funding; -import org.um.dsi.gavea.orcid.model.funding.FundingType; import org.um.dsi.gavea.orcid.model.person.externalidentifier.ExternalIdentifier; import org.um.dsi.gavea.orcid.model.work.Work; -import org.um.dsi.gavea.orcid.model.work.WorkType; +import org.um.dsi.gavea.orcid.model.work.WorkSummary; import pt.ptcris.exceptions.InvalidActivityException; import pt.ptcris.handlers.ProgressHandler; @@ -517,6 +518,7 @@ private static > toUpdate = new LinkedList>(); + List> toUpdateFundedBy = new LinkedList>(); for (int c = 0; c != orcids.size(); c++) { S orcid = orcids.get(c); @@ -528,14 +530,24 @@ private static (local, orcid, worksDiffs.get(local))); + isIncluded = true; + } else result.put(ORCIDHelper.getActivityLocalKey(local, BigInteger.valueOf(c)), PTCRISyncResult.uptodate()); locals.remove(local); + + // if the remote work isn't update in what concerns of FundedBy identifiers + ExternalIdsDiff fundedByExternalIdsDiff = helper.getFundedByExternalIdsDiff(local, orcid); + if (!isIncluded && (forced || !(fundedByExternalIdsDiff.more.isEmpty() && fundedByExternalIdsDiff.less.isEmpty())) ) { + fundedByExternalIdsDiff.same.addAll(worksDiffs.get(local).same); + toUpdateFundedBy.add(new UpdateRecord(local, orcid, fundedByExternalIdsDiff)); + } } handler.step(); } @@ -551,6 +563,7 @@ private static ids = new ArrayList(update.eidsDiff.same); ids.addAll(helper.getPartOfExternalIdsE(local).getExternalId()); + ids.addAll(helper.getFundedByExternalIdsE(local).getExternalId()); weids.setExternalId(ids); helper.setExternalIdsE(local,weids); @@ -559,6 +572,9 @@ private static ids = new ArrayList(update.eidsDiff.same); ids.addAll(update.eidsDiff.less); ids.addAll(helper.getPartOfExternalIdsE(local).getExternalId()); + ids.addAll(helper.getFundedByExternalIdsE(local).getExternalId()); weids.setExternalId(ids); helper.setExternalIdsE(local,weids); @@ -581,6 +598,9 @@ private static > void treatOuputWithChangesOnlyOnFundedBy_2Phase( + ORCIDHelper helper, ProgressHandler handler, Map> result, + List> toUpdateFundedBy) { + for (int c = 0; c != toUpdateFundedBy.size(); c++) { + + // the remote work is missing external identifiers or not updated in the 1st phase + UpdateRecord update = toUpdateFundedBy.get(c); + if (!update.eidsDiff.less.isEmpty() || update.eidsDiff.more.isEmpty()) { + E local = update.preElement; + ExternalIds weids = new ExternalIds(); + List ids = new ArrayList(update.eidsDiff.same); + ids.addAll(update.eidsDiff.less); + ids.addAll(helper.getPartOfExternalIdsE(local).getExternalId()); + weids.setExternalId(ids); + helper.setExternalIdsE(local,weids); + + PTCRISyncResult res = helper.update(update.posElement.getPutCode(), local); + result.put(ORCIDHelper.getActivityLocalKey(local, BigInteger.valueOf(c)),res); + } + handler.step(); + } + } + + private static > void treatOuputWithChangesOnlyOnFundedBy_1Phase( + ORCIDHelper helper, ProgressHandler handler, Map> result, + List> toUpdateFundedBy) { + for (int c = 0; c != toUpdateFundedBy.size(); c++) { + + UpdateRecord update = toUpdateFundedBy.get(c); + // the remote work has spurious external identifiers + if (!update.eidsDiff.more.isEmpty()) { + E local = update.preElement; + ExternalIds weids = new ExternalIds(); + List ids = new ArrayList(update.eidsDiff.same); + ids.addAll(helper.getPartOfExternalIdsE(local).getExternalId()); + weids.setExternalId(ids); + helper.setExternalIdsE(local,weids); + + PTCRISyncResult res = helper.update(update.posElement.getPutCode(), local); + result.put(ORCIDHelper.getActivityLocalKey(local, BigInteger.valueOf(c)),res); + } + handler.step(); + + } + } + /** *

* Discovers new valid works in an ORCID profile given a set of known local @@ -1265,9 +1331,14 @@ private static importWorkUpdates(ORCIDClient client, List locals, ProgressHandler handler, List orcids) + throws OrcidClientException, IllegalArgumentException { + return importUpdatesBase(new ORCIDWorkHelper(client), locals, Arrays.asList(WorkType.values()), handler, orcids); + } + public static List importWorkUpdates(ORCIDClient client, List locals, ProgressHandler handler) throws OrcidClientException, IllegalArgumentException { - return importUpdatesBase(new ORCIDWorkHelper(client), locals, Arrays.asList(WorkType.values()), handler); + return importUpdatesBase(new ORCIDWorkHelper(client), locals, Arrays.asList(WorkType.values()), handler, new ArrayList<>()); } /** @@ -1292,7 +1363,7 @@ public static List importWorkUpdates(ORCIDClient client, List locals @Deprecated public static List importUpdates(ORCIDClient client, List locals, ProgressHandler handler) throws OrcidClientException, IllegalArgumentException { - return importWorkUpdates(client, locals, handler); + return importWorkUpdates(client, locals, handler, new ArrayList<>()); } /** @@ -1360,7 +1431,7 @@ public static List importUpdates(ORCIDClient client, List locals, Pr */ public static List importFundingUpdates(ORCIDClient client, List locals, Collection types, ProgressHandler handler) throws OrcidClientException, IllegalArgumentException { - return importUpdatesBase(new ORCIDFundingHelper(client), locals, types, handler); + return importUpdatesBase(new ORCIDFundingHelper(client), locals, types, handler, new ArrayList<>()); } /** @@ -1429,7 +1500,7 @@ public static List importFundingUpdates(ORCIDClient client, List> List importUpdatesBase( ORCIDHelper helper, List locals, - Collection types, ProgressHandler handler) + Collection types, ProgressHandler handler, List toUpdateFundedBy ) throws OrcidClientException, IllegalArgumentException { if (helper == null || locals == null || handler == null) @@ -1455,8 +1526,14 @@ private static res = new ArrayList(); for (ExternalId eid : getNonNullExternalIdsS(summary).getExternalId()) - if (eid.getExternalIdRelationship() == RelationshipType.PART_OF) + if (eid.getExternalIdRelationship() == Relationship.PART_OF) + res.add(eid); + return new ExternalIds(res); + } + + /** + * Returns the non-null funded-by external identifiers of an activity summary + * (null becomes empty list). + * + * @param summary + * the ORCID activity summary from which to retrieve the external + * identifiers + * @return the non-null part-of external identifiers + */ + final ExternalIds getFundedByExternalIdsS(S summary) { + if (summary == null) + throw new IllegalArgumentException("Null element."); + + List res = new ArrayList(); + for (ExternalId eid : getNonNullExternalIdsS(summary).getExternalId()) + if (eid.getExternalIdRelationship() == Relationship.FUNDED_BY && eid.getExternalIdType().equalsIgnoreCase(EIdType.DOI.value)) res.add(eid); return new ExternalIds(res); } @@ -926,7 +947,7 @@ final ExternalIds getSelfExternalIdsS(S summary) { List res = new ArrayList(); for (ExternalId eid : getNonNullExternalIdsS(summary).getExternalId()) - if (eid.getExternalIdRelationship() == RelationshipType.SELF) + if (eid.getExternalIdRelationship() == Relationship.SELF) res.add(eid); return new ExternalIds(res); } @@ -973,6 +994,12 @@ public final Map getSelfExternalIdsDiffS(S summary, Collecti } return matches; } + + + public final ExternalIds getFundedByExternalIdsE(E activity) { + return getFundedByExternalIdsS(summarize(activity)); + } + /** * Tests whether two sets of (non-exclusively self or part-of) external @@ -1020,6 +1047,18 @@ public final boolean hasNewSelfIDs(E preElement, S posElement) { return diff.more.isEmpty(); } + + + public final ExternalIdsDiff getFundedByExternalIdsDiff(E preElement, S posElement) { + if (preElement == null || posElement == null) + throw new IllegalArgumentException("Null element."); + + final ExternalIdsDiff diff = new ExternalIdsDiff( + getFundedByExternalIdsE(preElement), + getFundedByExternalIdsS(posElement)); + + return diff; + } /** * Checks whether an activity is already up to date regarding another one, @@ -1143,11 +1182,11 @@ public final Set testMinimalQuality(S summary) { * @return whether the date is well formed */ static boolean testQualityFuzzyDate(FuzzyDate date) { - if (date.getYear() != null && date.getYear().getValue().length() != 4) + if (date.getYear() != null && String.valueOf(date.getYear().getValue()).length() != 4) return false; - if (date.getMonth() != null && date.getMonth().getValue().length() != 2) + if (date.getMonth() != null && date.getMonth().getValue() < 1 && date.getMonth().getValue() > 12 ) return false; - if (date.getDay() != null && date.getDay().getValue().length() != 2) + if (date.getDay() != null && date.getDay().getValue() < 1 && date.getDay().getValue() > 31) return false; return true; diff --git a/src/main/java/pt/ptcris/utils/ORCIDWorkHelper.java b/src/main/java/pt/ptcris/utils/ORCIDWorkHelper.java index 540eb26..256ed58 100644 --- a/src/main/java/pt/ptcris/utils/ORCIDWorkHelper.java +++ b/src/main/java/pt/ptcris/utils/ORCIDWorkHelper.java @@ -17,14 +17,15 @@ import java.util.List; import java.util.Map; import java.util.Set; +import java.util.stream.Collectors; import org.um.dsi.gavea.orcid.client.exception.OrcidClientException; import org.um.dsi.gavea.orcid.model.activities.WorkGroup; import org.um.dsi.gavea.orcid.model.common.ExternalId; import org.um.dsi.gavea.orcid.model.common.ExternalIds; +import org.um.dsi.gavea.orcid.model.common.WorkType; import org.um.dsi.gavea.orcid.model.work.Work; import org.um.dsi.gavea.orcid.model.work.WorkSummary; -import org.um.dsi.gavea.orcid.model.work.WorkType; import pt.ptcris.ORCIDClient; import pt.ptcris.PTCRISyncResult; @@ -235,7 +236,7 @@ protected String getYearS(WorkSummary summary) { if (summary.getPublicationDate() == null || summary.getPublicationDate().getYear() == null) return null; - return summary.getPublicationDate().getYear().getValue(); + return String.valueOf(summary.getPublicationDate().getYear().getValue()); } /** {@inheritDoc} */ @@ -257,6 +258,9 @@ protected WorkSummary group(WorkGroup group) throws IllegalArgumentException { final List eids = getPartOfExternalIdsS(dummy) .getExternalId(); + + addFundedByEidsFromAllWorkSummaries(group, eids); + for (ExternalId id : group.getExternalIds().getExternalId()) eids.add(clone(id)); dummy.setExternalIds(new ExternalIds(eids)); @@ -264,6 +268,18 @@ protected WorkSummary group(WorkGroup group) throws IllegalArgumentException { return dummy; } + private void addFundedByEidsFromAllWorkSummaries(WorkGroup group, final List eids) { + Set set = new HashSet<>(eids.size()); + for (int i = 0 ; i < group.getWorkSummary().size(); i++){ + WorkSummary cloned = cloneS(group.getWorkSummary().get(i)); + List fundedByEids = getFundedByExternalIdsS(cloned).getExternalId(); + List fundedByEidsWithoutDuplicates = fundedByEids.stream() + .filter(eid -> set.add(eid.getExternalIdValue())) + .collect(Collectors.toList()); + eids.addAll(fundedByEidsWithoutDuplicates); + } + } + /** * {@inheritDoc} * diff --git a/src/test/java/pt/ptcris/test/PTCRISExample.java b/src/test/java/pt/ptcris/test/PTCRISExample.java index 5720d9c..21ea3b0 100644 --- a/src/test/java/pt/ptcris/test/PTCRISExample.java +++ b/src/test/java/pt/ptcris/test/PTCRISExample.java @@ -22,10 +22,10 @@ import org.um.dsi.gavea.orcid.client.exception.OrcidClientException; import org.um.dsi.gavea.orcid.model.common.ExternalId; import org.um.dsi.gavea.orcid.model.common.ExternalIds; -import org.um.dsi.gavea.orcid.model.common.RelationshipType; +import org.um.dsi.gavea.orcid.model.common.Relationship; +import org.um.dsi.gavea.orcid.model.common.WorkType; import org.um.dsi.gavea.orcid.model.work.Work; import org.um.dsi.gavea.orcid.model.work.WorkTitle; -import org.um.dsi.gavea.orcid.model.work.WorkType; import pt.ptcris.ORCIDClient; import pt.ptcris.PTCRISync; @@ -100,7 +100,7 @@ private static Work work0() { work.setTitle(title); ExternalId e = new ExternalId(); - e.setExternalIdRelationship(RelationshipType.SELF); + e.setExternalIdRelationship(Relationship.SELF); e.setExternalIdValue("3000"); e.setExternalIdType("DOI"); @@ -122,12 +122,12 @@ private static Work work1() { work.setTitle(title); ExternalId e = new ExternalId(); - e.setExternalIdRelationship(RelationshipType.SELF); + e.setExternalIdRelationship(Relationship.SELF); e.setExternalIdValue("4000"); e.setExternalIdType("EID"); ExternalId e1 = new ExternalId(); - e1.setExternalIdRelationship(RelationshipType.SELF); + e1.setExternalIdRelationship(Relationship.SELF); e1.setExternalIdValue("00001"); e1.setExternalIdType("DOI"); @@ -150,7 +150,7 @@ private static Work work2() { work.setTitle(title); ExternalId e = new ExternalId(); - e.setExternalIdRelationship(RelationshipType.SELF); + e.setExternalIdRelationship(Relationship.SELF); // avoids conflicts e.setExternalIdValue(String.valueOf(System.currentTimeMillis())); diff --git a/src/test/java/pt/ptcris/test/TestClients.java b/src/test/java/pt/ptcris/test/TestClients.java index 8b05075..7575250 100644 --- a/src/test/java/pt/ptcris/test/TestClients.java +++ b/src/test/java/pt/ptcris/test/TestClients.java @@ -39,24 +39,25 @@ private Profile(int value) { private static final String orcid_api_uri = "https://api.sandbox.orcid.org/"; private static final String orcid_redirect_uri = "https://developers.google.com/oauthplayground"; - private static final String cris_client_id = "APP-X7DMY3AKDXK34RVS"; + private static final String cris_client_id = "APP-X7DMY3AKDXK34RVS"; //PTCRIS private static final String cris_client_secret = "d622a047-deef-4368-a1e8-223101911563"; - private static final String external_client_id = "APP-JFDCD0I82SXO91F9"; + private static final String external_client_id = "APP-JFDCD0I82SXO91F9"; //HASLab, INESC TEC & University of Minho private static final String external_client_secret = "a205bf62-e4b1-4d22-8a4b-2395e493358a"; - private static final String[] profiles = { "0000-0002-4464-361X", - "0000-0002-9007-3574", "0000-0002-5507-2082", "0000-0002-9055-9726" }; + private static final String[] profiles = { "0000-0003-4777-9763", + "0000-0002-1811-9160", "0000-0002-3505-9366", "0000-0002-6134-4419" }; + //ZECA //MANEL //Toze private static final String[] cris_profile_secrets = { - "dd90ad6f-3ec2-4a0a-8762-725f95389b22", - "4161f065-be8a-4736-b550-cde398028128", - "c8962118-bd00-4bd2-8784-8b7bf0c3b84b", - "7421f8d5-3173-4344-994e-e669d991c1d9" }; + "ea00bc47-1541-4824-a439-bf4feee40248", + "118f715f-058b-42ff-96a4-8ae015ca53f3", + "ebe045ed-497c-477f-b41b-5e0dee768857", + "e7e76ead-26e0-4d51-b51d-90a5c4085950" }; private static final String[] external_profile_secrets = { - "ba052ca1-b65b-41d4-969a-bc97a0f67386", - "f0b19290-0acf-4b35-b0c3-9da74d6be805", - "59e45d2f-d7e0-47fa-b6a1-31e0066781f3", - "ac790728-36d6-455d-9469-deb6fbaf0589" }; + "f0c619fe-07f6-4713-bc06-02a5aa66c640", + "70022d8d-4bec-400e-9181-4dca0233ce2a", + "54d08408-146f-4150-a360-ee65a2fd8f90", + "34ac7d34-8b95-48e2-b16c-68af144b7a00" }; /** * Retrieves an ORCID client for a given user profile using the local CRIS diff --git a/src/test/java/pt/ptcris/test/TestHelper.java b/src/test/java/pt/ptcris/test/TestHelper.java index f17c5e0..0d07dab 100644 --- a/src/test/java/pt/ptcris/test/TestHelper.java +++ b/src/test/java/pt/ptcris/test/TestHelper.java @@ -15,23 +15,24 @@ import java.util.logging.Logger; import java.util.logging.SimpleFormatter; +import org.um.dsi.gavea.orcid.model.common.DisambiguatedOrganization; import org.um.dsi.gavea.orcid.model.common.ElementSummary; import org.um.dsi.gavea.orcid.model.common.ExternalId; import org.um.dsi.gavea.orcid.model.common.ExternalIds; +import org.um.dsi.gavea.orcid.model.common.FundingType; import org.um.dsi.gavea.orcid.model.common.FuzzyDate; import org.um.dsi.gavea.orcid.model.common.FuzzyDate.Day; import org.um.dsi.gavea.orcid.model.common.FuzzyDate.Month; -import org.um.dsi.gavea.orcid.model.common.Iso3166Country; -import org.um.dsi.gavea.orcid.model.common.OrganizationAddress; import org.um.dsi.gavea.orcid.model.common.FuzzyDate.Year; +import org.um.dsi.gavea.orcid.model.common.Iso3166Country; import org.um.dsi.gavea.orcid.model.common.Organization; -import org.um.dsi.gavea.orcid.model.common.RelationshipType; +import org.um.dsi.gavea.orcid.model.common.OrganizationAddress; +import org.um.dsi.gavea.orcid.model.common.Relationship; +import org.um.dsi.gavea.orcid.model.common.WorkType; import org.um.dsi.gavea.orcid.model.funding.Funding; import org.um.dsi.gavea.orcid.model.funding.FundingTitle; -import org.um.dsi.gavea.orcid.model.funding.FundingType; import org.um.dsi.gavea.orcid.model.work.Work; import org.um.dsi.gavea.orcid.model.work.WorkTitle; -import org.um.dsi.gavea.orcid.model.work.WorkType; import pt.ptcris.handlers.ProgressHandler; import pt.ptcris.utils.ORCIDHelper; @@ -58,7 +59,7 @@ public static Work work(BigInteger key, String meta) { else work.setType(WorkType.CONFERENCE_PAPER); - FuzzyDate date = new FuzzyDate(new Year("201" + meta.charAt(meta.length()-1)), new Month("03"), new Day("21")); + FuzzyDate date = new FuzzyDate(new Year(Integer.valueOf("201" + meta.charAt(meta.length()-1))), new Month(3), new Day(21)); work.setPublicationDate(date); } @@ -70,7 +71,7 @@ public static Work workDOI(BigInteger key, String meta, String doi) { Work work = work(key, meta); ExternalId e1 = new ExternalId(); - e1.setExternalIdRelationship(RelationshipType.SELF); + e1.setExternalIdRelationship(Relationship.SELF); e1.setExternalIdValue(doi); e1.setExternalIdType("doi"); @@ -83,7 +84,7 @@ public static Work workUnk(BigInteger key, String meta, String doi) { Work work = work(key, meta); ExternalId e1 = new ExternalId(); - e1.setExternalIdRelationship(RelationshipType.SELF); + e1.setExternalIdRelationship(Relationship.SELF); e1.setExternalIdValue(doi); e1.setExternalIdType("ukn"); @@ -96,7 +97,7 @@ public static Work workDOIUnk(BigInteger key, String meta, String doi, String ei Work work = workDOI(key, meta, doi); ExternalId e = new ExternalId(); - e.setExternalIdRelationship(RelationshipType.SELF); + e.setExternalIdRelationship(Relationship.SELF); e.setExternalIdValue(eid); e.setExternalIdType("wosuid-"); @@ -108,14 +109,14 @@ public static Work workOtherOtherDOI(BigInteger key, String meta, String doi, St Work work = workDOI(key, meta, doi); ExternalId e = new ExternalId(); - e.setExternalIdRelationship(RelationshipType.SELF); + e.setExternalIdRelationship(Relationship.SELF); e.setExternalIdValue(eid); e.setExternalIdType("other-id"); work.getExternalIds().getExternalId().add(e); ExternalId e1 = new ExternalId(); - e1.setExternalIdRelationship(RelationshipType.SELF); + e1.setExternalIdRelationship(Relationship.SELF); e1.setExternalIdValue(eid2); e1.setExternalIdType("other-id"); @@ -128,7 +129,7 @@ public static Work workHANDLE(BigInteger key, String meta, String handle) { Work work = work(key, meta); ExternalId e1 = new ExternalId(); - e1.setExternalIdRelationship(RelationshipType.SELF); + e1.setExternalIdRelationship(Relationship.SELF); e1.setExternalIdValue(handle); e1.setExternalIdType("handle"); @@ -136,7 +137,7 @@ public static Work workHANDLE(BigInteger key, String meta, String handle) { // ExternalId e2 = new ExternalId(); -// e2.setExternalIdRelationship(RelationshipType.PART_OF); +// e2.setExternalIdRelationship(Relationship.PART_OF); // e2.setExternalIdValue("11111"); // e2.setExternalIdType("isbn"); // @@ -149,7 +150,7 @@ public static Work workDOIEID(BigInteger key, String meta, String doi, String ei Work work = workDOI(key, meta, doi); ExternalId e = new ExternalId(); - e.setExternalIdRelationship(RelationshipType.SELF); + e.setExternalIdRelationship(Relationship.SELF); e.setExternalIdValue(eid); e.setExternalIdType("eid"); @@ -161,14 +162,14 @@ public static Work workDOIHANDLE(BigInteger key, String meta, String doi, String Work work = workDOI(key, meta, doi); ExternalId e = new ExternalId(); - e.setExternalIdRelationship(RelationshipType.SELF); + e.setExternalIdRelationship(Relationship.SELF); e.setExternalIdValue(handle); e.setExternalIdType("handle"); work.getExternalIds().getExternalId().add(e); ExternalId e2 = new ExternalId(); - e2.setExternalIdRelationship(RelationshipType.PART_OF); + e2.setExternalIdRelationship(Relationship.PART_OF); e2.setExternalIdValue("11111"); e2.setExternalIdType("isbn"); @@ -181,7 +182,7 @@ public static Work workEIDHANDLE(BigInteger key, String meta, String eid, String Work work = workHANDLE(key, meta, handle); ExternalId e = new ExternalId(); - e.setExternalIdRelationship(RelationshipType.SELF); + e.setExternalIdRelationship(Relationship.SELF); e.setExternalIdValue(eid); e.setExternalIdType("eid"); @@ -194,12 +195,12 @@ public static Work workDOIEIDHANDLE(BigInteger key, String meta, String doi, Str Work work = workDOIEID(key, meta, doi, eid); ExternalId e2 = new ExternalId(); - e2.setExternalIdRelationship(RelationshipType.SELF); + e2.setExternalIdRelationship(Relationship.SELF); e2.setExternalIdValue(handle); e2.setExternalIdType("handle"); ExternalId e3 = new ExternalId(); - e3.setExternalIdRelationship(RelationshipType.PART_OF); + e3.setExternalIdRelationship(Relationship.PART_OF); e3.setExternalIdValue("11111"); e3.setExternalIdType("isbn"); work.getExternalIds().getExternalId().add(e3); @@ -213,7 +214,7 @@ public static Work workDOIDOIEIDHANDLE(BigInteger key, String meta, String doi1, Work work = workDOIEIDHANDLE(key, meta, doi1, eid, handle); ExternalId e1 = new ExternalId(); - e1.setExternalIdRelationship(RelationshipType.SELF); + e1.setExternalIdRelationship(Relationship.SELF); e1.setExternalIdValue(doi2); e1.setExternalIdType("doi"); @@ -235,14 +236,14 @@ public static Funding funding(BigInteger key, String meta) { title.setTitle("Meta-data " + meta); work.setTitle(title); - work.setOrganization(new Organization("Agency", new OrganizationAddress("Braga",null,Iso3166Country.PT), null)); + work.setOrganization(new Organization("Fundação para a Ciência e a Tecnologia", new OrganizationAddress("Lisboa",null,Iso3166Country.PT), new DisambiguatedOrganization("112084", "RINGGOLD"))); if (meta.equals("0")) work.setType(FundingType.CONTRACT); else work.setType(FundingType.GRANT); - FuzzyDate date = new FuzzyDate(new Year("201" + meta.charAt(meta.length()-1)), new Month("02"), null); + FuzzyDate date = new FuzzyDate(new Year(Integer.valueOf("201" + meta.charAt(meta.length()-1))), new Month(2), null); work.setStartDate(date); } @@ -254,7 +255,7 @@ public static Funding fundingNmb(BigInteger key, String meta, String doi) { Funding work = funding(key, meta); ExternalId e1 = new ExternalId(); - e1.setExternalIdRelationship(RelationshipType.SELF); + e1.setExternalIdRelationship(Relationship.SELF); e1.setExternalIdValue(doi); e1.setExternalIdType("grant_number"); @@ -267,7 +268,7 @@ public static Funding fundingNmbNmb(BigInteger key, String meta, String doi1, St Funding work = fundingNmb(key, meta, doi1); ExternalId e1 = new ExternalId(); - e1.setExternalIdRelationship(RelationshipType.SELF); + e1.setExternalIdRelationship(Relationship.SELF); e1.setExternalIdValue(doi2); e1.setExternalIdType("grant_number"); @@ -280,13 +281,13 @@ public static Funding fundingNmbNmbNmb(BigInteger key, String meta, String doi1, Funding work = fundingNmbNmb(key, meta, doi1, doi2); ExternalId e1 = new ExternalId(); - e1.setExternalIdRelationship(RelationshipType.SELF); + e1.setExternalIdRelationship(Relationship.SELF); e1.setExternalIdValue(doi3); e1.setExternalIdType("grant_number"); work.getExternalIds().getExternalId().add(e1); ExternalId e3 = new ExternalId(); - e3.setExternalIdRelationship(RelationshipType.PART_OF); + e3.setExternalIdRelationship(Relationship.PART_OF); e3.setExternalIdValue("11111"); e3.setExternalIdType("grant_number"); work.getExternalIds().getExternalId().add(e3); @@ -298,7 +299,7 @@ public static Funding fundingNmbNmbNmbNmb(BigInteger key, String meta, String do Funding work = fundingNmbNmbNmb(key, meta, doi1, doi2, doi3); ExternalId e1 = new ExternalId(); - e1.setExternalIdRelationship(RelationshipType.SELF); + e1.setExternalIdRelationship(Relationship.SELF); e1.setExternalIdValue(doi4); e1.setExternalIdType("grant_number"); @@ -325,13 +326,13 @@ public static Funding fundingIgn(BigInteger key, String meta, String nmb) { if (meta.equals("0")) work.setType(FundingType.AWARD); - FuzzyDate date = new FuzzyDate(new Year("201" + meta.charAt(meta.length()-1)), new Month("02"), null); + FuzzyDate date = new FuzzyDate(new Year(Integer.valueOf("201" + meta.charAt(meta.length()-1))), new Month(2), null); work.setStartDate(date); } ExternalId e1 = new ExternalId(); - e1.setExternalIdRelationship(RelationshipType.SELF); + e1.setExternalIdRelationship(Relationship.SELF); e1.setExternalIdValue(nmb); e1.setExternalIdType("grant_number"); work.getExternalIds().getExternalId().add(e1); diff --git a/src/test/java/pt/ptcris/test/scenarios/Scenario.java b/src/test/java/pt/ptcris/test/scenarios/Scenario.java index 6dece5d..747fbd7 100644 --- a/src/test/java/pt/ptcris/test/scenarios/Scenario.java +++ b/src/test/java/pt/ptcris/test/scenarios/Scenario.java @@ -9,7 +9,8 @@ */ package pt.ptcris.test.scenarios; -import static org.junit.Assert.*; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; import java.math.BigInteger; import java.util.ArrayList; @@ -25,9 +26,9 @@ import org.junit.Test; import org.um.dsi.gavea.orcid.client.exception.OrcidClientException; import org.um.dsi.gavea.orcid.model.activities.WorkGroup; +import org.um.dsi.gavea.orcid.model.common.WorkType; import org.um.dsi.gavea.orcid.model.work.Work; import org.um.dsi.gavea.orcid.model.work.WorkSummary; -import org.um.dsi.gavea.orcid.model.work.WorkType; import pt.ptcris.PTCRISync; import pt.ptcris.PTCRISyncResult; diff --git a/src/test/java/pt/ptcris/test/scenarios/ScenarioFunding.java b/src/test/java/pt/ptcris/test/scenarios/ScenarioFunding.java index e0f2075..8dec078 100644 --- a/src/test/java/pt/ptcris/test/scenarios/ScenarioFunding.java +++ b/src/test/java/pt/ptcris/test/scenarios/ScenarioFunding.java @@ -9,7 +9,8 @@ */ package pt.ptcris.test.scenarios; -import static org.junit.Assert.*; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; import java.math.BigInteger; import java.util.ArrayList; @@ -26,9 +27,9 @@ import org.junit.Test; import org.um.dsi.gavea.orcid.client.exception.OrcidClientException; import org.um.dsi.gavea.orcid.model.activities.FundingGroup; +import org.um.dsi.gavea.orcid.model.common.FundingType; import org.um.dsi.gavea.orcid.model.funding.Funding; import org.um.dsi.gavea.orcid.model.funding.FundingSummary; -import org.um.dsi.gavea.orcid.model.funding.FundingType; import pt.ptcris.PTCRISync; import pt.ptcris.PTCRISyncResult;