Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
adapt
ace
Commits
688ec119
Commit
688ec119
authored
Apr 07, 2017
by
Michael Ritter
Browse files
Separate queries for all summaries and group summary
parent
2154c5b8
Changes
1
Hide whitespace changes
Inline
Side-by-side
ace-am/src/main/java/edu/umiacs/ace/monitor/access/GroupSummaryContext.java
View file @
688ec119
...
@@ -21,27 +21,35 @@ public class GroupSummaryContext implements ServletContextListener {
...
@@ -21,27 +21,35 @@ public class GroupSummaryContext implements ServletContextListener {
public
static
Map
<
String
,
GroupSummary
>
summaries
;
public
static
Map
<
String
,
GroupSummary
>
summaries
;
// Main query
/**
private
static
final
String
SUMMARY_QUERY
=
"SELECT c.colgroup, sum(m.size) AS size, sum(m.count) AS count "
+
* Query to get ALL group summaries
*/
private
static
final
String
SUMMARY_QUERY_ALL
=
"SELECT c.colgroup, sum(m.size) AS size, sum(m.count) AS count "
+
"FROM collection c "
+
"FROM collection c "
+
"JOIN ( "
+
"JOIN ( "
+
"SELECT sum(size) AS size, count(id) AS count, parentcollection_id "
+
"SELECT sum(size) AS size, count(id) AS count, parentcollection_id "
+
"FROM monitored_item "
+
"FROM monitored_item "
+
"WHERE directory = 0 "
+
"WHERE directory = 0 "
+
"GROUP BY parentcollection_id "
+
"GROUP BY parentcollection_id "
+
") AS m ON c.id = m.parentcollection_id "
;
") AS m ON c.id = m.parentcollection_id "
+
"WHERE c.colgroup IS NOT NULL "
+
// clauses depending on if we're querying on a group or not
"GROUP BY c.colgroup"
;
private
static
final
String
SUMMARY_QUERY_NOT_NULL
=
"WHERE c.colgroup IS NOT NULL "
;
private
static
final
String
SUMMARY_QUERY_PARAM
=
"WHERE c.colgroup = ? "
;
// and the wrap up
/**
private
static
final
String
SUMMARY_QUERY_END
=
"GROUP BY c.colgroup"
;
* Query to get the group summary for a single group
*/
private
static
final
String
SUMMARY_QUERY_GROUP
=
"select c.colgroup, sum(m.size) AS size, count(m.id) AS count "
+
"FROM monitored_item m "
+
"JOIN ( "
+
" select colgroup, id "
+
" FROM collection "
+
" WHERE colgroup = ? "
+
") c ON c.id = m.parentcollection_id WHERE directory = 0"
;
@Override
@Override
public
void
contextInitialized
(
ServletContextEvent
servletContextEvent
)
{
public
void
contextInitialized
(
ServletContextEvent
servletContextEvent
)
{
summaries
=
new
HashMap
<>();
summaries
=
new
HashMap
<>();
updateSummaries
(
ImmutableList
.
of
(
SUMMARY_QUERY
,
SUMMARY_QUERY_NOT_NULL
,
SUMMARY_QUERY_END
),
updateSummaries
(
ImmutableList
.
of
(
SUMMARY_QUERY
_ALL
),
ImmutableList
.<
String
>
of
());
ImmutableList
.<
String
>
of
());
}
}
...
@@ -55,11 +63,12 @@ public class GroupSummaryContext implements ServletContextListener {
...
@@ -55,11 +63,12 @@ public class GroupSummaryContext implements ServletContextListener {
*
*
* @param group the group to update
* @param group the group to update
*/
*/
@SuppressWarnings
(
"WeakerAccess"
)
public
static
void
updateGroup
(
String
group
)
{
public
static
void
updateGroup
(
String
group
)
{
if
(
group
!=
null
)
{
if
(
group
!=
null
)
{
log
.
debug
(
"Updating group summary for "
+
group
);
log
.
debug
(
"Updating group summary for "
+
group
);
updateSummaries
(
updateSummaries
(
ImmutableList
.
of
(
SUMMARY_QUERY
,
SUMMARY_QUERY_PARAM
,
SUMMARY_QUERY_END
),
ImmutableList
.
of
(
SUMMARY_QUERY
_GROUP
),
ImmutableList
.
of
(
group
));
ImmutableList
.
of
(
group
));
}
}
}
}
...
@@ -87,6 +96,7 @@ public class GroupSummaryContext implements ServletContextListener {
...
@@ -87,6 +96,7 @@ public class GroupSummaryContext implements ServletContextListener {
List
<
GroupSummary
>
results
=
(
List
<
GroupSummary
>)
groupSummary
.
getResultList
();
List
<
GroupSummary
>
results
=
(
List
<
GroupSummary
>)
groupSummary
.
getResultList
();
for
(
GroupSummary
result
:
results
)
{
for
(
GroupSummary
result
:
results
)
{
log
.
info
(
"Result: group "
+
result
.
getGroup
()
+
", size: "
+
result
.
getSize
()
+
", count: "
+
result
.
getCount
());
summaries
.
put
(
result
.
getGroup
(),
result
);
summaries
.
put
(
result
.
getGroup
(),
result
);
}
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment