18 package org.turro.dossier.entity;
20 import java.util.ArrayList;
21 import java.util.HashSet;
22 import java.util.List;
24 import javax.persistence.CascadeType;
25 import javax.persistence.Column;
26 import javax.persistence.Entity;
27 import javax.persistence.FetchType;
28 import javax.persistence.Id;
29 import javax.persistence.Index;
30 import javax.persistence.ManyToOne;
31 import javax.persistence.OneToMany;
32 import javax.persistence.OrderBy;
33 import javax.persistence.Table;
34 import org.turro.string.Strings;
35 import org.turro.action.Contacts;
36 import org.turro.collections.Hierarchy;
37 import org.turro.dossier.db.DossierPU;
38 import org.turro.dossier.dossier.ParticipantSet;
39 import org.turro.elephant.db.IdUtils;
40 import org.turro.elephant.db.WhereClause;
41 import org.turro.jpa.Dao;
42 import org.turro.jpa.entity.IDaoEntity;
43 import org.turro.plugin.contacts.IContact;
44 import org.turro.util.Chars;
52 @Index(name=
"PathIndex", columnList=
"uniquePath")
57 @Column(name=
"IDENTIFIER")
60 private String description;
62 private String fullDescription, uniquePath;
64 private boolean knowledgeBase, ownsProjects;
69 @OneToMany(mappedBy =
"parent", fetch = FetchType.EAGER)
70 @OrderBy(value=
"description")
73 @OneToMany(mappedBy = "category", fetch = FetchType.LAZY, cascade = CascadeType.ALL, orphanRemoval=true)
74 @OrderBy(value="name")
77 @OneToMany(mappedBy = "category", fetch = FetchType.EAGER, cascade = CascadeType.ALL, orphanRemoval=true)
78 @OrderBy(value="orderNumber")
81 @OneToMany(mappedBy = "category", fetch = FetchType.EAGER, cascade = CascadeType.ALL, orphanRemoval=true)
89 this.children = children;
97 this.description = description;
113 this.parent = parent;
118 if(
id !=
null &&
id > 0 && dao.
isNotLoaded(participants)) {
119 participants = dao.lazyLoader(
Category.class,
this,
"participants").participants;
125 this.participants = participants;
129 return fullDescription;
133 this.fullDescription = fullDescription;
141 this.uniquePath = uniquePath;
145 return knowledgeBase;
149 this.knowledgeBase = knowledgeBase;
157 this.ownsProjects = ownsProjects;
165 this.descriptors = descriptors;
173 this.worths = worths;
185 return Strings.isBlank(description);
191 if(
id ==
null ||
id == 0) {
194 if(Hierarchy.checkLoop(
this, (c) -> c.id, (c) -> c.parent)) {
203 if(contact ==
null)
return null;
209 getParticipants().add(p);
214 if(contact ==
null)
return null;
220 getParticipants().add(p);
227 if(contact.
getId().equals(p.getIdContact())) {
238 contact.
getId().equals(p.getIdContact()) &&
247 List<IDossierParticipant> list =
new ArrayList<>();
257 if(!Strings.isBlank(fullDescription)) {
258 return "/" + fullDescription.replaceAll(
"\\s*\\" + Chars.backward() +
"\\s*",
"\\/");
264 if(!Strings.isBlank(path)) {
265 return path.substring(1).replaceAll(
"\\/",
" \\" + Chars.backward() +
" ");
282 if(p.getRole().equals(role)) {
286 if(getParent() !=
null) {
287 return getParent().getDefaultResponsible(role);
295 wc.
addClause(
"where d.category = :category");
298 return dao.getResultList(
Dossier.class, wc);
void setName(String name)
void setRole(ParticipantRole role)
void setCategory(Category category)
void setIdContact(String idContact)
boolean isBranchAdmin(IContact contact)
Set< CategoryParticipant > getParticipants()
static String getPathToFullDescription(String path)
Set< WorthDefinition > getWorths()
void setParticipants(Set< CategoryParticipant > participants)
void setOwnsProjects(boolean ownsProjects)
boolean isDirectOwner(IContact contact)
ParticipantSet< IDossierParticipant > getFullParticipants()
void setDescription(String description)
List< Dossier > getDossiers()
void setParent(Category parent)
boolean isKnowledgeBase()
void setWorths(Set< WorthDefinition > worths)
void setUniquePath(String uniquePath)
CategoryParticipant addAssistant(IContact contact)
List< IDossierParticipant > getDirectOwners()
void setFullDescription(String fullDescription)
Set< DescriptorDefinition > getDescriptors()
IContact getDefaultResponsible(ParticipantRole role)
String getFullDescription()
void setChildren(Set< Category > children)
void setKnowledgeBase(boolean knowledgeBase)
void setDescriptors(Set< DescriptorDefinition > descriptors)
CategoryParticipant addOwner(IContact contact)
static long getNewLongIdFromLong(Dao dao, String table, String field)
void addClause(String clause)
void addNamedValue(String name, Object value)
boolean isNotLoaded(Object o, String attribute)
default void prepareSave()