Skip to content

Commit 01187d9

Browse files
committed
Fixed #129, Fixed #126, working on 168
1 parent 9b49135 commit 01187d9

File tree

7 files changed

+33
-22
lines changed

7 files changed

+33
-22
lines changed

src/main/java/org/woehlke/simpleworklist/common/AuditModel.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
package org.woehlke.simpleworklist.common;
22

33
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
4+
import org.hibernate.id.UUIDGenerator;
45
import org.springframework.data.annotation.CreatedDate;
56
import org.springframework.data.annotation.LastModifiedDate;
67
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
78

89
import javax.persistence.*;
9-
import javax.validation.constraints.NotNull;
1010
import java.io.Serializable;
1111
import java.util.Date;
1212
import java.util.Objects;
13-
import java.util.UUID;
1413

14+
;
1515
@MappedSuperclass
1616
@EntityListeners(AuditingEntityListener.class)
1717
@JsonIgnoreProperties(
@@ -22,9 +22,8 @@ public class AuditModel implements Serializable {
2222

2323
private static final long serialVersionUID = 4399373914714726911L;
2424

25-
@NotNull
2625
@Column(name="uuid", nullable = false)
27-
protected String uuid = UUID.randomUUID().toString();
26+
protected String uuid;
2827

2928
@Temporal(TemporalType.TIMESTAMP)
3029
@Column(name = "row_created_at", nullable = false, updatable = false)

src/main/java/org/woehlke/simpleworklist/context/Context.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
package org.woehlke.simpleworklist.context;
22

33
import lombok.*;
4+
import org.hibernate.annotations.LazyToOne;
45
import org.hibernate.validator.constraints.Length;
6+
7+
import javax.validation.Valid;
58
import javax.validation.constraints.NotBlank;
69
import org.hibernate.validator.constraints.SafeHtml;
710
import org.woehlke.simpleworklist.common.AuditModel;
@@ -13,6 +16,8 @@
1316
import java.io.Serializable;
1417
import java.util.Objects;
1518

19+
import static org.hibernate.annotations.LazyToOneOption.PROXY;
20+
1621
/**
1722
* Created by tw on 13.03.16.
1823
*/
@@ -56,16 +61,17 @@ public class Context extends AuditModel implements Serializable, ComparableById<
5661
CascadeType.REFRESH
5762
})
5863
@JoinColumn(name = "user_account_id")
64+
@LazyToOne(PROXY)
5965
private UserAccount userAccount;
6066

6167
@SafeHtml(whitelistType = SafeHtml.WhiteListType.NONE)
62-
@NotBlank
68+
//@NotBlank
6369
@Length(min = 1, max = 255)
6470
@Column(name = "name_de", nullable = false)
6571
private String nameDe;
6672

6773
@SafeHtml(whitelistType = SafeHtml.WhiteListType.NONE)
68-
@NotBlank
74+
//@NotBlank
6975
@Length(min = 1, max = 255)
7076
@Column(name = "name_en", nullable = false)
7177
private String nameEn;

src/main/java/org/woehlke/simpleworklist/task/Task.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,15 @@
1010

1111
import lombok.Getter;
1212
import lombok.Setter;
13+
import org.hibernate.annotations.LazyToOne;
1314
import org.hibernate.annotations.OnDelete;
1415
import org.hibernate.annotations.OnDeleteAction;
1516
import org.hibernate.validator.constraints.Length;
17+
18+
import javax.validation.Valid;
1619
import javax.validation.constraints.NotBlank;
20+
import javax.validation.constraints.NotNull;
21+
1722
import org.hibernate.validator.constraints.SafeHtml;
1823
import org.springframework.format.annotation.DateTimeFormat;
1924
import org.woehlke.simpleworklist.context.Context;
@@ -23,6 +28,8 @@
2328
import org.woehlke.simpleworklist.common.AuditModel;
2429
import org.woehlke.simpleworklist.common.ComparableById;
2530

31+
import static org.hibernate.annotations.LazyToOneOption.PROXY;
32+
2633
@Entity
2734
@Table(
2835
name="task",
@@ -83,10 +90,10 @@ public class Task extends AuditModel implements Serializable, ComparableById<Tas
8390
)
8491
@JoinColumn(name = "context_id")
8592
@OnDelete(action = OnDeleteAction.NO_ACTION)
93+
@LazyToOne(PROXY)
8694
private Context context;
8795

8896
@Deprecated
89-
9097
@SafeHtml(whitelistType= SafeHtml.WhiteListType.NONE)
9198
@NotBlank
9299
@Length(min=1,max=255)

