Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Your application allows you to manage Task and Project entities. You have to add missing annotations and code over entity classes and converters to make

Your application allows you to manage Task and Project
entities.
You have to add missing annotations and code over entity classes
and converters to make it possible to store Task and Project
and their relations in specified tables.
:Requirements:
(1).Project. updates should be persisted in a table with thefollowing structure:
Table name: PROJECT_EVENT_UPDATES
Columns:
PROJECT_ID : foreign key;
USER_NAME : value of Itemupdate.user ;
EVENT_DATE: value of Itemupdate. date
(2)Task.watchers should be persisted in a table with the
Table name: TODO_WATCHERS :
Columns:TODO_ID : foreign key;
LOGIN: value of string from the set.
(3) Task.comments should prsisted in a table with the following structur
TODO_Table name: COMMENTS with columns TODO_ID,AUTHOR,ADD_DATE, COMMENT ;
(4)Task.updates should prsisted in a table with the following structur
1.Table name:TODO_UPDATES
2.columns:
1.TODO_ID:foreing key2.AUTHOR:value of Itemupdate.user 3.UPDATE_DATE:value of Itemupdate.user
(5)Task.tags should be persisted in a table with the following structure
1.Table name:TODO_TAGS
2.columns:
1.TODO_ID:foreing key2.Name:key from the Map3.DESCRIPTION:value of Map
The following tables should exist after implementation:
1. PROJECTS with columnS PROJECT_ID,NAME ;2.PROJECT_EVENT_UPDATES with columnS PROJECT_ID,USER_NAME, EVENT_DATE ;
3.TODOS with columns TODO_ID,SUBJECT, DETAILS;4.TODO_WATCHERS with columnS TODO_ID,LOGIN ;
5.TODO_COMMENTS with columns TODO_ID,AUTHOR,ADD_DATE, COMMENT ;6.TODO_UPDATES with columns TODO_ID,AUTHOR,UPDATE_DATE;
7.TODO_WATCHERS with columnS TODO_ID,NAME,DESCRIPTION .
@Entity
@Table(name = "PROJECTS")
@NoArgsConstructor(access=AccessLevel.PRIVATE)
public class Project {
@Id
@Column(name = "PROJECT_ID")
private Long id;
@Column(name = "NAME",nullable = false)
private String name;
@Transient
private List updates=new ArrayList<>() ;
private Project(ProjectBuilder builder)
{this.id=builder.id;this.name=builder.name; this.updates=builder.updates;}
static ProjectBuilder builder(Long id,String name)
{
return new ProjectBuilder(id,name);
}
static class ProjectBuilder
{private final Long id;private final String name;
private final List updates=new ArrayList<>();
ProjectBuilder(Long id,String name)
{this.id=id;this.name=name;
}
ProjectBuilder add(ItemUpdate update)
{updates.add(update);
return this;
}
Project build(){return new Project(this);}
@Entity
@Table(name = "TODOS")
@NoArgsConstructor(access=AccessLevel.PRIVATE)
public class Task {
@Id
@Column(name = "TODO_ID")
private Long id;
@Column(name = "SUBJECT",nullable = false)
private String subject;
@Column(name = "DETAILS",columnDefinition = "CLOB")
private String details;
@Transient
private Set watchers=new HashSet<>();
@Transient
private List comments=new ArrayList<>();
@Transient
private List<ItemUpdate> updates=new ArrayList<>();
@Transient
private Map<String,String> tags=new HashMap<>();
private Task(TaskBuilder builder)
{
this.id=builder.id;this.subject=builder.subject;this.details=builder.details;this.watchers=builder.watchers;this.comments=builder.comments;
this.updates=builder.updates;
this.tags=builder.tags;}
static TaskBuilder builder(Long id,String subject,String details)
{
return new TaskBuilder(id,subject,details);
}
static class TaskBuilder
{
private final Long id;private final String subject;private final String details;private final Set<String> watchers=new HashSet<>();
private final List<Comment> comments=new ArrayList<>();
private final List<ItemUpdate> updates=new ArrayList<>();
private final Map<String,String> tags=new HashMap<>();
public TaskBuilder(Long id, String subject, String details){}
TaskBuilder addWatcher(String watcher)
{watchers.add(watcher); return this;
}
TaskBuilder add(Comment comment)
{comments.add(comment);return this;
}
TaskBuilder add(ItemUpdate update)
{updates.add(update);return this;}
TaskBuilder addTag(String name,String description)
{tags.put(name,description);return this;}
Task build()
{return new Task(this);}
@Embeddable
@NoArgsConstructor(access=AccessLevel.PRIVATE)
public class ItemUpdate {private String user;private LocalDate date;}
@Embeddable
@NoArgsConstructor(access=AccessLevel.PRIVATE)
public class Comment {
@Column(name = "AUTHOR")
private String author;
@Column(name = "ADD_DATE")
private LocalDate date;
@Column(name = "COMMENT")
private String comment;
}\table[[Project.java </p><code class="asciimath">x</code><p>,Task.java </p><code class="asciimath">x</code></div><div><img src='https://media.cheggcdn.com/study/7fd/7fd3015c-2a5e-47cb-a844-6dd7f4cf435b/IMG-20240120-WA0044.jpg'/></div>

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Transactions On Large Scale Data And Knowledge Centered Systems Iv Special Issue On Database Systems For Biomedical Applications Lncs 6990

Authors: Abdelkader Hameurlain ,Josef Kung ,Roland Wagner ,Christian Bohm ,Johann Eder ,Claudia Plant

2011th Edition

3642237398, 978-3642237393

More Books

Students also viewed these Databases questions