From 50197f241e8d487e9db8015e53b71ea1fb57b419 Mon Sep 17 00:00:00 2001 From: Logan Terry Date: Wed, 8 Sep 2021 23:33:17 -0600 Subject: [PATCH 1/2] Fix interaction loading and layout saving --- SBOLCanvasBackend/src/utils/Converter.java | 31 ++++++++++------------ SBOLCanvasBackend/src/utils/MxToSBOL.java | 30 +++++++++++++-------- SBOLCanvasBackend/src/utils/SBOLData.java | 2 +- 3 files changed, 34 insertions(+), 29 deletions(-) diff --git a/SBOLCanvasBackend/src/utils/Converter.java b/SBOLCanvasBackend/src/utils/Converter.java index 93746d4a..551e04d1 100644 --- a/SBOLCanvasBackend/src/utils/Converter.java +++ b/SBOLCanvasBackend/src/utils/Converter.java @@ -6,8 +6,6 @@ import javax.xml.namespace.QName; -import org.sbolstandard.core2.SystemsBiologyOntology; - import com.mxgraph.io.mxCodecRegistry; import com.mxgraph.model.mxCell; import com.mxgraph.model.mxGraphModel.Filter; @@ -119,22 +117,21 @@ public boolean filter(Object arg0) { }; protected static URI getParticipantType(boolean source, Set interactionTypes) { - if (interactionTypes.contains(SystemsBiologyOntology.BIOCHEMICAL_REACTION)) { - return source ? SystemsBiologyOntology.REACTANT : SystemsBiologyOntology.PRODUCT; - } else if (interactionTypes.contains(SystemsBiologyOntology.CONTROL)) { - return source ? SystemsBiologyOntology.MODIFIER : SystemsBiologyOntology.MODIFIED; - } else if (interactionTypes.contains(SystemsBiologyOntology.DEGRADATION)) { - return SystemsBiologyOntology.REACTANT; - } else if (interactionTypes.contains(SystemsBiologyOntology.GENETIC_PRODUCTION)) { - return source ? SystemsBiologyOntology.TEMPLATE : SystemsBiologyOntology.PRODUCT; - } else if (interactionTypes.contains(SystemsBiologyOntology.INHIBITION)) { - return source ? SystemsBiologyOntology.INHIBITOR : SystemsBiologyOntology.INHIBITED; - } else if (interactionTypes.contains(SystemsBiologyOntology.NON_COVALENT_BINDING)) { - return source ? SystemsBiologyOntology.REACTANT : SystemsBiologyOntology.PRODUCT; - } else if (interactionTypes.contains(SystemsBiologyOntology.STIMULATION)) { - return source ? SystemsBiologyOntology.STIMULATOR : SystemsBiologyOntology.STIMULATED; + URI interactionType = null; + for(URI interactionURI : SBOLData.interactions.values()) { + if(interactionTypes.contains(interactionURI)) { + interactionType = interactionURI; + break; + } + } + if(interactionType == null) { + return null; + } + if(source) { + return SBOLData.interactionSourceRoles.get(interactionType); + }else { + return SBOLData.interactionTargetRoles.get(interactionType); } - return null; } static QName createQName(String name) { diff --git a/SBOLCanvasBackend/src/utils/MxToSBOL.java b/SBOLCanvasBackend/src/utils/MxToSBOL.java index 7909c243..cc85a8a5 100644 --- a/SBOLCanvasBackend/src/utils/MxToSBOL.java +++ b/SBOLCanvasBackend/src/utils/MxToSBOL.java @@ -255,16 +255,6 @@ private void createModuleDefinition(SBOLDocument document, mxGraph graph, mxGrap .toArray(mxCell[]::new); ModuleInfo modInfo = (ModuleInfo) infoDict.get(viewCell.getId()); - if (modInfo.getUriPrefix() == null) - modInfo.setUriPrefix(URI_PREFIX); - ModuleDefinition modDef = document.createModuleDefinition(modInfo.getUriPrefix(), modInfo.getDisplayID(), - modInfo.getVersion()); - layoutHelper.createGraphicalLayout(modDef.getIdentity(), modDef.getDisplayId() + "_Layout"); - - // text boxes - if (textBoxes.length > 0) { - attachTextBoxAnnotation(model, viewCell, modDef.getIdentity()); - } // if the uri is one of the synbiohub ones, just add the layout boolean layoutOnly = false; @@ -281,6 +271,23 @@ private void createModuleDefinition(SBOLDocument document, mxGraph graph, mxGrap } } + if (modInfo.getUriPrefix() == null || modInfo.getUriPrefix().equals("")) + modInfo.setUriPrefix(URI_PREFIX); + + ModuleDefinition modDef = null; + if(layoutOnly) { + modDef = document.getModuleDefinition(new URI(modInfo.getFullURI())); + }else { + modDef = document.createModuleDefinition(modInfo.getUriPrefix(), modInfo.getDisplayID(), + modInfo.getVersion()); + } + layoutHelper.createGraphicalLayout(modDef.getIdentity(), modDef.getDisplayId() + "_Layout"); + + // text boxes + if (textBoxes.length > 0) { + attachTextBoxAnnotation(model, viewCell, modDef.getIdentity()); + } + // proteins for (mxCell protein : proteins) { // proteins also have glyphInfos @@ -513,7 +520,8 @@ private void linkModuleDefinition(SBOLDocument document, mxGraph graph, mxGraphM Set interactions = modDef.getInteractions(); // find the interaction with the correct identity for (Interaction inter : interactions) { - if (inter.getIdentity().toString().equals((String) intInfo.getFullURI())) { + // TODO don't use startsWith here, inter.getIdentity() is including the version number, which isn't tracked in the front end + if (inter.getIdentity().toString().startsWith((String) intInfo.getFullURI())) { interaction = inter; break; } diff --git a/SBOLCanvasBackend/src/utils/SBOLData.java b/SBOLCanvasBackend/src/utils/SBOLData.java index 6e18f7cc..c97153ff 100644 --- a/SBOLCanvasBackend/src/utils/SBOLData.java +++ b/SBOLCanvasBackend/src/utils/SBOLData.java @@ -126,7 +126,7 @@ public class SBOLData { interactionSourceRoles.put(SystemsBiologyOntology.BIOCHEMICAL_REACTION, SystemsBiologyOntology.REACTANT); interactionSourceRoles.put(SystemsBiologyOntology.NON_COVALENT_BINDING, SystemsBiologyOntology.REACTANT); interactionSourceRoles.put(SystemsBiologyOntology.DEGRADATION, SystemsBiologyOntology.REACTANT); - interactionSourceRoles.put(SystemsBiologyOntology.GENETIC_PRODUCTION, SystemsBiologyOntology.REACTANT); + interactionSourceRoles.put(SystemsBiologyOntology.GENETIC_PRODUCTION, SystemsBiologyOntology.TEMPLATE); interactionSourceRoles.put(SystemsBiologyOntology.CONTROL, SystemsBiologyOntology.MODIFIER); interactionSourceRoles.put(SystemsBiologyOntology.DISSOCIATION, SystemsBiologyOntology.REACTANT); From a78f928508c21aba705091636a70eb5c8b717594 Mon Sep 17 00:00:00 2001 From: Logan Terry Date: Wed, 8 Sep 2021 23:37:21 -0600 Subject: [PATCH 2/2] Add logout button to upload --- .../src/app/upload-graph/upload-graph.component.html | 3 ++- .../src/app/upload-graph/upload-graph.component.ts | 7 +++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/SBOLCanvasFrontend/src/app/upload-graph/upload-graph.component.html b/SBOLCanvasFrontend/src/app/upload-graph/upload-graph.component.html index fa420e09..f14cda2a 100644 --- a/SBOLCanvasFrontend/src/app/upload-graph/upload-graph.component.html +++ b/SBOLCanvasFrontend/src/app/upload-graph/upload-graph.component.html @@ -57,7 +57,8 @@

Import

- + + diff --git a/SBOLCanvasFrontend/src/app/upload-graph/upload-graph.component.ts b/SBOLCanvasFrontend/src/app/upload-graph/upload-graph.component.ts index e0f082d2..75a008fc 100644 --- a/SBOLCanvasFrontend/src/app/upload-graph/upload-graph.component.ts +++ b/SBOLCanvasFrontend/src/app/upload-graph/upload-graph.component.ts @@ -102,6 +102,13 @@ export class UploadGraphComponent implements OnInit { }); } + async onLogoutClick() { + this.working = true; + await this.loginService.logout(this.registry); + this.working = false; + this.updateCollections(); + } + onCreateCollectionClick() { this.dialog.open(CollectionCreationComponent, {data: {registry: this.registry}}).afterClosed().subscribe(result => { if(result)