src/main/java/org/woehlke/simpleworklist/taskstate/TaskStateMoveController.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,9 +111,11 @@ public final String editTaskGet(
111111
} else {
112112
thisProject = task.getProject();
113113
}
114-
model.addAttribute("thisProject", thisProject);
114+
Context thisContext = task.getContext();
115115
Breadcrumb breadcrumb = breadcrumbService.getBreadcrumbForShowOneProject(thisProject,locale);
116116
model.addAttribute("breadcrumb", breadcrumb);
117+
model.addAttribute("thisProject", thisProject);
118+
model.addAttribute("thisContext", thisContext);
117119
model.addAttribute("task", task);
118120
model.addAttribute("areas", contexts);
119121
return "taskstate/task/edit";

src/main/java/org/woehlke/simpleworklist/user/account/UserAccount.java

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ public class UserAccount extends AuditModel implements Serializable, ComparableB
4040
initialValue = 1000
4141
)
4242
private Long id;
43-
4443
@Email
4544
@Column(name="user_email", nullable = false)
4645
private String userEmail;
@@ -61,31 +60,30 @@ public class UserAccount extends AuditModel implements Serializable, ComparableB
6160
fetch = FetchType.LAZY,
6261
optional = true,
6362
cascade = {
64-
CascadeType.MERGE,
65-
CascadeType.REFRESH
63+
CascadeType.REFRESH
6664
}
6765
)
6866
@JoinColumn(name = "default_context_id",nullable=true)
6967
private Context defaultContext;
7068

71-
@NotNull
69+
//@NotNull
7270
@Temporal(value = TemporalType.TIMESTAMP)
7371
@Column(name="last_login_timestamp", nullable = false)
7472
private Date lastLoginTimestamp;
7573

76-
@NotNull
74+
//@NotNull
7775
@Column(name="account_non_expired", nullable = false)
7876
private Boolean accountNonExpired=true;
7977

80-
@NotNull
78+
//@NotNull
8179
@Column(name="account_non_locked", nullable = false)
8280
private Boolean accountNonLocked=true;
8381

84-
@NotNull
82+
//@NotNull
8583
@Column(name="credentials_non_expired", nullable = false)
8684
private Boolean credentialsNonExpired=true;
8785

88-
@NotNull
86+
//@NotNull
8987
@Column(name="enabled", nullable = false)
9088
private Boolean enabled=true;
9189

src/main/java/org/woehlke/simpleworklist/user/account/UserAccountServiceImpl.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
package org.woehlke.simpleworklist.user.account;
22

33

4-
import java.util.Date;
5-
import java.util.HashMap;
6-
import java.util.List;
7-
import java.util.Map;
4+
import java.util.*;
85

96
import lombok.extern.slf4j.Slf4j;
7+
import org.hibernate.id.UUIDGenerator;
108
import org.springframework.beans.factory.annotation.Autowired;
119

1210
import org.springframework.data.domain.Page;
@@ -49,6 +47,7 @@ public boolean isEmailAvailable(String email) {
4947
@Transactional(propagation = Propagation.REQUIRES_NEW, readOnly = false)
5048
public void createUser(UserAccountForm userAccount) {
5149
UserAccount u = new UserAccount();
50+
u.setUuid(UUID.randomUUID().toString());
5251
u.setUserEmail(userAccount.getUserEmail());
5352
u.setUserFullname(userAccount.getUserFullname());
5453
u.setUserPassword(encoder.encode(userAccount.getUserPassword()));
@@ -63,6 +62,8 @@ public void createUser(UserAccountForm userAccount) {
6362
u = userAccountRepository.save(u);
6463
Context workContext = new Context("Arbeit","Work");
6564
Context privContext = new Context("Privat","Private");
65+
workContext.setUuid(UUID.randomUUID().toString());
66+
privContext.setUuid(UUID.randomUUID().toString());
6667
workContext.setUserAccount(u);
6768
privContext.setUserAccount(u);
6869
log.info("About to save " + workContext.toString());

src/main/resources/templates/taskstate/task/edit.html

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@ <h1>
2121
<div>
2222
<form id="formId" th:action="@{/taskstate/task/{taskId}/edit(taskId=${task.id})}" th:object="${task}" method="post">
2323
<input type="hidden" th:field="*{id}" />
24-
<input type="hidden" th:field="*{taskState}" />
25-
<input type="hidden" th:field="*{context.id}" />
2624
<input type="hidden" th:field="*{rowCreatedAt.time}" />
2725
<div class="form-group">
2826
<label th:for="${#ids.next('title')}" class="control-label">

0 commit comments

Comments
 (0)