Skip to content

Commit

Permalink
Implement Concept Map Model API in web app
Browse files Browse the repository at this point in the history
  • Loading branch information
failys committed Feb 8, 2017
1 parent c63e41d commit ef108fe
Show file tree
Hide file tree
Showing 4 changed files with 120 additions and 7 deletions.
12 changes: 7 additions & 5 deletions cairis/misc/ConceptMapModel.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def __init__(self,associations,envName,conceptName = '',cfSet = False,db_proxy=N
self.fontSize = b.fontSize

if (cfSet == True):
self.theGraph.set_node_defaults(shape='circle',colorscheme='set14',color='1',fontname=self.fontName,fontsize=self.fontSize,style='filled')
self.theGraph.set_node_defaults(shape='circle',colorscheme='set14',color='1',fontname=self.fontName,fontsize=self.fontSize)
else:
self.theGraph.set_node_defaults(shape='rectangle',colorscheme='spectral3',color='1',fontname=self.fontName,fontsize=self.fontSize)
self.theGraph.set_edge_defaults(arrowhead='vee')
Expand Down Expand Up @@ -75,10 +75,12 @@ def graph(self):
self.conceptNameSet = set([])
self.assocSet = set([])

reqNodes = self.dbProxy.getDimensionNames('requirement',self.theEnvironmentName)
for nodeName in reqNodes:
self.buildNode(nodeName,self.theEnvironmentName)
self.conceptNameSet.add(nodeName)

if self.theConceptName == '':
reqNodes = self.dbProxy.getDimensionNames('requirement',self.theEnvironmentName)
for nodeName in reqNodes:
self.buildNode(nodeName,self.theEnvironmentName)
self.conceptNameSet.add(nodeName)

for association in self.theAssociations:
fromName = association.fromName()
Expand Down
72 changes: 70 additions & 2 deletions cairis/web/dist/js/cairis/Cairis.js
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,40 @@ $('#amconcernsbox').change(function() {
}
});

$('#cmenvironmentsbox').change(function() {
var envName = $('#cmenvironmentsbox').val()

$.ajax({
type: "GET",
dataType: "json",
accept: "application/json",
data: {
session_id: String($.session.get('sessionID')),
},
crossDomain: true,
url: "/api/dimensions/table/requirement/environment/" + encodeURIComponent(envName),
success: function (data) {
fillObjectBox('#cmrequirementsbox','All',data);
$('#cmrequirementsbox').val('All');
getRequirementView(envName,'All');
},
error: function (xhr, textStatus, errorThrown) {
debugLogger(String(this.url));
debugLogger("error: " + xhr.responseText + ", textstatus: " + textStatus + ", thrown: " + errorThrown);
}
});


});

$('#cmrequirementsbox').change(function() {
if (window.theVisualModel == 'requirement') {
var envName = $('#cmenvironmentsbox').val()
var reqName = $('#cmrequirementsbox').val()
getRequirementView(envName,reqName);
}
});

