BrightSide Workbench Full Report + Source Code
CommentItEntry.java
Go to the documentation of this file.
1 /*
2  * TurrĂ³ i Cutiller Foundation. License notice.
3  * Copyright (C) 2021 Lluis TurrĂ³ Cutiller <http://www.turro.org/>
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU Affero General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU Affero General Public License for more details.
14  *
15  * You should have received a copy of the GNU Affero General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  */
18 
19 package org.turro.forum;
20 
21 import java.util.Date;
22 import org.turro.elephant.entities.db.Post;
23 import org.turro.elephant.entities.db.Topic;
24 import org.turro.forum.db.UniquePath;
25 import org.turro.jpa.Dao;
26 
31 public class CommentItEntry {
32 
33  private final String entityPath;
34  private final String contactId;
35  private final Date dateCreation;
36  private final String body;
37 
38  public CommentItEntry(String entityPath, String contactId, Date dateCreation, String body) {
39  this.entityPath = entityPath;
40  this.contactId = contactId;
41  this.dateCreation = dateCreation;
42  this.body = body;
43  }
44 
45  public String getEntityPath() {
46  return entityPath;
47  }
48 
49  public String getContactId() {
50  return contactId;
51  }
52 
53  public Date getDateCreation() {
54  return dateCreation;
55  }
56 
57  public String getBody() {
58  return body;
59  }
60 
61  public Topic migrateTopic(Dao dao) {
62  Topic topic = new Topic();
63  topic.setAuthorId(contactId);
64  topic.setCreation(dateCreation);
65  topic.setEntityPath(entityPath);
66  topic.setText(body);
67  topic = dao.saveObject(topic);
69  return topic;
70  }
71 
72  public void migratePost(Dao dao, Topic topic) {
73  Post post = new Post();
74  post.setAuthorId(contactId);
75  post.setCreation(dateCreation);
76  post.setText(body);
77  post.setTopic(topic);
78  post = dao.saveObject(post);
80  }
81 
82 }
void setAuthorId(String authorId)
Definition: Post.java:116
void setCreation(Date creation)
Definition: Post.java:124
void setTopic(Topic topic)
Definition: Post.java:91
void setCreation(Date creation)
Definition: Topic.java:114
void setEntityPath(String entityPath)
Definition: Topic.java:88
void setAuthorId(String authorId)
Definition: Topic.java:106
CommentItEntry(String entityPath, String contactId, Date dateCreation, String body)
void migratePost(Dao dao, Topic topic)
static void normalizeUniquePaths(Topic topic)
Definition: UniquePath.java:35