Skip to content

Commit

Permalink
redundancy feature is now mostly ready #722
Browse files Browse the repository at this point in the history
  • Loading branch information
umut-er committed Jul 3, 2024
1 parent e16731a commit f78289d
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 8 deletions.
15 changes: 12 additions & 3 deletions app/js/app-utilities.js
Original file line number Diff line number Diff line change
Expand Up @@ -3834,6 +3834,16 @@ appUtilities.removeDuplicateProcessesAfterQuery = function() {
var cy = appUtilities.getActiveCy();
var chiseInstance = appUtilities.getActiveChiseInstance();

var appendFullNodeInformation = function (node, neighborhoodDescriptorString) {
while(node.length != 0){
node.forEach( (node_) => {
neighborhoodDescriptorString += (node_.data("label") || node_.data("class"));
});
node = node.parent();
}
return neighborhoodDescriptorString;
}

var processes = cy.filter('node[class="process"],[class="omitted process"],[class="uncertain process"],[class="association"],[class="dissociation"]');
let processMap = new Map();
var deletion = cy.collection();
Expand All @@ -3852,18 +3862,17 @@ appUtilities.removeDuplicateProcessesAfterQuery = function() {
});

collectionArray.forEach( (item) => {
neighborhoodDescriptorString += (item.filter("node").data("label") || item.filter("node").data("class"));
neighborhoodDescriptorString = appendFullNodeInformation(item.filter("node"), neighborhoodDescriptorString);
neighborhoodDescriptorString += (item.filter("edge").data("label") || item.filter("edge").data("class"));
})
neighborhoodDescriptorString += process.data("class");
neighborhoodDescriptorString = appendFullNodeInformation(process, neighborhoodDescriptorString);
if(processMap.has(neighborhoodDescriptorString)){
deletion.merge(process);
}
else{
processMap.set(neighborhoodDescriptorString, true);
}
});

chiseInstance.deleteElesSimple(deletion);
}

Expand Down
5 changes: 5 additions & 0 deletions app/js/backbone-views.js
Original file line number Diff line number Diff line change
Expand Up @@ -3049,6 +3049,9 @@ var PathsByURIQueryView = Backbone.View.extend({
var removeDisconnected = document.getElementById(
"query-pathsbyURI-checkbox"
).checked;
var removeRedundant = document.getElementById(
"query-pathsbyURI-redundant-checkbox"
).checked;

if (uri.length === 0) {
document.getElementById("query-pathsbyURI-URI").focus();
Expand Down Expand Up @@ -3104,6 +3107,8 @@ var PathsByURIQueryView = Backbone.View.extend({
);
currentGeneralProperties.inferNestingOnLoad =
currentInferNestingOnLoad;
if(removeRedundant)
appUtilities.removeDuplicateProcessesAfterQuery();
if(removeDisconnected)
appUtilities.removeDisconnectedNodesAfterQuery([]);
$(document).trigger("sbgnvizLoadFileEnd", [filename, cy]);
Expand Down
12 changes: 7 additions & 5 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3585,7 +3585,7 @@ <h4 class="modal-title">Neighborhood Query</h4>
<td><input id="query-neighborhood-checkbox" type="checkbox" class="layout-text" checked></td>
</tr>
<tr>
<td class="caption-style-text" style="padding-left: 0;">Remove Redundant Nodes:</td>
<td class="caption-style-text" style="padding-left: 0;">Remove Redundant Processes:</td>
<td><input id="query-neighborhood-redundant-checkbox" type="checkbox" class="layout-text" checked></td>
</tr>
</tbody>
Expand Down Expand Up @@ -3651,7 +3651,7 @@ <h4 class="modal-title">Paths Between Query</h4>
<td><input id="query-pathsbetween-checkbox" type="checkbox" class="layout-text" checked></td>
</tr>
<tr>
<td class="caption-style-text" style="padding-left: 0;">Remove Redundant Nodes:</td>
<td class="caption-style-text" style="padding-left: 0;">Remove Redundant Processes:</td>
<td><input id="query-pathsbetween-redundant-checkbox" type="checkbox" class="layout-text" checked></td>
</tr>
</tbody>
Expand Down Expand Up @@ -3731,7 +3731,7 @@ <h4 class="modal-title">Paths From To Query</h4>
<td><input id="query-pathsfromto-checkbox" type="checkbox" class="layout-text" checked></td>
</tr>
<tr>
<td class="caption-style-text" style="padding-left: 0;">Remove Redundant Nodes:</td>
<td class="caption-style-text" style="padding-left: 0;">Remove Redundant Processes:</td>
<td><input id="query-pathsfromto-redundant-checkbox" type="checkbox" class="layout-text" checked></td>
</tr>
</tbody>
Expand Down Expand Up @@ -3798,7 +3798,7 @@ <h4 class="modal-title">Common Stream Query</h4>
<td><input id="query-commonstream-checkbox" type="checkbox" class="layout-text" checked></td>
</tr>
<tr>
<td class="caption-style-text" style="padding-left: 0;">Remove Redundant Nodes:</td>
<td class="caption-style-text" style="padding-left: 0;">Remove Redundant Processes:</td>
<td><input id="query-commonstream-redundant-checkbox" type="checkbox" class="layout-text" checked></td>
</tr>
</tbody>
Expand Down Expand Up @@ -3841,7 +3841,9 @@ <h4 class="modal-title">Paths By URI</h4>
<td colspan=2>
<div style="display: flex; flex-direction: row; column-gap: 5px;">
<div class="caption-style-text">Remove Disconnected Nodes:</div>
<input id="query-pathsbyURI-checkbox" type="checkbox" class="layout-text" style="margin: 0 0;" checked>
<input id="query-pathsbyURI-checkbox" type="checkbox" class="layout-text" style="margin: 0 0; padding-left: 50px" checked>
<div class="caption-style-text" style="padding-left: 65px">Remove Redundant Processes:</div>
<input id="query-pathsbyURI-redundant-checkbox" type="checkbox" class="layout-text" style="margin: 0 0;" checked>
</div>
</td>
</tr>
Expand Down

0 comments on commit f78289d

Please sign in to comment.