function getAssetview(environment){
window.assetEnvironment = environment;
$('#amenvironmentsbox').val(environment);
Expand Down Expand Up @@ -513,7 +547,7 @@ function getResponsibilityview(environment,role){
function getRequirementLabels(data) {
var lbls = [];
d3.select(data).selectAll('a').each(function(d) {
if ((d3.select(this).attr('xlink:href').indexOf('/api/requirements/shortcode') >= 0) && (d3.select(this).attr('xlink:title') != null)) {
if (((d3.select(this).attr('xlink:href').indexOf('/api/requirements/shortcode') >= 0) && (d3.select(this).attr('xlink:title') != null)) || ((d3.select(this).attr('xlink:href').indexOf('/api/requirements/name') >= 0) && (d3.select(this).attr('xlink:title') != null))) {
lbls.push(d3.select(this).attr('xlink:title'));
d3.select(this).attr('class','requirement');
}
Expand Down Expand Up @@ -630,7 +664,7 @@ function getRequirementScores(lbls) {
function replaceRequirementNodes(data,reqDict) {

d3.select(data).selectAll('a').each(function(d) {
if ((d3.select(this).attr('xlink:href').indexOf('/api/requirements/shortcode') >= 0) && (d3.select(this).attr('xlink:title') != null)) {
if (((d3.select(this).attr('xlink:href').indexOf('/api/requirements/shortcode') >= 0) && (d3.select(this).attr('xlink:title') != null)) || ((d3.select(this).attr('xlink:href').indexOf('/api/requirements/name') >= 0) && (d3.select(this).attr('xlink:title') != null))) {
var reqLabel = d3.select(this).attr('xlink:title');
var cxi = d3.select(this).select('ellipse').attr('cx');
var cyi = d3.select(this).select('ellipse').attr('cy');
Expand Down Expand Up @@ -687,6 +721,32 @@ function getRiskview(environment,dimName,objtName,modelLayout){
});
}

function getRequirementView(environment,reqName){
window.assetEnvironment = environment;
$('#cmenvironmentsbox').val(environment);
reqName = (reqName == undefined || reqName == 'All') ? 'all' : reqName;
$.ajax({
type:"GET",
accept:"application/json",
data: {
session_id: String($.session.get('sessionID')),
},
crossDomain: true,
url: serverIP + "/api/requirements/model/environment/" + encodeURIComponent(environment) + "/requirement/" + encodeURIComponent(reqName),
success: function(data){
var lbls = getRequirementLabels(data);
var reqDict = getRequirementScores(lbls);
replaceRequirementNodes(data,reqDict);
fillSvgViewer(data);
},
error: function(xhr, textStatus, errorThrown) {
debugLogger(String(this.url));
debugLogger("error: " + xhr.responseText + ", textstatus: " + textStatus + ", thrown: " + errorThrown);
}
});
}


function getTaskview(environment,task,misusecase){
if (task == undefined) {
$.ajax({
Expand Down Expand Up @@ -1313,13 +1373,15 @@ function createComboboxes(){
var tmEnvBox = $("#tmenvironmentsbox");
var remEnvBox = $("#remenvironmentsbox");
var rmEnvBox = $("#rmenvironmentsbox");
var cmEnvBox = $("#cmenvironmentsbox");
envBox.empty();
amEnvBox.empty();
gmEnvBox.empty();
omEnvBox.empty();
tmEnvBox.empty();
remEnvBox.empty();
rmEnvBox.empty();
cmEnvBox.empty();
$.each(data, function () {
envBox.append($("<option />").val(this).text(this));
amEnvBox.append($("<option />").val(this).text(this));
Expand All @@ -1328,6 +1390,7 @@ function createComboboxes(){
tmEnvBox.append($("<option />").val(this).text(this));
remEnvBox.append($("<option />").val(this).text(this));
rmEnvBox.append($("<option />").val(this).text(this));
cmEnvBox.append($("<option />").val(this).text(this));
});
// envBox.css("visibility", "visible");
// window.boxesAreFilled = true;
Expand Down Expand Up @@ -1412,6 +1475,7 @@ function activeElement(elementid){
$("#filterapmodelcontent").hide();
$("#filtertaskmodelcontent").hide();
$("#filterobstaclemodelcontent").hide();
$("#filterconceptmapmodelcontent").hide();
$("#rightnavGear").hide();

if (elementid == 'svgViewer') {
Expand All @@ -1423,6 +1487,9 @@ function activeElement(elementid){
if (window.theVisualModel == 'risk') {
$("#filterriskmodelcontent").show();
}
if (window.theVisualModel == 'requirement') {
$("#filterconceptmapmodelcontent").show();
}
else if (window.theVisualModel == 'goal') {
$("#filtergoalmodelcontent").show();
}
Expand Down Expand Up @@ -1454,6 +1521,7 @@ function activeElement(elementid){
$("#filterapmodelcontent").hide();
$("#filterresponsibilitymodelcontent").hide();
$("#filterobstaclemodelcontent").hide();
$("#filterconceptmapmodelcontent").hide();
$("#rightnavGear").hide();
}

Expand Down
27 changes: 27 additions & 0 deletions cairis/web/dist/js/cairis/buttonclicks.js
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,33 @@ $('#riskModelClick').click(function(){
});
});

$('#requirementModelClick').click(function(){
window.theVisualModel = 'requirement';
$.ajax({
type: "GET",
dataType: "json",
accept: "application/json",
data: {
session_id: String($.session.get('sessionID'))
},
crossDomain: true,
url: serverIP + "/api/environments/all/names",
success: function (data) {
$("#chooseEnvironmentSelect").empty();
$.each(data, function(i, item) {
$("#chooseEnvironmentSelect").append('<option value="' + item + '">' + item + '</option>');
});
$('#chooseEnvironment').attr('data-chooseDimension',"environment")
$('#chooseEnvironment').attr('data-applyEnvironmentSelection',"getRequirementView")
$('#chooseEnvironment').modal('show');
},
error: function (xhr, textStatus, errorThrown) {
debugLogger(String(this.url));
debugLogger("error: " + xhr.responseText + ", textstatus: " + textStatus + ", thrown: " + errorThrown);
}
});
});


$('#taskModelClick').click(function(){
window.theVisualModel = 'task';
Expand Down
16 changes: 16 additions & 0 deletions cairis/web/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button"><span class="glyphicon glyphicon-picture"> Models<span class="caret"></span></a>
<ul class="dropdown-menu">
<li><a id="riskModelClick" href="#">Risk</a></li>
<li><a id="requirementModelClick" href="#">Requirement</a></li>
<li><a id="assetModelClick" href="#">Asset</a></li>
<li><a id="goalModelClick" href="#">Goal</a></li>
<li><a id="obstacleModelClick" href="#">Obstacle</a></li>
Expand Down Expand Up @@ -345,6 +346,21 @@
</select>
</div>
</div>
<div id="filterconceptmapmodelcontent" class="extraContent row form-group">
<div class="col-md-2">
<label class="topCombobox control-label" for="cmenvironmentsbox">Environments</label>
</div>
<div class="col-md-2">
<select class="topCombobox form-control" id="cmenvironmentsbox" ></select>
</div>
<div class="col-md-1">
<label class="topCombobox control-label" for="cmrequirementsbox">Requirements</label>
</div>
<div class="col-md-2">
<select class="topCombobox form-control" id="cmrequirementsbox" ></select>
</div>
</div>

</section>
<!-- Main content -->
<section id="maincontent" class="content" style="margin-left: 5px; margin-right: 5px">
Expand Down

0 comments on commit ef108fe

Please sign in to comment.