BrightSide Workbench Full Report + Source Code
org.turro.entities.AttachEntities Class Reference
Inheritance diagram for org.turro.entities.AttachEntities:
Collaboration diagram for org.turro.entities.AttachEntities:

Public Member Functions

 AttachEntities ()
 
 AttachEntities (String entityPath)
 
 AttachEntities (Object entity)
 
Object getEntity ()
 
String getName ()
 
String getLabel ()
 
String getDescription ()
 
Object getLabelCtrl ()
 
String getImage ()
 
String getMimeImage ()
 
String getHierarchicalPath ()
 
IElephantEntity getParent ()
 
List< IElephantEntitygetChildren ()
 
String getExtendedPath ()
 
File getFile ()
 
boolean showPath ()
 
boolean showEntity ()
 
boolean canEdit (IContact contact)
 
boolean canPublish (IContact contact)
 
Collection getEntitites (String search, int maxResults, KeyValueMap kvm)
 
Collection getEntitites (String root, String search, int maxResults, KeyValueMap kvm)
 
Object configureCtrl (Object ctrl, IContact contact)
 
boolean canShowInContext (IContact contact, Object relatedEntity)
 
String getExtendedWebPath ()
 
String getUserContext ()
 
Collection< String > getAllowedRoots ()
 
- Public Member Functions inherited from org.turro.entities.DefaultElephantEntity
 DefaultElephantEntity ()
 
 DefaultElephantEntity (String entityPath)
 
 DefaultElephantEntity (Object entity)
 
IElephantEntity getController (String entityPath)
 
IElephantEntity getController (Object entity)
 
boolean isEmpty ()
 
String getStringId ()
 
String getNameOrLabel ()
 
String getRoot ()
 
String getPath ()
 
String getTreeLabel ()
 
Collection getEntitites (String search, int maxResults)
 
Collection getEntitites (String root, String search, int maxResults)
 
IElephantSendable getSendable ()
 
Collection< Object > getRelatedByRole (EntityRole role, IContact contact)
 
boolean hasRelatedRole (EntityRole role, IContact contact)
 
String getLinkRoot ()
 
String getEntityUrl ()
 
String getMemberUrl ()
 
String getAppUrl ()
 
String getEntityUrl (LinkType type, String contextPath)
 
String getReadAllUrl (LinkType type, String contextPath)
 
Object getControl (String name, IContact contact)
 
Object getControl (String name, IConstructor constructor, IContact contact)
 
Object getControl (String name, String entityPath, IContact contact)
 
Object getParticipationControl (IConstructor constructor, ParticipationReason reason)
 
Object getParticipationControl (IConstructor constructor, IContact contact, ParticipationReason reason)
 
String parseSpamCtrl (IConstructor constructor)
 
String parseFollowCtrl (IConstructor constructor)
 
EntitySet getAllChildren ()
 
Script getActorScript ()
 
boolean isActor (String actor)
 
boolean isActor (IContact contact, String actor)
 
ConceptPermission getConceptPermission (String name)
 
Folder getDeliverables ()
 
Object getObject (Path entityPath)
 
IElephantEntity getMain (Object entity)
 
int hashCode ()
 
boolean equals (Object obj)
 

Protected Member Functions

Dao createDao ()
 
boolean itsMine (String rootPath)
 
boolean itsMine (Object entity)
 
IElephantEntity createInstance (String entityPath)
 
IElephantEntity createInstance (Object entity)
 
Path createPath ()
 
- Protected Member Functions inherited from org.turro.entities.DefaultElephantEntity
boolean isValidLongEntity ()
 
Dao getDao ()
 

Additional Inherited Members

- Static Public Attributes inherited from org.turro.entities.IElephantEntity
static final String EMPTY_ID = "#"
 
static final String PATH_SEPARATOR = ";"
 
- Protected Attributes inherited from org.turro.entities.DefaultElephantEntity
String entityPath
 
Path path
 
Object entity
 

Detailed Description

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

Definition at line 52 of file AttachEntities.java.

Constructor & Destructor Documentation

◆ AttachEntities() [1/3]

org.turro.entities.AttachEntities.AttachEntities ( )

Definition at line 54 of file AttachEntities.java.

54  {
55  }
Here is the caller graph for this function:

◆ AttachEntities() [2/3]

org.turro.entities.AttachEntities.AttachEntities ( String  entityPath)

Definition at line 57 of file AttachEntities.java.

◆ AttachEntities() [3/3]

