com.indexdata.mkjsf.pazpar2.commands
Class Pazpar2Command

java.lang.Object
  extended by com.indexdata.mkjsf.pazpar2.commands.Pazpar2Command
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
AuthCommand, BytargetCommand, CategoriesCommand, InitCommand, PingCommand, RecordCommand, SearchCommand, SettingsCommand, ShowCommand, StatCommand, TermlistCommand

public abstract class Pazpar2Command
extends Object
implements Serializable

Represents a generic Pazpar2 or Service Proxy command with all its current parameters, and has methods for executing the command against the currently selected Pazpar2 service

Being an abstract class it only has generic methods for getting and setting parameters. Implementing classes are supposed to create named getters and setters for convenient access to parameters from the UI.

Parameters can be set with or without notifying the state manager.

Note: Internally the application has to be able to set parameters without state changes - for instance to avoid eternal feedback when copying parameter from one state to the next. A setting from the UI should spawn a new search state however.

Author:
Niels Erik
See Also:
Serialized Form

Field Summary
protected  String name
           
protected  Map<String,CommandParameter> parameters
           
 
Constructor Summary
Pazpar2Command()
           
Pazpar2Command(String name)
           
 
Method Summary
 void addExpression(String parameterName, Expression expression)
          Adds an expression to an ordered list of expressions on a given parameter and notifies the state manager of the change
protected  void checkInState(Pazpar2Command command)
          Notifies the state manager that this command changed a parameter
abstract  Pazpar2Command copy()
          Commands must implement this method to provide an completely detached, deep clone of themselves.
 boolean equals(Object otherCommand)
           
 String getCommandName()
           
 String getEncodedQueryString()
           
 CommandParameter getParameter(String name)
          Retrieves a command parameter by parameter name
 String getParameterValue(String parameterName)
           
 String getSession()
           
abstract  ServiceProxyCommand getSp()
          Implementing classes must provide their Service Proxy extension command if any extension parameters exists, or -- just to be polite -- 'this' if there is no Service Proxy extension to the given command.
 String getValueWithExpressions()
           
 int hashCode()
           
 boolean hasParameters()
           
 boolean hasParameterValue(String parameterName)
           
 void removeExpression(String parameterName, Expression expression)
           
 void removeExpressions(String parameterName, String... expressionFields)
           
 void removeExpressionsAfter(String parameterName, Expression expression, String... expressionFields)
           
 void removeParameter(String name)
          Removes a parameter completely and notifies the state manager about the change
 void removeParameters()
          Removes multiple parameters completely and notifies the state manager -- once -- about the change
 void removeParametersInState()
          Removes all parameters without notifying the state manager.
 ResponseDataObject run()
          Executes the command with the currently selected parameters against the currently selected Pazpar2 service
 ResponseDataObject run(SearchClient client, Responses pzresp)
          Executes the command in a thread.
 ResponseDataObject runWith(String... parameters)
          Executes the commands with the currently selected parameters, while adding the parameters provided
 void setCommandName(String name)
           
 void setParameter(CommandParameter parameter)
          Sets a parameter on this command and notifies the state manager about the change
 void setParameterInState(CommandParameter parameter)
          Sets a parameter on this command without notifying the state manager.
 void setParameters(CommandParameter... params)
          Sets multiple parameters on the command and notifies the state manager -- once -- about the change
 void setParametersInState(CommandParameter... params)
          Sets multiple parameters on this command without notifying the state manager.
 void setSession(String sessionId)
           
abstract  boolean spOnly()
          Here implementing commands publish whether they only apply to the Service Proxy or can be executed against straight Pazpar2 as well.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

name

protected String name

parameters

protected Map<String,CommandParameter> parameters
Constructor Detail

Pazpar2Command

public Pazpar2Command()

Pazpar2Command

public Pazpar2Command(String name)
Method Detail

setCommandName

public void setCommandName(String name)

copy

