BrightSide Workbench Full Report + Source Code
org.turro.publication.www.CategoryFilter Class Reference

Public Member Functions

 CategoryFilter (IConstructor constructor, String uniqueId)
 
boolean isBlogger ()
 
void setBlogger (boolean blogger)
 
Collection< PublicationCategorygetCategories (long groupId)
 
Collection< DefaultNavigatorItempubCategories (String parameters, long groupId)
 
void renderCategories (String parameters, long groupId)
 
void processParameters ()
 

Static Public Member Functions

static PublicationCategory getCategory (IConstructor constructor, String uniqueId)
 

Detailed Description

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

Definition at line 41 of file CategoryFilter.java.

Constructor & Destructor Documentation

◆ CategoryFilter()

org.turro.publication.www.CategoryFilter.CategoryFilter ( IConstructor  constructor,
String  uniqueId 
)

Definition at line 49 of file CategoryFilter.java.

49  {
50  this.constructor = constructor;
51  this.uniqueId = uniqueId;
52  }

Member Function Documentation

◆ getCategories()

Collection<PublicationCategory> org.turro.publication.www.CategoryFilter.getCategories ( long  groupId)

Definition at line 62 of file CategoryFilter.java.

62  {
63  ArrayList<PublicationCategory> list = new ArrayList<>();
64  IContact contact = Authentication.getIContact();
65  list.addAll(PublicationCategories.getPublicCategories(contact));
66  if(blogger) {
67  list.addAll(PublicationCategories.getPrivateBloggerCategories(contact));
68  }
69  //list.addAll(PublicationCategories.getSubscribedPrivateCategories(Authentication.getIContact()));
70  return list;
71 // return new PublicationPU().getResultList(
72 // "select distinct c.publicationCategory from Publication as c " +
73 // "where c.publicationCategory.publishable = true " +
74 // (groupId == 0 ? "" : "and c.publicationGroup.id = " + groupId));
75  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getCategory()

static PublicationCategory org.turro.publication.www.CategoryFilter.getCategory ( IConstructor  constructor,
String  uniqueId 
)
static

Definition at line 130 of file CategoryFilter.java.

130  {
131  return uniqueId == null ? null : (PublicationCategory) constructor.getSessionAttribute("/publication-category/" + uniqueId);
132  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ isBlogger()

boolean org.turro.publication.www.CategoryFilter.isBlogger ( )

Definition at line 54 of file CategoryFilter.java.

54  {
55  return blogger;
56  }

◆ processParameters()

void org.turro.publication.www.CategoryFilter.processParameters ( )

Definition at line 113 of file CategoryFilter.java.

113  {
114  String category = constructor.getParameter("category");
115  try {
116  if(!Strings.isBlank(category)) {
117  long id = Integer.valueOf(category).longValue();
118  if(id == 0) {
119  constructor.removeSessionAttribute("/publication-category/" + uniqueId);
120  } else {
121  constructor.setSessionAttribute("/publication-category/" + uniqueId,
122  new PublicationPU().find(PublicationCategory.class, id));
123  }
124  }
125  } catch(Exception ex) {
126  Logger.getLogger(CategoryFilter.class.getName()).log(Level.SEVERE, ElephantContext.logMsg(null), ex);
127  }
128  }
CategoryFilter(IConstructor constructor, String uniqueId)
void setSessionAttribute(String key, Object value)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ pubCategories()

Collection<DefaultNavigatorItem> org.turro.publication.www.CategoryFilter.pubCategories ( String  parameters,
long  groupId 
)

Definition at line 77 of file CategoryFilter.java.

77  {
78  PublicationCategory selected = getCategory(constructor, uniqueId);
79  ArrayList<DefaultNavigatorItem> cats = new ArrayList<>();
80 
81  cats.add(new DefaultNavigatorItem(I_.get("All categories"), parameters + "&category=0", null, selected == null));
82  for(PublicationCategory pc : getCategories(groupId)) {
83  cats.add(new DefaultNavigatorItem(pc.getName(), parameters + "&category=" + pc.getId(), null, selected != null && pc.getId() == selected.getId()));
84  }
85  return cats;
86  }
static PublicationCategory getCategory(IConstructor constructor, String uniqueId)
Collection< PublicationCategory > getCategories(long groupId)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ renderCategories()

void org.turro.publication.www.CategoryFilter.renderCategories ( String  parameters,
long  groupId 
)

Definition at line 88 of file CategoryFilter.java.

88  {
89  PublicationCategory selected = getCategory(constructor, uniqueId);
90  html = new HTMLHelper(constructor);
91  html.startTag("div", "class='publication-categories'");
92  if(selected == null) {
93  html.setExtraAttributes("class='publication-category-selected'");
94  } else {
95  html.setExtraAttributes("class='publication-category'");
96  }
97  html.startAnchor(parameters + "&category=0", null)
98  .write(I_.get("All categories"))
99  .endTag();
100  for(PublicationCategory pc : getCategories(groupId)) {
101  if(selected != null && pc.getId() == selected.getId()) {
102  html.setExtraAttributes("class='publication-category-selected'");
103  } else {
104  html.setExtraAttributes("class='publication-category'");
105  }
106  html.startAnchor(parameters + "&category=" + pc.getId(), null)
107  .write(pc.getName())
108  .endTag();
109  }
110  html.endAllTags();
111  }
HTMLGenerator write(String value)
void setExtraAttributes(String extraAttributes)
HTMLGenerator startTag(String tag)
HTMLGenerator startAnchor(String url, String hint)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ setBlogger()

void org.turro.publication.www.CategoryFilter.setBlogger ( boolean  blogger)

Definition at line 58 of file CategoryFilter.java.

58  {
59  this.blogger = blogger;
60  }
Here is the caller graph for this function:

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