Skip to content

Commit 4da9223

Browse files
committed
Merge pull request #12 from rwth-acis/develop
Rewrote created and lastupdated fields to work with older mysql insta…
2 parents 97953b1 + 9960a90 commit 4da9223

File tree

11 files changed

+56
-40
lines changed

11 files changed

+56
-40
lines changed

etc/ReqBaz_create.sql

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ SET FOREIGN_KEY_CHECKS = 0;
44
-- Table attachments
55
CREATE TABLE IF NOT EXISTS attachments (
66
Id INT NOT NULL AUTO_INCREMENT,
7-
creation_time TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
8-
lastupdated_time TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
7+
creation_time TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
8+
lastupdated_time TIMESTAMP NULL,
99
Requirement_Id INT NOT NULL,
1010
User_Id INT NOT NULL,
1111
title VARCHAR(255) NOT NULL,
@@ -26,8 +26,8 @@ CREATE TABLE IF NOT EXISTS attachments (
2626
CREATE TABLE IF NOT EXISTS comments (
2727
Id INT NOT NULL AUTO_INCREMENT,
2828
message TEXT NOT NULL,
29-
creation_time TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
30-
lastupdated_time TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
29+
creation_time TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
30+
lastupdated_time TIMESTAMP NULL,
3131
Requirement_Id INT NOT NULL,
3232
User_Id INT NOT NULL,
3333
CONSTRAINT comments_pk PRIMARY KEY (Id),
@@ -41,8 +41,8 @@ CREATE TABLE IF NOT EXISTS components (
4141
Id INT NOT NULL AUTO_INCREMENT,
4242
name VARCHAR(255) NOT NULL,
4343
description TEXT NOT NULL,
44-
creation_time TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
45-
lastupdated_time TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
44+
creation_time TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
45+
lastupdated_time TIMESTAMP NULL,
4646
Project_Id INT NOT NULL,
4747
Leader_Id INT NOT NULL,
4848
CONSTRAINT components_pk PRIMARY KEY (Id),
@@ -55,7 +55,7 @@ CREATE TABLE IF NOT EXISTS developers (
5555
Id INT NOT NULL AUTO_INCREMENT,
5656
Requirement_Id INT NOT NULL,
5757
User_Id INT NOT NULL,
58-
creation_time TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
58+
creation_time TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
5959
CONSTRAINT developers_pk PRIMARY KEY (Id),
6060
CONSTRAINT Developer_Requirement FOREIGN KEY Developer_Requirement (Requirement_Id) REFERENCES requirements (Id)
6161
ON DELETE CASCADE,
@@ -67,7 +67,7 @@ CREATE TABLE IF NOT EXISTS followers (
6767
Id INT NOT NULL AUTO_INCREMENT,
6868
Requirement_Id INT NOT NULL,
6969
User_Id INT NOT NULL,
70-
creation_time TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
70+
creation_time TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
7171
CONSTRAINT followers_pk PRIMARY KEY (Id),
7272
CONSTRAINT Follower_Requirement FOREIGN KEY Follower_Requirement (Requirement_Id) REFERENCES requirements (Id)
7373
ON DELETE CASCADE,
@@ -87,8 +87,8 @@ CREATE TABLE IF NOT EXISTS projects (
8787
name VARCHAR(255) NOT NULL,
8888
description TEXT NOT NULL,
8989
visibility CHAR(1) NOT NULL,
90-
creation_time TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
91-
lastupdated_time TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
90+
creation_time TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
91+
lastupdated_time TIMESTAMP NULL,
9292
Leader_Id INT NOT NULL,
9393
Default_Components_Id INT NULL,
9494
CONSTRAINT projects_pk PRIMARY KEY (Id),
@@ -102,8 +102,8 @@ CREATE TABLE IF NOT EXISTS requirements (
102102
title VARCHAR(255) NOT NULL,
103103
description TEXT NULL,
104104
realized TIMESTAMP NULL DEFAULT NULL,
105-
creation_time TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
106-
lastupdated_time TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
105+
creation_time TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
106+
lastupdated_time TIMESTAMP NULL,
107107
Lead_developer_Id INT NOT NULL,
108108
Creator_Id INT NOT NULL,
109109
Project_Id INT NOT NULL,

src/main/de/rwth/dbis/acis/bazaar/service/dal/jooq/tables/Attachments.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
@java.lang.SuppressWarnings({ "all", "unchecked", "rawtypes" })
1212
public class Attachments extends org.jooq.impl.TableImpl<de.rwth.dbis.acis.bazaar.service.dal.jooq.tables.records.AttachmentsRecord> {
1313

14-
private static final long serialVersionUID = 1060023319;
14+
private static final long serialVersionUID = 1778940691;
1515

1616
/**
1717
* The singleton instance of <code>reqbaz.attachments</code>
@@ -39,7 +39,7 @@ public java.lang.Class<de.rwth.dbis.acis.bazaar.service.dal.jooq.tables.records.
3939
/**
4040
* The column <code>reqbaz.attachments.lastupdated_time</code>.
4141
*/
42-
public final org.jooq.TableField<de.rwth.dbis.acis.bazaar.service.dal.jooq.tables.records.AttachmentsRecord, java.sql.Timestamp> LASTUPDATED_TIME = createField("lastupdated_time", org.jooq.impl.SQLDataType.TIMESTAMP.nullable(false).defaulted(true), this, "");
42+
public final org.jooq.TableField<de.rwth.dbis.acis.bazaar.service.dal.jooq.tables.records.AttachmentsRecord, java.sql.Timestamp> LASTUPDATED_TIME = createField("lastupdated_time", org.jooq.impl.SQLDataType.TIMESTAMP, this, "");
4343

4444
/**
4545
* The column <code>reqbaz.attachments.Requirement_Id</code>.

src/main/de/rwth/dbis/acis/bazaar/service/dal/jooq/tables/Comments.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
@java.lang.SuppressWarnings({ "all", "unchecked", "rawtypes" })
1212
public class Comments extends org.jooq.impl.TableImpl<de.rwth.dbis.acis.bazaar.service.dal.jooq.tables.records.CommentsRecord> {
1313

14-
private static final long serialVersionUID = 2130477508;
14+
private static final long serialVersionUID = -1225014848;
1515

1616
/**
1717
* The singleton instance of <code>reqbaz.comments</code>
@@ -44,7 +44,7 @@ public java.lang.Class<de.rwth.dbis.acis.bazaar.service.dal.jooq.tables.records.
4444
/**
4545
* The column <code>reqbaz.comments.lastupdated_time</code>.
4646
*/
47-
public final org.jooq.TableField<de.rwth.dbis.acis.bazaar.service.dal.jooq.tables.records.CommentsRecord, java.sql.Timestamp> LASTUPDATED_TIME = createField("lastupdated_time", org.jooq.impl.SQLDataType.TIMESTAMP.nullable(false).defaulted(true), this, "");
47+
public final org.jooq.TableField<de.rwth.dbis.acis.bazaar.service.dal.jooq.tables.records.CommentsRecord, java.sql.Timestamp> LASTUPDATED_TIME = createField("lastupdated_time", org.jooq.impl.SQLDataType.TIMESTAMP, this, "");
4848

4949
/**
5050
* The column <code>reqbaz.comments.Requirement_Id</code>.

src/main/de/rwth/dbis/acis/bazaar/service/dal/jooq/tables/Components.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
@java.lang.SuppressWarnings({ "all", "unchecked", "rawtypes" })
1212
public class Components extends org.jooq.impl.TableImpl<de.rwth.dbis.acis.bazaar.service.dal.jooq.tables.records.ComponentsRecord> {
1313

14-
private static final long serialVersionUID = 2046179571;
14+
private static final long serialVersionUID = 189665007;
1515

1616
/**
1717
* The singleton instance of <code>reqbaz.components</code>
@@ -49,7 +49,7 @@ public java.lang.Class<de.rwth.dbis.acis.bazaar.service.dal.jooq.tables.records.
4949
/**
5050
* The column <code>reqbaz.components.lastupdated_time</code>.
5151
*/
52-
public final org.jooq.TableField<de.rwth.dbis.acis.bazaar.service.dal.jooq.tables.records.ComponentsRecord, java.sql.Timestamp> LASTUPDATED_TIME = createField("lastupdated_time", org.jooq.impl.SQLDataType.TIMESTAMP.nullable(false).defaulted(true), this, "");
52+
public final org.jooq.TableField<de.rwth.dbis.acis.bazaar.service.dal.jooq.tables.records.ComponentsRecord, java.sql.Timestamp> LASTUPDATED_TIME = createField("lastupdated_time", org.jooq.impl.SQLDataType.TIMESTAMP, this, "");
5353

5454
/**
5555
* The column <code>reqbaz.components.Project_Id</code>.

src/main/de/rwth/dbis/acis/bazaar/service/dal/jooq/tables/Projects.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
@java.lang.SuppressWarnings({ "all", "unchecked", "rawtypes" })
1212
public class Projects extends org.jooq.impl.TableImpl<de.rwth.dbis.acis.bazaar.service.dal.jooq.tables.records.ProjectsRecord> {
1313

14-
private static final long serialVersionUID = -694816984;
14+
private static final long serialVersionUID = 1697564844;
1515

1616
/**
1717
* The singleton instance of <code>reqbaz.projects</code>
@@ -54,7 +54,7 @@ public java.lang.Class<de.rwth.dbis.acis.bazaar.service.dal.jooq.tables.records.
5454
/**
5555
* The column <code>reqbaz.projects.lastupdated_time</code>.
5656
*/
57-
public final org.jooq.TableField<de.rwth.dbis.acis.bazaar.service.dal.jooq.tables.records.ProjectsRecord, java.sql.Timestamp> LASTUPDATED_TIME = createField("lastupdated_time", org.jooq.impl.SQLDataType.TIMESTAMP.nullable(false).defaulted(true), this, "");
57+
public final org.jooq.TableField<de.rwth.dbis.acis.bazaar.service.dal.jooq.tables.records.ProjectsRecord, java.sql.Timestamp> LASTUPDATED_TIME = createField("lastupdated_time", org.jooq.impl.SQLDataType.TIMESTAMP, this, "");
5858

5959
/**
6060
* The column <code>reqbaz.projects.Leader_Id</code>.

src/main/de/rwth/dbis/acis/bazaar/service/dal/jooq/tables/Requirements.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
@java.lang.SuppressWarnings({ "all", "unchecked", "rawtypes" })
1212
public class Requirements extends org.jooq.impl.TableImpl<de.rwth.dbis.acis.bazaar.service.dal.jooq.tables.records.RequirementsRecord> {
1313

14-
private static final long serialVersionUID = 167100441;
14+
private static final long serialVersionUID = -1147081827;
1515

1616
/**
1717
* The singleton instance of <code>reqbaz.requirements</code>
@@ -54,7 +54,7 @@ public java.lang.Class<de.rwth.dbis.acis.bazaar.service.dal.jooq.tables.records.
5454
/**
5555
* The column <code>reqbaz.requirements.lastupdated_time</code>.
5656
*/
57-
public final org.jooq.TableField<de.rwth.dbis.acis.bazaar.service.dal.jooq.tables.records.RequirementsRecord, java.sql.Timestamp> LASTUPDATED_TIME = createField("lastupdated_time", org.jooq.impl.SQLDataType.TIMESTAMP.nullable(false).defaulted(true), this, "");
57+
public final org.jooq.TableField<de.rwth.dbis.acis.bazaar.service.dal.jooq.tables.records.RequirementsRecord, java.sql.Timestamp> LASTUPDATED_TIME = createField("lastupdated_time", org.jooq.impl.SQLDataType.TIMESTAMP, this, "");
5858

5959
/**
6060
* The column <code>reqbaz.requirements.Lead_developer_Id</code>.

src/main/de/rwth/dbis/acis/bazaar/service/dal/transform/AttachmentTransformator.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,8 @@ public class AttachmentTransformator implements Transformator<de.rwth.dbis.acis.
4141
@Override
4242
public AttachmentsRecord createRecord(Attachment entity) {
4343
AttachmentsRecord attachmentsRecord = new AttachmentsRecord();
44-
45-
// attachmentsRecord.setId(entity.getId());
4644
attachmentsRecord.setCreationTime(new Timestamp(entity.getCreation_time().getTime()));
45+
attachmentsRecord.setLastupdatedTime(attachmentsRecord.getCreationTime());
4746
attachmentsRecord.setRequirementId(entity.getRequirementId());
4847
attachmentsRecord.setUserId(entity.getCreatorId());
4948
attachmentsRecord.setTitle(entity.getTitle());
@@ -185,11 +184,15 @@ public Class<? extends AttachmentsRecord> getRecordClass() {
185184

186185
@Override
187186
public Map<Field, Object> getUpdateMap(final Attachment entity) {
188-
return new HashMap<Field, Object>() {{
187+
HashMap<Field, Object> updateMap = new HashMap<Field, Object>() {{
189188
put(ATTACHMENTS.USER_ID, entity.getCreatorId());
190189
put(ATTACHMENTS.TITLE, entity.getTitle());
191190
put(ATTACHMENTS.REQUIREMENT_ID, entity.getRequirementId());
192191
}};
192+
if (!updateMap.isEmpty()) {
193+
updateMap.put(ATTACHMENTS.LASTUPDATED_TIME, new java.sql.Timestamp(Calendar.getInstance().getTime().getTime()));
194+
}
195+
return updateMap;
193196
}
194197

195198
@Override

src/main/de/rwth/dbis/acis/bazaar/service/dal/transform/CommentTransformator.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,11 @@ public class CommentTransformator implements Transformator<de.rwth.dbis.acis.baz
3838
@Override
3939
public CommentsRecord createRecord(Comment entity) {
4040
CommentsRecord record = new CommentsRecord();
41-
// record.setId(entity.getId());
4241
record.setUserId(entity.getCreatorId());
4342
record.setMessage(entity.getMessage());
4443
record.setRequirementId(entity.getRequirementId());
4544
record.setCreationTime(new Timestamp(Calendar.getInstance().getTime().getTime()));
45+
record.setLastupdatedTime(record.getCreationTime());
4646
return record;
4747
}
4848

@@ -74,11 +74,15 @@ public Class<? extends CommentsRecord> getRecordClass() {
7474

7575
@Override
7676
public Map<Field, Object> getUpdateMap(final Comment entity) {
77-
return new HashMap<Field, Object>() {{
77+
HashMap<Field, Object> updateMap = new HashMap<Field, Object>() {{
7878
put(COMMENTS.REQUIREMENT_ID, entity.getRequirementId());
7979
put(COMMENTS.USER_ID, entity.getCreatorId());
8080
put(COMMENTS.MESSAGE, entity.getMessage());
8181
}};
82+
if (!updateMap.isEmpty()) {
83+
updateMap.put(COMMENTS.LASTUPDATED_TIME, new java.sql.Timestamp(Calendar.getInstance().getTime().getTime()));
84+
}
85+
return updateMap;
8286
}
8387

8488
@Override

src/main/de/rwth/dbis/acis/bazaar/service/dal/transform/ComponentTransformator.java

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,7 @@
2727

2828
import static de.rwth.dbis.acis.bazaar.service.dal.jooq.tables.Components.COMPONENTS;
2929

30-
import java.util.Arrays;
31-
import java.util.Collection;
32-
import java.util.HashMap;
33-
import java.util.Map;
30+
import java.util.*;
3431

3532
/**
3633
* @author Adam Gavronek <gavronek@dbis.rwth-aachen.de>
@@ -43,8 +40,9 @@ public ComponentsRecord createRecord(Component entry) {
4340
record.setDescription(entry.getDescription());
4441
record.setName(entry.getName());
4542
record.setProjectId(entry.getProjectId());
46-
// record.setId(entry.getId());
4743
record.setLeaderId(entry.getLeaderId());
44+
record.setCreationTime(new java.sql.Timestamp(Calendar.getInstance().getTime().getTime()));
45+
record.setLastupdatedTime(record.getCreationTime());
4846
return record;
4947
}
5048

@@ -77,14 +75,18 @@ public Class<? extends ComponentsRecord> getRecordClass() {
7775

7876
@Override
7977
public Map<Field, Object> getUpdateMap(final Component entry) {
80-
return new HashMap<Field, Object>() {{
78+
HashMap<Field, Object> updateMap = new HashMap<Field, Object>() {{
8179
if (entry.getDescription() != null) {
8280
put(COMPONENTS.DESCRIPTION, entry.getDescription());
8381
}
8482
if (entry.getName() != null) {
8583
put(COMPONENTS.NAME, entry.getName());
8684
}
8785
}};
86+
if (!updateMap.isEmpty()) {
87+
updateMap.put(COMPONENTS.LASTUPDATED_TIME, new java.sql.Timestamp(Calendar.getInstance().getTime().getTime()));
88+
}
89+
return updateMap;
8890
}
8991

9092
@Override

src/main/de/rwth/dbis/acis/bazaar/service/dal/transform/ProjectTransformator.java

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,7 @@
2828

2929
import org.jooq.*;
3030

31-
import java.util.Arrays;
32-
import java.util.Collection;
33-
import java.util.HashMap;
34-
import java.util.Map;
31+
import java.util.*;
3532

3633
/**
3734
* @author Adam Gavronek <gavronek@dbis.rwth-aachen.de>
@@ -41,12 +38,13 @@ public class ProjectTransformator implements Transformator<de.rwth.dbis.acis.baz
4138
@Override
4239
public ProjectsRecord createRecord(Project entry) {
4340
ProjectsRecord record = new ProjectsRecord();
44-
// record.setId(entry.getId());
4541
record.setDescription(entry.getDescription());
4642
record.setName(entry.getName());
4743
record.setLeaderId(entry.getLeaderId());
4844
record.setVisibility(entry.getVisibility().asChar());
4945
record.setDefaultComponentsId(entry.getDefaultComponentId());
46+
record.setCreationTime(new java.sql.Timestamp(Calendar.getInstance().getTime().getTime()));
47+
record.setLastupdatedTime(record.getCreationTime());
5048
return record;
5149
}
5250

@@ -80,7 +78,7 @@ public Class<? extends ProjectsRecord> getRecordClass() {
8078

8179
@Override
8280
public Map<Field, Object> getUpdateMap(final Project entry) {
83-
return new HashMap<Field, Object>() {{
81+
HashMap<Field, Object> updateMap = new HashMap<Field, Object>() {{
8482
if (entry.getDescription() != null) {
8583
put(PROJECTS.DESCRIPTION, entry.getDescription());
8684
}
@@ -97,6 +95,10 @@ public Map<Field, Object> getUpdateMap(final Project entry) {
9795
put(PROJECTS.VISIBILITY, entry.getVisibility().asChar());
9896
}
9997
}};
98+
if (!updateMap.isEmpty()) {
99+
updateMap.put(PROJECTS.LASTUPDATED_TIME, new java.sql.Timestamp(Calendar.getInstance().getTime().getTime()));
100+
}
101+
return updateMap;
100102
}
101103

102104
@Override

0 commit comments

Comments
 (0)