1010import javax .persistence .CascadeType ;
1111import javax .persistence .Column ;
1212import javax .persistence .Entity ;
13+ import javax .persistence .EnumType ;
14+ import javax .persistence .Enumerated ;
1315import javax .persistence .JoinTable ;
1416import javax .persistence .ManyToMany ;
17+ import javax .persistence .OneToMany ;
1518import javax .persistence .UniqueConstraint ;
1619
1720import org .hibernate .annotations .Fetch ;
1821
1922import com .fasterxml .jackson .annotation .JsonIdentityInfo ;
2023import com .fasterxml .jackson .annotation .JsonIdentityReference ;
21- import com .fasterxml .jackson .annotation .JsonIgnoreProperties ;
2224import com .fasterxml .jackson .annotation .ObjectIdGenerators ;
2325
26+ import edu .tamu .app .enums .FeatureProposalState ;
2427import edu .tamu .app .model .validation .FeatureProposalValidator ;
2528
2629@ Entity
27- @ JsonIgnoreProperties (value = { "voters" }, allowGetters = true )
2830public class FeatureProposal extends AbstractIdea {
2931
30- @ ManyToMany (fetch = EAGER , cascade = { CascadeType .REFRESH , CascadeType .DETACH , CascadeType .MERGE })
31- @ JoinTable (uniqueConstraints = @ UniqueConstraint (columnNames = { "feature_proposal_id" , "ideas_id" }))
32+ @ OneToMany (fetch = EAGER , cascade = { CascadeType .REFRESH , CascadeType .DETACH , CascadeType .MERGE }, mappedBy = "featureProposal" )
3233 @ Fetch (value = SELECT )
3334 private List <Idea > ideas ;
3435
@@ -39,12 +40,15 @@ public class FeatureProposal extends AbstractIdea {
3940 @ Fetch (value = SELECT )
4041 private List <User > voters ;
4142
43+ @ Enumerated (EnumType .STRING )
44+ @ Column (nullable = false )
45+ private FeatureProposalState state ;
46+
4247 @ Column (nullable = false )
43- private boolean submitted ;
48+ private Boolean isPrivate ;
4449
4550 public FeatureProposal () {
4651 super ();
47- this .modelValidator = new FeatureProposalValidator ();
4852 setup ();
4953 }
5054
@@ -70,9 +74,11 @@ public FeatureProposal(Idea idea) {
7074 }
7175
7276 private void setup () {
77+ this .modelValidator = new FeatureProposalValidator ();
7378 this .ideas = new ArrayList <Idea >();
7479 this .voters = new ArrayList <User >();
75- this .submitted = false ;
80+ this .state = FeatureProposalState .IN_PROGRESS ;
81+ this .isPrivate = false ;
7682 }
7783
7884 public List <Idea > getIdeas () {
@@ -126,12 +132,20 @@ public int getVotes() {
126132 return this .voters .size ();
127133 }
128134
129- public boolean isSubmitted () {
130- return submitted ;
135+ public FeatureProposalState getState () {
136+ return state ;
137+ }
138+
139+ public void setState (FeatureProposalState state ) {
140+ this .state = state ;
141+ }
142+
143+ public Boolean getIsPrivate () {
144+ return isPrivate ;
131145 }
132146
133- public void setSubmitted ( boolean submitted ) {
134- this .submitted = submitted ;
147+ public void setIsPrivate ( Boolean isPrivate ) {
148+ this .isPrivate = isPrivate ;
135149 }
136150
137151}
0 commit comments