Search in sources :

Example 1 with InvalidFilterConstraintException

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());
    }
}
Also used : MinMaxFilter(com.cosylab.logging.engine.MinMaxFilter) ExactFilter(com.cosylab.logging.engine.ExactFilter) LogTypeHelper(com.cosylab.logging.engine.log.LogTypeHelper) InvalidFilterConstraintException(com.cosylab.logging.engine.InvalidFilterConstraintException)

Example 2 with InvalidFilterConstraintException

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");
    }
}
Also used : MinMaxFilter(com.cosylab.logging.engine.MinMaxFilter) RegExpFilter(com.cosylab.logging.engine.RegExpFilter) ExactFilter(com.cosylab.logging.engine.ExactFilter) MinMaxFilter(com.cosylab.logging.engine.MinMaxFilter) Filter(com.cosylab.logging.engine.Filter) InvalidFilterConstraintException(com.cosylab.logging.engine.InvalidFilterConstraintException)

Example 3 with InvalidFilterConstraintException

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;
}
Also used : MinMaxFilter(com.cosylab.logging.engine.MinMaxFilter) MinMaxFilter(com.cosylab.logging.engine.MinMaxFilter) Filter(com.cosylab.logging.engine.Filter) FiltersVector(com.cosylab.logging.engine.FiltersVector) InvalidFilterConstraintException(com.cosylab.logging.engine.InvalidFilterConstraintException)

Example 4 with InvalidFilterConstraintException

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());
    }
}
Also used : MinMaxFilter(com.cosylab.logging.engine.MinMaxFilter) Date(java.util.Date) InvalidFilterConstraintException(com.cosylab.logging.engine.InvalidFilterConstraintException)

Aggregations

InvalidFilterConstraintException (com.cosylab.logging.engine.InvalidFilterConstraintException)4 MinMaxFilter (com.cosylab.logging.engine.MinMaxFilter)4 ExactFilter (com.cosylab.logging.engine.ExactFilter)2 Filter (com.cosylab.logging.engine.Filter)2 FiltersVector (com.cosylab.logging.engine.FiltersVector)1 RegExpFilter (com.cosylab.logging.engine.RegExpFilter)1 LogTypeHelper (com.cosylab.logging.engine.log.LogTypeHelper)1 Date (java.util.Date)1