-
-
Save magcius/860966c4a66cda39de6b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.verizon.dtix.webapp.webintfc; | |
import java.util.ArrayList; | |
import java.util.HashMap; | |
import java.util.HashSet; | |
import java.util.Iterator; | |
import java.util.LinkedHashMap; | |
import java.util.List; | |
import java.util.Properties; | |
import java.util.Set; | |
import java.util.Vector; | |
import javax.servlet.http.HttpServletRequest; | |
import org.apache.log4j.Logger; | |
import org.json.simple.JSONArray; | |
import org.json.simple.JSONObject; | |
import bsh.EvalError; | |
import bsh.Interpreter; | |
import com.verizon.dtix.fancyhash.FancyHash; | |
import com.verizon.dtix.mw.custinfo.CktDesign; | |
import com.verizon.dtix.webapp.DtixUtils; | |
import com.verizon.dtix.webapp.DtixWebConstants; | |
import com.verizon.dtix.webapp.Result; | |
import com.verizon.dtix.webapp.SessionHelper; | |
import com.verizon.dtix.webapp.circuitinfo.ElementAttributeConfig; | |
import com.verizon.dtix.webapp.circuitinfo.ElementAttributeInfo; | |
import com.verizon.dtix.webapp.config.DtixConfigMgr; | |
import com.verizon.dtix.webapp.config.DtixConfigUtils; | |
import com.verizon.dtix.webapp.config.WAConfig; | |
import com.verizon.dtix.webapp.mwintfc.MWIntfcCircuitInfoHandler; | |
import com.verizon.dtix.webapp.sessionmgmt.SessionDataObject; | |
import com.verizon.dtix.xmldecoder.XmlDecoder; | |
public class SpecialsSvcInfoDataBlockPrep implements SvcInfoDataBlockDomainInterface{ | |
private static Logger _logger = Logger.getLogger(SpecialsSvcInfoDataBlockPrep.class.getName()); | |
private static HashMap<String,String> siteIconMap; | |
private LinkedHashMap<String,ArrayList> siteGroups = new LinkedHashMap<String,ArrayList>(); | |
private HashMap<String,Integer> elementCount = new HashMap<String,Integer>(); | |
private HashMap<String,Integer> siteCount = new HashMap<String,Integer>(); | |
private ArrayList<String> siteElements = new ArrayList<String>(); | |
private ArrayList<String> cktElements = new ArrayList<String>(); | |
private ArrayList<String> listOfSites = new ArrayList<String>(); | |
private ArrayList<ElementAttributeInfo> attributesList = new ArrayList<ElementAttributeInfo>(); | |
private ArrayList<ElementAttributeInfo> elementAttributes; | |
private HashMap<String,String> cktSiteGroupInfo = new HashMap<String,String>(); | |
private LinkedHashMap<String,String> attributesInfo; | |
private HashMap<String,String> iconLabelInfo; | |
private LinkedHashMap<String,LinkedHashMap> elementAttributesInfo = new LinkedHashMap<String,LinkedHashMap>(); | |
private HashMap<String,HashMap> elementIconLabelInfo = new HashMap<String,HashMap>(); | |
private HashMap<String,String> linkInfoAttributes; | |
private HashMap<String,String> endpoint1Attributes; | |
private HashMap<String,String> endpoint2Attributes; | |
private HashMap<String,String> connectorMiscAttributes; | |
private LinkedHashMap<String,String> equipmentMiscAttributes; | |
private LinkedHashMap<String,String> siteMiscAttributes; | |
private HashMap<String,String> siteIcons = new HashMap<String,String>(); | |
private String ringId= ""; | |
private HashMap<String,String> elementClass = new HashMap<String,String>(); | |
private HashMap<String,String> iconTag = new HashMap<String,String>(); | |
private HashMap<String,String> iconLabel = new HashMap<String,String>(); | |
private XmlDecoder xmlDecoder = new XmlDecoder(); | |
private HttpServletRequest request = null; | |
private String siteCktId = ""; | |
private boolean bInterSite = false; | |
private boolean bLastLink = false; | |
private boolean bLastElement = false; | |
private boolean bSiteNotAdded = false; | |
private boolean bIsDxc = false; | |
private StringBuffer svcInfo = null; | |
private SessionDataObject sObj = null; | |
private String linkType = ""; | |
private String parseableTID = ""; | |
private String parseableAID = ""; | |
private StringBuffer xConnectLabel = null; | |
private String prevLinkType = ""; | |
private String xConnectFrom = ""; | |
private String xConnectTo = ""; | |
private String xConnectLevel = ""; | |
private StringBuffer attributePath = null; | |
private StringBuffer connectorAttribute = null; | |
private StringBuffer connectorLabel = null; | |
private String testTimeStamp = ""; | |
private String cktId = ""; | |
private boolean bIsXConnectDXC = false; | |
private String siteIcon = ""; | |
private String ccmReference = ""; | |
private String altCcmRef = ""; | |
private String nextLinkType = ""; | |
private boolean bIsRingRoute = false; | |
private boolean bIsCable = false; | |
private boolean bMultiXConnectFromRef = false; | |
private boolean bMultiXConnectToRef = false; | |
private String firstRingRoute = ""; | |
private String firstCable = ""; | |
private String rateCode = ""; | |
private LinkedHashMap<String,String> portDetails ; | |
private ArrayList<LinkedHashMap<String,String>> portDetailsList; | |
private HashMap<String,ArrayList<LinkedHashMap<String,String>>> aidInfoMap = new HashMap<String,ArrayList<LinkedHashMap<String,String>>>(); | |
private ArrayList<HashMap<String,String>> connectorToMap = new ArrayList<HashMap<String,String>>(); | |
private String speed; | |
private boolean bportDetails = false; | |
private boolean bvalidateCCM = false; | |
private boolean bIsNormalDxc = false; | |
private boolean bIsJack = false; | |
private ArrayList<String> xConnectFromRefList ; | |
private ArrayList<String> xConnectToRefList ; | |
private LinkedHashMap<String,String> extraAttributes; | |
private LinkedHashMap<String,LinkedHashMap<String,String>> extraAttributesMap = new LinkedHashMap<String,LinkedHashMap<String,String>>(); | |
private Interpreter interp = null; | |
private String INTRA_SITE_LABEL = "Intra-site Wiring"; | |
private String INTER_SITE_LABEL = "Inter-site Carrier"; | |
private HashMap<String,String> sitesWithLatLong = new HashMap<String,String>(); | |
public SpecialsSvcInfoDataBlockPrep() { | |
} | |
/** Another constructor for Specials in order to pass the | |
* HTTP request as input paramter | |
* @param request | |
*/ | |
public SpecialsSvcInfoDataBlockPrep(HttpServletRequest request) { | |
this.request = request; | |
sObj = SessionHelper.getSessionDataObject(request); | |
constructSiteIconMap(); | |
parseCMForSpecials(request); | |
} | |
/** A static HashMap to maintain the mapping | |
* between the site icons and site Types. The CCM | |
* provides the Site Type | |
*/ | |
private void constructSiteIconMap() { | |
siteIconMap = new HashMap<String,String>(); | |
siteIconMap.put("customer site", "site-cpe"); | |
siteIconMap.put("mci site", "site-vzb-loc"); | |
siteIconMap.put("telco site", "site-telco"); | |
siteIconMap.put("vzt site", "site-vz-telco"); | |
siteIconMap.put("gateway", "site-gateway"); | |
siteIconMap.put("vzt", "site-vz-telco"); | |
} | |
/** The method called to start creation of | |
* datablocks from the FancyHash | |
* @param request | |
*/ | |
public void parseCMForSpecials(HttpServletRequest request) { | |
SessionDataObject sessionDataObject = SessionHelper.getSessionDataObject(request); | |
String svcType = sessionDataObject.getServiceType(); | |
FancyHash fh = null; | |
ArrayList<ElementAttributeInfo> elemAttrList = ElementAttributeConfig. | |
getAttributeInfoList(svcType,request, false); | |
for(int i = 0; i < elemAttrList.size(); i++) { | |
ElementAttributeInfo elemAttr = elemAttrList.get(i); | |
if(elemAttr.svcType.equals("SPECIALS") && elemAttr.sourceId.equals("design")){ | |
attributesList.add(elemAttr); | |
} | |
} | |
CktDesign cktDesign = MWIntfcCircuitInfoHandler.getDesign(request); | |
testTimeStamp = MWIntfcCircuitInfoHandler.getTestTimeStamp(request); | |
if(cktDesign != null) | |
fh = cktDesign.getDesign(); | |
else | |
_logger.warn("No design returned from middleware"); | |
createElementIdsList(fh); | |
//getNewLinks(fh); | |
} | |
public String getCktLabel() { | |
String cktLabel = ""; | |
if(svcInfo != null && svcInfo.length() > 0) | |
cktLabel = "SPECIALS "+svcInfo.toString(); | |
else | |
cktLabel = "SPECIALS"; | |
return cktLabel; | |
} | |
/** Construct D_CKT_VIEWS datablock | |
* | |
*/ | |
public JSONObject getViews(HttpServletRequest request, String cktIconsCsv) { | |
JSONObject cktViews = new JSONObject(); | |
//createElementIdsList(fh); | |
JSONObject view = new JSONObject(); | |
view.put("selected", "true"); | |
view.put("elementIdList", getViewElements(cktElements)); | |
cktViews.put("SPECIALS",view); | |
return cktViews; | |
} | |
public boolean isViewAvailable(){ | |
boolean bValidView=true; | |
if(cktElements==null || cktElements.isEmpty()) bValidView=false; | |
return bValidView; | |
} | |
/** Construct D_CKT_ELEMENTS datablock. | |
* | |
* @return | |
*/ | |
public JSONObject getCktElements() { | |
JSONObject cktElements = new JSONObject(); | |
Set<String> cktElementsKeys = elementIconLabelInfo.keySet(); | |
Iterator<String> iterator = cktElementsKeys.iterator(); | |
while(iterator.hasNext()){ | |
String elementId = iterator.next(); | |
JSONObject elementInfo = new JSONObject(); | |
HashMap info = new HashMap(); | |
info = elementIconLabelInfo.get(elementId); | |
if(info != null && info.size() > 0) { | |
elementInfo.put("elementClass", info.get("elementClass").toString()); | |
elementInfo.put("iconTag", info.get("iconTag").toString().toLowerCase()); | |
elementInfo.put("iconLabel", info.get("iconLabel")); | |
JSONObject elemInfo = new JSONObject(); | |
if(info.get("IsConnector").toString().equalsIgnoreCase("false")) { | |
JSONObject ccmRefObj = new JSONObject(); | |
String ccmRef = (String)info.get("ccmRef"); | |
ccmRefObj = buildRefObject(ccmRef); | |
//elemInfo.put("ccmRef", info.get("ccmRef")); | |
elemInfo.put("ccmRef", ccmRefObj); | |
if(info.containsKey("altCcmRef")) { | |
JSONObject altCcmRefObj = new JSONObject(); | |
String altCcmRef = (String)info.get("altCcmRef"); | |
altCcmRefObj = buildRefObject(altCcmRef); | |
// elemInfo.put("altCcmRef", info.get("altCcmRef")); | |
elemInfo.put("altCcmRef", altCcmRefObj); | |
} | |
elemInfo.put("elementGroup", info.get("elementGroup")); | |
if(info.containsKey("parseableTID")) | |
elemInfo.put("parseableTID", info.get("parseableTID")); | |
if(info.containsKey("parseableAID")) | |
elemInfo.put("parseableAID", info.get("parseableAID")); | |
} | |
elementInfo.put("elementInfo", elemInfo); | |
cktElements.put(elementId, elementInfo); | |
} else { | |
continue; | |
} | |
} | |
// _logger.debug("D_CKT_ELEMENTS: "+cktElements.toString()); | |
return cktElements; | |
} | |
private JSONObject buildRefObject(String ref) { | |
JSONObject refObject = new JSONObject(); | |
String[] refTokens = ref.split(";",-1); | |
for(int i = 0; i < refTokens.length; i++) { | |
String refToken = refTokens[i]; | |
if(refToken != null && refToken.length() > 0) { | |
ArrayList<LinkedHashMap<String,String>> portInfoList = aidInfoMap.get(refToken); | |
if(portInfoList != null && portInfoList.size() > 0) { | |
JSONObject portInfoObj; | |
JSONArray portInfoArray = new JSONArray(); | |
String speed = ""; | |
String port = ""; | |
String aid = ""; | |
String rateCode = ""; | |
String level = ""; | |
String defaultAid = ""; | |
for (LinkedHashMap<String, String> linkedHashMap : portInfoList) { | |
portInfoObj = new JSONObject(); | |
aid = (linkedHashMap.get("AID") != null) ? linkedHashMap.get("AID") : ""; | |
portInfoObj.put("aid", aid); | |
rateCode = (linkedHashMap.get("RateCode") == null) ? "" :linkedHashMap.get("RateCode"); | |
portInfoObj.put("rateCode", rateCode); | |
level = (linkedHashMap.get("Level") == null) ? "" : linkedHashMap.get("Level"); | |
portInfoObj.put("level", level); | |
speed = (linkedHashMap.get("Speed") == null) ? "" : "("+linkedHashMap.get("Speed")+")" ; | |
portInfoObj.put("speed", speed); | |
port = (linkedHashMap.get("Port") == null) ? "" :linkedHashMap.get("Port"); | |
portInfoObj.put("port", port); | |
if(linkedHashMap.containsKey("defaultVar")) { | |
defaultAid = (linkedHashMap.get("defaultVar") == null) ? "" :linkedHashMap.get("defaultVar"); | |
portInfoObj.put("defaultVar", defaultAid); | |
} | |
portInfoArray.add(portInfoObj); | |
} | |
refObject.put(refToken, portInfoArray); | |
} | |
} | |
} | |
return refObject; | |
} | |
/** Construct D_CKT_ATTRS datablock | |
* | |
* @return | |
*/ | |
public JSONObject getAttrs() { | |
JSONObject elementAttributes = new JSONObject(); | |
Set<String> cktElementsKeys = elementAttributesInfo.keySet(); | |
//_logger.debug("In getAtrs: cktElementKeys: "+cktElementsKeys); | |
Iterator<String> iterator = cktElementsKeys.iterator(); | |
ArrayList<String> refs; | |
while(iterator.hasNext()){ | |
String elementId = iterator.next(); | |
refs = new ArrayList<String>(); | |
HashMap info = new HashMap(); | |
info = elementAttributesInfo.get(elementId); | |
if(info.size() > 1){ | |
Set<String> infoKeys = info.keySet(); | |
// _logger.debug("In getAtrs: infoKeys: "+infoKeys); | |
Iterator<String> itr = infoKeys.iterator(); | |
JSONArray keyValuePair = new JSONArray(); | |
while(itr.hasNext()) { | |
String key = itr.next(); | |
String newKey = key; | |
if(key.startsWith("XConnect From") || key.startsWith("XConnect To")) { | |
String[] xConnectTokens = key.split(",", -1); | |
newKey = xConnectTokens[0]; | |
for(int k = 1; k < xConnectTokens.length;k++) | |
refs.add(xConnectTokens[k]); | |
} | |
String value = info.get(key).toString(); | |
if(key.equalsIgnoreCase("altCcmRef")) { | |
refs.add(value); | |
continue; | |
} | |
JSONObject keyValueObject = new JSONObject(); | |
keyValueObject.put(newKey, value); | |
keyValuePair.add(keyValueObject); | |
} | |
if(!refs.contains(elementId)) | |
refs.add(elementId); | |
for(int k = 0; k < refs.size(); k++) { | |
String ccmRef = refs.get(k); | |
ArrayList<LinkedHashMap<String, String>> portInfoList = aidInfoMap.get(ccmRef); | |
if (portInfoList != null && portInfoList.size() > 0) { | |
JSONObject portInfoObj; | |
JSONObject finalPortInfoObj = new JSONObject(); | |
String speed = ""; | |
String port = ""; | |
String aid = ""; | |
String rateCode = ""; | |
String level = ""; | |
JSONArray portInfoArray = new JSONArray(); | |
LinkedHashMap<String, String> linkMap = portInfoList.get(0); | |
if(linkMap != null){ | |
rateCode = (linkMap.get("RateCode") == null) ? "" :linkMap.get("RateCode"); | |
portInfoObj = new JSONObject(); | |
portInfoObj.put("RateCode", rateCode); | |
portInfoArray.add(portInfoObj); | |
} | |
for (LinkedHashMap<String, String> linkedHashMap : portInfoList) { | |
aid = (linkedHashMap.get("AID") != null) ? linkedHashMap.get("AID") : ""; | |
level = (linkedHashMap.get("Level") == null) ? "" : linkedHashMap.get("Level")+" "; | |
speed = (linkedHashMap.get("Speed") == null) ? "" : "("+linkedHashMap.get("Speed")+")" ; | |
port = (linkedHashMap.get("Port") == null) ? "" :linkedHashMap.get("Port")+" "; | |
portInfoObj = new JSONObject(); | |
portInfoObj.put(level+"AID", aid); | |
portInfoArray.add(portInfoObj); | |
} | |
finalPortInfoObj.put("Port "+port+speed, portInfoArray); | |
keyValuePair.add(finalPortInfoObj); | |
} | |
elementAttributes.put(elementId, keyValuePair); | |
} | |
}else | |
continue; | |
} | |
// _logger.debug("D_CKT_ATTRS: "+elementAttributes.toString()); | |
return elementAttributes; | |
} | |
/** Construct D_ELEMENT_GROUPS datablock | |
* | |
*/ | |
public JSONObject getGroups() { | |
// TODO use domain(or service)-specific configuration to construct the set of groups | |
JSONObject elementGroups = new JSONObject(); | |
for(int i = 0; i < listOfSites.size(); i++) { | |
JSONObject groups = new JSONObject(); | |
ArrayList elements = new ArrayList(); | |
JSONArray elementsInSite = new JSONArray(); | |
String site = listOfSites.get(i); | |
elements = siteGroups.get(site); | |
//elementsInSite.add(elements); | |
boolean enableInterSiteLatLongFeet = ((SessionHelper.getPropText(request, "enableInterSiteLatLongFeet").equals("Y")?true:false)); | |
String[] latlong = {}; | |
String[] templatlong={}; | |
double feet=0.0; | |
int interSiteLatLongFeet=0; | |
String tempsite =null; | |
if(enableInterSiteLatLongFeet){ | |
if(site.equals(listOfSites.get(listOfSites.size()-1))) | |
tempsite=site; | |
else | |
tempsite = listOfSites.get(++i); | |
templatlong = sitesWithLatLong.get(tempsite).split("~"); | |
latlong = sitesWithLatLong.get(site).split("~"); | |
double lat1 = 0.0, lat2 = 0.0, long1 = 0.0, long2 = 0.0; | |
lat1=Double.parseDouble(latlong[0].equals("null")?"0.0":latlong[0]); | |
long1=Double.parseDouble(latlong[1].equals("null")?"0.0":latlong[1]); | |
lat2=Double.parseDouble(templatlong[0].equals("null")?"0.0":templatlong[0]); | |
long2=Double.parseDouble(templatlong[1].equals("null")?"0.0":templatlong[1]); | |
feet = DtixUtils.convertLatLantoFeet(long1, lat1, long2, lat2); | |
interSiteLatLongFeet = Integer.parseInt(SessionHelper.getPropText(request, "interSiteLatLongFeet")); | |
} | |
if(enableInterSiteLatLongFeet&&feet!=0.0&&feet<=interSiteLatLongFeet){ | |
for(int k=0;k<cktElements.size();k++){ | |
String name = cktElements.get(k); | |
String a =elements.get(elements.size()-1).toString(); | |
if(a.equals(name)){ | |
String b=cktElements.get(++k); | |
elements.add(b); | |
LinkedHashMap<String,String> lastElemAttributes =elementAttributesInfo.get(b); | |
if(lastElemAttributes!=null&&lastElemAttributes.size()!=0&&lastElemAttributes.get("_attrLabel")!=null){ | |
lastElemAttributes.put("_attrLabel",lastElemAttributes.get("_attrLabel").replace(INTER_SITE_LABEL,INTRA_SITE_LABEL)); | |
elementAttributesInfo.put(b, lastElemAttributes); | |
} | |
break; | |
} | |
} | |
} | |
if(enableInterSiteLatLongFeet){ | |
if(feet!=0.0&&feet<=interSiteLatLongFeet){ | |
elements.addAll(siteGroups.get(tempsite)); | |
}else if(!site.equals(tempsite)){ | |
--i; | |
} | |
} | |
// elementsInSite.add(elements); | |
if(elements != null && elements.size() > 0) | |
for(int j = 0; j < elements.size(); j++) { | |
elementsInSite.add(elements.get(j)); | |
} | |
groups.put("iconTag",siteIcons.get(site).toLowerCase()); | |
if(site.indexOf("#") != -1) { | |
String iconLabel = site.substring(0,site.indexOf("#")); | |
groups.put("iconLabel",iconLabel); | |
if(enableInterSiteLatLongFeet&&feet!=0.0&&feet<=interSiteLatLongFeet){ | |
iconLabel=iconLabel+"-"+tempsite.substring(0,tempsite.indexOf("#")); | |
groups.put("iconLabel",iconLabel); | |
}else | |
groups.put("iconLabel",iconLabel); | |
}else | |
groups.put("iconLabel",site); | |
groups.put("elementIdList", elementsInSite); | |
JSONObject groupInfo = new JSONObject(); | |
groupInfo.put("cktId", ((cktSiteGroupInfo.get(site)!=null?cktSiteGroupInfo.get(site)+"-":""))+((enableInterSiteLatLongFeet&&feet!=0.0&&feet<=interSiteLatLongFeet)?((cktSiteGroupInfo.get(tempsite)!=null?cktSiteGroupInfo.get(tempsite):"")):"")); | |
groups.put("groupInfo", groupInfo); | |
elementGroups.put(site, groups); | |
} | |
//_logger.debug("D_CKT_GROUPS: "+elementGroups.toString()); | |
return elementGroups; | |
} | |
public String getElementClass(String elementId) { | |
return elementClass.get(elementId); | |
} | |
public String getIconTag(String elementId) { | |
return iconTag.get(elementId); | |
} | |
public String getIconLabel(String elementId) { | |
return iconLabel.get(elementId); | |
} | |
/** This method is used to build the JSON Array | |
* which contains the elementIdList for D_CKT_VIEWS | |
* @param cktElements | |
* @return | |
*/ | |
private JSONArray getViewElements(ArrayList cktElements) { | |
JSONArray viewElements = new JSONArray(); | |
for(int i = 0; i < cktElements.size(); i++) { | |
viewElements.add(cktElements.get(i)); | |
} | |
return viewElements; | |
} | |
/** This method is called to start the parsing | |
* of the FancyHash | |
* @param fh | |
*/ | |
private void createElementIdsList(FancyHash fh) { | |
if(fh != null) { | |
//determine the Links | |
getCircuitLevelAttributes(fh); | |
Vector<FancyHash> links = fh.getFolders("Inventory/Connection/Circuit/CircuitRoute/Implementation"); | |
//determine the sites | |
Vector<FancyHash> sites = fh.getAggs("Inventory/Site"); | |
String ref1 = ""; | |
String ref2 = ""; | |
String site1 = ""; | |
String site2 = ""; | |
// process the Links | |
getServiceInformation(fh,sites); | |
if(links != null && links.size() > 0) { | |
for(int i = 0; i < links.size(); i++) { | |
//get the link Attributes | |
extraAttributes = new LinkedHashMap<String,String>(); | |
if(bIsNormalDxc) | |
bIsNormalDxc = false; | |
if(bIsRingRoute || bIsCable){ | |
prevLinkType = prevLinkType; | |
}else | |
prevLinkType = linkType; | |
linkType = links.get(i).getFirstNode(links.elementAt(i)); | |
extraAttributes.put("LinkType", linkType); | |
// _logger.debug("Link Type is: "+linkType); | |
FancyHash linkAttrs = links.get(i).getAgg(linkType+"/_ATTRS>"); | |
if(linkAttrs != null) { | |
Vector<String> linkAttributes = new Vector<String>(); | |
linkAttributes = linkAttrs.getKeys(linkAttrs); | |
if(linkAttributes != null && linkAttributes.size() > 0){ | |
linkInfoAttributes = new HashMap<String,String>(); | |
for(int j = 0; j < linkAttributes.size(); j++) { | |
String key = linkAttributes.get(j); | |
String value = linkAttrs.get(key); | |
linkInfoAttributes.put(key, value); | |
if("XConnect".equalsIgnoreCase(linkType) && "bandwidth".equalsIgnoreCase(key)){ | |
xConnectLevel = value; | |
} | |
} | |
} | |
} else { | |
_logger.debug("No Attributes for Link"); | |
} | |
// get the endpoint attributes | |
FancyHash endpoint1Attrs = links.get(i).getAgg(linkType+"/EndPoints1/_ATTRS>"); | |
if(endpoint1Attrs != null) { | |
Vector<String> endpoint1Keys = new Vector<String>(); | |
endpoint1Keys = endpoint1Attrs.getKeys(endpoint1Attrs); | |
if(endpoint1Keys != null && endpoint1Keys.size() > 0) { | |
endpoint1Attributes = new HashMap<String,String>(); | |
for(int k = 0; k < endpoint1Keys.size(); k++) { | |
String key = endpoint1Keys.get(k); | |
String value = endpoint1Attrs.get(key); | |
endpoint1Attributes.put(key, value); | |
} | |
} | |
}else | |
_logger.debug("No Attributes for EndPoint1"); | |
FancyHash endpoint2Attrs = links.get(i).getAgg(linkType+"/EndPoints2/_ATTRS>"); | |
if(endpoint2Attrs != null) { | |
Vector<String> endpoint2Keys = new Vector<String>(); | |
endpoint2Keys = endpoint2Attrs.getKeys(endpoint1Attrs); | |
if(endpoint2Keys != null && endpoint2Keys.size() > 0) { | |
endpoint2Attributes = new HashMap<String,String>(); | |
for(int k = 0; k < endpoint2Keys.size(); k++) { | |
String key = endpoint2Keys.get(k); | |
String value = endpoint2Attrs.get(key); | |
endpoint2Attributes.put(key, value); | |
} | |
} | |
}else | |
_logger.debug("No Attributes for EndPoint1"); | |
Vector<FancyHash> linkMiscAttributes = links.get(i).getAggs(linkType+"/Misc/KVP"); | |
// get the Misc Attributes of Link | |
if(linkMiscAttributes != null && linkMiscAttributes.size() > 0) { | |
connectorMiscAttributes = new HashMap<String,String>(); | |
for(int l = 0; l < linkMiscAttributes.size(); l++) { | |
String miscKey = linkMiscAttributes.get(l).get("_ATTRS>/Key"); | |
String miscValue = linkMiscAttributes.get(l).get("_ATTRS>/Value"); | |
if(miscKey != null && miscKey.length() > 0 && miscValue != null && miscValue.length() > 0) | |
connectorMiscAttributes.put(miscKey, miscValue); | |
} | |
} | |
Vector<String> endpoint1 = links.get(i).getValues(linkType+"/EndPoints1/ref"); | |
Vector<String> endpoint2 = links.get(i).getValues(linkType+"/EndPoints2/ref"); | |
if(endpoint1 != null && endpoint1.size() > 0) { | |
//if(endpoint1.size() == 1) | |
ref1 = endpoint1.elementAt(0); | |
} else { | |
_logger.debug("No value for Endpoint1"); | |
} | |
if(endpoint2 != null && endpoint2.size() > 0){ | |
// if(endpoint2.size() == 1) | |
ref2 = endpoint2.elementAt(0); | |
} else | |
_logger.debug("No value for Endpoint2"); | |
if(ref1.equalsIgnoreCase(ref2)) { //ignore link if ref1 is same as ref2 | |
continue; | |
} | |
String[] ref1Tokenizer = ref1.split("\\|", -1); | |
String[] ref2Tokenizer = ref2.split("\\|", -1); | |
site1 = ref1Tokenizer[0]; | |
site2 = ref2Tokenizer[0]; | |
if(bIsRingRoute || bIsCable) { | |
bIsRingRoute = false; | |
bIsCable = false; | |
} | |
else { | |
if(i+1 < links.size()) { | |
if(linkType.equalsIgnoreCase("RingRoute") || linkType.equalsIgnoreCase("Cable")){ | |
nextLinkType = links.get(i+1).getFirstNode(links.elementAt(i+1)); | |
Vector<String> nextLinkEndpoint1 = links.get(i+1).getValues(nextLinkType+"/EndPoints1/ref"); | |
String nextLinkRef1 = nextLinkEndpoint1.elementAt(0); | |
String[] nextLinkTokenizer = nextLinkRef1.split("\\|",-1); | |
String nextLinkSite = nextLinkTokenizer[0]; | |
if(site1.equalsIgnoreCase(nextLinkSite)) { | |
String nextLinkEquipId = ""; | |
String equipId = ""; | |
if(ref1Tokenizer.length > 1) | |
equipId = ref1Tokenizer[1]; | |
if(nextLinkTokenizer.length > 1){ | |
nextLinkEquipId = nextLinkTokenizer[1]; | |
} | |
if(equipId.equalsIgnoreCase(nextLinkEquipId)) { | |
if(nextLinkType.equalsIgnoreCase("RingRoute")) { | |
bIsRingRoute = true; | |
} else if(nextLinkType.equalsIgnoreCase("Cable")) { | |
bIsCable = true; | |
} | |
}else { | |
bIsRingRoute = false; | |
bIsCable = false; | |
} | |
}else { | |
bIsRingRoute = false; | |
bIsCable = false; | |
} | |
} | |
} | |
} | |
if(bSiteNotAdded) { | |
String lastSite = listOfSites.get(listOfSites.size()-1); | |
if(lastSite.equalsIgnoreCase(site1)) | |
bInterSite = false; | |
else { | |
if(siteElements != null && siteElements.size() > 0) | |
addSiteElementsToSite(lastSite); | |
bSiteNotAdded = false; | |
bInterSite = true; | |
} | |
}else if(site1.equalsIgnoreCase(site2)) //check if it is same site or different site | |
bInterSite = false; | |
else | |
bInterSite = true; | |
if(i == links.size()-1) | |
bLastLink = true; | |
if(linkType.equalsIgnoreCase("XConnect")) { | |
xConnectToRefList = new ArrayList<String>(); | |
xConnectFromRefList = new ArrayList<String>(); | |
if(endpoint1.size() > 1) { | |
bMultiXConnectFromRef = true; | |
} | |
if(bMultiXConnectFromRef) { | |
for(int j = 0; j < endpoint1.size(); j++) { | |
createDataBlocks(sites,endpoint1.elementAt(j),bInterSite); | |
xConnectFromRefList.add(endpoint1.elementAt(j)); | |
} | |
bMultiXConnectFromRef = false; | |
} else { | |
createDataBlocks(sites,ref1,bInterSite); | |
xConnectFromRefList.add(ref1); | |
} | |
if(endpoint2.size() > 1) { | |
bMultiXConnectToRef = true; | |
} | |
if(bMultiXConnectToRef) { | |
for(int j = 0; j < endpoint2.size(); j++) { | |
createDataBlocks(sites,endpoint2.elementAt(j),bInterSite); | |
xConnectToRefList.add(endpoint2.elementAt(j)); | |
} | |
} | |
} else | |
createDataBlocks(sites,ref1,bInterSite); | |
if(bLastLink) { | |
bLastElement = true; | |
createDataBlocks(sites,ref2,true); | |
} | |
} | |
}else | |
_logger.debug("No Links under Connection"); | |
} else | |
_logger.debug("No Fancy Hash"); | |
} | |
/** This method populates the data needed for | |
* the D_SVC_INFO datablock | |
* @param fh | |
* @param sites | |
*/ | |
private void getServiceInformation(FancyHash fh,Vector<FancyHash> sites) { | |
svcInfo = new StringBuffer(); | |
String svcCategory = fh.get("Inventory/Connection/Circuit/ServiceCategory/Description"); | |
if(svcCategory != null && svcCategory.length() > 0) { | |
svcInfo.append(svcCategory.trim()); | |
svcInfo.append(":"); | |
} | |
else{ | |
svcCategory = fh.get("Inventory/Connection/Circuit/TransmissionLevel"); | |
if(svcCategory != null && svcCategory.length() > 0) { | |
svcInfo.append(svcCategory.trim()); | |
svcInfo.append(":"); | |
} | |
} | |
String circuitId = fh.get("Inventory/Connection/Circuit/_ATTRS>/CKTID"); | |
if(circuitId != null && circuitId.length() > 0) { | |
svcInfo.append(circuitId.trim()); | |
} | |
String topologyOrigin = fh.get("Inventory/Connection/Circuit/TopologyOrigin"); | |
if(topologyOrigin != null && topologyOrigin.length() > 0) { | |
svcInfo.append("["); | |
svcInfo.append(topologyOrigin.trim()); | |
svcInfo.append("] "); | |
} | |
String fromSite = fh.get("Inventory/Connection/Circuit/CircuitRoute/EndPoints1/ref"); | |
if(fromSite != null && fromSite.length() > 0) { | |
if(fromSite.indexOf("|") != -1){ | |
fromSite = fromSite.substring(0,fromSite.indexOf("|")); | |
} | |
}else | |
fromSite = "InvalidSite"; | |
String toSite = fh.get("Inventory/Connection/Circuit/CircuitRoute/EndPoints2/ref"); | |
if(toSite != null && toSite.length() > 0) { | |
if(toSite.indexOf("|") != -1){ | |
toSite = toSite.substring(0,toSite.indexOf("|")); | |
} | |
}else | |
toSite = "InvalidSite"; | |
String fromSiteDetails = ""; | |
String toSiteDetails = ""; | |
for(int i = 0; i < sites.size(); i++) { | |
String site = sites.elementAt(i).get("_ATTRS>/id"); | |
if(site != null && site.length() > 0) { | |
if(site.equalsIgnoreCase(fromSite)) { | |
FancyHash siteDetails = sites.elementAt(i).newInstance(); | |
fromSiteDetails = getSiteAddressAndLocation(siteDetails); | |
}else if(site.equalsIgnoreCase(toSite)){ | |
FancyHash siteDetails = sites.elementAt(i).newInstance(); | |
toSiteDetails = getSiteAddressAndLocation(siteDetails); | |
} | |
}else | |
continue; | |
} | |
if(fromSiteDetails != null && fromSiteDetails.length() > 0) { | |
svcInfo.append("From:"); | |
svcInfo.append(fromSiteDetails.trim()); | |
svcInfo.append(" "); | |
} | |
if(toSiteDetails != null && toSiteDetails.length() > 0) { | |
svcInfo.append("To:"); | |
svcInfo.append(toSiteDetails.trim()); | |
svcInfo.append(". "); | |
} | |
String custName = fh.get("Inventory/Connection/Circuit/Customer/ContactName"); | |
if(custName != null && custName.length() > 0){ | |
svcInfo.append(custName.trim()); | |
svcInfo.append(" "); | |
} | |
String custPhone = fh.get("Inventory/Connection/Circuit/Customer/ContactNumber"); | |
if(custPhone != null && custPhone.length() > 0){ | |
svcInfo.append(custPhone.trim()); | |
svcInfo.append(" "); | |
} | |
String compName = fh.get("Inventory/Connection/Circuit/Customer/Company"); | |
if(compName != null && compName.length() > 0) { | |
svcInfo.append(compName.trim()); | |
} | |
} | |
/** This method gets the Site Address and Location | |
* needed for the From and To sites for the D_SVC_INFO datablock | |
* @param siteDetails | |
* @return | |
*/ | |
private String getSiteAddressAndLocation(FancyHash siteDetails) { | |
StringBuffer siteAddress = new StringBuffer(); | |
String site = siteDetails.get("_ATTRS>/id"); | |
String siteType = ""; | |
Vector<FancyHash> siteMiscAttributes = siteDetails.getAggs("Misc/KVP"); | |
if(siteMiscAttributes != null && siteMiscAttributes.size() > 0) { | |
for(int i = 0; i < siteMiscAttributes.size(); i++) { | |
String miscKey = siteMiscAttributes.get(i).get("_ATTRS>/Key"); | |
if(miscKey.equalsIgnoreCase("Site Type Code")) | |
siteType = siteMiscAttributes.get(i).get("_ATTRS>/Value"); | |
} | |
} | |
// _logger.debug("Site Type is: "+siteType); | |
if(siteType != null && siteType.length() > 0) { | |
if(siteType.equalsIgnoreCase("Customer Site")) { | |
String addressStreet = siteDetails.get("Address"); | |
if(addressStreet != null && addressStreet.length() > 0) | |
siteAddress.append(addressStreet); | |
}else { | |
_logger.debug("Site: "+site+" is not a customer site"); | |
} | |
}else { | |
_logger.debug("Site Type Details unavailable for Site: "+site); | |
} | |
return siteAddress.toString(); | |
} | |
/** Method called to populate the circuit level attributes | |
* for the diagram | |
* @param fh | |
*/ | |
private void getCircuitLevelAttributes(FancyHash fh) { | |
attributesInfo = new LinkedHashMap<String,String>(); | |
FancyHash cktAttributes = fh.getAgg("Inventory/Connection/Circuit/"); | |
attributesInfo.put("_attrLabel","Circuit Attributes"); | |
if(testTimeStamp != null && testTimeStamp.length() > 0) { | |
attributesInfo.put("Test Timestamp", testTimeStamp); | |
} | |
Vector<FancyHash> miscAttributes = cktAttributes.getAggs("Misc/KVP"); | |
LinkedHashMap<String,String> cktLevelMiscAttributes = new LinkedHashMap<String,String>(); | |
if(miscAttributes != null && miscAttributes.size() > 0) { | |
for(int j = 0; j < miscAttributes.size(); j++) { | |
String miscKey = miscAttributes.get(j).get("_ATTRS>/Key"); | |
String miscValue = miscAttributes.get(j).get("_ATTRS>/Value"); | |
if(miscKey != null && miscKey.length() > 0 && miscValue != null && miscValue.length() > 0) | |
cktLevelMiscAttributes.put(miscKey,miscValue); | |
} | |
} | |
elementAttributes = new ArrayList<ElementAttributeInfo>(); | |
for(int i = 0; i < attributesList.size(); i++) { | |
ElementAttributeInfo elemAttr = attributesList.get(i); | |
if(elemAttr.elementId.equals("CKT")) { | |
elementAttributes.add(elemAttr); | |
} | |
} | |
for(int i = 0; i < elementAttributes.size(); i++) { | |
String path = elementAttributes.get(i).sourceField1; | |
path = path.replace("__", " "); | |
String key = elementAttributes.get(i).fieldFormatText; | |
String source = elementAttributes.get(i).sourceSection; | |
String value = ""; | |
if(source != null && source.length() > 0) { | |
if(source.equalsIgnoreCase("Misc")) { | |
if(cktLevelMiscAttributes.containsKey(path)) | |
value = cktLevelMiscAttributes.get(path); | |
} | |
}else | |
value = cktAttributes.get(path); | |
if(value != null && value.length() > 0) | |
attributesInfo.put(key,value); | |
} | |
cktId = attributesInfo.get("Circuit ID"); | |
elementAttributesInfo.put("CKT",attributesInfo); | |
} | |
/** Method called to create various | |
* collections with all the data for datablocks | |
* @param sites | |
* @param reference | |
* @param bInterSite | |
*/ | |
private void createDataBlocks(Vector<FancyHash> sites,String reference, boolean bInterSite) { | |
FancyHash siteDetails = null; | |
FancyHash nodesDetails = null; | |
FancyHash locationDetails = null; | |
FancyHash equipmentDetails = null; | |
String sitePosition = ""; | |
String equipType = ""; | |
String site = ""; | |
String role = ""; | |
String ccmPath = ""; | |
String linkEquipId = ""; | |
String connector = ""; | |
boolean bExistingSite = false; | |
iconLabelInfo = new HashMap<String,String>(); | |
iconLabelInfo.put("ccmRef", reference); | |
iconLabelInfo.put("currentCcmRef", reference); | |
if(altCcmRef != null && altCcmRef.length() > 0) { | |
iconLabelInfo.put("altCcmRef", altCcmRef); | |
altCcmRef = ""; | |
} | |
// StringTokenizer refTokenizer = new StringTokenizer(reference,"|"); | |
// site = refTokens.nextToken(); | |
// if(refTokenizer.hasMoreTokens()) | |
// refTokenizer.nextToken(); | |
String[] refTokens = reference.split("\\|",-1); | |
site = refTokens[0]; | |
if(site.equalsIgnoreCase("UNKNOWN")) | |
return; | |
for(int i = 0; i < sites.size(); i++) { | |
siteDetails = sites.elementAt(i); | |
String siteInVector = sites.elementAt(i).get("_ATTRS>/id"); | |
siteCktId = siteDetails.get("_ATTRS>/cid"); | |
siteMiscAttributes = new LinkedHashMap<String,String>(); | |
Vector<FancyHash> miscAttributes = siteDetails.getAggs("Misc/KVP"); | |
for(int j = 0; j < miscAttributes.size(); j++) { | |
String miscKey = miscAttributes.get(j).get("_ATTRS>/Key"); | |
String miscValue = miscAttributes.get(j).get("_ATTRS>/Value"); | |
if(miscKey != null && miscKey.length() > 0 && miscValue != null && miscValue.length() > 0) | |
siteMiscAttributes.put(miscKey,miscValue); | |
} | |
siteIcon = siteMiscAttributes.get("Site Type Code"); | |
if(siteIcon != null) | |
iconLabelInfo.put("elementGroup", siteIcon); | |
if(siteInVector.equals(site)) { | |
nodesDetails = sites.elementAt(i).newInstance(); | |
String siteName = site; | |
String lastSite = ""; | |
String tempSite = ""; | |
if(listOfSites != null && listOfSites.size() > 0) { | |
lastSite = listOfSites.get(listOfSites.size()-1); | |
tempSite = lastSite.substring(0, lastSite.indexOf("#")); | |
} | |
if(site.equalsIgnoreCase(tempSite)) { | |
bExistingSite = true; | |
site = lastSite; | |
}else { | |
if(siteCount.containsKey(site)) { | |
int siteNo = siteCount.get(siteName); | |
site = site+"#"+String.valueOf(siteNo+1); | |
siteCount.put(siteName, siteNo+1); | |
} else{ | |
site = site+"#"+String.valueOf(1); | |
siteCount.put(siteName, 1); | |
} | |
listOfSites.add(site); | |
sitesWithLatLong.put(site, siteDetails.get("Latitude")+"~"+siteDetails.get("Longitude")); | |
bExistingSite = false; | |
} | |
/* if(listOfSites.contains(site)) { | |
//bExistingSite = true; | |
if(siteGroups.containsKey(site)) { | |
bExistingSite = false; | |
int siteNo = siteCount.get(site); | |
String newSite = site+"#"+String.valueOf(siteNo); | |
siteCount.put(site, siteNo+1); | |
listOfSites.add(newSite); | |
}else | |
bExistingSite = true; | |
} | |
else { | |
listOfSites.add(site); | |
}*/ | |
String siteIconTag= getSiteIcon(siteIcon); | |
String ownCompany = siteMiscAttributes.get("Owning Company"); | |
if(ownCompany!=null){ | |
if(ownCompany.equals("UKBT") && "site-cpe".equals(siteIconTag)) | |
siteIconTag="site-cpe-bt"; | |
} | |
siteIcons.put(site, siteIconTag); | |
getSiteAttributes(siteDetails,site); | |
break; | |
} | |
} | |
sitePosition = String.valueOf(listOfSites.indexOf(site)); | |
Vector<FancyHash> nodes = nodesDetails.getAggs("Node"); | |
if(nodes != null && nodes.size() > 0) { | |
if(refTokens.length>=2) | |
linkEquipId = refTokens[1]; | |
// getting all the nodes under a particular site. | |
for(int k = 0; k < nodes.size(); k++) { | |
String equipId = nodes.elementAt(k).get("_ATTRS>/id"); | |
if(equipId==null) continue; | |
if(equipId.equalsIgnoreCase(linkEquipId)) { | |
// equipType is determined to find out the CCM hierarchy path | |
equipmentMiscAttributes = new LinkedHashMap<String,String>(); | |
Vector<FancyHash> miscAttributes = nodes.elementAt(k).getAggs("Misc/KVP"); | |
for(int j = 0; j < miscAttributes.size(); j++) { | |
String miscKey = miscAttributes.get(j).get("_ATTRS>/Key"); | |
String miscValue = miscAttributes.get(j).get("_ATTRS>/Value"); | |
if(miscKey != null && miscKey.length() > 0 && miscValue != null && miscValue.length() > 0) | |
equipmentMiscAttributes.put(miscKey,miscValue); | |
} | |
parseableTID = nodes.elementAt(k).get("Parseable"); | |
equipType = equipmentMiscAttributes.get("Equip Type"); | |
if(equipType == null || equipType.length() == 0) | |
equipType = "Unknown"; | |
equipType = equipType.replace(" ", ""); | |
// _logger.debug("Equip Type is: "+equipType); | |
if(equipType.equalsIgnoreCase("DSX3")) | |
bIsJack = true; | |
String propKey = "SpecialsCCM."+equipType; | |
String location = nodes.elementAt(k).get("Location"); | |
if(location != null && location.length() > 0) | |
extraAttributes.put("Location",location); | |
if(!bIsDxc && !bIsXConnectDXC) { | |
Set<String> equipTypes = SessionHelper.getPropSet(sObj, "SPECIALS.ignorableEquipTypes",false); | |
if(equipTypes != null && !equipTypes.isEmpty()) { | |
Iterator<String> itr = equipTypes.iterator(); | |
while(itr.hasNext()) { | |
String equipTypeToIgnore = itr.next(); | |
if(equipType.equalsIgnoreCase(equipTypeToIgnore)) { | |
if(bExistingSite) { | |
bSiteNotAdded = true; | |
} | |
else { | |
String lastSite = listOfSites.get(listOfSites.size()-1); | |
listOfSites.remove(lastSite); | |
lastSite = lastSite.substring(0,lastSite.indexOf("#")); | |
int siteNo = siteCount.get(lastSite); | |
if(siteNo == 1) | |
siteCount.remove(lastSite); | |
else { | |
siteNo--; | |
siteCount.put(lastSite, siteNo); | |
} | |
} | |
return; | |
} | |
} | |
} | |
// in case of dxcs, there is no connector and is | |
//shown as one equipment | |
Set<String> dxcs = SessionHelper.getPropSet(sObj,"SPECIALS.DXC",false); | |
if(dxcs != null && !dxcs.isEmpty()) { | |
Iterator<String> itr = dxcs.iterator(); | |
while(itr.hasNext()) { | |
String dxc = itr.next(); | |
if(equipType.equalsIgnoreCase(dxc)) { | |
if(linkType.equalsIgnoreCase("XConnect")) { | |
bIsXConnectDXC = true; | |
} | |
String equipDisplayClass = equipmentMiscAttributes.get("Display Class"); | |
if(equipDisplayClass != null && equipDisplayClass.length() > 0) { | |
if(equipDisplayClass.equalsIgnoreCase("dcs-a")) { | |
if(k+1 < nodes.size()) { | |
LinkedHashMap<String,String> nextEquipMiscAttrs = new LinkedHashMap<String,String>(); | |
Vector<FancyHash> tempMiscAttributes = nodes.elementAt(k+1).getAggs("Misc/KVP"); | |
for(int j = 0; j < tempMiscAttributes.size(); j++) { | |
String miscKey = tempMiscAttributes.get(j).get("_ATTRS>/Key"); | |
String miscValue = tempMiscAttributes.get(j).get("_ATTRS>/Value"); | |
if(miscKey != null && miscKey.length() > 0 && miscValue != null && miscValue.length() > 0) | |
nextEquipMiscAttrs.put(miscKey,miscValue); | |
} | |
String nextEquipType = nextEquipMiscAttrs.get("Equip Type"); | |
if(nextEquipType != null && nextEquipType.length() > 0) { | |
nextEquipType = nextEquipType.replace(" ", ""); | |
if(nextEquipType.equalsIgnoreCase(equipType)) { | |
String displayClass = nextEquipMiscAttrs.get("Display Class"); | |
if(displayClass != null && displayClass.length() > 0) { | |
if(displayClass.equalsIgnoreCase("dcs-z") ){ | |
bIsDxc = true; | |
bIsNormalDxc = true; | |
//return; | |
}else | |
bIsDxc = false; | |
}else | |
bIsDxc = false; | |
}else | |
bIsDxc = false; | |
}else | |
bIsDxc = false; | |
}else | |
break; | |
}else | |
bIsDxc = false; | |
}else | |
bIsDxc = false; | |
}else | |
continue; | |
} | |
} | |
} | |
Set<String> ccmPaths = SessionHelper.getPropSet(sObj,propKey,false); | |
//String linkType = linkInfoAttributes.get("type"); | |
if(ccmPaths!=null && !ccmPaths.isEmpty()){ | |
Iterator<String> itr = ccmPaths.iterator(); | |
while(itr.hasNext()) { | |
ccmPath = itr.next(); | |
/* role = nodes.elementAt(k).get(ccmPath+"/Role"); | |
if(role != null && role.length() > 0) {*/ | |
boolean bCCMPath = validateCCMPath(reference,ccmPath,nodes.elementAt(k)); | |
if(bCCMPath) { | |
break; | |
}else | |
ccmPath = ""; | |
/* }else | |
ccmPath = "";*/ | |
} | |
if(ccmPath == null || ccmPath.length() == 0) { | |
ccmPath = "Port"; | |
role = nodes.elementAt(k).get(ccmPath+"/Role"); | |
if(role != null && role.length() > 0) { | |
boolean bCCMPath = validateCCMPath(reference,ccmPath,nodes.elementAt(k)); | |
if(bCCMPath) { | |
ccmPath = "Port"; | |
}else | |
ccmPath = ""; | |
} else { | |
ccmPath = getCCMPath(nodes.elementAt(k),reference); | |
_logger.info("Missing CCM Path variant: ("+ccmPath+") for Equipment: ("+equipType+") with Equipment ID: ("+ | |
equipId+") in Site: ("+site+") of circuit: ("+cktId+")"); | |
} | |
//connector = nodes.elementAt(k).get(ccmPath+"/RateCode"); | |
connector = rateCode; | |
if(connector == null || connector.length() == 0) { | |
connector = linkType; | |
} | |
} | |
// get the connector rate code | |
if(linkType.equalsIgnoreCase("WIRING") || | |
linkType.equalsIgnoreCase("CARRIER") || | |
linkType.equalsIgnoreCase("FEEDER")) | |
connector = linkType; | |
else | |
//connector = nodes.elementAt(k).get(ccmPath+"/RateCode"); | |
connector = rateCode; | |
if(connector == null || connector.length() == 0) | |
connector = linkType; | |
}else { | |
ccmPath="Port"; | |
role = nodes.elementAt(k).get(ccmPath+"/Role"); | |
if(role != null && role.length() > 0) { | |
boolean bCCMPath = validateCCMPath(reference,ccmPath,nodes.elementAt(k)); | |
if(bCCMPath) { | |
ccmPath="Port"; | |
}else { | |
ccmPath = ""; | |
} | |
} else { | |
ccmPath = getCCMPath(nodes.elementAt(k).newInstance(),reference); | |
_logger.info("Missing Equipment Type: ("+equipType+") with Equipment ID: ("+ | |
equipId+") in Site: ("+site+") of circuit: ("+cktId+") having CCM Path: ("+ccmPath+")"); | |
} | |
//connector = nodes.elementAt(k).get(ccmPath+"/RateCode"); | |
connector = rateCode; | |
if(connector == null || connector.length() == 0) { | |
connector = linkType; | |
} | |
} | |
extraAttributes.put("CCM_Path", ccmPath); | |
if(bportDetails && !bIsJack){ | |
aidInfoMap.put(reference, portDetailsList); | |
bportDetails = false; | |
} | |
if(linkType.equalsIgnoreCase("XConnect") || bIsRingRoute || bIsCable || bIsNormalDxc ) { | |
extraAttributesMap.put(reference, extraAttributes); | |
altCcmRef = reference; | |
return; | |
} | |
equipmentDetails = nodes.elementAt(k); | |
break; | |
} | |
} | |
if(equipmentDetails!=null){ | |
populateIconsLabelsAttributes(equipmentDetails,equipType,ccmPath,false,reference); | |
if(!bLastElement) { | |
populateIconsLabelsAttributes(equipmentDetails,connector,ccmPath,true,reference); | |
} | |
} | |
} else { | |
addSite(site,siteDetails,ccmPath); | |
} | |
if(bInterSite) { | |
addSiteElementsToSite(site); | |
} | |
} | |
private boolean validateCCMPath(String reference, String ccmPath, FancyHash node) { | |
boolean bIsValidPath = false; | |
String[] refTokens = reference.split("\\|", -1); | |
String[] ccmPathTokens = ccmPath.split("/",-1); | |
int refPoint = 2; | |
int ccmPathPoint = 0; | |
attributePath = new StringBuffer(); | |
if(refTokens.length-2 == ccmPathTokens.length) { | |
xConnectLabel = new StringBuffer(); | |
bvalidateCCM = true; | |
bIsValidPath = validateValuesInCCMPath(ccmPathTokens,refTokens,node,ccmPathPoint,refPoint,bIsValidPath); | |
bvalidateCCM = false; | |
if(linkType.equalsIgnoreCase("XConnect")) { | |
if(bMultiXConnectFromRef) { | |
if(xConnectFrom.length() > 0) | |
xConnectFrom = xConnectFrom+","+xConnectLabel.toString(); | |
else | |
xConnectFrom = xConnectLabel.toString(); | |
} else if(xConnectFrom.length() == 0) | |
xConnectFrom = xConnectLabel.toString(); | |
if(bMultiXConnectToRef) { | |
if(xConnectTo.length() > 0) | |
xConnectTo = xConnectTo+","+xConnectLabel.toString(); | |
else | |
xConnectTo = xConnectLabel.toString(); | |
} | |
} | |
else if(bIsRingRoute && firstRingRoute.length() == 0) { | |
firstRingRoute = xConnectLabel.toString().replace("-", " "); | |
}else if(bIsCable) { | |
firstCable = xConnectLabel.toString(); | |
} | |
}else | |
bIsValidPath = false; | |
return bIsValidPath; | |
} | |
private boolean validateValuesInCCMPath(String[] ccmPathTokens,String[] refTokens,FancyHash node, | |
int ccmPathPoint,int refPoint, boolean bIsValidPath) { | |
boolean bLabelAdded = false; | |
String refValue = refTokens[refPoint]; | |
String ccmPathToken = ccmPathTokens[ccmPathPoint]; | |
Vector<FancyHash> nodeChildren = node.getFolders(); | |
for(int n = 0; n < nodeChildren.size(); n++){ | |
String childToken = nodeChildren.get(n).getFirstNode(nodeChildren.elementAt(n)); | |
if(childToken.equalsIgnoreCase(ccmPathToken)) { | |
Vector<FancyHash> subNodeDetails = node.getAggs(ccmPathToken); | |
if(subNodeDetails != null && subNodeDetails.size() > 0) { | |
for(int i = 0; i < subNodeDetails.size(); i++) { | |
String ccmPathValue = subNodeDetails.elementAt(i).get("_ATTRS>/id"); | |
String label = ""; | |
if(refValue.equalsIgnoreCase(ccmPathValue)) { | |
bIsValidPath = true; | |
rateCode = ""; | |
extraAttributes.put(ccmPathToken, ccmPathValue); | |
if(ccmPathToken.equalsIgnoreCase("Shelf") || ccmPathToken.equalsIgnoreCase("Card")) { | |
_logger.debug("Ignore values for Shelf and Card for Label"); | |
} else if((ccmPathToken.equalsIgnoreCase("Group")) || (ccmPathToken.equalsIgnoreCase("Port"))) { | |
String tempLabel = subNodeDetails.elementAt(i).get("TypeID"); | |
if(tempLabel != null && tempLabel.length() > 0) { | |
if(ccmPathToken.equalsIgnoreCase("Group")) | |
speed = tempLabel; | |
if(tempLabel.equalsIgnoreCase("Generic")) | |
label = SessionHelper.getPropText(sObj, "SPECIALS."+ccmPathToken,false); | |
else if(tempLabel.equalsIgnoreCase("LowSpeed") || tempLabel.equalsIgnoreCase("HighSpeed")) | |
label = SessionHelper.getPropText(sObj, "SPECIALS."+tempLabel,false); | |
else | |
label = tempLabel; | |
if(ccmPathToken.equalsIgnoreCase("Port")) { | |
rateCode = subNodeDetails.elementAt(i).get("RateCode"); | |
if(rateCode != null && rateCode.length() > 0) | |
extraAttributes.put("RateCode", rateCode); | |
String aid = subNodeDetails.elementAt(i).get("Aid"); | |
if(bvalidateCCM){ | |
portDetailsList = new ArrayList<LinkedHashMap<String,String>>(); | |
Vector<FancyHash> miscAttributes = subNodeDetails.elementAt(i).getAggs("Misc/KVP"); | |
HashMap<String,String> portMiscValues = null; | |
if(miscAttributes != null && miscAttributes.size() > 0) { | |
portMiscValues = new HashMap<String, String>(); | |
for(int j = 0; j < miscAttributes.size(); j++) { | |
String miscKey = miscAttributes.elementAt(j).get("_ATTRS>/Key"); | |
String miscValue = miscAttributes.get(j).get("_ATTRS>/Value"); | |
if(miscKey != null && miscKey.length() > 0 && miscValue != null && miscValue.length() > 0) | |
portMiscValues.put(miscKey, miscValue); | |
} | |
} | |
if(portMiscValues != null && portMiscValues.containsKey("AIDLIST")) { | |
String levels = portMiscValues.get("AIDLIST"); | |
String[] levelTokens = levels.split(",", -1); | |
for (String levelToken : levelTokens) { | |
portDetails = new LinkedHashMap<String, String>(); | |
String levelAid = portMiscValues.get(levelToken+" AID"); | |
portDetails.put("AID",levelAid); | |
portDetails.put("RateCode",rateCode); | |
portDetails.put("Level",levelToken); | |
portDetails.put("Port", ccmPathValue); | |
portDetails.put("Speed", speed); | |
speed = null; | |
if(levelAid.equalsIgnoreCase(aid)) | |
portDetails.put("defaultVar", "true"); | |
bportDetails = true; | |
portDetailsList.add(portDetails); | |
} | |
} | |
else { | |
portDetails = new LinkedHashMap<String, String>(); | |
portDetails.put("AID",aid); | |
portDetails.put("RateCode",rateCode); | |
portDetails.put("Port", ccmPathValue); | |
portDetails.put("Speed", speed); | |
speed = null; | |
if(aid != null && aid.length() > 0) | |
portDetails.put("defaultVar", "true"); | |
bportDetails = true; | |
portDetailsList.add(portDetails); | |
} | |
} | |
} | |
} | |
} else | |
label = SessionHelper.getPropText(sObj, "SPECIALS."+ccmPathToken,false); | |
if(label != null && label.length() > 0 && ccmPathValue != null && ccmPathValue.length() > 0) { | |
extraAttributes.put(ccmPathToken, label+"-"+ccmPathValue); | |
xConnectLabel.append(label+"-"+ccmPathValue); | |
bLabelAdded = true; | |
if(connectorAttribute != null) | |
connectorAttribute.append(label+" "+ccmPathValue); | |
/*if(connectorLabel != null && connectorLabel.length() > 0) | |
connectorLabel.append(label+"-"+ccmPathValue);*/ | |
} | |
if(refPoint < refTokens.length && xConnectLabel.length() > 0) { | |
if(bLabelAdded) { | |
xConnectLabel.append(" "); | |
if(connectorAttribute != null && connectorAttribute.length() > 0) | |
connectorAttribute.append(":"); | |
/* if(connectorLabel != null && connectorLabel.length() > 0) | |
connectorLabel.append(",");*/ | |
} | |
} | |
if(ccmPathPoint+1 < ccmPathTokens.length && refPoint+1 < refTokens.length) { | |
ccmPathPoint++; | |
refPoint++; | |
FancyHash subNode = subNodeDetails.elementAt(i); | |
// attributePath.append("/"); | |
bIsValidPath = validateValuesInCCMPath(ccmPathTokens,refTokens,subNode,ccmPathPoint, | |
refPoint,bIsValidPath); | |
}else { | |
bIsValidPath = true; | |
} | |
break; | |
}else | |
continue; | |
} | |
break; | |
} else{ | |
bIsValidPath = false; | |
} | |
} else { | |
bIsValidPath = false; | |
continue; | |
} | |
} | |
return bIsValidPath; | |
} | |
private String getCCMPath(FancyHash node, String reference) { | |
String ccmPath = ""; | |
String[] refTokens = reference.split("\\|", -1); | |
int ccmPathLength = refTokens.length-2; | |
int m = 2; | |
Vector<FancyHash> nodeChildren = node.getFolders(); | |
if(nodeChildren != null && nodeChildren.size() > 0) { | |
StringBuffer ccmPathBuffer = new StringBuffer(); | |
for(int n = 0; n < nodeChildren.size(); n++) { | |
FancyHash childNode = nodeChildren.elementAt(n).newInstance(); | |
String firstElement = nodeChildren.get(n).getFirstNode(childNode); | |
if(firstElement.equalsIgnoreCase("Shelf") || firstElement.equalsIgnoreCase("Group")) { | |
Vector<FancyHash> firstElementAggs = nodeChildren.get(n).getAggs(firstElement); | |
if(firstElementAggs != null && firstElementAggs.size() > 0) { | |
for(int i = 0; i < firstElementAggs.size(); i++) { | |
String firstElementValue = firstElementAggs.elementAt(i).get("_ATTRS>/id"); | |
if(firstElementValue != null) { | |
if(firstElementValue.equalsIgnoreCase(refTokens[m])) { | |
ccmPathBuffer.append(firstElement); | |
ccmPath = decipherCCMPath(childNode,ccmPathBuffer,firstElement,refTokens,m+1); | |
break; | |
} | |
} | |
} | |
} | |
} | |
} | |
boolean bCCMPath = validateCCMPath(reference,ccmPath,node); | |
if(!bCCMPath) | |
ccmPath = ""; | |
}else | |
ccmPath = ""; | |
return ccmPath; | |
} | |
private String decipherCCMPath(FancyHash childNode,StringBuffer ccmPathBuffer,String firstElement,String[] refTokens, | |
int refTokenPoint) { | |
String ccmPath = ""; | |
Vector<FancyHash> subNodeChildren = childNode.getFolders(firstElement); | |
if(subNodeChildren != null && subNodeChildren.size() > 0) { | |
for(int i = 0; i < subNodeChildren.size(); i++) { | |
Set<String> ccmPathValues = SessionHelper.getPropSet(sObj,"SPECIALS.CCMPathValues",false); | |
String firstChild = subNodeChildren.get(i).getFirstNode(subNodeChildren.elementAt(i)); | |
if(firstChild.equalsIgnoreCase("Port")) { | |
ccmPathBuffer.append("/Port"); | |
break; | |
} | |
else { | |
Iterator<String> itr = ccmPathValues.iterator(); | |
while(itr.hasNext()) { | |
String ccmPathValidValue = itr.next(); | |
if(ccmPathValidValue.equalsIgnoreCase(firstChild)) { | |
Vector<FancyHash> firstChildAggs = subNodeChildren.elementAt(i).getAggs(firstChild); | |
for(int n = 0; n < firstChildAggs.size(); n++) { | |
String firstChildValue = firstChildAggs.elementAt(n).get("_ATTRS>/id"); | |
if(firstChildValue != null) { | |
if(firstChildValue.equalsIgnoreCase(refTokens[refTokenPoint])) { | |
ccmPathBuffer.append("/"+firstChild); | |
FancyHash subNodeChild = subNodeChildren.elementAt(i); | |
if(refTokenPoint+1 < refTokens.length) | |
ccmPath = decipherCCMPath(subNodeChild,ccmPathBuffer,firstChild,refTokens,refTokenPoint+1); | |
else | |
break; | |
} | |
} | |
} | |
} | |
} | |
} | |
} | |
} | |
ccmPath = ccmPathBuffer.toString(); | |
return ccmPath; | |
} | |
/** Adding the siteElements against a particular site | |
* for D_ELEMENT_GROUPS | |
* @param site | |
*/ | |
private void addSiteElementsToSite(String site) { | |
ArrayList<String> elementIdList = new ArrayList<String>(); | |
elementIdList.addAll(siteElements); | |
if(bSiteNotAdded) { | |
String lastElement = elementIdList.get(elementIdList.size()-1); | |
// in case the last Element is a connector, then remove it | |
if(lastElement.indexOf("|") == -1 || lastElement.indexOf("_") != -1){ | |
elementIdList.remove(lastElement); | |
LinkedHashMap<String,String> lastElemAttributes = elementAttributesInfo.get(lastElement); | |
if(lastElemAttributes!=null&&lastElemAttributes.size()>0&&lastElemAttributes.get("_attrLabel")!=null){ | |
lastElemAttributes.put("_attrLabel",lastElemAttributes.get("_attrLabel").replace(INTRA_SITE_LABEL,INTER_SITE_LABEL)); | |
elementAttributesInfo.put(lastElement, lastElemAttributes); | |
} | |
} | |
} | |
siteGroups.put(site, elementIdList); | |
siteElements.clear(); | |
bSiteNotAdded = false; | |
} | |
/** Adding a site itself as the site Element in case | |
* it has no equipments in it | |
* @param site | |
* @param siteDetails | |
* @param ccmPath | |
*/ | |
private void addSite(String site,FancyHash siteDetails, String ccmPath) { | |
siteElements = new ArrayList<String>(); | |
String siteElement = site; | |
siteElements.add(siteElement); | |
cktElements.add(siteElement); | |
if(!bLastElement && cktElements.size() > 2) { | |
String link = cktElements.get(cktElements.size()-2); | |
String newLink = link.substring(0,link.indexOf("_")); | |
int sNo = elementCount.get(newLink); | |
String elementInList = newLink+"_"+String.valueOf(sNo+1); | |
elementCount.put(newLink, sNo+1); | |
cktElements.add(elementInList); | |
LinkedHashMap attributesInfoMap = new LinkedHashMap(); | |
HashMap iconLabelInfoMap = new HashMap(); | |
attributesInfoMap = elementAttributesInfo.get(link); | |
iconLabelInfoMap = elementIconLabelInfo.get(link); | |
elementAttributesInfo.put(elementInList, attributesInfoMap); | |
elementIconLabelInfo.put(elementInList, iconLabelInfoMap); | |
} else if(cktElements.size() == 1){ | |
String link = linkType; | |
String elementInList = ""; | |
if(elementCount.containsKey(link)) { | |
int noOfElements = elementCount.get(link); | |
elementCount.put(link, noOfElements+1); | |
elementInList = link+"_"+String.valueOf(noOfElements+1); | |
} else { | |
elementCount.put(link,1); | |
elementInList = link+"_"+String.valueOf(1); | |
} | |
cktElements.add(elementInList); | |
iconLabelInfo.put("elementClass",link); | |
getElementAttributes(elementInList,false,siteDetails,true,""); | |
LinkedHashMap attributesInfoMap = new LinkedHashMap(); | |
HashMap iconLabelInfoMap = new HashMap(); | |
attributesInfoMap.putAll(attributesInfo); | |
iconLabelInfoMap.putAll(iconLabelInfo); | |
elementAttributesInfo.put(elementInList, attributesInfoMap); | |
elementIconLabelInfo.put(elementInList, iconLabelInfoMap); | |
} | |
getElementAttributes(siteElement,true,siteDetails,false,ccmPath); | |
elementAttributesInfo.put(siteElement, attributesInfo); | |
elementIconLabelInfo.put(siteElement, iconLabelInfo); | |
} | |
private void getSiteAttributes(FancyHash siteNode,String site) { | |
String cktElement = "SITE"; | |
elementAttributes = new ArrayList<ElementAttributeInfo>(); | |
for(int i = 0; i < attributesList.size(); i++) { | |
ElementAttributeInfo elemAttr = attributesList.get(i); | |
if(elemAttr.elementId.equals(cktElement)) { | |
elementAttributes.add(elemAttr); | |
} | |
} | |
attributesInfo = new LinkedHashMap<String,String>(); | |
String siteName = site.substring(0, site.indexOf("#")); | |
attributesInfo.put("_attrLabel", "Site "+siteName+" Attributes"); | |
for(int j = 0; j < elementAttributes.size(); j++) { | |
String path = elementAttributes.get(j).sourceField1; | |
path = path.replace("__", " "); | |
path = path.replace("$d", "."); | |
String value = ""; | |
String key = elementAttributes.get(j).fieldFormatText; | |
String source = elementAttributes.get(j).sourceSection; | |
if(source != null && source.length() > 0) { | |
if(source.equalsIgnoreCase("Misc")) | |
value = siteMiscAttributes.get(path); | |
}else { | |
value = siteNode.get(path); | |
} | |
if(value != null && value.length() > 0) | |
attributesInfo.put(key, value); | |
} | |
elementAttributesInfo.put(site,attributesInfo); | |
} | |
/** This method mainly populated the attributes | |
* for each equipment | |
* @param cktElement | |
* @param bSite | |
* @param node | |
* @param bConnector | |
* @param ccmPath | |
*/ | |
private void getElementAttributes(String cktElement,boolean bSite,FancyHash node, | |
boolean bConnector,String ccmPath) { | |
if(node==null) return; | |
String propKey = ""; | |
String site = ""; | |
StringBuffer attributePath = new StringBuffer(); | |
if(bSite) { | |
site = cktElement; | |
cktElement = "SITE"; | |
} else if(bConnector){ | |
if(cktElement != null && cktElement.length() > 0) | |
cktElement = cktElement.substring(0,cktElement.indexOf("_")); | |
else { | |
cktElement = ""; | |
} | |
}else | |
cktElement = iconLabelInfo.get("elementClass"); | |
elementAttributes = new ArrayList<ElementAttributeInfo>(); | |
attributesInfo = new LinkedHashMap<String,String>(); | |
for(int i = 0; i < attributesList.size(); i++) { | |
ElementAttributeInfo elemAttr = attributesList.get(i); | |
if(!bConnector && !bSite){ | |
if(elemAttr.elementId.equals(cktElement) || elemAttr.elementId.equals("ALL")) | |
elementAttributes.add(elemAttr); | |
}else { | |
if(elemAttr.elementId.equals(cktElement)) { | |
elementAttributes.add(elemAttr); | |
} | |
} | |
} | |
//String aid = node.get(ccmPath+"/Aid"); | |
initializeInterpreter(); | |
if(bConnector) { // if it is a connector | |
iconLabelInfo.put("IsConnector", "true"); | |
String reference = iconLabelInfo.get("currentCcmRef"); | |
String[] refTokens = reference.split("\\|",-1); | |
String[] ccmPathTok = ccmPath.split("/",-1); | |
connectorAttribute = new StringBuffer(); | |
connectorLabel = new StringBuffer(); | |
if(cktElement != null && cktElement.length() > 0) { | |
if(cktElement.equalsIgnoreCase("GENERICROUTE")) | |
connectorLabel.append(","); | |
else | |
connectorLabel.append(cktElement+","); | |
int m = 2; | |
int ccmTokens = ccmPathTok.length; | |
int refLength = ccmTokens+2; | |
if(refTokens.length == refLength) { | |
validateValuesInCCMPath(ccmPathTok,refTokens,node, | |
0,2, false); | |
}else { | |
_logger.debug("No Label for : "+cktElement); | |
} | |
if(!cktElement.equalsIgnoreCase("GENERICROUTE")) { | |
if(cktElement.equalsIgnoreCase("FEEDER") || cktElement.equalsIgnoreCase("WIRING") | |
|| cktElement.equalsIgnoreCase("CARRIER") || cktElement.equalsIgnoreCase("SONET")) | |
attributesInfo.put("_attrLabel", cktElement+":"+cktElement); | |
else if(bInterSite) { | |
attributesInfo.put("_attrLabel", cktElement+" Inter-site Carrier"); | |
} else { | |
attributesInfo.put("_attrLabel", cktElement+" Intra-site Wiring"); | |
} | |
attributesInfo.put("System", cktElement); | |
} | |
if(connectorAttribute.toString().endsWith(":")) { | |
connectorAttribute.deleteCharAt(connectorAttribute.length()-1); | |
} | |
extraAttributes.put("connectorAttribute", connectorAttribute.toString()); | |
if(firstRingRoute.length() > 0) { | |
attributesInfo.put("First RingRoute", firstRingRoute); | |
attributesInfo.put("Second RingRoute", connectorAttribute.toString()); | |
bIsRingRoute = true; | |
firstRingRoute = ""; | |
} | |
else if(firstCable.length() > 0) { | |
attributesInfo.put("First Cable", firstCable); | |
attributesInfo.put("Second Cable", connectorAttribute.toString()); | |
firstCable = ""; | |
} | |
else if(connectorAttribute.length() > 0) | |
attributesInfo.put("Channels", connectorAttribute.toString()); | |
if(connectorMiscAttributes != null && connectorMiscAttributes.size() > 0){ | |
attributesInfo.putAll(connectorMiscAttributes); | |
connectorMiscAttributes.clear(); | |
} | |
String connectorLabel = getConnectorLabel(); | |
if(connectorLabel != null && connectorLabel.length() > 0) | |
iconLabelInfo.put("iconLabel", connectorLabel); | |
String noOfWires = attributesInfo.get("No of Wires"); | |
/*if(noOfWires != null && noOfWires.length() > 0) { | |
cktElement = cktElement.toLowerCase(); | |
String iconTag = cktElement+"-"+noOfWires; | |
String newIconTag = SessionHelper.getPropText(sObj, "SPECIALS.ICON."+iconTag,false); | |
if(newIconTag != null && newIconTag.length() > 0) | |
iconTag = newIconTag; | |
else | |
iconTag = "wire"; | |
iconLabelInfo.put("iconTag", iconTag);*/ | |
if(noOfWires != null && noOfWires.length() > 0){ | |
String iconTag = "wire-"+noOfWires; | |
iconLabelInfo.put("iconTag",iconTag); | |
} else if(linkType.equalsIgnoreCase("RingRoute")){ | |
if(bIsRingRoute) | |
iconLabelInfo.put("iconTag", "sonet-n"); | |
else | |
iconLabelInfo.put("iconTag", "sonet"); | |
bIsRingRoute = false; | |
}else | |
iconLabelInfo.put("iconTag", "wire"); | |
}else { | |
iconLabelInfo.put("iconLabel", ""); | |
iconLabelInfo.put("iconTag", "wire"); | |
} | |
} else { // for other equipments | |
iconLabelInfo.put("IsConnector", "false"); | |
if(parseableTID != null && parseableTID.length() > 0) { | |
iconLabelInfo.put("parseableTID", parseableTID); | |
} | |
parseableAID = node.get(ccmPath+"/Parseable"); | |
if(parseableAID != null && parseableAID.length() > 0) | |
iconLabelInfo.put("parseableAID", parseableAID); | |
for(int j = 0; j < elementAttributes.size(); j++) { | |
String path = elementAttributes.get(j).sourceField1; | |
path = path.replace("__", " "); | |
String value = ""; | |
String key = elementAttributes.get(j).fieldFormatText; | |
String source = elementAttributes.get(j).sourceSection; | |
String equipType = ""; | |
if(equipmentMiscAttributes != null && equipmentMiscAttributes.size() > 0) | |
equipType = equipmentMiscAttributes.get("Equip Type"); | |
String equipId = node.get("_ATTRS>/id"); | |
String attrLabel = ""; | |
if(equipType != null && equipType.length() > 0) | |
attrLabel = equipType+" "+equipId+" Attributes"; | |
else | |
attrLabel = equipId+" Attributes"; | |
attributesInfo.put("_attrLabel", attrLabel); | |
if(source != null && source.length() > 0) { | |
if(source.equalsIgnoreCase("Link")) { // if source section is Link | |
if(linkInfoAttributes != null && linkInfoAttributes.size() > 0) | |
if(linkType.equalsIgnoreCase("RingRoute")) | |
value = linkInfoAttributes.get(path); | |
else | |
value = ""; | |
if(value != null && value.length() > 0) { | |
ringId = value; | |
} else { | |
value = ringId; | |
} | |
} else if(source.equalsIgnoreCase("Endpoint1")) { | |
if(endpoint1Attributes != null && endpoint1Attributes.size() > 0) | |
value = endpoint1Attributes.get(path); | |
else | |
value = ""; | |
}else if(source.equalsIgnoreCase("Misc")) { | |
if(equipmentMiscAttributes != null && equipmentMiscAttributes.size() > 0) { | |
if(equipmentMiscAttributes.containsKey(path)) | |
value = equipmentMiscAttributes.get(path); | |
} | |
else | |
value = ""; | |
}else { | |
String reference = iconLabelInfo.get("ccmRef"); | |
String ccmPathTokens[] = ccmPath.split("\\/", -1); | |
String refTokens[] = reference.split("\\|",-1); | |
value = getCCMPathValues(source,ccmPathTokens,refTokens,node,0,2,path); | |
} | |
} else { //if value is present directly under specified source field | |
if(path.indexOf("&&") != -1) { | |
String[] pathTokens = path.split("&&"); | |
if(pathTokens.length > 1) { | |
String attrType = ""; | |
String attrValue = ""; | |
String attrPath = pathTokens[0]; | |
String condition = pathTokens[1]; | |
condition = condition.substring(0,condition.length()); | |
String[] condTokens = condition.split("~",-1); | |
if(condTokens.length > 1) { | |
attrType = condTokens[0]; | |
attrValue = condTokens[1]; | |
} | |
String finalPath = attrPath+"/"+attrType; | |
if(node.get(finalPath).equalsIgnoreCase(attrValue)) { | |
value = node.get(attrPath); | |
} | |
}else | |
_logger.debug("Path is: "+path); | |
}else { | |
value = node.get(path); | |
} | |
if(value == null || value.length() ==0) { | |
String path2 = elementAttributes.get(j).sourceField2; | |
value = node.get(path2); | |
} | |
} | |
if(value != null && value.length() > 0) | |
attributesInfo.put(key, value); | |
} | |
if(prevLinkType.equalsIgnoreCase("XConnect")) { | |
if(xConnectLevel.length() > 0){ | |
attributesInfo.put("XConnect Level", xConnectLevel); | |
xConnectLevel = ""; | |
} | |
if(xConnectFrom != null && xConnectFrom.length() > 0) { | |
StringBuffer xConnectFromKey = new StringBuffer("XConnect From"); | |
if(xConnectFromRefList != null && xConnectFromRefList.size() > 0) { | |
for(int j = 0; j < xConnectFromRefList.size(); j++) { | |
xConnectFromKey.append(","+xConnectFromRefList.get(j)); | |
altCcmRef = altCcmRef+";"+xConnectFromRefList.get(j); | |
} | |
} | |
attributesInfo.put(xConnectFromKey.toString(), xConnectFrom); | |
iconLabelInfo.put(xConnectFromKey.toString(), xConnectFrom); | |
iconLabelInfo.put("altCcmRef", altCcmRef); | |
altCcmRef = ""; | |
xConnectFrom = ""; | |
} | |
if(bMultiXConnectToRef) { | |
StringBuffer xConnectToKey = new StringBuffer("XConnect To"); | |
if(xConnectToRefList != null && xConnectToRefList.size() > 0) { | |
for(int j = 0; j < xConnectToRefList.size(); j++) { | |
xConnectToKey.append(","+xConnectToRefList.get(j)); | |
ccmReference = ccmReference+";"+xConnectToRefList.get(j); | |
} | |
} | |
attributesInfo.put(xConnectToKey.toString(), xConnectTo); | |
iconLabelInfo.put(xConnectToKey.toString(), xConnectTo); | |
iconLabelInfo.put("ccmRef", ccmReference); | |
ccmReference = ""; | |
bMultiXConnectToRef = false; | |
xConnectTo = ""; | |
}else if(xConnectLabel != null && xConnectLabel.length() > 0) | |
attributesInfo.put("XConnect To", xConnectLabel.toString()); | |
} | |
if(bIsDxc) { | |
attributesInfo.put("altCcmRef", iconLabelInfo.get("altCcmRef")); | |
} | |
if(cktElement.equals("SITE")) { | |
attributesInfo.putAll(elementAttributesInfo.get(site)); | |
String siteName = site.substring(0,site.indexOf("#")); | |
attributesInfo.put("_attrLabel", "Site "+siteName+" Attributes"); | |
iconLabelInfo.put("iconLabel", node.get("_ATTRS>/id")); | |
String iconTag = siteMiscAttributes.get("Site Type Code"); | |
iconTag=getSiteIcon(iconTag).toLowerCase(); | |
iconLabelInfo.put("elementClass",iconTag); | |
iconLabelInfo.put("iconTag",iconTag); | |
String ownCompany = siteMiscAttributes.get("Owning Company"); | |
if(ownCompany!=null){ | |
iconLabelInfo.put("owningCompany",ownCompany); | |
iconLabelInfo.put("elementClass",ownCompany); | |
if(ownCompany.equals("UKBT")) | |
iconLabelInfo.put("iconTag","site-cpe-bt"); | |
} | |
} | |
else { | |
/* String equipId = node.get("_ATTRS>/id"); | |
String tid = node.get("Tid"); | |
String aid = attributesInfo.get("AID"); | |
if(tid == null) | |
tid = ""; | |
if(aid == null) | |
aid = ""; | |
String label = equipId+","+tid+","+aid; */ | |
String label = ""; | |
label = getEquipmentLabel(); | |
iconLabelInfo.put("iconLabel", label); | |
String iconTag = equipmentMiscAttributes.get("Display Class"); | |
if(iconTag==null){iconTag="unknown";} | |
String newIconTag = SessionHelper.getPropText(sObj, "SPECIALS.ICON."+iconTag,false); | |
if(newIconTag != null && newIconTag.length() > 0) | |
iconTag = newIconTag; | |
if(bIsDxc || bIsXConnectDXC) | |
iconTag = "dcs"; | |
bIsDxc = false; | |
bIsXConnectDXC = false; | |
// bIsNormalDxc = false; | |
bIsJack = false; | |
iconLabelInfo.put("iconTag", iconTag.toLowerCase()); | |
} | |
} | |
} | |
private void initializeInterpreter() { | |
interp = new Interpreter(); | |
try { | |
interp.set("attributesInfo", attributesInfo); | |
interp.set("extraAttributes", extraAttributes); | |
interp.set("aidInfoMap", aidInfoMap); | |
interp.set("iconLabelInfo", iconLabelInfo); | |
interp.set("linkInfoAttributes",linkInfoAttributes); | |
interp.set("endpoint1Attributes", endpoint1Attributes); | |
interp.set("endpoint2Attributes", endpoint2Attributes); | |
}catch(EvalError e) { | |
_logger.warn("error initializing interpreter: " + e); | |
interp = null; | |
} | |
} | |
private String getConnectorLabel() { | |
StringBuffer label = new StringBuffer(); | |
Set<String> connectorLabelTags = null; | |
Properties appProps = null; | |
WAConfig waConfig = DtixConfigMgr.getInstance().getWAConfig(); | |
if (waConfig != null) appProps = waConfig.getWAProperties(); | |
if(linkType.equalsIgnoreCase("RingRoute")) | |
connectorLabelTags = DtixConfigUtils.getPropSet(appProps,"SPECIALS.CONNECTOR.RingRoute.Label"); | |
else | |
connectorLabelTags = DtixConfigUtils.getPropSet(appProps,"SPECIALS.CONNECTOR.default.Label"); | |
Iterator<String> itr = connectorLabelTags.iterator(); | |
while(itr.hasNext()) { | |
String tag = itr.next(); | |
try { | |
String condScript = DtixConfigUtils.getPropText(appProps, tag); | |
String value = interp.eval(condScript).toString(); | |
label.append(value); | |
if(itr.hasNext()) | |
label.append(","); | |
}catch (EvalError e) { | |
_logger.warn("error initializing interpreter or executing script: " + tag + ", :" + e); | |
interp = null; | |
} | |
} | |
return label.toString(); | |
} | |
private String getEquipmentLabel() { | |
StringBuffer label = new StringBuffer(); | |
Set<String> equipmentLabelTags = null; | |
Properties appProps = null; | |
WAConfig waConfig = DtixConfigMgr.getInstance().getWAConfig(); | |
if (waConfig != null) appProps = waConfig.getWAProperties(); | |
if(bIsJack) | |
equipmentLabelTags = DtixConfigUtils.getPropSet(appProps, "SPECIALS.EQUIP.JACK.Label"); | |
else if(bIsDxc || bIsXConnectDXC) | |
equipmentLabelTags = DtixConfigUtils.getPropSet(appProps, "SPECIALS.EQUIP.DXC.Label"); | |
else | |
equipmentLabelTags = DtixConfigUtils.getPropSet(appProps, "SPECIALS.EQUIP.default.Label"); | |
if(prevLinkType.equalsIgnoreCase("XConnect") && !bIsXConnectDXC) { | |
Set<String> xConnectLabelTags = null; | |
xConnectLabelTags = DtixConfigUtils.getPropSet(appProps, "SPECIALS.EQUIP.XCONNECT.Label"); | |
if(equipmentLabelTags.contains("AID")) { | |
equipmentLabelTags.remove("AID"); | |
equipmentLabelTags.addAll(xConnectLabelTags); | |
} | |
} | |
Iterator<String> itr = equipmentLabelTags.iterator(); | |
while(itr.hasNext()) { | |
String tag = itr.next(); | |
try { | |
String condScript = DtixConfigUtils.getPropText(appProps, tag); | |
String value = interp.eval(condScript).toString(); | |
label.append(value); | |
if(itr.hasNext()) | |
label.append(","); | |
}catch (EvalError e) { | |
_logger.warn("error initializing interpreter or executing script: " + tag + ", :" + e); | |
interp = null; | |
} | |
} | |
return label.toString(); | |
} | |
/** This method is called to get any equipment attribute | |
* which falls under the CCM hierarchy path | |
* @param source | |
* @param ccmPathTokens | |
* @param refTokens | |
* @param node | |
* @param ccmPathPoint | |
* @param refTokenPoint | |
* @param path | |
* @return | |
*/ | |
private String getCCMPathValues(String source,String[] ccmPathTokens, String[] refTokens, | |
FancyHash node,int ccmPathPoint,int refTokenPoint,String path) { | |
String value = ""; | |
String ccmPathToken = ccmPathTokens[ccmPathPoint]; | |
Vector<FancyHash> subNodeDetails = node.getAggs(ccmPathToken); | |
if(subNodeDetails != null && subNodeDetails.size() > 0) { | |
for(int i = 0; i < subNodeDetails.size(); i++) { | |
String attributeId = subNodeDetails.elementAt(i).get("_ATTRS>/id"); | |
if(attributeId != null /*&& attributeId.length() > 0*/) { | |
String refId = refTokens[refTokenPoint]; | |
if(attributeId.equalsIgnoreCase(refId)) { | |
if(source.equalsIgnoreCase(ccmPathToken)) { | |
value = subNodeDetails.elementAt(i).get(path); | |
if(value == null || value.length() == 0) { | |
Vector<FancyHash> miscAttributes = subNodeDetails.elementAt(i).getAggs("Misc/KVP"); | |
if(miscAttributes != null && miscAttributes.size() > 0) { | |
for(int j = 0; j < miscAttributes.size(); j++) { | |
String miscKey = miscAttributes.elementAt(j).get("_ATTRS>/Key"); | |
if(miscKey.equalsIgnoreCase(path)) | |
value = miscAttributes.get(j).get("_ATTRS>/Value"); | |
} | |
} | |
} | |
break; | |
} else { | |
if(ccmPathPoint+1 < ccmPathTokens.length && refTokenPoint+1 < refTokens.length) { | |
ccmPathPoint++; | |
refTokenPoint++; | |
FancyHash subNode = subNodeDetails.elementAt(i); | |
value = getCCMPathValues(source,ccmPathTokens,refTokens,subNode,ccmPathPoint, | |
refTokenPoint,path); | |
}else | |
continue; | |
} | |
} else { | |
continue; | |
} | |
} else { | |
if(ccmPathPoint+1 < ccmPathTokens.length && refTokenPoint+1 < refTokens.length) { | |
ccmPathPoint++; | |
refTokenPoint++; | |
FancyHash subNode = subNodeDetails.elementAt(i); | |
value = getCCMPathValues(source,ccmPathTokens,refTokens,subNode,ccmPathPoint, | |
refTokenPoint,path); | |
} else | |
continue; | |
} | |
} | |
} | |
return value; | |
} | |
/** This method returns iconTag | |
* as Unknown if it is null | |
* @param iconTag | |
* @return | |
*/ | |
private String getSiteIcon(String iconTag) { | |
if(iconTag!=null) iconTag = iconTag.toLowerCase(); | |
String icon = siteIconMap.get(iconTag); | |
if(icon==null) icon="unknown"; | |
return icon; | |
} | |
/** This method differentiates between equipments | |
* and connectors | |
* @param node | |
* @param cktElement | |
* @param ccmPath | |
* @param bConnector | |
* @param reference | |
*/ | |
private void populateIconsLabelsAttributes(FancyHash node,String cktElement,String ccmPath, | |
boolean bConnector,String reference) { | |
iconLabelInfo.put("elementClass",cktElement); | |
String elementInList = ""; | |
if(bConnector) { | |
if(elementCount.containsKey(cktElement)) { | |
int noOfElements = elementCount.get(cktElement); | |
elementCount.put(cktElement, noOfElements+1); | |
elementInList = cktElement+"_"+String.valueOf(noOfElements+1); | |
} else { | |
if(cktElement.equalsIgnoreCase("")) { | |
elementInList = ""; | |
} else { | |
elementCount.put(cktElement,1); | |
elementInList = cktElement+"_"+String.valueOf(1); | |
} | |
} | |
if(bInterSite) { | |
cktElements.add(elementInList); | |
} else { | |
siteElements.add(elementInList); | |
cktElements.add(elementInList); | |
} | |
getElementAttributes(elementInList,false,node,true,ccmPath); | |
} else { | |
//Check if any elements are left out of site | |
if(siteElements.size()>0 && !siteElements.get(siteElements.size()-1).equals(cktElements.get(cktElements.size()-1))){ | |
for(int k=cktElements.indexOf(siteElements.get(0));k<cktElements.size();k++){ | |
if(!siteElements.contains(cktElements.get(k))){ | |
siteElements.add(cktElements.get(k)); | |
} | |
} | |
} | |
siteElements.add(reference); | |
cktElements.add(reference); | |
getElementAttributes(reference,false,node,false,ccmPath); | |
} | |
LinkedHashMap attributesInfoMap = new LinkedHashMap(); | |
HashMap iconLabelInfoMap = new HashMap(); | |
attributesInfoMap.putAll(attributesInfo); | |
iconLabelInfoMap.putAll(iconLabelInfo); | |
if(bConnector) { | |
elementAttributesInfo.put(elementInList, attributesInfoMap); | |
elementIconLabelInfo.put(elementInList, iconLabelInfoMap); | |
} else { | |
elementAttributesInfo.put(reference, attributesInfoMap); | |
elementIconLabelInfo.put(reference, iconLabelInfoMap); | |
} | |
extraAttributesMap.put(reference,extraAttributes); | |
} | |
/** Preparation of D_ELEMENT_STATUS datablock | |
* | |
* @param request | |
* @param elementStatusDBlk | |
* @param resultObj | |
* @return | |
*/ | |
public static boolean prepElementStatusUpdates(HttpServletRequest request,DataBlock elementStatusDBlk, | |
Result resultObj){ | |
boolean updatesMade = false; | |
List<String> errElemList = resultObj.getFailedComponentList(); | |
for (int i=0; i< errElemList.size();i++) { | |
// if necessary to update D_ELEMENT_STATUS entry, set updatesMade = true | |
String elemId = errElemList.get(i); | |
elementStatusDBlk.set(elemId, "FAULT"); | |
updatesMade = true; | |
} | |
ArrayList<HashMap<String, String>> statusList = resultObj.getResearchStatusInfo(); | |
for(int i=0;i<statusList.size();i++){ | |
HashMap<String,String> status = statusList.get(i); | |
if(status.get("topologyId")!=null){ | |
String topId = status.get("topologyId"); | |
Object oldStat = elementStatusDBlk.get(topId); | |
String oldStatus = null; | |
JSONArray statusInfArr = null; | |
if(oldStat instanceof String) | |
oldStatus = oldStat.toString(); | |
else if(oldStat instanceof JSONObject){ | |
statusInfArr = (JSONArray)((JSONObject)oldStat).get("statusInfo"); | |
oldStatus = (String)((JSONObject)oldStat).get("status"); | |
} | |
if(statusInfArr==null) | |
statusInfArr = new JSONArray(); | |
if(oldStatus==null) | |
oldStatus = "NOOP"; | |
JSONObject statusObj = new JSONObject(); | |
statusObj.put("status", oldStatus); | |
JSONObject statusInfObj = new JSONObject(); | |
statusInfObj.put("statusType","research"); | |
statusInfObj.put("researchType",status.get("researchType")); | |
statusInfObj.put("aid",status.get("aid")); | |
statusInfObj.put("timestamp",status.get("timestamp")); | |
statusInfObj.put("htmlRef",status.get("htmlRef")); | |
statusInfArr.add(statusInfObj); | |
statusObj.put("statusInfo", statusInfArr); | |
elementStatusDBlk.set(topId,statusObj); | |
updatesMade = true; | |
} | |
} | |
SessionDataObject sdo = SessionHelper.getSessionDataObject(request); | |
if(sdo!=null){ | |
HashSet<String> stateCmds=new HashSet<String>(); | |
stateCmds.add(DtixWebConstants.SPECIALS_TL1_CHANGE_IS); | |
stateCmds.add(DtixWebConstants.SPECIALS_TL1_CHANGE_OOS); | |
stateCmds.add(DtixWebConstants.SPECIALS_TL1_ENABLE_LPBK); | |
stateCmds.add(DtixWebConstants.SPECIALS_TL1_RELEASE_LPBK); | |
stateCmds.add(DtixWebConstants.SPECIALS_TL1_SWITCH2PROT); | |
stateCmds.add(DtixWebConstants.SPECIALS_TL1_SWITCH2WKGT); | |
String ac = sdo.getActionId(); | |
if(stateCmds.contains(ac)){ | |
String msg = resultObj.getMsgResults(); | |
if(msg!=null && msg.contains("<TRBL_CODE>TSDELTOK</TRBL_CODE>")){ | |
String topRef = sdo.getTopologyRef(); | |
Object oldStat = elementStatusDBlk.get(topRef); | |
String oldStatus = null; | |
JSONArray statusInfArr = null; | |
if(oldStat instanceof String) | |
oldStatus = oldStat.toString(); | |
else if(oldStat instanceof JSONObject){ | |
statusInfArr = (JSONArray)((JSONObject)oldStat).get("statusInfo"); | |
oldStatus = (String)((JSONObject)oldStat).get("status"); | |
} | |
if(statusInfArr==null) | |
statusInfArr = new JSONArray(); | |
if(oldStatus==null) | |
oldStatus = "NOOP"; | |
JSONObject statusObj = new JSONObject(); | |
statusObj.put("status", oldStatus); | |
JSONObject statusInfObj = new JSONObject(); | |
statusInfObj.put("statusType","state"); | |
statusInfObj.put("state",getDvcState(ac,msg)); | |
statusInfArr.add(statusInfObj); | |
statusObj.put("statusInfo", statusInfArr); | |
elementStatusDBlk.set(topRef,statusObj); | |
updatesMade = true; | |
} | |
} | |
} | |
return updatesMade; | |
} | |
private static String getDvcState(String ac,String msg) { | |
String state=null; | |
if(DtixWebConstants.SPECIALS_TL1_CHANGE_IS.equals(ac)) state="is"; | |
else if(DtixWebConstants.SPECIALS_TL1_CHANGE_OOS.equals(ac)) state="oos"; | |
else if(DtixWebConstants.SPECIALS_TL1_ENABLE_LPBK.equals(ac)) { | |
if(msg.contains("<LPBKTYPE>TERM</LPBKTYPE>")) state="elpbk_t"; | |
else state="elpbk_f"; | |
} | |
else if(DtixWebConstants.SPECIALS_TL1_RELEASE_LPBK.equals(ac)) state="rlpbk"; | |
else if(DtixWebConstants.SPECIALS_TL1_SWITCH2PROT.equals(ac)) state="s2p"; | |
else if(DtixWebConstants.SPECIALS_TL1_SWITCH2WKGT.equals(ac)) state="s2w"; | |
return state==null?DtixWebConstants.PROP_ID_STRING_EMPTY:state; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment