/**
*
*/
package com.lgnortel.r4.r4equipment.management.olt.Interface.BundleEther;
import java.util.Hashtable;
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.BundleEtherVlanQos;
import com.lgnortel.netconf.wdmpon.Jinterface;
import com.lgnortel.netconf.wdmpon.JinterfaceBundleEther;
import com.lgnortel.netconf.wdmpon.JinterfaceBundleEtherVlan;
import com.lgnortel.netconf.wdmpon.Msp;
import com.lgnortel.platform.db.DBDataDesc;
import com.lgnortel.platform.db.DBManager;
import com.lgnortel.r4.r4equipment.common.ManagementComplexModelIF;
import com.lgnortel.r4.r4equipment.common.ParameterCheckException;
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: InterfaceBundleEtherVlanModel<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. 6. 25.
* @modified 2009. 6. 25.
* @product EFA R4.0 EMS
* @sw_block
*/
public class InterfaceBundleEtherVlanModel implements ManagementComplexModelIF {
// Log4J
Logger logger = LoggerUtil.getInstance().getLogger(this.getClass().getName());
public static final String TABLE_NAME = "Interface Bundle-Ether Vlan";
// Node ID
private int nodeId = -1;
// Syntax information
String sMaxOccurs = null;
// Column Definition
private String COLUMN_NAME_BUNDLE_ETHER_ID = "bundle-id"; // BundleEther table's key
private String COLUMN_NAME_VLAN = "vlan";
private String COLUMN_NAME_VID = "vid";
private String COLUMN_NAME_MIRROR = "mirror";
private String COLUMN_NAME_FILTER_POLICY_INPUT = "filter-policy-input";
private String COLUMN_NAME_FILTER_POLICY_OUTPUT = "filter-policy-output";
private String COLUMN_NAME_SERVICE_POLICY_INPUT = "service-policy-input";
/**
* Constructor
*
* @param neId
*/
public InterfaceBundleEtherVlanModel(int nodeId) {
this.nodeId = nodeId;
}
/**
* Return table schema information
*/
public List<NetconfElementModel> getTableSchema() {
Vector<NetconfElementModel> columnInfo = new Vector<NetconfElementModel>();
// Locate "msp/interface/Ethernet" Node in the DOM tree of wdmpon.cs
DOM4Confspec dom4Confspec = DOM4Confspec.getInstance();
String[] fdn = {"msp", "interface", "Bundle-Ether", "vlan"};
org.w3c.dom.Node node = dom4Confspec.findNode(fdn);
if (node == null) {
logger.warning("wdmpon.cs parsing error!");
return null;
}
// extract and save 'maxOccurs' value for getMaxOccurs()
NamedNodeMap nnm = node.getAttributes();
org.w3c.dom.Node itemNode = nnm.getNamedItem("maxOccurs");
if (itemNode != null) {
sMaxOccurs = itemNode.getNodeValue();
logger.info("sMaxOccurs: " + sMaxOccurs);
}
// Retrieve all attributes of Ethernet component
columnInfo = dom4Confspec.getComponentSchema(node.getChildNodes());
// fetch attribute info under qos
String[] qosFdn = {"msp", "interface", "Bundle-Ether", "vlan", "qos"};
org.w3c.dom.Node qosNode = dom4Confspec.findNode(qosFdn);
Vector<NetconfElementModel> qosColumnInfo = dom4Confspec.getComponentSchema(qosNode.getChildNodes());
// Retrieve profile name list from DB
DBManager dbManager = DBManager.getInstance();
Hashtable<String, Vector<String>> aclTypeValue = dbManager.getNEProfileList(nodeId, DBDataDesc.OLT_QOS_ACCESSLIST_TYPE);
Hashtable<String, Vector<String>> classifierTypeValue = dbManager.getNEProfileList(nodeId, DBDataDesc.OLT_QOS_CLASSIFIER_TYPE);
// change column name and width
for (NetconfElementModel qosNem : qosColumnInfo) {
if (qosNem.getElementName().equals(COLUMN_NAME_FILTER_POLICY_INPUT)) {
qosNem.setColWidth(110);
if (aclTypeValue.get("ENUMERATION").size() > 1) {
qosNem.setTypeValue(aclTypeValue);
}
} else if (qosNem.getElementName().equals(COLUMN_NAME_FILTER_POLICY_OUTPUT)) {
qosNem.setColWidth(110);
if (aclTypeValue.get("ENUMERATION").size() > 1) {
qosNem.setTypeValue(aclTypeValue);
}
} else if (qosNem.getElementName().equals(COLUMN_NAME_SERVICE_POLICY_INPUT)) {
qosNem.setColWidth(110);
if (classifierTypeValue.get("ENUMERATION").size() > 1) {
qosNem.setTypeValue(classifierTypeValue);
}
}
}
// columnInfo += qosColumnInfo
for (int i=0; i<qosColumnInfo.size(); i++) {
columnInfo.addElement(qosColumnInfo.get(i));
}
return columnInfo;
}
/**
* Return maxOccurs value of msp/interface/Bundle-Ether/vlan Component
*/
public int getMaxOccurs() {
int maxOccurs = 1;
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
*/
public Element getFilter() {
Msp filter = new Msp();
try {
filter.addJinterface().addBundleEther().addVlan();
} catch (Exception e) {
logger.log(Level.SEVERE, "Exception", e);
}
return filter;
}
/**
* Convert Element into the form that can be used in Table Model
* =================================================================================================
* vlan mirror filter-policy-input filter-policy-output service-policy-input
* xs:int mirror-dir-type xs:string xs:string xs:string
* -------------------------------------------------------------------------------------------------
* 1 input default default default
* 2 output default default default
* 3 bidirectional default default default
* =================================================================================================
*/
public Vector<Vector<Object>> makeTableInformation(Element element, Map<String, Object> keys) {
// save parent MO's key
Object bundleEtherId = keys.get(COLUMN_NAME_BUNDLE_ETHER_ID);
if (bundleEtherId == null) {
logger.warning("makeTableInformation().. error in keys.. there should be '" + COLUMN_NAME_BUNDLE_ETHER_ID + "' key!");
return null;
}
logger.info("makeTableInformation() under msp/interface/Bundle-Ether['" + bundleEtherId + "']..");
// return value
Vector<Vector<Object>> tblInfo = new Vector<Vector<Object>>();
try {
// Locate msp/interface/Bundle-Ether MO
Msp msp = (Msp) element;
Jinterface mspIf = msp.jinterface;
if (mspIf == null) {
logger.info("No interface configuration..");
return tblInfo;
}
JinterfaceBundleEther bundleEther = null;
try {
bundleEther = mspIf.getBundleEther(bundleEtherId.toString());
} catch (Exception e) {
logger.info("No interface/Bundle-Ether['" + bundleEtherId + "'] configuration..");
return tblInfo;
}
// Get vlan MO list from Bundle-Ether MO
ElementChildrenIterator vlanIt = bundleEther.vlanIterator();
while (vlanIt.hasNext()) {
// vlan MO
JinterfaceBundleEtherVlan bundleEtherVlan = (JinterfaceBundleEtherVlan) vlanIt.next();
// Extract attribute value
Object vlan = R4Util.validateNullValue(bundleEtherVlan.getVlanValue());
Object vid = R4Util.validateNullValue(bundleEtherVlan.getVidValue());
Object mirror = R4Util.validateNullValue(bundleEtherVlan.getMirrorValue());
Object filterPolicyInput = "", filterPolicyOutput = "", servicePolicyInput = "";
if (bundleEtherVlan.qos != null) {
filterPolicyInput = R4Util.validateNullValue(bundleEtherVlan.qos.getFilterPolicyInputValue());
filterPolicyOutput = R4Util.validateNullValue(bundleEtherVlan.qos.getFilterPolicyOutputValue());
servicePolicyInput = R4Util.validateNullValue(bundleEtherVlan.qos.getServicePolicyInputValue());
}
// make results
Vector<Object> tblRow = new Vector<Object>();
tblRow.addElement(vlan);
tblRow.addElement(vid);
tblRow.addElement(mirror);
tblRow.addElement(filterPolicyInput);
tblRow.addElement(filterPolicyOutput);
tblRow.addElement(servicePolicyInput);
// add a row into the table
tblInfo.addElement(tblRow);
}
} catch (Exception e) {
logger.log(Level.SEVERE, "Exception", e);
}
// return table information
return tblInfo;
}
/**
* Construct MO tree & request 'NETCONF-AUDIT' command
* =================================================================================================
* vlan mirror filter-policy-input filter-policy-output service-policy-input
* xs:int mirror-dir-type xs:string xs:string xs:string
* -------------------------------------------------------------------------------------------------
* 1 input default default default
* 2 output default default default
* 3 bidirectional default default default
* =================================================================================================
* @throws ParameterCheckException
*/
public Msp addTableInfoToMsp(Msp msp, List<Map<String, Object>> rows, Map<String, Object> keys) throws ParameterCheckException {
// save parent MO's key
Object bundleEtherId = keys.get(COLUMN_NAME_BUNDLE_ETHER_ID);
if (bundleEtherId == null) {
logger.warning("addTableInfoToMsp().. error in keys.. there should be '" + COLUMN_NAME_BUNDLE_ETHER_ID + "' key!");
return null;
}
try {
// Locate msp/interface/Bundle-Ether MO
Jinterface mspIf = msp.jinterface;
if (mspIf == null) {
logger.info("No interface configuration..");
mspIf = new Jinterface();
msp.addJinterface(mspIf);
}
JinterfaceBundleEther bundleEther = null;
try {
bundleEther = mspIf.getBundleEther(bundleEtherId.toString());
} catch (Exception e) {
logger.info("No interface/Bundle-Ether['" + bundleEtherId + "'] configuration..");
bundleEther = new JinterfaceBundleEther(bundleEtherId.toString());
mspIf.addBundleEther(bundleEther);
}
for (int i=0; i<rows.size(); i++) {
Map<String, Object> oneRow = rows.get(i);
// save input argument(oneRow) into variables
String vlan = oneRow.get(COLUMN_NAME_VLAN).toString();
String vid = oneRow.get(COLUMN_NAME_VID).toString();
String mirror = oneRow.get(COLUMN_NAME_MIRROR).toString();
String filterPolicyInput = oneRow.get(COLUMN_NAME_FILTER_POLICY_INPUT).toString();
String filterPolicyOutput = oneRow.get(COLUMN_NAME_FILTER_POLICY_OUTPUT).toString();
String servicePolicyInput = oneRow.get(COLUMN_NAME_SERVICE_POLICY_INPUT).toString();
// Make vlan instance
JinterfaceBundleEtherVlan bundleEtherVlan = new JinterfaceBundleEtherVlan(vlan);
if (R4Util.isExistingField(mirror)) {
bundleEtherVlan.setMirrorValue(mirror);
}
if (R4Util.isExistingField(vid)) {
bundleEtherVlan.setVidValue(vid);
}
if (R4Util.isExistingField(filterPolicyInput)
|| R4Util.isExistingField(filterPolicyOutput)
|| R4Util.isExistingField(servicePolicyInput)) {
BundleEtherVlanQos qos = new BundleEtherVlanQos();
if (R4Util.isExistingField(filterPolicyInput)) {
qos.setFilterPolicyInputValue(filterPolicyInput);
}
if (R4Util.isExistingField(filterPolicyOutput)) {
qos.setFilterPolicyOutputValue(filterPolicyOutput);
}
if (R4Util.isExistingField(servicePolicyInput)) {
qos.setServicePolicyInputValue(servicePolicyInput);
}
bundleEtherVlan.addQos(qos);
}
// attach it under parent
bundleEther.addVlan(bundleEtherVlan);
}
} catch (Exception e) {
logger.log(Level.SEVERE, "Exception in set()", e);
throw new ParameterCheckException("Parameter Check Error", "Parameter Check Error");
}
logger.fine("config ==> \n" + msp.toXMLString());
return msp;
}
}
|