⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 adminsample.java

📁 噶额外噶外骨骼感广泛高热感 就 啊啊
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
  }
  /**
   * This method deletes the guestbook entries from the database. The mall
   * admin is having the privileges to delete the guestbook entries.
   *
   * @param guestId id of the guest book entery
   */
  protected void deleteGuestBook(String guestId) {

    Administration adminRemote = null;

    try {
      // Get the EJB Home 
      AdministrationHome adminHome =
        (AdministrationHome) ServiceLocator.getLocator().getService("Administration");

      // Get Remote Interface
      adminRemote = adminHome.create();

      // Execute the method to get the user profile.
      adminRemote.deleteGuestbookEntries(guestId);

      gui.putStatus("Successfully deleted the guestbook entry");

    } catch(Exception e) {
      gui.putStatus("Error in deleteting the guestbook entries:" +
                    e.getMessage());
    } finally {

      try {
        if(adminRemote != null) {
          adminRemote.remove();
        }
      } catch(Exception ex) {
        // do nothing
      }
    }
  }
  /**
   * This method contains the business logic of approving the shop request  by
   * the mall admin. Once the admin is having the privileges to delete  the
   * guestbook entries.
   *
   * @param shopId shop id
   * @param status status of the shop request
   * @param landId language id
   */
  protected void approveShop(String[] shopId, String[] status, String langId) {

    Administration adminRemote = null;

    try {
      // Get the EJB Home 
      AdministrationHome adminHome =
        (AdministrationHome) ServiceLocator.getLocator().getService("Administration");

      // Get Remote Interface
      adminRemote = adminHome.create();

      // Execute the method to get the user profile.
      adminRemote.manageShopRequests(shopId, status, langId);
      gui.putStatus("The selected shop is successfully " +
                    ("A".equals(status [ 0 ]) ? "approved" : "rejected"));

    } catch(Exception e) {
      gui.putStatus("Error in approving the shops: " + e.getMessage());
    } finally {

      try {
        if(adminRemote != null) {
          adminRemote.remove();
        }
      } catch(Exception ex) {

        // do nothing
      }
    }
  }
  /**
   * This method contains the business logic of fetching alla available
   * categories from the database abd display it to the the mall admin.
   */
  protected void displayCategories() {

    Administration adminRemote = null;

    try {
      // Get the EJB Home 
      AdministrationHome adminHome =
        (AdministrationHome) ServiceLocator.getLocator().getService("Administration");

      // Get Remote Interface
      adminRemote = adminHome.create();

      // Execute the method to get the user profile.
      Category[] maincat = adminRemote.getAllCategories("en");
      gui.catmodel.clearTable();

      for(int i = 0; i < maincat.length; i++) {

        ArrayList catData = new ArrayList();
        catData.add(maincat [ i ].getName());
        catData.add(maincat [ i ].getAttributes());
        catData.add(maincat [ i ].getId());
        gui.catmodel.insertRow(catData);
        gui.catTable.repaint();
      }
    } catch(Exception e) {
      gui.putStatus("Error in displaying the categories: " + e.getMessage());
    } finally {

      try {
        if(adminRemote != null) {
          adminRemote.remove();
        }
      } catch(Exception ex) {
        // do nothing
      }
    }
  }
  /**
   * This method contains the business logic of adding a new category to the
   * mall by the mall admin.
   *
   * @param CATID category id
   * @param item name of the item
   */
  protected void addCategory(String CATID, String[] item) {

    Administration adminRemote = null;

    try {
      // Populate the Category Object
      if(gui.catName.getText() == null || "".equals(gui.catName.getText())) {
        gui.putStatus("Please provide a name for the category");

        return;
      }

      Category cat = new Category(CATID, gui.catName.getText(), "en", item);

      // Get the EJB Home
      AdministrationHome adminHome =
        (AdministrationHome) ServiceLocator.getLocator().getService("Administration");

      // Get Remote Interface
      adminRemote = adminHome.create();

      // Execute the method to update the category
      adminRemote.addCategory(cat);

      ArrayList category = new ArrayList();
      category.add(gui.catName.getText());

      // refresh display
      gui.catName.setText("");
      gui.properties.removeAll();
      this.displayCategories();

      gui.putStatus("Successfully added the category ");

    } catch(Exception e) {
      gui.putStatus("Error in adding the category :" + e.getMessage());
    }
  }
  /**
   * This method contains the business logic of modyfying the existing category
   * in the shopping the mall by the mall admin.
   *
   * @param CATID category id
   * @param item name of the item
   */
  protected void modifyCategory(String CATID, String[] item) {

    Administration adminRemote = null;

    try {

      if(gui.catName.getText() == null || "".equals(gui.catName.getText())) {
        gui.putStatus("Please provide a name for the category");

        return;
      }

      if(CATID == null || "".equals(CATID)) {
        gui.putStatus("Please press the Add button");
        Toolkit.getDefaultToolkit().beep();

        return;
      }

      // Populate the Category Object
      Category cat = new Category(CATID, gui.catName.getText(), "en", item);

      // Get the EJB Home 
      AdministrationHome adminHome =
        (AdministrationHome) ServiceLocator.getLocator().getService("Administration");

      // Get Remote Interface
      adminRemote = adminHome.create();

      // Execute the method to update the category
      adminRemote.updateCategory(cat);

      this.displayCategories();

      gui.putStatus("Successfully updated the selected category ");

    } catch(Exception e) {
      gui.putStatus("Error in updating the category details: " +
                    e.getMessage());
    } finally {

      try {
        if(adminRemote != null) {
          adminRemote.remove();
        }
      } catch(Exception ex) {

        // do nothing
      }
    }
  }
  /**
   * This method contains the business logic of fetching alla available  shops
   * from the database abd display it to the the mall admin.
   */
  protected void displayShops() {

    Administration adminRemote = null;

    try {

      // Get the EJB Home 
      AdministrationHome adminHome =
        (AdministrationHome) ServiceLocator.getLocator().getService("Administration");

      // Get Remote Interface
      adminRemote = adminHome.create();

      // Execute the method to get the user profile.
      Shop[] shops = adminRemote.getPendingRequests("en");
      gui.shopmodel.clearTable();

      for(int i = 0; i < shops.length; i++) {

        ArrayList shopData = new ArrayList();
        shopData.add(shops [ i ].getUserName());
        shopData.add(shops [ i ].getRegDate());
        shopData.add("Pending");
        shopData.add(shops [ i ].getId());
        gui.shopmodel.insertRow(shopData);
        gui.shopTable.repaint();

      }
    } catch(Exception e) {
      gui.putStatus("Error in displaying the shop details :" + e.getMessage());
    } finally {
      try {
        if(adminRemote != null) {
          adminRemote.remove();
        }
      } catch(Exception ex) {
        // do nothing
      }
    }
  }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -