001 /*
002 * This file is part of McIDAS-V
003 *
004 * Copyright 2007-2013
005 * Space Science and Engineering Center (SSEC)
006 * University of Wisconsin - Madison
007 * 1225 W. Dayton Street, Madison, WI 53706, USA
008 * https://www.ssec.wisc.edu/mcidas
009 *
010 * All Rights Reserved
011 *
012 * McIDAS-V is built on Unidata's IDV and SSEC's VisAD libraries, and
013 * some McIDAS-V source code is based on IDV and VisAD source code.
014 *
015 * McIDAS-V is free software; you can redistribute it and/or modify
016 * it under the terms of the GNU Lesser Public License as published by
017 * the Free Software Foundation; either version 3 of the License, or
018 * (at your option) any later version.
019 *
020 * McIDAS-V is distributed in the hope that it will be useful,
021 * but WITHOUT ANY WARRANTY; without even the implied warranty of
022 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
023 * GNU Lesser Public License for more details.
024 *
025 * You should have received a copy of the GNU Lesser Public License
026 * along with this program. If not, see http://www.gnu.org/licenses.
027 */
028
029 package edu.wisc.ssec.mcidasv.servermanager;
030
031
032 /**
033 * Represents a source of ADDE data. An ADDE entry may describe a dataset on
034 * remote servers or the user's own machine.
035 */
036 public interface AddeEntry {
037
038 /** Represents the possible actions that an ADDE editor can perform. */
039 // @PersistableEnum
040 public enum EditorAction {
041 /** Created a new entry; hasn't been verified. */
042 ADDED,
043
044 /** Canceled out of creating or editing an entry. */
045 CANCELLED,
046
047 /** Verified the contents of the editor GUI. */
048 VERIFIED,
049
050 /** Created a new, verified entry. */
051 ADDED_VERIFIED,
052
053 /** Updated an existing entry without verifying changes. */
054 EDITED,
055
056 /** Updated an entry and verified the changes. */
057 EDITED_VERIFIED,
058
059 /** Editor GUI performed some {@literal "invalid"} action. */
060 INVALID;
061 };
062
063 /** Type of chooser this should appear under. */
064
065 public enum EntryType {
066 /** {@link edu.wisc.ssec.mcidasv.chooser.adde.AddeImageChooser} */
067 IMAGE,
068
069 /** {@link edu.wisc.ssec.mcidasv.chooser.adde.AddePointDataChooser} */
070 POINT,
071
072 /** */
073 GRID,
074
075 /** {@link edu.wisc.ssec.mcidasv.chooser.adde.AddeFrontChooser} */
076 TEXT,
077
078 /** */
079 NAV,
080
081 /** {@link edu.wisc.ssec.mcidasv.chooser.adde.AddeRadarChooser} */
082 RADAR,
083
084 /** */
085 UNKNOWN,
086
087 /** */
088 INVALID;
089
090 /**
091 * Attempts to convert a given {@code String} value into a valid
092 * {@code EntryType}.
093 *
094 * @param str {@code String} to convert. Should not be {@code null}.
095 *
096 * @return {@code EntryType} of the value specified in {@code str}.
097 */
098 public static EntryType fromStr(final String str) {
099 return EntryType.valueOf(str);
100 }
101
102 /**
103 * Attempts to convert a given {@code EntryType} into its
104 * {@code String} representation.
105 *
106 * @param type {@code EntryType} constant; should not be {@code null}.
107 *
108 * @return {@code String} representation of {@code type}.
109 */
110 public static String toStr(final EntryType type) {
111 return type.name();
112 }
113 };
114
115 /** Sort of a {@literal "misc"} status field... */
116 public enum EntryValidity {
117 /** Entry has been verified by connecting to the server. */
118 VERIFIED,
119
120 /** Unknown whether or not this entry actually works. */
121 UNVERIFIED,
122
123 /** Entry is being checked for validity. */
124 VALIDATING,
125
126 /**
127 * User has elected to remove this entry. This is an unfortunate
128 * {@literal "special case"}, as we can't simply remove these entries
129 * from a list! Say the user import entries from a remote MCTABLE file
130 * and later deleted some of the imported entries. Fine, good! But
131 * what should happen if the user hears that new servers have been
132 * added to that same MCTABLE file? The entries that the user has
133 * deleted <i>locally</i> should not reappear, right?
134 */
135 DELETED,
136
137 /** Entry is invalid in some way. */
138 INVALID;
139
140 public static EntryValidity fromStr(final String str) {
141 return EntryValidity.valueOf(str);
142 }
143 public static String toStr(final EntryValidity validity) {
144 return validity.name();
145 }
146 };
147
148 /** Where did this entry come from? */
149 public enum EntrySource {
150 /** Entry originated from McIDAS-V. */
151 SYSTEM,
152
153 /** Entry was imported from a MCTABLE file. */
154 MCTABLE,
155
156 /** Entry was added by the user.*/
157 USER,
158
159 /**
160 * Represents an {@literal "invalid"} {@code EntrySource}. Useful for
161 * invalid entry objects ({@link RemoteAddeEntry#INVALID_ENTRY} and
162 * {@link LocalAddeEntry#INVALID_ENTRY}).
163 */
164 INVALID;
165
166 public static EntrySource fromStr(final String str) {
167 return EntrySource.valueOf(str);
168 }
169 public static String toStr(final EntrySource source) {
170 return source.name();
171 }
172 };
173
174 /**
175 * Has the user elected to disable this entry from appearing in its
176 * relevant chooser?
177 */
178 public enum EntryStatus {
179 /** Entry is valid and toggled on. */
180 ENABLED,
181
182 /** Entry is valid and toggled off. */
183 DISABLED,
184
185 /** Something is wrong with this entry. */
186 INVALID;
187
188 public static EntryStatus fromStr(final String str) {
189 return EntryStatus.valueOf(str);
190 }
191
192 public static String toStr(final EntryType type) {
193 return type.name();
194 }
195 };
196
197 /** Represents the {@literal "no accounting"} entries. */
198 public static final AddeAccount DEFAULT_ACCOUNT =
199 new AddeAccount("idv", "0");
200
201 /**
202 * Address of the server associated with the current entry.
203 * {@link LocalAddeEntry}s will return {@code localhost}.
204 */
205 public String getAddress();
206
207 /**
208 * Dataset/group located on the server.
209 */
210 public String getGroup();
211
212 // TODO(jon): what part of a resolv.srv does this represent?
213 /**
214 * Name associated with this entry.
215 *
216 * @return Name associated with this entry.
217 */
218 public String getName();
219
220 /**
221 * Accounting information associated with the current entry. If the server
222 * does not require accounting information, this method returns
223 * {@link #DEFAULT_ACCOUNT}.
224 *
225 * @return ADDE account object.
226 */
227 public AddeAccount getAccount();
228
229 /**
230 * Type of chooser this entry should appear under.
231 *
232 * @return The {@literal "type"} of data associated with this entry.
233 */
234 public EntryType getEntryType();
235
236 /**
237 * Does this entry represent a {@literal "valid"} ADDE server.
238 *
239 * @return Whether or not this entry has been validated.
240 */
241 public EntryValidity getEntryValidity();
242
243 /**
244 * Source that specified this entry. For example; allows you to
245 * distinguish {@literal "system"} entries (which cannot be removed, only
246 * disabled) from entries created by the user (full control).
247 */
248 public EntrySource getEntrySource();
249
250 /**
251 * GUI status of the entry. Differs from {@link EntryValidity} in that
252 * {@code EntryStatus} controls this entry showing up in a chooser and has
253 * nothing to do with whether or not the entry is a valid ADDE server.
254 */
255 public EntryStatus getEntryStatus();
256
257 /**
258 * Handy {@code String} representation of this ADDE entry. Currently looks
259 * like {@code ADDRESS/GROUP}, but this is subject to change.
260 */
261 public String getEntryText();
262
263 // TODO(jon): should this be removed? this makes the entries mutable!
264 public void setEntryStatus(final EntryStatus newStatus);
265
266 // TODO(jon): integrate with parameter sets one fine day?
267 public String getEntryAlias();
268
269 // TODO(jon): should this be removed? this makes the entries mutable!
270 public void setEntryAlias(final String newAlias);
271
272 /** */
273 public boolean isEntryTemporary();
274
275 /**
276 * Currently used as a identifier for convenient storage by the server
277 * manager.
278 */
279 public String asStringId();
280
281 /**
282 * String representation of this entry.
283 */
284 public String toString();
285 }