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 42 of file CategoryFilter.java.

Constructor & Destructor Documentation

◆ CategoryFilter()

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

Definition at line 50 of file CategoryFilter.java.

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

Member Function Documentation

◆ getCategories()

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

Definition at line 63 of file CategoryFilter.java.

63  {
64  ArrayList<PublicationCategory> list = new ArrayList<>();
65  IContact contact = Authentication.getIContact();
66  list.addAll(PublicationCategories.getPublicCategories(contact));
67  if(blogger) {
68  list.addAll(PublicationCategories.getPrivateBloggerCategories(contact));
69  }
70  return list;
71  }
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 126 of file CategoryFilter.java.

126  {
127  return uniqueId == null ? null : (PublicationCategory) constructor.getSessionAttribute("/publication-category/" + uniqueId);
128  }
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 55 of file CategoryFilter.java.

55  {
56  return blogger;
57  }

◆ processParameters()

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

Definition at line 109 of file CategoryFilter.java.

109  {
110  String category = constructor.getParameter("category");
111  try {
112  if(!Strings.isBlank(category)) {
113  long id = Converter.STANDARD.convert(category, Long.class, 0L);
114  if(id == 0) {
115  constructor.removeSessionAttribute("/publication-category/" + uniqueId);
116  } else {
117  constructor.setSessionAttribute("/publication-category/" + uniqueId,
118  new PublicationPU().find(PublicationCategory.class, id));
119  }
120  }
121  } catch(Exception ex) {
122  Logger.getLogger(CategoryFilter.class.getName()).log(Level.SEVERE, ElephantContext.logMsg(null), ex);
123  }
124  }
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 73 of file CategoryFilter.java.

73  {
74  PublicationCategory selected = getCategory(constructor, uniqueId);
75  ArrayList<DefaultNavigatorItem> cats = new ArrayList<>();
76 
77  cats.add(new DefaultNavigatorItem(I_.get("All categories"), parameters + "&category=0", null, selected == null));
78  for(PublicationCategory pc : getCategories(groupId)) {
79  cats.add(new DefaultNavigatorItem(pc.getName(), parameters + "&category=" + pc.getId(), null, selected != null && pc.getId() == selected.getId()));
80  }
81  return cats;
82  }
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 84 of file CategoryFilter.java.

84  {
85  PublicationCategory selected = getCategory(constructor, uniqueId);
86  html = new HTMLHelper(constructor);
87  html.startTag("div", "class='publication-categories'");
88  if(selected == null) {
89  html.setExtraAttributes("class='publication-category-selected'");
90  } else {
91  html.setExtraAttributes("class='publication-category'");
92  }
93  html.startAnchor(parameters + "&category=0", null)
94  .write(I_.get("All categories"))
95  .endTag();
96  for(PublicationCategory pc : getCategories(groupId)) {
97  if(selected != null && pc.getId() == selected.getId()) {
98  html.setExtraAttributes("class='publication-category-selected'");
99  } else {
100  html.setExtraAttributes("class='publication-category'");
101  }
102  html.startAnchor(parameters + "&category=" + pc.getId(), null)
103  .write(pc.getName())
104  .endTag();
105  }
106  html.endAllTags();
107  }
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 59 of file CategoryFilter.java.

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

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