Skip to content

Commit

Permalink
Successfully tested against the Persona Helper extension
Browse files Browse the repository at this point in the history
  • Loading branch information
Shamal Faily committed Jan 2, 2017
1 parent a5ce50d commit 87f02e5
Show file tree
Hide file tree
Showing 9 changed files with 183 additions and 34 deletions.
9 changes: 3 additions & 6 deletions cairis/data/PersonaCharacteristicDAO.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,19 +150,16 @@ def convert_pcrs(self,real_pc=None,fake_pc=None):
pcr_list = []
if len(fake_pc.theGrounds) > 0:
for pcr in fake_pc.theGrounds:
check_required_keys(pcr,PersonaCharacteristicReference.required)
pcr_list.append((pcr['theReferenceName'],pcr['theReferenceDescription'],pcr['theDimensionName']))
pcr_list.append((pcr.theReferenceName,pcr.theReferenceDescription,pcr.theDimensionName))
fake_pc.theGrounds = pcr_list
if len(fake_pc.theWarrant) > 0:
pcr_list = []
for pcr in fake_pc.theWarrant:
check_required_keys(pcr,PersonaCharacteristicReference.required)
pcr_list.append((pcr['theReferenceName'],pcr['theReferenceDescription'],pcr['theDimensionName']))
pcr_list.append((pcr.theReferenceName,pcr.theReferenceDescription,pcr.theDimensionName))
fake_pc.theWarrant = pcr_list
if len(fake_pc.theRebuttal) > 0:
pcr_list = []
for pcr in fake_pc.theRebuttal:
check_required_keys(pcr,PersonaCharacteristicReference.required)
pcr_list.append((pcr['theReferenceName'],pcr['theReferenceDescription'],pcr['theDimensionName']))
pcr_list.append((pcr.theReferenceName,pcr.theReferenceDescription,pcr.theDimensionName))
fake_pc.theRebuttal = pcr_list
return fake_pc
2 changes: 1 addition & 1 deletion cairis/sql/procs.sql
Original file line number Diff line number Diff line change
Expand Up @@ -11368,7 +11368,7 @@ end

create procedure documentReferenceNames(in docName text)
begin
select dr.name from document_reference dr, external_document ed where ed.name = docName and dr.document_id = ed.id;
select dr.name from document_reference dr, external_document ed where ed.name = docName and dr.document_id = ed.id order by 1;
end
//

