QosAccessListComplexView.java :  » App » learnandroid » com » lgnortel » r4 » r4equipment » management » ont » qos » Android Open Source

Android Open Source » App » learnandroid 
learnandroid » com » lgnortel » r4 » r4equipment » management » ont » qos » QosAccessListComplexView.java
/**
 * 
 */
package com.lgnortel.r4.r4equipment.management.ont.qos;

import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.util.List;
import java.util.Map;
import java.util.logging.Level;

import javax.swing.JPanel;

import com.lgnortel.lib.help.HelpTargetConst;
import com.lgnortel.netconf.wdmpon.Msp;
import com.lgnortel.network.networkview.ErrorInspect;
import com.lgnortel.network.networkview.User;
import com.lgnortel.r4.r4equipment.common.ComplexChildView;
import com.lgnortel.r4.r4equipment.common.ComplexParentView;
import com.lgnortel.r4.r4equipment.common.ComplexViewParentIF;
import com.lgnortel.r4.r4equipment.common.DefaultManagementView;
import com.lgnortel.r4.r4equipment.common.DuplicateKeyException;
import com.lgnortel.r4.r4equipment.common.ManagementComplexControllerIF;
import com.lgnortel.r4.r4equipment.common.ManagementComplexModelIF;
import com.lgnortel.r4.r4equipment.common.R4CommonUtil;
import com.lgnortel.r4.r4equipment.common.WrongParameterException;
import com.lgnortel.rmi.common.ClientManager;
import com.lgnortel.rmi.common.EmsCode;

/**
 * Copyright (c) 2008 LG-Nortel, Inc. All Rights Reserved.
 * 
 * CONFIDENTIALITY AND LIMITED USE: This software, including any software of <br>
 * third parties embodied herein, contains code, information, data and concepts <br>
 * which are confidential and/or proprietary to LG-Nortel and such third <br>
 * parties. This software is licensed for use solely in accordance with the <br>
 * terms and conditions of the applicable license agreement with LG-Nortel or <br>
 * its authorized distributor, and not for any other use or purpose. No <br>
 * redistribution of this software by any party is permitted. <br>
 * 
 * Title: QoSClassifierComplexView.java<br>
 * Description: This class display QoS Classifier View.<br>
 * Copyright: Copyright(c) 2009 LG-NORTEL ALL Rights Reserved<br>
 * Company: LG-Nortel<br>
 * 
 * @author Jonghwa, Lee
 * @version 0.1
 * @created 2009. 4. 3.
 * @modified 2009. 4. 3.
 * @product EFA R4.0 EMS
 * @sw_block Client Block
 */
public class QosAccessListComplexView extends DefaultManagementView implements ManagementComplexControllerIF, ComplexViewParentIF {
  /**
   * 
   */
  private static final long serialVersionUID = 9111791937866718694L;

  private ManagementComplexModelIF modelAclName;
  private ManagementComplexModelIF modelAccessList;

  private ComplexParentView pnlAclName;
  private ComplexChildView pnlAcl;

  Object[] resultData;

  private int viewId;
  private int neId;

  private ClientManager clientManager = ClientManager.getInstance();
  private User user = User.getInstance();

  public QosAccessListComplexView(int neId, String title) {
    super();
    this.neId = neId;
    this.sTitle = title;
    initialize();
  }

  @Override
  protected JPanel createMainPanel() {
    modelAclName = new QosAccessListNameModel();
    modelAccessList = new QosAccessListModel();

    pnlAclName = new ComplexParentView("ONT Access List Name", modelAclName, this);
    pnlAcl = new ComplexChildView("ONT Access List", modelAccessList);

    JPanel panel = new JPanel();
    panel.setLayout(new GridBagLayout());
    panel.add(pnlAclName, new GridBagConstraints(1, 1, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(1, 1, 1, 1), 0, 0));
    panel.add(pnlAcl, new GridBagConstraints(1, 2, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(1, 1, 1, 1), 0, 0));

    return panel;
  }

  @Override
  /*
   * Request 'NETCONF-GETFILTER' command
   */
  public void get() {
    Msp filter = getFilter();

    // make argument for 'NETCONF-GETFILTER' command
    Object[] data = new Object[1];
    data[0] = filter;
    clientManager.cmdRequest(viewId, user.getUserId(), neId, 0, EmsCode.NETCONF_GETFILTER_CONFIG, data, "");
  }

  @Override
  protected void set() {
    Msp msp = new Msp();
    try {
      pnlAclName.checkTableValues();
      pnlAcl.checkTableValues();

      msp = modelAclName.addTableInfoToMsp(msp, pnlAclName.getExecuteTableRows(), null);
      msp = R4CommonUtil.getMspAddedTableInfo(msp, pnlAcl.getChildrenInfo(), modelAccessList, pnlAclName.getTableKeyRows());

      if (R4CommonUtil.displayQuestionDialog(this, sTitle, "Do you want to execute?")) {
        this.set(msp);
      }
    } catch (WrongParameterException we) {
      R4CommonUtil.displayConfirmDialog(this, sTitle, we.getDisplayMessage());
      logger.info("Parameter value is wrong !! " + we.getMessage());
    } catch (DuplicateKeyException dc) {
      R4CommonUtil.displayConfirmDialog(this, sTitle, dc.getDisplayMessage());
      logger.info("Duplicated key exists !! : " + dc.getMessage());
    } catch (Exception e) {
      R4CommonUtil.displayConfirmDialog(this, sTitle, "Internal Error!");
      logger.log(Level.SEVERE, "Execute failed!", e);
    }
  }

  @Override
  public void set(Msp msp) {
    Msp filter = getFilter();

    // make argument for 'NETCONF-AUDIT' command
    Object[] data = new Object[2];
    data[0] = filter;
    data[1] = msp;
    clientManager.cmdRequest(viewId, user.getUserId(), neId, 0, EmsCode.NETCONF_AUDIT, data, "");
  }

  @Override
  public boolean cmdResponse(int viewId, int userId, int nodeId, int cmdCode, Object[] data, int result, String errMessage) {
    pnlResult.updateMessage(errMessage);
    if (EmsCode.NETCONF_GET_CONFIG == cmdCode || EmsCode.NETCONF_GETFILTER_CONFIG == cmdCode) {
      resultData = data;
      removeAllChildInfo();
      pnlAclName.cmdResponse(viewId, userId, nodeId, cmdCode, data, result, errMessage);
      arrangeTableInfo();
      refreshComplexChildView(pnlAclName.getSelectedRowKey());
    } else if ((EmsCode.NETCONF_DELETE == cmdCode || EmsCode.NETCONF_EDIT == cmdCode) || EmsCode.NETCONF_AUDIT == cmdCode) {
      if (ErrorInspect.SUCCESS == result) {
        get();
      }
    }

    return true;
  }

  public Msp getFilter() {

    // construct filter to retrieve msp/pon-access/qos/access-list MOs only
    Msp filter = new Msp();
    try {
      filter.addPonAccess().addQos().addAccessList();
    } catch (Exception e) {
      logger.log(Level.SEVERE, "Exception", e);
    }

    return filter;
  }

  @Override
  public String getHelpFilePath() {
    return HelpTargetConst.R4_ONT_ACCESS_LIST;
  }

  @Override
  public void setViewId(int viewId) {
    this.viewId = viewId;
  }

  @Override
  public void removeAllChildInfo() {
    pnlAcl.removeAllTableInformation();
  }

  @Override
  public void arrangeTableInfo() {
    List<Map<String, Object>> keyRows = pnlAclName.getTableKeyRows();
    for (Map<String, Object> keyRow : keyRows) {
      this.saveResponseDataIntoTable(keyRow);
    }
  }

  @Override
  public void removeKey(Map<String, Object> key) {
    pnlAcl.removeChildTableOfKey(key);
    pnlAcl.saveAndRefreshTable(null, key);
  }

  @Override
  public void refreshComplexChildView(Map<String, Object> key) {
    if (R4CommonUtil.isEmptyMap(key)) {
      pnlAcl.clearTable();
    } else {
      pnlAcl.saveAndRefreshTable(resultData, key);
    }
  }

  private void saveResponseDataIntoTable(Map<String, Object> key) {
    if (R4CommonUtil.isEmptyMap(key)) {
      pnlAcl.clearTable();
    } else {
      pnlAcl.saveResponseDataIntoTable(resultData, key);
    }
  }
}
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.