4740 |
05 Feb 09 |
nicklas |
1 |
/** |
4740 |
05 Feb 09 |
nicklas |
$Id$ |
4740 |
05 Feb 09 |
nicklas |
3 |
|
4740 |
05 Feb 09 |
nicklas |
Copyright (C) 2009 Nicklas Nordborg |
4740 |
05 Feb 09 |
nicklas |
5 |
|
4740 |
05 Feb 09 |
nicklas |
This file is part of BASE - BioArray Software Environment. |
4740 |
05 Feb 09 |
nicklas |
Available at http://base.thep.lu.se/ |
4740 |
05 Feb 09 |
nicklas |
8 |
|
4740 |
05 Feb 09 |
nicklas |
BASE is free software; you can redistribute it and/or |
4740 |
05 Feb 09 |
nicklas |
modify it under the terms of the GNU General Public License |
4740 |
05 Feb 09 |
nicklas |
as published by the Free Software Foundation; either version 3 |
4740 |
05 Feb 09 |
nicklas |
of the License, or (at your option) any later version. |
4740 |
05 Feb 09 |
nicklas |
13 |
|
4740 |
05 Feb 09 |
nicklas |
BASE is distributed in the hope that it will be useful, |
4740 |
05 Feb 09 |
nicklas |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
4740 |
05 Feb 09 |
nicklas |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
4740 |
05 Feb 09 |
nicklas |
GNU General Public License for more details. |
4740 |
05 Feb 09 |
nicklas |
18 |
|
4740 |
05 Feb 09 |
nicklas |
You should have received a copy of the GNU General Public License |
4740 |
05 Feb 09 |
nicklas |
along with BASE. If not, see <http://www.gnu.org/licenses/>. |
4740 |
05 Feb 09 |
nicklas |
21 |
*/ |
4740 |
05 Feb 09 |
nicklas |
22 |
package net.sf.basedb.util.overview.node; |
4740 |
05 Feb 09 |
nicklas |
23 |
|
4740 |
05 Feb 09 |
nicklas |
24 |
import net.sf.basedb.core.FileSetMember; |
4740 |
05 Feb 09 |
nicklas |
25 |
import net.sf.basedb.core.PermissionDeniedException; |
4740 |
05 Feb 09 |
nicklas |
26 |
import net.sf.basedb.util.overview.Node; |
4740 |
05 Feb 09 |
nicklas |
27 |
|
4740 |
05 Feb 09 |
nicklas |
28 |
/** |
4740 |
05 Feb 09 |
nicklas |
Since a FileSetMember isn't Nameable we construct the name |
4740 |
05 Feb 09 |
nicklas |
by combining the name of the file type and the name of the |
4740 |
05 Feb 09 |
nicklas |
file. |
4740 |
05 Feb 09 |
nicklas |
32 |
|
4740 |
05 Feb 09 |
nicklas |
@author Nicklas |
4740 |
05 Feb 09 |
nicklas |
@version 2.10 |
4740 |
05 Feb 09 |
nicklas |
@base.modified $Date$ |
4740 |
05 Feb 09 |
nicklas |
36 |
*/ |
4740 |
05 Feb 09 |
nicklas |
37 |
public class FileSetMemberNameGenerator |
4740 |
05 Feb 09 |
nicklas |
38 |
implements NodeNameGenerator<FileSetMember> |
4740 |
05 Feb 09 |
nicklas |
39 |
{ |
4740 |
05 Feb 09 |
nicklas |
40 |
public FileSetMemberNameGenerator() |
4740 |
05 Feb 09 |
nicklas |
41 |
{} |
4740 |
05 Feb 09 |
nicklas |
42 |
|
4740 |
05 Feb 09 |
nicklas |
43 |
/* |
4740 |
05 Feb 09 |
nicklas |
From the NodeNameGenerator interface |
4740 |
05 Feb 09 |
nicklas |
45 |
------------------------------------ |
4740 |
05 Feb 09 |
nicklas |
46 |
*/ |
4740 |
05 Feb 09 |
nicklas |
47 |
@Override |
4740 |
05 Feb 09 |
nicklas |
48 |
public String getNodeName(FileSetMember item, Node parentNode) |
4740 |
05 Feb 09 |
nicklas |
49 |
{ |
4740 |
05 Feb 09 |
nicklas |
50 |
return "member." + item.getId(); |
4740 |
05 Feb 09 |
nicklas |
51 |
} |
4740 |
05 Feb 09 |
nicklas |
52 |
|
4740 |
05 Feb 09 |
nicklas |
53 |
@Override |
4740 |
05 Feb 09 |
nicklas |
54 |
public String getNodeTitle(FileSetMember item, Node parentNode) |
4740 |
05 Feb 09 |
nicklas |
55 |
{ |
4740 |
05 Feb 09 |
nicklas |
56 |
String prefix = "Data file"; |
4740 |
05 Feb 09 |
nicklas |
57 |
String name = "denied"; |
4740 |
05 Feb 09 |
nicklas |
58 |
try |
4740 |
05 Feb 09 |
nicklas |
59 |
{ |
4740 |
05 Feb 09 |
nicklas |
60 |
prefix = item.getDataFileType().getName(); |
4740 |
05 Feb 09 |
nicklas |
61 |
} |
4740 |
05 Feb 09 |
nicklas |
62 |
catch (PermissionDeniedException ex) |
4740 |
05 Feb 09 |
nicklas |
63 |
{} |
4740 |
05 Feb 09 |
nicklas |
64 |
try |
4740 |
05 Feb 09 |
nicklas |
65 |
{ |
4740 |
05 Feb 09 |
nicklas |
66 |
name = item.getFile().getName(); |
4740 |
05 Feb 09 |
nicklas |
67 |
} |
4740 |
05 Feb 09 |
nicklas |
68 |
catch (PermissionDeniedException ex) |
4740 |
05 Feb 09 |
nicklas |
69 |
{} |
4740 |
05 Feb 09 |
nicklas |
70 |
return prefix + ": " + name; |
4740 |
05 Feb 09 |
nicklas |
71 |
} |
4740 |
05 Feb 09 |
nicklas |
72 |
|
4740 |
05 Feb 09 |
nicklas |
73 |
@Override |
4740 |
05 Feb 09 |
nicklas |
74 |
public String getDeniedNodeName(Node parentNode) |
4740 |
05 Feb 09 |
nicklas |
75 |
{ |
4740 |
05 Feb 09 |
nicklas |
76 |
return "member"; |
4740 |
05 Feb 09 |
nicklas |
77 |
} |
4740 |
05 Feb 09 |
nicklas |
78 |
|
4740 |
05 Feb 09 |
nicklas |
79 |
@Override |
4740 |
05 Feb 09 |
nicklas |
80 |
public String getDeniedNodeTitle(Node parentNode) |
4740 |
05 Feb 09 |
nicklas |
81 |
{ |
4740 |
05 Feb 09 |
nicklas |
82 |
return "Data file: denied"; |
4740 |
05 Feb 09 |
nicklas |
83 |
} |
4740 |
05 Feb 09 |
nicklas |
84 |
|
4740 |
05 Feb 09 |
nicklas |
85 |
@Override |
4740 |
05 Feb 09 |
nicklas |
86 |
public String getMissingNodeName(Node parentNode) |
4740 |
05 Feb 09 |
nicklas |
87 |
{ |
4740 |
05 Feb 09 |
nicklas |
88 |
return "member"; |
4740 |
05 Feb 09 |
nicklas |
89 |
} |
4740 |
05 Feb 09 |
nicklas |
90 |
|
4740 |
05 Feb 09 |
nicklas |
91 |
@Override |
4740 |
05 Feb 09 |
nicklas |
92 |
public String getMissingNodeTitle(Node parentNode) |
4740 |
05 Feb 09 |
nicklas |
93 |
{ |
4740 |
05 Feb 09 |
nicklas |
94 |
return "Data file: missing"; |
4740 |
05 Feb 09 |
nicklas |
95 |
} |
4740 |
05 Feb 09 |
nicklas |
96 |
|
4740 |
05 Feb 09 |
nicklas |
97 |
// ------------------------------------------------ |
4740 |
05 Feb 09 |
nicklas |
98 |
|
4740 |
05 Feb 09 |
nicklas |
99 |
} |