From: Niels Erik G. Nielsen
* If there are outstanding changes to the search command, a search
@@ -232,7 +232,7 @@ public class Pz2Service implements StateListener, Configurable, Serializable {
* Simultaneously refreshes the data objects listed in 'commands' from pazpar2, potentially running a
* search or a record command first if any of these two commands have outstanding parameter changes.
*
- * @param commands comma separated list of Pazpar2 commands to execute
+ * @param commands, a comma-separated list of Pazpar2 commands to execute
*
* @return Number of activeclients at the time of the 'show' command,
* or 'new' if search was just initiated.
diff --git a/src/main/java/com/indexdata/mkjsf/pazpar2/commands/BytargetCommand.java b/src/main/java/com/indexdata/mkjsf/pazpar2/commands/BytargetCommand.java
index daea58a..02a2307 100644
--- a/src/main/java/com/indexdata/mkjsf/pazpar2/commands/BytargetCommand.java
+++ b/src/main/java/com/indexdata/mkjsf/pazpar2/commands/BytargetCommand.java
@@ -3,7 +3,7 @@ package com.indexdata.mkjsf.pazpar2.commands;
import com.indexdata.mkjsf.pazpar2.commands.sp.ServiceProxyCommand;
/**
- * Represents a Pazpar2 'bytarget' command
+ * Represents a Pazpar2 Examples Examples:bytarget
command
*
* @author Niels Erik
*
diff --git a/src/main/java/com/indexdata/mkjsf/pazpar2/commands/CommandParameter.java b/src/main/java/com/indexdata/mkjsf/pazpar2/commands/CommandParameter.java
index eaff692..6c6df86 100644
--- a/src/main/java/com/indexdata/mkjsf/pazpar2/commands/CommandParameter.java
+++ b/src/main/java/com/indexdata/mkjsf/pazpar2/commands/CommandParameter.java
@@ -13,11 +13,11 @@ import org.apache.log4j.Logger;
/**
* Represents a Pazpar2 command parameter with a name, an operator,
* a simple value and/or one or more complex values (expressions).
- *
- *
* @author Niels Erik
*
diff --git a/src/main/java/com/indexdata/mkjsf/pazpar2/commands/Expression.java b/src/main/java/com/indexdata/mkjsf/pazpar2/commands/Expression.java
index 67cc3d4..1961bae 100644
--- a/src/main/java/com/indexdata/mkjsf/pazpar2/commands/Expression.java
+++ b/src/main/java/com/indexdata/mkjsf/pazpar2/commands/Expression.java
@@ -11,11 +11,11 @@ import org.apache.log4j.Logger;
* An expression consist of a left-of-operator field or key, an equality operator (= or ~),
* a right-of-operator value, and optionally a label describing the value for UI display.
* {name}{=}{value}
{name}{=}{value} AND {expr1=value1} AND {expr2=value2}
{name}{=}{expr1~value1},{expr2~value2}
Examples:
*pz:id=1234
"My Target"category~libcatalog
"Library Catalogs"author="Steinbeck, John"
A filter parameter consists of one or more expressions separated by commas.
+ * + * @author Niels Erik + * + */ public class FilterParameter extends CommandParameter { private static final long serialVersionUID = -3697328835895528654L; @@ -28,7 +36,13 @@ public class FilterParameter extends CommandParameter { return completeValue.toString(); } - public String pz2escape (String expressionString) { + /** + * Escapes backslash (\), comma (,) and pipe (|) from an expression string. + * + * @param expressionString + * @return escaped expressionString + */ + private String pz2escape (String expressionString) { String escaped = expressionString.replaceAll("\\\\","\\\\\\\\"); escaped = escaped.replaceAll(",","\\\\,"); escaped = escaped.replaceAll("\\|", "\\\\|"); diff --git a/src/main/java/com/indexdata/mkjsf/pazpar2/commands/InitCommand.java b/src/main/java/com/indexdata/mkjsf/pazpar2/commands/InitCommand.java index d52ec51..e98a5cf 100644 --- a/src/main/java/com/indexdata/mkjsf/pazpar2/commands/InitCommand.java +++ b/src/main/java/com/indexdata/mkjsf/pazpar2/commands/InitCommand.java @@ -5,6 +5,12 @@ import org.apache.log4j.Logger; import com.indexdata.mkjsf.pazpar2.commands.sp.InitCommandSp; import com.indexdata.mkjsf.pazpar2.commands.sp.ServiceProxyCommand; +/** + * Represents a Pazpar2init
command.
+ *
+ * @author Niels Erik
+ *
+ */
public class InitCommand extends Pazpar2Command implements ServiceProxyCommand {
private static final long serialVersionUID = -4915976465898889987L;
@@ -15,27 +21,48 @@ public class InitCommand extends Pazpar2Command implements ServiceProxyCommand {
super("init");
}
+ /**
+ * Sets the clear
parameter. See Pazpar2 documentation for details.
+ *
+ * @param clear
+ */
public void setClear(String clear) {
setParameterInState(new CommandParameter("clear","=",clear));
}
-
+
+ /**
+ * Returns the clear
parameter value.
+ */
public String getClear() {
return getParameterValue("clear");
}
+ /**
+ * Sets the service
parameter. See Pazpar2 documentation for details.
+ * @param serviceId
+ */
public void setService(String serviceId) {
setParameterInState(new CommandParameter("service","=",serviceId));
}
+ /**
+ * Returns the service
parameter value.
+ */
public String getService() {
return getParameterValue("service");
}
+ /**
+ * Disabled, not supported for init
+ */
@Override
public void setSession (String sessionId) {
throw new UnsupportedOperationException("Cannot set session id on init command");
}
-
+
+ /**
+ * Disabled, not supported for init
+ */
@Override
public String getSession () {
throw new UnsupportedOperationException("Cannot set or get session id on init command");
diff --git a/src/main/java/com/indexdata/mkjsf/pazpar2/commands/LimitParameter.java b/src/main/java/com/indexdata/mkjsf/pazpar2/commands/LimitParameter.java
index b86c27f..0b98956 100644
--- a/src/main/java/com/indexdata/mkjsf/pazpar2/commands/LimitParameter.java
+++ b/src/main/java/com/indexdata/mkjsf/pazpar2/commands/LimitParameter.java
@@ -2,6 +2,14 @@ package com.indexdata.mkjsf.pazpar2.commands;
import org.apache.log4j.Logger;
+/**
+ * Represents a limit parameter as it applies to the Pazpar2 search command
+ *
+ * A limit parameter consists of one or more expressions separated by commas.
+ * + * @author Niels Erik + * + */ public class LimitParameter extends CommandParameter { private static final long serialVersionUID = -1410691265213389826L; @@ -29,7 +37,7 @@ public class LimitParameter extends CommandParameter { return completeValue.toString(); } - public String pz2escape (String expressionString) { + private String pz2escape (String expressionString) { String escaped = expressionString.replaceAll("\\\\","\\\\\\\\"); escaped = escaped.replaceAll(",","\\\\,"); escaped = escaped.replaceAll("\\|", "\\\\|"); diff --git a/src/main/java/com/indexdata/mkjsf/pazpar2/commands/Pazpar2Commands.java b/src/main/java/com/indexdata/mkjsf/pazpar2/commands/Pazpar2Commands.java index c9dc4c0..b847e17 100644 --- a/src/main/java/com/indexdata/mkjsf/pazpar2/commands/Pazpar2Commands.java +++ b/src/main/java/com/indexdata/mkjsf/pazpar2/commands/Pazpar2Commands.java @@ -14,17 +14,17 @@ import com.indexdata.mkjsf.utils.Utils; /** * Pazpar2Commands holds references to all Pazpar2 commands. *
- * The Pazpar2Commands object itself is exposed to the UI as 'pzreq'.
+ * The Pazpar2Commands object itself is exposed to the UI as pzreq
.
*
* When the UI request a command it will be retrieved from the current state * through the state manager, so that the command can trigger a mutation of * the state if the user/UI modifies its parameters. *
- * Examples: + *Examples:
*pzreq.show
- will retrieve the show command for editing or execution
+ * pzreq.sp.auth
- will retrieve the Service Proxy extension command 'auth'
* pzreq.init
*
* @return init command from current state
*/
@@ -60,6 +61,7 @@ public class Pazpar2Commands implements Serializable {
}
/**
+ * ping command - referenced from UI as pzreq.ping
*
* @return ping command from current state
*/
@@ -68,6 +70,7 @@ public class Pazpar2Commands implements Serializable {
}
/**
+ * settings command - referenced from UI as pzreq.settings
*
* @return settings command from current state
*/
diff --git a/src/main/java/com/indexdata/mkjsf/pazpar2/commands/PingCommand.java b/src/main/java/com/indexdata/mkjsf/pazpar2/commands/PingCommand.java
index 8dbf348..6d3d024 100644
--- a/src/main/java/com/indexdata/mkjsf/pazpar2/commands/PingCommand.java
+++ b/src/main/java/com/indexdata/mkjsf/pazpar2/commands/PingCommand.java
@@ -2,6 +2,12 @@ package com.indexdata.mkjsf.pazpar2.commands;
import com.indexdata.mkjsf.pazpar2.commands.sp.ServiceProxyCommand;
+/**
+ * Represents a Pazpar2 ping
command.
+ *
+ * @author Niels Erik
+ *
+ */
public class PingCommand extends Pazpar2Command implements ServiceProxyCommand {
private static final long serialVersionUID = 8876721711326535847L;
diff --git a/src/main/java/com/indexdata/mkjsf/pazpar2/commands/RecordCommand.java b/src/main/java/com/indexdata/mkjsf/pazpar2/commands/RecordCommand.java
index c9df610..d453b75 100644
--- a/src/main/java/com/indexdata/mkjsf/pazpar2/commands/RecordCommand.java
+++ b/src/main/java/com/indexdata/mkjsf/pazpar2/commands/RecordCommand.java
@@ -11,6 +11,12 @@ import com.indexdata.mkjsf.pazpar2.data.RecordResponse;
import com.indexdata.mkjsf.pazpar2.data.ResponseDataObject;
import com.indexdata.mkjsf.pazpar2.data.ResponseParser;
+/**
+ * Represents a Pazpar2 record
command.
+ *
+ * @author Niels Erik
+ *
+ */
public class RecordCommand extends Pazpar2Command implements ServiceProxyCommand {
private static final long serialVersionUID = 2817539422114569506L;
@@ -57,58 +63,102 @@ public class RecordCommand extends Pazpar2Command implements ServiceProxyCommand
return responseObject;
}
+ /**
+ * Sets the id
parameter. See Pazpar2 documentation for details.
+ *
+ * @param recId record ID
+ */
public void setId(String recId) {
setParameter(new CommandParameter("id","=",recId));
}
-
+
+ /**
+ * Returns the id
parameter value.
+ */
public String getId () {
return getParameterValue("id");
}
-
+
+ /**
+ * Sets the offset
parameter. See Pazpar2 documentation for details.
+ */
public void setOffset (String offset) {
setParameter(new CommandParameter("offset","=",offset));
}
-
+
+ /**
+ * Returns the offset
parameter value.
+ */
public String getOffset () {
return getParameterValue("offset");
}
+ /**
+ * Sets the checksum
parameter. See Pazpar2 documentation for details.
+ */
public void setChecksum (String checksum) {
setParameter(new CommandParameter("checksum","=",checksum));
}
+ /**
+ * Returns the checksum
parameter value.
+ */
public String getChecksum () {
return getParameterValue("checksum");
}
+ /**
+ * Sets the nativesyntax
parameter. See Pazpar2 documentation for details.
+ */
public void setNativesyntax (String nativesyntax) {
setParameterInState(new CommandParameter("nativesyntax","=",nativesyntax));
}
+ /**
+ * Returns the nativesyntax
parameter value.
+ */
public String getNativesyntax () {
return getParameterValue("nativesyntax");
}
+ /**
+ * Sets the syntax
parameter. See Pazpar2 documentation for details.
+ */
public void setSyntax (String syntax) {
setParameterInState(new CommandParameter("syntax","=",syntax));
}
+ /**
+ * Returns the syntax
parameter value.
+ */
public String getSyntax () {
return getParameterValue("syntax");
}
+ /**
+ * Sets the esn
parameter. See Pazpar2 documentation for details.
+ */
public void setEsn (String esn) {
setParameter(new CommandParameter("esn","=",esn));
}
+ /**
+ * Returns the esn
parameter value.
+ */
public String getEsn () {
return getParameterValue("esn");
}
+ /**
+ * Sets the binary
parameter. See Pazpar2 documentation for details.
+ */
public void setBinary (String binary) {
setParameter(new CommandParameter("binary","=",binary));
}
+ /**
+ * Returns the binary
parameter value.
+ */
public String getBinary () {
return getParameterValue("binary");
}
diff --git a/src/main/java/com/indexdata/mkjsf/pazpar2/commands/SearchCommand.java b/src/main/java/com/indexdata/mkjsf/pazpar2/commands/SearchCommand.java
index e36b239..671e723 100644
--- a/src/main/java/com/indexdata/mkjsf/pazpar2/commands/SearchCommand.java
+++ b/src/main/java/com/indexdata/mkjsf/pazpar2/commands/SearchCommand.java
@@ -12,6 +12,12 @@ import com.indexdata.mkjsf.pazpar2.Pz2Service;
import com.indexdata.mkjsf.pazpar2.commands.sp.ServiceProxyCommand;
import com.indexdata.mkjsf.pazpar2.data.ResponseDataObject;
+/**
+ * Represents a Pazpar2 search
command.
+ *
+ * @author Niels Erik
+ *
+ */
@SessionScoped @Named
public class SearchCommand extends Pazpar2Command implements ServiceProxyCommand {
@@ -31,7 +37,10 @@ public class SearchCommand extends Pazpar2Command implements ServiceProxyCommand
Pz2Service.get().getSearchClient().setSearchCommand(this);
return super.run();
}
-
+
+ /**
+ * Sets the query
parameter. See Pazpar2 documentation for details.
+ */
public void setQuery(String query) {
setParameter(new QueryParameter("query","=",query));
}
@@ -42,14 +51,24 @@ public class SearchCommand extends Pazpar2Command implements ServiceProxyCommand
checkInState(copy);
}
+ /**
+ * Returns the simple part of the query
parameter value, excluding parts that
+ * were added as expressions (that is, not set with setQuery()
).
+ */
public String getQuery () {
return getParameter("query") == null ? null : getParameter("query").getSimpleValue();
}
-
+
+ /**
+ * Returns the complete query
parameter value, including expressions.
+ */
public String getExtendedQuery () {
return getParameter("query") == null ? null : getParameter("query").getValueWithExpressions();
}
-
+
+ /**
+ * Sets the filter
parameter. See Pazpar2 documentation for details.
+ */
public void setFilter(String filterExpression) {
if (filterExpression != null && filterExpression.length()>0) {
if (filterExpression.split("[=~]").length==1) {
@@ -62,10 +81,18 @@ public class SearchCommand extends Pazpar2Command implements ServiceProxyCommand
}
}
+ /**
+ * Sets the filter
parameter. See Pazpar2 documentation for details.
+ */
public void setFilter(String field, String operator, String value, String label) {
setParameter(new FilterParameter(new Expression(field,operator,value,label)));
}
-
+
+ /**
+ * Checks if there are any filter expressions matching any of the given expressionFields
+ * @param expressionFields expression fields (left-of-operator entities) to look for
+ * @return true if expression(s) found with any of expressionFields
+ */
public boolean hasFilterExpression(String... expressionFields) {
logger.trace("Checking for filter expression for " + Arrays.deepToString(expressionFields));
for (String field : expressionFields) {
@@ -79,10 +106,18 @@ public class SearchCommand extends Pazpar2Command implements ServiceProxyCommand
}
+ /**
+ * Returns the filter
parameter value.
+ */
public String getFilter() {
return getParameter("filter") == null ? null : ((FilterParameter)getParameter("filter")).getValueWithExpressions();
}
+ /**
+ * Returns the first filter expression of the given type
+ * @param expressionField expression field (left-of-operator entity) to look for
+ * @return the first filter expression found with the field expressionField
or null if none found
+ */
public Expression getOneFilterExpression(String expressionField) {
ListfieldsToRemove
+ * @param fieldsToRemove
+ */
public void removeFilters(String... fieldsToRemove) {
removeExpressions("filter",fieldsToRemove);
}
-
+
+ /**
+ * Removes filter expressions coming after the expression matching the provided filter expression,
+ * if they have a field listed in fieldsToRemove
. To be used for bread crumb like UI
+ * controls.
+ *
+ * @param field
+ * @param operator
+ * @param value
+ * @param fieldsToRemove
+ */
public void removeFiltersAfter(String field, String operator, String value, String... fieldsToRemove) {
removeExpressionsAfter("filter",new Expression(field,operator,value,null),fieldsToRemove);
}
+ /**
+ * Sets the limit
parameter. See Pazpar2 documentation for details.
+ */
public void setLimit (String limitExpression) {
if (limitExpression != null && limitExpression.length()>0) {
setParameter(new LimitParameter(new Expression(limitExpression)));
}
}
+ /**
+ * Sets the limit
parameter including a label. See Pazpar2 documentation for details.
+ */
public void setLimit(String field, String operator, String value, String label) {
setParameter(new LimitParameter(new Expression(field,operator,value,label)));
}
+ /**
+ * Returns the limit
parameter value.
+ */
public String getLimit () {
return getParameter("limit") == null ? null : ((FilterParameter)getParameter("limit")).getValueWithExpressions();
}
+ /**
+ * Checks if there are any limit expressions matching any of the given expressionFields
+ * @param expressionFields expression fields (left-of-operator entities) to look for
+ * @return true if expression(s) found with any of expressionFields
+ */
public boolean hasLimitExpression(String... expressionFields) {
logger.trace("Checking for limit expression for " + Arrays.deepToString(expressionFields));
for (String field : expressionFields) {
@@ -165,6 +251,11 @@ public class SearchCommand extends Pazpar2Command implements ServiceProxyCommand
return false;
}
+ /**
+ * Returns the first limit expression of the given type
+ * @param expressionField expression field (left-of-operator entity) to look for
+ * @return the first limit expression found with the field expressionField
or null if none found
+ */
public Expression getOneLimitExpression(String expressionField) {
ListexpressionFields
+ *
+ * @param expressionFields limit expressions to look for
+ */
public ListfieldsToRemove
+ * @param fieldsToRemove
+ */
public void removeLimits(String... fieldsToRemove) {
removeExpressions("limit",fieldsToRemove);
}
+ /**
+ * Removes a limit expression by exact attributes
+ *
+ * @param field
+ * @param operator
+ * @param value
+ */
public void removeLimit(String field, String operator, String value) {
removeExpression("limit",new Expression(field, operator, value, null));
}
+ /**
+ * Removes limit expressions coming after the provided limit expression, if they have a field listed in
+ * fieldsToRemove
. To be used for bread crumb like UI controls.
+ *
+ * @param field
+ * @param operator
+ * @param value
+ * @param fieldsToRemove
+ */
public void removeLimitsAfter(String field, String operator, String value, String... fieldsToRemove) {
removeExpressionsAfter("limit",new Expression(field,operator,value,null),fieldsToRemove);
}
+ /**
+ * Sets the startrecs
parameter. See Pazpar2 documentation for details.
+ */
public void setStartrecs (String startrecs) {
setParameter(new CommandParameter("startrecs","=",startrecs));
}
+ /**
+ * Returns the startrecs
parameter value.
+ */
public String getStartrecs () {
return getParameterValue("startrecs");
}
+ /**
+ * Sets the maxrecs
parameter. See Pazpar2 documentation for details.
+ */
public void setMaxrecs (String maxrecs) {
setParameter(new CommandParameter("maxrecs","=",maxrecs));
}
+ /**
+ * Returns the maxrecs
parameter value.
+ */
public String getMaxrecs () {
return getParameterValue("maxrecs");
}
+ /**
+ * Sets the sort
parameter. See Pazpar2 documentation for details.
+ */
public void setSort (String sort) {
setParameter(new CommandParameter("sort","=",sort));
}
+ /**
+ * Returns the sort
parameter value.
+ */
public String getSort () {
return getParameterValue("sort");
}
+ /**
+ * Sets the rank
parameter. See Pazpar2 documentation for details.
+ */
public void setRank (String rank) {
setParameter(new CommandParameter("rank","=",rank));
}
+ /**
+ * Returns the rank
parameter value.
+ */
public String getRank () {
return getParameterValue("rank");
}
+ /**
+ * Sets the mergekey
parameter. See Pazpar2 documentation for details.
+ */
public void setMergekey (String mergekey) {
setParameter(new CommandParameter("mergekey","=",mergekey));
}
+ /**
+ * Returns the mergekey
parameter value.
+ */
public String getMergekey () {
return getParameterValue("mergekey");
}
diff --git a/src/main/java/com/indexdata/mkjsf/pazpar2/commands/package-info.java b/src/main/java/com/indexdata/mkjsf/pazpar2/commands/package-info.java
index 347e81e..dd66c3f 100644
--- a/src/main/java/com/indexdata/mkjsf/pazpar2/commands/package-info.java
+++ b/src/main/java/com/indexdata/mkjsf/pazpar2/commands/package-info.java
@@ -5,29 +5,29 @@
* the selected Pazpar2 service.
*
* The UI can access the command objects through the bean Pazpar2Commands,
- * which is exposed to the UI under the name 'pzreq'.
+ * which is exposed to the UI under the name pzreq
.
*
* For commands that has Service Proxy extension parameters, the UI
* can access the extension parameters through the getSp() method
- * on the command.
+ * on the command - using for instance pzreq.record.sp
*
* The UI can access Service Proxy-only commands through the getSp()
- * method on the pzreq bean.
+ * method on the pzreq bean - for instance pzreq.sp.categories
*
Examples:
*pzreq.search.query
references getter and setter for the
* query parameter of the search command.pzreq.search.run()
executes the search command with current
* parameterspzreq.record.sp.recordquery
references getter and setter on a Service Proxy-only
+ * parameter to the record commandpzreq.sp.auth.run()
executes a Service Proxy-only command