use of catdata.opl.OplExp.OplFlower in project fql by CategoricalData.
the class OplParser method toFlower.
private static OplFlower toFlower(Object c) {
Tuple3 p = (Tuple3) c;
// if (p.a.toString().equals("flower")) {
String I = (String) p.c;
Tuple3 q = (Tuple3) p.b;
// list of tuple3 of (path, string)
List s = (List) ((org.jparsec.functors.Pair) q.a).b;
// list of tuple3 of (string, string)
List f = (List) ((org.jparsec.functors.Pair) q.b).b;
// list of tuple3 of (path, path)
List w = (List) ((org.jparsec.functors.Pair) q.c).b;
Map<String, OplTerm<String, String>> select = new HashMap<>();
Map<String, String> from = new HashMap<>();
List<Pair<OplTerm<String, String>, OplTerm<String, String>>> where = new LinkedList<>();
Set<String> seen = new HashSet<>();
for (Object o : f) {
Tuple3 t = (Tuple3) o;
String lhs = t.a.toString();
String rhs = t.c.toString();
if (seen.contains(rhs)) {
throw new DoNotIgnore("Duplicate AS name: " + rhs + " (note: AS names can't be used in the schema either)");
}
seen.add(rhs);
from.put(rhs, lhs);
}
for (Object o : w) {
Tuple3 t = (Tuple3) o;
OplTerm lhs = toTerm(from.keySet(), null, t.a, false);
OplTerm rhs = toTerm(from.keySet(), null, t.c, false);
where.add(new Pair<>(rhs, lhs));
}
for (Object o : s) {
Tuple3 t = (Tuple3) o;
OplTerm lhs = toTerm(from.keySet(), null, t.a, false);
String rhs = t.c.toString();
if (seen.contains(rhs)) {
throw new DoNotIgnore("Duplicate AS name: " + rhs + " (note: AS names can't be used in the schema either)");
}
seen.add(rhs);
select.put(rhs, lhs);
}
return new OplFlower<>(select, from, where, I);
}
Aggregations