org.turro.entities.AttachEntities.AttachEntities ( Object  entity)

Definition at line 61 of file AttachEntities.java.

61  {
62  super(entity);
63  }

Member Function Documentation

◆ canEdit()

boolean org.turro.entities.AttachEntities.canEdit ( IContact  contact)

Checks when contact has permissions to edit the entity.

Parameters
contactthe contact checked.
Returns
true when the contact can edit.

Implements org.turro.entities.IElephantEntity.

Definition at line 227 of file AttachEntities.java.

227  {
228  if(getEntity() != null) {
229  if(entity instanceof Attachment) {
230  return contact.getPermissions().isInRole("attach:list");
231  } else if(entity instanceof File) {
232  return contact.getPermissions().isInRole("file-attach:list");
233  }
234  }
235  return false;
236  }
Here is the call graph for this function:

◆ canPublish()

boolean org.turro.entities.AttachEntities.canPublish ( IContact  contact)

Checks when contact has permissions to see the entity.

Parameters
contactthe contact checked.
Returns
true when the contact can see.

Implements org.turro.entities.IElephantEntity.

Definition at line 239 of file AttachEntities.java.

239  {
240  if(getEntity() != null) {
241  if(entity instanceof Attachment) {
242  Attachment attachment = (Attachment) entity;
243  return contact.getPermissions().isInRole("attach-show:all") ||
244  (
245  attachment.isPublishable() &&
246  ((
247  attachment.isRequiresAcceptance() &&
248  attachment.getSingleStatus(contact).equals(AcceptanceSingleStatus.SINGLE_ACCEPTED)
249  ) || !attachment.isRequiresAcceptance())
250  );
251  } else if(entity instanceof File) {
252  return true; // Controlled by owner entity
253  }
254  }
255  return false;
256  }
Here is the call graph for this function:

◆ canShowInContext()

boolean org.turro.entities.AttachEntities.canShowInContext ( IContact  contact,
Object  relatedEntity 
)

Checks whether the related entity can be shown to the given contact.

Parameters
contactthe contact to be checked against.
relatedEntitythe related entity to be shown.
Returns
true if can be shown.

Implements org.turro.entities.IElephantEntity.

Definition at line 284 of file AttachEntities.java.

284  {
285  return true;
286  }

◆ configureCtrl()

Object org.turro.entities.AttachEntities.configureCtrl ( Object  ctrl,
IContact  contact 
)

Configures specific entity related controls for the given contact.

Parameters
ctrlthe control to configure.
contactthe contact who receive the control.
Returns
the configured control.

Implements org.turro.entities.IElephantEntity.

Definition at line 279 of file AttachEntities.java.

279  {
280  return ctrl;
281  }

◆ createDao()

Dao org.turro.entities.AttachEntities.createDao ( )
protected

Reimplemented from org.turro.entities.DefaultElephantEntity.

Definition at line 299 of file AttachEntities.java.

299  {
300  return new AttachPU();
301  }

◆ createInstance() [1/2]

IElephantEntity org.turro.entities.AttachEntities.createInstance ( Object  entity)
protected

Reimplemented from org.turro.entities.DefaultElephantEntity.

Definition at line 324 of file AttachEntities.java.

324  {
325  return new AttachEntities(entity);
326  }
Here is the call graph for this function:

◆ createInstance() [2/2]

IElephantEntity org.turro.entities.AttachEntities.createInstance ( String  entityPath)
protected

Reimplemented from org.turro.entities.DefaultElephantEntity.

Definition at line 319 of file AttachEntities.java.

319  {
320  return new AttachEntities(entityPath);
321  }
Here is the call graph for this function:

◆ createPath()

Path org.turro.entities.AttachEntities.createPath ( )
protected

Reimplemented from org.turro.entities.DefaultElephantEntity.

Definition at line 329 of file AttachEntities.java.

329  {
330  return new Path(AttachPU.getObjectPath(entity));
331  }
Here is the call graph for this function:

◆ getAllowedRoots()

Collection<String> org.turro.entities.AttachEntities.getAllowedRoots ( )

Implements org.turro.entities.IElephantEntity.

Definition at line 314 of file AttachEntities.java.

314  {
315  return Arrays.asList("attachment", "file");
316  }

◆ getChildren()

List<IElephantEntity> org.turro.entities.AttachEntities.getChildren ( )

Gets the children for this entity.

Returns
the children controllers.

Implements org.turro.entities.IElephantEntity.

Definition at line 180 of file AttachEntities.java.

180  {
181  return Collections.EMPTY_LIST;
182  }

◆ getDescription()

String org.turro.entities.AttachEntities.getDescription ( )

Gets the entity description.

Returns
the description string.

Implements org.turro.entities.IElephantEntity.

Definition at line 117 of file AttachEntities.java.

117  {
118  return null;
119  }

◆ getEntitites() [1/2]

Collection org.turro.entities.AttachEntities.getEntitites ( String  root,
String  search,
int  maxResults,
KeyValueMap  kvm 
)

Implements org.turro.entities.IElephantEntity.

Definition at line 266 of file AttachEntities.java.

266  {
267  ArrayList<Object> list = new ArrayList<>();
268  if(null != root) switch (root) {
269  case "attachment":
270  list.addAll(searchAttachments(search, maxResults, kvm));
271  break;
272  default:
273  break;
274  }
275  return list;
276  }

◆ getEntitites() [2/2]

Collection org.turro.entities.AttachEntities.getEntitites ( String  search,
int  maxResults,
KeyValueMap  kvm 
)

Implements org.turro.entities.IElephantEntity.

Definition at line 259 of file AttachEntities.java.

259  {
260  ArrayList<Object> list = new ArrayList<>();
261  list.addAll(searchAttachments(search, maxResults, kvm));
262  return list;
263  }

◆ getEntity()

Object org.turro.entities.AttachEntities.getEntity ( )

Returns the entity for this controller.

Returns
the entity's object.

Implements org.turro.entities.IElephantEntity.

Definition at line 66 of file AttachEntities.java.

