1 package com.indexdata.mkjsf.pazpar2.commands;
\r
3 import java.io.Serializable;
\r
5 import javax.enterprise.context.SessionScoped;
\r
6 import javax.inject.Named;
\r
8 import org.apache.log4j.Logger;
\r
10 import com.indexdata.mkjsf.pazpar2.Pz2Service;
\r
11 import com.indexdata.mkjsf.pazpar2.commands.sp.ServiceProxyCommands;
\r
12 import com.indexdata.mkjsf.utils.Utils;
\r
15 * Pazpar2Commands holds references to all Pazpar2 commands.
\r
17 * The Pazpar2Commands object itself is exposed to the UI as <code>pzreq</code>.
\r
20 * When the UI request a command it will be retrieved from the current state
\r
21 * through the state manager, so that the command can trigger a mutation of
\r
22 * the state if the user/UI modifies its parameters.
\r
26 * <li><code>pzreq.show</code> - will retrieve the show command for editing or execution
\r
27 * <li><code>pzreq.sp.auth</code> - will retrieve the Service Proxy extension command 'auth'
\r
30 * @author Niels Erik
\r
33 @SessionScoped @Named
\r
34 public class Pazpar2Commands implements Serializable {
\r
36 private static final long serialVersionUID = -5172466320351302413L;
\r
37 private static Logger logger = Logger.getLogger(Pazpar2Commands.class);
\r
39 public static final String INIT = "init";
\r
40 public static final String PING = "ping";
\r
41 public static final String SETTINGS = "settings";
\r
42 public static final String SEARCH = "search";
\r
43 public static final String STAT = "stat";
\r
44 public static final String SHOW = "show";
\r
45 public static final String RECORD = "record";
\r
46 public static final String TERMLIST = "termlist";
\r
47 public static final String BYTARGET = "bytarget";
\r
48 private ServiceProxyCommands sp = null;
\r
50 public Pazpar2Commands() {
\r
51 logger.info("Initializing Pazpar2Commands [" + Utils.objectId(this) + "]");
\r
55 * init command - referenced from UI as <code>pzreq.init</code>
\r
57 * @return init command from current state
\r
59 public InitCommand getInit() {
\r
60 return (InitCommand) (Pz2Service.get().getStateMgr().getCommand(INIT));
\r
64 * ping command - referenced from UI as <code>pzreq.ping</code>
\r
66 * @return ping command from current state
\r
68 public PingCommand getPing() {
\r
69 return (PingCommand) (Pz2Service.get().getStateMgr().getCommand(PING));
\r
73 * settings command - referenced from UI as <code>pzreq.settings</code>
\r
75 * @return settings command from current state
\r
77 public SettingsCommand getSettings() {
\r
78 return (SettingsCommand) (Pz2Service.get().getStateMgr().getCommand(SETTINGS));
\r
83 * @return search command from current state
\r
85 public SearchCommand getSearch() {
\r
86 return (SearchCommand) (Pz2Service.get().getStateMgr().getCommand(SEARCH));
\r
91 * @return stat command from current state
\r
93 public StatCommand getStat() {
\r
94 return (StatCommand) (Pz2Service.get().getStateMgr().getCommand(STAT));
\r
99 * @return show command from current state
\r
101 public ShowCommand getShow() {
\r
102 return (ShowCommand) (Pz2Service.get().getStateMgr().getCommand(SHOW));
\r
107 * @return record command from current state
\r
109 public RecordCommand getRecord() {
\r
110 return (RecordCommand) (Pz2Service.get().getStateMgr().getCommand(RECORD));
\r
115 * @return termlist command from current state
\r
117 public TermlistCommand getTermlist() {
\r
118 return (TermlistCommand) (Pz2Service.get().getStateMgr().getCommand(TERMLIST));
\r
123 * @return bytarget command from current state
\r
125 public BytargetCommand getBytarget() {
\r
126 return (BytargetCommand) (Pz2Service.get().getStateMgr().getCommand(BYTARGET));
\r
130 * Generically retrieves any command
\r
132 * @param name name of command to retrieve
\r
133 * @return command of the given type
\r
135 public Pazpar2Command getCommand(String name) {
\r
136 return Pz2Service.get().getStateMgr().getCommand(name);
\r
140 * Gets the object holding references to Service Proxy-only commands.
\r
143 public ServiceProxyCommands getSp() {
\r
145 sp = new ServiceProxyCommands(Pz2Service.get().getStateMgr());
\r