Skip to content

Commit

Permalink
merge reverted
Browse files Browse the repository at this point in the history
  • Loading branch information
nmacedo committed Nov 3, 2016
1 parent 1d2e4bc commit 6f03716
Show file tree
Hide file tree
Showing 7 changed files with 74 additions and 97 deletions.
57 changes: 29 additions & 28 deletions src/test/java/pt/ptcris/test/PTCRISExample.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,11 @@
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.ExternalIdentifier;
import org.um.dsi.gavea.orcid.model.work.ExternalIdentifierType;
import org.um.dsi.gavea.orcid.model.work.Work;
import org.um.dsi.gavea.orcid.model.work.WorkExternalIdentifiers;
import org.um.dsi.gavea.orcid.model.work.WorkTitle;
import org.um.dsi.gavea.orcid.model.work.WorkType;

Expand Down Expand Up @@ -90,16 +91,16 @@ private static Work work0() {
title.setTitle("Yet Another Work Updated Once");
work.setTitle(title);

ExternalId e = new ExternalId();
e.setExternalIdRelationship(RelationshipType.SELF);
e.setExternalIdValue("3000");
e.setExternalIdType("DOI");
ExternalIdentifier e = new ExternalIdentifier();
e.setRelationship(RelationshipType.SELF);
e.setExternalIdentifierId("3000");
e.setExternalIdentifierType(ExternalIdentifierType.DOI);

ExternalIds uids = new ExternalIds();
WorkExternalIdentifiers uids = new WorkExternalIdentifiers();

uids.getExternalId().add(e);
uids.getWorkExternalIdentifier().add(e);

work.setExternalIds(uids);
work.setExternalIdentifiers(uids);

work.setType(WorkType.CONFERENCE_PAPER);

Expand All @@ -112,22 +113,22 @@ private static Work work1() {
title.setTitle("A Work Updated Once");
work.setTitle(title);

ExternalId e = new ExternalId();
e.setExternalIdRelationship(RelationshipType.SELF);
e.setExternalIdValue("4000");
e.setExternalIdType("EID");
ExternalIdentifier e = new ExternalIdentifier();
e.setRelationship(RelationshipType.SELF);
e.setExternalIdentifierId("4000");
e.setExternalIdentifierType(ExternalIdentifierType.EID);

ExternalId e1 = new ExternalId();
e1.setExternalIdRelationship(RelationshipType.SELF);
e1.setExternalIdValue("00001");
e1.setExternalIdType("DOI");
ExternalIdentifier e1 = new ExternalIdentifier();
e1.setRelationship(RelationshipType.SELF);
e1.setExternalIdentifierId("00001");
e1.setExternalIdentifierType(ExternalIdentifierType.DOI);

ExternalIds uids = new ExternalIds();
WorkExternalIdentifiers uids = new WorkExternalIdentifiers();

uids.getExternalId().add(e);
uids.getExternalId().add(e1);
uids.getWorkExternalIdentifier().add(e);
uids.getWorkExternalIdentifier().add(e1);

work.setExternalIds(uids);
work.setExternalIdentifiers(uids);

work.setType(WorkType.CONFERENCE_PAPER);

Expand All @@ -140,18 +141,18 @@ private static Work work2() {
title.setTitle("Another Work Updated Twice");
work.setTitle(title);

ExternalId e = new ExternalId();
e.setExternalIdRelationship(RelationshipType.SELF);
ExternalIdentifier e = new ExternalIdentifier();
e.setRelationship(RelationshipType.SELF);
// avoids conflicts
e.setExternalIdValue(String.valueOf(System.currentTimeMillis()));
e.setExternalIdentifierId(String.valueOf(System.currentTimeMillis()));

e.setExternalIdType("DOI");
e.setExternalIdentifierType(ExternalIdentifierType.DOI);

ExternalIds uids = new ExternalIds();
WorkExternalIdentifiers uids = new WorkExternalIdentifiers();

uids.getExternalId().add(e);
uids.getWorkExternalIdentifier().add(e);

work.setExternalIds(uids);
work.setExternalIdentifiers(uids);

work.setType(WorkType.JOURNAL_ARTICLE);

Expand Down
104 changes: 40 additions & 64 deletions src/test/java/pt/ptcris/test/TestHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@
import java.util.logging.Logger;
import java.util.logging.SimpleFormatter;

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.Year;
import org.um.dsi.gavea.orcid.model.common.RelationshipType;
import org.um.dsi.gavea.orcid.model.work.ExternalIdentifier;
import org.um.dsi.gavea.orcid.model.work.ExternalIdentifierType;
import org.um.dsi.gavea.orcid.model.work.Work;
import org.um.dsi.gavea.orcid.model.work.WorkExternalIdentifiers;
import org.um.dsi.gavea.orcid.model.work.WorkTitle;
import org.um.dsi.gavea.orcid.model.work.WorkType;

Expand All @@ -25,8 +26,8 @@ public class TestHelper {
public static Work work(BigInteger key, String meta) {
Work work = new Work();

ExternalIds uids = new ExternalIds();
work.setExternalIds(uids);
WorkExternalIdentifiers uids = new WorkExternalIdentifiers();
work.setExternalIdentifiers(uids);

work.setPutCode(key);

Expand All @@ -50,114 +51,89 @@ public static Work work(BigInteger key, String meta) {
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");
ExternalIdentifier e1 = new ExternalIdentifier();
e1.setRelationship(RelationshipType.SELF);
e1.setExternalIdentifierId(doi);
e1.setExternalIdentifierType(ExternalIdentifierType.DOI);

work.getExternalIds().getExternalId().add(e1);
work.getExternalIdentifiers().getWorkExternalIdentifier().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 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");
ExternalIdentifier e1 = new ExternalIdentifier();
e1.setRelationship(RelationshipType.SELF);
e1.setExternalIdentifierId(handle);
e1.setExternalIdentifierType(ExternalIdentifierType.HANDLE);

work.getExternalIds().getExternalId().add(e1);
work.getExternalIdentifiers().getWorkExternalIdentifier().add(e1);

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");
ExternalIdentifier e = new ExternalIdentifier();
e.setRelationship(RelationshipType.SELF);
e.setExternalIdentifierId(eid);
e.setExternalIdentifierType(ExternalIdentifierType.EID);

work.getExternalIds().getExternalId().add(e);
work.getExternalIdentifiers().getWorkExternalIdentifier().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");
ExternalIdentifier e = new ExternalIdentifier();
e.setRelationship(RelationshipType.SELF);
e.setExternalIdentifierId(handle);
e.setExternalIdentifierType(ExternalIdentifierType.HANDLE);

work.getExternalIds().getExternalId().add(e);
work.getExternalIdentifiers().getWorkExternalIdentifier().add(e);

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");
ExternalIdentifier e = new ExternalIdentifier();
e.setRelationship(RelationshipType.SELF);
e.setExternalIdentifierId(eid);
e.setExternalIdentifierType(ExternalIdentifierType.EID);

work.getExternalIds().getExternalId().add(e);
work.getExternalIdentifiers().getWorkExternalIdentifier().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");
ExternalIdentifier e2 = new ExternalIdentifier();
e2.setRelationship(RelationshipType.SELF);
e2.setExternalIdentifierId(handle);
e2.setExternalIdentifierType(ExternalIdentifierType.HANDLE);

work.getExternalIds().getExternalId().add(e2);
work.getExternalIdentifiers().getWorkExternalIdentifier().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");
ExternalIdentifier e1 = new ExternalIdentifier();
e1.setRelationship(RelationshipType.SELF);
e1.setExternalIdentifierId(doi2);
e1.setExternalIdentifierType(ExternalIdentifierType.DOI);

work.getExternalIds().getExternalId().add(e1);
work.getExternalIdentifiers().getWorkExternalIdentifier().add(e1);

return work;
}
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/pt/ptcris/test/scenarios/Scenario01.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ List<Work> expectedImportedInvalidWorks() {
@Override
Set<String> expectedInvalidCodes(BigInteger putCode) {
Set<String> res = new HashSet<String>();
res.add(ORCIDHelper.INVALID_EXTERNALIDENTIFIERS);
res.add(ORCIDHelper.INVALID_WORKEXTERNALIDENTIFIERS);
return res;
}

Expand Down
2 changes: 1 addition & 1 deletion src/test/java/pt/ptcris/test/scenarios/Scenario02.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ List<Work> expectedImportedInvalidWorks() {
@Override
Set<String> expectedInvalidCodes(BigInteger putCode) {
Set<String> res = new HashSet<String>();
res.add(ORCIDHelper.INVALID_EXTERNALIDENTIFIERS);
res.add(ORCIDHelper.INVALID_WORKEXTERNALIDENTIFIERS);
return res;
}

Expand Down
2 changes: 1 addition & 1 deletion src/test/java/pt/ptcris/test/scenarios/Scenario03.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ List<Work> expectedImportedInvalidWorks() {
@Override
Set<String> expectedInvalidCodes(BigInteger putCode) {
Set<String> res = new HashSet<String>();
res.add(ORCIDHelper.INVALID_EXTERNALIDENTIFIERS);
res.add(ORCIDHelper.INVALID_WORKEXTERNALIDENTIFIERS);
return res;
}

Expand Down
2 changes: 1 addition & 1 deletion src/test/java/pt/ptcris/test/scenarios/Scenario15.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ List<Work> expectedImportedInvalidWorks() {
@Override
Set<String> expectedInvalidCodes(BigInteger putCode) {
Set<String> res = new HashSet<String>();
res.add(ORCIDHelper.INVALID_EXTERNALIDENTIFIERS);
res.add(ORCIDHelper.INVALID_WORKEXTERNALIDENTIFIERS);
return res;
}

Expand Down
2 changes: 1 addition & 1 deletion src/test/java/pt/ptcris/test/scenarios/Scenario16.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ List<Work> expectedImportedInvalidWorks() {
@Override
Set<String> expectedInvalidCodes(BigInteger putCode) {
Set<String> res = new HashSet<String>();
res.add(ORCIDHelper.INVALID_EXTERNALIDENTIFIERS);
res.add(ORCIDHelper.INVALID_WORKEXTERNALIDENTIFIERS);
return res;
}

Expand Down

0 comments on commit 6f03716

Please sign in to comment.