/**
 * Copyright 2010 OpenEngSB Division, Vienna University of Technology
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.openengsb.domains.report;

import java.util.List;

import org.openengsb.core.common.Domain;
import org.openengsb.domains.report.model.Report;
import org.openengsb.domains.report.model.ReportPart;

public interface ReportDomain extends Domain {

    /**
     * Generate the report using the information stored under the given reportId and stop collecting data for this
     * report. The report is added to the specified report category and named as specified by the {@code reportName}
     * parameter. The category is created if it is not already present. If there is already a report with the same name
     * under this category it is overwritten.
     * 
     * @return the generated report
     * @throws NoSuchReportException if no report with the given {@code reportId} is currently collecting data.
     */
    Report generateReport(String reportId, String category, String reportName) throws NoSuchReportException;

    /**
     * 
     * Generate a report based on the currently available data stored for the given {@code reportId}. The report is
     * generated but not stored. Furthermore the data collection is not stopped for this report. This method can be used
     * if a preview of the report is needed, but the data collection is not finished yet.
     * 
     * @return the generated report draft
     * @throws NoSuchReportException if no report with the given {@code reportId} is currently collecting data.
     */
    Report getDraft(String reportId, String draftName) throws NoSuchReportException;

    /**
     * Start collecting data for all arriving events with the given id of the given {@link IdType}. If the data
     * collection process is finished the report can be generated by calling the
     * {@link #generateReport(String, String, String)} method specifying the reportId returned by this method.
     * 
     * @return the reportId that can later be used to generate the report by calling
     *         {@link #generateReport(String, String, String)}
     */
    String collectData(IdType idType, String id);

    /**
     * Add the given report part to the report data currently collected for the given {@code reportId}. The report part
     * is appended at the end of the report.
     * 
     * @throws NoSuchReportException if no report with the given {@code reportId} is currently collecting data.
     */
    void addReportPart(String reportId, ReportPart reportPart) throws NoSuchReportException;

    /**
     * Get all finished reports of the given category. Reports, which are currently generated and collect data are not
     * included.
     */
    List<Report> getAllReports(String category);

    /**
     * Store the given report in the report store under the given category. The category is created if it is not already
     * present. If there is already a report with the same name under this category it is overwritten.
     */
    void storeReport(String category, Report report);

    /**
     * Remove the given report from the given category. The report is deleted and cannot be restored if it is not also
     * stored under another category. If no such report exist no operation is performed.
     */
    void removeReport(String category, Report report);

    /**
     * Get all report categories.
     */
    List<String> getAllCategories();

    /**
     * Remove the given category and all reports stored in this category. If no category with the specified name exists,
     * nothing is done.
     */
    void removeCategory(String category);

    /**
     * Creates the given category, which is empty at the start. Reports can later be added by either calling
     * {@link #storeReport(String, Report)} or {@link #generateReport(String, String, String)} specifying the respective
     * category. If a category exists with the given name no operation is performed.
     */
    void createCategory(String category);
}

@@ -732,16 +732,56 @@
 Domain;%0A
+import org.openengsb.core.common.Event;%0A
 import o
@@ -3118,32 +3118,423 @@
 portException;%0A%0A
+    /**%0A     * Analyzes the context in which the given event was raised and adds all information stored in the event to any%0A     * active report data collection if the respective id of the event context is equal to the id of the idType%0A     * specified when the report data collection was initialized by calling %7B@link #collectData(IdType, String)%7D.%0A     */%0A    void processEvent(Event e);%0A%0A
     /**%0A     * G

Add process event method to report domain.