BrightSide Workbench Full Report + Source Code
org.turro.financials.report.ReportBody Class Reference

Public Member Functions

 ReportBody (String name)
 
String getName ()
 
TreeSet< ReportRowgetRows ()
 
TreeSet< ReportColumngetColumns ()
 
Double getValue (ReportRow row, ReportColumn column)
 
Double getSum (ReportRow row, ReportColumn column, String group)
 
File getFile ()
 
void fill (Date start, Date end)
 
boolean hasValues ()
 

Static Public Member Functions

static List< ReportBodyreports ()
 
static ReportBody load (File file)
 

Detailed Description

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

Definition at line 43 of file ReportBody.java.

Constructor & Destructor Documentation

◆ ReportBody()

org.turro.financials.report.ReportBody.ReportBody ( String  name)

Definition at line 52 of file ReportBody.java.

52  {
53  this.name = name;
54  }

Member Function Documentation

◆ fill()

void org.turro.financials.report.ReportBody.fill ( Date  start,
Date  end 
)

Definition at line 95 of file ReportBody.java.

95  {
96  if(values != null) values.clear();
97  if(sum != null) sum.clear();
98  WhereClause wc = new WhereClause();
99  wc.addClause("select e from RegisterEntry e");
100  wc.addClause("where e.register.registerDate >= :start");
101  wc.addClause("and e.register.registerDate <= :end");
102  wc.addNamedValue("start", start);
103  wc.addNamedValue("end", end);
104  try(Stream<RegisterEntry> entries = new FinancialsPU().stream(RegisterEntry.class, wc)) {
105  entries.forEach((e) -> {
106  addEntry(e);
107  });
108  }
109  // Generate sum groups
110  if(sum == null) sum = new HashMap<>();
111  for(ReportRow row : getRows()) {
112  if(row.isSum()) {
113  sum.put(row.getGroup(), new HashMap<>());
114  }
115  }
116  }
Here is the call graph for this function:

◆ getColumns()

TreeSet<ReportColumn> org.turro.financials.report.ReportBody.getColumns ( )

Definition at line 65 of file ReportBody.java.

65  {
66  if(columns == null) columns = new TreeSet<>();
67  return columns;
68  }

◆ getFile()

File org.turro.financials.report.ReportBody.getFile ( )

Definition at line 91 of file ReportBody.java.

91  {
92  return file;
93  }
Here is the caller graph for this function:

◆ getName()

String org.turro.financials.report.ReportBody.getName ( )

Definition at line 56 of file ReportBody.java.

56  {
57  return name;
58  }
Here is the caller graph for this function:

◆ getRows()

TreeSet<ReportRow> org.turro.financials.report.ReportBody.getRows ( )

Definition at line 60 of file ReportBody.java.

60  {
61  if(rows == null) rows = new TreeSet<>();
62  return rows;
63  }
Here is the caller graph for this function:

◆ getSum()

Double org.turro.financials.report.ReportBody.getSum ( ReportRow  row,
ReportColumn  column,
String  group 
)

Definition at line 80 of file ReportBody.java.

80  {
81  if(sum != null) {
82  Double total = sum.get(group).get(generateKey(null, column));
83  sum.get(group).put(generateKey(null, column), 0.0);
84  if(total != null) {
85  return row.isNegate() ? -total : total;
86  }
87  }
88  return 0.0;
89  }
Here is the call graph for this function:

◆ getValue()

Double org.turro.financials.report.ReportBody.getValue ( ReportRow  row,
ReportColumn  column 
)

Definition at line 70 of file ReportBody.java.

70  {
71  if(values != null) {
72  Double accumulate = values.get(generateKey(row, column));
73  if(accumulate != null) {
74  return formatAndAddSum(row, column, accumulate);
75  }
76  }
77  return 0.0;
78  }

◆ hasValues()

boolean org.turro.financials.report.ReportBody.hasValues ( )

Definition at line 118 of file ReportBody.java.

118  {
119  return values != null && !values.isEmpty();
120  }

◆ load()

static ReportBody org.turro.financials.report.ReportBody.load ( File  file)
static

Definition at line 195 of file ReportBody.java.

195  {
196  ReportBody body = null;
197  if(file != null) {
198  try {
199  JSONSerializer ser = new JSONSerializer(true);
200  body = ser.fromJson(FileUtil.getContent(file), ReportBody.class);
201  body.setFile(file);
202  } catch (IOException ex) {
203  Logger.getLogger(ReportBody.class.getName()).log(Level.SEVERE, ElephantContext.logMsg(null), ex);
204  }
205  }
206  if(body == null) {
207  body = new ReportBody("Test report");
208  setTest(body);
209  ReportBody.save(body, "test");
210  }
211  return body;
212  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ reports()

static List<ReportBody> org.turro.financials.report.ReportBody.reports ( )
static

Definition at line 183 of file ReportBody.java.

183  {
184  File root = new File(ElephantContext.getRealPath(dveRoot));
185  root.mkdirs();
186  List<ReportBody> reports = new ArrayList<>();
187  for(File file : root.listFiles()) {
188  if(file.isFile() && !file.isHidden()) {
189  reports.add(ReportBody.load(file));
190  }
191  }
192  return reports;
193  }
static List< ReportBody > reports()
Here is the call graph for this function:
Here is the caller graph for this function:

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