buildframework/helium/sf/java/metadata/src/com/nokia/helium/metadata/ant/types/LogMetaDataInput.java
author wbernard
Fri, 13 Aug 2010 14:59:05 +0300
changeset 628 7c4a911dc066
parent 588 c7c26511138f
permissions -rw-r--r--
helium_11.0.0-e00f171ca185
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
     1
/*
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
     2
 * Copyright (c) 2007-2008 Nokia Corporation and/or its subsidiary(-ies).
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
     3
 * All rights reserved.
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
     4
 * This component and the accompanying materials are made available
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
     5
 * under the terms of the License "Eclipse Public License v1.0"
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
     6
 * which accompanies this distribution, and is available
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
     7
 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
     8
 *
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
     9
 * Initial Contributors:
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    10
 * Nokia Corporation - initial contribution.
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    11
 *
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    12
 * Contributors:
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    13
 *
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    14
 * Description:
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    15
 *
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    16
 */
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    17
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    18
package com.nokia.helium.metadata.ant.types;
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    19
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    20
import java.io.File;
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    21
import java.util.ArrayList;
628
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
    22
import java.util.Iterator;
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    23
import java.util.List;
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    24
import java.util.regex.Pattern;
628
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
    25
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
    26
import javax.persistence.EntityManager;
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
    27
import javax.persistence.EntityManagerFactory;
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
    28
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
    29
import org.apache.tools.ant.Project;
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
    30
import org.apache.tools.ant.Task;
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    31
import org.apache.tools.ant.types.DataType;
628
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
    32
import org.apache.tools.ant.types.Resource;
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
    33
import org.apache.tools.ant.types.ResourceCollection;
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
    34
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
    35
import com.nokia.helium.metadata.MetaDataInput;
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
    36
import com.nokia.helium.metadata.MetadataException;
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
    37
import com.nokia.helium.metadata.model.metadata.LogFile;
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
    38
import com.nokia.helium.metadata.model.metadata.LogFileDAO;
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    39
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    40
/**
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    41
 * Abstract base class to provide common functionality for the log parsing.
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    42
 */
628
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
    43
