19 package org.turro.documentation;
21 import java.io.IOException;
22 import java.util.ArrayList;
23 import java.util.List;
25 import java.util.Objects;
26 import java.util.TreeMap;
27 import java.util.logging.Level;
28 import java.util.logging.Logger;
29 import org.turro.string.Strings;
30 import org.turro.attach.db.AttachPU;
31 import org.turro.elephant.context.ElephantContext;
32 import org.turro.file.Document;
33 import org.turro.file.Folder;
34 import org.turro.plugin.contacts.IContact;
35 import org.turro.sql.SqlClause;
36 import org.turro.util.CompareUtil;
58 this.allowedRoot = root;
63 this.description = text;
68 this.allowMultiple =
true;
73 this.uploadControl =
true;
96 this.allowedRoot = allowedRoot;
120 return uploadControl;
124 this.uploadControl = uploadControl;
150 return !
"*".equals(Strings.isBlank(allowedRoot,
"*"));
154 return !
isFiltered() || (CompareUtil.compare(root, allowedRoot) == 0);
158 Map<String, List<Document>> docs =
new TreeMap<>();
161 if(folder.exists()) docs.put(
"*", folder.documents());
162 for(Folder child : folder.folders()) {
163 docs.put(child.name(), child.documents());
165 }
catch (IOException ex) {
172 List<Document> docs =
new ArrayList<>();
175 if(folder.exists()) docs.addAll(folder.documents());
176 Folder selfDocs = folder.child(contact.
getId());
177 if(selfDocs.exists()) docs.addAll(selfDocs.documents());
180 Folder parentDocs = folder.child(parent.
getId());
181 if(parentDocs.exists()) docs.addAll(parentDocs.documents());
183 }
catch (IOException ex) {
198 return "hash-" +
hashCode() +
"-def";
202 return SqlClause.select(
"count(ed)")
203 .from(
"EntityDocumentation ed")
204 .where().equal(
"ed.documentation",
name)
206 .singleResult(Long.class) == 0L;
212 hash = 73 * hash + Objects.hashCode(this.name);
224 if (getClass() != obj.getClass()) {
233 return CompareUtil.compare(
name, o.
name);
DocumentDefinition uploadControl()
void setUploadControl(boolean uploadControl)
DocumentDefinition min(int min)
boolean isUploadControl()
List< Document > getDocumentsFor(IContact contact)
boolean isAllowMultiple()
void setAllowedRoot(String allowedRoot)
DocumentDefinition allowMultiple()
DocumentDefinition description(String text)
void setAllowMultiple(boolean allowMultiple)
DocumentDefinition allowedRoot(String root)
DocumentDefinition max(int max)
void setDescription(String description)
boolean matches(String root)
boolean equals(Object obj)
Map< String, List< Document > > getDocumentsMap()
DocumentDefinition(String name, DocumentType type)
int compareTo(DocumentDefinition o)
static String getRealPath(String path)