Skip to content
Snippets Groups Projects
Verified Commit 7028a06b authored by Timm Fitschen's avatar Timm Fitschen
Browse files

MAINT: rename paging variables to startIndex, endIndex

parent a88a62cb
No related branches found
No related tags found
2 merge requests!96DOC: Added CITATION.cff to the list of files in the release guide where the...,!81ENH: apply paging such that no unwanted jobs are being triggered
Pipeline #37096 passed
This commit is part of merge request !81. Comments created here will be created in the context of that merge request.
...@@ -59,18 +59,18 @@ public class ExecuteQuery extends FlagJob { ...@@ -59,18 +59,18 @@ public class ExecuteQuery extends FlagJob {
} }
getContainer().addMessage(queryInstance); getContainer().addMessage(queryInstance);
int index = 0; int startIndex = 0;
int length = getContainer().size(); int endIndex = getContainer().size();
if (((Retrieve) getTransaction()).hasPaging()) { if (((Retrieve) getTransaction()).hasPaging()) {
Retrieve.Paging paging = ((Retrieve) getTransaction()).getPaging(); Retrieve.Paging paging = ((Retrieve) getTransaction()).getPaging();
index = Math.min(getContainer().size(), paging.index); startIndex = Math.min(getContainer().size(), paging.startIndex);
length = Math.min(getContainer().size(), paging.length); endIndex = Math.min(getContainer().size(), paging.endIndex);
} }
int ii = 0; int ii = 0;
for (final EntityInterface entity : getContainer()) { for (final EntityInterface entity : getContainer()) {
if (ii >= index && ii < length) { if (ii >= startIndex && ii < endIndex) {
getTransaction().getSchedule().addAll(loadJobs(entity, getTransaction())); getTransaction().getSchedule().addAll(loadJobs(entity, getTransaction()));
} else { } else {
entity.setEntityStatus(EntityStatus.IGNORE); entity.setEntityStatus(EntityStatus.IGNORE);
......
...@@ -42,24 +42,24 @@ public class Paging extends FlagJob { ...@@ -42,24 +42,24 @@ public class Paging extends FlagJob {
protected void job(final String value) { protected void job(final String value) {
if (getTransaction() instanceof Retrieve) { if (getTransaction() instanceof Retrieve) {
if (value != null) { if (value != null) {
int index = DEFAULT_INDEX; int startIndex = DEFAULT_INDEX;
int length = index + DEFAULT_LENGTH; int endIndex = startIndex + DEFAULT_LENGTH;
final Matcher m = pattern.matcher(value); final Matcher m = pattern.matcher(value);
if (m.matches()) { if (m.matches()) {
if (m.group(1) != null) { if (m.group(1) != null) {
index = Integer.parseInt(m.group(1)); startIndex = Integer.parseInt(m.group(1));
} }
if (m.group(2) != null) { if (m.group(2) != null) {
length = index + Integer.parseInt(m.group(2)); endIndex = startIndex + Integer.parseInt(m.group(2));
} }
} }
// this info may be used by other jobs // this info may be used by other jobs
((Retrieve) getTransaction()).setPaging(index, length); ((Retrieve) getTransaction()).setPaging(startIndex, endIndex);
int i = 0; int i = 0;
for (final EntityInterface e : getContainer()) { for (final EntityInterface e : getContainer()) {
if (i >= length || i < index) { if (i >= endIndex || i < startIndex) {
// do not retrieve this entity // do not retrieve this entity
e.setEntityStatus(EntityStatus.IGNORE); e.setEntityStatus(EntityStatus.IGNORE);
} }
......
...@@ -45,18 +45,20 @@ public class RetrieveAllJob extends FlagJob { ...@@ -45,18 +45,20 @@ public class RetrieveAllJob extends FlagJob {
execute(new RetrieveAll(getContainer(), value)); execute(new RetrieveAll(getContainer(), value));
int index = 0; int startIndex = 0;
int length = getContainer().size(); int endIndex = getContainer().size();
if (((Retrieve) getTransaction()).hasPaging()) { if (((Retrieve) getTransaction()).hasPaging()) {
index = Math.min(getContainer().size(), ((Retrieve) getTransaction()).getPaging().index); startIndex =
length = Math.min(getContainer().size(), ((Retrieve) getTransaction()).getPaging().length); Math.min(getContainer().size(), ((Retrieve) getTransaction()).getPaging().startIndex);
endIndex =
Math.min(getContainer().size(), ((Retrieve) getTransaction()).getPaging().endIndex);
} }
// only add jobs for those which are on this page // only add jobs for those which are on this page
int ii = 0; int ii = 0;
for (EntityInterface entity : getContainer()) { for (EntityInterface entity : getContainer()) {
if (ii >= index && ii < length) { if (ii >= startIndex && ii < endIndex) {
getTransaction().getSchedule().addAll(loadJobs(entity, getTransaction())); getTransaction().getSchedule().addAll(loadJobs(entity, getTransaction()));
} else { } else {
entity.setEntityStatus(EntityStatus.IGNORE); entity.setEntityStatus(EntityStatus.IGNORE);
......
...@@ -123,13 +123,13 @@ public class Retrieve extends Transaction<RetrieveContainer> { ...@@ -123,13 +123,13 @@ public class Retrieve extends Transaction<RetrieveContainer> {
} }
public static class Paging { public static class Paging {
public Paging(int index, int length) { public Paging(int startIndex, int endIndex) {
this.index = index; this.startIndex = startIndex;
this.length = length; this.endIndex = endIndex;
} }
public final int index; public final int startIndex;
public final int length; public final int endIndex;
} }
private Retrieve.Paging paging = null; private Retrieve.Paging paging = null;
...@@ -138,8 +138,8 @@ public class Retrieve extends Transaction<RetrieveContainer> { ...@@ -138,8 +138,8 @@ public class Retrieve extends Transaction<RetrieveContainer> {
return this.paging != null; return this.paging != null;
} }
public void setPaging(int index, int length) { public void setPaging(int startIndex, int endIndex) {
this.paging = new Retrieve.Paging(index, length); this.paging = new Retrieve.Paging(startIndex, endIndex);
} }
public Retrieve.Paging getPaging() { public Retrieve.Paging getPaging() {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment