Skip to content

Commit

Permalink
Merge pull request #1137 from ericenns/spring-hateoas-1.0
Browse files Browse the repository at this point in the history
Spring hateoas 1.0
  • Loading branch information
deepsidhu85 authored Dec 16, 2021
2 parents 88e8067 + 488cc51 commit a310805
Show file tree
Hide file tree
Showing 65 changed files with 209 additions and 206 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Changes
* [UI]: Refactored share/move samples between projects to use a separate page.
* [UI]: Added capability to share/move samples between projects from the line list page.
* [UI]: Fixed issue with dynamic pipeline parameters with only one value not rendering.
* [Developer]: Upgraded Spring Hateoas to 1.0.3.RELEASE

21.05 to 21.09
--------------
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1160,7 +1160,7 @@
<commons.fileupload.version>1.3.1</commons.fileupload.version>
<javax.el-api.version>3.0.0</javax.el-api.version>
<javax.servlet-api.version>3.1.0</javax.servlet-api.version>
<spring.hateoas.version>0.19.0.RELEASE</spring.hateoas.version>
<spring.hateoas.version>1.0.3.RELEASE</spring.hateoas.version>
<el.ri.version>1.0</el.ri.version>
<oltu.version>1.0.0</oltu.version>
<thymeleaf.version>3.0.9.RELEASE</thymeleaf.version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@

import java.util.ArrayList;
import java.util.List;
import java.util.Optional;

import javax.xml.bind.annotation.XmlElement;

import org.springframework.hateoas.IanaLinkRelations;
import org.springframework.hateoas.Link;
import org.springframework.hateoas.ResourceSupport;
import org.springframework.hateoas.RepresentationModel;
import org.springframework.util.Assert;

import com.fasterxml.jackson.annotation.JsonIgnore;
Expand All @@ -17,15 +19,15 @@

