if( operatorObject.has("TERMS") ) {
termsObject = operatorObject.getJSONObject("TERMS");
}
Operator op = null;
// Connections
if (opName.equals("CONNECTIONS")) {
continue;
}
// UnitermOperator
if (operatorObject.has("OP TYPE")
&& operatorObject.getString("OP TYPE").equals(
"UnitermOperator" ) && (termsObject != null)) {
final UnitermOperator uniTerm = new UnitermOperator();
uniTerm.fromJSON(operatorObject, uniTerm, this);
uniTerm.setConstantComboBoxEntries(this.visualRifEditor.getDocumentContainer().getActiveDocument().getDocumentEditorPane().getPrefixList());
uniTerm.setVisualRifEditor(this.visualRifEditor);
uniTerm.setTermName(operatorObject.getString("TERMNAME"));
uniTerm.getUniTermComboBox().setSelectedItem(operatorObject.getString("SELECTEDPREFIX"));
uniTerm.setSelectedPrefix(operatorObject.getString("SELECTEDPREFIX"));
uniTerm.setExternal(operatorObject.getBoolean("EXTERNAL"));
uniTerm.setNamed(operatorObject.getBoolean("NAMED"));
// get savedTerms
final HashMap<String,Term> unsortedTerms = this.getSavedTerms(termsObject,uniTerm);
// sort terms
final LinkedList<Term> terms = this.sortTerms(unsortedTerms);
uniTerm.setTerms(terms);
op = uniTerm;
} // end UnitermOperator
// ListOperator
if (operatorObject.has("OP TYPE")
&& operatorObject.getString("OP TYPE").equals(
"ListOperator") && (termsObject != null)) {
final ListOperator listOp = new ListOperator();
listOp.fromJSON(operatorObject, listOp, this);
listOp.setConstantComboBoxEntries(this.visualRifEditor.getDocumentContainer().getActiveDocument().getDocumentEditorPane().getPrefixList());
listOp.setVisualRifEditor(this.visualRifEditor);
listOp.setOpen(operatorObject.getBoolean("ISOPEN"));
// get savedTerms
final HashMap<String,Term> unsortedTerms = this.getSavedTerms(termsObject,listOp);
// sort terms
final LinkedList<Term> terms = this.sortTerms(unsortedTerms);
listOp.setTerms(terms);
op = listOp;
} // end ListOperator
// FrameOperator
if (operatorObject.has("OP TYPE")
&& operatorObject.getString("OP TYPE").equals(
"FrameOperator") && (termsObject != null)) {
final FrameOperator frameOp = new FrameOperator();
frameOp.setConstantComboBoxEntries(this.visualRifEditor.getDocumentContainer().getActiveDocument().getDocumentEditorPane().getPrefixList());
frameOp.setVisualRifEditor(this.visualRifEditor);
// get savedTerms
final HashMap<String,Term> unsortedTerms = this.getSavedTerms(termsObject,frameOp);
// sort terms
final LinkedList<Term> terms = this.sortTerms(unsortedTerms);
frameOp.setTerms(terms);
op = frameOp;
} // end FrameOperator
// AND
if (operatorObject.has("OP TYPE")
&& operatorObject.getString("OP TYPE").equals(
"and")) {
final AndContainer andContainer = new AndContainer();
andContainer.setVisualRifEditor(this.visualRifEditor);
andContainer.fromJSON(operatorObject.getJSONObject("OPERATORGRAPH"));
op = andContainer;
}
// Or
if (operatorObject.has("OP TYPE")
&& operatorObject.getString("OP TYPE").equals(
"or")) {
final OrContainer orContainer = new OrContainer();
orContainer.setVisualRifEditor(this.visualRifEditor);
orContainer.fromJSON(operatorObject.getJSONObject("OPERATORGRAPH"));
op = orContainer;
}
// Exists
if (operatorObject.has("OP TYPE")
&& operatorObject.getString("OP TYPE").equals(
"exists")) {
final ExistsContainer existsContainer = new ExistsContainer();
existsContainer.setVisualRifEditor(this.visualRifEditor);
existsContainer.fromJSON(operatorObject.getJSONObject("OPERATORGRAPH"));
op = existsContainer;
}
// Variable
if (operatorObject.has("OP TYPE")
&& operatorObject.getString("OP TYPE").equals(
"VariableOperator")) {
final VariableOperator variableOperator = new VariableOperator();
variableOperator.setVisualRifEditor(this.visualRifEditor);
variableOperator.fromJSON(operatorObject,variableOperator,this);
op = variableOperator;
}
// Constant
if (operatorObject.has("OP TYPE")
&& operatorObject.getString("OP TYPE").equals(
"ConstantOperator")) {
final ConstantOperator constantOperator = new ConstantOperator();
constantOperator.setVisualRifEditor(this.visualRifEditor);
constantOperator.fromJSON(operatorObject, constantOperator, this);
op = constantOperator;
}
System.out.println(operatorObject.getString("OP TYPE"));
final JSONArray positionArray = operatorObject.getJSONArray("POSITION");
if (this.isRecursiveOperatorGraph() ) {
System.out.println("this.isRecursiveOperatorGraph() "+op.getClass().getSimpleName());
this.operatorContainer.addOperator(op);
}
this.addOperator(positionArray.getInt(0), positionArray.getInt(1), op);