Skip to content
Snippets Groups Projects
Commit ae9dcbd7 authored by Raphael GIRARDOT's avatar Raphael GIRARDOT
Browse files

better minimum archiving period management (TANGOARCH-930)

parent db72c60d
Branches
No related tags found
No related merge requests found
......@@ -18,7 +18,7 @@ import fr.soleil.mambo.containers.archiving.dialogs.AttributesPropertiesPanel;
import fr.soleil.mambo.datasources.db.archiving.ArchivingManagerFactory;
import fr.soleil.mambo.datasources.db.archiving.IArchivingManager;
public class ArchivingConfigurationAttributeDBProperties implements Cloneable {
public abstract class ArchivingConfigurationAttributeDBProperties implements Cloneable {
private static final Logger LOGGER = LoggerFactory.getLogger(ArchivingConfigurationAttributeDBProperties.class);
......@@ -146,11 +146,13 @@ public class ArchivingConfigurationAttributeDBProperties implements Cloneable {
return modes == null ? Boolean.FALSE : modes.containsKey(Integer.valueOf(type));
}
public void controlValues() throws ArchivingConfigurationException {
public abstract void controlValues() throws ArchivingConfigurationException;
protected void controlValues(int minPeriod) throws ArchivingConfigurationException {
ArchivingConfigurationMode[] modes = getModes();
if ((modes != null) && (modes.length > 0)) {
for (ArchivingConfigurationMode mode : modes) {
mode.controlValues();
mode.controlValues(minPeriod);
}
}
}
......
......@@ -159,7 +159,7 @@ public class ArchivingConfigurationAttributeHDBProperties extends ArchivingConfi
@Override
public void controlValues() throws ArchivingConfigurationException {
if (!isEmpty()) {
super.controlValues();
super.controlValues(1000);
}
}
......
......@@ -202,7 +202,7 @@ public class ArchivingConfigurationAttributeTDBProperties extends ArchivingConfi
if (exportPeriod < EXPORT_PERIOD_MIN) {
throw new ArchivingConfigurationException(null, EXPORT_PERIOD_TOO_LOW);
}
super.controlValues();
super.controlValues(100);
}
}
......
......@@ -162,7 +162,7 @@ public class ArchivingConfigurationAttributeTTSProperties extends ArchivingConfi
@Override
public void controlValues() throws ArchivingConfigurationException {
if (!isEmpty()) {
super.controlValues();
super.controlValues(100);
}
}
......
......@@ -81,8 +81,6 @@ public class ArchivingConfigurationMode {
public static final int MODE_A_VAL_INF_BIGGER_THAN_VAL_SUP = 101;
public static final int MODE_R_PERCENT_INF_BIGGER_THAN_PERCENT_SUP = 102;
private static final int PERIOD_MIN = 1000;
public static String getLabel(int _type) {
String ret = null;
......@@ -415,67 +413,61 @@ public class ArchivingConfigurationMode {
}
/**
* 9 sept. 2005
*
* @throws ArchivingConfigurationException
* Checks whether mode parameters are valid.
*
* @param minPeriod The known minimum archiving period allowed according to database.
* @throws ArchivingConfigurationException If any parameter is invalid.
*/
public void controlValues() throws ArchivingConfigurationException {
public void controlValues(int minPeriod) throws ArchivingConfigurationException {
switch (this.type) {
case TYPE_A:
ModeAbsolu modeA = this.mode.getModeA();
if (modeA.getValInf() >= modeA.getValSup()) {
throw new ArchivingConfigurationException(null, MODE_A_VAL_INF_BIGGER_THAN_VAL_SUP);
}
if (modeA.getPeriod() < PERIOD_MIN) {
if (modeA.getPeriod() < minPeriod) {
throw new ArchivingConfigurationException(null, PERIOD_TOO_LOW);
}
break;
case TYPE_C:
ModeCalcul modeC = this.mode.getModeC();
if (modeC.getPeriod() < PERIOD_MIN) {
if (modeC.getPeriod() < minPeriod) {
throw new ArchivingConfigurationException(null, PERIOD_TOO_LOW);
}
break;
case TYPE_D:
ModeDifference modeD = this.mode.getModeD();
if (modeD.getPeriod() < PERIOD_MIN) {
if (modeD.getPeriod() < minPeriod) {
throw new ArchivingConfigurationException(null, PERIOD_TOO_LOW);
}
break;
case TYPE_E:
break;
case TYPE_P:
ModePeriode modeP = this.mode.getModeP();
if (modeP.getPeriod() < PERIOD_MIN) {
if (modeP.getPeriod() < minPeriod) {
throw new ArchivingConfigurationException(null, PERIOD_TOO_LOW);
}
break;
case TYPE_R:
ModeRelatif modeR = this.mode.getModeR();
if (modeR.getPercentInf() >= modeR.getPercentSup()) {
throw new ArchivingConfigurationException(null, MODE_R_PERCENT_INF_BIGGER_THAN_PERCENT_SUP);
}
if (modeR.getPeriod() < PERIOD_MIN) {
if (modeR.getPeriod() < minPeriod) {
throw new ArchivingConfigurationException(null, PERIOD_TOO_LOW);
}
break;
case TYPE_T:
ModeSeuil modeT = this.mode.getModeT();
if (modeT.getThresholdInf() >= modeT.getThresholdSup()) {
throw new ArchivingConfigurationException(null, MODE_R_PERCENT_INF_BIGGER_THAN_PERCENT_SUP);
}
if (modeT.getPeriod() < PERIOD_MIN) {
if (modeT.getPeriod() < minPeriod) {
throw new ArchivingConfigurationException(null, PERIOD_TOO_LOW);
}
break;
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment