Skip to content

Commit

Permalink
Merge branch 'develop' into fdias-2446-respect-limits-for-shapefile-p…
Browse files Browse the repository at this point in the history
…rocessing
  • Loading branch information
diasf authored Apr 25, 2024
2 parents 0874946 + c482a8a commit 0160c14
Show file tree
Hide file tree
Showing 70 changed files with 827 additions and 333 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,9 @@ public class AuthenticatedUser implements User, Serializable, JpaEntity<Long> {
@NotNull
@Column(nullable = false, unique = true)
private String email;
private String orcid;
private String affiliation;
private String affiliationROR;
private String position;

@NotBlank(message = "{user.lastName}")
Expand Down Expand Up @@ -148,10 +150,18 @@ public String getEmail() {
return email;
}

public String getOrcid() {
return orcid;
}

public String getAffiliation() {
return affiliation;
}

public String getAffiliationROR() {
return affiliationROR;
}

public String getPosition() {
return position;
}
Expand Down Expand Up @@ -214,7 +224,7 @@ public String getIdentifier() {

@Override
public AuthenticatedUserDisplayInfo getDisplayInfo() {
return new AuthenticatedUserDisplayInfo(firstName, lastName, email, affiliation, position);
return new AuthenticatedUserDisplayInfo(firstName, lastName, email, orcid, affiliation, affiliationROR, position);
}

/**
Expand All @@ -233,6 +243,12 @@ public void applyDisplayInfo(AuthenticatedUserDisplayInfo inf) {
if (StringUtils.isNotBlank(inf.getPosition())) {
setPosition(inf.getPosition());
}
if (StringUtils.isNotBlank(inf.getOrcid())) {
setOrcid(inf.getOrcid());
}
if (StringUtils.isNotBlank(inf.getAffiliationROR())) {
setAffiliationROR(inf.getAffiliationROR());
}
}

@Override
Expand All @@ -248,12 +264,6 @@ public String getSortByString() {
return String.format("%s %s %s", getLastName(), getFirstName(), getUserIdentifier());
}

public String getOrcidId() {
String authProviderId = getAuthenticatedUserLookup().getAuthenticationProviderId();
return AuthenticatedUserLookup.ORCID_PROVIDER_ID_PRODUCTION.equals(authProviderId)
? getAuthenticatedUserLookup().getPersistentUserId() : null;
}

// -------------------- SETTERS --------------------

public void setDatasetLocks(List<DatasetLock> datasetLocks) {
Expand All @@ -277,10 +287,18 @@ public void setEmail(String email) {
this.email = email.trim();
}

public void setOrcid(String orcid) {
this.orcid = orcid;
}

public void setAffiliation(String affiliation) {
this.affiliation = affiliation;
}

public void setAffiliationROR(String affiliationROR) {
this.affiliationROR = affiliationROR;
}

public void setPosition(String position) {
this.position = position;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,35 @@ public class AuthenticatedUserDisplayInfo extends RoleAssigneeDisplayInfo {
@NotBlank(message = "{user.firstName}")
private String firstName;
private String position;
private String orcid;

/*
* @todo Shouldn't we persist the displayName too? It still exists on the
* authenticateduser table.
*/
public AuthenticatedUserDisplayInfo(String firstName, String lastName, String emailAddress, String affiliation, String position) {
super(firstName + " " + lastName, emailAddress, affiliation);
public AuthenticatedUserDisplayInfo(String firstName, String lastName, String emailAddress,
String affiliation, String position) {
super(firstName + " " + lastName, emailAddress, affiliation, null);
this.firstName = firstName;
this.lastName = lastName;
this.position = position;
}

public AuthenticatedUserDisplayInfo(String firstName, String lastName, String emailAddress, String orcid,
String affiliation, String affiliationROR, String position) {
super(firstName + " " + lastName, emailAddress, affiliation, affiliationROR);
this.firstName = firstName;
this.lastName = lastName;
this.position = position;
this.orcid = orcid;
}

public AuthenticatedUserDisplayInfo() {
super("", "", "");
super("", "", "", "");
firstName = "";
lastName = "";
position = "";
orcid = "";
}


Expand All @@ -40,7 +52,8 @@ public AuthenticatedUserDisplayInfo() {
* @param src the display info {@code this} will be a copy of.
*/
public AuthenticatedUserDisplayInfo(AuthenticatedUserDisplayInfo src) {
this(src.getFirstName(), src.getLastName(), src.getEmailAddress(), src.getAffiliation(), src.getPosition());
this(src.getFirstName(), src.getLastName(), src.getEmailAddress(), src.getOrcid(), src.getAffiliation(),
src.getAffiliationROR(), src.getPosition());
}

public String getLastName() {
Expand All @@ -67,9 +80,18 @@ public void setPosition(String position) {
this.position = position;
}

public String getOrcid() {
return orcid;
}

public void setOrcid(String orcid) {
this.orcid = orcid;
}

@Override
public String toString() {
return "AuthenticatedUserDisplayInfo{firstName=" + firstName + ", lastName=" + lastName + ", position=" + position + ", email=" + getEmailAddress() + '}';
return "AuthenticatedUserDisplayInfo{firstName=" + firstName + ", lastName=" + lastName +
", position=" + position + ", email=" + getEmailAddress() + ", orcid=" + getOrcid() + '}';
}

@Override
Expand Down Expand Up @@ -97,7 +119,7 @@ public boolean equals(Object obj) {
if (!Objects.equals(this.firstName, other.firstName)) {
return false;
}
return Objects.equals(this.position, other.position) && super.equals(obj);
return Objects.equals(this.position, other.position) && Objects.equals(this.orcid, other.orcid) && super.equals(obj);
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,17 @@ public class RoleAssigneeDisplayInfo implements java.io.Serializable {
private String title;
private String emailAddress;
private String affiliation;
private String affiliationROR;

public RoleAssigneeDisplayInfo(String title, String emailAddress) {
this(title, emailAddress, null);
this(title, emailAddress, null, null);
}

public RoleAssigneeDisplayInfo(String title, String emailAddress, String anAffiliation) {
public RoleAssigneeDisplayInfo(String title, String emailAddress, String anAffiliation, String affiliationROR) {
this.title = title;
this.emailAddress = emailAddress;
affiliation = anAffiliation;
this.affiliation = anAffiliation;
this.affiliationROR = affiliationROR;
}

public String getTitle() {
Expand All @@ -36,6 +38,10 @@ public String getAffiliation() {
return affiliation;
}

public String getAffiliationROR() {
return affiliationROR;
}

public void setTitle(String title) {
this.title = title;
}
Expand All @@ -48,9 +54,14 @@ public void setAffiliation(String affiliation) {
this.affiliation = affiliation;
}

public void setAffiliationROR(String affiliationROR) {
this.affiliationROR = affiliationROR;
}

@Override
public String toString() {
return "RoleAssigneeDisplayInfo{" + "title=" + title + ", emailAddress=" + emailAddress + ", affiliation=" + affiliation + '}';
return "RoleAssigneeDisplayInfo{" + "title=" + title + ", emailAddress=" + emailAddress +
", affiliation=" + affiliation + ", affiliationROR=" + affiliationROR + '}';
}

@Override
Expand Down Expand Up @@ -78,7 +89,8 @@ public boolean equals(Object obj) {
if (!Objects.equals(this.emailAddress, other.emailAddress)) {
return false;
}
return Objects.equals(this.affiliation, other.affiliation);
return Objects.equals(this.affiliation, other.affiliation)
&& Objects.equals(this.affiliationROR, other.affiliationROR);
}

}
10 changes: 10 additions & 0 deletions dataverse-persistence/src/main/resources/Bundle_en.properties
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,17 @@ user.lastName=Family Name
user.lastName.tip=The last name you would like to use for this account.
user.email.tip=A valid email address you have access to in order to be contacted.
user.email.taken=This email address is already taken.
user.orcid=ORCID
user.orcid.tip=ORCID is an open digital identifier allowing distinction between researchers having the same or similar name and surname.
user.orcid.invalid.format=Invalid ORCID format.
user.orcid.invalid.checksum=Invalid ORCID checksum.
user.affiliation.tip=The organization with which you are affiliated.
user.affiliationror=Affiliation ROR
user.affiliationror.tip=ROR identifier of the affiliating institution. The identifier must be provided in its URL form, for instance "https://ror.org/039bjqg32" for the University of Warsaw. You can also enter the name of the institution and select its ROR ID from the list.
user.affiliationror.suggestionDisplay.valueHeader=ROR
user.affiliationror.suggestionDisplay.detailsHeader=Institution
user.affiliationror.ror.invalid.format=Invalid ROR format.
user.affiliationror.ror.invalid.checksum=Invalid ROR checksum.
user.position=Position
user.position.tip=Your role or title at the organization you are affiliated with; such as staff, faculty, student, etc.
user.notificationsLanguage=E-mail notifications language
Expand Down
10 changes: 10 additions & 0 deletions dataverse-persistence/src/main/resources/Bundle_pl.properties
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,17 @@ user.lastName=Nazwisko
user.lastName.tip=Nazwisko, kt\u00F3re chcesz u\u017Cy\u0107 dla tego konta.
user.email.tip=Aktualny adres e-mail, do kt\u00F3rego posiadasz dost\u0119p i kt\u00F3rego mo\u017Cna u\u017Cy\u0107, by si\u0119 z Tob\u0105 skontaktowa\u0107.
user.email.taken=Ten adres e-mail jest ju\u017C przypisany do innego konta.
user.orcid=ORCID
user.orcid.tip=ORCID to otwarty identyfikator cyfrowy umo\u017Cliwiaj\u0105cy rozr\u00F3\u017Cnienie naukowc\u00F3w o tym samym lub podobnym imieniu i nazwisku.
user.orcid.invalid.format=Nieprawid\u0142owo zbudowany identyfikator.
user.orcid.invalid.checksum=Nieprawid\u0142owy identyfikator.
user.affiliation.tip=Instytucja przy kt\u00F3rej jeste\u015B afiliowana/afiliowany.
user.affiliationror=ROR instytucji afiliuj\u0105cej
user.affiliationror.tip=Identyfikator ROR instytucji afiliuj\u0105cej. Identyfikator musi zosta\u0107 podany w formie adresu URL, np. "https://ror.org/039bjqg32" dla Uniwersytetu Warszawskiego. W to pole mo\u017Cesz r\u00F3wnie\u017C wprowadzi\u0107 nazw\u0119 instytucji i wybra\u0107 jej identyfikator ROR z listy.
user.affiliationror.suggestionDisplay.valueHeader=ROR
user.affiliationror.suggestionDisplay.detailsHeader=Instytucja
user.affiliationror.ror.invalid.format=Nieprawid\u0142owo zbudowany identyfikator ROR.
user.affiliationror.ror.invalid.checksum=Nieprawid\u0142owy identyfikator ROR.
user.position=Stanowisko
user.position.tip=Stanowisko lub rola jak\u0105 pe\u0142nisz w instytucji, przy kt\u00F3rej jeste\u015B afiliowana/afiliowany, na przyk\u0142ad "pracownik naukowy", "student", "pracownik administracyjny" itp.
user.notificationsLanguage=J\u0119zyk powiadomie\u0144 e-mailowych
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ALTER TABLE authenticateduser ADD COLUMN orcid TEXT, ADD COLUMN affiliationror TEXT;
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,24 @@ public void testGetIdentifier() {
@Test
public void testApplyDisplayInfo() {
System.out.println("applyDisplayInfo");
AuthenticatedUserDisplayInfo inf = new AuthenticatedUserDisplayInfo("Homer", "Simpson", "[email protected]", "UnitTester", "In-Memory user");
AuthenticatedUserDisplayInfo inf = new AuthenticatedUserDisplayInfo("Homer", "Simpson", "[email protected]",
"0000-0001-2345-6789", "UnitTester", "https://ror.org/04k0tth05", "In-Memory user");
testUser.applyDisplayInfo(inf);
assertEquals(inf, testUser.getDisplayInfo());
}

@Test
public void testGetDisplayInfo() {
System.out.println("getDisplayInfo");
AuthenticatedUserDisplayInfo expResult = new AuthenticatedUserDisplayInfo("Homer", "Simpson", "[email protected]", "UnitTester", "In-Memory user");
// given
testUser.setOrcid("0000-0001-2345-6789");
testUser.setAffiliationROR("https://ror.org/04k0tth05");
AuthenticatedUserDisplayInfo expResult = new AuthenticatedUserDisplayInfo("Homer", "Simpson", "[email protected]",
"0000-0001-2345-6789", "UnitTester", "https://ror.org/04k0tth05", "In-Memory user");
// when
AuthenticatedUserDisplayInfo result = testUser.getDisplayInfo();

// then
assertEquals(expResult, result);

}
Expand Down
12 changes: 12 additions & 0 deletions dataverse-webapp/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>fluent-hc</artifactId>
<exclusions>
<exclusion>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
Expand Down Expand Up @@ -431,6 +437,12 @@
<groupId>com.onelogin</groupId>
<artifactId>java-saml</artifactId>
<version>2.8.0</version>
<exclusions>
<exclusion>
<groupId>org.apache.santuario</groupId>
<artifactId>xmlsec</artifactId>
</exclusion>
</exclusions>
</dependency>

<!-- OpenID Connect library -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import edu.harvard.iq.dataverse.settings.SettingsServiceBean;
import edu.harvard.iq.dataverse.util.SystemConfig;
import edu.harvard.iq.dataverse.validation.DatasetFieldValidationService;
import edu.harvard.iq.dataverse.validation.field.ValidationResult;
import edu.harvard.iq.dataverse.validation.field.FieldValidationResult;
import org.swordapp.server.AuthCredentials;
import org.swordapp.server.Deposit;
import org.swordapp.server.DepositReceipt;
Expand Down Expand Up @@ -322,10 +322,10 @@ DepositReceipt replaceOrAddFiles(String uri, Deposit deposit, AuthCredentials au
throw new SwordError(UriRegistry.ERROR_BAD_REQUEST, "Unable to add file(s) to dataset: Unknown error");
}
if (!dataFiles.isEmpty()) {
List<ValidationResult> validationResults = fieldValidationService.validateFieldsOfDatasetVersion(editVersion);
List<FieldValidationResult> fieldValidationResults = fieldValidationService.validateFieldsOfDatasetVersion(editVersion);
Set<ConstraintViolation<FileMetadata>> constraintViolations = editVersion.validateFileMetadata();
if (!validationResults.isEmpty()) {
ValidationResult firstError = validationResults.get(0);
if (!fieldValidationResults.isEmpty()) {
FieldValidationResult firstError = fieldValidationResults.get(0);
throw new SwordError(UriRegistry.ERROR_BAD_REQUEST,
String.format("Unable to add file(s) to dataset: %s The invalid value was \"%s\".", firstError.getMessage(), firstError.getField().getSingleValue()));
} else if (!constraintViolations.isEmpty()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import edu.harvard.iq.dataverse.search.index.IndexServiceBean;
import edu.harvard.iq.dataverse.util.json.JsonParseException;
import edu.harvard.iq.dataverse.validation.DatasetFieldValidationService;
import edu.harvard.iq.dataverse.validation.field.ValidationResult;
import edu.harvard.iq.dataverse.validation.field.FieldValidationResult;
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang.StringUtils;

Expand Down Expand Up @@ -137,10 +137,10 @@ public Dataset doImportHarvestedDataset(DataverseRequest dataverseRequest, Harve

// Check data against validation contraints
DatasetVersion versionToValidate = ds.getVersions().get(0);
List<ValidationResult> validationResults = fieldValidationService.validateFieldsOfDatasetVersion(versionToValidate);
if (!validationResults.isEmpty()) {
List<FieldValidationResult> fieldValidationResults = fieldValidationService.validateFieldsOfDatasetVersion(versionToValidate);
if (!fieldValidationResults.isEmpty()) {
// For migration and harvest, add NA for missing required values
validationResults.forEach(r -> ((DatasetField) r.getField()).setFieldValue(DatasetField.NA_VALUE));
fieldValidationResults.forEach(r -> ((DatasetField) r.getField()).setFieldValue(DatasetField.NA_VALUE));
}

// A Global ID is required, in order for us to be able to harvest and import
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ public enum EditableAccountField {
FAMILY_NAME,
EMAIL,
AFFILIATION,
AFFILIATION_ROR,
POSITION,
NOTIFICATIONS_LANG
NOTIFICATIONS_LANG,
ORCID
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ public static Set<EditableAccountField> createAllFieldsSet() {

public static Set<EditableAccountField> createSecondaryFieldsSet() {
return Collections.unmodifiableSet(
Stream.of(EditableAccountField.AFFILIATION, EditableAccountField.POSITION, EditableAccountField.NOTIFICATIONS_LANG)
Stream.of(EditableAccountField.AFFILIATION, EditableAccountField.POSITION, EditableAccountField.NOTIFICATIONS_LANG,
EditableAccountField.ORCID, EditableAccountField.AFFILIATION_ROR)
.collect(Collectors.toSet()));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import edu.harvard.iq.dataverse.authorization.AuthenticationServiceBean;
import edu.harvard.iq.dataverse.authorization.EditableAccountField;
import edu.harvard.iq.dataverse.authorization.UserRecordIdentifier;
import edu.harvard.iq.dataverse.authorization.providers.common.BaseUserPage;
import edu.harvard.iq.dataverse.authorization.providers.shib.ShibAuthenticationProvider;
import edu.harvard.iq.dataverse.common.BundleUtil;
import edu.harvard.iq.dataverse.consent.ConsentDto;
Expand Down Expand Up @@ -60,7 +61,7 @@

@ViewScoped
@Named("DataverseUserPage")
public class DataverseUserPage implements java.io.Serializable {
public class DataverseUserPage extends BaseUserPage {

private static final Logger logger = Logger.getLogger(DataverseUserPage.class.getCanonicalName());

Expand Down
Loading

0 comments on commit 0160c14

Please sign in to comment.