
Added organization
@cc48414f8f0ecce12890538427520f9fa84ee3b6
+++ app/models/Organization.java
... | ... | @@ -0,0 +1,35 @@ |
1 | +package models; | |
2 | + | |
3 | +import play.data.format.Formats; | |
4 | +import play.db.ebean.Model; | |
5 | + | |
6 | +import javax.persistence.*; | |
7 | +import java.util.Date; | |
8 | +import java.util.List; | |
9 | + | |
10 | +/** | |
11 | + * @author Keeun Baik | |
12 | + */ | |
13 | +@Entity | |
14 | +public class Organization extends Model { | |
15 | + | |
16 | + private static final long serialVersionUID = -1L; | |
17 | + | |
18 | + @Id | |
19 | + public Long id; | |
20 | + | |
21 | + public String name; | |
22 | + | |
23 | + @Formats.DateTime(pattern = "yyyy-MM-dd") | |
24 | + public Date created; | |
25 | + | |
26 | + @OneToMany(mappedBy = "organization", cascade = CascadeType.ALL) | |
27 | + public List<Project> projects; | |
28 | + | |
29 | + @OneToMany(mappedBy = "organization", cascade = CascadeType.ALL) | |
30 | + public List<OrganizationUser> users; | |
31 | + | |
32 | + public String descr; | |
33 | + | |
34 | + | |
35 | +} |
+++ app/models/OrganizationUser.java
... | ... | @@ -0,0 +1,29 @@ |
1 | +package models; | |
2 | + | |
3 | +import play.db.ebean.Model; | |
4 | + | |
5 | +import javax.persistence.Entity; | |
6 | +import javax.persistence.Id; | |
7 | +import javax.persistence.ManyToOne; | |
8 | + | |
9 | +/** | |
10 | + * @author Keeun Baik | |
11 | + */ | |
12 | +@Entity | |
13 | +public class OrganizationUser extends Model { | |
14 | + | |
15 | + private static final long serialVersionUID = -1L; | |
16 | + | |
17 | + @Id | |
18 | + public Long id; | |
19 | + | |
20 | + @ManyToOne | |
21 | + public User user; | |
22 | + | |
23 | + @ManyToOne | |
24 | + public Organization organization; | |
25 | + | |
26 | + @ManyToOne | |
27 | + public Role role; | |
28 | + | |
29 | +} |
--- app/models/Project.java
+++ app/models/Project.java
... | ... | @@ -4,6 +4,7 @@ |
4 | 4 |
import com.avaje.ebean.ExpressionList; |
5 | 5 |
import com.avaje.ebean.Page; |
6 | 6 |
import controllers.routes; |
7 |
+import models.enumeration.ProjectScope; |
|
7 | 8 |
import models.enumeration.RequestState; |
8 | 9 |
import models.enumeration.ResourceType; |
9 | 10 |
import models.enumeration.RoleType; |
... | ... | @@ -117,6 +118,12 @@ |
117 | 118 |
|
118 | 119 |
public boolean isUsingReviewerCount; |
119 | 120 |
|
121 |
+ @ManyToOne |
|
122 |
+ public Organization organization; |
|
123 |
+ |
|
124 |
+ @Enumerated(EnumType.STRING) |
|
125 |
+ public ProjectScope projectScope; |
|
126 |
+ |
|
120 | 127 |
/** |
121 | 128 |
* 신규 프로젝트를 생성한다. |
122 | 129 |
* |
--- app/models/User.java
+++ app/models/User.java
... | ... | @@ -146,6 +146,9 @@ |
146 | 146 |
@OneToOne(mappedBy = "user", cascade = CascadeType.ALL) |
147 | 147 |
public RecentlyVisitedProjects recentlyVisitedProjects; |
148 | 148 |
|
149 |
+ @OneToMany(mappedBy = "user", cascade = CascadeType.ALL) |
|
150 |
+ public List<OrganizationUser> organizationUsers; |
|
151 |
+ |
|
149 | 152 |
public User() { |
150 | 153 |
} |
151 | 154 |
|
+++ app/models/enumeration/ProjectScope.java
... | ... | @@ -0,0 +1,9 @@ |
1 | +package models.enumeration; | |
2 | + | |
3 | +/** | |
4 | + * @author Keeun Baik | |
5 | + */ | |
6 | +public enum ProjectScope { | |
7 | + | |
8 | + PRIVATE, PROTECTED, PUBLIC; | |
9 | +} |
+++ conf/evolutions/default/63.sql
... | ... | @@ -0,0 +1,49 @@ |
1 | +# --- !Ups | |
2 | +create table organization ( | |
3 | + id bigint not null, | |
4 | + name varchar(255), | |
5 | + descr varchar(255), | |
6 | + created timestamp, | |
7 | + constraint pk_organization primary key (id) | |
8 | +); | |
9 | +create sequence organization_seq; | |
10 | + | |
11 | +create table organization_user ( | |
12 | + id bigint not null, | |
13 | + user_id bigint, | |
14 | + organization_id bigint, | |
15 | + role_id bigint, | |
16 | + constraint pk_organization_user primary key (id)) | |
17 | +; | |
18 | +create sequence organization_user_seq; | |
19 | +alter table organization_user add constraint fk_organization_user_user foreign key (user_id) references n4user (id) on delete restrict on update restrict; | |
20 | +create index ix_organization_user_user on organization_user (user_id); | |
21 | +alter table organization_user add constraint fk_organization_user_organization foreign key (organization_id) references organization (id) on delete restrict on update restrict; | |
22 | +create index ix_organization_user_organization on organization_user (organization_id); | |
23 | +alter table organization_user add constraint fk_organization_user_role foreign key (role_id) references role (id) on delete restrict on update restrict; | |
24 | +create index ix_organization_user_role on organization_user (role_id); | |
25 | + | |
26 | +alter table project add column organization_id bigint; | |
27 | +alter table project add constraint fk_project_organization foreign key (organization_id) references organization (id) on delete restrict on update restrict; | |
28 | + | |
29 | +alter table project add column project_scope varchar(255); | |
30 | +alter table project add constraint ck_project_project_scope check (project_scope in ('PRIVATE','PROTECTED','PUBLIC')); | |
31 | + | |
32 | +update project set project_scope = 'PUBLIC' where is_public = true; | |
33 | +update project set project_scope = 'PRIVATE' where is_public = false; | |
34 | +# --- !Downs | |
35 | +alter table project drop constraint if exists ck_project_project_scope; | |
36 | +alter table project drop column project_scope; | |
37 | + | |
38 | +alter table project drop constraint if exists fk_project_organization; | |
39 | +alter table project drop column organization_id; | |
40 | + | |
41 | +alter table organization_user drop constraint if exists fk_organization_user_role; | |
42 | +alter table organization_user drop constraint if exists fk_organization_user_organization; | |
43 | +alter table organization_user drop constraint if exists fk_organization_user_user; | |
44 | + | |
45 | +drop sequence if exists organization_user_seq; | |
46 | +drop table if exists organization_user; | |
47 | + | |
48 | +drop sequence if exists organization_seq; | |
49 | +drop table if exists organization; |
--- conf/initial-data.yml
+++ conf/initial-data.yml
... | ... | @@ -21,6 +21,13 @@ |
21 | 21 |
- !!models.Role |
22 | 22 |
name: member |
23 | 23 |
active: true |
24 |
+ - !!models.Role |
|
25 |
+ name: org_admin |
|
26 |
+ active: true |
|
27 |
+ - !!models.Role |
|
28 |
+ name: org_participant |
|
29 |
+ active: true |
|
30 |
+ |
|
24 | 31 |
|
25 | 32 |
# Labels |
26 | 33 |
labels: |
Add a comment
Delete comment
Once you delete this comment, you won't be able to recover it. Are you sure you want to delete this comment?