Skip to content

Commit

Permalink
Add spool name filter to SpooledFileList (IBM#100)
Browse files Browse the repository at this point in the history
Signed-off-by: Nicola Isotta <nicola.isotta@gmail.com>
  • Loading branch information
NicolaIsotta committed Aug 23, 2023
1 parent f7254eb commit ca2447d
Show file tree
Hide file tree
Showing 4 changed files with 170 additions and 58 deletions.
34 changes: 30 additions & 4 deletions src/main/java/com/ibm/as400/access/NPCPSelSplF.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ class NPCPSelSplF extends NPCPSelection implements Cloneable
static final String STR_ALLOUTQLIBS = "*ALL";
static final String STR_BLANKOUTQLIB = "";

@Override
protected Object clone()
{
NPCPSelSplF cp = new NPCPSelSplF(this);
Expand Down Expand Up @@ -212,9 +213,23 @@ String getEndTime()
} else {
return endTime;
}
}


}

/**
* gets the spool name filter
*
* @returns the filter for the spool name or an empty string if it isn't
* set.
*/
String getSpoolName() {
String spoolName = getStringValue(PrintObject.ATTR_SPOOLFILE);
if (spoolName == null) {
return emptyString;
} else {
return spoolName;
}
}

/**
* set formtype filter.
* Removes the filter if formType is "".
Expand Down Expand Up @@ -373,5 +388,16 @@ void setEndDate(String endDate)
}
}

}
/**
* set spool name filter. Removes the filter if spoolName is "".
*
*/
void setSpoolName(String spoolName) {
if (spoolName.isEmpty()) {
removeAttribute(PrintObject.ATTR_SPOOLFILE);
} else {
setAttrValue(PrintObject.ATTR_SPOOLFILE, spoolName);
}
}

}
109 changes: 59 additions & 50 deletions src/main/java/com/ibm/as400/access/PrintObjectListImplRemote.java
Original file line number Diff line number Diff line change
Expand Up @@ -690,57 +690,66 @@ public void setIDCodePointFilter(NPCPID cpID)

public void setFilter(String filterType, String filter)
{
if (filterType.equals("resource"))
{
NPCPSelRes selectionCP = (NPCPSelRes)getSelectionCP();
selectionCP.setResource(filter);
}
if (filterType.equals("queue"))
{
NPCPSelOutQ selectionCP = (NPCPSelOutQ)getSelectionCP();
selectionCP.setQueue(filter);
}
else if (filterType.equals("printer"))
{
NPCPSelPrtD selectionCP = (NPCPSelPrtD)getSelectionCP();
selectionCP.setPrinter(filter);
}
else if (filterType.equals("printerFile"))
{
NPCPSelPrtF selectionCP = (NPCPSelPrtF)getSelectionCP();
selectionCP.setPrinterFile(filter);
}
else if (filterType.equals("formType"))
{
NPCPSelSplF selectionCP = (NPCPSelSplF)getSelectionCP();
selectionCP.setFormType(filter);
}
else if (filterType.equals("spooledFileQueue"))
{
NPCPSelSplF selectionCP = (NPCPSelSplF)getSelectionCP();
selectionCP.setQueue(filter);
}
else if (filterType.equals("user"))
{
NPCPSelSplF selectionCP = (NPCPSelSplF)getSelectionCP();
selectionCP.setUser(filter);
}
else if (filterType.equals("userData"))
{
NPCPSelSplF selectionCP = (NPCPSelSplF)getSelectionCP();
selectionCP.setUserData(filter);
}
else if (filterType.equals("writerJobQueue"))
{
NPCPSelWrtJ selectionCP = (NPCPSelWrtJ)getSelectionCP();
selectionCP.setQueue(filter);
}
else if (filterType.equals("writer"))
{
NPCPSelWrtJ selectionCP = (NPCPSelWrtJ)getSelectionCP();
selectionCP.setWriter(filter);
switch (filterType) {
case "resource": {
NPCPSelRes selectionCP = (NPCPSelRes) getSelectionCP();
selectionCP.setResource(filter);
break;
}
case "queue": {
NPCPSelOutQ selectionCP = (NPCPSelOutQ) getSelectionCP();
selectionCP.setQueue(filter);
break;
}
case "printer": {
NPCPSelPrtD selectionCP = (NPCPSelPrtD) getSelectionCP();
selectionCP.setPrinter(filter);
break;
}
case "printerFile": {
NPCPSelPrtF selectionCP = (NPCPSelPrtF) getSelectionCP();
selectionCP.setPrinterFile(filter);
break;
}
case "formType": {
NPCPSelSplF selectionCP = (NPCPSelSplF) getSelectionCP();
selectionCP.setFormType(filter);
break;
}
case "spooledFileQueue": {
NPCPSelSplF selectionCP = (NPCPSelSplF) getSelectionCP();
selectionCP.setQueue(filter);
break;
}
case "user": {
NPCPSelSplF selectionCP = (NPCPSelSplF) getSelectionCP();
selectionCP.setUser(filter);
break;
}
case "userData": {
NPCPSelSplF selectionCP = (NPCPSelSplF) getSelectionCP();
selectionCP.setUserData(filter);
break;
}
case "spoolName": {
NPCPSelSplF selectionCP = (NPCPSelSplF) getSelectionCP();
selectionCP.setSpoolName(filter);
break;
}
case "writerJobQueue": {
NPCPSelWrtJ selectionCP = (NPCPSelWrtJ) getSelectionCP();
selectionCP.setQueue(filter);
break;
}
case "writer": {
NPCPSelWrtJ selectionCP = (NPCPSelWrtJ) getSelectionCP();
selectionCP.setWriter(filter);
break;
}
default:
break;
}
}
}


