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
No related branches found
No related tags found
2 merge requests!21Release v0.4.0,!18fix importance bug
Pipeline #8885 failed
Showing
with 64 additions and 64 deletions
/*
* ** header v3.0
* 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
*
* 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/>.
*
* ** end header
*/
package org.caosdb.server.database.proto;
import java.io.Serializable;
import org.caosdb.server.jobs.core.JobFailureSeverity;
public class Rule implements Serializable {
private static final long serialVersionUID = 1122097540596265945L;
public int domain = 0;
public int entity = 0;
public String job = null;
public String transaction = null;
public JobFailureSeverity mode = null;
}
///*
// * ** header v3.0
// * 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
// *
// * 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/>.
// *
// * ** end header
// */
//package org.caosdb.server.database.proto;
//
//import java.io.Serializable;
//import org.caosdb.server.jobs.core.JobFailureSeverity;
/
//public class Rule implements Serializable {
//
// private static final long serialVersionUID = 1122097540596265945L;
//
// public int domain = 0;
// public int entity = 0;
// public String job = null;
// public String transaction = null;
// public JobFailureSeverity severity = null;
//}
......@@ -70,7 +70,7 @@ public abstract class Job {
private static List<Class<? extends Job>> loadAlways;
private Transaction<? extends TransactionContainer> transaction = null;
private JobFailureSeverity mode = null;
private JobFailureSeverity failureSeverity = null;
private final TransactionStage stage;
private EntityInterface entity = null;
......@@ -99,7 +99,7 @@ public abstract class Job {
protected ScheduledJob appendJob(final EntityInterface entity, final Class<? extends Job> clazz) {
try {
final Job job = clazz.getDeclaredConstructor().newInstance();
job.init(getMode(), entity, getTransaction());
job.init(getFailureSeverity(), entity, getTransaction());
return getTransaction().getSchedule().add(job);
} catch (InstantiationException
| IllegalAccessException
......@@ -128,10 +128,10 @@ public abstract class Job {
}
public final Job init(
final JobFailureSeverity mode,
final JobFailureSeverity severity,
final EntityInterface entity,
final Transaction<? extends TransactionContainer> transaction) {
this.mode = mode;
this.failureSeverity = severity;
this.entity = entity;
this.transaction = transaction;
return this;
......@@ -149,12 +149,12 @@ public abstract class Job {
return this.entity;
}
protected final JobFailureSeverity getMode() {
return this.mode;
protected final JobFailureSeverity getFailureSeverity() {
return this.failureSeverity;
}
protected final void setMode(final JobFailureSeverity mode) {
this.mode = mode;
protected final void setFailureSeverity(final JobFailureSeverity severiy) {
this.failureSeverity = severiy;
}
TransactionContainer getContainer() {
......@@ -307,7 +307,7 @@ public abstract class Job {
*/
public static Job getJob(
final String job,
final JobFailureSeverity mode,
final JobFailureSeverity severiy,
final EntityInterface entity,
final Transaction<? extends TransactionContainer> transaction) {
// Fill `allClasses` with available subclasses
......@@ -315,7 +315,7 @@ public abstract class Job {
// Get matching class for Job and generate it.
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 {
private static Job getJob(
final Class<? extends Job> jobClass,
final JobFailureSeverity mode,
final JobFailureSeverity severity,
final EntityInterface entity,
final Transaction<? extends TransactionContainer> transaction) {
Job ret;
......@@ -435,7 +435,7 @@ public abstract class Job {
if (jobClass != null) {
ret = jobClass.getDeclaredConstructor().newInstance();
ret.init(mode, entity, transaction);
ret.init(severity, entity, transaction);
return ret;
}
return null;
......@@ -526,7 +526,7 @@ public abstract class Job {
+ "-"
+ (getEntity() != null ? getEntity().toString() : "NOENTITY")
+ " #"
+ getMode().toString()
+ getFailureSeverity().toString()
+ "]";
}
......
......@@ -87,12 +87,12 @@ public class JobConfig {
final Integer entity = Integer.parseInt(row[1]);
final String transaction = row[2];
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);
if (!result.containsKey(key)) {
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) {
throw new ConfigurationException("Could not parse the job rules.", e);
......
......@@ -35,7 +35,7 @@ public class CheckDescPresent extends EntityJob {
@Override
public final void run() {
if (!getEntity().hasDescription()) {
switch (getMode()) {
switch (getFailureSeverity()) {
case ERROR:
getEntity().addError(ServerMessages.ENTITY_HAS_NO_DESCRIPTION);
getEntity().setEntityStatus(EntityStatus.UNQUALIFIED);
......
......@@ -35,7 +35,7 @@ public class CheckNamePresent extends EntityJob {
@Override
public final void run() {
if (!getEntity().hasName()) {
switch (getMode()) {
switch (getFailureSeverity()) {
case ERROR:
getEntity().addError(ServerMessages.ENTITY_HAS_NO_NAME);
getEntity().setEntityStatus(EntityStatus.UNQUALIFIED);
......
......@@ -45,7 +45,7 @@ public class CheckNoAdditionalPropertiesPresent extends EntityJob {
}
private void addMessage(EntityInterface property, Message message) {
if (getMode() == JobFailureSeverity.ERROR) {
if (getFailureSeverity() == JobFailureSeverity.ERROR) {
property.addError(message);
} else {
property.addWarning(message);
......
......@@ -28,7 +28,7 @@ public class CheckNoOverridesPresent extends EntityJob {
}
private void addMessage(Property p, Message message) {
if (getMode() == JobFailureSeverity.ERROR) {
if (getFailureSeverity() == JobFailureSeverity.ERROR) {
p.addError(message);
} else {
p.addWarning(message);
......
......@@ -53,7 +53,7 @@ public class CheckParOblPropPresent extends EntityJob {
if (getEntity().hasParents()) {
handleImportanceFlags();
if (getMode() == JobFailureSeverity.IGNORE) {
if (getFailureSeverity() == JobFailureSeverity.IGNORE) {
// importance is to be ignored
return;
}
......@@ -105,7 +105,7 @@ public class CheckParOblPropPresent extends EntityJob {
// No entityProperty has been found which
// implements this parentProperty. Add the
// respective messages.
switch (getMode()) {
switch (getFailureSeverity()) {
case ERROR:
// TODO add information WHICH property is
// missing.
......@@ -133,13 +133,13 @@ public class CheckParOblPropPresent extends EntityJob {
if (entityFlag != null) {
switch (entityFlag) {
case "error":
setMode(JobFailureSeverity.ERROR);
setFailureSeverity(JobFailureSeverity.ERROR);
break;
case "warn":
setMode(JobFailureSeverity.WARN);
setFailureSeverity(JobFailureSeverity.WARN);
break;
case "ignore":
setMode(JobFailureSeverity.IGNORE);
setFailureSeverity(JobFailureSeverity.IGNORE);
break;
default:
// do nothing
......
......@@ -35,7 +35,7 @@ public class CheckParPresent extends EntityJob {
@Override
public final void run() {
if (!getEntity().hasParents() || getEntity().getParents().isEmpty()) {
switch (getMode()) {
switch (getFailureSeverity()) {
case ERROR:
getEntity().addError(ServerMessages.ENTITY_HAS_NO_PARENTS);
getEntity().setEntityStatus(EntityStatus.UNQUALIFIED);
......
......@@ -35,7 +35,7 @@ public class CheckPropPresent extends EntityJob {
@Override
public final void run() {
if (getEntity().getProperties().isEmpty()) {
switch (getMode()) {
switch (getFailureSeverity()) {
case ERROR:
getEntity().addError(ServerMessages.ENTITY_HAS_NO_PROPERTIES);
getEntity().setEntityStatus(EntityStatus.UNQUALIFIED);
......
......@@ -40,7 +40,7 @@ public class CheckUnitPresent extends EntityJob {
runJobFromSchedule(getEntity(), Inheritance.class);
if (!hasUnit(getEntity())) {
switch (getMode()) {
switch (getFailureSeverity()) {
case ERROR:
getEntity().addError(ServerMessages.ENTITY_HAS_NO_UNIT);
getEntity().setEntityStatus(EntityStatus.UNQUALIFIED);
......
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