This repository has been archived by the owner on Mar 10, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
first attempt on Tags: relation in only from Tags to Proposal, with Tags
managing the relationship (also correct display on view)
- Loading branch information
Showing
6 changed files
with
143 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
|
||
package models; | ||
|
||
import java.util.List; | ||
|
||
import javax.persistence.*; | ||
|
||
import play.db.ebean.*; | ||
|
||
import com.avaje.ebean.*; | ||
|
||
/** | ||
* A Tag is a subject/theme that classifies a specimen (like a Proposal). | ||
* Its main objective is to catalog/group similar specimens, easing their | ||
* search. | ||
*/ | ||
@Entity | ||
public class Tag extends Model { | ||
|
||
@Id | ||
public String name; | ||
public String desc; | ||
@ManyToMany | ||
public List<Proposal> taggedProposals; | ||
|
||
/** | ||
* Finder | ||
*/ | ||
public static Finder<String, Tag> find = new Finder<String, Tag>( | ||
String.class, Tag.class); | ||
|
||
/** | ||
* Constructor | ||
* @param name | ||
* @param description | ||
*/ | ||
public Tag(String name, String description) { | ||
this.name = name; | ||
this.desc = description; | ||
} | ||
|
||
/** | ||
* @return All proposals tagged with that Tag | ||
*/ | ||
public List<Proposal> getTaggedProposals() { | ||
return taggedProposals; | ||
} | ||
|
||
/** | ||
* Tags a specific Proposal with the current Tag. | ||
* @param prop Proposal object to tag | ||
*/ | ||
public void tagProposal(Proposal prop) { | ||
taggedProposals.add(prop); | ||
} | ||
|
||
public String toString() { | ||
return "Tag (name=" + name +")"; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters