Skip to content

Commit

Permalink
Adding derivedFrom property for variables too
Browse files Browse the repository at this point in the history
  • Loading branch information
IKCAP committed Jan 19, 2015
1 parent a45d0ce commit 789f346
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1394,6 +1394,7 @@ public Template getExpandedTemplate(Template template) {
// Input Variable doesn't exist. Create a new variable and link
newVariable = curt.addVariable(ns + variable.getName(), variable.getVariableType());
newVariable.setBinding(cb);
newVariable.setDerivedFrom(variable.getID());
newVariables.put(varkey, newVariable);

// Add new input link
Expand Down Expand Up @@ -1450,6 +1451,7 @@ public Template getExpandedTemplate(Template template) {
// Create a new variable
newVariable = curt.addVariable(ns + variable.getName(), variable.getVariableType());
newVariable.setBinding(cb);
newVariable.setDerivedFrom(variable.getID());
newVariables.put(varkey, newVariable);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -534,6 +534,10 @@ else if(verobj.getValue().getClass() == Integer.class)
KBObject autoFill = kb.getPropertyValue(varObj, pmap.get("autoFill"));
if(autoFill != null && (Boolean)autoFill.getValue())
var.setAutoFill(true);

KBObject dvar = kb.getPropertyValue(varObj, propertyObjMap.get("derivedFrom"));
if(dvar != null)
var.setDerivedFrom(dvar.getID());
varMap.put(varObj.getID(), var);
}
}
Expand Down Expand Up @@ -1711,6 +1715,10 @@ private KBAPI serializeIntoKB(KBAPI tkb, boolean subtemplate) {
ontologyFactory.getDataObject(true));
}
}
if(v.getDerivedFrom() != null)
tkb.addPropertyValue(vobj, propertyObjMap.get("derivedFrom"),
tkb.getResource(v.getDerivedFrom()));

if (vobj != null && v.getComment() != null) {
tkb.setComment(vobj, v.getComment());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ public class Variable extends URIEntity {
private boolean autofill;
private boolean breakpoint;

private String derivedFrom;

public Variable(String id, short type) {
super(id);
this.type = type;
Expand Down Expand Up @@ -89,4 +91,12 @@ public void setBreakpoint(boolean breakpoint) {
public String toString() {
return getID() + (binding != null ? " (" + binding.toString() + ")" : "");
}

public String getDerivedFrom() {
return derivedFrom;
}

public void setDerivedFrom(String derivedFrom) {
this.derivedFrom = derivedFrom;
}
}
4 changes: 4 additions & 0 deletions portal/src/main/webapp/js/gui/template/template.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,13 @@ Template.prototype.initialize = function() {
var type = variable.type == 1 ? 'DATA' : 'PARAM';
this.variables[variable.id] = new Variable(this, variable.id, getLocalName(variable.id),
parseInt(xy.x) + 0.5, parseInt(xy.y) + 0.5, type);

if(xy.center)
this.variables[variable.id].centercoords = true;
this.variables[variable.id].setBinding(variable.binding);

this.variables[variable.id].derivedFrom = variable.derivedFrom;

// Set input/output role dimensionality
var irole = this.store.inputRoles[variable.id];
if(irole)
Expand Down Expand Up @@ -268,6 +271,7 @@ Template.prototype.saveToStore = function(showFullPorts) {
type : v.type == 'DATA' ? 1 : 2,
binding : v.binding,
inactive : v.inactive,
derivedFrom : v.derivedFrom,
//FIXME: unknown isn't currently stored on server
unknown : v.unknown,
autofill : v.autofill,
Expand Down

0 comments on commit 789f346

Please sign in to comment.