Skip to content

Commit

Permalink
Merge pull request #187 from SynBioDex/encoding-fixes-and-logout-on-u…
Browse files Browse the repository at this point in the history
…pload

Encoding fixes and logout on upload
  • Loading branch information
cjmyers authored Sep 9, 2021
2 parents f367e63 + a78f928 commit 71c4ae6
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 30 deletions.
31 changes: 14 additions & 17 deletions SBOLCanvasBackend/src/utils/Converter.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -119,22 +117,21 @@ public boolean filter(Object arg0) {
};

protected static URI getParticipantType(boolean source, Set<URI> 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) {
Expand Down
30 changes: 19 additions & 11 deletions SBOLCanvasBackend/src/utils/MxToSBOL.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
Expand Down Expand Up @@ -513,7 +520,8 @@ private void linkModuleDefinition(SBOLDocument document, mxGraph graph, mxGraphM
Set<Interaction> 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;
}
Expand Down
2 changes: 1 addition & 1 deletion SBOLCanvasBackend/src/utils/SBOLData.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ <h1 mat-dialog-title *ngIf="importMode">Import</h1>
</div>

<div mat-dialog-actions>
<button mat-button [disabled]="loginDisabled()" (click)="onLoginClick()">Login</button>
<button mat-button *ngIf="!loginDisabled()" [disabled]="!registry" (click)="onLoginClick()">Login</button>
<button mat-button *ngIf="loginDisabled()" [disabled]="!registry" (click)="onLogoutClick()">Logout</button>
<button mat-button (click)="onCancelClick()">Cancel</button>
<button *ngIf="!importMode" mat-button [disabled]="!finishCheck()" (click)="onUploadClick()">Upload</button>
<button *ngIf="importMode" mat-button [disabled]="!finishCheck()" (click)="onImportClick()">Import</button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 71c4ae6

Please sign in to comment.