public void setPrintObjectListAttrs(NPCPAttributeIDList attrsToRetrieve,
Expand Down
70 changes: 66 additions & 4 deletions src/main/java/com/ibm/as400/access/SpooledFileList.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
/**
* Builds a list of objects of type SpooledFile.
* The list can be filtered by formtype, output queue, user, ending date,
* ending time, or user data.
* ending time, user data or spool name.
*
*@see SpooledFile
**/
Expand All @@ -38,7 +38,8 @@ public class SpooledFileList extends PrintObjectList<SpooledFile>
private static final String START_DATE_FILTER = "startDateFilter";
private static final String START_TIME_FILTER = "startTimeFilter";
private static final String JOB_SYSTEM_FILTER = "jobSystemFilter";

private static final String SPOOL_NAME_FILTER = "spoolNameFilter";

/**
* Constructs a SpooledFileList object. The system
* must be set later. This constructor is provided for visual
Expand Down Expand Up @@ -228,8 +229,20 @@ public String getStartTimeFilter()
NPCPSelSplF selectionCP = (NPCPSelSplF)getSelectionCP();
return( selectionCP.getStartTime() );
}



/**
* Returns the spool name list filter.
*
* @return spool name filter
*/
public String getSpoolNameFilter() {
// The selection code point is always present, the spoolName Filter
// may not have been set. If empty, getSpoolName() will return
// an empty string.

NPCPSelSplF selectionCP = (NPCPSelSplF) getSelectionCP();
return selectionCP.getSpoolName();
}


/**
Expand Down Expand Up @@ -718,5 +731,54 @@ public void setUserDataFilter(String userDataFilter)
oldUserDataFilter, userDataFilter );
}

/**
* Sets the spool name list filter.
*
* @param spoolNameFilter The name the spooled file must have for it to be
* included in the list. The value can be any specific value or the special
* value *ALL. The value cannot be greater than 10 characters. The default
* is *ALL.
*
* @exception PropertyVetoException If the change is vetoed.
*
*/
public void setSpoolNameFilter(String spoolNameFilter)
throws PropertyVetoException {
if (spoolNameFilter == null) {
Trace.log(Trace.ERROR, "Parameter 'spoolNameFilter' is null");
throw new NullPointerException(SPOOL_NAME_FILTER);
}

// Allow a length of 0 to remove the filter from the
// selection code point.
if (spoolNameFilter.length() > 10) {
Trace.log(Trace.ERROR, "Parameter 'spoolNameFilter' is greater than 10 characters in length.");
throw new ExtendedIllegalArgumentException(
"spoolNameFilter(" + spoolNameFilter + ")",
ExtendedIllegalArgumentException.LENGTH_NOT_VALID);
}

String oldSpoolNameFilter = getSpoolNameFilter();

// Tell any vetoers about the change. If anyone objects
// we let the PropertyVetoException propagate back to
// our caller.
vetos.fireVetoableChange(SPOOL_NAME_FILTER,
oldSpoolNameFilter, spoolNameFilter);

// No one vetoed, make the change.
NPCPSelSplF selectionCP = (NPCPSelSplF) getSelectionCP();
selectionCP.setSpoolName(spoolNameFilter);

// Propagate any change to ImplRemote if necessary...
if (impl_ != null) {
impl_.setFilter("spoolName", spoolNameFilter);
}

// Notify any property change listeners.
changes.firePropertyChange(SPOOL_NAME_FILTER,
oldSpoolNameFilter, spoolNameFilter);
}

} // SpooledFileList class

15 changes: 15 additions & 0 deletions src/main/java/com/ibm/as400/access/SpooledFileListImplRemote.java
Original file line number Diff line number Diff line change
Expand Up @@ -261,4 +261,19 @@ public void setUserDataFilter(String userDataFilter)
selectionCP.setUserData(userDataFilter);
}

/**
* Sets the spool name list filter.
*
* @param spoolNameFilter The name the spooled file must have for it to
* be included in the list. The value can be any specific value or the
* special value *ALL. The value cannot be greater than 10 characters. The
* default is *ALL.
*
*/
public void setSpoolNameFilter(String spoolNameFilter)
{
NPCPSelSplF selectionCP = (NPCPSelSplF) getSelectionCP();
selectionCP.setSpoolName(spoolNameFilter);
}

}

0 comments on commit ca2447d

Please sign in to comment.