buildframework/helium/sf/java/metadata/src/com/nokia/helium/metadata/db/ORMMetadataDB.java
changeset 587 85df38eb4012
child 588 c7c26511138f
equal deleted inserted replaced
217:0f5e3a7fb6af 587:85df38eb4012
       
     1 /*
       
     2  * Copyright (c) 2007-2008 Nokia Corporation and/or its subsidiary(-ies).
       
     3  * All rights reserved.
       
     4  * This component and the accompanying materials are made available
       
     5  * under the terms of the License "Eclipse Public License v1.0"
       
     6  * which accompanies this distribution, and is available
       
     7  * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8  *
       
     9  * Initial Contributors:
       
    10  * Nokia Corporation - initial contribution.
       
    11  *
       
    12  * Contributors:
       
    13  *
       
    14  * Description:
       
    15  *
       
    16  */
       
    17 
       
    18 package com.nokia.helium.metadata.db;
       
    19 
       
    20 
       
    21 import com.nokia.helium.jpa.entity.metadata.MetadataUtil;
       
    22 import java.io.File;
       
    23 import org.apache.log4j.Logger;
       
    24 import com.nokia.helium.jpa.entity.metadata.Metadata;
       
    25 
       
    26 /**
       
    27  * Database class to write the contents to the database.
       
    28  */
       
    29 public class ORMMetadataDB {
       
    30 
       
    31     private static Logger log = Logger.getLogger(ORMMetadataDB.class);
       
    32 
       
    33     private String dbPath;
       
    34     
       
    35     public ORMMetadataDB(String databasePath) {
       
    36         log.debug("initializing ORMMetadataDB: dbPath: " + databasePath);
       
    37         // Lower case the filename because of SMB share.
       
    38         File actualPath = new File(databasePath);
       
    39         String fileName = actualPath.getName();
       
    40         dbPath = new File(actualPath.getParent(), fileName.toLowerCase()).getPath();
       
    41         MetadataUtil.initializeORM(dbPath);
       
    42     }
       
    43 
       
    44     public void addLogEntry(Metadata.LogEntry entry) {
       
    45         MetadataUtil.addEntry(dbPath, entry);
       
    46     }
       
    47     
       
    48     /**
       
    49      * Add an execution time record to the database for current log.
       
    50      * @param time
       
    51      */
       
    52     public void addExecutionTime(String logPath, int time) {
       
    53         MetadataUtil.addEntry(dbPath, logPath, time);
       
    54     }
       
    55 
       
    56     public void removeEntries(String logPath) {
       
    57         MetadataUtil.removeEntries(dbPath, logPath);
       
    58     }
       
    59 
       
    60     public void finalizeMetadata(String logPath) {
       
    61         MetadataUtil.finalizeMetadata(logPath);
       
    62     }
       
    63 
       
    64     public void finalizeDB() {
       
    65         MetadataUtil.finalizeORM(dbPath);
       
    66     }
       
    67 
       
    68 }