001 /*
002 * Sonar, open source software quality management tool.
003 * Copyright (C) 2008-2011 SonarSource
004 * mailto:contact AT sonarsource DOT com
005 *
006 * Sonar is free software; you can redistribute it and/or
007 * modify it under the terms of the GNU Lesser General Public
008 * License as published by the Free Software Foundation; either
009 * version 3 of the License, or (at your option) any later version.
010 *
011 * Sonar is distributed in the hope that it will be useful,
012 * but WITHOUT ANY WARRANTY; without even the implied warranty of
013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014 * Lesser General Public License for more details.
015 *
016 * You should have received a copy of the GNU Lesser General Public
017 * License along with Sonar; if not, write to the Free Software
018 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
019 */
020 package org.sonar.core.plugin;
021
022 import org.sonar.api.database.BaseIdentifiable;
023
024 import javax.persistence.*;
025
026 /**
027 * @since 2.2
028 */
029 @Entity
030 @Table(name = "plugin_files")
031 public class JpaPluginFile extends BaseIdentifiable {
032
033 @ManyToOne(fetch = FetchType.EAGER)
034 @JoinColumn(name = "plugin_id")
035 private JpaPlugin plugin;
036
037 @Column(name = "filename", updatable = true, nullable = false, length = 100)
038 private String filename;
039
040 public JpaPluginFile() {
041 }
042
043 public JpaPluginFile(JpaPlugin plugin, String filename) {
044 this.plugin = plugin;
045 this.filename = filename;
046 }
047
048 public JpaPlugin getPlugin() {
049 return plugin;
050 }
051
052 public String getPluginKey() {
053 return plugin.getKey();
054 }
055
056 public void setPlugin(JpaPlugin plugin) {
057 this.plugin = plugin;
058 }
059
060 public String getFilename() {
061 return filename;
062 }
063
064 public void setFilename(String filename) {
065 this.filename = filename;
066 }
067
068 public String getPath() {
069 return new StringBuilder()
070 .append(plugin.getKey())
071 .append("/")
072 .append(filename).toString();
073 }
074 }