diff --git a/pom.xml b/pom.xml index 44b48e3423..0b52d5a30e 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ org.tdl vireo - 4.2.7 + 4.2.8 Vireo Vireo Thesis and Dissertation Submission System diff --git a/src/main/java/org/tdl/vireo/auth/service/VireoUserCredentialsService.java b/src/main/java/org/tdl/vireo/auth/service/VireoUserCredentialsService.java index ff63920efa..fc8b442b5e 100644 --- a/src/main/java/org/tdl/vireo/auth/service/VireoUserCredentialsService.java +++ b/src/main/java/org/tdl/vireo/auth/service/VireoUserCredentialsService.java @@ -3,7 +3,9 @@ import java.util.HashMap; import java.util.Map; +import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; import org.tdl.vireo.config.constant.ConfigurationName; import org.tdl.vireo.model.Role; @@ -17,80 +19,134 @@ @Service public class VireoUserCredentialsService extends UserCredentialsService { + private static final String NETID = ConfigurationName.APPLICATION_AUTH_SHIB_ATTRIBUTE_NETID; + private static final String EMAIL = ConfigurationName.APPLICATION_AUTH_SHIB_ATTRIBUTE_EMAIL; + private static final String BIRTH_YEAR = ConfigurationName.APPLICATION_AUTH_SHIB_ATTRIBUTE_BIRTH_YEAR; + private static final String FIRST_NAME = ConfigurationName.APPLICATION_AUTH_SHIB_ATTRIBUTE_FIRST_NAME; + private static final String MIDDLE_NAME = ConfigurationName.APPLICATION_AUTH_SHIB_ATTRIBUTE_MIDDLE_NAME; + private static final String LAST_NAME = ConfigurationName.APPLICATION_AUTH_SHIB_ATTRIBUTE_LAST_NAME; + private static final String ORCID = ConfigurationName.APPLICATION_AUTH_SHIB_ATTRIBUTE_ORCID; + private static final String INSTITUTIONAL_IDENTIFIER = ConfigurationName.APPLICATION_AUTH_SHIB_ATTRIBUTE_INSTITUTIONAL_IDENTIFIER; + + private static final String SHIBBOLETH = "shibboleth"; + + private static final Map shibSettings = new HashMap<>(); + + static { + shibSettings.put(NETID, "netid"); + shibSettings.put(EMAIL, "email"); + shibSettings.put(BIRTH_YEAR, "birthYear"); + shibSettings.put(FIRST_NAME, "firstName"); + shibSettings.put(MIDDLE_NAME, "middleName"); + shibSettings.put(LAST_NAME, "lastName"); + shibSettings.put(ORCID, "orcid"); + shibSettings.put(INSTITUTIONAL_IDENTIFIER, "uin"); + } + @Autowired private ConfigurationRepo configurationRepo; + @Value("${app.useNetidAsIdentifier:false}") + private boolean useNetidAsIdentifier; + @Override public synchronized User updateUserByCredentials(Credentials credentials) { - User user = userRepo.findByEmail(credentials.getEmail()); + Map shibValues = new HashMap<>(); - Map shibSettings = new HashMap(); - Map shibValues = new HashMap(); + shibSettings.forEach((k, v) -> + shibValues.put(k, configurationRepo.getValueByNameAndType(k, SHIBBOLETH) != null ? configurationRepo.getValueByNameAndType(k, SHIBBOLETH) : v) + ); - shibSettings.put(ConfigurationName.APPLICATION_AUTH_SHIB_ATTRIBUTE_NETID, "netid"); - shibSettings.put(ConfigurationName.APPLICATION_AUTH_SHIB_ATTRIBUTE_BIRTH_YEAR, "birthYear"); - shibSettings.put(ConfigurationName.APPLICATION_AUTH_SHIB_ATTRIBUTE_MIDDLE_NAME, "middleName"); - shibSettings.put(ConfigurationName.APPLICATION_AUTH_SHIB_ATTRIBUTE_ORCID, "orcid"); - shibSettings.put(ConfigurationName.APPLICATION_AUTH_SHIB_ATTRIBUTE_INSTITUTIONAL_IDENTIFIER, "uin"); + String shibNetid = credentials.getAllCredentials().get(shibValues.get(NETID)); + String shibEmail = credentials.getAllCredentials().get(shibValues.get(EMAIL)); + String shibFirstName = credentials.getAllCredentials().get(shibValues.get(FIRST_NAME)); + String shibMiddleName = credentials.getAllCredentials().get(shibValues.get(MIDDLE_NAME)); + String shibLastName = credentials.getAllCredentials().get(shibValues.get(LAST_NAME)); + String shibOrcid = credentials.getAllCredentials().get(shibValues.get(ORCID)); - shibSettings.forEach((k, v) -> { - shibValues.put(k, configurationRepo.getValueByNameAndType(k, "shibboleth") != null ? configurationRepo.getValueByNameAndType(k, "shibboleth") : v); - }); + User user = useNetidAsIdentifier + ? userRepo.findByNetid(shibNetid) + : userRepo.findByEmail(shibEmail); - String uin = credentials.getAllCredentials().get(shibValues.get(ConfigurationName.APPLICATION_AUTH_SHIB_ATTRIBUTE_INSTITUTIONAL_IDENTIFIER)); - if (uin == null) { - uin = credentials.getEmail(); - } - - // TODO: check to see if credentials is from basic login or shibboleth - // do not create new user from basic login credentials that have no user! if (user == null) { - Role role = Role.ROLE_STUDENT; - if (credentials.getRole() == null) { - credentials.setRole(role.toString()); - } - - String shibEmail = credentials.getEmail(); - for (String email : admins) { if (email.equals(shibEmail)) { role = Role.ROLE_ADMIN; - credentials.setRole(role.toString()); } } - user = userRepo.create(credentials.getEmail(), credentials.getFirstName(), credentials.getLastName(), role); + user = userRepo.create(shibEmail, shibFirstName, shibLastName, role); - user.setNetid(credentials.getAllCredentials().get(shibValues.get(ConfigurationName.APPLICATION_AUTH_SHIB_ATTRIBUTE_NETID))); - if (credentials.getAllCredentials().get(shibValues.get(ConfigurationName.APPLICATION_AUTH_SHIB_ATTRIBUTE_BIRTH_YEAR)) != null) { - user.setBirthYear(Integer.parseInt(credentials.getAllCredentials().get(shibValues.get(ConfigurationName.APPLICATION_AUTH_SHIB_ATTRIBUTE_BIRTH_YEAR)))); + user.setNetid(shibNetid); + user.setMiddleName(shibMiddleName); + user.setOrcid(shibOrcid); + + if (credentials.getAllCredentials().containsKey(shibValues.get(BIRTH_YEAR))) { + String shibBirthYearValue = credentials.getAllCredentials().get(shibValues.get(BIRTH_YEAR)); + if (StringUtils.isNotEmpty(shibBirthYearValue)) { + user.setBirthYear(Integer.parseInt(shibBirthYearValue)); + } } - user.setMiddleName(credentials.getAllCredentials().get(shibValues.get(ConfigurationName.APPLICATION_AUTH_SHIB_ATTRIBUTE_MIDDLE_NAME))); - user.setOrcid(credentials.getAllCredentials().get(shibValues.get(ConfigurationName.APPLICATION_AUTH_SHIB_ATTRIBUTE_ORCID))); - user.setUsername(credentials.getEmail()); user = userRepo.save(user); } else { + boolean isUserUpdated = false; - // TODO: update only if user properties does not match current credentials + if (StringUtils.isNotEmpty(shibNetid) && !user.getNetid().equals(shibNetid)) { + user.setNetid(shibNetid); + isUserUpdated = true; + } + + if (credentials.getAllCredentials().containsKey(shibValues.get(BIRTH_YEAR))) { + String shibBirthYearValue = credentials.getAllCredentials().get(shibValues.get(BIRTH_YEAR)); -//DONT OVERWRITE WITH NULL VALUE -//MORE WORK NEEDED - //user.setNetid(credentials.getAllCredentials().get(shibValues.get(ConfigurationName.APPLICATION_AUTH_SHIB_ATTRIBUTE_INSTITUTIONAL_IDENTIFIER))); - if (credentials.getAllCredentials().get(shibValues.get(ConfigurationName.APPLICATION_AUTH_SHIB_ATTRIBUTE_BIRTH_YEAR)) != null) { - user.setBirthYear(Integer.parseInt(credentials.getAllCredentials().get(shibValues.get(ConfigurationName.APPLICATION_AUTH_SHIB_ATTRIBUTE_BIRTH_YEAR)))); + if (StringUtils.isNotEmpty(shibBirthYearValue)) { + int shibBirthYear = Integer.parseInt(shibBirthYearValue); + if (shibBirthYear != user.getBirthYear()) { + user.setBirthYear(shibBirthYear); + isUserUpdated = true; + } + } } - user.setMiddleName(credentials.getAllCredentials().get(shibValues.get(ConfigurationName.APPLICATION_AUTH_SHIB_ATTRIBUTE_MIDDLE_NAME))); - user.setOrcid(credentials.getAllCredentials().get(shibValues.get(ConfigurationName.APPLICATION_AUTH_SHIB_ATTRIBUTE_ORCID))); - user.setUsername(credentials.getEmail()); - user = userRepo.save(user); + if (StringUtils.isNotEmpty(shibFirstName) && !user.getFirstName().equals(shibFirstName)) { + user.setFirstName(shibFirstName); + isUserUpdated = true; + } + + if (StringUtils.isNotEmpty(shibMiddleName) && !user.getMiddleName().equals(shibMiddleName)) { + user.setMiddleName(shibMiddleName); + isUserUpdated = true; + } + + if (StringUtils.isNotEmpty(shibLastName) && !user.getLastName().equals(shibLastName)) { + user.setLastName(shibLastName); + isUserUpdated = true; + } + + if (StringUtils.isNotEmpty(shibOrcid) && !user.getOrcid().equals(shibOrcid)) { + user.setOrcid(shibOrcid); + isUserUpdated = true; + } + + if (StringUtils.isNotEmpty(shibEmail) && !user.getUsername().equals(shibEmail)) { + user.setEmail(shibEmail); + user.setUsername(shibEmail); + isUserUpdated = true; + } + + if (isUserUpdated) { + user = userRepo.save(user); + } } credentials.setRole(user.getRole().toString()); - credentials.setUin(user.getUsername()); + + credentials.setNetid(user.getNetid()); + credentials.setFirstName(user.getFirstName()); + credentials.setLastName(user.getLastName()); return user; } diff --git a/src/main/java/org/tdl/vireo/controller/FieldValueController.java b/src/main/java/org/tdl/vireo/controller/FieldValueController.java index 44b4cbdcc3..a7b85dcdfb 100644 --- a/src/main/java/org/tdl/vireo/controller/FieldValueController.java +++ b/src/main/java/org/tdl/vireo/controller/FieldValueController.java @@ -34,7 +34,7 @@ public class FieldValueController { @GetMapping("/predicate/{value}") @PreAuthorize("hasRole('STUDENT')") public ApiResponse getFieldValuesByPredicateValue(@PathVariable String value) { - return new ApiResponse(SUCCESS, fieldValueRepo.getAllValuesByFieldPredicateValue("submission_type")); + return new ApiResponse(SUCCESS, fieldValueRepo.getAllValuesByFieldPredicateValue(value)); } } diff --git a/src/main/java/org/tdl/vireo/controller/SubmissionListController.java b/src/main/java/org/tdl/vireo/controller/SubmissionListController.java index daded5bbab..0e43a70d14 100644 --- a/src/main/java/org/tdl/vireo/controller/SubmissionListController.java +++ b/src/main/java/org/tdl/vireo/controller/SubmissionListController.java @@ -4,12 +4,11 @@ import static edu.tamu.weaver.response.ApiStatus.SUCCESS; import static org.springframework.web.bind.annotation.RequestMethod.POST; -import edu.tamu.weaver.auth.annotation.WeaverUser; -import edu.tamu.weaver.response.ApiResponse; -import edu.tamu.weaver.validation.aspect.annotation.WeaverValidatedModel; +import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.Optional; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -36,6 +35,10 @@ import org.tdl.vireo.model.repo.UserRepo; import org.tdl.vireo.service.DefaultSubmissionListColumnService; +import edu.tamu.weaver.auth.annotation.WeaverUser; +import edu.tamu.weaver.response.ApiResponse; +import edu.tamu.weaver.validation.aspect.annotation.WeaverValidatedModel; + @RestController @RequestMapping("/submission-list") public class SubmissionListController { @@ -228,7 +231,19 @@ public ApiResponse addFilterCriterion(@WeaverUser User user, @RequestBody Map fieldValues; @@ -236,6 +249,10 @@ public class Submission extends ValidatingBaseEntity { @Column(nullable = true) private String depositURL; + @Transient + @JsonView(Views.SubmissionList.class) + private Map columnValues; + public Submission() { setModelValidator(new SubmissionValidator()); setFieldValues(new HashSet()); @@ -295,6 +312,20 @@ public void setAssignee(User assignee) { this.assignee = assignee; } + /** + * @return the lastAction + */ + public ActionLog getLastAction() { + return lastAction; + } + + /** + * @param lastAction the last action to set + */ + public void setLastAction(ActionLog lastAction) { + this.lastAction = lastAction; + } + /** * @return the submissionStatus */ @@ -529,23 +560,6 @@ public void removeActionLog(ActionLog actionLog) { getActionLogs().remove(actionLog); } - /** - * - */ - @JsonView(Views.Partial.class) - public String getLastEvent() { - Optional actionLog = getActionLogs() - .stream() - .max(Comparator.comparing(al -> al.getActionDate())); - String lastEvent = null; - - if (actionLog.isPresent()) { - lastEvent = actionLog.get().getEntry(); - } - - return lastEvent; - } - /** * @return The reviewer notes. */ @@ -630,6 +644,20 @@ public void setDepositURL(String depositURL) { this.depositURL = depositURL; } + /** + * @return the list column values mapped from field values + */ + public Map getColumnValues() { + return columnValues; + } + + /** + * @param columnValues the list column values mapped from field values + */ + public void setColumnValues(Map columnValues) { + this.columnValues = columnValues; + } + /** * @param customActionValue */ @@ -704,7 +732,7 @@ public List getFieldValuesByPredicateValueStartsWith(String predicat } }); return fieldValues; - } + } @JsonIgnore diff --git a/src/main/java/org/tdl/vireo/model/SubmissionListColumn.java b/src/main/java/org/tdl/vireo/model/SubmissionListColumn.java index a2814f8d76..7eaf1125a6 100644 --- a/src/main/java/org/tdl/vireo/model/SubmissionListColumn.java +++ b/src/main/java/org/tdl/vireo/model/SubmissionListColumn.java @@ -2,36 +2,31 @@ import static javax.persistence.FetchType.EAGER; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashSet; -import java.util.List; -import java.util.Set; - import javax.persistence.Column; import javax.persistence.ElementCollection; import javax.persistence.Entity; import javax.persistence.ManyToOne; import javax.persistence.OrderColumn; -import javax.persistence.Table; import javax.persistence.Transient; -import javax.persistence.UniqueConstraint; -import org.tdl.vireo.model.validation.SubmissionListColumnValidator; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashSet; +import java.util.List; +import java.util.Set; import com.fasterxml.jackson.annotation.JsonIgnore; +import org.tdl.vireo.model.validation.SubmissionListColumnValidator; import edu.tamu.weaver.validation.model.ValidatingBaseEntity; @Entity -@Table(uniqueConstraints = @UniqueConstraint(columnNames = { "title", "predicate", "input_type_id" })) public class SubmissionListColumn extends ValidatingBaseEntity { @ManyToOne(fetch = EAGER, optional = false) private InputType inputType; - // NOTE: should this be unique? Are there any front end requirements for it to be unique. - @Column(nullable = false) + @Column(nullable = false, unique = true) private String title; @Column(nullable = true) diff --git a/src/main/java/org/tdl/vireo/model/User.java b/src/main/java/org/tdl/vireo/model/User.java index 87a9d9fc4a..7917b8e0e0 100644 --- a/src/main/java/org/tdl/vireo/model/User.java +++ b/src/main/java/org/tdl/vireo/model/User.java @@ -55,7 +55,7 @@ public class User extends AbstractWeaverUserDetails { private static final long serialVersionUID = -614285536644750464L; @JsonView(Views.Partial.class) - @Column(nullable = true) + @Column(nullable = true, unique = true) private String netid; @JsonView(Views.SubmissionList.class) diff --git a/src/main/java/org/tdl/vireo/model/repo/SubmissionRepo.java b/src/main/java/org/tdl/vireo/model/repo/SubmissionRepo.java index 3be041b7bc..b6448a8a54 100644 --- a/src/main/java/org/tdl/vireo/model/repo/SubmissionRepo.java +++ b/src/main/java/org/tdl/vireo/model/repo/SubmissionRepo.java @@ -17,7 +17,7 @@ public interface SubmissionRepo extends WeaverRepo, SubmissionRepoCu public List findByOrganization(Organization organization); - public List findByActionLogsId(Long id); + public Submission findByActionLogsId(Long id); @EntityGraph(value = "graph.Submission.Individual") public List findAllBySubmitterId(Long submitterId); diff --git a/src/main/java/org/tdl/vireo/model/repo/UserRepo.java b/src/main/java/org/tdl/vireo/model/repo/UserRepo.java index 0e5d859dc5..2a1554460f 100644 --- a/src/main/java/org/tdl/vireo/model/repo/UserRepo.java +++ b/src/main/java/org/tdl/vireo/model/repo/UserRepo.java @@ -17,6 +17,8 @@ public interface UserRepo extends AbstractWeaverUserRepo, UserRepoCustom { public User findByEmail(String email); + public User findByNetid(String netid); + public List findAllByRoleIn(List role, Sort sort); public List findAllByRoleIn(List role, Pageable pageable); diff --git a/src/main/java/org/tdl/vireo/model/repo/impl/ActionLogRepoImpl.java b/src/main/java/org/tdl/vireo/model/repo/impl/ActionLogRepoImpl.java index 8e40f7fff1..bb717cff71 100644 --- a/src/main/java/org/tdl/vireo/model/repo/impl/ActionLogRepoImpl.java +++ b/src/main/java/org/tdl/vireo/model/repo/impl/ActionLogRepoImpl.java @@ -1,76 +1,92 @@ -package org.tdl.vireo.model.repo.impl; - -import static edu.tamu.weaver.response.ApiStatus.SUCCESS; - -import java.util.Calendar; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.messaging.simp.SimpMessagingTemplate; -import org.tdl.vireo.model.ActionLog; -import org.tdl.vireo.model.Submission; -import org.tdl.vireo.model.User; -import org.tdl.vireo.model.repo.ActionLogRepo; -import org.tdl.vireo.model.repo.SubmissionRepo; -import org.tdl.vireo.model.repo.custom.ActionLogRepoCustom; - -import edu.tamu.weaver.data.model.repo.impl.AbstractWeaverRepoImpl; -import edu.tamu.weaver.response.ApiResponse; - -public class ActionLogRepoImpl extends AbstractWeaverRepoImpl implements ActionLogRepoCustom { - - @Autowired - private ActionLogRepo actionLogRepo; - - @Autowired - private SubmissionRepo submissionRepo; - - @Autowired - private SimpMessagingTemplate simpMessagingTemplate; - - @Override - public ActionLog create(Submission submission, User user, Calendar actionDate, String entry, boolean privateFlag) { - ActionLog log = actionLogRepo.save(new ActionLog(submission.getSubmissionStatus(), user, actionDate, entry, privateFlag)); - submission.addActionLog(log); - submissionRepo.save(submission); - simpMessagingTemplate.convertAndSend("/channel/submission/" + submission.getId() + "/action-logs", new ApiResponse(SUCCESS, log)); - return log; - } - - @Override - public ActionLog create(Submission submission, Calendar actionDate, String entry, boolean privateFlag) { - ActionLog log = actionLogRepo.save(new ActionLog(submission.getSubmissionStatus(), actionDate, entry, privateFlag)); - submission.addActionLog(log); - submissionRepo.save(submission); - simpMessagingTemplate.convertAndSend("/channel/submission/" + submission.getId() + "/action-logs", new ApiResponse(SUCCESS, log)); - return log; - } - - @Override - public ActionLog createPublicLog(Submission submission, User user, String entry) { - return create(submission, user, Calendar.getInstance(), entry, false); - } - - @Override - public ActionLog createAdvisorPublicLog(Submission submission, String entry) { - return create(submission, Calendar.getInstance(), entry, false); - } - - @Override - public ActionLog createPrivateLog(Submission submission, User user, String entry) { - return create(submission, user, Calendar.getInstance(), entry, true); - } - - @Override - public void delete(ActionLog actionLog) { - for (Submission submission : submissionRepo.findByActionLogsId(actionLog.getId())) { - submission.removeActionLog(actionLog); - submissionRepo.save(submission); - } - } - - @Override - protected String getChannel() { - return "/channel/action-log"; - } - -} +package org.tdl.vireo.model.repo.impl; + +import static edu.tamu.weaver.response.ApiStatus.SUCCESS; + +import java.util.ArrayList; +import java.util.Calendar; +import java.util.Comparator; +import java.util.List; +import java.util.Objects; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.messaging.simp.SimpMessagingTemplate; +import org.tdl.vireo.model.ActionLog; +import org.tdl.vireo.model.Submission; +import org.tdl.vireo.model.User; +import org.tdl.vireo.model.repo.ActionLogRepo; +import org.tdl.vireo.model.repo.SubmissionRepo; +import org.tdl.vireo.model.repo.custom.ActionLogRepoCustom; + +import edu.tamu.weaver.data.model.repo.impl.AbstractWeaverRepoImpl; +import edu.tamu.weaver.response.ApiResponse; + +public class ActionLogRepoImpl extends AbstractWeaverRepoImpl implements ActionLogRepoCustom { + + @Autowired + private ActionLogRepo actionLogRepo; + + @Autowired + private SubmissionRepo submissionRepo; + + @Autowired + private SimpMessagingTemplate simpMessagingTemplate; + + @Override + public ActionLog create(Submission submission, User user, Calendar actionDate, String entry, boolean privateFlag) { + ActionLog log = actionLogRepo.save(new ActionLog(submission.getSubmissionStatus(), user, actionDate, entry, privateFlag)); + submission.addActionLog(log); + submission.setLastAction(log); + submissionRepo.save(submission); + simpMessagingTemplate.convertAndSend("/channel/submission/" + submission.getId() + "/action-logs", new ApiResponse(SUCCESS, log)); + return log; + } + + @Override + public ActionLog create(Submission submission, Calendar actionDate, String entry, boolean privateFlag) { + ActionLog log = actionLogRepo.save(new ActionLog(submission.getSubmissionStatus(), actionDate, entry, privateFlag)); + submission.addActionLog(log); + submission.setLastAction(log); + submissionRepo.save(submission); + simpMessagingTemplate.convertAndSend("/channel/submission/" + submission.getId() + "/action-logs", new ApiResponse(SUCCESS, log)); + return log; + } + + @Override + public ActionLog createPublicLog(Submission submission, User user, String entry) { + return create(submission, user, Calendar.getInstance(), entry, false); + } + + @Override + public ActionLog createAdvisorPublicLog(Submission submission, String entry) { + return create(submission, Calendar.getInstance(), entry, false); + } + + @Override + public ActionLog createPrivateLog(Submission submission, User user, String entry) { + return create(submission, user, Calendar.getInstance(), entry, true); + } + + @Override + public void delete(ActionLog actionLog) { + Submission submission = submissionRepo.findByActionLogsId(actionLog.getId()); + submission.removeActionLog(actionLog); + + List actionLogs = new ArrayList<>(submission.getActionLogs()); + + if (!actionLogs.isEmpty() && Objects.nonNull(submission.getLastAction()) + && submission.getLastAction().getId().equals(actionLog.getId())) { + actionLogs.sort(Comparator.comparing(ActionLog::getActionDate)); + submission.setLastAction(actionLogs.get(actionLogs.size() - 1)); + } else { + submission.setLastAction(null); + } + + submissionRepo.save(submission); + } + + @Override + protected String getChannel() { + return "/channel/action-log"; + } + +} diff --git a/src/main/java/org/tdl/vireo/model/repo/impl/SubmissionRepoImpl.java b/src/main/java/org/tdl/vireo/model/repo/impl/SubmissionRepoImpl.java index ec4894c22f..e50b7804e8 100644 --- a/src/main/java/org/tdl/vireo/model/repo/impl/SubmissionRepoImpl.java +++ b/src/main/java/org/tdl/vireo/model/repo/impl/SubmissionRepoImpl.java @@ -5,9 +5,8 @@ import static edu.tamu.weaver.response.ApiAction.UPDATE; import static edu.tamu.weaver.response.ApiStatus.SUCCESS; -import edu.tamu.weaver.auth.model.Credentials; -import edu.tamu.weaver.data.model.repo.impl.AbstractWeaverRepoImpl; -import edu.tamu.weaver.response.ApiResponse; +import javax.sql.DataSource; + import java.io.IOException; import java.sql.ResultSet; import java.sql.SQLException; @@ -21,10 +20,13 @@ import java.util.List; import java.util.Map; import java.util.Map.Entry; +import java.util.Objects; import java.util.Set; import java.util.concurrent.ExecutionException; import java.util.regex.Pattern; -import javax.sql.DataSource; +import java.util.stream.Collectors; + +import org.apache.commons.lang.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -65,6 +67,10 @@ import org.tdl.vireo.model.repo.custom.SubmissionRepoCustom; import org.tdl.vireo.service.AssetService; +import edu.tamu.weaver.auth.model.Credentials; +import edu.tamu.weaver.data.model.repo.impl.AbstractWeaverRepoImpl; +import edu.tamu.weaver.response.ApiResponse; + public class SubmissionRepoImpl extends AbstractWeaverRepoImpl implements SubmissionRepoCustom { final static Logger logger = LoggerFactory.getLogger(SubmissionRepoImpl.class); @@ -334,8 +340,8 @@ private void writeLicenseFile(User user, Submission submission, String licenseNa } @Override - public List batchDynamicSubmissionQuery(NamedSearchFilterGroup activeFilter, List submissionListColums) { - QueryStrings queryBuilder = craftDynamicSubmissionQuery(activeFilter, submissionListColums, null); + public List batchDynamicSubmissionQuery(NamedSearchFilterGroup activeFilter, List submissionListColumns) { + QueryStrings queryBuilder = craftDynamicSubmissionQuery(activeFilter, submissionListColumns, null); List ids = new ArrayList(); jdbcTemplate.queryForList(queryBuilder.getQuery()).forEach(row -> { ids.add((Long) row.get("ID")); @@ -345,10 +351,10 @@ public List batchDynamicSubmissionQuery(NamedSearchFilterGroup activ } @Override - public Page pageableDynamicSubmissionQuery(NamedSearchFilterGroup activeFilter, List submissionListColums, Pageable pageable) throws ExecutionException { + public Page pageableDynamicSubmissionQuery(NamedSearchFilterGroup activeFilter, List submissionListColumns, Pageable pageable) throws ExecutionException { long startTime = System.nanoTime(); - QueryStrings queryBuilder = craftDynamicSubmissionQuery(activeFilter, submissionListColums, pageable); + QueryStrings queryBuilder = craftDynamicSubmissionQuery(activeFilter, new ArrayList<>(submissionListColumns), pageable); Long total = jdbcTemplate.queryForObject(queryBuilder.getCountQuery(), Long.class); @@ -364,29 +370,70 @@ public Long mapRow(ResultSet rs, int rowNum) throws SQLException { logger.debug("ID query for dynamic query took " + ((System.nanoTime() - startTime) / 1000000000.0) + " seconds"); startTime = System.nanoTime(); - List submissions = new ArrayList<>(); - - List unordered = submissionRepo.findAllById(ids); + List submissions = submissionRepo.findAllById(ids); logger.debug("Find all query for dynamic query took " + ((System.nanoTime() - startTime) / 1000000000.0) + " seconds"); // order them - for (Long id : ids) { - for (Submission sub : unordered) { - if (sub.getId().equals(id)) { - submissions.add(sub); - unordered.remove(sub); - break; - } - } + Map idToIndexMap = new HashMap<>(); + for (int i = 0; i < ids.size(); i++) { + idToIndexMap.put(ids.get(i), i); } + submissions.sort((s1, s2) -> { + mapColumnValues(s1, submissionListColumns); + mapColumnValues(s2, submissionListColumns); + int index1 = idToIndexMap.get(s1.getId()); + int index2 = idToIndexMap.get(s2.getId()); + return Integer.compare(index1, index2); + }); + + logger.debug("Sorting and mapping results took " + ((System.nanoTime() - startTime) / 1000000000.0) + " seconds"); + int offset = pageable.getPageSize() * pageable.getPageNumber(); int limit = pageable.getPageSize(); return new PageImpl(submissions, PageRequest.of((int) Math.floor(offset / limit), limit), total); } - private QueryStrings craftDynamicSubmissionQuery(NamedSearchFilterGroup activeFilter, List submissionListColums, Pageable pageable) { + private void mapColumnValues(Submission submission, List submissionListColumns) { + if (Objects.isNull(submission.getColumnValues())) { + Map columnValues = new HashMap<>(); + + Map> groupedByPredicate = submission.getFieldValues().stream() + .collect(Collectors.groupingBy( + fv -> fv.getFieldPredicate().getValue(), + Collectors.mapping(FieldValue::getValue, Collectors.toList()) + )); + + for (SubmissionListColumn slc : submissionListColumns) { + if (StringUtils.isNotEmpty(slc.getPredicate())) { + StringBuilder value = new StringBuilder(); + + String predicate = slc.getPredicate().trim(); + + if (groupedByPredicate.containsKey(predicate)) { + value.append(String.join(", ", groupedByPredicate.get(predicate))); + } else { + // if the predicate is not found, see if it is space delimited set of predicates + if (predicate.contains(" ")) { + for (String p : predicate.split(" ")) { + String tp = p.replace(",", " ").trim(); + if (groupedByPredicate.containsKey(tp)) { + value.append(String.join(", ", groupedByPredicate.get(tp)) + (p.endsWith(",") ? ", " : " ")); + } + } + } + } + + columnValues.put(slc.getId(), value.toString()); + } + } + + submission.setColumnValues(columnValues); + } + } + + private QueryStrings craftDynamicSubmissionQuery(NamedSearchFilterGroup activeFilter, List submissionListColumns, Pageable pageable) { // set up storage for user's preferred columns Set allColumnSearchFilters = new HashSet<>(); @@ -396,7 +443,7 @@ private QueryStrings craftDynamicSubmissionQuery(NamedSearchFilterGroup activeFi // set sort and sort order on all submission list columns that are set // on the requesting user's submission list columns - submissionListColums.forEach(submissionListColumn -> { + submissionListColumns.forEach(submissionListColumn -> { for (SubmissionListColumn slc : allSubmissionListColumns) { if (submissionListColumn.equals(slc)) { slc.setVisible(true); @@ -455,7 +502,8 @@ public int compare(SubmissionListColumn svc1, SubmissionListColumn svc2) { int n = 0; int totalFieldValueConditions = 0; - for (SubmissionListColumn submissionListColumn : allSubmissionListColumns) { + for (int i = 0; i < allSubmissionListColumns.size(); i++) { + SubmissionListColumn submissionListColumn = allSubmissionListColumns.get(i); if (submissionListColumn.getSortOrder() > 0 || submissionListColumn.getFilters().size() > 0 || allColumnSearchFilters.size() > 0 || submissionListColumn.getVisible()) { if (sqlColumnsBuilders.containsKey(submissionListColumn.getId())) { @@ -467,7 +515,31 @@ public int compare(SubmissionListColumn svc1, SubmissionListColumn svc2) { switch (String.join(".", submissionListColumn.getValuePath())) { case "fieldValues.value": - Long predicateId = fieldPredicateRepo.findByValue(submissionListColumn.getPredicate()).getId(); + FieldPredicate fieldPredicate = fieldPredicateRepo.findByValue(submissionListColumn.getPredicate()); + + // if the predicate is not found, see if it is space delimited set of predicates + // for each predicate, add a submission list column clone with predicate and sort order updated + if (fieldPredicate == null) { + String[] predicates = submissionListColumn.getPredicate().split(" "); + int sortOrder = submissionListColumn.getSortOrder(); + for(int j = 0; j < predicates.length; ++j) { + + SubmissionListColumn column = new SubmissionListColumn( + submissionListColumn.getTitle(), + submissionListColumn.getSort(), + predicates[j].replace(",", "").trim(), + submissionListColumn.getInputType() + ); + + column.setSortOrder(sortOrder++); + + allSubmissionListColumns.add(i + j + 1, column); + } + + continue; + } + + Long predicateId = fieldPredicate.getId(); // @formatter:off if (submissionListColumn.getSortOrder() > 0 || submissionListColumn.getFilters().size() > 0) { @@ -593,7 +665,7 @@ public int compare(SubmissionListColumn svc1, SubmissionListColumn svc2) { for (String filterString : submissionListColumn.getFilters()) { sqlBuilder = new StringBuilder(); - sqlBuilder.append("s").append(".id = ").append(filterString); + sqlBuilder.append("s.id = ").append(filterString); sqlWhereBuilderList.add(sqlBuilder); getFromBuildersMap(sqlCountWhereFilterBuilders, "id").add(sqlBuilder); } @@ -615,10 +687,10 @@ public int compare(SubmissionListColumn svc1, SubmissionListColumn svc2) { sqlBuilder = new StringBuilder(); if (submissionListColumn.getExactMatch()) { - sqlBuilder.append("ss").append(".name = '").append(filterString).append("'"); + sqlBuilder.append("ss.name = '").append(filterString).append("'"); } else { // TODO: determine if status will ever be search using a like - sqlBuilder.append("LOWER(ss").append(".name) LIKE '%").append(escapeString(filterString)).append("%'"); + sqlBuilder.append("LOWER(ss.name) LIKE '%").append(escapeString(filterString)).append("%'"); } sqlWhereBuilderList.add(sqlBuilder); @@ -628,7 +700,7 @@ public int compare(SubmissionListColumn svc1, SubmissionListColumn svc2) { // all column search filter for (String filterString : allColumnSearchFilters) { sqlBuilder = new StringBuilder(); - sqlBuilder.append("LOWER(ss").append(".name) LIKE '%").append(escapeString(filterString)).append("%'"); + sqlBuilder.append("LOWER(ss.name) LIKE '%").append(escapeString(filterString)).append("%'"); sqlAllColumnsWhereBuilderList.add(sqlBuilder); } @@ -652,11 +724,10 @@ public int compare(SubmissionListColumn svc1, SubmissionListColumn svc2) { sqlBuilder = new StringBuilder(); if (submissionListColumn.getExactMatch()) { - sqlBuilder.append("o").append(".name = '").append(filterString).append("'"); + sqlBuilder.append("o.name = '").append(filterString).append("'"); } else { - // TODO: determine if organization name will ever be - // search using a like - sqlBuilder.append("LOWER(o").append(".name) LIKE '%").append(escapeString(filterString)).append("%'"); + // TODO: determine if organization name will ever be search using a like + sqlBuilder.append("LOWER(o.name) LIKE '%").append(escapeString(filterString)).append("%'"); } sqlWhereBuilderList.add(sqlBuilder); @@ -666,7 +737,7 @@ public int compare(SubmissionListColumn svc1, SubmissionListColumn svc2) { // all column search filter for (String filterString : allColumnSearchFilters) { sqlBuilder = new StringBuilder(); - sqlBuilder.append("LOWER(o").append(".name) LIKE '%").append(escapeString(filterString)).append("%'"); + sqlBuilder.append("LOWER(o.name) LIKE '%").append(escapeString(filterString)).append("%'"); sqlAllColumnsWhereBuilderList.add(sqlBuilder); } @@ -690,11 +761,11 @@ public int compare(SubmissionListColumn svc1, SubmissionListColumn svc2) { for (String filterString : submissionListColumn.getFilters()) { sqlBuilder = new StringBuilder(); if (submissionListColumn.getExactMatch()) { - sqlBuilder.append("oc").append(".name = '").append(filterString).append("'"); + sqlBuilder.append("oc.name = '").append(filterString).append("'"); } else { // TODO: determine if organization category name // will ever be search using a like - sqlBuilder.append("LOWER(oc").append(".name) LIKE '%").append(escapeString(filterString)).append("%'"); + sqlBuilder.append("LOWER(oc.name) LIKE '%").append(escapeString(filterString)).append("%'"); } sqlWhereBuilderList.add(sqlBuilder); @@ -704,7 +775,7 @@ public int compare(SubmissionListColumn svc1, SubmissionListColumn svc2) { // all column search filter for (String filterString : allColumnSearchFilters) { sqlBuilder = new StringBuilder(); - sqlBuilder.append("LOWER(oc").append(".name) LIKE '%").append(escapeString(filterString)).append("%'"); + sqlBuilder.append("LOWER(oc.name) LIKE '%").append(escapeString(filterString)).append("%'"); sqlAllColumnsWhereBuilderList.add(sqlBuilder); } @@ -725,11 +796,11 @@ public int compare(SubmissionListColumn svc1, SubmissionListColumn svc2) { sqlBuilder = new StringBuilder(); if (filterString == null) { - sqlBuilder.append("a").append(".email IS NULL"); + sqlBuilder.append("a.email IS NULL"); } else if (submissionListColumn.getExactMatch()) { - sqlBuilder.append("a").append(".email = '").append(filterString).append("'"); + sqlBuilder.append("a.email = '").append(filterString).append("'"); } else { - sqlBuilder.append("LOWER(a").append(".email) LIKE '%").append(escapeString(filterString)).append("%'"); + sqlBuilder.append("LOWER(a.email) LIKE '%").append(escapeString(filterString)).append("%'"); } sqlWhereBuilderList.add(sqlBuilder); @@ -739,12 +810,83 @@ public int compare(SubmissionListColumn svc1, SubmissionListColumn svc2) { // all column search filter for (String filterString : allColumnSearchFilters) { sqlBuilder = new StringBuilder(); - sqlBuilder.append("LOWER(a").append(".email) LIKE '%").append(escapeString(filterString)).append("%'"); + sqlBuilder.append("LOWER(a.email) LIKE '%").append(escapeString(filterString)).append("%'"); sqlAllColumnsWhereBuilderList.add(sqlBuilder); } break; + case "lastAction.entry": + sqlBuilder = new StringBuilder(); + if (!sqlJoinsBuilder.toString().contains("LEFT JOIN action_log al ON al.id=s.last_action_id")) { + sqlBuilder.append("\nLEFT JOIN action_log al ON al.id=s.last_action_id"); + } + + sqlJoinsBuilder.append(sqlBuilder); + sqlCountSelectBuilder.append(sqlBuilder); + + if (submissionListColumn.getSortOrder() > 0) { + setColumnOrdering(submissionListColumn.getSort(), sqlAliasBuilders, sqlOrderBysBuilder, "al.entry"); + } + + for (String filterString : submissionListColumn.getFilters()) { + sqlBuilder = new StringBuilder(); + + if (filterString == null) { + sqlBuilder.append("al.entry IS NULL"); + } else if (submissionListColumn.getExactMatch()) { + sqlBuilder.append("al.entry = '").append(filterString).append("'"); + } else { + sqlBuilder.append("LOWER(al.entry) LIKE '%").append(escapeString(filterString)).append("%'"); + } + + sqlWhereBuilderList.add(sqlBuilder); + getFromBuildersMap(sqlCountWhereFilterBuilders, "lastAction.entry").add(sqlBuilder); + } + + // all column search filter + for (String filterString : allColumnSearchFilters) { + sqlBuilder = new StringBuilder(); + sqlBuilder.append("LOWER(al.entry) LIKE '%").append(escapeString(filterString)).append("%'"); + sqlAllColumnsWhereBuilderList.add(sqlBuilder); + } + + break; + + case "lastAction.actionDate": + sqlBuilder = new StringBuilder(); + if (!sqlJoinsBuilder.toString().contains("LEFT JOIN action_log al ON al.id=s.last_action_id")) { + sqlBuilder.append("\nLEFT JOIN action_log al ON al.id=s.last_action_id"); + } + + sqlJoinsBuilder.append(sqlBuilder); + sqlCountSelectBuilder.append(sqlBuilder); + + if (submissionListColumn.getSortOrder() > 0) { + setColumnOrdering(submissionListColumn.getSort(), sqlAliasBuilders, sqlOrderBysBuilder, "al.action_date"); + } + + for (String filterString : submissionListColumn.getFilters()) { + if (filterString.contains("|")) { + String[] dates = filterString.split(Pattern.quote("|")); + sqlBuilder = new StringBuilder() + .append("al.action_date") + .append(" BETWEEN CAST('").append(dates[0]) + .append("' AS DATE) AND CAST('").append(dates[1]) + .append("' AS DATE)"); + } else { + sqlBuilder = new StringBuilder() + .append("al.action_date") + .append(" = CAST('").append(filterString) + .append("' AS DATE)"); + } + + sqlWhereBuilderList.add(sqlBuilder); + getFromBuildersMap(sqlCountWhereFilterBuilders, "lastAction.actionDate").add(sqlBuilder); + } + + break; + case "embargoTypes.name": // This is not a select column but is instead only a custom filter. if (submissionListColumn.getFilters().size() > 0) { @@ -809,23 +951,6 @@ public int compare(SubmissionListColumn svc1, SubmissionListColumn svc2) { break; - case "lastEvent": - sqlBuilder = new StringBuilder() - .append("\nLEFT JOIN") - .append("\n (SELECT al.id, al.action_date, al.entry, al.action_logs_id") - .append("\n FROM action_log al") - .append("\n WHERE (al.action_logs_id = id)") - .append("\n ORDER BY al.action_date DESC") - .append("\n LIMIT 1) als") - .append("\n ON action_logs_id = s.submission_status_id"); - - sqlJoinsBuilder.append(sqlBuilder); - sqlCountSelectBuilder.append(sqlBuilder); - - // TODO: finish sqlWheresBuilder. - - break; - // exclude individual submissions from submission list case "exclude": @@ -835,9 +960,9 @@ public int compare(SubmissionListColumn svc1, SubmissionListColumn svc2) { for (String filterString : submissionListColumn.getFilters()) { if (sqlWheresExcludeBuilder.length() > 0) { - sqlWheresExcludeBuilder.append(" AND s").append(".id <> ").append(filterString); + sqlWheresExcludeBuilder.append(" AND s.id <> ").append(filterString); } else { - sqlWheresExcludeBuilder.append(" s").append(".id <> ").append(filterString); + sqlWheresExcludeBuilder.append(" s.id <> ").append(filterString); } } @@ -922,7 +1047,7 @@ public int compare(SubmissionListColumn svc1, SubmissionListColumn svc2) { for (String filterString : submissionListColumn.getFilters()) { sqlBuilder = new StringBuilder(); - sqlBuilder.append("LOWER(s").append(".depositurl) LIKE '%").append(escapeString(filterString)).append("%'"); + sqlBuilder.append("LOWER(s.depositurl) LIKE '%").append(escapeString(filterString)).append("%'"); sqlWhereBuilderList.add(sqlBuilder); getFromBuildersMap(sqlCountWhereFilterBuilders, "depositurl").add(sqlBuilder); } @@ -930,7 +1055,7 @@ public int compare(SubmissionListColumn svc1, SubmissionListColumn svc2) { // all column search filter for (String filterString : allColumnSearchFilters) { sqlBuilder = new StringBuilder(); - sqlBuilder.append("LOWER(s").append(".depositurl) LIKE '%").append(escapeString(filterString)).append("%'"); + sqlBuilder.append("LOWER(s.depositurl) LIKE '%").append(escapeString(filterString)).append("%'"); sqlAllColumnsWhereBuilderList.add(sqlBuilder); } @@ -943,7 +1068,7 @@ public int compare(SubmissionListColumn svc1, SubmissionListColumn svc2) { for (String filterString : submissionListColumn.getFilters()) { sqlBuilder = new StringBuilder(); - sqlBuilder.append("LOWER(s").append(".reviewer_notes) LIKE '%").append(escapeString(filterString)).append("%'"); + sqlBuilder.append("LOWER(s.reviewer_notes) LIKE '%").append(escapeString(filterString)).append("%'"); sqlWhereBuilderList.add(sqlBuilder); getFromBuildersMap(sqlCountWhereFilterBuilders, "reviewer_notes").add(sqlBuilder); } @@ -951,7 +1076,7 @@ public int compare(SubmissionListColumn svc1, SubmissionListColumn svc2) { // all column search filter for (String filterString : allColumnSearchFilters) { sqlBuilder = new StringBuilder(); - sqlBuilder.append("LOWER(s").append(".reviewer_notes) LIKE '%").append(escapeString(filterString)).append("%'"); + sqlBuilder.append("LOWER(s.reviewer_notes) LIKE '%").append(escapeString(filterString)).append("%'"); sqlAllColumnsWhereBuilderList.add(sqlBuilder); } @@ -1093,8 +1218,7 @@ public void setColumnOrdering(Sort sort, List sqlAliasBuilders, StringBu if (!sqlAliasBuilders.contains(value)) { sqlAliasBuilders.add(value); } - - sqlOrderBysBuilder.append(" ").append(value).append(" ").append(sort.name()).append(","); + sqlOrderBysBuilder.append("\n ").append(value).append(" ").append(sort.name()).append(","); } } @@ -1154,8 +1278,8 @@ protected String getChannel() { private StringBuilder buildSubmissionDateFieldString(String column, String filter) { if (filter.contains("|")) { String[] dates = filter.split(Pattern.quote("|")); - return new StringBuilder() - .append("s.").append(column) + return new StringBuilder() + .append("s.").append(column) .append(" BETWEEN CAST('").append(dates[0]) .append("' AS DATE) AND CAST('").append(dates[1]) .append("' AS DATE)"); diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 08a6541d2f..796d9b7931 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -177,6 +177,9 @@ app: dataLoader: initialize: true + # org.tdl.vireo.auth.service.VireoUserCredentialsService + useNetidAsIdentifier: false + # edu.tamu.weaver.token.service.TokenService auth: security.jwt: diff --git a/src/main/resources/organization/SYSTEM_Organization_Definition.json b/src/main/resources/organization/SYSTEM_Organization_Definition.json index 184717b65a..01fa5f62fe 100644 --- a/src/main/resources/organization/SYSTEM_Organization_Definition.json +++ b/src/main/resources/organization/SYSTEM_Organization_Definition.json @@ -113,7 +113,7 @@ }, "mappedShibAttribute": { "isSystemRequired": true, - "name": "APPLICATION_AUTH_SHIB_ATTRIBUTE_EMAIL", + "name": "auth.shib.attribute.email", "type": "shibboleth", "value": "email" }, @@ -160,7 +160,7 @@ }, "mappedShibAttribute": { "isSystemRequired": true, - "name": "APPLICATION_AUTH_SHIB_ATTRIBUTE_INSTITUTIONAL_IDENTIFIER", + "name": "auth.shib.attribute.institutionalIdentifier", "type": "shibboleth", "value": "uin" }, diff --git a/src/main/resources/settings/SYSTEM_Defaults.json b/src/main/resources/settings/SYSTEM_Defaults.json index 5c6f7b878f..b18b6c58ef 100644 --- a/src/main/resources/settings/SYSTEM_Defaults.json +++ b/src/main/resources/settings/SYSTEM_Defaults.json @@ -183,70 +183,70 @@ ], "shibboleth": [ { - "APPLICATION_AUTH_SHIB_ATTRIBUTE_NETID": "netid" + "auth.shib.attribute.netid": "netid" }, { - "APPLICATION_AUTH_SHIB_ATTRIBUTE_EMAIL": "email" + "auth.shib.attribute.email": "email" }, { - "APPLICATION_AUTH_SHIB_ATTRIBUTE_FIRST_NAME": "firstName" + "auth.shib.attribute.firstName": "firstName" }, { - "APPLICATION_AUTH_SHIB_ATTRIBUTE_LAST_NAME": "lastName" + "auth.shib.attribute.lastName": "lastName" }, { - "APPLICATION_AUTH_SHIB_ATTRIBUTE_INSTITUTION_IDENTIFIER": "institutionid" + "auth.shib.attribute.institutionIdentifier": "institutionid" }, { - "APPLICATION_AUTH_SHIB_ATTRIBUTE_INSTITUTIONAL_IDENTIFIER": "uin" + "auth.shib.attribute.institutionalIdentifier": "uin" }, { - "APPLICATION_AUTH_SHIB_ATTRIBUTE_MIDDLE_NAME": "middleName" + "auth.shib.attribute.middleName": "middleName" }, { - "APPLICATION_AUTH_SHIB_ATTRIBUTE_BIRTH_YEAR": "birthYear" + "auth.shib.attribute.birthYear": "birthYear" }, { - "APPLICATION_AUTH_SHIB_ATTRIBUTE_AFFILIATIONS": "affiliations" + "auth.shib.attribute.affiliations": "affiliations" }, { - "APPLICATION_AUTH_SHIB_ATTRIBUTE_CURRENT_PHONE_NUMBER": "currentPhoneNumber" + "auth.shib.attribute.currentPhoneNumber": "currentPhoneNumber" }, { - "APPLICATION_AUTH_SHIB_ATTRIBUTE_CURRENT_POSTAL_ADDRESS": "currentPostalAddress" + "auth.shib.attribute.currentPostalAddress": "currentPostalAddress" }, { - "APPLICATION_AUTH_SHIB_ATTRIBUTE_CURRENT_EMAIL_ADDRESS": "currentEmailAddress" + "auth.shib.attribute.currentEmailAddress": "currentEmailAddress" }, { - "APPLICATION_AUTH_SHIB_ATTRIBUTE_PERMANENT_PHONE_NUMBER": "permanentPhoneNumber" + "auth.shib.attribute.permanentPhoneNumber": "permanentPhoneNumber" }, { - "APPLICATION_AUTH_SHIB_ATTRIBUTE_PERMANENT_POSTAL_ADDRESS": "permanentPostalAddress" + "auth.shib.attribute.permanentPostalAddress": "permanentPostalAddress" }, { - "APPLICATION_AUTH_SHIB_ATTRIBUTE_PERMANENT_EMAIL_ADDRESS": "permanentEmailAddress" + "auth.shib.attribute.permanentEmailAddress": "permanentEmailAddress" }, { - "APPLICATION_AUTH_SHIB_ATTRIBUTE_CURRENT_DEGREE": "currentDegree" + "auth.shib.attribute.currentDegree": "currentDegree" }, { - "APPLICATION_AUTH_SHIB_ATTRIBUTE_CURRENT_DEPARTMENT": "currentDepartment" + "auth.shib.attribute.currentDepartment": "currentDepartment" }, { - "APPLICATION_AUTH_SHIB_ATTRIBUTE_CURRENT_COLLEGE": "currentCollege" + "auth.shib.attribute.currentCollege": "currentCollege" }, { - "APPLICATION_AUTH_SHIB_ATTRIBUTE_CURRENT_MAJOR": "currentMajor" + "auth.shib.attribute.currentMajor": "currentMajor" }, { - "APPLICATION_AUTH_SHIB_ATTRIBUTE_CURRENT_GRADUATION_YEAR": "currentGraduationYear" + "auth.shib.attribute.currentGraduationYear": "currentGraduationYear" }, { - "APPLICATION_AUTH_SHIB_ATTRIBUTE_CURRENT_GRADUATION_MONTH": "currentGraduationMonth" + "auth.shib.attribute.currentGraduationMonth": "currentGraduationMonth" }, { - "APPLICATION_AUTH_SHIB_ATTRIBUTE_ORCID": "orcid" + "auth.shib.attribute.orcid": "orcid" } ] -} \ No newline at end of file +} diff --git a/src/main/resources/submission_list_columns/SYSTEM_Default_Submission_List_Columns.json b/src/main/resources/submission_list_columns/SYSTEM_Default_Submission_List_Columns.json index b81bf84e02..78fbefc6db 100644 --- a/src/main/resources/submission_list_columns/SYSTEM_Default_Submission_List_Columns.json +++ b/src/main/resources/submission_list_columns/SYSTEM_Default_Submission_List_Columns.json @@ -162,7 +162,8 @@ "title": "Last Event", "sort": "NONE", "valuePath": [ - "lastEvent" + "lastAction", + "entry" ], "status": null, "inputType": { @@ -172,10 +173,13 @@ { "title": "Event Time", "sort": "NONE", - "valuePath": [], + "valuePath": [ + "lastAction", + "actionDate" + ], "status": null, "inputType": { - "name": "INPUT_TEXT" + "name": "INPUT_DATE" } }, { @@ -221,5 +225,24 @@ "inputType": { "name": "INPUT_TEXT" } + }, + { + "title": "Graduation Semester (List)", + "sort": "NONE", + "predicate": "dc.date.issued", + "valuePath": [], + "status": null, + "inputType": { + "name": "INPUT_DEGREEDATE" + } + }, + { + "title": "Student Name", + "sort": "ASC", + "predicate": "last_name, first_name middle_name", + "status": null, + "inputType": { + "name": "INPUT_TEXT" + } } ] diff --git a/src/main/webapp/app/controllers/submission/adminSubmissionViewController.js b/src/main/webapp/app/controllers/submission/adminSubmissionViewController.js index 0e9cd011d4..2bdacc0c18 100644 --- a/src/main/webapp/app/controllers/submission/adminSubmissionViewController.js +++ b/src/main/webapp/app/controllers/submission/adminSubmissionViewController.js @@ -1,4 +1,4 @@ -vireo.controller("AdminSubmissionViewController", function ($anchorScroll, $controller, $location, $routeParams, $scope, $timeout, DepositLocationRepo, EmailRecipient, EmailRecipientType, EmailTemplateRepo, EmbargoRepo, FieldPredicateRepo, FieldValue, FileUploadService, SidebarService, SubmissionRepo, SubmissionStatuses, SubmissionStatusRepo, UserRepo, UserService, UserSettings, WsApi) { +vireo.controller("AdminSubmissionViewController", function ($anchorScroll, $controller, $filter, $location, $routeParams, $scope, $timeout, DepositLocationRepo, EmailRecipient, EmailRecipientType, EmailTemplateRepo, EmbargoRepo, FieldPredicateRepo, FieldValue, FileUploadService, SidebarService, SubmissionRepo, SubmissionStatuses, SubmissionStatusRepo, UserRepo, UserService, UserSettings, WsApi) { angular.extend(this, $controller('AbstractController', { $scope: $scope @@ -590,14 +590,18 @@ vireo.controller("AdminSubmissionViewController", function ($anchorScroll, $cont "hasPrimaryDocument": $scope.hasPrimaryDocument }; + var getLastActionLog = function() { + if ($scope.submission.actionLogs.length > 0) { + return $filter('orderBy')($scope.submission.actionLogs, 'actionDate', true)[0]; + } + } + var getLastActionDate = function() { - var index = $scope.submission.actionLogs.length - 1; - return $scope.submission.actionLogs[index].actionDate; + return getLastActionLog().actionDate; }; var getLastActionEntry = function() { - var index = $scope.submission.actionLogs.length - 1; - return $scope.submission.actionLogs[index].entry; + return getLastActionLog().entry; }; var isUmiRelease = function() { diff --git a/src/main/webapp/app/controllers/submission/submissionListController.js b/src/main/webapp/app/controllers/submission/submissionListController.js index 06fc7008fc..96262e07d5 100644 --- a/src/main/webapp/app/controllers/submission/submissionListController.js +++ b/src/main/webapp/app/controllers/submission/submissionListController.js @@ -164,7 +164,7 @@ vireo.controller("SubmissionListController", function (NgTableParams, $controlle if (!!allSubmissionListFilters) { submissionListColumns = allSubmissionListFilters.filter(function excludeCustomFilters(slc) { - return slc.title !== 'Search Box' && slc.title !== "Submission Type (List)" && slc.title !== "Embargo Type"; + return slc.title !== 'Search Box' && slc.title !== "Submission Type (List)" && slc.title !== "Graduation Semester (List)" && slc.title !== "Embargo Type"; }); submissionListColumnsForManage = allSubmissionListFilters.filter(function excludeSearchBox(slc) { @@ -189,10 +189,7 @@ vireo.controller("SubmissionListController", function (NgTableParams, $controlle $scope.columns = angular.fromJson(angular.toJson($filter('orderBy')($filter('exclude')(submissionListColumns, $scope.excludedColumns, 'title'), 'title'))); - angular.extend(filterColumns, { - userFilterColumns: managerFilterColumns, - inactiveFilterColumns: $filter('orderBy')($filter('exclude')(submissionListColumnsForManage, managerFilterColumns, 'title'), 'title') - }); + setFilterColumns(managerFilterColumns, $filter('orderBy')($filter('exclude')(submissionListColumnsForManage, managerFilterColumns, 'title'), 'title')); if (reloadList === true) { query(); @@ -203,6 +200,10 @@ vireo.controller("SubmissionListController", function (NgTableParams, $controlle update(true); + const withoutActiveFilter = function(value) { + return $scope.activeFilters.namedSearchFilters.filter((nsf) => nsf.filterValues.indexOf(value) >= 0).length == 0; + }; + var assignableUsers = UserRepo.getAssignableUsers(0, 0); var savedFilters = SavedFilterRepo.getAll(); var emailTemplates = EmailTemplateRepo.getAll(); @@ -217,6 +218,34 @@ vireo.controller("SubmissionListController", function (NgTableParams, $controlle var packagers = PackagerRepo.getAll(); var controlledVocabularies = ControlledVocabularyRepo.getAll(); var submissionTypeList = FieldValueRepo.findValuesByPredicateValue('submission_type'); + var graduationSemesters = FieldValueRepo.findValuesByPredicateValue('dc.date.issued', function (a, b) { + try { + if (typeof a !== 'string' || typeof b !== 'string') { + throw new Error('Invalid input type. Both inputs must be strings.'); + } + + const regex = /^[A-Za-z]+\s\d{4}$/; + + if (!regex.test(a) || !regex.test(b)) { + throw new Error('Invalid input format. Inputs must be in the format "Month Year".'); + } + + const [monthA, yearA] = a.split(' '); + const [monthB, yearB] = b.split(' '); + + const dateA = new Date(`${monthA} 1, ${yearA}`); + const dateB = new Date(`${monthB} 1, ${yearB}`); + + if (isNaN(dateA) || isNaN(dateB)) { + throw new Error('Invalid date. Inputs must be valid dates.'); + } + + return dateB - dateA; + } catch (error) { + console.error(error.message); + return 0; + } + }); var addBatchCommentEmail = function (message) { batchCommentEmail.adding = true; @@ -351,6 +380,16 @@ vireo.controller("SubmissionListController", function (NgTableParams, $controlle }); }; + var hasSinglePredicate = (c) => c.predicate === undefined || c.predicate === null || c.predicate.trim().indexOf(' ') === -1; + + var setFilterColumns = function(userFilterColumns, inactiveFilterColumns) { + // exclude columns which have multiple predicates + angular.extend(filterColumns, { + userFilterColumns: userFilterColumns.filter(hasSinglePredicate), + inactiveFilterColumns: inactiveFilterColumns.filter(hasSinglePredicate) + }); + } + $scope.addRowFilter = function ($index, row) { // When removing the last row for a page, and the page number is the last if ($scope.page.content.length == 1 && $scope.page.number > 0 && $scope.page.number == $scope.page.totalPages) { @@ -541,18 +580,12 @@ vireo.controller("SubmissionListController", function (NgTableParams, $controlle var value = ""; for (var j in array) { var member = array[j]; - if (member.fieldPredicate !== undefined) { - if (member.fieldPredicate.value === col.predicate) { - value += value.length > 0 ? ", " + member.value : member.value; - } - } else { - var path = col.valuePath; - var curr = member; - for (var p = 1; p < path.length; p++) { - curr = curr[path[p]]; - } - value += value.length > 0 ? ", " + curr : curr; + var path = col.valuePath; + var curr = member; + for (var p = 1; p < path.length; p++) { + curr = curr[path[p]]; } + value += value.length > 0 ? ", " + curr : curr; } return value; }; @@ -625,6 +658,8 @@ vireo.controller("SubmissionListController", function (NgTableParams, $controlle "embargos": embargos, "submissionTypeList": submissionTypeList, "assignableUsers": assignableUsers, + "graduationSemesters": graduationSemesters, + "withoutActiveFilter": withoutActiveFilter, "defaultLimit": 3, "getTypeAheadByPredicateName": getTypeAheadByPredicateName, "datepickerOptions": datepickerOptions @@ -646,6 +681,8 @@ vireo.controller("SubmissionListController", function (NgTableParams, $controlle "submissionStatuses": submissionStatuses, "newStatus": submissionStatuses[0], "assignableUsers": assignableUsers, + "graduationSemesters": graduationSemesters, + "withoutActiveFilter": withoutActiveFilter, "batchAssignTo": batchAssignTo, "batchPublish": batchPublish, "resetBatchCommentEmailModal": resetBatchCommentEmailModal, @@ -666,25 +703,35 @@ vireo.controller("SubmissionListController", function (NgTableParams, $controlle $scope.getSubmissionProperty = function (row, col) { var value; - for (var i in col.valuePath) { - if(typeof col.valuePath[i] !== 'function') { - if (value === undefined) { - value = row[col.valuePath[i]]; - } else { - if (value instanceof Array) { - return getValueFromArray(value, col); + if (row.columnValues !== undefined) { + value = row.columnValues[col.id]; + } else { + console.error('row.columnValues is undefined') + } + + // check value path to get values + if (value === undefined) { + for (var i in col.valuePath) { + if (typeof col.valuePath[i] !== 'function') { + if (value === undefined) { + value = row[col.valuePath[i]]; } else { - if (value !== null) { - if (col.valuePath[0] === "assignee") { - value = getAssigneeDisplayName(row); - } else { - value = value[col.valuePath[i]]; + if (value instanceof Array) { + return getValueFromArray(value, col); + } else { + if (value !== null) { + if (col.valuePath[0] === "assignee") { + value = getAssigneeDisplayName(row); + } else { + value = value[col.valuePath[i]]; + } } } } } } } + return value; }; @@ -780,10 +827,7 @@ vireo.controller("SubmissionListController", function (NgTableParams, $controlle var userFilterColumns = filtersPreviouslyDisplayed.concat(filterColumns.userFilterColumns); var inactiveFilterColumns = filtersPreviouslyDisabled.concat(filterColumns.inactiveFilterColumns); - angular.extend(filterColumns, { - userFilterColumns: userFilterColumns, - inactiveFilterColumns: inactiveFilterColumns - }); + setFilterColumns(userFilterColumns, inactiveFilterColumns); updateChange(false); }; diff --git a/src/main/webapp/app/repo/fieldValueRepo.js b/src/main/webapp/app/repo/fieldValueRepo.js index cecb285460..54a673e354 100644 --- a/src/main/webapp/app/repo/fieldValueRepo.js +++ b/src/main/webapp/app/repo/fieldValueRepo.js @@ -2,7 +2,7 @@ vireo.repo("FieldValueRepo", function FieldValueRepo(FieldValue, WsApi) { var fieldValueRepo = this; - fieldValueRepo.findValuesByPredicateValue = function(value) { + fieldValueRepo.findValuesByPredicateValue = function(value, sort) { var fieldValues = []; // FieldValue exists on the API Mapping but is under the Submission controller, which is not correct and so manually define the entire mapping inline here. @@ -20,6 +20,10 @@ vireo.repo("FieldValueRepo", function FieldValueRepo(FieldValue, WsApi) { for (var i in values) { fieldValues.push(values[i]); } + + if (sort) { + fieldValues = fieldValues.sort(sort); + } } } }); diff --git a/src/main/webapp/app/views/admin/settings/workflow/shibbolethAttributes.html b/src/main/webapp/app/views/admin/settings/workflow/shibbolethAttributes.html index fc34c62006..156d288370 100644 --- a/src/main/webapp/app/views/admin/settings/workflow/shibbolethAttributes.html +++ b/src/main/webapp/app/views/admin/settings/workflow/shibbolethAttributes.html @@ -1,252 +1,252 @@
-
-
- - - - - - - - - - - - - - - - - - - - - - -
-
-
-
- - - - - - - - - - - - - - - - - - - - - - -
-
+
+
+ + + + + + + + + + + + + + + + + + + + + + +
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + +
+
diff --git a/src/main/webapp/app/views/sideboxes/furtherFilterBy/furtherFilterBy.html b/src/main/webapp/app/views/sideboxes/furtherFilterBy/furtherFilterBy.html index 73da63516d..6c2e23ae8c 100644 --- a/src/main/webapp/app/views/sideboxes/furtherFilterBy/furtherFilterBy.html +++ b/src/main/webapp/app/views/sideboxes/furtherFilterBy/furtherFilterBy.html @@ -43,6 +43,10 @@
+
+
+
+
diff --git a/src/main/webapp/app/views/sideboxes/furtherFilterBy/furtherFilterByDegreeDate.html b/src/main/webapp/app/views/sideboxes/furtherFilterBy/furtherFilterByDegreeDate.html index 4b8acb0052..cac0a5ac16 100644 --- a/src/main/webapp/app/views/sideboxes/furtherFilterBy/furtherFilterByDegreeDate.html +++ b/src/main/webapp/app/views/sideboxes/furtherFilterBy/furtherFilterByDegreeDate.html @@ -1,20 +1,20 @@
-
- - - - -
- +
+ + + + +
+
diff --git a/src/main/webapp/app/views/sideboxes/furtherFilterBy/furtherFilterByDegreeDateList.html b/src/main/webapp/app/views/sideboxes/furtherFilterBy/furtherFilterByDegreeDateList.html new file mode 100644 index 0000000000..b258c2db94 --- /dev/null +++ b/src/main/webapp/app/views/sideboxes/furtherFilterBy/furtherFilterByDegreeDateList.html @@ -0,0 +1,10 @@ +
+ +
diff --git a/src/main/webapp/tests/mocks/models/mockSubmission.js b/src/main/webapp/tests/mocks/models/mockSubmission.js index 49fdc00d95..4fddc9ab1f 100644 --- a/src/main/webapp/tests/mocks/models/mockSubmission.js +++ b/src/main/webapp/tests/mocks/models/mockSubmission.js @@ -13,6 +13,7 @@ var dataSubmission1 = { customActionValues: [], depositURL: "", fieldValues: [], + columnValues: [], organization: { id: 1, acceptsSubmissions: true, @@ -73,6 +74,7 @@ var dataSubmission2 = { customActionValues: [], depositURL: "", fieldValues: [], + columnValues: [], organization: { id: 2, acceptsSubmissions: false, @@ -124,6 +126,7 @@ var dataSubmission3 = { customActionValues: [], depositURL: "", fieldValues: [], + columnValues: [], organization: { id: 1, acceptsSubmissions: true, @@ -184,6 +187,7 @@ var dataSubmission4 = { customActionValues: [], depositURL: "", fieldValues: [], + columnValues: [], organization: { id: 1, acceptsSubmissions: true, @@ -225,6 +229,7 @@ var dataSubmission5 = { customActionValues: [], depositURL: "", fieldValues: [], + columnValues: [], organization: { id: 1, acceptsSubmissions: true, @@ -266,6 +271,7 @@ var dataSubmission6 = { customActionValues: [], depositURL: "", fieldValues: [], + columnValues: [], organization: { id: 2, acceptsSubmissions: false, diff --git a/src/main/webapp/tests/unit/controllers/settings/organizationManagementControllerTest.js b/src/main/webapp/tests/unit/controllers/settings/organizationManagementControllerTest.js index 06d112f342..6891a29554 100644 --- a/src/main/webapp/tests/unit/controllers/settings/organizationManagementControllerTest.js +++ b/src/main/webapp/tests/unit/controllers/settings/organizationManagementControllerTest.js @@ -244,6 +244,7 @@ describe("controller: OrganizationManagementController", function () { spyOn(AccordionService, "closeAll"); spyOn(OrganizationRepo, "reorderWorkflowSteps"); + scope.selectedOrganization = mockOrganization(q); scope.reorderWorkflowStepDown(1); expect(AccordionService.closeAll).toHaveBeenCalled(); @@ -253,6 +254,7 @@ describe("controller: OrganizationManagementController", function () { spyOn(AccordionService, "closeAll"); spyOn(OrganizationRepo, "reorderWorkflowSteps"); + scope.selectedOrganization = mockOrganization(q); scope.reorderWorkflowStepUp(1); expect(AccordionService.closeAll).toHaveBeenCalled(); diff --git a/src/main/webapp/tests/unit/controllers/submission/submissionListControllerTest.js b/src/main/webapp/tests/unit/controllers/submission/submissionListControllerTest.js index 2e283c3070..d1f412806b 100644 --- a/src/main/webapp/tests/unit/controllers/submission/submissionListControllerTest.js +++ b/src/main/webapp/tests/unit/controllers/submission/submissionListControllerTest.js @@ -352,8 +352,8 @@ describe("controller: SubmissionListController", function () { expect(scope.columns.length).toBe(1); }); it("displaySubmissionProperty should return a value", function () { - var row = {}; - var column = { inputType: mockInputType(q) }; + var row = { columnValues: [] }; + var column = { inputType: mockInputType(q), id: 1 }; scope.displaySubmissionProperty(row, column); @@ -399,8 +399,8 @@ describe("controller: SubmissionListController", function () { }); it("getSubmissionProperty should return a property", function () { var response; - var row = { assignee: mockUser(q) }; - var column = { valuePath: [ "assignee" ] }; + var row = { assignee: mockUser(q), columnValues: [] }; + var column = { valuePath: [ "assignee" ], id: 1 }; response = scope.getSubmissionProperty(row, column); expect(response).toEqual(row.assignee); diff --git a/src/test/java/org/tdl/vireo/model/EmailRecipientContactTest.java b/src/test/java/org/tdl/vireo/model/EmailRecipientContactTest.java index ff00b906ec..53a0e6c9d4 100644 --- a/src/test/java/org/tdl/vireo/model/EmailRecipientContactTest.java +++ b/src/test/java/org/tdl/vireo/model/EmailRecipientContactTest.java @@ -3,6 +3,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.Mockito.when; import java.util.ArrayList; @@ -44,11 +45,12 @@ public void testGetEmails() { fieldValues.add(fieldValue); fieldValues.add(otherFieldValue); fieldPredicate.setId(1L); - fieldPredicate.setValue("notnull"); + + fieldPredicate.setValue("fp_value"); ReflectionTestUtils.setField(emailRecipientContact, "fieldPredicate", fieldPredicate); - when(submission.getFieldValuesByPredicateValue(any(String.class))).thenReturn(fieldValues); + when(submission.getFieldValuesByPredicateValue(anyString())).thenReturn(fieldValues); List got = emailRecipientContact.getEmails(submission); diff --git a/src/test/java/org/tdl/vireo/model/repo/AbstractRepoTest.java b/src/test/java/org/tdl/vireo/model/repo/AbstractRepoTest.java index 80c272910c..184e8c5c9f 100644 --- a/src/test/java/org/tdl/vireo/model/repo/AbstractRepoTest.java +++ b/src/test/java/org/tdl/vireo/model/repo/AbstractRepoTest.java @@ -133,6 +133,8 @@ public abstract class AbstractRepoTest { // WorkFlow test protected static final String TEST_WORKFLOW_NAME = "Test Workflow"; protected static final String TEST_GLOSS = "Test Gloss"; + protected static final String TEST_GLOSS_2 = "Test Gloss 2"; + protected static final String TEST_GLOSS_3 = "Test Gloss 3"; protected static final String TEST_SEVERABLE_GLOSS = "Test Severable Gloss"; // Organization Category test diff --git a/src/test/java/org/tdl/vireo/model/repo/FieldProfileRepoTest.java b/src/test/java/org/tdl/vireo/model/repo/FieldProfileRepoTest.java index 21627b1ffe..446d9ca1d6 100644 --- a/src/test/java/org/tdl/vireo/model/repo/FieldProfileRepoTest.java +++ b/src/test/java/org/tdl/vireo/model/repo/FieldProfileRepoTest.java @@ -307,11 +307,11 @@ public void testInheritAndRemoveFieldProfiles() { workflowStep = workflowStepRepo.findById(workflowStep.getId()).get(); fieldPredicate = fieldPredicateRepo.findById(fieldPredicate.getId()).get(); - FieldProfile fp2 = fieldProfileRepo.create(workflowStep, fieldPredicate2, inputType, TEST_FIELD_PROFILE_USAGE, TEST_GLOSS, TEST_FIELD_PROFILE_REPEATABLE, TEST_FIELD_PROFILE_OVERRIDEABLE, TEST_FIELD_PROFILE_ENABLED, TEST_FIELD_PROFILE_OPTIONAL, TEST_FIELD_PROFILE_FLAGGED, TEST_FIELD_PROFILE_LOGGED, TEST_FIELD_PROFILE_DEFAULT_VALUE); + FieldProfile fp2 = fieldProfileRepo.create(workflowStep, fieldPredicate2, inputType, TEST_FIELD_PROFILE_USAGE, TEST_GLOSS_2, TEST_FIELD_PROFILE_REPEATABLE, TEST_FIELD_PROFILE_OVERRIDEABLE, TEST_FIELD_PROFILE_ENABLED, TEST_FIELD_PROFILE_OPTIONAL, TEST_FIELD_PROFILE_FLAGGED, TEST_FIELD_PROFILE_LOGGED, TEST_FIELD_PROFILE_DEFAULT_VALUE); workflowStep = workflowStepRepo.findById(workflowStep.getId()).get(); fieldPredicate = fieldPredicateRepo.findById(fieldPredicate.getId()).get(); - FieldProfile fp3 = fieldProfileRepo.create(workflowStep, fieldPredicate3, inputType, TEST_FIELD_PROFILE_USAGE, TEST_GLOSS, TEST_FIELD_PROFILE_REPEATABLE, TEST_FIELD_PROFILE_OVERRIDEABLE, TEST_FIELD_PROFILE_ENABLED, TEST_FIELD_PROFILE_OPTIONAL, TEST_FIELD_PROFILE_FLAGGED, TEST_FIELD_PROFILE_LOGGED, TEST_FIELD_PROFILE_DEFAULT_VALUE); + FieldProfile fp3 = fieldProfileRepo.create(workflowStep, fieldPredicate3, inputType, TEST_FIELD_PROFILE_USAGE, TEST_GLOSS_3, TEST_FIELD_PROFILE_REPEATABLE, TEST_FIELD_PROFILE_OVERRIDEABLE, TEST_FIELD_PROFILE_ENABLED, TEST_FIELD_PROFILE_OPTIONAL, TEST_FIELD_PROFILE_FLAGGED, TEST_FIELD_PROFILE_LOGGED, TEST_FIELD_PROFILE_DEFAULT_VALUE); workflowStep = workflowStepRepo.findById(workflowStep.getId()).get(); fieldPredicate = fieldPredicateRepo.findById(fieldPredicate.getId()).get(); @@ -458,11 +458,11 @@ public void testReorderAggregateFieldProfiles() throws WorkflowStepNonOverrideab workflowStep = workflowStepRepo.findById(workflowStep.getId()).get(); fieldPredicate = fieldPredicateRepo.findById(fieldPredicate.getId()).get(); - FieldProfile fp2 = fieldProfileRepo.create(workflowStep, fieldPredicate2, inputType, TEST_FIELD_PROFILE_USAGE, TEST_GLOSS, TEST_FIELD_PROFILE_REPEATABLE, TEST_FIELD_PROFILE_OVERRIDEABLE, TEST_FIELD_PROFILE_ENABLED, TEST_FIELD_PROFILE_OPTIONAL, TEST_FIELD_PROFILE_FLAGGED, TEST_FIELD_PROFILE_LOGGED, TEST_FIELD_PROFILE_DEFAULT_VALUE); + FieldProfile fp2 = fieldProfileRepo.create(workflowStep, fieldPredicate2, inputType, TEST_FIELD_PROFILE_USAGE, TEST_GLOSS_2, TEST_FIELD_PROFILE_REPEATABLE, TEST_FIELD_PROFILE_OVERRIDEABLE, TEST_FIELD_PROFILE_ENABLED, TEST_FIELD_PROFILE_OPTIONAL, TEST_FIELD_PROFILE_FLAGGED, TEST_FIELD_PROFILE_LOGGED, TEST_FIELD_PROFILE_DEFAULT_VALUE); workflowStep = workflowStepRepo.findById(workflowStep.getId()).get(); fieldPredicate = fieldPredicateRepo.findById(fieldPredicate.getId()).get(); - FieldProfile fp3 = fieldProfileRepo.create(workflowStep, fieldPredicate3, inputType, TEST_FIELD_PROFILE_USAGE, TEST_GLOSS, TEST_FIELD_PROFILE_REPEATABLE, TEST_FIELD_PROFILE_OVERRIDEABLE, TEST_FIELD_PROFILE_ENABLED, TEST_FIELD_PROFILE_OPTIONAL, TEST_FIELD_PROFILE_FLAGGED, TEST_FIELD_PROFILE_LOGGED, TEST_FIELD_PROFILE_DEFAULT_VALUE); + FieldProfile fp3 = fieldProfileRepo.create(workflowStep, fieldPredicate3, inputType, TEST_FIELD_PROFILE_USAGE, TEST_GLOSS_3, TEST_FIELD_PROFILE_REPEATABLE, TEST_FIELD_PROFILE_OVERRIDEABLE, TEST_FIELD_PROFILE_ENABLED, TEST_FIELD_PROFILE_OPTIONAL, TEST_FIELD_PROFILE_FLAGGED, TEST_FIELD_PROFILE_LOGGED, TEST_FIELD_PROFILE_DEFAULT_VALUE); workflowStep = workflowStepRepo.findById(workflowStep.getId()).get(); fieldPredicate = fieldPredicateRepo.findById(fieldPredicate.getId()).get(); @@ -761,11 +761,11 @@ public void testMaintainFieldOrderWhenOverriding() throws HeritableModelNonOverr workflowStep = workflowStepRepo.findById(workflowStep.getId()).get(); fieldPredicate = fieldPredicateRepo.findById(fieldPredicate.getId()).get(); - FieldProfile fp2 = fieldProfileRepo.create(workflowStep, fieldPredicate2, inputType, TEST_FIELD_PROFILE_USAGE, TEST_GLOSS, TEST_FIELD_PROFILE_REPEATABLE, TEST_FIELD_PROFILE_OVERRIDEABLE, TEST_FIELD_PROFILE_ENABLED, TEST_FIELD_PROFILE_OPTIONAL, TEST_FIELD_PROFILE_FLAGGED, TEST_FIELD_PROFILE_LOGGED, TEST_FIELD_PROFILE_DEFAULT_VALUE); + FieldProfile fp2 = fieldProfileRepo.create(workflowStep, fieldPredicate2, inputType, TEST_FIELD_PROFILE_USAGE, TEST_GLOSS_2, TEST_FIELD_PROFILE_REPEATABLE, TEST_FIELD_PROFILE_OVERRIDEABLE, TEST_FIELD_PROFILE_ENABLED, TEST_FIELD_PROFILE_OPTIONAL, TEST_FIELD_PROFILE_FLAGGED, TEST_FIELD_PROFILE_LOGGED, TEST_FIELD_PROFILE_DEFAULT_VALUE); workflowStep = workflowStepRepo.findById(workflowStep.getId()).get(); fieldPredicate = fieldPredicateRepo.findById(fieldPredicate.getId()).get(); - fieldProfileRepo.create(workflowStep, fieldPredicate3, inputType, TEST_FIELD_PROFILE_USAGE, TEST_GLOSS, TEST_FIELD_PROFILE_REPEATABLE, TEST_FIELD_PROFILE_OVERRIDEABLE, TEST_FIELD_PROFILE_ENABLED, TEST_FIELD_PROFILE_OPTIONAL, TEST_FIELD_PROFILE_FLAGGED, TEST_FIELD_PROFILE_LOGGED, TEST_FIELD_PROFILE_DEFAULT_VALUE); + fieldProfileRepo.create(workflowStep, fieldPredicate3, inputType, TEST_FIELD_PROFILE_USAGE, TEST_GLOSS_3, TEST_FIELD_PROFILE_REPEATABLE, TEST_FIELD_PROFILE_OVERRIDEABLE, TEST_FIELD_PROFILE_ENABLED, TEST_FIELD_PROFILE_OPTIONAL, TEST_FIELD_PROFILE_FLAGGED, TEST_FIELD_PROFILE_LOGGED, TEST_FIELD_PROFILE_DEFAULT_VALUE); workflowStep = workflowStepRepo.findById(workflowStep.getId()).get(); fieldPredicate = fieldPredicateRepo.findById(fieldPredicate.getId()).get(); @@ -822,11 +822,11 @@ public void testMakeFieldProfileNonOverrideable() throws HeritableModelNonOverri workflowStep = workflowStepRepo.findById(wsId).get(); fieldPredicate = fieldPredicateRepo.findById(fieldPredicate.getId()).get(); - FieldProfile fp2 = fieldProfileRepo.create(workflowStep, fieldPredicate2, inputType, TEST_FIELD_PROFILE_USAGE, TEST_GLOSS, TEST_FIELD_PROFILE_REPEATABLE, TEST_FIELD_PROFILE_OVERRIDEABLE, TEST_FIELD_PROFILE_ENABLED, TEST_FIELD_PROFILE_OPTIONAL, TEST_FIELD_PROFILE_FLAGGED, TEST_FIELD_PROFILE_LOGGED, TEST_FIELD_PROFILE_DEFAULT_VALUE); + FieldProfile fp2 = fieldProfileRepo.create(workflowStep, fieldPredicate2, inputType, TEST_FIELD_PROFILE_USAGE, TEST_GLOSS_2, TEST_FIELD_PROFILE_REPEATABLE, TEST_FIELD_PROFILE_OVERRIDEABLE, TEST_FIELD_PROFILE_ENABLED, TEST_FIELD_PROFILE_OPTIONAL, TEST_FIELD_PROFILE_FLAGGED, TEST_FIELD_PROFILE_LOGGED, TEST_FIELD_PROFILE_DEFAULT_VALUE); workflowStep = workflowStepRepo.findById(wsId).get(); fieldPredicate = fieldPredicateRepo.findById(fieldPredicate.getId()).get(); - /* FieldProfile fp3 = */ fieldProfileRepo.create(workflowStep, fieldPredicate3, inputType, TEST_FIELD_PROFILE_USAGE, TEST_GLOSS, TEST_FIELD_PROFILE_REPEATABLE, TEST_FIELD_PROFILE_OVERRIDEABLE, TEST_FIELD_PROFILE_ENABLED, TEST_FIELD_PROFILE_OPTIONAL, TEST_FIELD_PROFILE_FLAGGED, TEST_FIELD_PROFILE_LOGGED, TEST_FIELD_PROFILE_DEFAULT_VALUE); + /* FieldProfile fp3 = */ fieldProfileRepo.create(workflowStep, fieldPredicate3, inputType, TEST_FIELD_PROFILE_USAGE, TEST_GLOSS_3, TEST_FIELD_PROFILE_REPEATABLE, TEST_FIELD_PROFILE_OVERRIDEABLE, TEST_FIELD_PROFILE_ENABLED, TEST_FIELD_PROFILE_OPTIONAL, TEST_FIELD_PROFILE_FLAGGED, TEST_FIELD_PROFILE_LOGGED, TEST_FIELD_PROFILE_DEFAULT_VALUE); workflowStep = workflowStepRepo.findById(wsId).get(); fieldPredicate = fieldPredicateRepo.findById(fieldPredicate.getId()).get(); @@ -928,11 +928,11 @@ public void testDeleteFPAtDescendantOrgAndDuplicateWSIsDeletedToo() throws Herit workflowStep = workflowStepRepo.findById(workflowStep.getId()).get(); fieldPredicate = fieldPredicateRepo.findById(fieldPredicate.getId()).get(); - /* FieldProfile fp2 = */ fieldProfileRepo.create(workflowStep, fieldPredicate2, inputType, TEST_FIELD_PROFILE_USAGE, TEST_GLOSS, TEST_FIELD_PROFILE_REPEATABLE, TEST_FIELD_PROFILE_OVERRIDEABLE, TEST_FIELD_PROFILE_ENABLED, TEST_FIELD_PROFILE_OPTIONAL, TEST_FIELD_PROFILE_FLAGGED, TEST_FIELD_PROFILE_LOGGED, TEST_FIELD_PROFILE_DEFAULT_VALUE); + /* FieldProfile fp2 = */ fieldProfileRepo.create(workflowStep, fieldPredicate2, inputType, TEST_FIELD_PROFILE_USAGE, TEST_GLOSS_2, TEST_FIELD_PROFILE_REPEATABLE, TEST_FIELD_PROFILE_OVERRIDEABLE, TEST_FIELD_PROFILE_ENABLED, TEST_FIELD_PROFILE_OPTIONAL, TEST_FIELD_PROFILE_FLAGGED, TEST_FIELD_PROFILE_LOGGED, TEST_FIELD_PROFILE_DEFAULT_VALUE); workflowStep = workflowStepRepo.findById(workflowStep.getId()).get(); fieldPredicate = fieldPredicateRepo.findById(fieldPredicate.getId()).get(); - /* FieldProfile fp3 = */ fieldProfileRepo.create(workflowStep, fieldPredicate3, inputType, TEST_FIELD_PROFILE_USAGE, TEST_GLOSS, TEST_FIELD_PROFILE_REPEATABLE, TEST_FIELD_PROFILE_OVERRIDEABLE, TEST_FIELD_PROFILE_ENABLED, TEST_FIELD_PROFILE_OPTIONAL, TEST_FIELD_PROFILE_FLAGGED, TEST_FIELD_PROFILE_LOGGED, TEST_FIELD_PROFILE_DEFAULT_VALUE); + /* FieldProfile fp3 = */ fieldProfileRepo.create(workflowStep, fieldPredicate3, inputType, TEST_FIELD_PROFILE_USAGE, TEST_GLOSS_3, TEST_FIELD_PROFILE_REPEATABLE, TEST_FIELD_PROFILE_OVERRIDEABLE, TEST_FIELD_PROFILE_ENABLED, TEST_FIELD_PROFILE_OPTIONAL, TEST_FIELD_PROFILE_FLAGGED, TEST_FIELD_PROFILE_LOGGED, TEST_FIELD_PROFILE_DEFAULT_VALUE); workflowStep = workflowStepRepo.findById(workflowStep.getId()).get(); fieldPredicate = fieldPredicateRepo.findById(fieldPredicate.getId()).get(); diff --git a/src/test/java/org/tdl/vireo/service/SystemDataLoaderTest.java b/src/test/java/org/tdl/vireo/service/SystemDataLoaderTest.java index 815d03671f..4b9fa9f5ef 100644 --- a/src/test/java/org/tdl/vireo/service/SystemDataLoaderTest.java +++ b/src/test/java/org/tdl/vireo/service/SystemDataLoaderTest.java @@ -274,7 +274,7 @@ private void assertWorkflowStep(boolean isReload) { ? "Incorrect number of workflowStep found after reload" : "Incorrect number of workflowStep found"); - + assertWorkflowStepHeritableProperties(new int[] { 3, 18 }, "Personal Information", isReload); assertWorkflowStepHeritableProperties(new int[] { 0, 2 }, "License Agreement", isReload); assertWorkflowStepHeritableProperties(new int[] { 4, 13 }, "Document Information", isReload); @@ -480,19 +480,19 @@ private void assertSubmissionStatusState(SubmissionState expected, SubmissionSta private void assertSubmissionStatusTransitions(String[] expected, SubmissionStatus actual, boolean isReload) { assertEquals(expected.length, actual.getTransitionSubmissionStatuses().size(), - isReload + isReload ? String.format("%s submission status has incorrect number of transition status after reload", actual.getName()) : String.format("%s submission status has incorrect number of transition status", actual.getName())); for (String name : expected) { assertTrue(actual.getTransitionSubmissionStatuses().stream().anyMatch(ts -> ts.getName().equals(name)), - isReload + isReload ? String.format("%s submission status is missing %s transition status after reload", actual.getName(), name) : String.format("%s submission status is missing %s transition status", actual.getName(), name)); } } private void assertSubmissionListColumn(boolean isReload) { - assertEquals(61, submissionListColumnRepo.count(), + assertEquals(63, submissionListColumnRepo.count(), isReload ? "Incorrect number of submissionListColumn found after reload" : "Incorrect number of submissionListColumn found");