use of de.prob.prolog.term.PrologTerm in project prob2 by bendisposto.
the class ExpandedFormula method init.
public void init(final CompoundPrologTerm cpt) {
name = cpt.getArgument(1).getFunctor();
fields.put("name", escapeUnicode(name));
// Value
PrologTerm v = cpt.getArgument(2);
value = getValue(v);
fields.put("value", value instanceof String ? escapeUnicode((String) value) : value);
fields.put("hasError", hasError);
// Children
id = cpt.getArgument(3).getFunctor();
fields.put("id", id);
ListPrologTerm list = BindingGenerator.getList(cpt.getArgument(4));
if (!list.isEmpty()) {
children = new ArrayList<>();
List<Object> childrenFields = new ArrayList<>();
for (PrologTerm prologTerm : list) {
ExpandedFormula expandedFormula = new ExpandedFormula(BindingGenerator.getCompoundTerm(prologTerm, 4));
children.add(expandedFormula);
childrenFields.add(expandedFormula.getFields());
}
fields.put("children", childrenFields);
}
}
use of de.prob.prolog.term.PrologTerm in project prob2 by bendisposto.
the class GetCurrentPreferencesCommand method processResult.
@Override
public void processResult(final ISimplifiedROMap<String, PrologTerm> bindings) {
ListPrologTerm prefs = BindingGenerator.getList(bindings.get(PREFERENCES_VARIABLE));
for (PrologTerm prologTerm : prefs) {
CompoundPrologTerm cpt = BindingGenerator.getCompoundTerm(prologTerm, 2);
preferences.put(cpt.getArgument(1).getFunctor(), cpt.getArgument(2).getFunctor());
}
}
use of de.prob.prolog.term.PrologTerm in project prob2 by bendisposto.
the class GetEnableMatrixCommand method processResult.
// yes('.'(=('Matrix','.'(enable_rel(new,del,enable_edges(ok,ok,false,false)),[])),[]))
// enable_edges(Enable,KeepEnabled,Disable,KeepDisabled)
@Override
public void processResult(final ISimplifiedROMap<String, PrologTerm> bindings) {
ListPrologTerm elements = (ListPrologTerm) bindings.get(MATRIX_VAR);
matrix.clear();
for (PrologTerm term : elements) {
EventPair key = new EventPair(term.getArgument(1).getFunctor(), term.getArgument(2).getFunctor());
matrix.put(key, new EnableMatixEntry(term.getArgument(3)));
}
}
use of de.prob.prolog.term.PrologTerm in project prob2 by bendisposto.
the class GetMachineOperationInfos method processResult.
@Override
public void processResult(final ISimplifiedROMap<String, PrologTerm> bindings) {
for (PrologTerm prologTerm : BindingGenerator.getList(bindings, RESULT_VARIABLE)) {
final String opName = prologTerm.getArgument(1).getFunctor();
final List<String> outputParameterNames = ((ListPrologTerm) prologTerm.getArgument(2)).stream().map(PrologTerm::getFunctor).collect(Collectors.toList());
final List<String> parameterNames = ((ListPrologTerm) prologTerm.getArgument(3)).stream().map(PrologTerm::getFunctor).collect(Collectors.toList());
operationInfos.add(new OperationInfo(opName, parameterNames, outputParameterNames));
}
}
use of de.prob.prolog.term.PrologTerm in project prob2 by bendisposto.
the class TestHelper method mkAtomMock.
public static ISimplifiedROMap<String, PrologTerm> mkAtomMock(final String... strings) {
@SuppressWarnings("unchecked") ISimplifiedROMap<String, PrologTerm> map = mock(ISimplifiedROMap.class);
for (int i = 0; i < strings.length; i += 2) {
String key = strings[i];
String value = strings[i + 1];
when(map.get(key)).thenReturn(new CompoundPrologTerm(value));
}
return map;
}
Aggregations