OperInterfaceVlanQosSpEthernetModel.java :  » App » learnandroid » com » lgnortel » r4 » r4equipment » management » olt » qos » oper » Android Open Source

Android Open Source » App » learnandroid 
learnandroid » com » lgnortel » r4 » r4equipment » management » olt » qos » oper » OperInterfaceVlanQosSpEthernetModel.java
/**
 * 
 */
package com.lgnortel.r4.r4equipment.management.olt.qos.oper;

import java.util.List;
import java.util.Map;
import java.util.Vector;
import java.util.logging.Level;
import java.util.logging.Logger;

import com.lgnortel.lib.logger.LoggerUtil;
import com.lgnortel.netconf.DOM4Confspec;
import com.lgnortel.netconf.NetconfElementModel;
import com.lgnortel.netconf.wdmpon.EthernetVlan;
import com.lgnortel.netconf.wdmpon.InterfaceVlanQosSp;
import com.lgnortel.netconf.wdmpon.InterfaceVlanQosSpEthernet;
import com.lgnortel.netconf.wdmpon.Msp;
import com.lgnortel.netconf.wdmpon.Oper;
import com.lgnortel.r4.r4equipment.common.ManagementTableIF;
import com.lgnortel.r4.util.R4Util;
import com.tailf.inm.Element;
import com.tailf.inm.ElementChildrenIterator;

/**
 * Copyright (c) 2009 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: InterfaceEthernetStatusModel<br>
 * Description: <br>
 * Copyright: Copyright(c) 2009 LG-NORTEL ALL Rights Reserved<br>
 * Company: LG-Nortel<br>
 * 
 * @author Sungill, Kim
 * @version 0.1
 * @created 2009. 9. 04.
 * @modified 2009. 9. 04.
 * @product EFA R4.0 EMS
 * @sw_block
 */
public class OperInterfaceVlanQosSpEthernetModel implements ManagementTableIF {

  // Log4J
  Logger logger = LoggerUtil.getInstance().getLogger(this.getClass().getName());

  // table name
  public static final String TABLE_NAME = "Oper Interface VLAN QoS SP Ethernet";

  // Syntax information
  String sMaxOccurs = null;

  // Column Definition
//  private String COLUMN_NAME_INTERFACE = "interface"; // key
//  private String COLUMN_NAME_VLAN = "vlan"; // key
//  private String COLUMN_NAME_INPUT = "input";
//  private String COLUMN_NAME_NAME = "name";
  private String COLUMN_NAME_COLOR_AWARE = "color-*aware";
  private String COLUMN_NAME_PERMIT_PACKETS = "permit-*packets";
  private String COLUMN_NAME_PERMIT_BYTES = "permit-*bytes";
  private String COLUMN_NAME_DISCARD_PACKETS = "discard-*packets";
  private String COLUMN_NAME_DISCARD_BYTES = "discard-*bytes";
//  ...


  /**
   * Return table schema information
   */
  public List<NetconfElementModel> getTableSchema() {

    Vector<NetconfElementModel> columnInfo = new Vector<NetconfElementModel>();

    // 1. Locate "msp/oper/interface-qos-sp/Ethernet" Node in the DOM tree of wdmpon.cs
    DOM4Confspec dom4Confspec = DOM4Confspec.getInstance();
    String[] fdn = {"msp", "oper", "interface-vlan-qos-sp", "Ethernet"};
    org.w3c.dom.Node node = dom4Confspec.findNode(fdn);
    if (node == null) {
      logger.warning("wdmpon.cs parsing error!");
      return null;
    }

    // 2. Extract leaf nodes' attribute information with 'type' attribute
    columnInfo = dom4Confspec.getComponentSchema(node.getChildNodes());

    // Retrieve attributes under vlan component
    String[] entryFdn = {"msp", "oper", "interface-vlan-qos-sp", "Ethernet", "vlan"};
    org.w3c.dom.Node entryNode = dom4Confspec.findNode(entryFdn);
    Vector<NetconfElementModel> entryColumnInfo = dom4Confspec.getComponentSchema(entryNode.getChildNodes());

    // change column name and width
    for (NetconfElementModel oneNem : entryColumnInfo) {
      if (oneNem.getElementName().equals("color-aware")) {
        oneNem.setElementName(COLUMN_NAME_COLOR_AWARE);
        oneNem.setColWidth(60);
      } else if (oneNem.getElementName().equals("permit-packets")) {
        oneNem.setElementName(COLUMN_NAME_PERMIT_PACKETS);
        oneNem.setColWidth(60);
      } else if (oneNem.getElementName().equals("permit-bytes")) {
        oneNem.setElementName(COLUMN_NAME_PERMIT_BYTES);
        oneNem.setColWidth(60);
      } else if (oneNem.getElementName().equals("discard-packets")) {
        oneNem.setElementName(COLUMN_NAME_DISCARD_PACKETS);
        oneNem.setColWidth(60);
      } else if (oneNem.getElementName().equals("discard-bytes")) {
        oneNem.setElementName(COLUMN_NAME_DISCARD_BYTES);
        oneNem.setColWidth(60);
      }
    }

    for (int i=0; i<entryColumnInfo.size(); i++) {
      columnInfo.add(entryColumnInfo.get(i));
    }

    return columnInfo;
  }

  /**
   * Return maxOccurs value of msp/oper/interface-vlan-qos-sp/Ethernet Component
   */
  public int getMaxOccurs() {

    return 0;
  }

  /**
   * Convert Element into the form that can be used in Table Model
   * ================================================================
   * interface  vlan   input      name    seq-no  matches
   * xs:string  xs:int  xs:string    xs:string  xs:int  xs:int
   * ----------------------------------------------------------------
   * 1/1/1    1    io1        acl1    1    1
   * 1/1/2    2    io2        acl2    2    2
   * 1/1/3    3    io3        acl3    3    3
   * ================================================================
   */
  public Vector<Vector<Object>> makeTableInformation(Element element, Map<String, Object> keys) {

    logger.info("makeTableInformation()..");

    // return value
    Vector<Vector<Object>> tblInfo = new Vector<Vector<Object>>();

    try {
      // Locate msp/oper MO
      Msp msp = (Msp) element;
      Oper oper = msp.oper;
      if (oper == null) {
        logger.info("No msp/oper status..");
        return tblInfo;
      }
      InterfaceVlanQosSp ifVlanQosSp= oper.interfaceVlanQosSp;
      if (ifVlanQosSp == null) {
        logger.info("No msp/oper/interface-vlan-qos-sp status..");
        return tblInfo;
      }

      // Retrieve children MO list
      ElementChildrenIterator ethernetIt = ifVlanQosSp.ethernetIterator();
      while (ethernetIt.hasNext()) {
        // msp/oper/interface-vlan-qos-sp/Ethernet MO
        InterfaceVlanQosSpEthernet ethernet = (InterfaceVlanQosSpEthernet) ethernetIt.next();

        // extract attribute value
        Object ifName = ethernet.getJinterfaceValue();
        ElementChildrenIterator vlanIt = ethernet.vlanIterator();
        while (vlanIt.hasNext()) {
          // oper/interface-vlan-qos-sp/Ethernet/vlan
          EthernetVlan vlan = (EthernetVlan) vlanIt.next();

          Object vlanId = vlan.getVlanValue();
          Object input = R4Util.validateNullValue(vlan.getInputValue());
          Object name = R4Util.validateNullValue(vlan.getNameValue());
          Object algorithm = R4Util.validateNullValue(vlan.getAlgorithmValue());
          Object colorAware = R4Util.validateNullValue(vlan.getColorAwareValue());
          Object cir = R4Util.validateNullValue(vlan.getCirValue());
          Object cbs = R4Util.validateNullValue(vlan.getCbsValue());
          Object eir = R4Util.validateNullValue(vlan.getEirValue());
          Object ebs = R4Util.validateNullValue(vlan.getEbsValue());
          Object permitPackets = R4Util.validateNullValue(vlan.getPermitPacketsValue());
          Object permitBytes = R4Util.validateNullValue(vlan.getPermitBytesValue());
          Object discardPackets = R4Util.validateNullValue(vlan.getDiscardPacketsValue());
          Object discardBytes = R4Util.validateNullValue(vlan.getDiscardBytesValue());

          // Make a row
          Vector<Object> tblRow = new Vector<Object>();
          tblRow.addElement(ifName);
          tblRow.addElement(vlanId);
          tblRow.addElement(input);
          tblRow.addElement(name);
          tblRow.addElement(algorithm);
          tblRow.addElement(colorAware);
          tblRow.addElement(cir);
          tblRow.addElement(cbs);
          tblRow.addElement(eir);
          tblRow.addElement(ebs);
          tblRow.addElement(permitPackets);
          tblRow.addElement(permitBytes);
          tblRow.addElement(discardPackets);
          tblRow.addElement(discardBytes);

          // add a row into the table
          tblInfo.addElement(tblRow);  
        }
      }
    } catch (Exception e) {
      logger.log(Level.SEVERE, "Exception in makeTableInformation()", e);
    }

    // return table information
    return tblInfo;
  }
}
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.