/**
*
*/
package com.lgnortel.r4.r4equipment.management.olt.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;
import com.tailf.inm.INMException;
/**
* 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: QoSProfileComplexView.java<br>
* Description: <br>
* Copyright: Copyright(c) 2009 LG-NORTEL ALL Rights Reserved<br>
* Company: LG-Nortel<br>
*
* @author Jonghwa, Lee
* @version 0.1
* @created 2009. 4. 7.
* @modified 2009. 4. 7.
* @product EFA R4.0 EMS
* @sw_block Client Block
*/
public class QosWredProfileComplexView extends DefaultManagementView implements ManagementComplexControllerIF, ComplexViewParentIF {
/**
*
*/
private static final long serialVersionUID = -4228380548737392576L;
private ManagementComplexModelIF modelWredName;
private ManagementComplexModelIF modelWred;
private ComplexParentView pnlWredName;
private ComplexChildView pnlWred;
Object[] resultData;
private int viewId;
private int neId;
private ClientManager clientManager = ClientManager.getInstance();
private User user = User.getInstance();
public QosWredProfileComplexView(int neId, String title) throws INMException {
super();
this.neId = neId;
this.sTitle = title;
initialize();
}
@Override
protected JPanel createMainPanel() {
modelWredName = new QosWredProfileProfileNameModel();
modelWred = new QosWredProfileProfileModel();
pnlWredName = new ComplexParentView("WRED Profile Name", modelWredName, this);
pnlWred = new ComplexChildView("WRED Profile", modelWred);
JPanel panel = new JPanel();
panel.setLayout(new GridBagLayout());
panel.add(pnlWredName, new GridBagConstraints(1, 1, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(1, 1, 1, 1), 0, 0));
panel.add(pnlWred, 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 {
pnlWredName.checkTableValues();
pnlWred.checkTableValues();
msp = modelWredName.addTableInfoToMsp(msp, pnlWredName.getExecuteTableRows(), null);
msp = R4CommonUtil.getMspAddedTableInfo(msp, pnlWred.getChildrenInfo(), modelWred, pnlWredName.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);
resultData = data;
if (EmsCode.NETCONF_GET_CONFIG == cmdCode || EmsCode.NETCONF_GETFILTER_CONFIG == cmdCode) {
removeAllChildInfo();
pnlWredName.cmdResponse(viewId, userId, nodeId, cmdCode, data, result, errMessage);
arrangeTableInfo();
refreshComplexChildView(pnlWredName.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/qos/wred-profile MOs only
Msp filter = new Msp();
try {
filter.addQos().addWredProfile();
} catch (Exception e) {
logger.log(Level.SEVERE, "Exception", e);
}
return filter;
}
@Override
public String getHelpFilePath() {
return HelpTargetConst.R4_OLT_WREDPROFILE;
}
@Override
public void setViewId(int viewId) {
this.viewId = viewId;
}
@Override
public void removeAllChildInfo() {
pnlWred.removeAllTableInformation();
}
@Override
public void arrangeTableInfo() {
List<Map<String, Object>> keyRows = pnlWredName.getTableKeyRows();
for (Map<String, Object> keyRow : keyRows) {
this.saveResponseDataIntoTable(keyRow);
}
}
@Override
public void removeKey(Map<String, Object> key) {
pnlWred.removeChildTableOfKey(key);
pnlWred.saveAndRefreshTable(null, key);
}
@Override
public void refreshComplexChildView(Map<String, Object> key) {
if (key == null || key.isEmpty() || key.size() == 0) {
pnlWred.clearTable();
} else {
pnlWred.saveAndRefreshTable(resultData, key);
}
}
private void saveResponseDataIntoTable(Map<String, Object> key) {
if (key == null || key.isEmpty() || key.size() == 0) {
pnlWred.clearTable();
} else {
pnlWred.saveResponseDataIntoTable(resultData, key);
}
}
}
|