-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathThothResource.java
More file actions
78 lines (66 loc) · 2.24 KB
/
ThothResource.java
File metadata and controls
78 lines (66 loc) · 2.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
package model;
import dtos.ResourceDto;
public abstract class ThothResource {
private final int id;
private final int classId;
private final String title;
private final String description;
private final Type type;
enum Type {FILE, BOOK, LINK}
protected ThothResource(int id, int classId, String title, String description, Type type) {
this.id = id;
this.classId = classId;
this.title = title;
this.description = description;
this.type = type;
}
protected abstract String getDetails();
public static ThothResource parseResourceDto(ResourceDto resourceDto) {
String type = resourceDto.getType();
if(type.equalsIgnoreCase("Book"))
return new ThothBook(resourceDto.getId(),
resourceDto.getClassId(),
resourceDto.getTitle(),
resourceDto.getDescription(),
resourceDto.getIsbn(),
resourceDto.getAuthors());
else if(type.equalsIgnoreCase("File"))
return new ThothFile(resourceDto.getId(),
resourceDto.getClassId(),
resourceDto.getTitle(),
resourceDto.getDescription(),
resourceDto.getFileName(),
resourceDto.getContentType());
else if(type.equalsIgnoreCase("Link"))
return new ThothLink(resourceDto.getId(),
resourceDto.getClassId(),
resourceDto.getTitle(),
resourceDto.getDescription(),
resourceDto.getLinkUrl());
return null;
}
public int getId() {
return id;
}
public int getClassId() {
return classId;
}
public String getTitle() {
return title;
}
public String getDescription() {
return description;
}
public Type getType() {
return type;
}
@Override
public String toString() {
return "{id: " + id +
", ClassID: " + classId +
", Title: \"" + title +
"\", Description: \"" + description +
"\", Type: \"" + type +
"\", ResourceDetails: {" + getDetails() + "}}";
}
}