public abstract Pazpar2Command copy()
Commands must implement this method to provide an completely detached, deep clone of themselves. The clone is needed by the state manager to transfer commands with current setting from one state to the next. Whenever a non-standard attribute is added to a command class, the copy method must be updated to ensure that the new attribute is brought over as well.

Returns:
a Pazpar2 command of the given type

getCommandName

public String getCommandName()

run

public ResponseDataObject run()
Executes the command with the currently selected parameters against the currently selected Pazpar2 service

Returns:
Response data object based on the Pazpar2 service response.

runWith

public ResponseDataObject runWith(String... parameters)
Executes the commands with the currently selected parameters, while adding the parameters provided

Parameters:
parameters - A list of parameters on the form [key=value]
Returns:
Response data object based on the Pazpar2 service response

run

public ResponseDataObject run(SearchClient client,
                              Responses pzresp)
Executes the command in a thread. Note: Client and Responses must be provided because at this point CDI beans cannot be retrieved from within a thread.

Parameters:
client -
pzresp -
Returns:

setParameter

public void setParameter(CommandParameter parameter)
Sets a parameter on this command and notifies the state manager about the change

Parameters:
parameter -

setParameters

public void setParameters(CommandParameter... params)
Sets multiple parameters on the command and notifies the state manager -- once -- about the change

Parameters:
params -

setParametersInState

public void setParametersInState(CommandParameter... params)
Sets multiple parameters on this command without notifying the state manager. Typically used when one parameter setting should automatically trigger other parameters to be reset to defaults etc. Intended to avoid useless proliferation of states

Parameters:
params -

setParameterInState

public void setParameterInState(CommandParameter parameter)
Sets a parameter on this command without notifying the state manager. Typically used when one parameter setting should automatically trigger other parameters to be reset to defaults etc. Intended to avoid useless proliferation of states

Parameters:
parameter -

getParameter

public CommandParameter getParameter(String name)
Retrieves a command parameter by parameter name

Parameters:
name - of the parameter
Returns:
CommandParameter

removeParameter

public void removeParameter(String name)
Removes a parameter completely and notifies the state manager about the change

Parameters:
name - of the parameter to remove

removeParameters

public void removeParameters()
Removes multiple parameters completely and notifies the state manager -- once -- about the change

Parameters:
name - of the parameter to remove

removeParametersInState

public void removeParametersInState()
Removes all parameters without notifying the state manager. For instance used in case of change of Pazpar2 service or renewed login to a service.


addExpression

public void addExpression(String parameterName,
                          Expression expression)
Adds an expression to an ordered list of expressions on a given parameter and notifies the state manager of the change

Parameters:
parameterName - name of the parameter to add the expression to
expression -

removeExpression

public void removeExpression(String parameterName,
                             Expression expression)

removeExpressionsAfter

public void removeExpressionsAfter(String parameterName,
                                   Expression expression,
                                   String... expressionFields)

removeExpressions

public void removeExpressions(String parameterName,
                              String... expressionFields)

hasParameters

public boolean hasParameters()

hasParameterValue

public boolean hasParameterValue(String parameterName)

getEncodedQueryString

public String getEncodedQueryString()

getValueWithExpressions

public String getValueWithExpressions()

equals

public boolean equals(Object otherCommand)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

toString

public String toString()
Overrides:
toString in class Object

getParameterValue

public String getParameterValue(String parameterName)

setSession

public void setSession(String sessionId)

getSession

public String getSession()

checkInState

protected void checkInState(Pazpar2Command command)
Notifies the state manager that this command changed a parameter

Parameters:
command -

getSp

public abstract ServiceProxyCommand getSp()
Implementing classes must provide their Service Proxy extension command if any extension parameters exists, or -- just to be polite -- 'this' if there is no Service Proxy extension to the given command.

Returns:

spOnly

public abstract boolean spOnly()
Here implementing commands publish whether they only apply to the Service Proxy or can be executed against straight Pazpar2 as well. This is convenient for a UI that switches between service types either deployment time or run time.

Returns:
false if the command applies to straight Pazpar2


Copyright © 2013. All Rights Reserved.