19 package org.turro.attach.entity;
21 import java.io.IOException;
22 import java.io.Serializable;
23 import java.util.Collections;
24 import java.util.Date;
25 import java.util.HashSet;
26 import java.util.List;
28 import java.util.logging.Level;
29 import java.util.logging.Logger;
30 import javax.persistence.ElementCollection;
31 import javax.persistence.Entity;
32 import javax.persistence.FetchType;
33 import javax.persistence.Id;
34 import javax.persistence.IdClass;
35 import javax.persistence.Temporal;
36 import javax.persistence.TemporalType;
37 import org.turro.action.Contacts;
38 import org.turro.auth.Authentication;
39 import org.turro.documentation.DocumentDefinition;
40 import org.turro.documentation.DocumentDefinitions;
41 import org.turro.elephant.context.ElephantContext;
42 import org.turro.entities.Entities;
43 import org.turro.entities.IElephantEntity;
44 import org.turro.file.Document;
45 import org.turro.file.Folder;
46 import org.turro.plugin.contacts.IContact;
53 @IdClass(EntityDocumentationPK.class)
56 @Id
private String entityPath;
57 @Id
private String contactId;
58 @Id
private String documentation;
60 private String requesterId;
62 private String comment;
64 @Temporal(TemporalType.TIMESTAMP)
65 private Date deadline;
67 @ElementCollection(fetch = FetchType.EAGER)
68 private Set<String> assistantIds =
new HashSet<>();
75 this.entityPath = entityPath;
83 this.contactId = contactId;
91 this.documentation = documentation;
99 this.requesterId = requesterId;
107 this.status = status;
115 this.comment = comment;
123 this.deadline = deadline;
131 this.assistantIds = assistantIds;
136 public boolean isValid(List<EntityDocumentation> invalids) {
137 if(getDefinition() ==
null) {
145 if(getFolder().count() < getDefinition().getMin()) {
154 (getDefinition().isUploadControl() || getFolder().count() < getDefinition().getMax())) ||
177 Folder folder = getFolder();
178 if(folder.exists())
try {
179 return folder.documents();
180 }
catch (IOException ex) {
183 return Collections.EMPTY_LIST;
192 return "/WEB-INF/files/" + entityPath +
"/documentation/" +
void setAssistantIds(Set< String > assistantIds)
DocumentDefinition getDefinition()
void setDocumentation(String documentation)
List< IContact > getAssistants()
void setRequesterId(String requesterId)
IElephantEntity getEntity()
void setDeadline(Date deadline)
void setContactId(String contactId)
boolean allowsDeleteDef()
void setEntityPath(String entityPath)
void setStatus(EntityDocumentationStatus status)
boolean allowsValidation()
Set< String > getAssistantIds()
EntityDocumentationStatus getStatus()
void setComment(String comment)
boolean isValid(List< EntityDocumentation > invalids)
List< Document > getDocuments()
String getDocumentation()
static boolean isAdministrator()
static DocumentDefinitions instance()
DocumentDefinition get(String name)
static String getRealPath(String path)
static IElephantEntity getController(String path)
static EnumSet< EntityDocumentationStatus > validationStatus()