5610 |
15 Apr 11 |
nicklas |
1 |
/** |
5610 |
15 Apr 11 |
nicklas |
$Id$ |
5610 |
15 Apr 11 |
nicklas |
3 |
|
5610 |
15 Apr 11 |
nicklas |
Copyright (C) 2011 Nicklas Nordborg |
5610 |
15 Apr 11 |
nicklas |
5 |
|
5610 |
15 Apr 11 |
nicklas |
This file is part of BASE - BioArray Software Environment. |
5610 |
15 Apr 11 |
nicklas |
Available at http://base.thep.lu.se/ |
5610 |
15 Apr 11 |
nicklas |
8 |
|
5610 |
15 Apr 11 |
nicklas |
BASE is free software; you can redistribute it and/or |
5610 |
15 Apr 11 |
nicklas |
modify it under the terms of the GNU General Public License |
5610 |
15 Apr 11 |
nicklas |
as published by the Free Software Foundation; either version 3 |
5610 |
15 Apr 11 |
nicklas |
of the License, or (at your option) any later version. |
5610 |
15 Apr 11 |
nicklas |
13 |
|
5610 |
15 Apr 11 |
nicklas |
BASE is distributed in the hope that it will be useful, |
5610 |
15 Apr 11 |
nicklas |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
5610 |
15 Apr 11 |
nicklas |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
5610 |
15 Apr 11 |
nicklas |
GNU General Public License for more details. |
5610 |
15 Apr 11 |
nicklas |
18 |
|
5610 |
15 Apr 11 |
nicklas |
You should have received a copy of the GNU General Public License |
5610 |
15 Apr 11 |
nicklas |
along with BASE. If not, see <http://www.gnu.org/licenses/>. |
5610 |
15 Apr 11 |
nicklas |
21 |
*/ |
5610 |
15 Apr 11 |
nicklas |
22 |
package net.sf.basedb.util.extensions.xml; |
5610 |
15 Apr 11 |
nicklas |
23 |
|
5760 |
26 Sep 11 |
nicklas |
24 |
import java.util.Comparator; |
5610 |
15 Apr 11 |
nicklas |
25 |
import java.util.HashMap; |
5610 |
15 Apr 11 |
nicklas |
26 |
import java.util.Map; |
5610 |
15 Apr 11 |
nicklas |
27 |
|
5615 |
19 Apr 11 |
nicklas |
28 |
import net.sf.basedb.core.DbControl; |
5615 |
19 Apr 11 |
nicklas |
29 |
import net.sf.basedb.core.PluginDefinition; |
5610 |
15 Apr 11 |
nicklas |
30 |
import net.sf.basedb.core.plugin.About; |
5821 |
24 Oct 11 |
nicklas |
31 |
import net.sf.basedb.core.plugin.Plugin.MainType; |
5610 |
15 Apr 11 |
nicklas |
32 |
|
5610 |
15 Apr 11 |
nicklas |
33 |
/** |
5615 |
19 Apr 11 |
nicklas |
Object for holding information about a plug-in definition as |
5615 |
19 Apr 11 |
nicklas |
it is loaded from the extensions definition file. This class |
5615 |
19 Apr 11 |
nicklas |
has no effect on the actual installed plug-ins. To get |
5615 |
19 Apr 11 |
nicklas |
more information about what is installed and what is not, |
5615 |
19 Apr 11 |
nicklas |
call {@link PluginDefinition#checkInstallation(DbControl, java.util.Collection)}. |
5610 |
15 Apr 11 |
nicklas |
39 |
|
5610 |
15 Apr 11 |
nicklas |
@author Nicklas |
5610 |
15 Apr 11 |
nicklas |
@since 3.0 |
5610 |
15 Apr 11 |
nicklas |
@base.modified $Date$ |
5610 |
15 Apr 11 |
nicklas |
43 |
*/ |
5610 |
15 Apr 11 |
nicklas |
44 |
public class PluginInfo |
5610 |
15 Apr 11 |
nicklas |
45 |
{ |
5610 |
15 Apr 11 |
nicklas |
46 |
|
5760 |
26 Sep 11 |
nicklas |
47 |
|
5760 |
26 Sep 11 |
nicklas |
48 |
/** |
5760 |
26 Sep 11 |
nicklas |
Comparator that sort plug-ins according to their names. |
5760 |
26 Sep 11 |
nicklas |
If two names are equal, the sort is also done on the class |
5760 |
26 Sep 11 |
nicklas |
name. |
5760 |
26 Sep 11 |
nicklas |
52 |
*/ |
5760 |
26 Sep 11 |
nicklas |
53 |
public static final Comparator<PluginInfo> NAME_COMPARATOR = |
5760 |
26 Sep 11 |
nicklas |
54 |
new Comparator<PluginInfo>() |
5760 |
26 Sep 11 |
nicklas |
55 |
{ |
5760 |
26 Sep 11 |
nicklas |
56 |
@Override |
5760 |
26 Sep 11 |
nicklas |
57 |
public int compare(PluginInfo o1, PluginInfo o2) |
5760 |
26 Sep 11 |
nicklas |
58 |
{ |
5760 |
26 Sep 11 |
nicklas |
59 |
String name1 = o1.getAbout() == null ? null : o1.getAbout().getName(); |
5760 |
26 Sep 11 |
nicklas |
60 |
String name2 = o2.getAbout() == null ? null : o2.getAbout().getName(); |
5760 |
26 Sep 11 |
nicklas |
61 |
int result = name1 != null && name2 != null ? name1.compareTo(name2) : 0; |
5760 |
26 Sep 11 |
nicklas |
62 |
if (result == 0) result = o1.getClassName().compareTo(o2.getClassName()); |
5760 |
26 Sep 11 |
nicklas |
63 |
return result; |
5760 |
26 Sep 11 |
nicklas |
64 |
} |
5760 |
26 Sep 11 |
nicklas |
65 |
}; |
5760 |
26 Sep 11 |
nicklas |
66 |
|
5760 |
26 Sep 11 |
nicklas |
67 |
|
5610 |
15 Apr 11 |
nicklas |
68 |
private final String id; |
5610 |
15 Apr 11 |
nicklas |
69 |
private About about; |
5821 |
24 Oct 11 |
nicklas |
70 |
private MainType type; |
5610 |
15 Apr 11 |
nicklas |
71 |
private String className; |
5610 |
15 Apr 11 |
nicklas |
72 |
private Map<String, String> properties; |
5610 |
15 Apr 11 |
nicklas |
73 |
|
5615 |
19 Apr 11 |
nicklas |
74 |
private int internalId; |
5615 |
19 Apr 11 |
nicklas |
75 |
private boolean disabled; |
5775 |
30 Sep 11 |
nicklas |
76 |
private boolean notFound; |
5615 |
19 Apr 11 |
nicklas |
77 |
|
5615 |
19 Apr 11 |
nicklas |
78 |
/** |
5615 |
19 Apr 11 |
nicklas |
Create a new information object. |
5615 |
19 Apr 11 |
nicklas |
80 |
*/ |
5610 |
15 Apr 11 |
nicklas |
81 |
public PluginInfo(String id) |
5610 |
15 Apr 11 |
nicklas |
82 |
{ |
5610 |
15 Apr 11 |
nicklas |
83 |
this.id = id; |
5610 |
15 Apr 11 |
nicklas |
84 |
} |
5610 |
15 Apr 11 |
nicklas |
85 |
|
5615 |
19 Apr 11 |
nicklas |
86 |
/** |
5615 |
19 Apr 11 |
nicklas |
Get the class name of the plug-in. |
5615 |
19 Apr 11 |
nicklas |
88 |
*/ |
5615 |
19 Apr 11 |
nicklas |
89 |
public String getClassName() |
5615 |
19 Apr 11 |
nicklas |
90 |
{ |
5615 |
19 Apr 11 |
nicklas |
91 |
return className; |
5615 |
19 Apr 11 |
nicklas |
92 |
} |
5610 |
15 Apr 11 |
nicklas |
93 |
public void setClassName(String className) |
5610 |
15 Apr 11 |
nicklas |
94 |
{ |
5610 |
15 Apr 11 |
nicklas |
95 |
this.className = className; |
5610 |
15 Apr 11 |
nicklas |
96 |
} |
5610 |
15 Apr 11 |
nicklas |
97 |
|
5615 |
19 Apr 11 |
nicklas |
98 |
/** |
5615 |
19 Apr 11 |
nicklas |
Get information about the authors of the plug-in. |
5615 |
19 Apr 11 |
nicklas |
100 |
*/ |
5615 |
19 Apr 11 |
nicklas |
101 |
public About getAbout() |
5610 |
15 Apr 11 |
nicklas |
102 |
{ |
5615 |
19 Apr 11 |
nicklas |
103 |
return about; |
5610 |
15 Apr 11 |
nicklas |
104 |
} |
5610 |
15 Apr 11 |
nicklas |
105 |
public void setAbout(About about) |
5610 |
15 Apr 11 |
nicklas |
106 |
{ |
5610 |
15 Apr 11 |
nicklas |
107 |
this.about = about; |
5610 |
15 Apr 11 |
nicklas |
108 |
} |
5610 |
15 Apr 11 |
nicklas |
109 |
|
5821 |
24 Oct 11 |
nicklas |
110 |
/** |
5821 |
24 Oct 11 |
nicklas |
Get the main type of the plug-in. This information may |
5821 |
24 Oct 11 |
nicklas |
not be available for plug-ins that has not been installed. |
5821 |
24 Oct 11 |
nicklas |
113 |
*/ |
5821 |
24 Oct 11 |
nicklas |
114 |
public MainType getType() |
5821 |
24 Oct 11 |
nicklas |
115 |
{ |
5821 |
24 Oct 11 |
nicklas |
116 |
return type; |
5821 |
24 Oct 11 |
nicklas |
117 |
} |
5821 |
24 Oct 11 |
nicklas |
118 |
|
5821 |
24 Oct 11 |
nicklas |
119 |
public void setType(MainType type) |
5821 |
24 Oct 11 |
nicklas |
120 |
{ |
5821 |
24 Oct 11 |
nicklas |
121 |
this.type = type; |
5821 |
24 Oct 11 |
nicklas |
122 |
} |
5821 |
24 Oct 11 |
nicklas |
123 |
|
5610 |
15 Apr 11 |
nicklas |
124 |
public void setProperty(String name, String value) |
5610 |
15 Apr 11 |
nicklas |
125 |
{ |
5610 |
15 Apr 11 |
nicklas |
126 |
if (properties == null) properties = new HashMap<String, String>(); |
5610 |
15 Apr 11 |
nicklas |
127 |
properties.put(name, value); |
5610 |
15 Apr 11 |
nicklas |
128 |
} |
5610 |
15 Apr 11 |
nicklas |
129 |
|
5610 |
15 Apr 11 |
nicklas |
130 |
public String getProperty(String name) |
5610 |
15 Apr 11 |
nicklas |
131 |
{ |
5610 |
15 Apr 11 |
nicklas |
132 |
return properties == null ? null : properties.get(name); |
5610 |
15 Apr 11 |
nicklas |
133 |
} |
5610 |
15 Apr 11 |
nicklas |
134 |
|
5615 |
19 Apr 11 |
nicklas |
135 |
/** |
5615 |
19 Apr 11 |
nicklas |
Get the internal if of this plug-in. This information is |
5615 |
19 Apr 11 |
nicklas |
only available after {@link PluginDefinition#checkInstallation(DbControl, java.util.Collection)} |
5615 |
19 Apr 11 |
nicklas |
has been called. |
5615 |
19 Apr 11 |
nicklas |
139 |
*/ |
5615 |
19 Apr 11 |
nicklas |
140 |
public int getInternalId() |
5615 |
19 Apr 11 |
nicklas |
141 |
{ |
5615 |
19 Apr 11 |
nicklas |
142 |
return internalId; |
5615 |
19 Apr 11 |
nicklas |
143 |
} |
5610 |
15 Apr 11 |
nicklas |
144 |
|
5615 |
19 Apr 11 |
nicklas |
145 |
public void setInternalId(int internalId) |
5615 |
19 Apr 11 |
nicklas |
146 |
{ |
5615 |
19 Apr 11 |
nicklas |
147 |
this.internalId = internalId; |
5615 |
19 Apr 11 |
nicklas |
148 |
} |
5615 |
19 Apr 11 |
nicklas |
149 |
|
5615 |
19 Apr 11 |
nicklas |
150 |
/** |
5615 |
19 Apr 11 |
nicklas |
Is this plug-in installed or not? |
5615 |
19 Apr 11 |
nicklas |
152 |
*/ |
5615 |
19 Apr 11 |
nicklas |
153 |
public boolean isInstalled() |
5615 |
19 Apr 11 |
nicklas |
154 |
{ |
5615 |
19 Apr 11 |
nicklas |
155 |
return internalId != 0; |
5615 |
19 Apr 11 |
nicklas |
156 |
} |
5615 |
19 Apr 11 |
nicklas |
157 |
|
5615 |
19 Apr 11 |
nicklas |
158 |
/** |
5615 |
19 Apr 11 |
nicklas |
Is this plug-in enabled or not? |
5615 |
19 Apr 11 |
nicklas |
160 |
*/ |
5615 |
19 Apr 11 |
nicklas |
161 |
public boolean isDisabled() |
5615 |
19 Apr 11 |
nicklas |
162 |
{ |
5615 |
19 Apr 11 |
nicklas |
163 |
return disabled; |
5615 |
19 Apr 11 |
nicklas |
164 |
} |
5615 |
19 Apr 11 |
nicklas |
165 |
|
5615 |
19 Apr 11 |
nicklas |
166 |
public void setDisabled(boolean disabled) |
5615 |
19 Apr 11 |
nicklas |
167 |
{ |
5615 |
19 Apr 11 |
nicklas |
168 |
this.disabled = disabled; |
5615 |
19 Apr 11 |
nicklas |
169 |
} |
5615 |
19 Apr 11 |
nicklas |
170 |
|
5775 |
30 Sep 11 |
nicklas |
171 |
/** |
5775 |
30 Sep 11 |
nicklas |
Does this plug-in exists on the server or not? |
5775 |
30 Sep 11 |
nicklas |
173 |
*/ |
5775 |
30 Sep 11 |
nicklas |
174 |
public boolean isNotFound() |
5775 |
30 Sep 11 |
nicklas |
175 |
{ |
5775 |
30 Sep 11 |
nicklas |
176 |
return notFound; |
5775 |
30 Sep 11 |
nicklas |
177 |
} |
5775 |
30 Sep 11 |
nicklas |
178 |
|
5775 |
30 Sep 11 |
nicklas |
179 |
public void setNotFound(boolean notFound) |
5775 |
30 Sep 11 |
nicklas |
180 |
{ |
5775 |
30 Sep 11 |
nicklas |
181 |
this.notFound = notFound; |
5775 |
30 Sep 11 |
nicklas |
182 |
} |
5610 |
15 Apr 11 |
nicklas |
183 |
} |