19 package org.turro.students.entities;
21 import java.util.Date;
22 import java.util.HashSet;
24 import javax.persistence.CascadeType;
25 import javax.persistence.Column;
26 import javax.persistence.Entity;
27 import javax.persistence.FetchType;
28 import javax.persistence.GeneratedValue;
29 import javax.persistence.GenerationType;
30 import javax.persistence.Id;
31 import javax.persistence.Lob;
32 import javax.persistence.OneToMany;
33 import javax.persistence.OrderBy;
34 import javax.persistence.Temporal;
35 import org.turro.string.Strings;
36 import org.turro.action.Contacts;
37 import org.turro.entities.Entities;
38 import org.turro.entities.IElephantEntity;
39 import org.turro.jpa.entity.EntityCollections;
40 import org.turro.jpa.entity.IDaoEntity;
41 import org.turro.parser.wiki.WikiCompiler;
42 import org.turro.plugin.contacts.IContact;
43 import org.turro.reflection.MappingSet;
53 @GeneratedValue(strategy=GenerationType.IDENTITY)
54 @Column(name=
"IDENTIFIER")
57 private String entityPath;
59 private String idChallenger;
62 private String question;
64 @Temporal(value = javax.persistence.TemporalType.TIMESTAMP)
65 private java.util.Date creation;
67 @Temporal(value = javax.persistence.TemporalType.DATE)
68 private java.util.Date deadline;
76 private String wikiText;
78 @OneToMany(mappedBy =
"challenge", fetch = FetchType.EAGER, cascade = CascadeType.ALL, orphanRemoval=
true)
79 @OrderBy(value=
"creation")
80 private Set<Response> responses =
new HashSet<>();
95 this.entityPath = entityPath;
103 this.idChallenger = idChallenger;
119 this.question = question;
127 this.creation = creation;
135 this.deadline = deadline;
151 this.wikiText = wikiText;
160 this.responses = responses;
172 return Strings.isBlank(entityPath) || Strings.isBlank(idChallenger) ||
173 Strings.isBlank(question);
185 return idChallenger.equals(contact.
getId()) ||
186 responses.stream().anyMatch(r -> r.getStudentIds().contains(contact.
getId()));
197 private transient IContact _contact;
200 if(_contact ==
null) {
208 idChallenger = _contact !=
null ? _contact.
getId() :
null;
209 name = _contact !=
null ? _contact.
getName() :
null;
215 MappingSet
set =
new MappingSet();
217 new String[] {
"id",
"question",
"entityPath",
"idChallenger",
"creation",
"deadline" },
218 new String[] {
"wikiText",
"responses" });
220 new String[] {
"id",
"creation" },
221 new String[] {
"wikiText",
"studentIds" });
static IElephantEntity getController(String path)
static EntityCollections entities(Collection values)
boolean remove(IDaoEntity entity)
void setContact(IContact contact)
IElephantEntity getEntity()
void setQuestion(String question)
boolean removeResponse(Response response)
boolean isParticipant(IContact contact)
void setDeadline(Date deadline)
void setText(String text)
void setWikiText(String wikiText)
void setIdChallenger(String idChallenger)
void setCreation(Date creation)
MappingSet getSerializerMappings()
Set< Response > getResponses()
void setEntityPath(String entityPath)
void setResponses(Set< Response > responses)
void setName(String name)
void setChallenge(Challenge challenge)