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

Android Open Source » App » learnandroid 
learnandroid » com » lgnortel » r4 » r4equipment » management » olt » ces » oper » OperCesInterfaceTdmModel.java
package com.lgnortel.r4.r4equipment.management.olt.ces.oper;

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

import org.w3c.dom.NamedNodeMap;

import com.lgnortel.lib.logger.LoggerUtil;
import com.lgnortel.netconf.DOM4Confspec;
import com.lgnortel.netconf.NetconfElementModel;
import com.lgnortel.netconf.wdmpon.InterfaceTdm;
import com.lgnortel.netconf.wdmpon.Msp;
import com.lgnortel.netconf.wdmpon.Oper;
import com.lgnortel.r4.r4equipment.common.ManagementComplexModelIF;
import com.lgnortel.r4.util.R4Constants;
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: IgmpGroupStatusModel<br>
 * Description: This is a class that GUI uses. And this is a class to set information of ONT port using Netconf interface and get it. <br>
 * Copyright: Copyright(c) 2009 LG-NORTEL ALL Rights Reserved<br>
 * Company: LG-Nortel<br>
 * 
 * @author Moongye, Oh
 * @version 0.1
 * @created 2009. 7. 1.
 * @modified 2009. 7. 1.
 * @product EFA R4.0 EMS
 * @sw_block
 */
public class OperCesInterfaceTdmModel implements ManagementComplexModelIF {
  
  // Log4J
  Logger logger = LoggerUtil.getInstance().getLogger(this.getClass().getName());

  // table name
  public static final String TABLE_NAME = "Show Interface TDM";

  // Syntax information
  String sMaxOccurs = null;

  /**
   * Constructor
   */
  public OperCesInterfaceTdmModel() {}

  /**
   * Reference : <elem[DOM tree node name] K[DOM tree attribute name]="K1"[DOM tree attribute value]...> 
   * 
   * @return table schema information
   */
  public List<NetconfElementModel> getTableSchema() {
    
    logger.info("getTableSchema()..");
    
    Vector<NetconfElementModel> columnInfo = new Vector<NetconfElementModel>();

    DOM4Confspec dom4Confspec = DOM4Confspec.getInstance();
        
    String[] fFdn = {"msp", "oper", "interface-tdm"};
    org.w3c.dom.Node fNode = dom4Confspec.findNode(fFdn);  
    if (fNode == null) {
      logger.warning("wdmpon.cs parsing error!");
      return null;
    }
    columnInfo = dom4Confspec.getComponentSchema(fNode.getChildNodes(), null, null);

    NamedNodeMap nnm = fNode.getAttributes(); 
    org.w3c.dom.Node fmNode = nnm.getNamedItem("maxOccurs");
    if (fmNode != null) {
      sMaxOccurs = fmNode.getNodeValue();
      logger.info("sMaxOccurs: " + sMaxOccurs);
    }
      
    return columnInfo;
  }

  /**
   * Get maxOccurs value for GUI table
   * 
   * @return maxOccurs value
   */
  public int getMaxOccurs() {

    int maxOccurs = 0;

    if (sMaxOccurs != null) {
      if (sMaxOccurs.equals(R4Constants.MAX_OCCURS_VALUE_UNBOUNDED)) {
        maxOccurs = Integer.MAX_VALUE;
      } else {
        maxOccurs = Integer.parseInt(sMaxOccurs);
      }
    }

    return maxOccurs;
  }
  
  /**
   * Make Filter from Msp MO
   * 
   * @return filter
   */
  public Element getFilter() {

    Msp filter = new Msp();
    try {
      filter.addOper().addInterfaceTdm();
    } catch (Exception e) {
      logger.log(Level.SEVERE, "Exception in getFilter()", e);
    }
    
    return filter;
  }

  /**
   * Convert Element into the form that can be used in Table Model
   * 
   * @param element: data to be filtered by GET request
   * @param keys: key to get a data among element argument
   *
   * @return table information for inquery
   */
  public Vector<Vector<Object>> makeTableInformation(Element element, Map<String, Object> keys) {

    logger.info("makeTableInformation()...");
    
    // Valuable for returning table information
    Vector<Vector<Object>> tblInfo = new Vector<Vector<Object>>();

    try {      
                  
      // Get a upper mo
      // NodeSet is leaf mo(attribute) list(one more) and element is mo or attribute(only one)
      Msp msp = (Msp) element;
      logger.fine("msp ==> \n" + msp.toXMLString());

      Oper oper = msp.oper;
      if (oper == null) {
        logger.info("No oper configuration..");
        return tblInfo;
      }
      
      ElementChildrenIterator interfaceTdmIteratorIt = oper.interfaceTdmIterator();
      while(interfaceTdmIteratorIt.hasNext()) {
        InterfaceTdm interfaceTdm  = (InterfaceTdm) interfaceTdmIteratorIt.next();
        Object jInterface = interfaceTdm.getJinterfaceValue();
        Object signal_format = R4Util.validateNullValue(interfaceTdm.getSignalFormatValue());
        Object framing = R4Util.validateNullValue(interfaceTdm.getFramingValue());
        Object line_encoding = R4Util.validateNullValue(interfaceTdm.getLineEncodingValue());
        Object disable = R4Util.validateNullValue(interfaceTdm.getDisableValue());
        Object link_state = R4Util.validateNullValue(interfaceTdm.getLinkStateValue());
        Object loopback = R4Util.validateNullValue(interfaceTdm.getLoopbackValue());
        Object link_alarm = R4Util.validateNullValue(interfaceTdm.getLinkAlarmValue());

        Vector<Object> tblRow = new Vector<Object>();
        tblRow.addElement(jInterface);
        tblRow.addElement(signal_format);
        tblRow.addElement(framing);
        tblRow.addElement(line_encoding);
        tblRow.addElement(disable);
        tblRow.addElement(link_state);
        tblRow.addElement(loopback);
        tblRow.addElement(link_alarm);
        tblInfo.addElement(tblRow);
      }
          
    } catch (Exception e) {
      logger.log(Level.SEVERE, "Exception in makeTableInformation()", e);
    }  
    
    return tblInfo;
  }

  /**
   * Construct MO tree & request 'NETCONF-AUDIT' command
   * 
   * @param msp: msp to include data of other tables 
   * @param rows: data to be existed in the table of GUI interface
   *
   * @return Msp MO tree for set command
   */
  public Msp addTableInfoToMsp(Msp msp, List<Map<String, Object>> rows, Map<String, Object> keys) {
    
    logger.info("PmEthernetStatisticsStatsModel addTableInfoToMsp(): only view..");
    
    return msp;
  }  
}
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.