Search in sources :

Example 1 with MinMaxFilter

use of com.cosylab.logging.engine.MinMaxFilter 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 2 with MinMaxFilter

use of com.cosylab.logging.engine.MinMaxFilter 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)

Example 3 with MinMaxFilter

use of com.cosylab.logging.engine.MinMaxFilter 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 4 with MinMaxFilter

use of com.cosylab.logging.engine.MinMaxFilter in project ACS by ACS-Community.

the class FilterTest method testMinMaxFilterType.

/**
	 * Check if the filter works for MinMax value 
	 */
public void testMinMaxFilterType() throws Exception {
    // Check the line
    Integer maxLine = Integer.valueOf(120);
    Integer minLine = Integer.valueOf(98);
    Filter minMaxFilter = new MinMaxFilter(LogField.LINE, lethal, minLine, maxLine, false);
    assertTrue("MinMax should have accepted this line value", minMaxFilter.applyTo(log1, lethal));
    assertFalse("MinMax should have rejected this line value", minMaxFilter.applyTo(log2, lethal));
    assertFalse("MinMax should have rejected this line value", minMaxFilter.applyTo(log3, lethal));
    // Check the time
    Date maxDate = df.parseIsoTimestamp("2013-08-07T15:10:10.512");
    Date minDate = df.parseIsoTimestamp("2013-08-02T15:10:10.512");
    Filter minMaxDateFilter = new MinMaxFilter(LogField.TIMESTAMP, lethal, minDate, maxDate, false);
    assertTrue("MinMax should have accepted this timestamp", minMaxDateFilter.applyTo(log1, lethal));
    assertFalse("MinMax should have rejected this timestamp", minMaxDateFilter.applyTo(log2, lethal));
    assertFalse("MinMax should have rejected this timestamp", minMaxDateFilter.applyTo(log3, lethal));
    // Log type
    LogTypeHelper maxType = LogTypeHelper.NOTICE;
    LogTypeHelper minType = LogTypeHelper.DEBUG;
    Filter minMaxTypeFilter = new MinMaxFilter(LogField.ENTRYTYPE, lethal, minType, maxType, false);
    assertTrue("MinMax should have accepted this log type", minMaxTypeFilter.applyTo(log1, lethal));
    assertFalse("MinMax should have rejected this log type", minMaxTypeFilter.applyTo(log2, lethal));
    assertFalse("MinMax should have rejected this log type", minMaxTypeFilter.applyTo(log3, lethal));
}
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) LogTypeHelper(com.cosylab.logging.engine.log.LogTypeHelper) Date(java.util.Date)

Example 5 with MinMaxFilter

use of com.cosylab.logging.engine.MinMaxFilter in project ACS by ACS-Community.

the class FilterTest method testMaxFilterType.

/**
	 * Check if the filter works for max value 
	 */
public void testMaxFilterType() throws Exception {
    // Check the line
    Integer maxLine = Integer.valueOf(120);
    Filter maxFilter = new MinMaxFilter(LogField.LINE, lethal, null, maxLine, false);
    assertTrue("Max should have accepted this line value", maxFilter.applyTo(log1, lethal));
    Integer noMaxLine = Integer.valueOf(98);
    Filter noMaxFilter = new MinMaxFilter(LogField.LINE, lethal, null, noMaxLine, false);
    assertFalse("Min should have rejected this line value", noMaxFilter.applyTo(log1, lethal));
    // Check the time
    Date date = df.parseIsoTimestamp("2013-09-01T15:10:10.512");
    Filter maxDateFilter = new MinMaxFilter(LogField.TIMESTAMP, lethal, null, date, false);
    assertTrue("Max should have accepted this timestamp", maxDateFilter.applyTo(log1, lethal));
    Date noDate = df.parseIsoTimestamp("2013-07-01T15:10:10.512");
    Filter noMaxDateFilter = new MinMaxFilter(LogField.TIMESTAMP, lethal, null, noDate, false);
    assertFalse("Max should have accepted this timestamp", noMaxDateFilter.applyTo(log1, lethal));
    // Log type
    LogTypeHelper maxType = LogTypeHelper.CRITICAL;
    Filter maxTypeFilter = new MinMaxFilter(LogField.ENTRYTYPE, lethal, null, maxType, false);
    assertTrue("Min should have accepted this log type", maxTypeFilter.applyTo(log1, lethal));
    LogTypeHelper noMaxType = LogTypeHelper.TRACE;
    Filter noMaxTypeFilter = new MinMaxFilter(LogField.ENTRYTYPE, lethal, null, noMaxType, false);
    assertFalse("Min should have accepted this log type", noMaxTypeFilter.applyTo(log1, lethal));
}
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) LogTypeHelper(com.cosylab.logging.engine.log.LogTypeHelper) Date(java.util.Date)

Aggregations

MinMaxFilter (com.cosylab.logging.engine.MinMaxFilter)8 ExactFilter (com.cosylab.logging.engine.ExactFilter)6 Filter (com.cosylab.logging.engine.Filter)6 RegExpFilter (com.cosylab.logging.engine.RegExpFilter)5 Date (java.util.Date)5 InvalidFilterConstraintException (com.cosylab.logging.engine.InvalidFilterConstraintException)4 LogTypeHelper (com.cosylab.logging.engine.log.LogTypeHelper)4 FiltersVector (com.cosylab.logging.engine.FiltersVector)1 File (java.io.File)1