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

rename more occurrences of mode to severity

parent 0b6e7de3
Branches
Tags
2 merge requests!21Release v0.4.0,!18fix importance bug
Pipeline #8885 failed
Showing
with 64 additions and 64 deletions
/* ///*
* ** header v3.0 // * ** header v3.0
* This file is a part of the CaosDB Project. // * This file is a part of the CaosDB Project.
* // *
* Copyright (C) 2018 Research Group Biomedical Physics, // * Copyright (C) 2018 Research Group Biomedical Physics,
* Max-Planck-Institute for Dynamics and Self-Organization Göttingen // * Max-Planck-Institute for Dynamics and Self-Organization Göttingen
* // *
* This program is free software: you can redistribute it and/or modify // * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as // * it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the // * published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version. // * License, or (at your option) any later version.
* // *
* This program is distributed in the hope that it will be useful, // * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of // * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details. // * GNU Affero General Public License for more details.
* // *
* You should have received a copy of the GNU Affero General Public License // * 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/>. // * along with this program. If not, see <https://www.gnu.org/licenses/>.
* // *
* ** end header // * ** end header
*/ // */
package org.caosdb.server.database.proto; //package org.caosdb.server.database.proto;
//
import java.io.Serializable; //import java.io.Serializable;
import org.caosdb.server.jobs.core.JobFailureSeverity; //import org.caosdb.server.jobs.core.JobFailureSeverity;
/
public class Rule implements Serializable { //public class Rule implements Serializable {
//
private static final long serialVersionUID = 1122097540596265945L; // private static final long serialVersionUID = 1122097540596265945L;
//
public int domain = 0; // public int domain = 0;
public int entity = 0; // public int entity = 0;
public String job = null; // public String job = null;
public String transaction = null; // public String transaction = null;
public JobFailureSeverity mode = null; // public JobFailureSeverity severity = null;
} //}
...@@ -70,7 +70,7 @@ public abstract class Job { ...@@ -70,7 +70,7 @@ public abstract class Job {
private static List<Class<? extends Job>> loadAlways; private static List<Class<? extends Job>> loadAlways;
private Transaction<? extends TransactionContainer> transaction = null; private Transaction<? extends TransactionContainer> transaction = null;
private JobFailureSeverity mode = null; private JobFailureSeverity failureSeverity = null;
private final TransactionStage stage; private final TransactionStage stage;
private EntityInterface entity = null; private EntityInterface entity = null;
...@@ -99,7 +99,7 @@ public abstract class Job { ...@@ -99,7 +99,7 @@ public abstract class Job {
protected ScheduledJob appendJob(final EntityInterface entity, final Class<? extends Job> clazz) { protected ScheduledJob appendJob(final EntityInterface entity, final Class<? extends Job> clazz) {
try { try {
final Job job = clazz.getDeclaredConstructor().newInstance(); final Job job = clazz.getDeclaredConstructor().newInstance();
job.init(getMode(), entity, getTransaction()); job.init(getFailureSeverity(), entity, getTransaction());
return getTransaction().getSchedule().add(job); return getTransaction().getSchedule().add(job);
} catch (InstantiationException } catch (InstantiationException
| IllegalAccessException | IllegalAccessException
...@@ -128,10 +128,10 @@ public abstract class Job { ...@@ -128,10 +128,10 @@ public abstract class Job {
} }
public final Job init( public final Job init(
final JobFailureSeverity mode, final JobFailureSeverity severity,
final EntityInterface entity, final EntityInterface entity,
final Transaction<? extends TransactionContainer> transaction) { final Transaction<? extends TransactionContainer> transaction) {
this.mode = mode; this.failureSeverity = severity;
this.entity = entity; this.entity = entity;
this.transaction = transaction; this.transaction = transaction;
return this; return this;
...@@ -149,12 +149,12 @@ public abstract class Job { ...@@ -149,12 +149,12 @@ public abstract class Job {
return this.entity; return this.entity;
} }
protected final JobFailureSeverity getMode() { protected final JobFailureSeverity getFailureSeverity() {
return this.mode; return this.failureSeverity;
} }
protected final void setMode(final JobFailureSeverity mode) { protected final void setFailureSeverity(final JobFailureSeverity severiy) {
this.mode = mode; this.failureSeverity = severiy;
} }
TransactionContainer getContainer() { TransactionContainer getContainer() {
...@@ -307,7 +307,7 @@ public abstract class Job { ...@@ -307,7 +307,7 @@ public abstract class Job {
*/ */
public static Job getJob( public static Job getJob(
final String job, final String job,
final JobFailureSeverity mode, final JobFailureSeverity severiy,
final EntityInterface entity, final EntityInterface entity,
final Transaction<? extends TransactionContainer> transaction) { final Transaction<? extends TransactionContainer> transaction) {
// Fill `allClasses` with available subclasses // Fill `allClasses` with available subclasses
...@@ -315,7 +315,7 @@ public abstract class Job { ...@@ -315,7 +315,7 @@ public abstract class Job {
// Get matching class for Job and generate it. // Get matching class for Job and generate it.
final Class<? extends Job> jobClass = allClasses.get(job.toLowerCase()); final Class<? extends Job> jobClass = allClasses.get(job.toLowerCase());
return getJob(jobClass, mode, entity, transaction); return getJob(jobClass, severiy, entity, transaction);
} }
/** /**
...@@ -427,7 +427,7 @@ public abstract class Job { ...@@ -427,7 +427,7 @@ public abstract class Job {
private static Job getJob( private static Job getJob(
final Class<? extends Job> jobClass, final Class<? extends Job> jobClass,
final JobFailureSeverity mode, final JobFailureSeverity severity,
final EntityInterface entity, final EntityInterface entity,
final Transaction<? extends TransactionContainer> transaction) { final Transaction<? extends TransactionContainer> transaction) {
Job ret; Job ret;
...@@ -435,7 +435,7 @@ public abstract class Job { ...@@ -435,7 +435,7 @@ public abstract class Job {
if (jobClass != null) { if (jobClass != null) {
ret = jobClass.getDeclaredConstructor().newInstance(); ret = jobClass.getDeclaredConstructor().newInstance();
ret.init(mode, entity, transaction); ret.init(severity, entity, transaction);
return ret; return ret;
} }
return null; return null;
...@@ -526,7 +526,7 @@ public abstract class Job { ...@@ -526,7 +526,7 @@ public abstract class Job {
+ "-" + "-"
+ (getEntity() != null ? getEntity().toString() : "NOENTITY") + (getEntity() != null ? getEntity().toString() : "NOENTITY")
+ " #" + " #"
+ getMode().toString() + getFailureSeverity().toString()
+ "]"; + "]";
} }
......
...@@ -87,12 +87,12 @@ public class JobConfig { ...@@ -87,12 +87,12 @@ public class JobConfig {
final Integer entity = Integer.parseInt(row[1]); final Integer entity = Integer.parseInt(row[1]);
final String transaction = row[2]; final String transaction = row[2];
final String job = row[3]; final String job = row[3];
final JobFailureSeverity mode = JobFailureSeverity.valueOf(row[4]); final JobFailureSeverity severiy = JobFailureSeverity.valueOf(row[4]);
final String key = getKey(domain, entity, transaction); final String key = getKey(domain, entity, transaction);
if (!result.containsKey(key)) { if (!result.containsKey(key)) {
result.put(key, new ArrayList<>()); result.put(key, new ArrayList<>());
} }
result.get(key).add(new Object[] {job, mode}); result.get(key).add(new Object[] {job, severiy});
} catch (final Exception e) { } catch (final Exception e) {
throw new ConfigurationException("Could not parse the job rules.", e); throw new ConfigurationException("Could not parse the job rules.", e);
......
...@@ -35,7 +35,7 @@ public class CheckDescPresent extends EntityJob { ...@@ -35,7 +35,7 @@ public class CheckDescPresent extends EntityJob {
@Override @Override
public final void run() { public final void run() {
if (!getEntity().hasDescription()) { if (!getEntity().hasDescription()) {
switch (getMode()) { switch (getFailureSeverity()) {
case ERROR: case ERROR:
getEntity().addError(ServerMessages.ENTITY_HAS_NO_DESCRIPTION); getEntity().addError(ServerMessages.ENTITY_HAS_NO_DESCRIPTION);
getEntity().setEntityStatus(EntityStatus.UNQUALIFIED); getEntity().setEntityStatus(EntityStatus.UNQUALIFIED);
......
...@@ -35,7 +35,7 @@ public class CheckNamePresent extends EntityJob { ...@@ -35,7 +35,7 @@ public class CheckNamePresent extends EntityJob {
@Override @Override
public final void run() { public final void run() {
if (!getEntity().hasName()) { if (!getEntity().hasName()) {
switch (getMode()) { switch (getFailureSeverity()) {
case ERROR: case ERROR:
getEntity().addError(ServerMessages.ENTITY_HAS_NO_NAME); getEntity().addError(ServerMessages.ENTITY_HAS_NO_NAME);
getEntity().setEntityStatus(EntityStatus.UNQUALIFIED); getEntity().setEntityStatus(EntityStatus.UNQUALIFIED);
......
...@@ -45,7 +45,7 @@ public class CheckNoAdditionalPropertiesPresent extends EntityJob { ...@@ -45,7 +45,7 @@ public class CheckNoAdditionalPropertiesPresent extends EntityJob {
} }
private void addMessage(EntityInterface property, Message message) { private void addMessage(EntityInterface property, Message message) {
if (getMode() == JobFailureSeverity.ERROR) { if (getFailureSeverity() == JobFailureSeverity.ERROR) {
property.addError(message); property.addError(message);
} else { } else {
property.addWarning(message); property.addWarning(message);
......
...@@ -28,7 +28,7 @@ public class CheckNoOverridesPresent extends EntityJob { ...@@ -28,7 +28,7 @@ public class CheckNoOverridesPresent extends EntityJob {
} }
private void addMessage(Property p, Message message) { private void addMessage(Property p, Message message) {
if (getMode() == JobFailureSeverity.ERROR) { if (getFailureSeverity() == JobFailureSeverity.ERROR) {
p.addError(message); p.addError(message);
} else { } else {
p.addWarning(message); p.addWarning(message);
......
...@@ -53,7 +53,7 @@ public class CheckParOblPropPresent extends EntityJob { ...@@ -53,7 +53,7 @@ public class CheckParOblPropPresent extends EntityJob {
if (getEntity().hasParents()) { if (getEntity().hasParents()) {
handleImportanceFlags(); handleImportanceFlags();
if (getMode() == JobFailureSeverity.IGNORE) { if (getFailureSeverity() == JobFailureSeverity.IGNORE) {
// importance is to be ignored // importance is to be ignored
return; return;
} }
...@@ -105,7 +105,7 @@ public class CheckParOblPropPresent extends EntityJob { ...@@ -105,7 +105,7 @@ public class CheckParOblPropPresent extends EntityJob {
// No entityProperty has been found which // No entityProperty has been found which
// implements this parentProperty. Add the // implements this parentProperty. Add the
// respective messages. // respective messages.
switch (getMode()) { switch (getFailureSeverity()) {
case ERROR: case ERROR:
// TODO add information WHICH property is // TODO add information WHICH property is
// missing. // missing.
...@@ -133,13 +133,13 @@ public class CheckParOblPropPresent extends EntityJob { ...@@ -133,13 +133,13 @@ public class CheckParOblPropPresent extends EntityJob {
if (entityFlag != null) { if (entityFlag != null) {
switch (entityFlag) { switch (entityFlag) {
case "error": case "error":
setMode(JobFailureSeverity.ERROR); setFailureSeverity(JobFailureSeverity.ERROR);
break; break;
case "warn": case "warn":
setMode(JobFailureSeverity.WARN); setFailureSeverity(JobFailureSeverity.WARN);
break; break;
case "ignore": case "ignore":
setMode(JobFailureSeverity.IGNORE); setFailureSeverity(JobFailureSeverity.IGNORE);
break; break;
default: default:
// do nothing // do nothing
......
...@@ -35,7 +35,7 @@ public class CheckParPresent extends EntityJob { ...@@ -35,7 +35,7 @@ public class CheckParPresent extends EntityJob {
@Override @Override
public final void run() { public final void run() {
if (!getEntity().hasParents() || getEntity().getParents().isEmpty()) { if (!getEntity().hasParents() || getEntity().getParents().isEmpty()) {
switch (getMode()) { switch (getFailureSeverity()) {
case ERROR: case ERROR:
getEntity().addError(ServerMessages.ENTITY_HAS_NO_PARENTS); getEntity().addError(ServerMessages.ENTITY_HAS_NO_PARENTS);
getEntity().setEntityStatus(EntityStatus.UNQUALIFIED); getEntity().setEntityStatus(EntityStatus.UNQUALIFIED);
......
...@@ -35,7 +35,7 @@ public class CheckPropPresent extends EntityJob { ...@@ -35,7 +35,7 @@ public class CheckPropPresent extends EntityJob {
@Override @Override
public final void run() { public final void run() {
if (getEntity().getProperties().isEmpty()) { if (getEntity().getProperties().isEmpty()) {
switch (getMode()) { switch (getFailureSeverity()) {
case ERROR: case ERROR:
getEntity().addError(ServerMessages.ENTITY_HAS_NO_PROPERTIES); getEntity().addError(ServerMessages.ENTITY_HAS_NO_PROPERTIES);
getEntity().setEntityStatus(EntityStatus.UNQUALIFIED); getEntity().setEntityStatus(EntityStatus.UNQUALIFIED);
......
...@@ -40,7 +40,7 @@ public class CheckUnitPresent extends EntityJob { ...@@ -40,7 +40,7 @@ public class CheckUnitPresent extends EntityJob {
runJobFromSchedule(getEntity(), Inheritance.class); runJobFromSchedule(getEntity(), Inheritance.class);
if (!hasUnit(getEntity())) { if (!hasUnit(getEntity())) {
switch (getMode()) { switch (getFailureSeverity()) {
case ERROR: case ERROR:
getEntity().addError(ServerMessages.ENTITY_HAS_NO_UNIT); getEntity().addError(ServerMessages.ENTITY_HAS_NO_UNIT);
getEntity().setEntityStatus(EntityStatus.UNQUALIFIED); getEntity().setEntityStatus(EntityStatus.UNQUALIFIED);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment