July 5, 2012

Posted in Uncategorized at 7:24 am by mrrohit007

<%@

pageimport=“com.maxis.global.common.BizCmnFunctions”%>

<%@

pageimport=“com.maxis.common.util.BeanLocatorFactory”%>

<%@

pageimport=“java.util.List”%>

<%@

pageimport=“com.maxis.portal.assetmgmt.bpo.AssetManagementBPO”%>

<%

AssetManagementBPO assetManagementBPO = (AssetManagementBPO)BeanLocatorFactory.getService(

“AssetManagementBPO”);

UserManagementBPO userManagementBPO = (UserManagementBPO)BeanLocatorFactory.getService(

“UserManagementBPO”);

int expandItems = 0;

boolean blnShowHistory = false;

boolean blnEmptyAsset = false;

boolean blnAssetInProgress  = false;

    String contextPath = request.getContextPath();

    StringBuilder assetDetails =

new StringBuilder();

//default styles if style properties are not present for the particular asset

    String style1 =

“background-color:#edebc9;”;

    String style2 =

“background-color:#f6f5e4;”;

    String style3 =

“background-color:#fafaf1;”;

    String style4 =

“border-color:#e5e5b2;”;

    String style5 =

“#e5e5b2”;

    String imageIcon =

“asset/images/defalut.jpg”;

    String assetId = BizCmnFunctions.checkNull(request.getParameter(

“assetId”));

String strExpandItems = BizCmnFunctions.checkNull(request.getParameter(

“expandItems”));

String showHistory = BizCmnFunctions.checkNull(request.getParameter(

“sh”));

if(strExpandItems != “”)

expandItems = Integer.parseInt(strExpandItems);

if(showHistory != “”)

blnShowHistory = Boolean.parseBoolean(showHistory);

if(assetId != “”){

   Asset asset = assetManagementBPO.getAssetByAssetIdHavingDeleteInd(assetId);

if(asset != null){

//checks if asset is being updated

boolean inProgress =  AssetManagementInterceptor.isAssetUpdateInProgress(assetId);

//boolean inProgress =  true;

   String assetLabel =

“”;

   String assetCallBackId = asset.getAssetCallBackId();

//retriving all style properties of Asset which is shown as different layers of asset

   AssetEntity assetEntity = assetManagementBPO.getAssetEntityByAssetEntityId(asset.getAssetEntityId());

if(assetEntity.getStyle1() != null && assetEntity.getStyle2() != null &&

   assetEntity.getStyle3() !=

null && assetEntity.getStyle4() != null &&

   assetEntity.getStyle5() !=

null && assetEntity.getImageIcon() != null){

    style1 = assetEntity.getStyle1();

    style2 = assetEntity.getStyle2();

    style3 = assetEntity.getStyle3();

    style4 = assetEntity.getStyle4();

    style5 = assetEntity.getStyle5();

    imageIcon = assetEntity.getImageIcon();

   }

   assetDetails.append(

“<div id='”+asset.getAssetId()+“_asset’ class=’divWindow wordwrapText’ style='”+style4+“margin-top:6px;margin-bottom:6px;margin-left:50px;margin-right:50px;’>”);

if(!inProgress){

   UserInfo createdUserInfo = userManagementBPO.getUserInfoById(asset.getAuditBean().getCreateById());

   UserInfo modifiedUserInfo =

null;

if(asset.getAuditBean().getModById() != null)

   modifiedUserInfo = userManagementBPO.getUserInfoById(asset.getAuditBean().getModById());

   AssetEntityProperty assetEntityProperty = assetManagementBPO.getAssetEntityPropertyByAssetEntityIdAndCaptionInd(assetEntity.getAssetEntityId());

if(assetEntityProperty != null){

   AssetProperty assetProperty = assetManagementBPO.getAssetPropertyByPropKeyAndAssetId(assetEntityProperty.getPropertyKey(),asset.getAssetId()).get(0);

if(assetProperty != null){

   assetLabel = assetProperty.getValue();

   }

   }

if(!assetLabel.equals(“”))

   assetLabel = assetLabel+

” – “+assetEntity.getEntityLable();

else

 

   assetLabel = assetEntity.getEntityLable();

   assetDetails.append(

“<table id='”+asset.getAssetId()+“_layout’ width=’100%’ cellspacing=’0′ cellpadding=’6′ border=’0′ >”);

   assetDetails.append(

“<tr style='”+style1+“‘ onmouseover=’showAssetTooltip(&quot;”+asset.getAssetId()+“&quot;,&quot;”+style1+“&quot;,&quot;”+style4+“&quot;)’ onmouseout=’hideAssetTooltip(&quot;”+asset.getAssetId()+“&quot;)’>”);

   assetDetails.append(

“<td valign=’middle’ align=’center’>”);

   assetDetails.append(

“<img id='”+asset.getAssetId()+“_icon’ src=”+contextPath+“/”+imageIcon+” width=’11px’ height=’11px’ title='”+assetEntity.getEntityLable()+“‘ alt='”+assetEntity.getEntityLable()+“‘ />”);

   assetDetails.append(

“</td>”);

   assetDetails.append(

“<td valign=’middle’ align=’left’>”);

   assetDetails.append(

“<div class=’wordwrapText’ style=’width:250px;overflow:hidden;’ >”+assetLabel+“</div>”);

        assetDetails.append(

“</td>”);

   assetDetails.append(

“</tr>”);

   assetDetails.append(

“<tr style='”+style2+“‘>”);

   assetDetails.append(

“<td colspan=’2′>”);

   assetDetails.append(

“<span style=’color:gray;’>Created by </span>”);

   assetDetails.append(

“<span style=’font-weight:bold;’>”+ createdUserInfo.getFirstName()+” “+createdUserInfo.getLastName()+” “+“</span>”);

if(asset.getAuditBean().getCreateDtm() != null && !asset.getAuditBean().getCreateDtm().equals(“”))

   assetDetails.append(

“<span style=’color:gray;font-weight:bold;’>”+ new SimpleDateFormat(“yyyy-MM-dd HH:mm:ss”).format(asset.getAuditBean().getCreateDtm()) +” IST”+“</span>”);

   assetDetails.append(

“<br/>”);

if(modifiedUserInfo != null){

   assetDetails.append(

“<span style=’color:gray;’>Modified by </span>”);

   assetDetails.append(

“<span style=’font-weight:bold;’>”+ modifiedUserInfo.getFirstName()+” “+modifiedUserInfo.getLastName()+” “+“</span>”);

if(asset.getAuditBean().getModDtm() != null && !asset.getAuditBean().getModDtm().equals(“”))

   assetDetails.append(

“<span style=’color:gray;font-weight:bold;’>”+new SimpleDateFormat(“yyyy-MM-dd HH:mm:ss”).format(asset.getAuditBean().getModDtm())+” IST”+“</span>”);

   }

   assetDetails.append(

“</td>”);

       assetDetails.append(

“</tr>”);

       String width =

“35%”;

       assetDetails.append(

“<tr style='”+style3+“‘>”);

   assetDetails.append(

“<td colspan=’2′ align=’left’ valign=’middle’>”);

   assetDetails.append(

“<table width=’100%’ border=’0′ cellspacing=’0′ cellpadding=’0′>”);

       assetDetails.append(

“<tr>”);

   assetDetails.append(

“<td width=’5%’>”);

   assetDetails.append(

“<img src='”+contextPath+“/images/plus.png’ alt=’expand’ title=’expand’ class=’imgPlusStyle_left’ id='”+asset.getAssetId()+“_img_plus_left’ onclick=’getLeftItems(&quot;”+asset.getAssetId()+“&quot;,&quot;containerEle_parent&quot;)’ />”);

   assetDetails.append(

“</td>”);

if(assetEntity.getOpenAssetLnk() != null){

      assetDetails.append(

“<td width=’35%’ align=’right’ valign=’top’>”);

          assetDetails.append(

“<span id='”+assetCallBackId+“‘ style=’cursor:pointer;text-decoration:underline;’ title=’open link’ onclick='”+assetEntity.getOpenAssetLnk()+“‘ >open link</span>”);

          assetDetails.append(

“</td>”);

   }

else{

   assetDetails.append(

“<td width=’35%’>&nbsp;</td>”);

   }

if(blnShowHistory){

   assetDetails.append(

“<td width=’29%’ align=’right’ valign=’top’>”);

       assetDetails.append(

“<span id='”+asset.getAssetId()+“_sh’ class=’show_history’ style=’cursor:pointer;text-decoration:underline;’ title=’show history’ onclick=’showHistory(this.id)’>show history</span>”);

       assetDetails.append(

“</td>”);

   }

else{

   width =

“20%”;

   }

       assetDetails.append(

“<td width='”+width+“‘ align=’right’ valign=’top’>”);

       assetDetails.append(

“<span id='”+asset.getAssetId()+“_showmore’ style=’margin-right:15px;cursor:pointer;text-decoration:underline;’ title=’show more’ onclick=’showProperties(&quot;”+asset.getAssetId()+“&quot;)’>show more</span>”);

       assetDetails.append(

“</td>”);

   assetDetails.append(

“<td width=’5%’>”);

   assetDetails.append(

“<img src='”+contextPath+“/images/plus.png’  alt=’expand’ title=’expand’ class=’imgPlusStyle_right’ id='”+asset.getAssetId()+“_img_plus_right’ onclick=’getRightItems(&quot;”+asset.getAssetId()+“&quot;,&quot;”+style5+“&quot;,&quot;containerEle_child&quot;)’ />”);

   assetDetails.append(

“</td>”);

       assetDetails.append(

“</tr>”);

   assetDetails.append(

“</table>”);

   assetDetails.append(

“</td>”);

       assetDetails.append(

“</tr>”);

//retrieving asset properties to display in read more link

   assetDetails.append(

“<tr bgcolor=’#ffffff’ id='”+asset.getAssetId()+“_property’ style=’display:none’>”);

   assetDetails.append(

“<td  colspan=’2′>”);

   assetDetails.append(

“<div id='”+asset.getAssetId()+“_propertyDiv’ style=’width:293px;’>”);

   assetDetails.append(

“</div>”);

   assetDetails.append(

“</td>”);

   assetDetails.append(

“</tr>”);

   assetDetails.append(

“</table>”);

   }

else{

   blnAssetInProgress =

true;

   assetDetails.append(

“<table width=’100%’ height=’100%’ cellspacing=’0′ cellpadding=’6′ border=’0′>”);

   assetDetails.append(

“<tr style='”+style1+“‘>”);

   assetDetails.append(

“<td colspan=’2′>&nbsp;</td>”);

   assetDetails.append(

“</tr>”);

   assetDetails.append(

“<tr style='”+style1+“‘>”);

   assetDetails.append(

“<td align=’right’>”);

   assetDetails.append(

“<img src='”+contextPath+“/images/ajax-loader.gif’ width=’16’ height=’16’/>”);

   assetDetails.append(

“</td>”);

   assetDetails.append(

“<td align=’left’>”);

   assetDetails.append(

“Please wait,asset updation is in progress”);

   assetDetails.append(

“</td>”);

   assetDetails.append(

“<tr style='”+style1+“‘>”);

   assetDetails.append(

“<td colspan=’2′>&nbsp;</td>”);

   assetDetails.append(

“</tr>”);

   assetDetails.append(

“</table>”);

   }

   assetDetails.append(

“<div class=’divClears’></div></div>”);

   }

else{

   blnEmptyAsset =

true;

   assetDetails.append(

“<div class=’divWindow wordwrapText’ style=’border:1px solid #8db2e3′>”);

   assetDetails.append(

“<table width=’100%’ height=’100%’ cellspacing=’0′ cellpadding=’6′ border=’0′>”);

   assetDetails.append(

“<tr bgcolor=’#e2f0ff’>”);

   assetDetails.append(

“<td colspan=’2′>&nbsp;</td>”);

   assetDetails.append(

“</tr>”);

   assetDetails.append(

“<tr bgcolor=’#e2f0ff’>”);

   assetDetails.append(

“<td align=’right’>”);

   assetDetails.append(

“<img src='”+contextPath+“/images/ajax-loader.gif’ width=’16’ height=’16’/>”);

   assetDetails.append(

“</td>”);

   assetDetails.append(

“<td align=’left’>”);

   assetDetails.append(

“Please wait,asset creation is in progress”);

   assetDetails.append(

“</td>”);

   assetDetails.append(

“<tr bgcolor=’#e2f0ff’>”);

   assetDetails.append(

“<td colspan=’2′>&nbsp;</td>”);

   assetDetails.append(

“</tr>”);

   assetDetails.append(

“</table>”);

   assetDetails.append(

“<div class=’divClears’></div></div>”);

}

   }

%>

<%@

pageimport=“com.maxis.bean.domain.Asset”%>

<%@

pageimport=“com.maxis.bean.domain.AssetEntity”%>

<%@

pageimport=“com.maxis.bean.domain.AssetProperty”%>

<%@

pageimport=“com.maxis.bean.domain.AssetType”%>

<%@

pageimport=“java.util.ArrayList”%>

<%@

pageimport=“java.util.HashMap”%>

<%@

pageimport=“com.maxis.bean.domain.AssetTrack”%>

<%@

pageimport=“com.maxis.bean.domain.UserInfo”%>

<%@

pageimport=“com.maxis.ecore.bpo.UserManagementBPO”%>

<%@

pageimport=“java.text.SimpleDateFormat”%>

<%@

pageimport=“com.maxis.bean.domain.AssetEntityProperty”%>

<%@

pageimport=“com.maxis.portal.assetmgmt.AssetManagementInterceptor”%><html>

<

head>

<

title>Dependency Graph</title>

<

styletype=“text/css”>

body table

{

font-family:Arial, Helvetica, sans-serif;

font-size:11px;

color:#003366;

}

.divWindow

{

font-size:11px;

width: 305px;

height:auto;

/*-moz-box-shadow: 3px 3px 3px #d2e5ff;*/

/*-webkit-box-shadow: 3px 3px 3px #d2e5ff;*/

/*box-shadow: 3px 3px 3px #d2e5ff;*/

}

.imgPlusStyle_right

{

float:right;

width:13;

height:13;

cursor:pointer;

}

.imgPlusStyle_left

{

float:left;

width:13;

height:13;

cursor:pointer;

}

.divClears

{

clear:both;

}

.wordwrapText

{

word-wrap: break-word;

}

</

style>

<!– <script type=”text/javascriptsrc=”<%=request.getContextPath()%>/extjs/adapter/ext/ext-base.js”></script>

<script type=”text/javascriptsrc=”

<%=request.getContextPath()%>/extjs/ext-all.js”></script>

–>

<scripttype=“text/javascript”src=<%=request.getContextPath()%>/js/jquery/js/jquery-1.3.2.min.js”></script>

<scripttype=“text/javascript”src=<%=request.getContextPath()%>/js/jquery/js/jquery-ui-1.7.2.custom.min.js”></script>

<scripttype=“text/javascript”src=<%=request.getContextPath()%>/js/jsplumb/jquery.jsPlumb-1.3.7-all-min.js”></script>

<scripttype=“text/javascript”src=<%=request.getContextPath()%>/js/maxis/jquery.json-2.2.min.js”></script>

<scripttype=“text/javascript”>

var progressBar;

var rightTargetIds = new Array();

var historyWinIds = new Array();

var simpleTipIds = new Array();

var assetId = “<%=assetId%>“;

var expandItems = “<%=expandItems%>“;

var assetDetails = “<%=assetDetails.toString()%>“;

var blnShowHistory = “<%=blnShowHistory%>“;

var blnEmptyAsset = “<%=blnEmptyAsset%>“;

var blnAssetInProgress = “<%=blnAssetInProgress%>“;

var contextPath = “<%=contextPath%>“;

var jsPlumbConnInstance;

var color = “<%=style5%>“;

var arrowColors = new Array();

var jsPlumbConnInstanceArr = new Array();

//calls on body load

function pageInit()

{

//expandItems = 12;

//check if asset is created or not

if(blnEmptyAsset == “true”){

$(

“#containerEle”).append(generateDivComponent(assetId,“containerEle”,assetDetails));

checkAsset(assetId);

}

//checks if asset status is beign updated

elseif(blnAssetInProgress == “true”){

$(

“#containerEle”).append(generateDivComponent(assetId,“containerEle”,assetDetails));

checkAssetInProgress(

“”,assetId,blnShowHistory,“containerEle”)

}

elseif(assetId != “” && assetDetails != “”){

$(

“#containerEle”).append(generateDivComponent(assetId,“containerEle”,assetDetails));

if(expandItems >= 2){

expandMultipleItems(assetId,color,

“containerEle_child”);

}

elseif(expandItems == 1){

getRightItems(assetId,color,

“containerEle_child”);

}

if($.browser.msie){

//IE fix

$(

“#containerEle_Parent”).draggable({

cursor:

“move”,

disabled:

false,

addClasses:

false,

drag:

function(event, ui) {

doLayoutVersionHistory();

}

});

}

else{

$(

“#containerEle”).draggable({

cursor:

“move”,

disabled:

false,

addClasses:

false,

stop :

function(event, ui) {

doLayoutVersionHistory();

}

});

}

}

}

//checks if asset is created

function checkAsset(assetId){

jQuery.ajax({

    url: ‘

<%=request.getContextPath()%>/asset/DependencyGraph/dependencyData.jsp‘,

    type:

‘POST’,

    data :{

    assetId :assetId,

                items:

“checkAsset”,

                token:

new Date()

                },

                success:

function (result)

                {

if($.trim(result) == “true”){

                window.location.reload();

            }

else{

            window.setTimeout(

“checkAsset(‘”+assetId+“‘)”,1000);

        }

                },

                failure:

function(result){

         }

});

}

//check child/parent assets are being updated

function checkAssetInProgress(id,assetId,blnShowHistory,containerEle){

jQuery.ajax({

url: ‘

<%=request.getContextPath()%>/asset/DependencyGraph/dependencyData.jsp‘,

    type:

“POST”,

    data :{

    assetId :assetId,

items:

“asset”,

blnShowHistory:blnShowHistory,

containerEle:containerEle,

               token:

new Date()

               },

   success:

function(result)

   {

if($.trim(result) == “true”){

   window.setTimeout(

“checkAssetInProgress(‘”+id+“‘,'”+assetId+“‘,”+blnShowHistory+“,'”+containerEle+“‘)”,1000);

   }

else{

var jsonData = jQuery.evalJSON(result);

if(document.getElementById(jsonData.assetId+“_asset”) != null)

   document.getElementById(jsonData.assetId+

“_asset”).innerHTML = jsonData.assetDetails;

if(id != “”){

var connInstance = jsPlumbConnInstanceArr[id];

if(connInstance != undefined){

if(rightTargetIds[id] != undefined && rightTargetIds[id].length > 0 ){

connInstance.repaintEverything();

}

}

   }

   }

   },

failure:

function(result){

  }

});

}

//shows asset properties as tooltip for asset

function showAssetTooltip(id,bgColor,borderColor){

bgColor = bgColor.substring(bgColor.indexOf(

“:”)+1,bgColor.indexOf(“;”));

borderColor = borderColor.substring(borderColor.indexOf(

“:”)+1,borderColor.indexOf(“;”));

var position = $(“#”+id+“_icon”).offset();

var leftPos = position.left;

var topPos = position.top;

var propDiv = document.getElementById(id+“_propertyDiv”);

var simpleTipDiv = document.getElementById(id+“_simpletip”);

if(simpleTipIds[id+“_simpletip”] == undefined)

  simpleTipIds[id+

“_simpletip”] = id+“_simpletip”;

if(simpleTipDiv == null){

  $(

‘<div id=”‘+id+‘_simpletip”></div>’).css({

‘position’: ‘absolute’,

‘display’: ‘none’,

‘top’: topPos+20,

‘left’: leftPos-100,

‘width’:‘293px’,//250

‘height’:‘auto’,

‘border’:borderColor,

‘padding’: ‘5px’,

‘z-index’: ‘8890’,

‘background-color’:bgColor,

‘font-family’:‘Arial, Helvetica, sans-serif’,

‘font-size’:’11px’

        }).appendTo(

“body”).fadeIn(500);

}

if(simpleTipDiv != null && propDiv.innerHTML != “”){

document.getElementById(id+

“_simpletip”).innerHTML = propDiv.innerHTML;

$(

“#”+id+“_simpletip”).css({

top: topPos+20,

        left: leftPos-100

}).show();

}

elseif(simpleTipDiv != null && simpleTipDiv.innerHTML != “”){

$(

“#”+id+“_simpletip”).css({

top: topPos+20,

        left: leftPos-100

}).show();

}

else{

jQuery.ajax({

    url: ‘

<%=request.getContextPath()%>/asset/DependencyGraph/dependencyData.jsp‘,

    type:

‘POST’,

    async:

false,

    data :{

    assetId :id,

                items:

“properties”,

                token:

new Date()

                },

                success:

function (result)

                {

var content = $.trim(result);

                document.getElementById(id+

“_simpletip”).innerHTML = content;

                },

                failure:

function (result) {

  }

});

}

    }

//hide asset tooltip

function hideAssetTooltip(id){

if(document.getElementById(id+“_simpletip”) != null)

$(

“#”+id+“_simpletip”).hide();

}

//retrieves history details of asset properties

function showHistory(id){

var assetId = id.substring(0,id.indexOf(“_”));

var spanEle = document.getElementById(id);

spanEle.innerHTML =

“hide history”;

spanEle.title =

“hide history”;

spanEle.onclick =

function(e){

var evt = window.event || e ;//cross browserevent object

hideHistory(id);

};

if(historyWinIds[assetId+“_history”] == undefined)

historyWinIds[assetId+

“_history”] = assetId+“_history”;

var position = $(“#”+id).offset();

var leftPos = position.left;

var topPos = position.top+25;

if(document.getElementById(assetId+“_history”) == null){

$(

‘<div id=”‘+assetId+‘_history”><img id=”‘+assetId+‘_loadImg” src=”‘+contextPath+‘/images/ajax-loader.gif” width=”16″ height=”16″></div>’).css({

‘position’: ‘absolute’,

‘left’:+leftPos+,

‘top’:+topPos+,

‘z-index’: ‘8888’,

‘width’:‘350px’,

‘min-height’:’50px’,

‘max-height’:‘320px’,

‘overflow’:‘auto’

        }).appendTo(

“body”);

jQuery.ajax({

    url: ‘

<%=request.getContextPath()%>/asset/DependencyGraph/dependencyData.jsp‘,

    type:

‘POST’,

    async:

false,

    data :{

    assetId :assetId,

                items:

“showHistory”,

                token:

new Date()

                },

                success:

function ( result )

                {

var jsonData = jQuery.evalJSON(result);

      document.getElementById(assetId+

“_history”).innerHTML = jsonData.historyDetails;

                },

                failure:

function (result) {

  }

});

}

else{

  $(

“#”+assetId+“_history”).css({

‘left’:+leftPos+,

‘top’:+topPos+

});

}

  $(

“#”+assetId+“_history”).show( “fold”, {}, 500 );

  }

//hide history details

function hideHistory(id){

var assetId = id.substring(0,id.indexOf(“_”));

var spanEle = document.getElementById(id);

spanEle.innerHTML =

“show history”;

spanEle.title =

“show history”;

spanEle.onclick =

function(e){

var evt = window.event || e ;//cross browserevent object

showHistory(id);

};

$(

“#”+assetId+“_history”).hide( “fold”, {}, 500 );

}

//changes the position of history div when other assets as moved

function doLayoutVersionHistory(){

for(var historyId in historyWinIds){

if(historyWinIds[historyId] != undefined){

var id = historyWinIds[historyId];

var assetId = id.substring(0,id.indexOf(“_”));

if(document.getElementById(id) != null){

var position = $(“#”+assetId+“_sh”).offset();

var leftPos = position.left;

var topPos = position.top+25;

  $(

“#”+id).css({‘left’:+leftPos+,

‘top’:+topPos+});

}

  }

  }

  }

//remove asset history details from DOM

function removeHistory(id){

if(historyWinIds[id+“_history”] != undefined){

if(document.getElementById(id+“_history”) != null){

$(

“#”+id+“_history”).remove();

delete simpleTipIds[id+“_history”];

  }

  }

  }

//remove tooltips from DOM

function removeToolTip(id){

if(simpleTipIds[id+“_simpletip”] != undefined){

if(document.getElementById(id+“_simpletip”) != null){

$(

“#”+simpleTipIds[id+“_simpletip”]).remove();

delete simpleTipIds[id+“_simpletip”];

}

}

}

//shows asset properties

function showProperties(id){

var anchEle = document.getElementById(id+“_showmore”);

  anchEle.innerHTML =

“hide”;

  anchEle.title =

“hide”;

  anchEle.onclick =

function(e){

var evt = window.event || e ;//cross browserevent object

hideProperties(id);

};

if(document.getElementById(id+“_propertyDiv”).innerHTML == “”){

jQuery.ajax({

    url: ‘

<%=request.getContextPath()%>/asset/DependencyGraph/dependencyData.jsp‘,

    type:

‘POST’,

    async:

false,

    data :{

    assetId :id,

                items:

“properties”,

                token:

new Date()

                },

                success:

function (result)

                {

                document.getElementById(id+

“_propertyDiv”).innerHTML = result;

                },

                failure:

function (result) {

  }

});

  }

document.getElementById(id+

“_property”).style.display = ‘table-row’;

            $(

“#”+id+“_showmore”).focus();

doLayoutVersionHistory();

repaintConnections();

  }

//hide asset properties

function hideProperties(id){

  document.getElementById(id+

“_property”).style.display = ‘none’;

var anchEle = document.getElementById(id+“_showmore”);

  anchEle.innerHTML =

“show more”;

  anchEle.title =

“show more”;

  anchEle.onclick =

function(e){

var evt = window.event || e ;//cross browserevent object

showProperties(id);

};

$(

“#”+id+“_showmore”).focus();

doLayoutVersionHistory();

repaintConnections();

  }

//repaint every connection when new assets are expanded

function repaintConnections(){

for(var connId in jsPlumbConnInstanceArr){

//alert(“connId >>>”+connId);

var connInstance = jsPlumbConnInstanceArr[connId];

//alert(“connInstance >>>”+connInstance);

if(connInstance != undefined){

if(rightTargetIds[connId] != undefined && rightTargetIds[connId].length > 0 ){

connInstance.repaintEverything();

}

else{

connInstance.reset();

}

}

}

  }

//creates connection between expanded asset with its child/parent assets

function createConnection(id)

{

jsPlumb.ready(

function() {

jsPlumb.Defaults.Container =

‘containerEle’;

    jsPlumbConnInstance = jsPlumb.getInstance();

jsPlumbConnInstance.setRenderMode(jsPlumb.CANVAS);

jsPlumbConnInstanceArr[id] = jsPlumbConnInstance;

var overlays = [[ “Arrow”, { location:1 }, { foldback:0.5, fillStyle:color, width:12 } ]];

var divSrcId = id;

if(arrowColors[divSrcId] != undefined)

color = arrowColors[divSrcId];

var childs = rightTargetIds[id];

if(childs != undefined){

for(var i=0; i<childs.length; i++){

var divDestId = childs[i];

if(divDestId != “” && divDestId != undefined){

var componentSrc = document.getElementById(divSrcId+“_asset”);

var componentDest = document.getElementById(divDestId+“_asset”);

if((componentSrc != null) && (componentDest != null))

{

jsPlumbConnInstance.connect({

source:divSrcId+

“_asset”,

target: divDestId+

“_asset”,

anchors:[

“RightMiddle”,“LeftMiddle”],

paintStyle:{lineWidth:1,strokeStyle:color},

endpoint:

“Blank”,

connector: [

“Bezier”, { curviness:50 } ],

overlays:overlays

});

}

}

}

}

});

}

//creates div in which asset details are shown for selected asset

function generateDivComponent(assetId,containerEle,assetDetails)

  {

var component = document.getElementById(assetId);

if(component == null)

{

var index = 0;

var dmDiv = new Array();

dmDiv[index++] =

“<table id='”+containerEle+“_table’ border=’0′ cellspacing=’0′  >”;

dmDiv[index++] =

“<tr>”;

dmDiv[index++] =

“<td id='”+containerEle+“_parent’>”;

dmDiv[index++] =

“</td>”;

dmDiv[index++] =

“<td id='”+containerEle+“_root’>”;

dmDiv[index++] = assetDetails;

dmDiv[index++] =

“</td>”;

dmDiv[index++] =

“<td id='”+containerEle+“_child’>”;

dmDiv[index++] =

“</td>”;

dmDiv[index++] =

“</tr>”;

dmDiv[index++] =

“</table>”;

return dmDiv.join(“”);

}

}

// expands multiple child assets

function expandMultipleItems(assetId,arrowStyleColor,containerEle)

    {

  arrowColors[assetId] = arrowStyleColor;

  parent.startProgressbar(

“Please wait…”);

  jQuery.ajax({

    url: ‘

<%=request.getContextPath()%>/asset/DependencyGraph/dependencyData.jsp‘,

    type:

‘POST’,

    data :{

    assetId :assetId,

                items:

“rightItems”,

                blnShowHistory:blnShowHistory,

                containerEle:containerEle,

                token:

new Date()

                },

                success:

function (result)

                {

                expandFirstLevel(result,assetId,blnShowHistory,containerEle,

true);

                },

                failure:

function (result) {

  }

});

  }

//expands first level child assets

function expandFirstLevel(result,id,blnShowHistory,containerEle,flag)

    {

var imgEle = document.getElementById(id+“_img_plus_right”);

imgEle.src =

“”+contextPath+“/images/minus.png”;

imgEle.title =

“collapse”;

imgEle.alt =

“collapse”;

imgEle.onclick =

function(e){

var evt = window.event || e ;//cross browserevent object

hideRightComp(id,arrowColors[id],containerEle);

};

var jsonData = jQuery.evalJSON(result);

if ((jsonData != null) && (jsonData != “”) && (jsonData != undefined)){

var len = jsonData.dataRoot.length;

if(len == 0){

$(imgEle).hide();

    }

else{

if(containerEle.indexOf(“_parent”) == -1 && document.getElementById(containerEle+“_child”) == null){

var childContainer = “<td id='”+containerEle+“_child’>”;

   childContainer +=

“</td>”;

   $(

“#”+containerEle).after(childContainer);

}

var assetDetails = jsonData.assetDetails;

            $(

“#”+containerEle).append(assetDetails);

for(var i=0; i<len; i++){

var assetId = jsonData.dataRoot[i].assetId;

     arrowColors[assetId] = jsonData.dataRoot[i].leftArrowColor;

var isAssetInProgress = jsonData.dataRoot[i].isAssetInProgress;

if(assetId != id){

var rightTargetArr = rightTargetIds[id];

if(rightTargetArr == undefined)

     rightTargetIds[id] =

new Array(assetId);

else

     rightTargetArr[rightTargetArr.length] = assetId;

     }

if(isAssetInProgress == “true”)

            checkForAssetStatus(id,assetId,blnShowHistory,containerEle,containerEle+

“_child”,flag);

elseif(flag)

            expandSecondLevel(assetId,id,blnShowHistory,containerEle+

“_child”);

            }

if(jsPlumbConnInstanceArr[id] != undefined){

            jsPlumbConnInstanceArr[id].reset();

delete jsPlumbConnInstanceArr[id];

            }

            repaintConnections();

            createConnection(id);

      }

            }

parent.stopProgressbar();

      }

function checkForAssetStatus(id,assetId,blnShowHistory,parentContainerEle,containerEleId,flag){

      jQuery.ajax({

url: ‘

<%=request.getContextPath()%>/asset/DependencyGraph/dependencyData.jsp‘,

    type:

“POST”,

    data :{

    assetId :assetId,

items:

“asset”,

blnShowHistory:blnShowHistory,

containerEle:parentContainerEle,

             token:

new Date()

             },

   success:

function(result)

   {

if($.trim(result) == “true”){

   window.setTimeout(

“checkForAssetStatus(‘”+id+“‘,'”+assetId+“‘,'”+blnShowHistory+“‘,'”+parentContainerEle+“‘,'”+containerEleId+“‘,”+flag+“)”,1000);

   }

else{

var jsonData = jQuery.evalJSON(result);

if(document.getElementById(jsonData.assetId+“_asset”) != null)

   document.getElementById(jsonData.assetId+

“_asset”).innerHTML = jsonData.assetDetails;

if(flag){

   expandSecondLevel(assetId,id,blnShowHistory,containerEleId);

   }

else{

   repaintConnections();

   }

   }

   },

failure:

function(result){

  }

});

  }

//expands second level child assets

function expandSecondLevel(assetId,id,blnShowHistory,containerEle)

      {

  jQuery.ajax({

    url: ‘

<%=request.getContextPath()%>/asset/DependencyGraph/dependencyData.jsp‘,

    type:

‘POST’,

    async:

false,

    data :{

    assetId :assetId,

                items:

“rightItems”,

                blnShowHistory:blnShowHistory,

                containerEle:containerEle,

                token:

new Date()

               },

                success:

function (result)

                {

                expandFirstLevel(result,assetId,blnShowHistory,containerEle,

false);

                },

                failure:

function (result) {

  }

});

      }

//retrieves all child assets on expand right bottom expand image

function getRightItems(assetId,arrowStyleColor,containerEle)

   {

   arrowColors[assetId] = arrowStyleColor;

    parent.startProgressbar(

“Please wait…”);

    jQuery.ajax({

    url: ‘

<%=request.getContextPath()%>/asset/DependencyGraph/dependencyData.jsp‘,

    type:

‘POST’,

    data :{

    assetId :assetId,

                items:

“rightItems”,

                blnShowHistory:blnShowHistory,

                containerEle:containerEle,

                token:

new Date()

                },

                success:

function (result){

                createRightItems(result,assetId,blnShowHistory,containerEle);

                },

                failure:

function (result) {

  }

});

   }

//retrieves all parent assets on expand left bottom expand image

function getLeftItems(assetId,containerEle)

   {

   parent.startProgressbar(

“Please wait…”);

   jQuery.ajax({

            url: ‘

<%=request.getContextPath()%>/asset/DependencyGraph/dependencyData.jsp‘,

            type:

‘POST’,

            data :{

            assetId:assetId,

            items:

“leftItems”,

            blnShowHistory:blnShowHistory,

            containerEle:containerEle,

            token:

new Date()

                },

                success:

function (result){

    createLeftItems(result,assetId,blnShowHistory,containerEle);

                },

                failure:

function (result) {

  }

});

   }

//creates div in which child assets are displayed and connects to its parent

function createRightItems(result,id,blnShowHistory,containerEle)

   {

var imgEle = document.getElementById(id+“_img_plus_right”);

imgEle.src =

“”+contextPath+“/images/minus.png”;

imgEle.title =

“collapse”;

imgEle.alt =

“collapse”;

imgEle.onclick =

function(e){

var evt = window.event || e ;//cross browserevent object

hideRightComp(id,arrowColors[id],containerEle);

};

var index = 0;

var dmDiv = new Array();

var jsonData = jQuery.evalJSON(result);

if ((jsonData != null) && (jsonData != “”) && (jsonData != undefined)){

var len = jsonData.dataRoot.length;

if(len == 0){

$(imgEle).hide();

    }

else{

if(containerEle.indexOf(“_parent”) == -1 && document.getElementById(containerEle+“_child”) == null){

var childContainer = “<td id='”+containerEle+“_child’>”;

   childContainer +=

“</td>”;

   $(

“#”+containerEle).after(childContainer);

}

if(document.getElementById(containerEle).innerHTML != “”){

if(containerEle == “containerEle”)

$(

‘#’+containerEle+‘_root’).children(“:last”).css(‘margin-bottom’,’40px’);

else

 

            $(

‘#’+containerEle).children(“:last”).css(‘margin-bottom’,’40px’);

            }

var assetDetails = jsonData.assetDetails;

if(containerEle == “containerEle”){

       $(

“#”+containerEle+“_root”).append(assetDetails);

            }

else{

       $(

“#”+containerEle).append(assetDetails);

           }

for(var i=0; i<len; i++){

var assetId = jsonData.dataRoot[i].assetId;

var isAssetInProgress = jsonData.dataRoot[i].isAssetInProgress;

if(assetId != id){

var rightTargetArr = rightTargetIds[id];

if(rightTargetArr == undefined)

     rightTargetIds[id] =

new Array(assetId);

else

     rightTargetArr[rightTargetArr.length] = assetId;

     }

if(isAssetInProgress == “true”)

            checkAssetInProgress(id,assetId,blnShowHistory,containerEle);

            }

if(jsPlumbConnInstanceArr[id] != undefined){

            jsPlumbConnInstanceArr[id].reset();

delete jsPlumbConnInstanceArr[id];

            }

            repaintConnections();

            createConnection(id);

var position = $(“#”+id+“_icon”).offset();

window.scrollTo(position.left-10,position.top-200);

doLayoutVersionHistory();

}

            }

parent.stopProgressbar();

      }

//creates div in which parent assets are displayed and connects to is child(s)

function createLeftItems(result,id,blnShowHistory,containerEle)

  {

var imgEle = document.getElementById(id+“_img_plus_left”);

     $(imgEle).hide();

var jsonData = jQuery.evalJSON(result);

if ((jsonData != null) && (jsonData != “”) && (jsonData != undefined)){

var len = jsonData.dataRoot.length;

if(len > 0){

if(containerEle.indexOf(“_child”) == -1 && document.getElementById(containerEle+“_parent”) == null){

var childContainer = “<td id='”+containerEle+“_parent’>”;

   childContainer +=

“</td>”;

   $(

“#”+containerEle).before(childContainer);

}

var assetDetails = jsonData.assetDetails;

if(containerEle == “containerEle”){

       $(

“#”+containerEle+“_root”).append(assetDetails);

       }

else{

       $(

“#”+containerEle).append(assetDetails);

           }

for(var i=0; i<len; i++){

var assetId = jsonData.dataRoot[i].assetId;

     arrowColors[assetId] = jsonData.dataRoot[i].leftArrowColor;

var isAssetInProgress = jsonData.dataRoot[i].isAssetInProgress;

if(assetId != id){

var rightTargetArr = rightTargetIds[assetId];

if(rightTargetArr == undefined)

     rightTargetIds[assetId] =

new Array(id);

else

     rightTargetArr[rightTargetArr.length] = id;

     }

if(isAssetInProgress == “true”)

            checkAssetInProgress(id,assetId,blnShowHistory,containerEle);

if(jsPlumbConnInstanceArr[assetId] != undefined){

           jsPlumbConnInstanceArr[assetId].reset();

delete jsPlumbConnInstanceArr[assetId];

           }

           createConnection(assetId);

            }

            repaintConnections();

var position = $(“#”+id+“_icon”).offset();

    window.scrollTo(position.left-450,position.top-200);

    doLayoutVersionHistory();

    }

        }

parent.stopProgressbar();

     }

//collapse child assets

function hideRightComp(id,arrowColor,containerEle)

{

var imgEle = document.getElementById(id+“_img_plus_right”);

imgEle.src =

“”+contextPath+“/images/plus.png”;

imgEle.title =

“expand”;

imgEle.alt =

“expand”;

imgEle.onclick =

function(e){

var evt = window.event || e ; //cross browserevent object

getRightItems(id,arrowColor,containerEle);

};

detachConnection(id,rightTargetIds);

rightTargetIds[id] =

new Array();

if(jsPlumbConnInstanceArr[id] != undefined){

        jsPlumbConnInstanceArr[id].reset();

delete jsPlumbConnInstanceArr[id];

        }

        repaintConnections();

        createConnection(id);

var position = $(“#”+id+“_icon”).offset();

window.scrollTo(position.left,position.top-200);

doLayoutVersionHistory();

}

//removes all jsPlumb connections on selected asset

function detachConnection(id,destArray)

{

var childItems = destArray[id];

//alert(“childItems >>>>>>>”+childItems);

var flag = false;

if(childItems != undefined){

for(var i=0; i<childItems.length; i++){

   flag =

false;

   inner:

for(var parent in destArray){

if(parent != id){

var childs = destArray[parent];

if(childs != undefined){

for(var j=0; j<childs.length; j++){

if(childItems[i] != “” && childs[j] != “”){

if(childItems[i] == childs[j]){

//alert(“——- FOUND ——-“+childItems[i]);

   flag =

true;

break inner;

   }

   }

   }

   }

   }

   }

if(flag){

   childItems[i] =

“”;

   }

else{

if(document.getElementById(childItems[i]+“_asset”) != null)

   $(

“#”+childItems[i]+“_asset”).remove();

   removeHistory(childItems[i]);

   removeToolTip(childItems[i]);

   detachConnection(childItems[i],destArray);

   destArray[childItems[i]] =

new Array();

   }

   }

}

   destArray[id] =

new Array();

}

//opens gridview metadata for Metadata

function viewTransformationMtdt(id){

parent.parent.openTransformationMtdt(id);

}

//opens view mapping for Map

function viewTransformationMap(id){

parent.parent.openTransformationMap(id);

}

</script>

</head>

<bodyid=“DM_body”onLoad=“pageInit()”onUnload=“jsPlumb.unload();”>

<tableid=‘containerEle_Parent’border=“0”align=“center”width=“100%”height=“100%”style=“padding-top:20px;padding-bottom:20px;padding-left:50px;padding-right:50px;”>

<trheight=“10%”>

<td>&nbsp;</td>

</tr>

<trheight=“60%”>

<tdalign=“center”>

<divid=“containerEle”></div>

</td>

</tr>

<trheight=“30%”>

<td>&nbsp;</td>

</tr>

</table>

</

body>

</

html>

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: