buildframework/helium/sf/java/metadata/src/com/nokia/helium/metadata/model/metadata/MetadataEntry.java
changeset 628 7c4a911dc066
equal deleted inserted replaced
588:c7c26511138f 628:7c4a911dc066
       
     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.model.metadata;
       
    19 
       
    20 import javax.persistence.Basic;
       
    21 import javax.persistence.CascadeType;
       
    22 import javax.persistence.Column;
       
    23 import javax.persistence.Entity;
       
    24 import javax.persistence.GeneratedValue;
       
    25 import javax.persistence.GenerationType;
       
    26 import javax.persistence.Id;
       
    27 import javax.persistence.JoinColumn;
       
    28 import javax.persistence.ManyToOne;
       
    29 
       
    30 
       
    31 
       
    32 /**
       
    33  * Entity class which stores the the mapping of all the other tables
       
    34  * along with actual error information.
       
    35  */
       
    36 @SuppressWarnings("PMD.UnusedPrivateField")
       
    37 @Entity
       
    38 public class MetadataEntry {
       
    39 
       
    40     /// Maximum size of the text we store in the metadata
       
    41     public static final int TEXT_LENGTH = 500;
       
    42 
       
    43     @Id
       
    44     @Column(name = "ENTRY_ID")
       
    45     @GeneratedValue(strategy = GenerationType.SEQUENCE)
       
    46     private int id;
       
    47 
       
    48     @Basic
       
    49     private int lineNumber;
       
    50 
       
    51     @Basic
       
    52     @Column(length = TEXT_LENGTH)
       
    53     private String text;
       
    54 
       
    55     @Basic
       
    56     @Column(name = "COMPONENT_ID", insertable = false, updatable = false)
       
    57     private int componentId;
       
    58 
       
    59     @Basic
       
    60     @Column(name = "SEVERITY_ID", insertable = false, updatable = false)
       
    61     private int severityId;
       
    62 
       
    63     @ManyToOne(cascade = CascadeType.REMOVE, optional = false)
       
    64     @JoinColumn(name = "COMPONENT_ID", referencedColumnName = "COMPONENT_ID")
       
    65     private Component component;
       
    66 
       
    67     @ManyToOne(cascade = CascadeType.REFRESH, optional = false)
       
    68     @JoinColumn(name = "SEVERITY_ID", referencedColumnName = "SEVERITY_ID")
       
    69     private Severity severity;
       
    70 
       
    71     @Column(name = "LOGFILE_ID", insertable = false, updatable = false)
       
    72     private int logFileId;
       
    73     
       
    74     @ManyToOne(cascade = CascadeType.REMOVE, optional = false)
       
    75     @JoinColumn(name = "LOGFILE_ID", referencedColumnName = "LOGFILE_ID")
       
    76     private LogFile logFile;
       
    77     
       
    78     /**
       
    79      * Helper function to get the identifier of the metadata record
       
    80      * which is being stored in the database.
       
    81      *  @return id - identifier for the log record.
       
    82      */
       
    83     public int getId() {
       
    84         return id;
       
    85     }
       
    86 
       
    87     /**
       
    88      * Helper function to set the logfile associated to the metadata entry.
       
    89      *  @param LogFile object associated to this entry.
       
    90      */
       
    91     public void setLogFile(LogFile file) {
       
    92         logFile = file;
       
    93     }
       
    94 
       
    95     /**
       
    96      * Helper function to set the severity object associated to this entry.
       
    97      *  @param severity object associated to this entry.
       
    98      */
       
    99     public void setSeverity(Severity severity) {
       
   100         this.severity = severity;
       
   101     }
       
   102 
       
   103     /**
       
   104      * Helper function to set the component object associated to this entry.
       
   105      *  @param component object associated to this entry.
       
   106      */
       
   107     public void setComponent(Component component) {
       
   108         this.component = component;
       
   109     }
       
   110 
       
   111     /**
       
   112      * Helper function to set the identifier for this entry.
       
   113      *  @param id identifier to be set for this entry.
       
   114      */
       
   115     public void setId(int id) {
       
   116         this.id = id;
       
   117     }
       
   118 
       
   119     /**
       
   120      * Helper function to set the log text associated to this entry.
       
   121      *  @param txt - text representing this log entry.
       
   122      */
       
   123     public void setText(String text) {
       
   124         // Let's trunk ourselves the text we are passing to the 
       
   125         // storage.
       
   126         if (text.length() > TEXT_LENGTH) {
       
   127             text = text.substring(0, TEXT_LENGTH);
       
   128         }
       
   129         this.text = text;
       
   130     }
       
   131 
       
   132     /**
       
   133      * Helper function to set the line number for this entry.
       
   134      *  @param line number associated to this entry.
       
   135      */
       
   136     public void setLineNumber(int lineNumber) {
       
   137         this.lineNumber = lineNumber;
       
   138     }
       
   139 
       
   140     /**
       
   141      * Helper function to get the text message associated to this entry.
       
   142      *  @return text message of this entry.
       
   143      */
       
   144     public String getText() {
       
   145         return text;
       
   146     }
       
   147 
       
   148     /**
       
   149      * Helper function to get line number of the error message associated
       
   150      * with this object.
       
   151      *  @return line number associated to this entry.
       
   152      */
       
   153     public int getLineNumber() {
       
   154         return lineNumber;
       
   155     }
       
   156 
       
   157     /**
       
   158      * Helper function to get the log path id of this entry.
       
   159      *  @return log path id associated to this entry.
       
   160      */
       
   161     public int getLogFileId() {
       
   162         return logFileId;
       
   163     }
       
   164 
       
   165     /**
       
   166      * Helper function to set the logpath id associated to this entry.
       
   167      *  @param id logpath id of this entry.
       
   168      */
       
   169     public void setLogFileId(int id) {
       
   170         logFileId = id;
       
   171     }
       
   172 
       
   173     /**
       
   174      * Helper function to set the severity id associated to this entry.
       
   175      *  @param severityId severity id of this entry.
       
   176      */
       
   177     public void setSeverityId(int severityId) {
       
   178         this.severityId = severityId;
       
   179     }
       
   180 
       
   181     /**
       
   182      * Helper function to set the component id associated to this entry.
       
   183      *  @param componentId component id of this entry.
       
   184      */
       
   185     public void setComponentId(int componentId) {
       
   186         this.componentId = componentId;
       
   187     }
       
   188 }