System.exit(1);
}
try {
ProductType type = client.getProductTypeByName(typeName);
ProductPage firstPage = client.getFirstPage(type);
System.out.println("Page: [num=" + firstPage.getPageNum()
+ ", totalPages=" + firstPage.getTotalPages()
+ ", pageSize=" + firstPage.getPageSize() + "]");
System.out.println("Products:");
if (firstPage.getPageProducts() != null
&& firstPage.getPageProducts().size() > 0) {
for (Iterator<Product> i = firstPage.getPageProducts()
.iterator(); i.hasNext();) {
Product p = i.next();
System.out.println("Product: [id=" + p.getProductId()
+ ",name=" + p.getProductName() + ",type="
+ p.getProductType().getName() + ",structure="
+ p.getProductStructure() + ", transferStatus="
+ p.getTransferStatus() + "]");
}
}
} catch (Exception e) {
e.printStackTrace();
throw new RuntimeException(e);
}
} else if (operation.equals("--getNextPage")) {
String typeName = null;
int currentPageNum = -1;
for (int i = 4; i < args.length; i++) {
if (args[i].equals("--productTypeName")) {
typeName = args[++i];
} else if (args[i].equals("--currentPageNum")) {
currentPageNum = Integer.parseInt(args[++i]);
}
}
if (typeName == null || currentPageNum == -1) {
System.err.println(getNextPageOperation);
System.exit(1);
}
try {
ProductType type = client.getProductTypeByName(typeName);
ProductPage firstPage = client.getFirstPage(type);
ProductPage currentPage = new ProductPage();
currentPage.setPageNum(currentPageNum);
currentPage.setPageSize(firstPage.getPageSize());
currentPage.setTotalPages(firstPage.getTotalPages());
ProductPage nextPage = client.getNextPage(type, currentPage);
System.out.println("Page: [num=" + nextPage.getPageNum()
+ ", totalPages=" + nextPage.getTotalPages()
+ ", pageSize=" + nextPage.getPageSize() + "]");
System.out.println("Products:");
if (nextPage.getPageProducts() != null
&& nextPage.getPageProducts().size() > 0) {
for (Iterator<Product> i = nextPage.getPageProducts()
.iterator(); i.hasNext();) {
Product p = i.next();
System.out.println("Product: [id=" + p.getProductId()
+ ",name=" + p.getProductName() + ",type="
+ p.getProductType().getName() + ",structure="
+ p.getProductStructure() + ", transferStatus="
+ p.getTransferStatus() + "]");
}
}
} catch (Exception e) {
e.printStackTrace();
throw new RuntimeException(e);
}
} else if (operation.equals("--getPrevPage")) {
String typeName = null;
int currentPageNum = -1;
for (int i = 4; i < args.length; i++) {
if (args[i].equals("--productTypeName")) {
typeName = args[++i];
} else if (args[i].equals("--currentPageNum")) {
currentPageNum = Integer.parseInt(args[++i]);
}
}
if (typeName == null || currentPageNum == -1) {
System.err.println(getNextPageOperation);
System.exit(1);
}
try {
ProductType type = client.getProductTypeByName(typeName);
ProductPage firstPage = client.getFirstPage(type);
ProductPage currentPage = new ProductPage();
currentPage.setPageNum(currentPageNum);
currentPage.setPageSize(firstPage.getPageSize());
currentPage.setTotalPages(firstPage.getTotalPages());
ProductPage prevPage = client.getPrevPage(type, currentPage);
System.out.println("Page: [num=" + prevPage.getPageNum()
+ ", totalPages=" + prevPage.getTotalPages()
+ ", pageSize=" + prevPage.getPageSize() + "]");
System.out.println("Products:");
if (prevPage.getPageProducts() != null
&& prevPage.getPageProducts().size() > 0) {
for (Iterator<Product> i = prevPage.getPageProducts()
.iterator(); i.hasNext();) {
Product p = i.next();
System.out.println("Product: [id=" + p.getProductId()
+ ",name=" + p.getProductName() + ",type="
+ p.getProductType().getName() + ",structure="
+ p.getProductStructure() + ", transferStatus="
+ p.getTransferStatus() + "]");
}
}
} catch (Exception e) {
e.printStackTrace();
throw new RuntimeException(e);
}
} else if (operation.equals("--getLastPage")) {
String typeName = null;
for (int i = 4; i < args.length; i++) {
if (args[i].equals("--productTypeName")) {
typeName = args[++i];
}
}
if (typeName == null) {
System.err.println(getLastPageOperation);
System.exit(1);
}
try {
ProductType type = client.getProductTypeByName(typeName);
ProductPage lastPage = client.getLastPage(type);
System.out.println("Page: [num=" + lastPage.getPageNum()
+ ", totalPages=" + lastPage.getTotalPages()
+ ", pageSize=" + lastPage.getPageSize() + "]");
System.out.println("Products:");
if (lastPage.getPageProducts() != null
&& lastPage.getPageProducts().size() > 0) {
for (Iterator<Product> i = lastPage.getPageProducts()
.iterator(); i.hasNext();) {
Product p = i.next();
System.out.println("Product: [id=" + p.getProductId()
+ ",name=" + p.getProductName() + ",type="
+ p.getProductType().getName() + ",structure="