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
......@@ -59,18 +59,18 @@ public class ExecuteQuery extends FlagJob {
}
getContainer().addMessage(queryInstance);
int index = 0;
int length = getContainer().size();
int startIndex = 0;
int endIndex = getContainer().size();
if (((Retrieve) getTransaction()).hasPaging()) {
Retrieve.Paging paging = ((Retrieve) getTransaction()).getPaging();
index = Math.min(getContainer().size(), paging.index);
length = Math.min(getContainer().size(), paging.length);
startIndex = Math.min(getContainer().size(), paging.startIndex);
endIndex = Math.min(getContainer().size(), paging.endIndex);
}
int ii = 0;
for (final EntityInterface entity : getContainer()) {
if (ii >= index && ii < length) {
if (ii >= startIndex && ii < endIndex) {
getTransaction().getSchedule().addAll(loadJobs(entity, getTransaction()));
} else {
entity.setEntityStatus(EntityStatus.IGNORE);
......
......@@ -42,24 +42,24 @@ public class Paging extends FlagJob {
protected void job(final String value) {
if (getTransaction() instanceof Retrieve) {
if (value != null) {
int index = DEFAULT_INDEX;
int length = index + DEFAULT_LENGTH;
int startIndex = DEFAULT_INDEX;
int endIndex = startIndex + DEFAULT_LENGTH;
final Matcher m = pattern.matcher(value);
if (m.matches()) {
if (m.group(1) != null) {
index = Integer.parseInt(m.group(1));
startIndex = Integer.parseInt(m.group(1));
}
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
((Retrieve) getTransaction()).setPaging(index, length);
((Retrieve) getTransaction()).setPaging(startIndex, endIndex);
int i = 0;
for (final EntityInterface e : getContainer()) {
if (i >= length || i < index) {
if (i >= endIndex || i < startIndex) {
// do not retrieve this entity
e.setEntityStatus(EntityStatus.IGNORE);
}
......
......@@ -45,18 +45,20 @@ public class RetrieveAllJob extends FlagJob {
execute(new RetrieveAll(getContainer(), value));
int index = 0;
int length = getContainer().size();
int startIndex = 0;
int endIndex = getContainer().size();
if (((Retrieve) getTransaction()).hasPaging()) {
index = Math.min(getContainer().size(), ((Retrieve) getTransaction()).getPaging().index);
length = Math.min(getContainer().size(), ((Retrieve) getTransaction()).getPaging().length);
startIndex =
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
int ii = 0;
for (EntityInterface entity : getContainer()) {
if (ii >= index && ii < length) {
if (ii >= startIndex && ii < endIndex) {
getTransaction().getSchedule().addAll(loadJobs(entity, getTransaction()));
} else {
entity.setEntityStatus(EntityStatus.IGNORE);
......
......@@ -123,13 +123,13 @@ public class Retrieve extends Transaction<RetrieveContainer> {
}
public static class Paging {
public Paging(int index, int length) {
this.index = index;
this.length = length;
public Paging(int startIndex, int endIndex) {
this.startIndex = startIndex;
this.endIndex = endIndex;
}
public final int index;
public final int length;
public final int startIndex;
public final int endIndex;
}
private Retrieve.Paging paging = null;
......@@ -138,8 +138,8 @@ public class Retrieve extends Transaction<RetrieveContainer> {
return this.paging != null;
}
public void setPaging(int index, int length) {
this.paging = new Retrieve.Paging(index, length);
public void setPaging(int startIndex, int endIndex) {
this.paging = new Retrieve.Paging(startIndex, endIndex);
}
public Retrieve.Paging getPaging() {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment