use of org.jparsec.functors.Tuple4 in project fql by CategoricalData.
the class XRaToFpql method toEd.
@SuppressWarnings({ "rawtypes", "unchecked" })
private static EED toEd(Object decl) {
Map<String, String> from1 = new LinkedHashMap<>();
Map<String, String> from2 = new LinkedHashMap<>();
List<Pair<Pair<String, String>, Pair<String, String>>> where1 = new LinkedList<>();
List<Pair<Pair<String, String>, Pair<String, String>>> where2 = new LinkedList<>();
Tuple4 o = (Tuple4) decl;
org.jparsec.functors.Pair from10 = (org.jparsec.functors.Pair) o.a;
org.jparsec.functors.Pair where10 = (org.jparsec.functors.Pair) o.b;
org.jparsec.functors.Pair from11 = (org.jparsec.functors.Pair) o.c;
org.jparsec.functors.Pair where11 = (org.jparsec.functors.Pair) o.d;
List<Tuple3> from10x = (List<Tuple3>) from10.b;
for (Tuple3 k : from10x) {
from1.put(k.c.toString(), k.a.toString());
}
// if (where0 == null) {
//
// } else {
List<Tuple3> where10x = (List<Tuple3>) where10.b;
for (Tuple3 k : where10x) {
Tuple3 l = (Tuple3) k.a;
if (k.c instanceof Tuple3) {
Tuple3 r = (Tuple3) k.c;
where1.add(new Pair<>(new Pair<>(l.a.toString(), l.c.toString()), new Pair<>(r.a.toString(), r.c.toString())));
} else {
String r = (String) k.c;
where1.add(new Pair<>(new Pair<>(l.a.toString(), l.c.toString()), new Pair<>(r, null)));
}
}
// }
List<Tuple3> from11x = (List<Tuple3>) from11.b;
for (Tuple3 k : from11x) {
from2.put(k.c.toString(), k.a.toString());
}
// if (where0 == null) {
//
// } else {
List<Tuple3> where11x = (List<Tuple3>) where11.b;
for (Tuple3 k : where11x) {
Tuple3 l = (Tuple3) k.a;
if (k.c instanceof Tuple3) {
Tuple3 r = (Tuple3) k.c;
where2.add(new Pair<>(new Pair<>(l.a.toString(), l.c.toString()), new Pair<>(r.a.toString(), r.c.toString())));
} else {
String r = (String) k.c;
where2.add(new Pair<>(new Pair<>(l.a.toString(), l.c.toString()), new Pair<>(r, null)));
}
}
return new EED(from1, from2, where1, where2);
}
use of org.jparsec.functors.Tuple4 in project fql by CategoricalData.
the class XRaToFpql method toECreateTable.
@SuppressWarnings("rawtypes")
private static ECreateTable toECreateTable(Object decl) {
Tuple4 t = (Tuple4) decl;
String name = t.c.toString();
Tuple3 t0 = (Tuple3) t.d;
List t1 = (List) t0.b;
List<Pair<String, String>> types = new LinkedList<>();
for (Object o : t1) {
org.jparsec.functors.Pair p = (org.jparsec.functors.Pair) o;
types.add(new Pair<>(p.a.toString(), p.b.toString()));
}
return new ECreateTable(name, types);
}
use of org.jparsec.functors.Tuple4 in project fql by CategoricalData.
the class XSqlToFql method toECreateTable.
@SuppressWarnings("rawtypes")
private static ECreateTable toECreateTable(Object decl) {
Tuple4 t = (Tuple4) decl;
String name = t.c.toString();
Tuple3 t0 = (Tuple3) t.d;
List t1 = (List) t0.b;
List<Pair<String, String>> types = new LinkedList<>();
List<Pair<String, String>> fks = new LinkedList<>();
for (Object o : t1) {
org.jparsec.functors.Pair p = (org.jparsec.functors.Pair) o;
if (p.a.toString().equals("FOREIGN")) {
Tuple5 x = (Tuple5) o;
Tuple3 y = (Tuple3) x.b;
fks.add(new Pair<>(y.b.toString(), x.d.toString()));
} else {
// if (p.a.toString().toLowerCase().equals("id")) {
types.add(new Pair<>(p.a.toString(), p.b.toString()));
// } else {
// types.add(new Pair<>(name + "_" + p.a.toString(), p.b.toString()));
// }
}
}
return new ECreateTable(name, types, fks);
}
use of org.jparsec.functors.Tuple4 in project fql by CategoricalData.
the class RaToFql method toECreateTable.
@SuppressWarnings("rawtypes")
private static ECreateTable toECreateTable(Object decl) {
Tuple4 t = (Tuple4) decl;
String name = t.c.toString();
Tuple3 t0 = (Tuple3) t.d;
List t1 = (List) t0.b;
List<Pair<String, String>> types = new LinkedList<>();
for (Object o : t1) {
org.jparsec.functors.Pair p = (org.jparsec.functors.Pair) o;
types.add(new Pair<>(p.a.toString(), p.b.toString()));
}
return new ECreateTable(name, types);
}
use of org.jparsec.functors.Tuple4 in project fql by CategoricalData.
the class FQLParser method toSchemaConst.
@SuppressWarnings({ "rawtypes", "unchecked" })
private static SigExp toSchemaConst(Object y) {
List<String> nodes = new LinkedList<>();
List<Triple<String, String, String>> attrs = new LinkedList<>();
List<Triple<String, String, String>> arrows = new LinkedList<>();
List<Pair<List<String>, List<String>>> eqs = new LinkedList<>();
Tuple4 s = (Tuple4) y;
Tuple3 nodes0 = (Tuple3) s.a;
Tuple3 attrs0 = (Tuple3) s.b;
Tuple3 arrows0 = (Tuple3) s.c;
Tuple3 eqs0 = (Tuple3) s.d;
List nodes1 = (List) nodes0.b;
List arrows1 = (List) arrows0.b;
List eqs1 = (List) eqs0.b;
for (Object o : nodes1) {
nodes.add((String) o);
}
if (attrs0.b.toString().equals("ASWRITTEN")) {
for (String k : nodes) {
attrs.add(new Triple<>(k + "_att", k, "string"));
}
} else {
List attrs1 = (List) attrs0.b;
for (Object o : attrs1) {
Tuple5 x = (Tuple5) o;
attrs.add(new Triple<>((String) x.a, (String) x.c, (String) x.e));
}
}
for (Object o : arrows1) {
Tuple5 x = (Tuple5) o;
arrows.add(new Triple<>((String) x.a, (String) x.c, (String) x.e));
}
for (Object o : eqs1) {
Tuple3 x = (Tuple3) o;
eqs.add(new Pair<>((List<String>) x.a, (List<String>) x.c));
}
Const c = new Const(nodes, attrs, arrows, eqs);
return c;
}
Aggregations