use of com.cosylab.logging.engine.InvalidFilterConstraintException in project ACS by ACS-Community.
the class FilterTypePanel method getFilter.
/* (non-Javadoc)
* @see com.cosylab.logging.settings.FilterParameterPanel#getFilter()
*/
public Filter getFilter() throws FilterParameterException {
boolean bmin = minimumCheck.isSelected();
boolean bmax = maximumCheck.isSelected();
boolean bexact = exactCheck.isSelected();
LogTypeHelper min = null;
LogTypeHelper max = null;
if (bexact) {
try {
return new ExactFilter(getFieldIndex(), isLethal(), (LogTypeHelper) exact.getSelectedItem(), notCheck.isSelected());
} catch (InvalidFilterConstraintException e) {
e.printStackTrace();
throw new FilterParameterException(e.getMessage());
}
}
if (bmin) {
min = (LogTypeHelper) minimum.getSelectedItem();
}
if (bmax) {
max = (LogTypeHelper) maximum.getSelectedItem();
}
if ((min != null) && (max != null)) {
if (min.compareTo(max) > -1) {
throw new FilterParameterException("Minimum must be less than maximum");
}
}
try {
return new MinMaxFilter(getFieldIndex(), isLethal(), min, max, notCheck.isSelected());
} catch (InvalidFilterConstraintException e) {
throw new FilterParameterException(e.getMessage());
}
}
use of com.cosylab.logging.engine.InvalidFilterConstraintException in project ACS by ACS-Community.
the class FilterTest method testWrongMinMaxValuesInFilters.
/**
* Building a filter with a min>=max must return a error.
* This tests builds a filter passing a min value greater then a max value and catching the exception.
*
* @throws Exception
*/
public void testWrongMinMaxValuesInFilters() throws Exception {
Integer maxLine = Integer.valueOf(120);
Integer minLine = Integer.valueOf(98);
try {
Filter minMaxFilter = new MinMaxFilter(LogField.LINE, lethal, maxLine, minLine, false);
System.out.println("Error building a filter with min=" + maxLine + "max=" + minLine);
} catch (InvalidFilterConstraintException ivc) {
// This exception means that the test passed!
System.out.println("Test passed: error received while building a filter with wrong values");
}
}
use of com.cosylab.logging.engine.InvalidFilterConstraintException in project ACS by ACS-Community.
the class FileHelper method setupFilters.
/**
* Create the filters for loading logs;:
* <UL>
* <LI>time range
* <LI>min and max log levels
* </UL>
* @return
*/
private FiltersVector setupFilters() throws ZoomException {
FiltersVector filters = new FiltersVector();
Filter dateFilter = null;
Filter levelFilter = null;
try {
dateFilter = new MinMaxFilter(LogField.TIMESTAMP, false, startTime, endTime, false);
levelFilter = new MinMaxFilter(LogField.ENTRYTYPE, false, minLogLevel, maxLogLevel, false);
} catch (InvalidFilterConstraintException e) {
throw new ZoomException("Error setting the filters", e);
}
filters.addFilter(dateFilter, true);
filters.addFilter(levelFilter, true);
return filters;
}
use of com.cosylab.logging.engine.InvalidFilterConstraintException in project ACS by ACS-Community.
the class FilterDatePanel method getFilter.
/**
* Insert the method's description here.
* Creation date: (2/7/02 11:59:47 AM)
* @return com.cosylab.logging.engine.Filter
* @exception com.cosylab.logging.engine.InvalidFilterConstraintException The exception description.
*/
public Filter getFilter() throws FilterParameterException {
Date min = null;
Date max = null;
if (minimumCheck.isSelected()) {
min = minimum.getDate().getTime();
// System.out.println(min.toString());
}
if (maximumCheck.isSelected()) {
max = maximum.getDate().getTime();
// System.out.println(max.toString());
}
if ((min == null) && (max == null)) {
throw new FilterParameterException("Select at least one constraint");
}
if ((min != null) && (max != null)) {
if (min.compareTo(max) > -1)
throw new FilterParameterException("From must be less than To");
}
try {
return new MinMaxFilter(getFieldIndex(), isLethal(), min, max, notCheck.isSelected());
} catch (InvalidFilterConstraintException e) {
throw new FilterParameterException(e.getMessage());
}
}
Aggregations