Gjort FileDescription till en entity
git-svn-id: svn://svn.dsv.su.se/scipro/scipro/trunk@240 73ecded7-942e-4092-bab0-0e58ef0ee984
This commit is contained in:
parent
68ae454ce6
commit
a17ae68445
src/main
java/se/su/dsv/scipro
data/dataobjects
project/pages
repository
resources/META-INF
@ -0,0 +1,134 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package se.su.dsv.scipro.data.dataobjects;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.Id;
|
||||
|
||||
|
||||
/**
|
||||
* http://www.xaloon.org
|
||||
*
|
||||
* @author vytautas racelis
|
||||
* @author Martin Peters - mpeters@dsv.su.se
|
||||
*/
|
||||
@Entity
|
||||
public class FileDescription extends DomainObject implements Comparable<FileDescription>{
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Id
|
||||
@GeneratedValue
|
||||
private Long id;
|
||||
|
||||
private String name;
|
||||
private Date lastModified;
|
||||
private String mimeType;
|
||||
private String identifier;
|
||||
private String path;
|
||||
private Long userId = null;
|
||||
private Long size;
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
public String getPath() {
|
||||
return path;
|
||||
}
|
||||
public void setPath(String path) {
|
||||
this.path = path;
|
||||
}
|
||||
public String getIdentifier() {
|
||||
return identifier;
|
||||
}
|
||||
public void setIdentifier(String identifier) {
|
||||
this.identifier = identifier;
|
||||
}
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
public Date getLastModified() {
|
||||
return lastModified;
|
||||
}
|
||||
public void setLastModified(Date lastModified) {
|
||||
this.lastModified = lastModified;
|
||||
}
|
||||
public String getMimeType() {
|
||||
return mimeType;
|
||||
}
|
||||
public void setMimeType(String mimeType) {
|
||||
this.mimeType = mimeType;
|
||||
}
|
||||
public void setSize(Long size) {
|
||||
this.size = size;
|
||||
}
|
||||
public Long getSize() {
|
||||
return size;
|
||||
}
|
||||
|
||||
public void setUserId(Long userId) {
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
public Long getUserId() {
|
||||
return userId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object other){
|
||||
if(other == null)
|
||||
return false;
|
||||
if(!(other instanceof FileDescription))
|
||||
return false;
|
||||
FileDescription fDesc = (FileDescription) other;
|
||||
if(this.getIdentifier() == null || fDesc.getIdentifier() == null)
|
||||
throw new IllegalStateException("Tried to check FileDescription objects for equality where identifier was null");
|
||||
if(!this.getIdentifier().equals(fDesc.identifier))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode(){
|
||||
if(this.getIdentifier() == null)
|
||||
throw new IllegalStateException("Tried to get hashCode fore FileDescription where identifier was not set");
|
||||
return this.getIdentifier().hashCode();
|
||||
}
|
||||
@Override
|
||||
public String toString(){
|
||||
if(name != null)
|
||||
return name;
|
||||
else
|
||||
return super.toString();
|
||||
}
|
||||
@Override
|
||||
public int compareTo(FileDescription other) {
|
||||
return this.name.compareToIgnoreCase(other.name);
|
||||
}
|
||||
|
||||
}
|
@ -9,10 +9,10 @@ import se.su.dsv.scipro.basepages.MenuPage;
|
||||
import se.su.dsv.scipro.data.dao.interfaces.ProjectDao;
|
||||
import se.su.dsv.scipro.data.dao.interfaces.StringResourceDao;
|
||||
import se.su.dsv.scipro.data.dao.interfaces.UserDao;
|
||||
import se.su.dsv.scipro.data.dataobjects.FileDescription;
|
||||
import se.su.dsv.scipro.data.dataobjects.Project;
|
||||
import se.su.dsv.scipro.data.dataobjects.StringResource;
|
||||
import se.su.dsv.scipro.data.dataobjects.User;
|
||||
import se.su.dsv.scipro.repository.FileDescription;
|
||||
import se.su.dsv.scipro.repository.components.FileChooser;
|
||||
import se.su.dsv.scipro.repository.pages.ProjectFilePage;
|
||||
import se.su.dsv.scipro.repository.pages.SysAdminFilePage;
|
||||
|
@ -22,6 +22,8 @@ import java.util.List;
|
||||
import org.apache.wicket.markup.html.form.upload.FileUpload;
|
||||
import org.apache.wicket.util.resource.IResourceStream;
|
||||
|
||||
import se.su.dsv.scipro.data.dataobjects.FileDescription;
|
||||
|
||||
/**
|
||||
* http://www.xaloon.org
|
||||
*
|
||||
|
@ -48,6 +48,7 @@ import eu.medsea.mimeutil.MimeUtil;
|
||||
import eu.medsea.mimeutil.detector.ExtensionMimeDetector;
|
||||
|
||||
import se.su.dsv.scipro.SciProSession;
|
||||
import se.su.dsv.scipro.data.dataobjects.FileDescription;
|
||||
import se.su.dsv.scipro.repository.util.FileStorageException;
|
||||
import se.su.dsv.scipro.repository.util.RepositoryHelper;
|
||||
import se.su.dsv.scipro.repository.util.RepositoryManager;
|
||||
|
@ -24,9 +24,9 @@ import org.apache.wicket.util.resource.IResourceStream;
|
||||
import se.su.dsv.scipro.SciProSession;
|
||||
import se.su.dsv.scipro.data.dao.interfaces.ProjectDao;
|
||||
import se.su.dsv.scipro.data.dao.interfaces.UserDao;
|
||||
import se.su.dsv.scipro.data.dataobjects.FileDescription;
|
||||
import se.su.dsv.scipro.data.dataobjects.Project;
|
||||
import se.su.dsv.scipro.data.dataobjects.User;
|
||||
import se.su.dsv.scipro.repository.FileDescription;
|
||||
import se.su.dsv.scipro.repository.FileRepository;
|
||||
import se.su.dsv.scipro.repository.FolderDescription;
|
||||
import se.su.dsv.scipro.repository.SortOrder;
|
||||
|
@ -29,8 +29,8 @@ import org.apache.wicket.util.lang.Bytes;
|
||||
import org.apache.wicket.util.resource.IResourceStream;
|
||||
|
||||
import se.su.dsv.scipro.data.dao.interfaces.UserDao;
|
||||
import se.su.dsv.scipro.data.dataobjects.FileDescription;
|
||||
import se.su.dsv.scipro.data.dataobjects.User;
|
||||
import se.su.dsv.scipro.repository.FileDescription;
|
||||
import se.su.dsv.scipro.repository.FilePanelContainer;
|
||||
import se.su.dsv.scipro.repository.FileRepository;
|
||||
import se.su.dsv.scipro.repository.FolderDescription;
|
||||
|
@ -16,7 +16,7 @@ import org.apache.wicket.util.resource.AbstractResourceStream;
|
||||
import org.apache.wicket.util.resource.IResourceStream;
|
||||
import org.apache.wicket.util.resource.ResourceStreamNotFoundException;
|
||||
|
||||
import se.su.dsv.scipro.repository.FileDescription;
|
||||
import se.su.dsv.scipro.data.dataobjects.FileDescription;
|
||||
import se.su.dsv.scipro.repository.FileRepository;
|
||||
|
||||
public class FileLinkPanel extends Panel{
|
||||
@ -34,8 +34,7 @@ public class FileLinkPanel extends Panel{
|
||||
|
||||
public FileLinkPanel(String id, final IModel<FileDescription> model) {
|
||||
super(id, model);
|
||||
fileExists = fileRepository.existsFileByIdentifier(model.getObject().getIdentifier());
|
||||
|
||||
fileExists = fileRepository.existsFileByPath(model.getObject().getPath());
|
||||
Link<Void> fileLink = new Link<Void>("fileLink"){
|
||||
private static final long serialVersionUID = 1L;
|
||||
@Override
|
||||
@ -53,8 +52,7 @@ public class FileLinkPanel extends Panel{
|
||||
return getFileStream(model.getObject());
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
if(!fileExists){
|
||||
fileLink.setEnabled(false);
|
||||
|
@ -44,6 +44,7 @@
|
||||
<class>se.su.dsv.scipro.data.dataobjects.Tag</class>
|
||||
<class>se.su.dsv.scipro.data.dataobjects.Comment</class>
|
||||
<class>se.su.dsv.scipro.data.dataobjects.ProjectClass</class>
|
||||
<class>se.su.dsv.scipro.data.dataobjects.FileDescription</class>
|
||||
|
||||
<properties>
|
||||
|
||||
@ -116,6 +117,7 @@
|
||||
<class>se.su.dsv.scipro.data.dataobjects.Tag</class>
|
||||
<class>se.su.dsv.scipro.data.dataobjects.Comment</class>
|
||||
<class>se.su.dsv.scipro.data.dataobjects.ProjectClass</class>
|
||||
<class>se.su.dsv.scipro.data.dataobjects.FileDescription</class>
|
||||
|
||||
<properties>
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user