public abstract class LogMetaDataInput extends DataType implements MetaDataInput {
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    44
    
628
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
    45
    private List<ResourceCollection> resourceCollections = new ArrayList<ResourceCollection>();
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
    46
    private Task task;
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
    47
    private List<MetaDataFilterSet> metadataFilterSets = new ArrayList<MetaDataFilterSet>();
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
    48
    private List<MetaDataFilter> completeFilterList;
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    49
    
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    50
    /**
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    51
     * Adds the fileset (list of input log files to be processed).
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    52
     *  @param fileSet fileset to be added
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    53
     * 
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    54
     */
628
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
    55
    public void add(ResourceCollection resourceCollection) {
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
    56
        resourceCollections.add(resourceCollection);
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    57
    }   
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    58
    
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    59
    /**
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    60
     * Adds the fileset (list of input log files to be processed).
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    61
     *  @param fileSet fileset to be added
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    62
     * 
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    63
     */
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    64
    public void add(MetaDataFilterSet metadataFilterSet) {
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    65
        metadataFilterSets.add(metadataFilterSet);
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    66
    } 
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    67
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    68
    /**
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    69
     * Helper function called by ant to create the new filter
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    70
     */
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    71
    public MetaDataFilterSet createMetaDataFilterSet() {
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    72
        MetaDataFilterSet filterSet =  new MetaDataFilterSet();
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    73
        add(filterSet);
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    74
        return filterSet;
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    75
    }
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    76
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    77
    /**
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    78
     * Helper function to return all the filters associated with this metadata input
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    79
     * @return all the filters merged based on the order of definition.
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    80
     */
628
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
    81
    private synchronized List<MetaDataFilter> getMetaDataFilters() {
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
    82
        if (completeFilterList == null) {
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
    83
            completeFilterList = new ArrayList<MetaDataFilter>();
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
    84
            for (MetaDataFilterSet filterSet : metadataFilterSets) {
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
    85
                completeFilterList.addAll(filterSet.getAllFilters());
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    86
            }
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    87
        }
628
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
    88
        return completeFilterList;
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    89
    }
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    90
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    91
    /**
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    92
     * Returns the severity matches for the log text
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    93
     * @param log text for which the severity needs to be identified.
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    94
     * @return the severity of the input text
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    95
     */
628
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
    96
    protected SeverityEnum.Severity getSeverity(String logText) {
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
    97
        for (MetaDataFilter filter : getMetaDataFilters()) {
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    98
            Pattern pattern = filter.getPattern();
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    99
            if ((pattern.matcher(logText)).matches()) {
628
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   100
                return filter.getSeverity();
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   101
            }
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   102
        }
628
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   103
        return SeverityEnum.Severity.NONE;
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   104
    }
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   105
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   106
    /**
628
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   107
     * Logging through the Ant task
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   108
     */
628
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   109
    public void log(String message) {
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   110
        log(message, Project.MSG_INFO);    
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   111
    }
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   112
    
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   113
    /**
628
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   114
     * Logging through the Ant task
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   115
     */
628
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   116
    public void log(String message, int level) {
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   117
        if (task != null) {
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   118
            task.log(message, level);
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   119
        } else {
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   120
            getProject().log(message, level);
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   121
        }
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   122
    }
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   123
    /**
628
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   124
     * Get the LogFile instance for the file log.
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   125
     * @param entityManager the entityManager to do the query.
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   126
     * @param file the log file locations
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   127
     * @return the LogFile entry for the file log. 
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   128
     */
628
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   129
    protected LogFile getLogFile(EntityManager entityManager, File file) {
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   130
        // Creating the filename
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   131
        LogFileDAO lfdao = new LogFileDAO();
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   132
        lfdao.setEntityManager(entityManager);
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   133
        LogFile logFile = lfdao.findByLogName(file);
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   134
        if (logFile == null) {
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   135
            log("Creating a logfile entry.", Project.MSG_DEBUG);
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   136
            logFile = new LogFile();
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   137
            logFile.setPath(file.getAbsolutePath());
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   138
            entityManager.getTransaction().begin();
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   139
            entityManager.persist(logFile);
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   140
            entityManager.getTransaction().commit();
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   141
        }
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   142
        return logFile;
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   143
    }
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   144
    
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   145
    /**
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   146
     * {@inheritDoc}
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   147
     * Implements default behavior, for each log file the reference inside
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   148
     * the database will first be removed, and then data will be collected. 
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   149
     */
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   150
    @SuppressWarnings("unchecked")
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   151
    public void extract(Task task, EntityManagerFactory factory)
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   152
        throws MetadataException {
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   153
        this.task = task;
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   154
        try {
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   155
            for (ResourceCollection resourceCollection : resourceCollections) {
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   156
                Iterator<Resource> ri = (Iterator<Resource>)resourceCollection.iterator();
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   157
                while (ri.hasNext()) {
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   158
                    File file = new File(ri.next().toString());
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   159
                    remove(factory, file);
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   160
                    log("Extracting data from " + file);
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   161
                    extract(factory, file);
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   162
                }
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   163
            }
628
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   164
        } finally {
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   165
            this.task = null;
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   166
        }
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   167
    }
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   168
    
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   169
    /**
628
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   170
     * Removing a file log data from the database (if any).
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   171
     * @param factory
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   172
     * @param file
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   173
     * @throws MetadataException
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   174
     */
628
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   175
    public void remove(EntityManagerFactory factory, File file) throws MetadataException {
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   176
        EntityManager entityManager = factory.createEntityManager();
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   177
        try {
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   178
            LogFileDAO logFileDAO = new LogFileDAO();
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   179
            logFileDAO.setEntityManager(entityManager);
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   180
            LogFile logFile = logFileDAO.findByLogName(file);
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   181
            if (logFile != null) {
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   182
                log("Removing log from database: " + file.getAbsolutePath());
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   183
                entityManager.getTransaction().begin();
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   184
                logFileDAO.remove(logFile);
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   185
                entityManager.getTransaction().commit();
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   186
            }
628
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   187
        } finally {
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   188
            entityManager.close();
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   189
        }
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   190
    }
628
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   191
    
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   192
    /**
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   193
     * Extracting the data from 
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   194
     * @param factory
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   195
     * @param file
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   196
     * @throws MetadataException
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   197
     */
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   198
    public abstract void extract(EntityManagerFactory factory, File file) throws MetadataException;
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   199
}