diff --git a/common/src/pandas/collection/Permission.java b/common/src/pandas/collection/Permission.java
index d2fdb739..937d3a63 100644
--- a/common/src/pandas/collection/Permission.java
+++ b/common/src/pandas/collection/Permission.java
@@ -4,6 +4,7 @@
import pandas.core.Individual;
import java.time.Instant;
+import java.util.Objects;
/**
* Information about whether the publisher of a title has granted or denied access to archived versions of that title,
@@ -212,4 +213,19 @@ public boolean isDenied() {
public boolean isUnknown() {
return hasState(PermissionState.UNKNOWN);
}
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+
+ Permission that = (Permission) o;
+
+ return Objects.equals(id, that.id);
+ }
+
+ @Override
+ public int hashCode() {
+ return id != null ? id.hashCode() : 0;
+ }
}
diff --git a/common/src/pandas/collection/TitleEditForm.java b/common/src/pandas/collection/TitleEditForm.java
index bf770ba2..01b3b0a6 100644
--- a/common/src/pandas/collection/TitleEditForm.java
+++ b/common/src/pandas/collection/TitleEditForm.java
@@ -6,11 +6,7 @@
import pandas.gather.*;
import java.time.*;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Set;
-import java.util.TreeSet;
-import java.util.stream.Collectors;
+import java.util.*;
import static pandas.util.Strings.emptyToNull;
@@ -42,7 +38,6 @@ public class TitleEditForm {
private String filters;
private Status status;
private Reason reason;
- private boolean legalDeposit = true;
private boolean unableToArchive;
private boolean disappeared;
@@ -55,6 +50,16 @@ public class TitleEditForm {
private Title continues;
private Set
continuesTitles = new TreeSet<>(Title.COMPARE_BY_NAME);
private Set continuedByTitles = new TreeSet<>(Title.COMPARE_BY_NAME);
+ private PermissionTypeRadio permissionType;
+ private String permissionState;
+ private String permissionLocalReference;
+ @DateTimeFormat(iso = DateTimeFormat.ISO.DATE)
+ private LocalDate permissionStatusSetDate;
+ private String permissionNote;
+
+ enum PermissionTypeRadio {
+ LEGAL_DEPOSIT, TITLE, PUBLISHER
+ }
public TitleEditForm() {}
@@ -67,7 +72,6 @@ public TitleEditForm(Title title) {
setDisappeared(title.isDisappeared());
setFormat(title.getFormat());
setId(title.getId());
- setLegalDeposit(title.getLegalDeposit());
setLocalDatabaseNo(title.getLocalDatabaseNo());
setLocalReference(title.getLocalReference());
setName(title.getName());
@@ -104,6 +108,23 @@ public TitleEditForm(Title title) {
setSeedUrls(getSeedUrls() + "\n" + gather.getAdditionalUrls());
}
}
+
+ if (title.getLegalDeposit()) {
+ permissionType = PermissionTypeRadio.LEGAL_DEPOSIT;
+ } else if (Objects.equals(title.getPermission(), title.getDefaultPermission())) {
+ permissionType = PermissionTypeRadio.TITLE;
+ } else {
+ permissionType = PermissionTypeRadio.PUBLISHER;
+ }
+
+ Permission permission = title.getDefaultPermission();
+ if (permission != null) {
+ permissionState = permission.getStateName();
+ permissionLocalReference = permission.getLocalReference();
+ permissionStatusSetDate = permission.getStatusSetDate().atZone(ZoneId.systemDefault()).toLocalDate();
+ permissionNote = permission.getNote();
+ }
+ if (permissionState == null) permissionState = "Unknown";
}
public Instant getScheduledInstant() {
@@ -253,14 +274,6 @@ public void setOneoffDates(List oneoffDates) {
this.oneoffDates = oneoffDates;
}
- public Boolean getLegalDeposit() {
- return legalDeposit;
- }
-
- public void setLegalDeposit(Boolean legalDeposit) {
- this.legalDeposit = legalDeposit;
- }
-
public Publisher getPublisher() {
return publisher;
}
@@ -382,4 +395,53 @@ public void setContinuedByTitles(Set continuedByTitles) {
this.continuedByTitles.clear();
this.continuedByTitles.addAll(continuedByTitles);
}
+
+ public String getPermissionState() {
+ return permissionState;
+ }
+
+ public TitleEditForm setPermissionState(String permissionState) {
+ this.permissionState = permissionState;
+ return this;
+ }
+
+ public LocalDate getPermissionStatusSetDate() {
+ return permissionStatusSetDate;
+ }
+ public Instant getPermissionStatusSetInstant() {
+ if (permissionStatusSetDate == null) return null;
+ return permissionStatusSetDate.atStartOfDay(ZoneId.systemDefault()).toInstant();
+ }
+
+ public TitleEditForm setPermissionStatusSetDate(LocalDate permissionStatusSetDate) {
+ this.permissionStatusSetDate = permissionStatusSetDate;
+ return this;
+ }
+
+ public String getPermissionLocalReference() {
+ return permissionLocalReference;
+ }
+
+ public TitleEditForm setPermissionLocalReference(String permissionLocalReference) {
+ this.permissionLocalReference = permissionLocalReference;
+ return this;
+ }
+
+ public String getPermissionNote() {
+ return permissionNote;
+ }
+
+ public TitleEditForm setPermissionNote(String permissionNote) {
+ this.permissionNote = permissionNote;
+ return this;
+ }
+
+ public PermissionTypeRadio getPermissionType() {
+ return permissionType;
+ }
+
+ public TitleEditForm setPermissionType(PermissionTypeRadio permissionType) {
+ this.permissionType = permissionType;
+ return this;
+ }
}
diff --git a/common/src/pandas/collection/TitleService.java b/common/src/pandas/collection/TitleService.java
index 6790b94a..290d3f8e 100644
--- a/common/src/pandas/collection/TitleService.java
+++ b/common/src/pandas/collection/TitleService.java
@@ -87,7 +87,7 @@ public TitleEditForm newTitleForm(Set collections, Set subj
form.setScope(scopeRepository.findById(Scope.DEFAULT_ID).orElse(null));
form.setStatus(statusRepository.findById(Status.SELECTED_ID).orElseThrow());
form.setSubjects(subjects);
- form.setLegalDeposit(true);
+ form.setPermissionType(TitleEditForm.PermissionTypeRadio.LEGAL_DEPOSIT);
form.setCataloguingNotRequired(true);
return form;
}
@@ -107,7 +107,7 @@ public Title save(TitleEditForm form, User user) {
title.setContinuesTitles(form.getContinuesTitles());
title.setDisappeared(form.isDisappeared());
title.setFormat(form.getFormat() == null ? formatRepository.findById(Format.DEFAULT_ID).orElseThrow() : form.getFormat());
- title.setLegalDeposit(form.getLegalDeposit());
+ title.setLegalDeposit(form.getPermissionType() == TitleEditForm.PermissionTypeRadio.LEGAL_DEPOSIT);
title.setLocalDatabaseNo(Strings.emptyToNull(form.getLocalDatabaseNo()));
title.setLocalReference(Strings.emptyToNull(form.getLocalReference()));
title.setName(form.getName().trim());
@@ -188,6 +188,15 @@ public Title save(TitleEditForm form, User user) {
title.setPermission(permission);
}
+ if (form.getPermissionType() == TitleEditForm.PermissionTypeRadio.TITLE) {
+ Permission permission = title.getDefaultPermission();
+ permission.setStateName(form.getPermissionState());
+ permission.setNote(form.getPermissionNote());
+ permission.setLocalReference(form.getPermissionLocalReference());
+ permission.setStatusSetDate(form.getPermissionStatusSetInstant());
+ title.setPermission(permission);
+ }
+
// create or update publisher
Publisher publisher = form.getPublisher();
if (publisher == null && form.getPublisherName() != null) { // create new
diff --git a/ui/resources/templates/TitleEdit.html b/ui/resources/templates/TitleEdit.html
index 18ffdfdd..ace04ee2 100644
--- a/ui/resources/templates/TitleEdit.html
+++ b/ui/resources/templates/TitleEdit.html
@@ -195,10 +195,6 @@ Archive an Australian We
Title URL (optional)
-
-
-