All Downloads are FREE. Search and download functionalities are using the official Maven repository.

de.uni.freiburg.iig.telematik.sewol.log.LogView Maven / Gradle / Ivy

Go to download

SEWOL provides support for the handling of workflow traces. Specifically it allows to specify the shape and content of process traces in terms of entries representing the execution of a specific workflow activity. SEWOL also allows to write these traces on disk as a log file with the help of a special file writer for process logs. Currently it supports plain text, Petrify, MXML and XES log file types. In order to specify security-related context information, SEWOL provides access control models such as access control lists (ACL) and role-based access control models (RBAC). All types of models can be conveniently edited with the help of appropriate dialogs.

The newest version!
/*
 * Copyright (c) 2016, IIG Telematics, Uni Freiburg
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted (subject to the limitations in the disclaimer
 * below) provided that the following conditions are met:
 *
 * * Redistributions of source code must retain the above copyright notice, this
 *   list of conditions and the following disclaimer.
 * * Redistributions in binary form must reproduce the above copyright notice,
 *   this list of conditions and the following disclaimer in the documentation
 *   and/or other materials provided with the distribution.
 * * Neither the name of IIG Telematics, Uni Freiburg nor the names of its
 *   contributors may be used to endorse or promote products derived from this
 *   software without specific prior written permission.
 *
 * NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY
 * THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
 * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT
 * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
 * CONTRIBUTORS BELIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */
package de.uni.freiburg.iig.telematik.sewol.log;

import de.invation.code.toval.misc.Filterable;
import de.invation.code.toval.validate.ParameterException;
import de.invation.code.toval.validate.Validate;
import de.uni.freiburg.iig.telematik.sewol.log.filter.AbstractLogFilter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Observable;
import java.util.Observer;
import java.util.Set;

/**
 * Adapter class for {@link Log} with {@link Filterable} representing a filtered
 * log.
 *
 * @author Adrian Lange 
 * @param  LogEntry type
 */
public class LogView extends Log implements Observer {

        private final List> allTraces = new ArrayList<>();
        private final Set> filters = new HashSet<>();

        private boolean uptodate = true;
        private String label;

        public LogView(String label) {
                setLabel(label);
        }

        /**
         * Adds a new filter to the view.
         *
         * @param filter
         */
        public void addFilter(AbstractLogFilter filter) {
                Validate.notNull(filter);
                filters.add(filter);
                uptodate = false;
                filter.addObserver(this);
        }

        /**
         * Removes a filter to the view.
         *
         * @param filter
         */
        public void removeFilter(AbstractLogFilter filter) {
                Validate.notNull(filter);
                filters.remove(filter);
                uptodate = false;
                filter.deleteObserver(this);
        }

        /**
         * Returns an unmodifiable list of filters.
         *
         * @return
         */
        public Set> getFilters() {
                return Collections.unmodifiableSet(filters);
        }

        /**
         * Returns the label of the view.
         *
         * @return
         */
        public final String getLabel() {
                return label;
        }

        /**
         * Sets the label of the view. It must have at least one character which
         * is not a whitespace.
         *
         * @param label
         */
        public final void setLabel(String label) {
                Validate.notEmpty(label.replaceAll("\\s+", ""));

                this.label = label;
        }

        @Override
        public LogSummary getSummary() {
                update();
                return summary;
        }

        @Override
        public void addTrace(LogTrace trace) throws ParameterException {
                Validate.notNull(trace);
                boolean accept = true;
                for (AbstractLogFilter filter : filters) {
                        if (!filter.accept(trace)) {
                                accept = false;
                                break;
                        }
                }
                if (accept) {
                        traces.add(trace);
                        summary.addTrace(trace);
                        if (!distinctTraces.add(trace)) {
                                for (LogTrace storedTrace : traces) {
                                        if (storedTrace.equals(trace)) {
                                                storedTrace.addSimilarInstance(trace.getCaseNumber());
                                                trace.addSimilarInstance(storedTrace.getCaseNumber());
                                        }
                                }
                        }
                }
                allTraces.add(trace);
        }

        @Override
        public void addTraces(List> traces) throws ParameterException {
                Validate.notNull(traces);
                for (LogTrace trace : traces) {
                        addTrace(trace);
                }
        }

        @Override
        public List> getTraces() {
                update();
                return Collections.unmodifiableList(traces);
        }

        @Override
        public void update(Observable observable, Object object) {
                uptodate = false;
        }

        /**
         * Updates the summary, set of distinct traces and list of traces if the
         * filter set has been changed.
         */
        private void update() {
                if (!uptodate) {
                        summary.clear();
                        distinctTraces.clear();
                        traces.clear();
                        addTraces(allTraces);
                        uptodate = true;
                }
        }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy