Commit 8bc499c2 authored by Matija Obreza's avatar Matija Obreza
Browse files

Migrated to application-blocks

parent 0c036492
......@@ -121,5 +121,10 @@
<artifactId>commons-codec</artifactId>
<version>1.10</version>
</dependency>
<dependency>
<groupId>org.genesys-pgr</groupId>
<artifactId>application-blocks-core</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
</dependencies>
</project>
......@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.genesys2.server.filerepository;
package org.genesys.filerepository;
// TODO: Auto-generated Javadoc
/**
......
......@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.genesys2.server.filerepository;
package org.genesys.filerepository;
// TODO: Auto-generated Javadoc
/**
......
......@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.genesys2.server.filerepository;
package org.genesys.filerepository;
// TODO: Auto-generated Javadoc
/**
......
......@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.genesys2.server.filerepository;
package org.genesys.filerepository;
/**
* The InvalidRepositoryPathException is thrown when Repository is not happy with your selected path.
......
......@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.genesys2.server.filerepository;
package org.genesys.filerepository;
// TODO: Auto-generated Javadoc
/**
......
......@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.genesys2.server.filerepository.metadata;
package org.genesys.filerepository.metadata;
import java.io.Serializable;
import java.util.Date;
......
......@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.genesys2.server.filerepository.metadata;
package org.genesys.filerepository.metadata;
// TODO: Auto-generated Javadoc
/**
......
......@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.genesys2.server.filerepository.metadata;
package org.genesys.filerepository.metadata;
// TODO: Auto-generated Javadoc
/**
......
......@@ -14,8 +14,9 @@
* limitations under the License.
*/
package org.genesys2.server.filerepository.model;
package org.genesys.filerepository.model;
import java.util.ArrayList;
import java.util.List;
import javax.persistence.Column;
......@@ -26,16 +27,20 @@ import javax.persistence.Lob;
import javax.persistence.ManyToMany;
import javax.persistence.OrderColumn;
import org.genesys.blocks.model.AuditedVersionedModel;
/**
* {@link ImageGallery} is a collection of ordered {@link RepositoryImage} instances.
*
* Gallery has a dedicated "path" in the file repository, where new images are posted. When an image is removed from the Gallery, it may be removed if it is hosted in the Gallery
* path, but must be kept as-is if it does not share the path.
* Gallery has a dedicated "path" in the file repository, where new images are posted. When an image is removed from the
* Gallery, it may be removed if it is hosted in the Gallery path, but must be kept as-is if it does not share the path.
*
* @author mobreza
*/
@Entity(name = "repositorygallery")
public class ImageGallery extends BaseEntity {
public class ImageGallery extends AuditedVersionedModel<ImageGallery> {
private static final long serialVersionUID = 6043583851401365284L;
/**
* Each Gallery has a dedicated "path" in the file repository. A gallery "owns" a unique path in the repository.
......@@ -132,4 +137,16 @@ public class ImageGallery extends BaseEntity {
public void setImages(final List<RepositoryImage> images) {
this.images = images;
}
@Override
public ImageGallery apply(ImageGallery source) {
super.apply((AuditedVersionedModel<ImageGallery>) source);
this.description = source.description;
this.images = new ArrayList<>(source.images);
this.path = source.path;
this.title = source.title;
return null;
}
}
......@@ -14,15 +14,15 @@
* limitations under the License.
*/
package org.genesys2.server.filerepository.model;
package org.genesys.filerepository.model;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.PrePersist;
import javax.persistence.Table;
import org.genesys2.server.filerepository.metadata.DocumentMetadata;
import org.genesys2.server.filerepository.metadata.ImageMetadata;
import org.genesys.filerepository.metadata.DocumentMetadata;
import org.genesys.filerepository.metadata.ImageMetadata;
// TODO: Auto-generated Javadoc
/**
......@@ -49,7 +49,7 @@ public class RepositoryDocument extends RepositoryFile implements DocumentMetada
/*
* (non-Javadoc)
*
* @see org.genesys2.server.filerepository.model.RepositoryFile#prePersist()
* @see org.genesys.filerepository.model.RepositoryFile#prePersist()
*/
@Override
@PrePersist
......@@ -61,7 +61,7 @@ public class RepositoryDocument extends RepositoryFile implements DocumentMetada
/*
* (non-Javadoc)
*
* @see org.genesys2.server.filerepository.metadata.DocumentMetadata#getLanguage()
* @see org.genesys.filerepository.metadata.DocumentMetadata#getLanguage()
*/
@Override
public String getLanguage() {
......@@ -80,7 +80,7 @@ public class RepositoryDocument extends RepositoryFile implements DocumentMetada
/*
* (non-Javadoc)
*
* @see org.genesys2.server.filerepository.metadata.DocumentMetadata#getAbstract()
* @see org.genesys.filerepository.metadata.DocumentMetadata#getAbstract()
*/
@Override
public String getAbstract() {
......
......@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.genesys2.server.filerepository.model;
package org.genesys.filerepository.model;
import java.util.Date;
import java.util.UUID;
......@@ -30,9 +30,8 @@ import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Transient;
import org.genesys2.server.filerepository.metadata.BaseMetadata;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedDate;
import org.genesys.blocks.model.AuditedVersionedModel;
import org.genesys.filerepository.metadata.BaseMetadata;
// TODO: Auto-generated Javadoc
/**
......@@ -41,7 +40,7 @@ import org.springframework.data.annotation.LastModifiedDate;
@Entity
@Table(name = "repositoryfile", indexes = { @Index(unique = false, columnList = "path", name = "IX_repoFile_path") })
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
public class RepositoryFile extends BaseEntity implements BaseMetadata {
public class RepositoryFile extends AuditedVersionedModel<RepositoryFile> implements BaseMetadata {
/** The Constant serialVersionUID. */
private static final long serialVersionUID = -4816923593950502695L;
......@@ -107,16 +106,6 @@ public class RepositoryFile extends BaseEntity implements BaseMetadata {
@Column(name = "bibliographicCitation")
private String bibliographicCitation;
/** The created date. */
@CreatedDate
@Column(name = "createdDate")
private Date createdDate;
/** The last modified date. */
@LastModifiedDate
@Column(name = "lastModifiedDate")
private Date lastModifiedDate;
/** URL where the resource was originally retrieved from. */
@Column(length = 400, nullable = true)
private String originalUrl;
......@@ -151,7 +140,7 @@ public class RepositoryFile extends BaseEntity implements BaseMetadata {
/*
* (non-Javadoc)
*
* @see org.genesys2.server.filerepository.metadata.BaseMetadata#getIdentifier()
* @see org.genesys.filerepository.metadata.BaseMetadata#getIdentifier()
*/
// TODO See if we can have a setter instead of this formula.
@Override
......@@ -213,7 +202,7 @@ public class RepositoryFile extends BaseEntity implements BaseMetadata {
/*
* (non-Javadoc)
*
* @see org.genesys2.server.filerepository.metadata.BaseMetadata#getTitle()
* @see org.genesys.filerepository.metadata.BaseMetadata#getTitle()
*/
@Override
public String getTitle() {
......@@ -232,7 +221,7 @@ public class RepositoryFile extends BaseEntity implements BaseMetadata {
/*
* (non-Javadoc)
*
* @see org.genesys2.server.filerepository.metadata.BaseMetadata#getSubject()
* @see org.genesys.filerepository.metadata.BaseMetadata#getSubject()
*/
@Override
public String getSubject() {
......@@ -251,7 +240,7 @@ public class RepositoryFile extends BaseEntity implements BaseMetadata {
/*
* (non-Javadoc)
*
* @see org.genesys2.server.filerepository.metadata.BaseMetadata#getDescription()
* @see org.genesys.filerepository.metadata.BaseMetadata#getDescription()
*/
@Override
public String getDescription() {
......@@ -270,7 +259,7 @@ public class RepositoryFile extends BaseEntity implements BaseMetadata {
/*
* (non-Javadoc)
*
* @see org.genesys2.server.filerepository.metadata.BaseMetadata#getCreator()
* @see org.genesys.filerepository.metadata.BaseMetadata#getCreator()
*/
@Override
public String getCreator() {
......@@ -289,7 +278,7 @@ public class RepositoryFile extends BaseEntity implements BaseMetadata {
/*
* (non-Javadoc)
*
* @see org.genesys2.server.filerepository.metadata.BaseMetadata#getCreated()
* @see org.genesys.filerepository.metadata.BaseMetadata#getCreated()
*/
@Override
public String getCreated() {
......@@ -308,7 +297,7 @@ public class RepositoryFile extends BaseEntity implements BaseMetadata {
/*
* (non-Javadoc)
*
* @see org.genesys2.server.filerepository.metadata.BaseMetadata#getRightsHolder( )
* @see org.genesys.filerepository.metadata.BaseMetadata#getRightsHolder( )
*/
@Override
public String getRightsHolder() {
......@@ -327,7 +316,7 @@ public class RepositoryFile extends BaseEntity implements BaseMetadata {
/*
* (non-Javadoc)
*
* @see org.genesys2.server.filerepository.metadata.BaseMetadata#getAccessRights( )
* @see org.genesys.filerepository.metadata.BaseMetadata#getAccessRights( )
*/
@Override
public String getAccessRights() {
......@@ -346,7 +335,7 @@ public class RepositoryFile extends BaseEntity implements BaseMetadata {
/*
* (non-Javadoc)
*
* @see org.genesys2.server.filerepository.metadata.BaseMetadata#getLicense()
* @see org.genesys.filerepository.metadata.BaseMetadata#getLicense()
*/
@Override
public String getLicense() {
......@@ -365,7 +354,7 @@ public class RepositoryFile extends BaseEntity implements BaseMetadata {
/*
* (non-Javadoc)
*
* @see org.genesys2.server.filerepository.metadata.BaseMetadata#getFormat()
* @see org.genesys.filerepository.metadata.BaseMetadata#getFormat()
*/
@Override
public String getFormat() {
......@@ -393,7 +382,7 @@ public class RepositoryFile extends BaseEntity implements BaseMetadata {
/*
* (non-Javadoc)
*
* @see org.genesys2.server.filerepository.metadata.BaseMetadata#getExtent()
* @see org.genesys.filerepository.metadata.BaseMetadata#getExtent()
*/
@Override
public String getExtent() {
......@@ -412,7 +401,7 @@ public class RepositoryFile extends BaseEntity implements BaseMetadata {
/*
* (non-Javadoc)
*
* @see org.genesys2.server.filerepository.metadata.BaseMetadata# getBibliographicCitation()
* @see org.genesys.filerepository.metadata.BaseMetadata# getBibliographicCitation()
*/
@Override
public String getBibliographicCitation() {
......@@ -431,59 +420,23 @@ public class RepositoryFile extends BaseEntity implements BaseMetadata {
/*
* (non-Javadoc)
*
* @see org.genesys2.server.filerepository.metadata.BaseMetadata#getDateSubmitted ()
* @see org.genesys.filerepository.metadata.BaseMetadata#getDateSubmitted ()
*/
@Override
public Date getDateSubmitted() {
return getCreatedDate();
}
/**
* Gets the created date.
*
* @return the created date
*/
public Date getCreatedDate() {
return createdDate;
}
/**
* Sets the created date.
*
* @param createdDate the new created date
*/
public void setCreatedDate(final Date createdDate) {
this.createdDate = createdDate;
}
/*
* (non-Javadoc)
*
* @see org.genesys2.server.filerepository.metadata.BaseMetadata#getModified()
* @see org.genesys.filerepository.metadata.BaseMetadata#getModified()
*/
@Override
public Date getModified() {
return getLastModifiedDate();
}
/**
* Gets the last modified date.
*
* @return the last modified date
*/
public Date getLastModifiedDate() {
return lastModifiedDate;
}
/**
* Sets the last modified date.
*
* @param lastModifiedDate the new last modified date
*/
public void setLastModifiedDate(final Date lastModifiedDate) {
this.lastModifiedDate = lastModifiedDate;
}
/**
* Sets the original filename.
*
......@@ -613,4 +566,31 @@ public class RepositoryFile extends BaseEntity implements BaseMetadata {
public void setMd5Sum(final String md5Sum) {
this.md5Sum = md5Sum;
}
@Override
public RepositoryFile apply(RepositoryFile source) {
super.apply((AuditedVersionedModel<RepositoryFile>) source);
this.accessRights = source.accessRights;
this.bibliographicCitation = source.bibliographicCitation;
this.contentType = source.contentType;
this.created = source.created;
this.creator = source.creator;
this.dateRetrieved = source.dateRetrieved;
this.description = source.description;
this.extension = source.extension;
this.extent = source.extent;
this.license = source.license;
this.md5Sum = source.md5Sum;
this.sha1Sum = source.sha1Sum;
this.originalFilename = source.originalFilename;
this.originalUrl = source.originalUrl;
this.path = source.path;
this.rightsHolder = source.rightsHolder;
this.subject = source.subject;
this.title = source.title;
this.uuid = source.uuid;
return this;
}
}
......@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.genesys2.server.filerepository.model;
package org.genesys.filerepository.model;
import javax.persistence.Column;
import javax.persistence.Entity;
......@@ -23,12 +23,12 @@ import javax.persistence.Enumerated;
import javax.persistence.PrePersist;
import javax.persistence.Table;
import org.genesys2.server.filerepository.metadata.ImageMetadata;
import org.genesys.filerepository.metadata.ImageMetadata;
// TODO: Auto-generated Javadoc
/**
* An {@link RepositoryImage} is an graphics file in one of the supported image formats (PNG and JPG). It extends the {@link RepositoryFile} by including image-specific metadata
* defined in {@link ImageMetadata}.
* An {@link RepositoryImage} is an graphics file in one of the supported image formats (PNG and JPG). It extends the
* {@link RepositoryFile} by including image-specific metadata defined in {@link ImageMetadata}.
*
* @author mobreza
*/
......@@ -54,7 +54,7 @@ public class RepositoryImage extends RepositoryFile implements ImageMetadata {
/*
* (non-Javadoc)
*
* @see org.genesys2.server.filerepository.model.RepositoryFile#prePersist()
* @see org.genesys.filerepository.model.RepositoryFile#prePersist()
*/
@Override
@PrePersist
......@@ -67,7 +67,7 @@ public class RepositoryImage extends RepositoryFile implements ImageMetadata {
/*
* (non-Javadoc)
*
* @see org.genesys2.server.filerepository.metadata.ImageMetadata#getWidth()
* @see org.genesys.filerepository.metadata.ImageMetadata#getWidth()
*/
@Override
public Integer getWidth() {
......@@ -87,7 +87,7 @@ public class RepositoryImage extends RepositoryFile implements ImageMetadata {
/*
* (non-Javadoc)
*
* @see org.genesys2.server.filerepository.metadata.ImageMetadata#getHeight()
* @see org.genesys.filerepository.metadata.ImageMetadata#getHeight()
*/
@Override
public Integer getHeight() {
......@@ -129,4 +129,14 @@ public class RepositoryImage extends RepositoryFile implements ImageMetadata {
private void updateOrientation() {
orientation = width > height ? Orientation.LANDSCAPE : Orientation.PORTRAIT;
}
public RepositoryImage apply(RepositoryImage source) {
super.apply(source);
this.height = source.height;
this.orientation = source.orientation;
this.width = source.width;
return this;
}
}
......@@ -14,9 +14,9 @@
* limitations under the License.
*/
package org.genesys2.server.filerepository.persistence;
package org.genesys.filerepository.persistence;
import org.genesys2.server.filerepository.model.ImageGallery;
import org.genesys.filerepository.model.ImageGallery;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
......@@ -45,7 +45,7 @@ public interface ImageGalleryPersistence extends JpaRepository<ImageGallery, Lon
* @param pageable the pageable
* @return the page
*/
@Query("select ig from org.genesys2.server.filerepository.model.ImageGallery ig where ig.path like ?1%")
@Query("select ig from org.genesys.filerepository.model.ImageGallery ig where ig.path like ?1%")
Page<ImageGallery> listByPath(String prefix, Pageable pageable);
}
......@@ -14,12 +14,12 @@
* limitations under the License.
*/
package org.genesys2.server.filerepository.persistence;
package org.genesys.filerepository.persistence;
import java.util.List;
import java.util.UUID;
import org.genesys2.server.filerepository.model.RepositoryDocument;
import org.genesys.filerepository.model.RepositoryDocument;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
......
......@@ -14,12 +14,12 @@
* limitations under the License.
*/
package org.genesys2.server.filerepository.persistence;
package org.genesys.filerepository.persistence;
import java.util.List;
import java.util.UUID;
import org.genesys2.server.filerepository.model.RepositoryFile;
import org.genesys.filerepository.model.RepositoryFile;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
......
......@@ -14,12 +14,12 @@
* limitations under the License.
*/
package org.genesys2.server.filerepository.persistence;
package org.genesys.filerepository.persistence;
import java.util.List;
import java.util.UUID;
import org.genesys2.server.filerepository.model.RepositoryImage;
import org.genesys.filerepository.model.RepositoryImage;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
......
......@@ -14,12 +14,12 @@
* limitations under the License.
*/
package org.genesys2.server.filerepository.service;
package org.genesys.filerepository.service;
import java.io.IOException;
import java.util.List;
import org.genesys2.server.filerepository.InvalidRepositoryPathException;
import org.genesys.filerepository.InvalidRepositoryPathException;
// TODO: Auto-generated Javadoc
/**
......