Expand Down
8 changes: 4 additions & 4 deletions cairis/test/test_PersonaCharacteristicAPI.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@ def setUp(self):
modQual = 'Maybe',
vName = 'Activities',
cDesc = 'This is a test characteristic',
pcGrounds = [PersonaCharacteristicReference('Line manager site authorisation','grounds','Can only access sites they have been authorised to; permission for authorisation changes need to be sought from the line manager.','document')],
pcWarrant = [PersonaCharacteristicReference('Work reports are filed','warrant','Work reports are filed and sent to ACME monthly.','document')],
pcBacking = ['Business compliance GT concept'],
pcRebuttal = [PersonaCharacteristicReference('Everything is logged','rebuttal','Everything that happens is logged.','document')])
pcGrounds = [{"theReferenceName": "Line manager site authorisation", "theDimensionName": "document", "theCharacteristicType": "grounds", "__python_obj__": "cairis.tools.PseudoClasses.PersonaCharacteristicReference", "theReferenceDescription": "Can only access sites they have been authorised to; permission for authorisation changes need to be sought from the line manager."}],
pcWarrant = [{"theReferenceDescription": "Work reports are filed and sent to ACME monthly.", "theDimensionName": "document", "theCharacteristicType": "warrant", "__python_obj__": "cairis.tools.PseudoClasses.PersonaCharacteristicReference", "theReferenceName": "Work reports are filed"}],
pcRebuttal = [{"theReferenceDescription": "Everything that happens is logged.", "theDimensionName": "document", "theCharacteristicType": "rebuttal", "__python_obj__": "cairis.tools.PseudoClasses.PersonaCharacteristicReference", "theReferenceName": "Everything is logged"}],
pcBacking = ['Business compliance GT concept'])
self.new_pc_dict = {
'session_id' : 'test',
'object': self.new_pc
Expand Down
92 changes: 89 additions & 3 deletions cairis/web/dist/js/cairis/ModelViewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,30 @@ $(window).load(function() {

window.document.title = Cookies.get('wTitle');
var modelUrl;
if (Cookies.get('model') == 'component_asset') {
modelUrl = serverIP + "/api/architectural_patterns/component/asset/model/" + encodeURIComponent(Cookies.get('parameter'));
var modelType = Cookies.get('model')
if (modelType == 'component_asset') {
$('#filterapmodelcontent').hide();
viewComponentModel(serverIP + "/api/architectural_patterns/component/asset/model/" + encodeURIComponent(Cookies.get('parameter')));

}
else if (modelType == 'component_goal') {
$('#filterapmodelcontent').hide();
viewComponentModel(serverIP + "/api/architectural_patterns/component/goal/model/" + encodeURIComponent(Cookies.get('parameter')));
}
else {
modelUrl = serverIP + "/api/architectural_patterns/component/goal/model/" + encodeURIComponent(Cookies.get('parameter'));
$('#filterapmodelcontent').show();
var pName = Cookies.get('pName');
var bvName = Cookies.get('bvName');
$('#appersonasbox').empty();
$('#appersonasbox').append($('<option>', {value: pName, text: pName},'</option>'));
$('#appersonasbox').val(pName);
$('#apbtbox').val(bvName);
appendPersonaCharacteristics(pName,bvName,'All');
getPersonaView(pName,bvName,Cookies.get('pcName'));
}
});

function viewComponentModel(modelUrl) {
$.ajax({
type: "GET",
accept: "application/json",
Expand All @@ -78,8 +95,75 @@ $(window).load(function() {
debugLogger("error: " + xhr.responseText + ", textstatus: " + textStatus + ", thrown: " + errorThrown);
}
});
}

$('#appersonasbox').change(function() {
var selection = $(this).find('option:selected').text();
appendPersonaCharacteristics(selection,'All','All');
getPersonaView(selection,'All','All');
});

$('#apbtbox').change(function() {
var selection = $(this).find('option:selected').text();
var pName = $('#appersonasbox').val();
appendPersonaCharacteristics(pName,selection,'All');
getPersonaView(pName,selection,'All');
});

$('#apcharacteristicbox').change(function() {
var selection = $(this).find('option:selected').text();
var pName = $('#appersonasbox').val();
var bvName = $('#apbtbox').val();
appendPersonaCharacteristics(pName,bvName,'All');
getPersonaView(pName,bvName,selection);
});

function appendPersonaCharacteristics(pName,bvName,pcName) {

$.ajax({
type: "GET",
dataType: "json",
accept: "application/json",
data: {
session_id: String($.session.get('sessionID'))
},
crossDomain: true,
url: serverIP + "/api/personas/characteristics/name/" + encodeURIComponent(pName) + "/variable/" + encodeURIComponent(bvName) + "/characteristic/" + encodeURIComponent(pcName),
success: function (data) {
$('#apcharacteristicbox').empty();
$('#apcharacteristicbox').append($('<option>', {value: 'All', text: 'All'},'</option>'));
$.each(data, function (index, item) {
$('#apcharacteristicbox').append($('<option>', {value: item, text: item},'</option>'));
});
$('#apcharacteristicbox').val(pcName);
},
error: function (xhr, textStatus, errorThrown) {
debugLogger(String(this.url));
debugLogger("error: " + xhr.responseText + ", textstatus: " + textStatus + ", thrown: " + errorThrown);
}
});
}

function getPersonaView(pName,bvName,pcName){
$('#appersonasbox').val(pName);
$.ajax({
type:"GET",
accept:"application/json",
data: {
session_id: String($.session.get('sessionID'))
},
crossDomain: true,
url: serverIP + "/api/personas/model/name/" + encodeURIComponent(pName) + "/variable/" + encodeURIComponent(bvName) + "/characteristic/" + encodeURIComponent(pcName),
success: function(data){
fillSvgViewer(data);
},
error: function(xhr, textStatus, errorThrown) {
debugLogger(String(this.url));
debugLogger("error: " + xhr.responseText + ", textstatus: " + textStatus + ", thrown: " + errorThrown);
}
});
}

function fillSvgViewer(data){
var xmlString = (new XMLSerializer()).serializeToString(data);
var svgDiv = $("#svgViewer");
Expand All @@ -96,3 +180,5 @@ function fillSvgViewer(data){
minZoom: 0.2
});
}


5 changes: 3 additions & 2 deletions cairis/web/dist/js/cairis/personacharacteristics.js
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,7 @@ function loadCharacteristicReference() {
crossDomain: true,
url: serverIP + "/api/dimensions/table/document_reference",
success: function (data) {
data.sort();
$("#theReferenceName").empty();
$.each(data, function(key, item) {
$("#theReferenceName").append("<option>" + item + "</option>");
Expand All @@ -336,7 +337,7 @@ function loadCharacteristicReference() {

function addCharacteristicReference() {
var cr = JSON.parse($("#editCharacteristicReference").data("crtype"));
var item = {};
var item = jQuery.extend(true, {},personaCharacteristicReferenceDefault );
item.theReferenceName = $("#theReferenceName").val();
item.theReferenceDescription = $("#theDescription").val();
appendGWR(cr.tableId,cr.classId,item);
Expand All @@ -360,7 +361,7 @@ function addCharacteristicReference() {

function updateReferenceList() {
var cr = JSON.parse($("#editCharacteristicReference").data("currentcr"));
var item = {};
var item = jQuery.extend(true, {},personaCharacteristicReferenceDefault );
item.theReferenceName = $("#theReferenceName").val();
item.theReferenceDescription = $("#theDescription").val();
$(cr.tableId).find("tbody").find('tr:eq(' + cr.index + ')').find('td:eq(1)').text(item.theReferenceName);
Expand Down
24 changes: 24 additions & 0 deletions cairis/web/dist/js/cairis/personas.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,20 @@ function viewPersona(personaName) {
$("#thePersonaEnvironments").find(".personaEnvironment:first").trigger('click');
$("#theImage").attr("src",getImagedir(data.theImage));
rescaleImage($("#theImage"),300);

$('#thePersonaCharacteristicList').contextMenu({
selector: 'li.personaContextMenu',
items: {
"visualise": {
name: "Visualise",
callback: function(key, opt) {
var pName = data.theName;
var bvName = $(this).text();
getTabbedPersonaView(pName,bvName,'All');
}
}
}
});
});
},
error: function (xhr, textStatus, errorThrown) {
Expand All @@ -134,6 +148,7 @@ function viewPersona(personaName) {
});
};


var mainContent = $("#objectViewer");
mainContent.on("click",".personaEnvironment", function () {
clearPersonaEnvInfo();
Expand Down Expand Up @@ -504,3 +519,12 @@ function postPersona(persona, callback){
}
});
}

function getTabbedPersonaView(pName,bvName,pcName){
Cookies.set('model','persona');
Cookies.set('pName',pName);
Cookies.set('bvName',bvName);
Cookies.set('pcName',pcName);
Cookies.set('wTitle',pName + " persona characteristics");
var viewerWindow = window.open('viewer.html');
}
7 changes: 7 additions & 0 deletions cairis/web/dist/js/objects/jsonDefaultObjects.js
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,13 @@ var documentReferenceDefault = {
"theContributor" : "",
"theExcerpt" : ""
};
var personaCharacteristicReferenceDefault = {
"__python_obj__": "cairis.tools.PseudoClasses.PersonaCharacteristicReference",
"theReferenceName" : "",
"theDimensionName" : "document",
"theCharacteristicType" : "grounds",
"theReferenceDescription" : ""
};
var personaCharacteristicDefault = {
"__python_obj__": "PersonaCharacteristic.PersonaCharacteristic",
"theId": -1,
Expand Down
18 changes: 9 additions & 9 deletions cairis/web/fastTemplates/editPersonasOptions.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@
<p><input type="file" id="fileupload" style="display: none"></p>
</div><br/>
<div class="tabs" style="float: right; width: 75%;">
<ul>
<ul id="thePersonaCharacteristicList">
<li><a href="#summary">Summary</a></li>
<li><a href="#activities">Activities</a></li>
<li><a href="#attitudes">Attitudes</a></li>
<li><a href="#aptitudes">Aptitudes</a></li>
<li><a href="#motivations">Motivations</a></li>
<li><a href="#skills">Skills</a></li>
<li><a href="#contextual">Contextual Trust</a></li>
<li><a href="#intrinsic">Intrinsic Trust</a></li>
<li class="personaContextMenu"><a href="#activities">Activities</a></li>
<li class="personaContextMenu"><a href="#attitudes">Attitudes</a></li>
<li class="personaContextMenu"><a href="#aptitudes">Aptitudes</a></li>
<li class="personaContextMenu"><a href="#motivations">Motivations</a></li>
<li class="personaContextMenu"><a href="#skills">Skills</a></li>
<li class="personaContextMenu"><a href="#contextual">Contextual Trust</a></li>
<li class="personaContextMenu"><a href="#intrinsic">Intrinsic Trust</a></li>
</ul>
<div id="summary">
<div class="form-group">
Expand All @@ -39,7 +39,7 @@
</div>
</div>
<div class="form-group" id="activities">
<textarea rows="15" id="theActivities" class="personaUpdate form-control" data-error="Activities are required" required></textarea>
<textarea rows="15" id="theActivities" class="personaUpdate form-control " data-error="Activities are required" required></textarea>
<div class="help-block with-errors"></div>
</div>
<div class="form-group" id="attitudes">
Expand Down
52 changes: 43 additions & 9 deletions cairis/web/viewer.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,49 @@
</head>

<body>
<div id="svgViewer"></div>
<div id="rightnavGear" class="no-print"
style="position: fixed; top: 100px; right: 0px; border-radius: 5px 0px 0px 5px; padding: 10px 15px; font-size: 16px; z-index: 100; cursor: pointer; color: rgb(60, 141, 188); box-shadow: rgba(0, 0, 0, 0.0980392) 0px 1px 3px; background: rgb(255, 255, 255);">
<i class="fa fa-gear"></i>
</div>
<div id="rightnavMenu" class="no-print"
style="padding: 10px; position: fixed; top: 100px; right: -400px; border: 0px solid rgb(221, 221, 221); width: 400px; z-index: 100; box-shadow: rgba(0, 0, 0, 0.0980392) 0px 1px 3px; background: rgb(255, 255, 255);">
<h4 id="optionsHeaderGear" class="text-light-blue" style="margin: 0 0 5px 0; border-bottom: 1px solid #ddd; padding-bottom: 15px;">Options</h4>
<div id="optionsContent"></div>
<div class="wrapper">
<div class="content-wrapper">
<div id="filterapmodelcontent" class="extraContent row form-group" style="display:none">
<div class="col-md-1">
<label class="topCombobox control-label" for="appersonasbox">Persona</label>
</div>
<div class="col-md-2">
<select class="topCombobox form-control" id="appersonasbox" ></select>
</div>
<div class="col-md-2">
<label class="topCombobox control-label" for="apbtbox">Behaviour Type</label>
</div>
<div class="col-md-2">
<select class="topCombobox form-control" id="apbtbox">
<option value="All">All</option>
<option value="Activities">Activities</option>
<option value="Attitudes">Attitudes</option>
<option value="Aptitudes">Aptitudes</option>
<option value="Motivations">Motivations</option>
<option value="Skills">Skills</option>
<option value="Environment Narrative">Environment Narrative</option>
<option value="Intrinsic">Intrinsic</option>
<option value="Contextual">Contextual</option>
</select>
</div>
<div class="col-md-1">
<label class="topCombobox control-label" for="apcharacteristicbox">Characteristic</label>
</div>
<div class="col-md-2">
<select class="topCombobox form-control" id="apcharacteristicbox"></select>
</div>
</div>
<div id="svgViewer"></div>
<div id="rightnavGear" class="no-print"
style="position: fixed; top: 100px; right: 0px; border-radius: 5px 0px 0px 5px; padding: 10px 15px; font-size: 16px; z-index: 100; cursor: pointer; color: rgb(60, 141, 188); box-shadow: rgba(0, 0, 0, 0.0980392) 0px 1px 3px; background: rgb(255, 255, 255);">
<i class="fa fa-gear"></i>
</div>
<div id="rightnavMenu" class="no-print"
style="padding: 10px; position: fixed; top: 100px; right: -400px; border: 0px solid rgb(221, 221, 221); width: 400px; z-index: 100; box-shadow: rgba(0, 0, 0, 0.0980392) 0px 1px 3px; background: rgb(255, 255, 255);">
<h4 id="optionsHeaderGear" class="text-light-blue" style="margin: 0 0 5px 0; border-bottom: 1px solid #ddd; padding-bottom: 15px;">Options</h4>
<div id="optionsContent"></div>
</div>
</div>
</div>
<script src="plugins/slimScroll/jquery.slimscroll.js" type="text/javascript"></script>
<script>
Expand Down

0 comments on commit 87f02e5

Please sign in to comment.