/**
* Adds a collection of {@link Link}s to extending objects. Similar to
* {@link ResourceSupport}
* {@link RepresentationModel}
*
* @see ResourceSupport
* @see RepresentationModel
*
*/
public class IridaResourceSupport {
public class IridaRepresentationModel {
private final List<Link> links;

public IridaResourceSupport() {
public IridaRepresentationModel() {
this.links = new ArrayList<Link>();
}

Expand Down Expand Up @@ -98,15 +100,15 @@ public void removeLinks() {
* the String rel to get a link for
* @return the link with the given rel or {@literal null} if none found.
*/
public Link getLink(String rel) {
public Optional<Link> getLink(String rel) {

for (Link link : links) {
if (link.getRel().equals(rel)) {
return link;
if (link.getRel().value().equals(rel)) {
return Optional.of(link);
}
}

return null;
return Optional.empty();
}

/**
Expand All @@ -131,7 +133,7 @@ public boolean equals(Object obj) {
return false;
}

IridaResourceSupport that = (IridaResourceSupport) obj;
IridaRepresentationModel that = (IridaRepresentationModel) obj;

return this.links.equals(that.links);
}
Expand All @@ -152,11 +154,8 @@ public int hashCode() {
*/
@JsonIgnore
public String getSelfHref() {
Link link = getLink(Link.REL_SELF);
if (link != null) {
return link.getHref();
}
return null;
Optional<Link> link = getLink(IanaLinkRelations.SELF.value());
return link.map(i -> i.getHref()).orElse(null);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import org.slf4j.LoggerFactory;
import org.springframework.data.annotation.CreatedDate;

import ca.corefacility.bioinformatics.irida.model.IridaResourceSupport;
import ca.corefacility.bioinformatics.irida.model.IridaRepresentationModel;
import ca.corefacility.bioinformatics.irida.model.IridaThing;
import ca.corefacility.bioinformatics.irida.model.VersionedFileFields;
import ca.corefacility.bioinformatics.irida.model.irida.IridaSequenceFile;
Expand All @@ -33,7 +33,7 @@
@Table(name = "genome_assembly")
@Inheritance(strategy = InheritanceType.JOINED)
@Audited
public abstract class GenomeAssembly extends IridaResourceSupport
public abstract class GenomeAssembly extends IridaRepresentationModel
implements IridaThing, IridaSequenceFile, VersionedFileFields<Long> {

private static final Logger logger = LoggerFactory.getLogger(GenomeAssembly.class);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package ca.corefacility.bioinformatics.irida.model.project;

import ca.corefacility.bioinformatics.irida.model.IridaResourceSupport;
import ca.corefacility.bioinformatics.irida.model.IridaRepresentationModel;
import ca.corefacility.bioinformatics.irida.model.MutableIridaThing;
import ca.corefacility.bioinformatics.irida.model.NcbiExportSubmission;
import ca.corefacility.bioinformatics.irida.model.event.ProjectEvent;
Expand Down Expand Up @@ -40,7 +40,7 @@
@Table(name = "project")
@Audited
@EntityListeners(AuditingEntityListener.class)
public class Project extends IridaResourceSupport
public class Project extends IridaRepresentationModel
implements MutableIridaThing, Comparable<Project>, RemoteSynchronizable {

@Id
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
package ca.corefacility.bioinformatics.irida.model.remote.resource;

import ca.corefacility.bioinformatics.irida.model.IridaResourceSupport;
import ca.corefacility.bioinformatics.irida.model.IridaRepresentationModel;

/**
* Object wrapping a list of returned resources from a remote IRIDA API. This
* type will be returned when listing objects from the API. Example: "/projects"
*
* @param <Type>
* The type of object being stored in the list extends
* {@link IridaResourceSupport}
* {@link IridaRepresentationModel}
*/
public class ListResourceWrapper<Type extends IridaResourceSupport> {
public class ListResourceWrapper<Type extends IridaRepresentationModel> {
private ResourceList<Type> resource;

public ResourceList<Type> getResource() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

import java.util.List;

import ca.corefacility.bioinformatics.irida.model.IridaResourceSupport;
import ca.corefacility.bioinformatics.irida.model.IridaRepresentationModel;

/**
* Class to hold a list of resources when being read from a remote Irida API
*
* @param <Type>
* The type of object being held in this list
*/
public class ResourceList<Type extends IridaResourceSupport> extends IridaResourceSupport{
public class ResourceList<Type extends IridaRepresentationModel> extends IridaRepresentationModel{

private List<Type> resources;
private Long totalResources;
Expand All @@ -20,31 +20,31 @@ public ResourceList() {

/**
* Get the list of resources
* @return the {@link IridaResourceSupport} collection.
* @return the {@link IridaRepresentationModel} collection.
*/
public List<Type> getResources() {
return resources;
}

/**
* Set the list of resources
* @param resources the {@link IridaResourceSupport} collection.
* @param resources the {@link IridaRepresentationModel} collection.
*/
public void setResources(List<Type> resources) {
this.resources = resources;
}

/**
* Get the total number of resources in this list
* @return the total number of {@link IridaResourceSupport} in the collection.
* @return the total number of {@link IridaRepresentationModel} in the collection.
*/
public Long getTotalResources() {
return totalResources;
}

/**
* Set the total number of resources
* @param totalResources the total number of {@link IridaResourceSupport} in the collection.
* @param totalResources the total number of {@link IridaRepresentationModel} in the collection.
*/
public void setTotalResources(Long totalResources) {
this.totalResources = totalResources;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
package ca.corefacility.bioinformatics.irida.model.remote.resource;

import ca.corefacility.bioinformatics.irida.model.IridaResourceSupport;
import ca.corefacility.bioinformatics.irida.model.IridaRepresentationModel;

/**
* Object wrapping a resource read from an Irida API
*
* @param <Type>
* The type this resource will hold (extends
* {@link IridaResourceSupport})
* {@link IridaRepresentationModel})
*/
public class ResourceWrapper<Type extends IridaResourceSupport> {
public class ResourceWrapper<Type extends IridaRepresentationModel> {
private Type resource;

/**
* Get the resource
*
* @return the {@link IridaResourceSupport} wrapped by this object.
* @return the {@link IridaRepresentationModel} wrapped by this object.
*/
public Type getResource() {
return resource;
Expand All @@ -25,7 +25,7 @@ public Type getResource() {
* Set the resource
*
* @param resource
* the {@link IridaResourceSupport} wrapped by this object.
* the {@link IridaRepresentationModel} wrapped by this object.
*/
public void setResource(Type resource) {
this.resource = resource;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package ca.corefacility.bioinformatics.irida.model.run;

import ca.corefacility.bioinformatics.irida.model.IridaResourceSupport;
import ca.corefacility.bioinformatics.irida.model.IridaRepresentationModel;
import ca.corefacility.bioinformatics.irida.model.MutableIridaThing;
import ca.corefacility.bioinformatics.irida.model.enums.SequencingRunUploadStatus;
import ca.corefacility.bioinformatics.irida.model.sequenceFile.SequencingObject;
Expand All @@ -26,7 +26,7 @@
@Audited
@Inheritance(strategy = InheritanceType.JOINED)
@EntityListeners(AuditingEntityListener.class)
public class SequencingRun extends IridaResourceSupport implements MutableIridaThing, Comparable<SequencingRun> {
public class SequencingRun extends IridaRepresentationModel implements MutableIridaThing, Comparable<SequencingRun> {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import ca.corefacility.bioinformatics.irida.model.IridaResourceSupport;
import ca.corefacility.bioinformatics.irida.model.IridaRepresentationModel;
import ca.corefacility.bioinformatics.irida.model.MutableIridaThing;
import ca.corefacility.bioinformatics.irida.model.event.SampleAddedProjectEvent;
import ca.corefacility.bioinformatics.irida.model.joins.impl.ProjectSampleJoin;
Expand Down Expand Up @@ -51,7 +51,7 @@
@Audited
@EntityListeners(AuditingEntityListener.class)
@JsonIgnoreProperties(ignoreUnknown = true)
public class Sample extends IridaResourceSupport
public class Sample extends IridaRepresentationModel
implements MutableIridaThing, Comparable<Sample>, RemoteSynchronizable {

@Id
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import ca.corefacility.bioinformatics.irida.exceptions.AnalysisAlreadySetException;
import ca.corefacility.bioinformatics.irida.model.IridaResourceSupport;
import ca.corefacility.bioinformatics.irida.model.IridaRepresentationModel;
import ca.corefacility.bioinformatics.irida.model.MutableIridaThing;
import ca.corefacility.bioinformatics.irida.model.VersionedFileFields;
import ca.corefacility.bioinformatics.irida.model.irida.IridaSequenceFile;
Expand All @@ -58,7 +58,7 @@
@Table(name = "sequence_file")
@Audited
@EntityListeners({ AuditingEntityListener.class, RelativePathTranslatorListener.class })
public class SequenceFile extends IridaResourceSupport
public class SequenceFile extends IridaRepresentationModel
implements MutableIridaThing, Comparable<SequenceFile>, VersionedFileFields<Long>, IridaSequenceFile,
RemoteSynchronizable {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package ca.corefacility.bioinformatics.irida.model.sequenceFile;

import ca.corefacility.bioinformatics.irida.exceptions.EntityNotFoundException;
import ca.corefacility.bioinformatics.irida.model.IridaResourceSupport;
import ca.corefacility.bioinformatics.irida.model.IridaRepresentationModel;
import ca.corefacility.bioinformatics.irida.model.MutableIridaThing;
import ca.corefacility.bioinformatics.irida.model.remote.RemoteStatus;
import ca.corefacility.bioinformatics.irida.model.remote.RemoteSynchronizable;
Expand Down Expand Up @@ -31,7 +31,7 @@
@EntityListeners(AuditingEntityListener.class)
@Audited
@Inheritance(strategy = InheritanceType.JOINED)
public abstract class SequencingObject extends IridaResourceSupport implements MutableIridaThing, RemoteSynchronizable {
public abstract class SequencingObject extends IridaRepresentationModel implements MutableIridaThing, RemoteSynchronizable {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;

import ca.corefacility.bioinformatics.irida.model.IridaResourceSupport;
import ca.corefacility.bioinformatics.irida.model.IridaRepresentationModel;
import ca.corefacility.bioinformatics.irida.model.MutableIridaThing;
import ca.corefacility.bioinformatics.irida.model.RemoteAPIToken;
import ca.corefacility.bioinformatics.irida.model.joins.impl.ProjectUserJoin;
Expand All @@ -39,7 +39,7 @@
@UniqueConstraint(name = User.USER_USERNAME_CONSTRAINT_NAME, columnNames = "username") })
@Audited
@EntityListeners(AuditingEntityListener.class)
public class User extends IridaResourceSupport implements MutableIridaThing, Comparable<User>, UserDetails {
public class User extends IridaRepresentationModel implements MutableIridaThing, Comparable<User>, UserDetails {

private static final long serialVersionUID = -7516211470008791995L;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
import javax.persistence.UniqueConstraint;
import javax.validation.constraints.NotNull;

import ca.corefacility.bioinformatics.irida.model.IridaResourceSupport;
import ca.corefacility.bioinformatics.irida.model.IridaRepresentationModel;
import ca.corefacility.bioinformatics.irida.model.IridaThing;
import ca.corefacility.bioinformatics.irida.model.workflow.analysis.type.AnalysisType;

Expand All @@ -42,7 +42,7 @@
@Entity
@Table(name = "analysis")
@Inheritance(strategy = InheritanceType.JOINED)
public class Analysis extends IridaResourceSupport implements IridaThing {
public class Analysis extends IridaRepresentationModel implements IridaThing {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.google.common.base.Strings;

import ca.corefacility.bioinformatics.irida.model.IridaResourceSupport;
import ca.corefacility.bioinformatics.irida.model.IridaRepresentationModel;
import ca.corefacility.bioinformatics.irida.model.IridaThing;
import ca.corefacility.bioinformatics.irida.model.VersionedFileFields;
import ca.corefacility.bioinformatics.irida.repositories.filesystem.FilesystemSupplementedRepository;
Expand All @@ -43,7 +43,7 @@
@Entity
@Table(name = "analysis_output_file")
@EntityListeners(RelativePathTranslatorListener.class)
public class AnalysisOutputFile extends IridaResourceSupport implements IridaThing, VersionedFileFields<Long> {
public class AnalysisOutputFile extends IridaRepresentationModel implements IridaThing, VersionedFileFields<Long> {
private static final Logger logger = LoggerFactory.getLogger(AnalysisOutputFile.class);

@Id
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import org.hibernate.envers.Audited;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import ca.corefacility.bioinformatics.irida.model.IridaResourceSupport;
import ca.corefacility.bioinformatics.irida.model.IridaRepresentationModel;
import ca.corefacility.bioinformatics.irida.model.IridaThing;
import ca.corefacility.bioinformatics.irida.model.workflow.submission.AnalysisSubmission;

Expand All @@ -30,7 +30,7 @@
@Entity
@Table(name = "job_error")
@EntityListeners(AuditingEntityListener.class)
public class JobError extends IridaResourceSupport implements IridaThing, Comparable<JobError> {
public class JobError extends IridaRepresentationModel implements IridaThing, Comparable<JobError> {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private final Long id;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package ca.corefacility.bioinformatics.irida.model.workflow.submission;

import ca.corefacility.bioinformatics.irida.model.IridaResourceSupport;
import ca.corefacility.bioinformatics.irida.model.IridaRepresentationModel;
import ca.corefacility.bioinformatics.irida.model.MutableIridaThing;
import ca.corefacility.bioinformatics.irida.model.project.ReferenceFile;
import ca.corefacility.bioinformatics.irida.model.user.User;
Expand All @@ -27,7 +27,7 @@
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
@Audited
@EntityListeners(AuditingEntityListener.class)
public abstract class AbstractAnalysisSubmission extends IridaResourceSupport implements MutableIridaThing {
public abstract class AbstractAnalysisSubmission extends IridaRepresentationModel implements MutableIridaThing {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id")
Expand Down
Loading

0 comments on commit a310805

Please sign in to comment.