diff --git a/conf/core/jobs.csv b/conf/core/jobs.csv index 71fd6422039c78f3f2ff81ed71e761356763c520..84795bee8657288473188cd9e7a6af81f6295221 100644 --- a/conf/core/jobs.csv +++ b/conf/core/jobs.csv @@ -1,8 +1,6 @@ # # This file is a part of the CaosDB Project. # -# Copyright (C) 2018 Research Group Biomedical Physics, -# Max-Planck-Institute for Dynamics and Self-Organization Göttingen # Copyright (C) 2021 Timm Fitsche <t.fitschen@indiscale.com> # Copyright (C) 2021 IndiScale GmbH <info@indiscale.com> # diff --git a/src/main/java/org/caosdb/server/jobs/Job.java b/src/main/java/org/caosdb/server/jobs/Job.java index ed2ca77c9cd7a8e728ea10f00bc8dfa1833092e9..f54cfa41db38c687e19746d1208a09cc21aa50f7 100644 --- a/src/main/java/org/caosdb/server/jobs/Job.java +++ b/src/main/java/org/caosdb/server/jobs/Job.java @@ -169,11 +169,12 @@ public abstract class Job { * <p>If the targetParent is not in the set of parents of the child, this method iterates through * the direct parents of the child. * - * <p>If the both entities are part of this transaction, they are resolved within this - * transaction. Otherwise they are fetched from the database backend or the whole evaluation takes - * place in the backend (if both have persistent ids and are not part of this transaction). + * <p>If both entities are part of this transaction, they are resolved within this transaction. + * Otherwise they are fetched from the database backend or the whole evaluation takes place in the + * backend (if both have persistent ids and are not part of this transaction). * - * <p>Also, if both entities have the same id or name, the return value is true. + * <p>If both entities have the same id or name, the return value is true without any further + * checks. * * @param child the child entity * @param targetParent the parent entity @@ -551,8 +552,8 @@ public abstract class Job { } /** - * Resolve an entity (which might only be specified by it's name or id) to it's full - * representation (with properties, parents and all). + * Resolve an entity (which might only be specified by it's name or id) to its full representation + * (with properties, parents and all). * * @param entity the entity to be resolved. * @return the resolved entity. diff --git a/src/main/java/org/caosdb/server/jobs/JobConfig.java b/src/main/java/org/caosdb/server/jobs/JobConfig.java index f400ec639c29ce6010a91f05d81a4e50e5f8a81a..732a985a78b5f67c88d1c01dff1565e887aab13c 100644 --- a/src/main/java/org/caosdb/server/jobs/JobConfig.java +++ b/src/main/java/org/caosdb/server/jobs/JobConfig.java @@ -1,3 +1,23 @@ +/* + * This file is a part of the CaosDB Project. + * + * Copyright (C) 2021 IndiScale GmbH <info@indiscale.com> + * Copyright (C) 2021 Timm Fitschen <t.fitschen@indiscale.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + */ + package org.caosdb.server.jobs; import java.io.BufferedReader; @@ -26,11 +46,11 @@ import org.caosdb.server.utils.ConfigurationException; * <p>A job rule contains of a quintuple (domain, entity, transaction type, job name, job failure * severity). * - * <p>The domain and the entities define for which entities the job (of the given name) should be - * loaded. The transaction type (e.g. Insert, Update, Delete) defines the transaction where this - * rule applies. The job failure severity sets the related property of a job. + * <p>The domain and entity define for which entities the job (of the given name) should be loaded. + * The transaction type (e.g. Insert, Update, Delete) defines the transaction where this rule + * applies. The job failure severity sets the related property of a job. * - * <p>The configuration is being read from a config file {@link + * <p>The configuration is being read by default from a config file {@link * ServerProperties#KEY_JOB_RULES_CONFIG} * * <p>This class works as a singleton, most of the time. It is possible to instanciate it otherwise, @@ -117,19 +137,19 @@ public class JobConfig { private void addRule(final Map<String, List<Object[]>> result, final String[] row) { if (row.length != 5) { throw new ConfigurationException( - "Could not parse the job rules. Lines of four comma-separated values expected"); + "Could not parse the job rules. Lines of five comma-separated values expected"); } try { final Integer domain = Integer.parseInt(row[0]); final Integer entity = Integer.parseInt(row[1]); final String transaction = row[2]; final String job = row[3]; - final JobFailureSeverity severiy = JobFailureSeverity.valueOf(row[4]); + final JobFailureSeverity severity = JobFailureSeverity.valueOf(row[4]); final String key = getKey(domain, entity, transaction); if (!result.containsKey(key)) { result.put(key, new ArrayList<>()); } - result.get(key).add(new Object[] {job, severiy}); + result.get(key).add(new Object[] {job, severity}); } catch (final Exception e) { throw new ConfigurationException("Could not parse the job rules.", e); @@ -137,14 +157,14 @@ public class JobConfig { } /** - * Factory method for the instanciation and configuration of a job for a specific entity. + * Factory method for the instanciation and configuration of jobs for a specific entity. * * @param domain the domain of the rule * @param entity the entity of the rule (this might be a particular datatype or a role, like * "RecordType") * @param target the entity for which the job will run. * @param transaction the transaction for which the job will run. - * @return A fresh job instance + * @return Fresh job instances, one for each matching job rule. */ public List<Job> getConfiguredJobs( final Integer domain, diff --git a/src/main/java/org/caosdb/server/jobs/core/CheckParOblPropPresent.java b/src/main/java/org/caosdb/server/jobs/core/CheckParOblPropPresent.java index ffcbcc061aa35dc7e8b076533c39eed5c17be072..b706afdbcd2082fa2ac3d76c0128959abfb42bd9 100644 --- a/src/main/java/org/caosdb/server/jobs/core/CheckParOblPropPresent.java +++ b/src/main/java/org/caosdb/server/jobs/core/CheckParOblPropPresent.java @@ -75,7 +75,9 @@ public class CheckParOblPropPresent extends EntityJob { } /** - * Check if all obligatory properties of the given parent are present. Add a warning, + * Check if all obligatory properties of the given parent are present. + * + * <p>Add an error or warning if not. * * @param parent * @throws Message @@ -128,6 +130,7 @@ public class CheckParOblPropPresent extends EntityJob { } } + /** Look at the entity's importance flag first, at the container's flag second. */ private void handleImportanceFlags() { final String globalFlag = getTransaction().getContainer().getFlags().get(OBL_IMPORTANCE_FLAG_KEY); diff --git a/src/main/java/org/caosdb/server/jobs/core/JobFailureSeverity.java b/src/main/java/org/caosdb/server/jobs/core/JobFailureSeverity.java index f3bfe63e15bd93a70590ddb413f8863533b7db88..e95bef34b7b9bea8e1b2b2126da196c1c7c53c12 100644 --- a/src/main/java/org/caosdb/server/jobs/core/JobFailureSeverity.java +++ b/src/main/java/org/caosdb/server/jobs/core/JobFailureSeverity.java @@ -4,6 +4,8 @@ * * Copyright (C) 2018 Research Group Biomedical Physics, * Max-Planck-Institute for Dynamics and Self-Organization Göttingen + * Copyright (C) 2021 Indiscale GmbH <info@indiscale.com> + * Copyright (C) 2021 Timm Fitschen <t.fitschen@indiscale.com> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as