-
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #201 from DropSnorz/feat/file-stats
Directory metrics and file statistics
- Loading branch information
Showing
13 changed files
with
543 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
owlplug-client/src/main/java/com/owlplug/core/dao/FileStatDAO.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* OwlPlug | ||
* Copyright (C) 2021 Arthur <[email protected]> | ||
* | ||
* This file is part of OwlPlug. | ||
* | ||
* OwlPlug is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License version 3 | ||
* as published by the Free Software Foundation. | ||
* | ||
* OwlPlug 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 General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with OwlPlug. If not, see <https://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
package com.owlplug.core.dao; | ||
|
||
import com.owlplug.core.model.FileStat; | ||
import jakarta.transaction.Transactional; | ||
import java.util.List; | ||
import java.util.Optional; | ||
import org.springframework.data.repository.CrudRepository; | ||
|
||
public interface FileStatDAO extends CrudRepository<FileStat, Long> { | ||
|
||
Optional<FileStat> findByPath(String path); | ||
|
||
List<FileStat> findByParentPathOrderByLengthDesc(String parentPath); | ||
|
||
@Transactional | ||
List<FileStat> deleteByPath(String path); | ||
|
||
} |
105 changes: 105 additions & 0 deletions
105
owlplug-client/src/main/java/com/owlplug/core/model/FileStat.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
/* OwlPlug | ||
* Copyright (C) 2021 Arthur <[email protected]> | ||
* | ||
* This file is part of OwlPlug. | ||
* | ||
* OwlPlug is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License version 3 | ||
* as published by the Free Software Foundation. | ||
* | ||
* OwlPlug 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 General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with OwlPlug. If not, see <https://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
package com.owlplug.core.model; | ||
|
||
import jakarta.persistence.CascadeType; | ||
import jakarta.persistence.Entity; | ||
import jakarta.persistence.GeneratedValue; | ||
import jakarta.persistence.GenerationType; | ||
import jakarta.persistence.Id; | ||
import jakarta.persistence.JoinColumn; | ||
import jakarta.persistence.ManyToOne; | ||
import jakarta.persistence.OneToMany; | ||
import java.util.HashSet; | ||
import java.util.Set; | ||
|
||
@Entity | ||
public class FileStat { | ||
|
||
@Id | ||
@GeneratedValue(strategy = GenerationType.AUTO) | ||
private Long id; | ||
|
||
private String name; | ||
|
||
private String path; | ||
|
||
@ManyToOne | ||
@JoinColumn(name = "parent_id") | ||
private FileStat parent; | ||
|
||
private String parentPath; | ||
private long length; | ||
|
||
@OneToMany(mappedBy = "parent", cascade = CascadeType.ALL) | ||
private Set<FileStat> childs = new HashSet<>(); | ||
|
||
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 String getPath() { | ||
return path; | ||
} | ||
|
||
public void setPath(String path) { | ||
this.path = path; | ||
} | ||
|
||
public FileStat getParent() { | ||
return parent; | ||
} | ||
|
||
public void setParent(FileStat parent) { | ||
this.parent = parent; | ||
} | ||
|
||
public String getParentPath() { | ||
return parentPath; | ||
} | ||
|
||
public void setParentPath(String parentPath) { | ||
this.parentPath = parentPath; | ||
} | ||
|
||
public long getLength() { | ||
return length; | ||
} | ||
|
||
public void setLength(long length) { | ||
this.length = length; | ||
} | ||
|
||
public Set<FileStat> getChilds() { | ||
return childs; | ||
} | ||
|
||
} |
Oops, something went wrong.