我使用这个例子来解决我的需求,以获得Ext JS 4.2.5无限非分组摘要网格不能正常工作在其Java后端的最新版本的Atlassian Jira服务器上,没有完全成功:Summary + ajax paging on ExtJS.Grid
第一次
这是源代码,其中有一些bug。
try
{
JqlQueryBuilder queryBuilder = JqlQueryBuilder.newBuilder();
JqlQueryBuilder addQueryBuilder = JqlQueryBuilder.newBuilder();
if (issueStatus.equals("--ALL--")) {
if (projectIdreq.equals("--ALL--")) {
if (req.getParameter("fields")==null) {
} else if (req.getParameter("fields").equals("[\"key\"]")) {
if (req.getParameter("query")==null) {
} else if (req.getParameter("query").equals("")) {
} else {
String typeQuery = req.getParameter("query");
}
} else {
}
Query addQuery = addQueryBuilder.buildQuery();
Clause clause = addQuery.getWhereClause();
if (req.getParameter("query")==null) {
if (sort.equals("id") && dir.equals("ASC")) {
queryBuilder.orderBy().issueId(SortOrder.ASC).endOrderBy();
} else if (sort.equals("id") && dir.equals("DESC")) {
queryBuilder.orderBy().issueId(SortOrder.DESC).endOrderBy();
}
} else if (req.getParameter("query").equals("")) {
if (sort.equals("id") && dir.equals("ASC")) {
queryBuilder.orderBy().issueId(SortOrder.ASC).endOrderBy();
} else if (sort.equals("id") && dir.equals("DESC")) {
queryBuilder.orderBy().issueId(SortOrder.DESC).endOrderBy();
}
} else {
if (req.getParameter("fields").equals("[\"key\"]")) {
String statusQuery = req.getParameter("query");
if (sort.equals("id") && dir.equals("ASC")) {
queryBuilder.where()
.issue(statusQuery)
.endWhere()
.orderBy().issueId(SortOrder.ASC).endOrderBy();
} else if (sort.equals("id") && dir.equals("DESC")) {
queryBuilder.where().issue(statusQuery)
.endWhere()
.orderBy().issueId(SortOrder.DESC).endOrderBy();
}
} else if (req.getParameter("fields").equals("[\"summary\"]")) {
String summaryQuery = req.getParameter("query");
if (sort.equals("id") && dir.equals("ASC")) {
queryBuilder.where()
.summary(summaryQuery)
.endWhere()
.orderBy().issueId(SortOrder.ASC).endOrderBy();
} else if (sort.equals("id") && dir.equals("DESC")) {
queryBuilder.where()
.summary(summaryQuery)
.endWhere()
.orderBy().issueId(SortOrder.DESC).endOrderBy();
}
} else {
if (sort.equals("id") && dir.equals("ASC")) {
queryBuilder.orderBy().issueId(SortOrder.ASC).endOrderBy();
} else if (sort.equals("id") && dir.equals("DESC")) {
queryBuilder.orderBy().issueId(SortOrder.DESC).endOrderBy();
}
}
}
} else {
if (req.getParameter("fields")==null) {
} else if (req.getParameter("fields").equals("[\"key\"]")) {
if (req.getParameter("query")==null) {
} else if (req.getParameter("query").equals("")) {
} else {
String typeQuery = req.getParameter("query");
}
} else {
//addQueryBuilder.where().endWhere();
}
Query addQuery = addQueryBuilder.buildQuery();
Clause clause = addQuery.getWhereClause();
if (req.getParameter("query")==null) {
if (sort.equals("id") && dir.equals("ASC")) {
queryBuilder.where().project(projectIdreq).endWhere().orderBy().issueId(SortOrder.ASC).endOrderBy();
} else if (sort.equals("id") && dir.equals("DESC")) {
queryBuilder.where().project(projectIdreq).endWhere().orderBy().issueId(SortOrder.DESC).endOrderBy();
}
} else if (req.getParameter("query").equals("")) {
if (sort.equals("id") && dir.equals("ASC")) {
queryBuilder.where().project(projectIdreq).endWhere().orderBy().issueId(SortOrder.ASC).endOrderBy();
} else if (sort.equals("id") && dir.equals("DESC")) {
queryBuilder.where().project(projectIdreq).endWhere().orderBy().issueId(SortOrder.DESC).endOrderBy();
}
} else {
if (req.getParameter("fields").equals("[\"key\"]")) {
String statusQuery = req.getParameter("query");
if (sort.equals("id") && dir.equals("ASC")) {
queryBuilder.where()
.issue(statusQuery)
.and().project(projectIdreq)
.endWhere()
.orderBy().issueId(SortOrder.ASC).endOrderBy();
} else if (sort.equals("id") && dir.equals("DESC")) {
queryBuilder.where().issue(statusQuery)
.and().project(projectIdreq)
.endWhere()
.orderBy().issueId(SortOrder.DESC).endOrderBy();
}
} else if (req.getParameter("fields").equals("[\"summary\"]")) {
String summaryQuery = req.getParameter("query");
if (sort.equals("id") && dir.equals("ASC")) {
queryBuilder.where()
.summary(summaryQuery)
.and().project(projectIdreq)
.endWhere()
.orderBy().issueId(SortOrder.ASC).endOrderBy();
} else if (sort.equals("id") && dir.equals("DESC")) {
queryBuilder.where()
.summary(summaryQuery)
.and().project(projectIdreq)
.endWhere()
.orderBy().issueId(SortOrder.DESC).endOrderBy();
}
} else {
if (sort.equals("id") && dir.equals("ASC")) {
queryBuilder.where().project(projectIdreq).endWhere().orderBy().issueId(SortOrder.ASC).endOrderBy();
} else if (sort.equals("id") && dir.equals("DESC")) {
queryBuilder.where().project(projectIdreq).endWhere().orderBy().issueId(SortOrder.DESC).endOrderBy();
}
}
}
}
} else if (issueStatus.equals("UNRESOLVED")) {
if (projectIdreq.equals("--ALL--")) {
if (req.getParameter("fields")==null) {
} else if (req.getParameter("fields").equals("[\"key\"]")) {
if (req.getParameter("query")==null) {
} else if (req.getParameter("query").equals("")) {
} else {
String typeQuery = req.getParameter("query");
}
} else {
}
Query addQuery = addQueryBuilder.buildQuery();
Clause clause = addQuery.getWhereClause();
if (req.getParameter("query")==null) {
if (sort.equals("id") && dir.equals("ASC")) {
queryBuilder.where().and().unresolved().endWhere().orderBy().issueId(SortOrder.ASC).endOrderBy();
} else if (sort.equals("id") && dir.equals("DESC")) {
queryBuilder.where().and().unresolved().endWhere().orderBy().issueId(SortOrder.DESC).endOrderBy();
}
} else if (req.getParameter("query").equals("")) {
if (sort.equals("id") && dir.equals("ASC")) {
queryBuilder.orderBy().issueId(SortOrder.ASC).endOrderBy();
} else if (sort.equals("id") && dir.equals("DESC")) {
queryBuilder.orderBy().issueId(SortOrder.DESC).endOrderBy();
}
} else {
if (req.getParameter("fields").equals("[\"key\"]")) {
String statusQuery = req.getParameter("query");
if (sort.equals("id") && dir.equals("ASC")) {
queryBuilder.where()
.issue(statusQuery)
.endWhere()
.orderBy().issueId(SortOrder.ASC).endOrderBy();
} else if (sort.equals("id") && dir.equals("DESC")) {
queryBuilder.where().issue(statusQuery)
.endWhere()
.orderBy().issueId(SortOrder.DESC).endOrderBy();
}
} else if (req.getParameter("fields").equals("[\"summary\"]")) {
String summaryQuery = req.getParameter("query");
if (sort.equals("id") && dir.equals("ASC")) {
queryBuilder.where()
.summary(summaryQuery)
.endWhere()
.orderBy().issueId(SortOrder.ASC).endOrderBy();
} else if (sort.equals("id") && dir.equals("DESC")) {
queryBuilder.where()
.summary(summaryQuery)
.endWhere()
.orderBy().issueId(SortOrder.DESC).endOrderBy();
}
} else {
if (sort.equals("id") && dir.equals("ASC")) {
queryBuilder.orderBy().issueId(SortOrder.ASC).endOrderBy();
} else if (sort.equals("id") && dir.equals("DESC")) {
queryBuilder.orderBy().issueId(SortOrder.DESC).endOrderBy();
}
}
}
} else {
if (req.getParameter("fields")==null) {
} else if (req.getParameter("fields").equals("[\"key\"]")) {
if (req.getParameter("query")==null) {
} else if (req.getParameter("query").equals("")) {
} else {
String typeQuery = req.getParameter("query");
}
} else {
}
Query addQuery = addQueryBuilder.buildQuery();
Clause clause = addQuery.getWhereClause();
if (req.getParameter("query")==null) {
if (sort.equals("id") && dir.equals("ASC")) {
queryBuilder.where().project(projectIdreq).and().unresolved().endWhere().orderBy().issueId(SortOrder.ASC).endOrderBy();
} else if (sort.equals("id") && dir.equals("DESC")) {
queryBuilder.where().project(projectIdreq).and().unresolved().endWhere().orderBy().issueId(SortOrder.DESC).endOrderBy();
}
} else if (req.getParameter("query").equals("")) {
if (sort.equals("id") && dir.equals("ASC")) {
queryBuilder.where().project(projectIdreq).and().unresolved().endWhere().orderBy().issueId(SortOrder.ASC).endOrderBy();
} else if (sort.equals("id") && dir.equals("DESC")) {
queryBuilder.where().project(projectIdreq).and().unresolved().endWhere().orderBy().issueId(SortOrder.DESC).endOrderBy();
}
} else {
if (req.getParameter("fields").equals("[\"key\"]")) {
String statusQuery = req.getParameter("query");
if (sort.equals("id") && dir.equals("ASC")) {
queryBuilder.where()
.issue(statusQuery)
.and().project(projectIdreq)
.and().unresolved()
.endWhere()
.orderBy().issueId(SortOrder.ASC).endOrderBy();
} else if (sort.equals("id") && dir.equals("DESC")) {
queryBuilder.where().issue(statusQuery)
.and().project(projectIdreq)
.and().unresolved()
.endWhere()
.orderBy().issueId(SortOrder.DESC).endOrderBy();
}
} else if (req.getParameter("fields").equals("[\"summary\"]")) {
String summaryQuery = req.getParameter("query");
if (sort.equals("id") && dir.equals("ASC")) {
queryBuilder.where() //.createdBetween(dateFirstDate, dateLastDate)
.summary(summaryQuery)
.and().project(projectIdreq)
.and().unresolved()
.endWhere()
.orderBy().issueId(SortOrder.ASC).endOrderBy();
} else if (sort.equals("id") && dir.equals("DESC")) {
queryBuilder.where() //.createdBetween(dateFirstDate, dateLastDate).and()
.summary(summaryQuery)
.and().project(projectIdreq)
.and().unresolved()
.endWhere()
.orderBy().issueId(SortOrder.DESC).endOrderBy();
}
} else {
if (sort.equals("id") && dir.equals("ASC")) {
queryBuilder.where().project(projectIdreq).and().unresolved().endWhere().orderBy().issueId(SortOrder.ASC).endOrderBy();
} else if (sort.equals("id") && dir.equals("DESC")) {
queryBuilder.where().project(projectIdreq).and().unresolved().endWhere().orderBy().issueId(SortOrder.DESC).endOrderBy();
}
}
}
}
} else {
if (projectIdreq.equals("--ALL--")) {
if (req.getParameter("fields")==null) {
} else if (req.getParameter("fields").equals("[\"key\"]")) {
if (req.getParameter("query")==null) {
} else if (req.getParameter("query").equals("")) {
} else {
String typeQuery = req.getParameter("query");
}
} else {
}
Query addQuery = addQueryBuilder.buildQuery();
Clause clause = addQuery.getWhereClause();
if (req.getParameter("query")==null) {
if (sort.equals("id") && dir.equals("ASC")) {
queryBuilder.where().not().unresolved().endWhere().orderBy().issueId(SortOrder.ASC).endOrderBy();
} else if (sort.equals("id") && dir.equals("DESC")) {
queryBuilder.where().not().unresolved().endWhere().orderBy().issueId(SortOrder.DESC).endOrderBy();
}
} else if (req.getParameter("query").equals("")) {
if (sort.equals("id") && dir.equals("ASC")) {
queryBuilder.where().not().unresolved().endWhere().orderBy().issueId(SortOrder.ASC).endOrderBy();
} else if (sort.equals("id") && dir.equals("DESC")) {
queryBuilder.where().not().unresolved().endWhere().orderBy().issueId(SortOrder.DESC).endOrderBy();
}
} else {
if (req.getParameter("fields").equals("[\"key\"]")) {
String statusQuery = req.getParameter("query");
if (sort.equals("id") && dir.equals("ASC")) {
queryBuilder.where()
.issue(statusQuery)
.and().not().unresolved()
.endWhere()
.orderBy().issueId(SortOrder.ASC).endOrderBy();
} else if (sort.equals("id") && dir.equals("DESC")) {
queryBuilder.where().issue(statusQuery)
.and().not().unresolved()
.endWhere()
.orderBy().issueId(SortOrder.DESC).endOrderBy();
}
} else if (req.getParameter("fields").equals("[\"summary\"]")) {
String summaryQuery = req.getParameter("query");
if (sort.equals("id") && dir.equals("ASC")) {
queryBuilder.where()
.summary(summaryQuery)
.and().not().unresolved()
.endWhere()
.orderBy().issueId(SortOrder.ASC).endOrderBy();
} else if (sort.equals("id") && dir.equals("DESC")) {
queryBuilder.where()
.summary(summaryQuery)
.and().not().unresolved()
.endWhere()
.orderBy().issueId(SortOrder.DESC).endOrderBy();
}
} else {
if (sort.equals("id") && dir.equals("ASC")) {
queryBuilder.where().and().not().unresolved().endWhere().orderBy().issueId(SortOrder.ASC).endOrderBy();
} else if (sort.equals("id") && dir.equals("DESC")) {
queryBuilder.where().and().not().unresolved().endWhere().orderBy().issueId(SortOrder.DESC).endOrderBy();
}
}
}
} else {
if (req.getParameter("fields")==null) {
} else if (req.getParameter("fields").equals("[\"key\"]")) {
if (req.getParameter("query")==null) {
} else if (req.getParameter("query").equals("")) {
} else {
String typeQuery = req.getParameter("query");
}
} else {
}
Query addQuery = addQueryBuilder.buildQuery();
Clause clause = addQuery.getWhereClause();
if (req.getParameter("query")==null) {
if (sort.equals("id") && dir.equals("ASC")) {
queryBuilder.where().project(projectIdreq).and().not().unresolved().endWhere().orderBy().issueId(SortOrder.ASC).endOrderBy();
} else if (sort.equals("id") && dir.equals("DESC")) {
queryBuilder.where().project(projectIdreq).and().not().unresolved().endWhere().orderBy().issueId(SortOrder.DESC).endOrderBy();
}
} else if (req.getParameter("query").equals("")) {
if (sort.equals("id") && dir.equals("ASC")) {
queryBuilder.where().project(projectIdreq).and().not().unresolved().endWhere().orderBy().issueId(SortOrder.ASC).endOrderBy();
} else if (sort.equals("id") && dir.equals("DESC")) {
queryBuilder.where().project(projectIdreq).and().not().unresolved().endWhere().orderBy().issueId(SortOrder.DESC).endOrderBy();
}
} else {
if (req.getParameter("fields").equals("[\"key\"]")) {
String statusQuery = req.getParameter("query");
if (sort.equals("id") && dir.equals("ASC")) {
queryBuilder.where()
.issue(statusQuery)
.and().project(projectIdreq)
.and().not().unresolved()
.endWhere()
.orderBy().issueId(SortOrder.ASC).endOrderBy();
} else if (sort.equals("id") && dir.equals("DESC")) {
queryBuilder.where().issue(statusQuery)
.and().project(projectIdreq)
.and().not().unresolved()
.endWhere()
.orderBy().issueId(SortOrder.DESC).endOrderBy();
}
} else if (req.getParameter("fields").equals("[\"summary\"]")) {
String summaryQuery = req.getParameter("query");
if (sort.equals("id") && dir.equals("ASC")) {
queryBuilder.where()
.summary(summaryQuery)
.and().project(projectIdreq)
.and().not().unresolved()
.endWhere()
.orderBy().issueId(SortOrder.ASC).endOrderBy();
} else if (sort.equals("id") && dir.equals("DESC")) {
queryBuilder.where()
.summary(summaryQuery)
.and().project(projectIdreq)
.and().not().unresolved()
.endWhere()
.orderBy().issueId(SortOrder.DESC).endOrderBy();
}
} else {
if (sort.equals("id") && dir.equals("ASC")) {
queryBuilder.where().project(projectIdreq).and().not().unresolved().endWhere().orderBy().issueId(SortOrder.ASC).endOrderBy();
} else if (sort.equals("id") && dir.equals("DESC")) {
queryBuilder.where().project(projectIdreq).and().not().unresolved().endWhere().orderBy().issueId(SortOrder.DESC).endOrderBy();
}
}
}
}
}
Query query = queryBuilder.buildQuery();
SearchResults results = searchService.search(targetUser, query, PagerFilter.getUnlimitedFilter());
iList = results.getResults();
pages = results.getTotal();
}
catch (SearchException e)
{
e.printStackTrace();
System.out.println("Got an SearchException: " + e.getCause());
}
Iterator iteratorUnlimited = iList.iterator();
timeSpentTotal = 0;
doubleTotalOrgEst = 0;
doubleTotleRemEst = 0;
doubleTimeSpent = 0;
while (iteratorUnlimited.hasNext()) {
Issue issueIter = (Issue) iteratorUnlimited.next();
try {
if (issueIter.getOriginalEstimate()==null) {
orgEst = 0.0;
doubleOrgEst = Double.valueOf(orgEst);
} else {
orgEst = Double.valueOf(issueIter.getOriginalEstimate());
doubleOrgEst = Double.valueOf(orgEst / 3600);
doubleTotalOrgEst = doubleTotalOrgEst + orgEst;
}
if (issueIter.getEstimate()==null) {
remEst = 0.0;
doubleRemEst = Double.valueOf(remEst);
} else {
remEst = Double.valueOf(issueIter.getEstimate());
doubleRemEst = Double.valueOf(remEst / 3600);
doubleTotleRemEst = doubleTotleRemEst + remEst;
}
double timespentInSeconds = 0;
if (issueIter.getTimeSpent()==null) {
} else {
timespentInSeconds = Double.valueOf(issueIter.getTimeSpent());
timeSpentTotal = timeSpentTotal + Double.valueOf(issueIter.getTimeSpent());
}
JSONObject obj = new JSONObject();
timeSpentTotalByDate = 0;
try {
remoteObj = new JSONObject()
.put("id", pages)
.put("timespent", timeSpentTotal / 3600)
.put("initial_estimate",doubleTotalOrgEst / 3600)
.put("remaining_estimate",doubleTotleRemEst / 3600);
} catch (JSONException err) {
err.printStackTrace();
System.out.println("Got an JSONException: " + err.getCause());
}
try {
List<GenericValue> worklogs = getTimeSpentsAsList(y,m,1,lastDate,issueIter.getId());
Iterator<GenericValue> worklogIterator = worklogs.iterator();
while (worklogIterator.hasNext()) {
GenericValue genericWorklog = worklogIterator.next();
Worklog worklog = WorklogUtil.convertToWorklog(genericWorklog, worklogManager, issueManager);
Issue issue = issueManager.getIssueObject(genericWorklog.getLong("issue"));
Issue iss = worklog.getIssue();
startDate = itter.format(worklog.getStartDate());
long timeSpent = worklog.getTimeSpent();
doubleTimeSpent = Double.valueOf(timeSpent) / 3600;
String[] parts = startDate.split("-");
int numDays = Integer.valueOf(parts[1]).intValue();
if (req.getParameter("fields")==null) {
try {
obj.put(startDate,getTimeSpentsTotals(y,m,numDays,numDays));
} catch (GenericEntityException e) {
e.printStackTrace();
}
if (req.getParameter("query")==null) {
try {
obj.put(startDate,getTimeSpentsTotals(y,m,numDays,numDays));
} catch (GenericEntityException e) {
e.printStackTrace();
}
} else if (req.getParameter("query").equals("")) {
try {
obj.put(startDate,getTimeSpentsTotals(y,m,numDays,numDays));
} catch (GenericEntityException e) {
e.printStackTrace();
}
} else {
try {
obj.put(startDate,getTimeSpentsTotals(y,m,numDays,numDays));
} catch (GenericEntityException e) {
e.printStackTrace();
}
}
} else {
try {
obj.put(startDate,getTimeSpentsTotals(y,m,numDays,numDays));
} catch (GenericEntityException e) {
e.printStackTrace();
}
}
}
} catch (GenericEntityException err) {
}
try
{
double oldTimeSpent = obj.getDouble(startDate);
doubleTimeSpent = doubleTimeSpent + oldTimeSpent;
JSONObject jsonTimeSpentTotalByDate = new JSONObject().put(startDate, doubleTimeSpent);
remoteByDate.put(jsonTimeSpentTotalByDate);
}
catch (JSONException e)
{
}
} catch (JSONException jerr) {
jerr.printStackTrace();
System.out.println("Got an JSONException: " + jerr.getCause());
}
}
}
}
else
{
//No license (valid or invalid) is stored.
licenseValid = false;
}
try {
merged = new JSONObject(remoteObj, JSONObject.getNames(remoteObj));
for (int i = 0; i < remoteByDate.length(); i++) {
JSONObject toMerge = remoteByDate.getJSONObject(i);
for(String key : JSONObject.getNames(toMerge))
{
merged.put(key, toMerge.get(key));
}
}
} catch (JSONException e) {
e.printStackTrace();
}
remote.put(merged);
issues = arr;
if (licenseValid) {
value = Boolean.valueOf(!"false"
.equalsIgnoreCase((String) "true"));
try {
json = new JSONObject()
.put("remotesummary", remote)
.put("issues", issues)
.put("totalCount", pages)
.put("success", value)
.toString();
} catch (JSONException err) {
err.printStackTrace();
System.out.println("Got an JSONException: " + err.getCause());
}
} else {
value = Boolean.valueOf(!"false"
.equalsIgnoreCase((String) "false"));
try {
json = new JSONObject()
.put("success", value)
.toString();
} catch (JSONException err) {
err.printStackTrace();
System.out.println("Got an JSONException: " + err.getCause());
}
}
resp.setContentType("application/json");
resp.getWriter().write(json);
resp.getWriter().close();
我该怎么解决这个问题?有人能帮我吗?
1条答案
按热度按时间vfhzx4xs1#
正确的答案是,summary不可能使用缓冲分页。所以我从LockingGrid中删除了缓冲分页功能,现在它可以工作了。缓冲分页也会导致其他功能的多个问题。