BrightSide Workbench Full Report + Source Code
org.turro.attach.search.Attachments Class Reference

Public Member Functions

void toFolder (Folder folder)
 
void remove ()
 
List< Attachmentget ()
 
PathTree getTree ()
 
Attachments onlyPublic ()
 
Attachments banRestricted ()
 

Static Public Member Functions

static Set< String > getAllPaths (String root)
 
static Attachments from (String path)
 

Detailed Description

Author
Lluis TurrĂ³ Cutiller lluis.nosp@m.@tur.nosp@m.ro.or.nosp@m.g

Definition at line 42 of file Attachments.java.

Member Function Documentation

◆ banRestricted()

Attachments org.turro.attach.search.Attachments.banRestricted ( )

Definition at line 141 of file Attachments.java.

141  {
142  banRestricted = true;
143  return this;
144  }

◆ from()

static Attachments org.turro.attach.search.Attachments.from ( String  path)
static

Definition at line 148 of file Attachments.java.

148  {
149  return new Attachments(path);
150  }
Here is the caller graph for this function:

◆ get()

List<Attachment> org.turro.attach.search.Attachments.get ( )

Definition at line 65 of file Attachments.java.

65  {
66  return SqlClause.select("a").from("Attachment a")
67  .where().group()
68  .equal("a.path", path)
69  .or().startsWith("a.path", path + "/")
70  .endGroup()
71  .startIf(onlyPublic)
72  .and().isTrue("a.publishable")
73  .endIf()
74  .startIf(banRestricted)
75  .and().not().contains("a.path", "#")
76  .endIf()
77  .orderBy("a.modification")
78  .dao(new AttachPU())
79  .resultList(Attachment.class);
80  }

◆ getAllPaths()

static Set<String> org.turro.attach.search.Attachments.getAllPaths ( String  root)
static

Definition at line 121 of file Attachments.java.

121  {
122  try(Stream<String> stream = SqlClause.select("distinct a.path").from("Attachment a")
123  .where().startsWith("a.path", "/" + root + "/")
124  .dao(new AttachPU())
125  .stream(String.class)) {
126  return new HashSet<>(
127  stream.map(path -> Path.pathFrom(path).getTill(2))
128  .toList());
129  }
130  }
Here is the caller graph for this function:

◆ getTree()

PathTree org.turro.attach.search.Attachments.getTree ( )

Definition at line 82 of file Attachments.java.

82  {
83  return PathTree.fromObjects(SqlClause.select("a").from("Attachment a")
84  .where().group()
85  .equal("a.path", path)
86  .or().startsWith("a.path", path + "/")
87  .endGroup()
88  .startIf(onlyPublic)
89  .and().isTrue("a.publishable")
90  .endIf()
91  .startIf(banRestricted)
92  .and().not().contains("a.path", "#")
93  .and().isFalse("a.requiresAcceptance")
94  .and().isFalse("a.watermark")
95  .endIf()
96  .orderBy("a.modification")
97  .dao(new AttachPU())
98  .stream(Attachment.class)
99  .map(a -> {
100  return PathObject.from(
101  a.getRelativePath(path) + "/" + a.getFileName(),
102  new AttachmentNode(a.getId(), a.getFileSize(), a.getModification(), a.getFileExtension()));
103  })
104  .toList(), new AttachmentNode(null, 0, null, null));
105  }

◆ onlyPublic()

Attachments org.turro.attach.search.Attachments.onlyPublic ( )

Definition at line 136 of file Attachments.java.

136  {
137  onlyPublic = true;
138  return this;
139  }

◆ remove()

void org.turro.attach.search.Attachments.remove ( )

Definition at line 49 of file Attachments.java.

49  {
50  SqlClause.delete("Attachment")
51  .where().group()
52  .equal("path", path)
53  .or().startsWith("path", path + "/")
54  .endGroup()
55  .startIf(onlyPublic)
56  .and().isTrue("publishable")
57  .endIf()
58  .startIf(banRestricted)
59  .and().not().contains("path", "#")
60  .endIf()
61  .dao(new AttachPU())
62  .execute();
63  }
Here is the caller graph for this function:

◆ toFolder()

void org.turro.attach.search.Attachments.toFolder ( Folder  folder)

Definition at line 44 of file Attachments.java.

44  {
45  folder.ensure();
46  get().forEach(a -> saveToFile(folder, a));
47  }

The documentation for this class was generated from the following file: