From 751fa7fe534b26d9d472beef2acf81f65548925f Mon Sep 17 00:00:00 2001 From: Daniel Hornung <d.hornung@indiscale.com> Date: Fri, 4 Jun 2021 10:25:00 +0200 Subject: [PATCH] STY: Automatic style changes. --- .../server/database/BackendTransaction.java | 4 +- src/main/java/org/caosdb/server/jobs/Job.java | 11 ++-- .../org/caosdb/server/jobs/JobAnnotation.java | 4 +- .../caosdb/server/jobs/JobExecutionTime.java | 4 +- .../java/org/caosdb/server/jobs/Schedule.java | 10 ++-- .../org/caosdb/server/jobs/ScheduledJob.java | 12 ++--- .../server/transaction/Transaction.java | 50 +++++++++---------- .../transaction/TransactionInterface.java | 3 +- 8 files changed, 39 insertions(+), 59 deletions(-) diff --git a/src/main/java/org/caosdb/server/database/BackendTransaction.java b/src/main/java/org/caosdb/server/database/BackendTransaction.java index 44f1b9d9..965e7181 100644 --- a/src/main/java/org/caosdb/server/database/BackendTransaction.java +++ b/src/main/java/org/caosdb/server/database/BackendTransaction.java @@ -145,9 +145,7 @@ public abstract class BackendTransaction implements Undoable { protected abstract void execute(); - /** - * Like execute(), but with benchmarking measurement. - */ + /** Like execute(), but with benchmarking measurement. */ public final void executeTransaction() { final long t1 = System.currentTimeMillis(); execute(); diff --git a/src/main/java/org/caosdb/server/jobs/Job.java b/src/main/java/org/caosdb/server/jobs/Job.java index f93c2e44..d9cd4d1f 100644 --- a/src/main/java/org/caosdb/server/jobs/Job.java +++ b/src/main/java/org/caosdb/server/jobs/Job.java @@ -60,10 +60,9 @@ import org.reflections.Reflections; * @todo Describe me. */ public abstract class Job { - /** - * All known Job classes, by name (actually lowercase getSimpleName()). - */ + /** All known Job classes, by name (actually lowercase getSimpleName()). */ static HashMap<String, Class<? extends Job>> allClasses = null; + private static List<Class<? extends Job>> loadAlways; private Transaction<? extends TransactionContainer> transaction = null; @@ -71,7 +70,6 @@ public abstract class Job { private final JobExecutionTime time; private EntityInterface entity = null; - public abstract JobTarget getTarget(); protected <S, T> HashMap<S, T> getCache(final String name) { @@ -239,8 +237,8 @@ public abstract class Job { /** * Create a Job object with the given parameters. - * <p> - * This static method is used by other classes to create Job objects, instead of the private + * + * <p>This static method is used by other classes to create Job objects, instead of the private * constructor. * * @return The generated Job object. @@ -476,7 +474,6 @@ public abstract class Job { /** * @todo What is a permanent Job? What does "load" mean? - * * @return A list with the jobs. */ public static List<Job> loadPermanentContainerJobs(Transaction<?> transaction) { diff --git a/src/main/java/org/caosdb/server/jobs/JobAnnotation.java b/src/main/java/org/caosdb/server/jobs/JobAnnotation.java index 3041fca4..b1493f13 100644 --- a/src/main/java/org/caosdb/server/jobs/JobAnnotation.java +++ b/src/main/java/org/caosdb/server/jobs/JobAnnotation.java @@ -26,9 +26,7 @@ import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import org.caosdb.server.transaction.TransactionInterface; -/** - * Jobs may be annotated with @JobAnnotation(...). - */ +/** Jobs may be annotated with @JobAnnotation(...). */ @Retention(RetentionPolicy.RUNTIME) public @interface JobAnnotation { JobExecutionTime time() default JobExecutionTime.CHECK; diff --git a/src/main/java/org/caosdb/server/jobs/JobExecutionTime.java b/src/main/java/org/caosdb/server/jobs/JobExecutionTime.java index 13570d1e..5d79d72b 100644 --- a/src/main/java/org/caosdb/server/jobs/JobExecutionTime.java +++ b/src/main/java/org/caosdb/server/jobs/JobExecutionTime.java @@ -22,9 +22,7 @@ */ package org.caosdb.server.jobs; -/** - * Not really a time (measured in seconds), but rather the execution stage. - */ +/** Not really a time (measured in seconds), but rather the execution stage. */ public enum JobExecutionTime { INIT, PRE_CHECK, diff --git a/src/main/java/org/caosdb/server/jobs/Schedule.java b/src/main/java/org/caosdb/server/jobs/Schedule.java index 6c28eaf9..58630648 100644 --- a/src/main/java/org/caosdb/server/jobs/Schedule.java +++ b/src/main/java/org/caosdb/server/jobs/Schedule.java @@ -30,9 +30,7 @@ import java.util.Map; import java.util.concurrent.CopyOnWriteArrayList; import org.caosdb.server.entity.EntityInterface; -/** - * Keeps track of Jobs, ordered by "time". - */ +/** Keeps track of Jobs, ordered by "time". */ public class Schedule { private final Map<Integer, List<ScheduledJob>> jobLists = new HashMap<>(); @@ -57,9 +55,7 @@ public class Schedule { return ret; } - /** - * Run all Jobs with the specified JobExecutionTime. - */ + /** Run all Jobs with the specified JobExecutionTime. */ public void runJobs(final JobExecutionTime time) { List<ScheduledJob> jobs = this.jobLists.get(time.ordinal()); if (jobs != null) { @@ -90,7 +86,7 @@ public class Schedule { /** * Run all scheduled Jobs for the given entity. * - * Execution time: Either CHECK or what is given as jobclass' annotation. + * <p>Execution time: Either CHECK or what is given as jobclass' annotation. */ public void runJob(final EntityInterface entity, final Class<? extends Job> jobclass) { List<ScheduledJob> jobs = diff --git a/src/main/java/org/caosdb/server/jobs/ScheduledJob.java b/src/main/java/org/caosdb/server/jobs/ScheduledJob.java index c3751d5e..defd1d68 100644 --- a/src/main/java/org/caosdb/server/jobs/ScheduledJob.java +++ b/src/main/java/org/caosdb/server/jobs/ScheduledJob.java @@ -54,16 +54,12 @@ public class ScheduledJob { return this.job.toString(); } - /** - * Does not actually start the job, but only sets the startTime. - */ + /** Does not actually start the job, but only sets the startTime. */ private void start() { this.startTime = System.currentTimeMillis(); } - /** - * Calculate and set the runtime, and add the measurement. - */ + /** Calculate and set the runtime, and add the measurement. */ private void finish() { this.runtime += System.currentTimeMillis() - this.startTime; this.job @@ -84,9 +80,7 @@ public class ScheduledJob { return this.startTime != -1; } - /** - * Return the state of the inner Job. - */ + /** Return the state of the inner Job. */ public JobExecutionTime getExecutionTime() { return this.job.getExecutionTime(); } diff --git a/src/main/java/org/caosdb/server/transaction/Transaction.java b/src/main/java/org/caosdb/server/transaction/Transaction.java index 7e5d4e16..fdc4e646 100644 --- a/src/main/java/org/caosdb/server/transaction/Transaction.java +++ b/src/main/java/org/caosdb/server/transaction/Transaction.java @@ -88,8 +88,8 @@ public abstract class Transaction<C extends TransactionContainer> extends Abstra /** * Implementation note: Not called in this class, but may be used by subclasses. - * <p> - * E.g. in {@link Retrieve} and {@link WriteTransaction}. + * + * <p>E.g. in {@link Retrieve} and {@link WriteTransaction}. */ protected void makeSchedule() throws Exception { // load flag jobs @@ -122,28 +122,28 @@ public abstract class Transaction<C extends TransactionContainer> extends Abstra /** * The main transaction execution method. - * <p> - * This method calls the following other internal methods and scheduled jobs stored in the {@link - * getSchedule() internal Schedule object}: - * <ul> - * <li> {@link init} - * <li> {@link Schedule.runJobs(INIT)} - * <li> {@link preCheck} - * <li> {@link Schedule.runJobs(PRE_CHECK)} - * <li> {@link check} - * <li> {@link Schedule.runJobs(POST_CHECK)} - * <li> {@link postCheck} - * <li> {@link preTransaction} - * <li> {@link Schedule.runJobs(PRE_TRANSACTION)} - * <li> {@link transaction}: This is typically the main method of a Transaction. - * <li> {@link Schedule.runJobs(POST_TRANSACTION)} - * <li> {@link postTransaction} - * <li> {@link writeHistory} - * <li> {@link commit} - * <li> {@link rollBack}: Only in the case of errors. - * <li> {@link cleanUp}: Always. - * <li> {@link notifyObservers(CLEAN_UP)}: Also always. * + * <p>This method calls the following other internal methods and scheduled jobs stored in the + * {@link getSchedule() internal Schedule object}: + * + * <ul> + * <li>{@link init} + * <li>{@link Schedule.runJobs(INIT)} + * <li>{@link preCheck} + * <li>{@link Schedule.runJobs(PRE_CHECK)} + * <li>{@link check} + * <li>{@link Schedule.runJobs(POST_CHECK)} + * <li>{@link postCheck} + * <li>{@link preTransaction} + * <li>{@link Schedule.runJobs(PRE_TRANSACTION)} + * <li>{@link transaction}: This is typically the main method of a Transaction. + * <li>{@link Schedule.runJobs(POST_TRANSACTION)} + * <li>{@link postTransaction} + * <li>{@link writeHistory} + * <li>{@link commit} + * <li>{@link rollBack}: Only in the case of errors. + * <li>{@link cleanUp}: Always. + * <li>{@link notifyObservers(CLEAN_UP)}: Also always. */ @Override public final void execute() throws Exception { @@ -234,8 +234,8 @@ public abstract class Transaction<C extends TransactionContainer> extends Abstra /** * Return the internal {@link Schedule} object. - * <p> - * The Schedule stores jobs which are also triggered by this transaction (see {@link execute()} + * + * <p>The Schedule stores jobs which are also triggered by this transaction (see {@link execute()} * for details). */ public Schedule getSchedule() { diff --git a/src/main/java/org/caosdb/server/transaction/TransactionInterface.java b/src/main/java/org/caosdb/server/transaction/TransactionInterface.java index 37c216bd..d56407ca 100644 --- a/src/main/java/org/caosdb/server/transaction/TransactionInterface.java +++ b/src/main/java/org/caosdb/server/transaction/TransactionInterface.java @@ -37,8 +37,7 @@ public interface TransactionInterface { /** * Append the BackendTransaction t to a RollBackHandler before basically calling {@code - * t.execute()}. Except for benchmarking, this method does not interact directly with this - * object. + * t.execute()}. Except for benchmarking, this method does not interact directly with this object. */ public default <K extends BackendTransaction> K execute(K t, Access access) { final RollBackHandler handler = (RollBackHandler) access.getHelper("RollBack"); -- GitLab