Skip to content
Snippets Groups Projects

refactor: :bulb: Great refactor of redirects

Merged Ghost User requested to merge dBucik/redirecting into main
48 files
+ 1259
1530
Compare changes
  • Side-by-side
  • Inline
Files
48
@@ -15,6 +15,8 @@
*******************************************************************************/
package cz.muni.ics.data;
import lombok.Getter;
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;
import java.util.Collection;
@@ -29,6 +31,8 @@ import java.util.Set;
* @author Colm Smyth.
*/
@Slf4j
@Getter
@Setter
public abstract class AbstractPageOperationTemplate<T> {
private static final int DEFAULT_MAX_PAGES = 1000;
@@ -39,44 +43,13 @@ public abstract class AbstractPageOperationTemplate<T> {
private boolean swallowExceptions = true;
private String operationName;
public AbstractPageOperationTemplate(String operationName){
protected AbstractPageOperationTemplate(String operationName){
this(DEFAULT_MAX_PAGES, DEFAULT_MAX_TIME_MILLIS, operationName);
}
public AbstractPageOperationTemplate(int maxPages, long maxTime, String operationName){
this.maxPages = maxPages;
this.maxTime = maxTime;
this.operationName = operationName;
}
public int getMaxPages() {
return maxPages;
}
public void setMaxPages(int maxPages) {
protected AbstractPageOperationTemplate(int maxPages, long maxTime, String operationName){
this.maxPages = maxPages;
}
public long getMaxTime() {
return maxTime;
}
public void setMaxTime(long maxTime) {
this.maxTime = maxTime;
}
public boolean isSwallowExceptions() {
return swallowExceptions;
}
public void setSwallowExceptions(boolean swallowExceptions) {
this.swallowExceptions = swallowExceptions;
}
public String getOperationName() {
return operationName;
}
public void setOperationName(String operationName) {
this.operationName = operationName;
}
@@ -88,7 +61,7 @@ public abstract class AbstractPageOperationTemplate<T> {
* performing the operation on the item will be swallowed if the
* swallowException (default true) field is set true.
*/
public void execute(){
public void execute() {
log.debug("[{}] Starting execution of paged operation. max time: {}, max pages: {}", getOperationName(), maxTime, maxPages);
long startTime = System.currentTimeMillis();
@@ -99,9 +72,9 @@ public abstract class AbstractPageOperationTemplate<T> {
int operationsCompleted = 0;
Set<String> exceptionsSwallowedClasses = new HashSet<>();
while (i < maxPages && executionTime < maxTime){
while (i < maxPages && executionTime < maxTime) {
Collection<T> page = fetchPage();
if (page == null || page.size() == 0){
if (page == null || page.isEmpty()){
break;
}
Loading