Package org.apache.oodt.cas.filemgr.structs

Examples of org.apache.oodt.cas.filemgr.structs.ProductPage


                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="
View Full Code Here


     * (non-Javadoc)
     *
     * @see org.apache.oodt.cas.filemgr.util.Pagination#getFirstPage(org.apache.oodt.cas.filemgr.structs.ProductType)
     */
    public ProductPage getFirstPage(ProductType type) {
        ProductPage firstPage = null;
        List<Product> products = null;
        Query query = new Query();

        try {
            products = paginateQuery(query, type, 1);
        } catch (CatalogException e) {
            LOG.log(Level.WARNING,
                    "CatalogException getting first page for product type: ["
                            + type.getProductTypeId()
                            + "] from catalog: Message: " + e.getMessage());
            return null;
        }

        if (products == null || (products != null && products.size() == 0)) {
            return firstPage;
        } else {
            // now construct the page
            firstPage = new ProductPage();
            firstPage.setPageNum(1);
            firstPage.setPageSize(pageSize);
            try {
                firstPage.setTotalPages(PaginationUtils.getTotalPage(
                        getNumHits(query, type), pageSize));
            } catch (Exception e) {
                LOG.log(Level.WARNING,
                        "Exception getting total pages for query: [" + query
                                + "]: Message: " + e.getMessage());
                firstPage.setTotalPages(-1);
            }

            firstPage.setPageProducts(products);

        }

        return firstPage;
    }
View Full Code Here

     * (non-Javadoc)
     *
     * @see org.apache.oodt.cas.filemgr.util.Pagination#getLastProductPage(org.apache.oodt.cas.filemgr.structs.ProductType)
     */
    public ProductPage getLastProductPage(ProductType type) {
        ProductPage lastPage = null;
        ProductPage firstPage = getFirstPage(type);
        List<Product> products = null;
        Query query = new Query();

        try {
            products = paginateQuery(query, type, firstPage.getTotalPages());
        } catch (CatalogException e) {
            LOG.log(Level.WARNING,
                    "CatalogException getting last page for product type: ["
                            + type.getProductTypeId()
                            + "] from catalog: Message: " + e.getMessage());
            return null;
        }

        if (products == null || (products != null && products.size() == 0)) {
            return lastPage;
        } else {
            // now construct the page
            lastPage = new ProductPage();
            lastPage.setPageNum(firstPage.getTotalPages());
            lastPage.setPageSize(pageSize);
            lastPage.setTotalPages(firstPage.getTotalPages());
            lastPage.setPageProducts(products);

        }

        return lastPage;
View Full Code Here

        if (currentPage.isLastPage()) {
            return currentPage;
        }

        List<Product> products = null;
        ProductPage nextPage = null;
        Query query = new Query();

        try {
            products = paginateQuery(query, type, currentPage.getPageNum() + 1);
        } catch (CatalogException e) {
            LOG.log(Level.WARNING,
                    "CatalogException getting next page for product type: ["
                            + type.getProductTypeId()
                            + "] from catalog: Message: " + e.getMessage());
            return null;
        }

        if (products == null || (products != null && products.size() == 0)) {
            return nextPage;
        } else {
            // now construct the page
            nextPage = new ProductPage();
            nextPage.setPageNum(currentPage.getPageNum() + 1);
            nextPage.setPageSize(pageSize);
            nextPage.setTotalPages(currentPage.getTotalPages());
            nextPage.setPageProducts(products);

        }

        return nextPage;
    }
View Full Code Here

        if (currentPage.isFirstPage()) {
            return currentPage;
        }
        List<Product> products = null;
        ProductPage prevPage = null;
        Query query = new Query();

        try {
            products = paginateQuery(query, type, currentPage.getPageNum() - 1);
        } catch (CatalogException e) {
            LOG.log(Level.WARNING,
                    "CatalogException getting prev page for product type: ["
                            + type.getProductTypeId()
                            + "] from catalog: Message: " + e.getMessage());
            return null;
        }

        if (products == null || (products != null && products.size() == 0)) {
            return prevPage;
        } else {
            // now construct the page
            prevPage = new ProductPage();
            prevPage.setPageNum(currentPage.getPageNum() - 1);
            prevPage.setPageSize(pageSize);
            prevPage.setTotalPages(currentPage.getTotalPages());
            prevPage.setPageProducts(products);

        }

        return prevPage;
    }
View Full Code Here

     *      org.apache.oodt.cas.filemgr.structs.ProductType, int)
     */
    public ProductPage pagedQuery(Query query, ProductType type, int pageNum)
            throws CatalogException {
        try {
            ProductPage retPage = new ProductPage();
            retPage.setPageNum(pageNum);
            retPage.setPageSize(pageSize);
            retPage.setTotalPages(PaginationUtils.getTotalPage(getNumHits(
                    query, type), pageSize));
            retPage.setPageProducts(paginateQuery(query, type, pageNum));
            return retPage;
        } catch (Exception e) {
            e.printStackTrace();
            LOG.log(Level.WARNING,
                    "CatalogException when doing paged product query: Message: "
View Full Code Here

         return pt;
      }

      @Override
      public ProductPage getFirstPage(ProductType pt) {
         ProductPage pp = new ProductPage();
         pp.setPageNum(PAGE_NUM);
         pp.setTotalPages(TOTAL_PAGES);
         pp.setPageSize(PAGE_SIZE);
         Product p1 = new Product();
         p1.setProductId(PRODUCT_ID_1);
         p1.setProductName(PRODUCT_NAME_1);
         p1.setProductType(pt);
         p1.setProductStructure(PRODUCT_STRUCTURE);
         p1.setTransferStatus(PRODUCT_STATUS);
         Product p2 = new Product();
         p2.setProductId(PRODUCT_ID_2);
         p2.setProductName(PRODUCT_NAME_2);
         p2.setProductType(pt);
         p2.setProductStructure(PRODUCT_STRUCTURE);
         p2.setTransferStatus(PRODUCT_STATUS);
         Product p3 = new Product();
         p3.setProductId(PRODUCT_ID_3);
         p3.setProductName(PRODUCT_NAME_3);
         p3.setProductType(pt);
         p3.setProductStructure(PRODUCT_STRUCTURE);
         p3.setTransferStatus(PRODUCT_STATUS);
         pp.setPageProducts(Lists.newArrayList(p1, p2, p3));
         return pp;
      }
View Full Code Here

         return pp;
      }

      @Override
      public ProductPage getNextPage(ProductType pt, ProductPage currentPage) {
         ProductPage pp = new ProductPage();
         pp.setPageNum(currentPage.getPageNum() + 1);
         pp.setTotalPages(currentPage.getTotalPages());
         pp.setPageSize(currentPage.getPageSize());
         Product p4 = new Product();
         p4.setProductId(PRODUCT_ID_4);
         p4.setProductName(PRODUCT_NAME_4);
         p4.setProductType(pt);
         p4.setProductStructure(PRODUCT_STRUCTURE);
         p4.setTransferStatus(PRODUCT_STATUS);
         pp.setPageProducts(Lists.newArrayList(p4));
         return pp;
      }
View Full Code Here

         return pt;
      }

      @Override
      public ProductPage getFirstPage(ProductType pt) {
         ProductPage pp = new ProductPage();
         pp.setPageNum(PAGE_NUM);
         pp.setTotalPages(TOTAL_PAGES);
         pp.setPageSize(PAGE_SIZE);
         Product p1 = new Product();
         p1.setProductId(PRODUCT_ID_1);
         p1.setProductName(PRODUCT_NAME_1);
         p1.setProductType(pt);
         p1.setProductStructure(PRODUCT_STRUCTURE);
         p1.setTransferStatus(PRODUCT_STATUS);
         Product p2 = new Product();
         p2.setProductId(PRODUCT_ID_2);
         p2.setProductName(PRODUCT_NAME_2);
         p2.setProductType(pt);
         p2.setProductStructure(PRODUCT_STRUCTURE);
         p2.setTransferStatus(PRODUCT_STATUS);
         Product p3 = new Product();
         p3.setProductId(PRODUCT_ID_3);
         p3.setProductName(PRODUCT_NAME_3);
         p3.setProductType(pt);
         p3.setProductStructure(PRODUCT_STRUCTURE);
         p3.setTransferStatus(PRODUCT_STATUS);
         pp.setPageProducts(Lists.newArrayList(p1, p2, p3));
         return pp;
      }
View Full Code Here

         return pp;
      }

      @Override
      public ProductPage getPrevPage(ProductType pt, ProductPage currentPage) {
         ProductPage pp = new ProductPage();
         pp.setPageNum(currentPage.getPageNum() - 1);
         pp.setTotalPages(currentPage.getTotalPages());
         pp.setPageSize(currentPage.getPageSize());
         Product p4 = new Product();
         p4.setProductId(PRODUCT_ID_4);
         p4.setProductName(PRODUCT_NAME_4);
         p4.setProductType(pt);
         p4.setProductStructure(PRODUCT_STRUCTURE);
         p4.setTransferStatus(PRODUCT_STATUS);
         pp.setPageProducts(Lists.newArrayList(p4));
         return pp;
      }
View Full Code Here

TOP

Related Classes of org.apache.oodt.cas.filemgr.structs.ProductPage

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.