CCM NG: First set of entities for new asset/attachment system
git-svn-id: https://svn.libreccm.org/ccm/ccm_ng@4183 8810af33-2d31-482b-a856-94f89814c4dfpull/2/head
parent
4b143d3b3b
commit
d01264b169
|
|
@ -15,7 +15,8 @@
|
|||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||
* MA 02110-1301 USA
|
||||
*/package org.librecms.assets;
|
||||
*/
|
||||
package org.librecms.assets;
|
||||
|
||||
import org.hibernate.envers.Audited;
|
||||
import org.libreccm.core.Identifiable;
|
||||
|
|
@ -68,6 +69,10 @@ public class Asset implements Identifiable, Serializable {
|
|||
)
|
||||
private LocalizedString title;
|
||||
|
||||
public Asset() {
|
||||
title = new LocalizedString();
|
||||
}
|
||||
|
||||
public long getAssetId() {
|
||||
return assetId;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,185 @@
|
|||
/*
|
||||
* Copyright (C) 2016 LibreCCM Foundation.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||
* MA 02110-1301 USA
|
||||
*/
|
||||
package org.librecms.assets;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Arrays;
|
||||
import java.util.Objects;
|
||||
import javax.activation.MimeType;
|
||||
import javax.persistence.AssociationOverride;
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Embedded;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.JoinColumn;
|
||||
import javax.persistence.JoinTable;
|
||||
import javax.persistence.Lob;
|
||||
import javax.persistence.Table;
|
||||
import org.hibernate.envers.Audited;
|
||||
import org.hibernate.validator.constraints.NotEmpty;
|
||||
import org.libreccm.l10n.LocalizedString;
|
||||
|
||||
import static org.librecms.CmsConstants.*;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||
*/
|
||||
@Entity
|
||||
@Table(name = "BINARY_ASSETS", schema = DB_SCHEMA)
|
||||
@Audited
|
||||
public class BinaryAsset extends Asset implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = -8540922051232103527L;
|
||||
|
||||
@Embedded
|
||||
@AssociationOverride(
|
||||
name = "values",
|
||||
joinTable = @JoinTable(name = "BINARY_ASSET_DESCRIPTIONS",
|
||||
schema = DB_SCHEMA,
|
||||
joinColumns = {
|
||||
@JoinColumn(name = "ASSET_ID")
|
||||
}
|
||||
)
|
||||
)
|
||||
private LocalizedString description;
|
||||
|
||||
@Column(name = "FILENAME", length = 512, nullable = false)
|
||||
@NotEmpty
|
||||
private String fileName;
|
||||
|
||||
@Column(name = "MIME_TYPE", length = 512, nullable = false)
|
||||
@NotEmpty
|
||||
private MimeType mimeType;
|
||||
|
||||
@Column(name = "ASSET_DATA")
|
||||
@Lob
|
||||
private byte[] data;
|
||||
|
||||
@Column(name = "DATA_SIZE")
|
||||
private long size;
|
||||
|
||||
public BinaryAsset() {
|
||||
super();
|
||||
description = new LocalizedString();
|
||||
}
|
||||
|
||||
public LocalizedString getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(final LocalizedString description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public String getFileName() {
|
||||
return fileName;
|
||||
}
|
||||
|
||||
public void setFileName(final String fileName) {
|
||||
this.fileName = fileName;
|
||||
}
|
||||
|
||||
public MimeType getMimeType() {
|
||||
return mimeType;
|
||||
}
|
||||
|
||||
public void setMimeType(final MimeType mimeType) {
|
||||
this.mimeType = mimeType;
|
||||
}
|
||||
|
||||
public byte[] getData() {
|
||||
return Arrays.copyOf(data, data.length);
|
||||
}
|
||||
|
||||
public void setData(final byte[] data) {
|
||||
this.data = Arrays.copyOf(data, data.length);
|
||||
size = data.length;
|
||||
}
|
||||
|
||||
public long getSize() {
|
||||
return size;
|
||||
}
|
||||
|
||||
public void setSize(final long size) {
|
||||
this.size = size;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int hash = super.hashCode();
|
||||
hash = 59 * hash + Objects.hashCode(description);
|
||||
hash = 59 * hash + Objects.hashCode(fileName);
|
||||
hash = 59 * hash + Objects.hashCode(mimeType);
|
||||
hash = 59 * hash + Arrays.hashCode(data);
|
||||
hash = 59 * hash + (int) (size ^ (size >>> 32));
|
||||
return hash;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(final Object obj) {
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
if (obj == null) {
|
||||
return false;
|
||||
}
|
||||
if (!super.equals(obj)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!(obj instanceof BinaryAsset)) {
|
||||
return false;
|
||||
}
|
||||
final BinaryAsset other = (BinaryAsset) obj;
|
||||
if (!(other.canEqual(this))) {
|
||||
return false;
|
||||
}
|
||||
if (size != other.getSize()) {
|
||||
return false;
|
||||
}
|
||||
if (!Objects.equals(fileName, other.getFileName())) {
|
||||
return false;
|
||||
}
|
||||
if (!Objects.equals(description, other.getDescription())) {
|
||||
return false;
|
||||
}
|
||||
if (!Objects.equals(mimeType, other.getMimeType())) {
|
||||
return false;
|
||||
}
|
||||
return Arrays.equals(data, other.getData());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canEqual(final Object obj) {
|
||||
return obj instanceof BinaryAsset;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString(final String data) {
|
||||
return super.toString(String.format(", description = %s, "
|
||||
+ "fileName = \"%s\", "
|
||||
+ "mimeType = \"%s\", "
|
||||
+ "size = %d%s",
|
||||
Objects.toString(description),
|
||||
fileName,
|
||||
Objects.toString(mimeType),
|
||||
size,
|
||||
data));
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,133 @@
|
|||
/*
|
||||
* Copyright (C) 2016 LibreCCM Foundation.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||
* MA 02110-1301 USA
|
||||
*/
|
||||
package org.librecms.assets;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.net.URL;
|
||||
import java.util.Objects;
|
||||
import javax.persistence.AssociationOverride;
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Embedded;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.JoinColumn;
|
||||
import javax.persistence.JoinTable;
|
||||
import javax.persistence.Table;
|
||||
import org.hibernate.envers.Audited;
|
||||
import org.hibernate.validator.constraints.NotEmpty;
|
||||
import org.libreccm.l10n.LocalizedString;
|
||||
|
||||
import static org.librecms.CmsConstants.*;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||
*/
|
||||
@Entity
|
||||
@Table(name = "BOOKMARKS", schema = DB_SCHEMA)
|
||||
@Audited
|
||||
public class Bookmark extends Asset implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = -2077380735104791483L;
|
||||
|
||||
@Embedded
|
||||
@AssociationOverride(
|
||||
name = "values",
|
||||
joinTable = @JoinTable(name = "BOOKMARK_DESCRIPTIONS",
|
||||
schema = DB_SCHEMA,
|
||||
joinColumns = {
|
||||
@JoinColumn(name = "ASSET_ID")
|
||||
}
|
||||
)
|
||||
)
|
||||
private LocalizedString description;
|
||||
|
||||
@Column(name = "URL", length = 2048, nullable = false)
|
||||
@NotEmpty
|
||||
private URL url;
|
||||
|
||||
public Bookmark() {
|
||||
super();
|
||||
description = new LocalizedString();
|
||||
}
|
||||
|
||||
public LocalizedString getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(final LocalizedString description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public URL getUrl() {
|
||||
return url;
|
||||
}
|
||||
|
||||
public void setUrl(final URL url) {
|
||||
this.url = url;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int hash = super.hashCode();
|
||||
hash = 19 * hash + Objects.hashCode(description);
|
||||
hash = 19 * hash + Objects.hashCode(url);
|
||||
return hash;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(final Object obj) {
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
if (obj == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!super.equals(obj)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!(obj instanceof Bookmark)) {
|
||||
return false;
|
||||
}
|
||||
final Bookmark other = (Bookmark) obj;
|
||||
if (!other.canEqual(this)) {
|
||||
return false;
|
||||
}
|
||||
if (!Objects.equals(description, other.getDescription())) {
|
||||
return false;
|
||||
}
|
||||
return Objects.equals(url, other.getUrl());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canEqual(final Object obj) {
|
||||
return obj instanceof Bookmark;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString(final String data) {
|
||||
return super.toString(String.format(", description = %s, "
|
||||
+ "url = %s%s",
|
||||
Objects.toString(description),
|
||||
Objects.toString(url),
|
||||
data));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,68 @@
|
|||
/*
|
||||
* Copyright (C) 2016 LibreCCM Foundation.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||
* MA 02110-1301 USA
|
||||
*/package org.librecms.assets;
|
||||
|
||||
import java.io.Serializable;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Table;
|
||||
import org.hibernate.envers.Audited;
|
||||
|
||||
import static org.librecms.CmsConstants.*;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||
*/
|
||||
@Entity
|
||||
@Table(name = "FILES", schema = DB_SCHEMA)
|
||||
@Audited
|
||||
public class File extends BinaryAsset implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = -8195062456502964401L;
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return super.hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(final Object obj) {
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
if (obj == null) {
|
||||
return false;
|
||||
}
|
||||
if (!super.equals(obj)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!(obj instanceof File)) {
|
||||
return false;
|
||||
}
|
||||
final BinaryAsset other = (File) obj;
|
||||
return other.canEqual(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canEqual(final Object obj) {
|
||||
return obj instanceof File;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,147 @@
|
|||
/*
|
||||
* Copyright (C) 2016 LibreCCM Foundation.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||
* MA 02110-1301 USA
|
||||
*/
|
||||
package org.librecms.assets;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Objects;
|
||||
import javax.persistence.AssociationOverride;
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Embedded;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.JoinColumn;
|
||||
import javax.persistence.JoinTable;
|
||||
import javax.persistence.Table;
|
||||
import org.hibernate.envers.Audited;
|
||||
import org.libreccm.l10n.LocalizedString;
|
||||
|
||||
import static org.librecms.CmsConstants.*;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||
*/
|
||||
@Entity
|
||||
@Table(name = "IMAGES", schema = DB_SCHEMA)
|
||||
@Audited
|
||||
public class Image extends BinaryAsset implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = -8095106228017573785L;
|
||||
|
||||
@Column(name = "WIDTH")
|
||||
private long width;
|
||||
|
||||
@Column(name = "HEIGHT")
|
||||
private long height;
|
||||
|
||||
@Embedded
|
||||
@AssociationOverride(
|
||||
name = "values",
|
||||
joinTable = @JoinTable(name = "IMAGE_COPYRIGHT_NOTICES",
|
||||
schema = DB_SCHEMA,
|
||||
joinColumns = {
|
||||
@JoinColumn(name = "ASSET_ID")
|
||||
}
|
||||
)
|
||||
)
|
||||
private LocalizedString copyrightNotice;
|
||||
|
||||
public Image() {
|
||||
super();
|
||||
copyrightNotice = new LocalizedString();
|
||||
}
|
||||
|
||||
public long getWidth() {
|
||||
return width;
|
||||
}
|
||||
|
||||
public void setWidth(final long width) {
|
||||
this.width = width;
|
||||
}
|
||||
|
||||
public long getHeight() {
|
||||
return height;
|
||||
}
|
||||
|
||||
public void setHeight(final long height) {
|
||||
this.height = height;
|
||||
}
|
||||
|
||||
public LocalizedString getCopyrightNotice() {
|
||||
return copyrightNotice;
|
||||
}
|
||||
|
||||
public void setCopyrightNotice(final LocalizedString copyrightNotice) {
|
||||
this.copyrightNotice = copyrightNotice;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int hash = super.hashCode();
|
||||
hash = 89 * hash + (int) (width ^ (width >>> 32));
|
||||
hash = 89 * hash + (int) (height ^ (height >>> 32));
|
||||
hash = 89 * hash + Objects.hashCode(copyrightNotice);
|
||||
return hash;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(final Object obj) {
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
if (obj == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!super.equals(obj)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!(obj instanceof Image)) {
|
||||
return false;
|
||||
}
|
||||
final Image other = (Image) obj;
|
||||
if (!other.canEqual(this)) {
|
||||
return false;
|
||||
}
|
||||
if (width != other.getWidth()) {
|
||||
return false;
|
||||
}
|
||||
if (height != other.getHeight()) {
|
||||
return false;
|
||||
}
|
||||
return Objects.equals(copyrightNotice, other.getCopyrightNotice());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canEqual(final Object obj) {
|
||||
return obj instanceof Image;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString(final String data) {
|
||||
return super.toString(String.format(", width = %d, "
|
||||
+ "height = %d, "
|
||||
+ "copyrightNotice = %s%s",
|
||||
width,
|
||||
height,
|
||||
Objects.toString(copyrightNotice),
|
||||
data));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
/*
|
||||
* Copyright (C) 2016 LibreCCM Foundation.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||
* MA 02110-1301 USA
|
||||
*/
|
||||
package org.librecms.assets;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||
*/
|
||||
public class VideoAsset extends BinaryAsset implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = -4377789857099678289L;
|
||||
|
||||
private long width;
|
||||
|
||||
private long height;
|
||||
|
||||
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue