com.sippnex.fileblade.entities.FilebladeItem Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of fileblade-server Show documentation
Show all versions of fileblade-server Show documentation
Server-side Spring library for fileblade. A web filemanager
package com.sippnex.fileblade.entities;
import javax.persistence.*;
import java.util.ArrayList;
import java.util.List;
@Entity
public abstract class FilebladeItem {
@Id
@GeneratedValue
private Long id;
private String name;
@ManyToOne(cascade = CascadeType.ALL)
@JoinColumn(name = "parent_directory_id")
private Directory parentDirectory;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Directory getParentDirectory() {
return parentDirectory;
}
public void setParentDirectory(Directory parentDirectory) {
this.parentDirectory = parentDirectory;
}
public String getPath() {
List pathElements = new ArrayList<>();
pathElements.add(this.getName());
Directory nextParentDirectory = this.getParentDirectory();
while(nextParentDirectory != null) {
pathElements.add(nextParentDirectory.getName());
nextParentDirectory = nextParentDirectory.getParentDirectory();
}
String path = "";
for(int i=pathElements.size() - 1; i>=0; i--) {
path += "/" + pathElements.get(i);
}
return path;
}
public FilebladeItem(String name, Directory parentDirectory) {
this.name = name;
this.parentDirectory = parentDirectory;
}
public FilebladeItem(String name) {
this.name = name;
}
public FilebladeItem() {
}
}