Skip to content

Commit

Permalink
Added the ability to view the task audit log [#756]
Browse files Browse the repository at this point in the history
 * Added a new feature to load entries and subscribe to updates.
 * Added unit testing level for TaskManager.
 * Changed task audit log to save the JSON body of the task.

Also renamed WebAuditLog => WebAuditLogPage to be consistent.
  • Loading branch information
mcpierce authored and BRUCELLA2 committed Jun 14, 2021
1 parent 13d5cd7 commit 31c0064
Show file tree
Hide file tree
Showing 73 changed files with 2,181 additions and 391 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@

package org.comixedproject.model.archives;

import com.fasterxml.jackson.annotation.JsonView;
import lombok.Getter;
import org.comixedproject.views.View;

/**
* <code>ArchiveType</code> reports the archive type detected for a file.
Expand All @@ -30,8 +32,13 @@ public enum ArchiveType {
CBR("RAR Comic", "application/vnc.comicbook+rar"),
CB7("7Z Comic", "application/vnc.comicbook+octet-stream");

@Getter private String name;
@Getter private String mimeType;
@JsonView(View.AuditLogEntryDetail.class)
@Getter
private String name;

@JsonView(View.AuditLogEntryDetail.class)
@Getter
private String mimeType;

private ArchiveType(String name, String mimeType) {
this.name = name;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,42 +57,42 @@ public class Comic {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@JsonProperty("id")
@JsonView({View.ComicListView.class, View.LastReadList.class})
@JsonView({View.ComicListView.class, View.LastReadList.class, View.AuditLogEntryDetail.class})
@Getter
@Setter
private Long id;

@Transient
@JsonProperty("nextIssueId")
@JsonView(View.ComicDetailsView.class)
@JsonView({View.ComicDetailsView.class, View.AuditLogEntryDetail.class})
@Getter
@Setter
private Long nextIssueId;

@Transient
@JsonProperty("previousIssueId")
@JsonView(View.ComicDetailsView.class)
@JsonView({View.ComicDetailsView.class, View.AuditLogEntryDetail.class})
@Getter
@Setter
private Long previousIssueId;

@Column(name = "Filename", nullable = false, unique = true, length = 1024)
@JsonProperty("filename")
@JsonView(View.ComicListView.class)
@JsonView({View.ComicListView.class, View.AuditLogEntryDetail.class})
@Getter
@Setter
private String filename;

@Column(name = "ComicState", nullable = false, updatable = true)
@Enumerated(EnumType.STRING)
@JsonProperty("comicState")
@JsonView(View.ComicListView.class)
@JsonView({View.ComicListView.class, View.AuditLogEntryDetail.class})
@Getter
@Setter
private ComicState comicState;

@OneToOne(cascade = CascadeType.ALL, mappedBy = "comic", orphanRemoval = true)
@JsonView(View.ComicListView.class)
@JsonView({View.ComicListView.class, View.AuditLogEntryDetail.class})
@Getter
@Setter
private ComicFileDetails fileDetails;
Expand All @@ -102,77 +102,77 @@ public class Comic {
@Column(name = "ArchiveType", nullable = false, updatable = true)
@Enumerated(EnumType.STRING)
@JsonProperty("archiveType")
@JsonView(View.ComicListView.class)
@JsonView({View.ComicListView.class, View.AuditLogEntryDetail.class})
@Getter
@Setter
private ArchiveType archiveType;

@Column(name = "Publisher", length = 128)
@JsonProperty("publisher")
@JsonView(View.ComicListView.class)
@JsonView({View.ComicListView.class, View.AuditLogEntryDetail.class})
@Getter
@Setter
private String publisher;

@Column(name = "Series", length = 128)
@JsonProperty("series")
@JsonView(View.ComicListView.class)
@JsonView({View.ComicListView.class, View.AuditLogEntryDetail.class})
@Getter
@Setter
private String series;

@Column(name = "Volume", length = 4)
@JsonProperty("volume")
@JsonView(View.ComicListView.class)
@JsonView({View.ComicListView.class, View.AuditLogEntryDetail.class})
@Getter
@Setter
private String volume;

@Column(name = "IssueNumber", length = 16)
@JsonProperty("issueNumber")
@JsonView(View.ComicListView.class)
@JsonView({View.ComicListView.class, View.AuditLogEntryDetail.class})
@Getter
private String issueNumber;

@Column(name = "Imprint")
@JsonProperty("imprint")
@JsonView(View.ComicListView.class)
@JsonView({View.ComicListView.class, View.AuditLogEntryDetail.class})
@Getter
@Setter
private String imprint;

@Column(name = "Notes", length = 128, nullable = true, updatable = true)
@JsonProperty("notes")
@JsonView(View.ComicListView.class)
@JsonView({View.ComicListView.class, View.AuditLogEntryDetail.class})
@Getter
@Setter
private String notes;

@OneToMany(mappedBy = "comic", cascade = CascadeType.ALL, orphanRemoval = true)
@OrderColumn(name = "PageNumber")
@JsonProperty("pages")
@JsonView(View.ComicDetailsView.class)
@JsonView({View.ComicDetailsView.class, View.AuditLogEntryDetail.class})
@Getter
List<Page> pages = new ArrayList<>();

@OneToMany(mappedBy = "comic", cascade = CascadeType.ALL, orphanRemoval = true)
@OrderColumn(name = "FileNumber")
@JsonView(View.ComicDetailsView.class)
@JsonView({View.ComicDetailsView.class, View.AuditLogEntryDetail.class})
@Getter
private List<ComicFileEntry> fileEntries = new ArrayList<>();

@ManyToOne
@JoinColumn(name = "ScanTypeId")
@JsonProperty("scanType")
@JsonView(View.ComicListView.class)
@JsonView({View.ComicListView.class, View.AuditLogEntryDetail.class})
@Getter
@Setter
private ScanType scanType;

@ManyToOne
@JoinColumn(name = "FormatId")
@JsonProperty("format")
@JsonView(View.ComicListView.class)
@JsonView({View.ComicListView.class, View.AuditLogEntryDetail.class})
@Getter
@Setter
private ComicFormat format;
Expand All @@ -191,15 +191,15 @@ public class Comic {
@CreatedDate
@JsonProperty("addedDate")
@JsonFormat(shape = JsonFormat.Shape.NUMBER)
@JsonView(View.ComicListView.class)
@JsonView({View.ComicListView.class, View.AuditLogEntryDetail.class})
@Temporal(TemporalType.TIMESTAMP)
@Getter
private Date dateAdded = new Date();

@Column(name = "DeletedOn", updatable = true, nullable = true)
@JsonProperty("deletedDate")
@JsonFormat(shape = Shape.NUMBER)
@JsonView(View.ComicListView.class)
@JsonView({View.ComicListView.class, View.AuditLogEntryDetail.class})
@Temporal(TemporalType.TIMESTAMP)
@Getter
@Setter
Expand All @@ -208,45 +208,45 @@ public class Comic {
@Column(name = "LastModifiedOn", updatable = true, nullable = false)
@JsonProperty("lastModifiedOn")
@JsonFormat(shape = JsonFormat.Shape.NUMBER)
@JsonView(View.ComicListView.class)
@JsonView({View.ComicListView.class, View.AuditLogEntryDetail.class})
@Temporal(TemporalType.TIMESTAMP)
@Getter
@Setter
private Date lastModifiedOn = new Date();

@Column(name = "ComicVineId", length = 16)
@JsonProperty("comicVineId")
@JsonView(View.ComicDetailsView.class)
@JsonView({View.ComicDetailsView.class, View.AuditLogEntryDetail.class})
@Getter
@Setter
private String comicVineId;

@Column(name = "CoverDate", nullable = true)
@Temporal(TemporalType.DATE)
@JsonProperty("coverDate")
@JsonView(View.ComicListView.class)
@JsonView({View.ComicListView.class, View.AuditLogEntryDetail.class})
@Getter
@Setter
private Date coverDate;

@Column(name = "SortName", length = 128)
@JsonProperty("sortName")
@JsonView(View.ComicListView.class)
@JsonView({View.ComicListView.class, View.AuditLogEntryDetail.class})
@Getter
@Setter
private String sortName;

@Column(name = "Title", length = 128)
@JsonProperty("title")
@JsonView(View.ComicListView.class)
@JsonView({View.ComicListView.class, View.AuditLogEntryDetail.class})
@Getter
@Setter
private String title;

@Column(name = "Description")
@Lob
@JsonProperty("description")
@JsonView(View.ComicDetailsView.class)
@JsonView({View.ComicDetailsView.class, View.AuditLogEntryDetail.class})
@Getter
@Setter
private String description;
Expand All @@ -256,7 +256,7 @@ public class Comic {
@CollectionTable(name = "Characters", joinColumns = @JoinColumn(name = "ComicId"))
@Column(name = "Name")
@JsonProperty("characters")
@JsonView(View.ComicListView.class)
@JsonView({View.ComicListView.class, View.AuditLogEntryDetail.class})
@Getter
private List<String> characters = new ArrayList<>();

Expand All @@ -265,7 +265,7 @@ public class Comic {
@CollectionTable(name = "Teams", joinColumns = @JoinColumn(name = "ComicId"))
@Column(name = "Name")
@JsonProperty("teams")
@JsonView(View.ComicListView.class)
@JsonView({View.ComicListView.class, View.AuditLogEntryDetail.class})
@Getter
private List<String> teams = new ArrayList<>();

Expand All @@ -274,7 +274,7 @@ public class Comic {
@CollectionTable(name = "Locations", joinColumns = @JoinColumn(name = "ComicId"))
@Column(name = "Name")
@JsonProperty("locations")
@JsonView(View.ComicListView.class)
@JsonView({View.ComicListView.class, View.AuditLogEntryDetail.class})
@Getter
private List<String> locations = new ArrayList<>();

Expand All @@ -283,42 +283,42 @@ public class Comic {
@CollectionTable(name = "Stories", joinColumns = @JoinColumn(name = "ComicId"))
@Column(name = "Name")
@JsonProperty("storyArcs")
@JsonView(View.ComicListView.class)
@JsonView({View.ComicListView.class, View.AuditLogEntryDetail.class})
@Getter
List<String> storyArcs = new ArrayList<>();

@OneToMany(mappedBy = "comic", cascade = CascadeType.ALL, orphanRemoval = true)
@JsonProperty("credits")
@JsonView(View.ComicListView.class)
@JsonView({View.ComicListView.class, View.AuditLogEntryDetail.class})
@Getter
private Set<Credit> credits = new HashSet<>();

@Formula(
value =
"(SELECT COUNT(*) FROM Pages p WHERE p.ComicId = id AND p.FileHash in (SELECT b.Hash FROM BlockedPages b))")
@JsonProperty("blockedPageCount")
@JsonView(View.ComicListView.class)
@JsonView({View.ComicListView.class, View.AuditLogEntryDetail.class})
@Getter
private int blockedPageCount;

@Transient
@JsonProperty("comicVineURL")
@JsonView(View.ComicDetailsView.class)
@JsonView({View.ComicDetailsView.class, View.AuditLogEntryDetail.class})
@Getter
@Setter
private String comicVineURL;

@Formula(
"(SELECT COUNT(*) FROM Comics c WHERE c.Series = series AND c.Volume = volume AND c.IssueNumber = IssueNumber AND c.CoverDate = CoverDate)")
@JsonProperty("duplicateCount")
@JsonView(View.ComicListView.class)
@JsonView({View.ComicListView.class, View.AuditLogEntryDetail.class})
private Integer duplicateCount;

@ManyToMany(
mappedBy = "comics",
cascade = {CascadeType.ALL})
@JsonProperty("readingLists")
@JsonView(View.ComicDetailsView.class)
@JsonView({View.ComicDetailsView.class, View.AuditLogEntryDetail.class})
@Getter
private Set<ReadingList> readingLists = new HashSet<>();

Expand Down Expand Up @@ -383,7 +383,7 @@ public void deletePage(int index) {
* @return the filename
*/
@JsonProperty("baseFilename")
@JsonView(View.ComicDetailsView.class)
@JsonView({View.ComicDetailsView.class, View.AuditLogEntryDetail.class})
public String getBaseFilename() {
return FilenameUtils.getName(this.filename);
}
Expand All @@ -409,7 +409,7 @@ public Page getCover() {
* @return <code>true</code> if the file is missing
*/
@JsonProperty("missing")
@JsonView(View.ComicListView.class)
@JsonView({View.ComicListView.class, View.AuditLogEntryDetail.class})
public boolean isMissing() {
if (this.backingFile == null) {
this.backingFile = new File(this.filename);
Expand All @@ -426,7 +426,7 @@ public int getIndexFor(Page page) {

@Transient
@JsonProperty("sortableIssueNumber")
@JsonView(View.ComicListView.class)
@JsonView({View.ComicListView.class, View.AuditLogEntryDetail.class})
public String getSortableIssueNumber() {
final String result = "00000" + (this.issueNumber != null ? this.issueNumber : "");

Expand Down Expand Up @@ -467,7 +467,7 @@ public Page getPage(int index) {
*/
@Transient
@JsonProperty("pageCount")
@JsonView(View.ComicListView.class)
@JsonView({View.ComicListView.class, View.AuditLogEntryDetail.class})
public int getPageCount() {
if (!this.pages.isEmpty()) return this.pages.size();
if (this.calculatedPageCount != null) return this.calculatedPageCount.intValue();
Expand All @@ -476,7 +476,7 @@ public int getPageCount() {

@Transient
@JsonProperty(value = "publishedYear")
@JsonView(View.ComicListView.class)
@JsonView({View.ComicListView.class, View.AuditLogEntryDetail.class})
public int getYearPublished() {
if (this.coverDate != null) {
GregorianCalendar calendar = new GregorianCalendar();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public class ComicFileDetails {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@JsonProperty("id")
@JsonView(View.ComicListView.class)
@JsonView({View.ComicListView.class, View.AuditLogEntryDetail.class})
@Getter
private Long id;

Expand All @@ -53,7 +53,7 @@ public class ComicFileDetails {

@Column(name = "FileHash", length = 32, nullable = false, updatable = true)
@JsonProperty("hash")
@JsonView(View.ComicListView.class)
@JsonView({View.ComicListView.class, View.AuditLogEntryDetail.class})
@Getter
@Setter
private String hash;
Expand Down

0 comments on commit 31c0064

Please sign in to comment.