66  {
67  if(entity == null) {
68  if(getPath() != null) {
69  if(path.getSize() == 2) {
70  if(null != path.getRoot()) switch (path.getRoot()) {
71  case "attachment":
72  if(isValidLongEntity()) {
73  entity = getDao().find(Attachment.class, path.getNodeAs(1, Long.class));
74  }
75  break;
76  case "file":
77  entity = new File(ElephantContext.getRealPath(path.getFrom(1)));
78  break;
79  default:
80  break;
81  }
82  }
83  }
84  }
85  return entity;
86  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getExtendedPath()

String org.turro.entities.AttachEntities.getExtendedPath ( )

Gets the extended path for this entity.

Returns
the extended path string.

Implements org.turro.entities.IElephantEntity.

Definition at line 185 of file AttachEntities.java.

185  {
186  return AttachPU.getObjectExtendedPath(entity);
187  }
Here is the call graph for this function:

◆ getExtendedWebPath()

String org.turro.entities.AttachEntities.getExtendedWebPath ( )

Returns a unique path for the entity.

Returns
the path string.

Implements org.turro.entities.IElephantEntity.

Definition at line 289 of file AttachEntities.java.

289  {
290  return null;
291  }

◆ getFile()

File org.turro.entities.AttachEntities.getFile ( )

Gets the file represented by the entity.

Returns
the entity file.

Implements org.turro.entities.IElephantEntity.

Definition at line 190 of file AttachEntities.java.

190  {
191  if(getEntity() != null) {
192  if(entity instanceof Attachment) {
193  try {
194  File file = File.createTempFile("attach_", "_mail");
195  AttachWd.writeToFile((Attachment) getEntity(), file);
196  return file;
197  } catch (IOException ex) {
198  Logger.getLogger(AttachEntities.class.getName()).log(Level.SEVERE, ElephantContext.logMsg(null), ex);
199  }
200  } else if(entity instanceof File) {
201  return (File) entity;
202  }
203  }
204  return null;
205  }
Here is the call graph for this function:

◆ getHierarchicalPath()

String org.turro.entities.AttachEntities.getHierarchicalPath ( )

Gets the hierarchical path for this entity. Mostly used for sorting purposes.

Returns
the hierarchical path string.

Implements org.turro.entities.IElephantEntity.

Definition at line 158 of file AttachEntities.java.

158  {
159  if(getEntity() != null) {
160  if(entity instanceof Attachment) {
161  IElephantEntity iee = ((Attachment) entity).getOwnerEntity();
162  String hp = iee.getHierarchicalPath();
163  return (Strings.isBlank(hp) ? "" : hp + PATH_SEPARATOR) + getPath();
164  }
165  }
166  return getPath();
167  }
Here is the call graph for this function:

◆ getImage()

String org.turro.entities.AttachEntities.getImage ( )

Gets the entity image based on its root.

Returns
the string image location.

Implements org.turro.entities.IElephantEntity.

Definition at line 127 of file AttachEntities.java.

127  {
128  if(getPath() != null) {
129  String root = path.getRoot();
130  if(null != root) switch (root) {
131  case "attachment":
132  return "/_zul/images/clip.png";
133  case "file":
134  return "/_zul/images/clip.png";
135  default:
136  break;
137  }
138  }
139  return null;
140  }
Here is the call graph for this function:

◆ getLabel()

String org.turro.entities.AttachEntities.getLabel ( )

Gets the entity label, based on its root.

Returns
the entity string label.

Implements org.turro.entities.IElephantEntity.

Definition at line 101 of file AttachEntities.java.

101  {
102  if(getPath() != null) {
103  String root = path.getRoot();
104  if(null != root) switch (root) {
105  case "attachment":
106  return I_.get("Attachment");
107  case "file":
108  return I_.get("File");
109  default:
110  break;
111  }
112  }
113  return null;
114  }
Here is the call graph for this function:

◆ getLabelCtrl()

Object org.turro.entities.AttachEntities.getLabelCtrl ( )

Gets the label control, usually a clickable LabelControl class.

Returns
a clickable label control.

Implements org.turro.entities.IElephantEntity.

Definition at line 122 of file AttachEntities.java.

122  {
123  return null;
124  }

◆ getMimeImage()

String org.turro.entities.AttachEntities.getMimeImage ( )

Definition at line 142 of file AttachEntities.java.

142  {
143  if(getPath() != null) {
144  String root = path.getRoot();
145  if(null != root) switch (root) {
146  case "attachment":
147  return getMimeImage(entity);
148  case "file":
149  return getMimeImage(entity);
150  default:
151  break;
152  }
153  }
154  return null;
155  }
Here is the call graph for this function:

◆ getName()

String org.turro.entities.AttachEntities.getName ( )

Gets the entity name.

Returns
the string name.

Implements org.turro.entities.IElephantEntity.

Definition at line 89 of file AttachEntities.java.

89  {
90  if(getEntity() != null) {
91  if(entity instanceof Attachment) {
92  return ((Attachment) entity).getFileName();
93  } else if(entity instanceof File) {
94  return ((File) entity).getName();
95  }
96  }
97  return null;
98  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getParent()

IElephantEntity org.turro.entities.AttachEntities.getParent ( )

Gets the parent for this entity.

Returns
the parent controller.

Implements org.turro.entities.IElephantEntity.

Definition at line 170 of file AttachEntities.java.

170  {
171  if(getEntity() != null) {
172  if(entity instanceof Attachment) {
173  return ((Attachment) entity).getOwnerEntity();
174  }
175  }
176  return null;
177  }
Here is the call graph for this function:

◆ getUserContext()

String org.turro.entities.AttachEntities.getUserContext ( )

Returns the user context for this type of entity

Returns
the path string;

Implements org.turro.entities.IElephantEntity.

Definition at line 294 of file AttachEntities.java.

294  {
295  return null;
296  }

◆ itsMine() [1/2]

boolean org.turro.entities.AttachEntities.itsMine ( Object  entity)
protected

Reimplemented from org.turro.entities.DefaultElephantEntity.

Definition at line 309 of file AttachEntities.java.

309  {
310  return (entity instanceof Attachment) || (entity instanceof File);
311  }

◆ itsMine() [2/2]

boolean org.turro.entities.AttachEntities.itsMine ( String  rootPath)
protected

Reimplemented from org.turro.entities.DefaultElephantEntity.

Definition at line 304 of file AttachEntities.java.

304  {
305  return super.itsMine(rootPath) || "file".equals(rootPath);
306  }

◆ showEntity()

boolean org.turro.entities.AttachEntities.showEntity ( )

Shows the view for the entity.

Returns
true when a view is shown.

Implements org.turro.entities.IElephantEntity.

Definition at line 213 of file AttachEntities.java.

213  {
214  if(getEntity() != null) {
215  if(entity instanceof Attachment) {
216  AttachmentUtil.download((Attachment) entity);
217  return true;
218  } else if(entity instanceof File) {
219  new FileWrapper((File) entity).download();
220  return true;
221  }
222  }
223  return false;
224  }
Here is the call graph for this function:

◆ showPath()

boolean org.turro.entities.AttachEntities.showPath ( )

Shows the view for this path.

Returns
true when a view is shown.

Implements org.turro.entities.IElephantEntity.

Definition at line 208 of file AttachEntities.java.

208  {
209  return false;
210  }

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