1 package jalview.ws2.actions.api;
3 import java.util.EnumSet;
6 import jalview.viewmodel.AlignmentViewport;
7 import jalview.ws.params.ArgumentI;
8 import jalview.ws2.api.CredentialType;
9 import jalview.ws2.api.Credentials;
10 import jalview.ws2.api.WebService;
13 * {@code Action} object represents an executable action that the web service
14 * can perform. Actions are factories for {@link TaskI} objects which are
15 * created by {@link #perform} method. Actions are instantiated by
16 * {@link WebServiceDiscovererI} from the service definition obtained from the
17 * server and are added to and provided by the {@link WebService}.
19 * Majority of web services will have a single action only, however multiple
20 * actions providing variation to job execution are possible e.g. align and
21 * realign actions of ClustalO service.
28 public interface ActionI<R>
31 * Get the web service containing this action.
33 * @return containing web service
35 WebService<? extends ActionI<R>> getWebService();
38 * Get the name of the action. Typically, it should be the same as the name of
46 * Get the tooltip for the action which contains extra details about the
49 * @return action tooltip
54 * Get the subcategory this action belongs to. Can be used to group or
55 * separate multiple actions.
57 * @return action subcategory
59 String getSubcategory();
62 * Get the minimum number of sequences this action requires to run or -1 for
63 * no minimum. Actions may still run if the requirement is not met, but may
64 * produce meaningless results.
66 * @return minimum required number of sequences
68 int getMinSequences();
71 * Get the maximum number of sequences this action requires to run or -1 for
72 * no maximum. Actions may still run if the requirement is not met, but may
73 * produce meaningless or incomplete results.
75 * @return maximum required number of sequences
77 int getMaxSequences();
80 * Return if this action allows protein sequences.
82 * @return {@code true} if protein sequences are allowed
84 boolean doAllowProtein();
87 * Return if this action allows nucleotide sequences.
89 * @return {@code true} if nucleotide sequences are allowed
91 boolean doAllowNucleotide();
94 * Get the set of credentials required to run the action.
96 * @return required credentials
98 EnumSet<CredentialType> getRequiredCredentials();
101 * Run the action, create and start a new task with provided viewport,
102 * arguments and credentials and attach the handler to the task. The
103 * implementations of this method are responsible for starting the task using
104 * execution method appropriate for the action class.
107 * current alignment viewport
109 * job parameters appropriate for the service
111 * optional user credentials
113 * event handler attached to the new task
114 * @return new running task
116 TaskI<R> perform(AlignmentViewport viewport, List<ArgumentI> args,
117 Credentials credentials, TaskEventListener<R> handler);
120 * Return if the action is currently active for the given viewport. Active
121 * actions refer to interactive services which are registered to run
122 * repeatedly on viewport changes. This method has no use for one-shot
123 * services and should always return {@code false} in that case.
126 * viewport being checked for interactive services
127 * @return if there are interactive services registered for viewport
129 boolean isActive(AlignmentViewport viewport);