Search in sources :

Example 41 with Tuple5

use of org.jparsec.functors.Tuple5 in project fql by CategoricalData.

the class XParser method fromSoed.

/*
J = soed {
	exists f:A->B, g:C->D;
	forall a:A, a.f = p.q, a.g = p.f;
	forall b:B, p = q; 
} : X -> Y on I
	 */
private static XSOED fromSoed(Object ooo) {
    org.jparsec.functors.Pair ooo1 = (org.jparsec.functors.Pair) ooo;
    Tuple4 a = (Tuple4) ooo1.a;
    List<Triple<String, String, String>> es = new LinkedList<>();
    List<FOED> as = new LinkedList<>();
    List<Tuple5> es0 = (List<Tuple5>) a.b;
    for (Tuple5 t : es0) {
        es.add(new Triple(t.a, t.c, t.e));
    }
    List<Tuple4> as0 = (List<Tuple4>) a.d;
    for (Tuple4 t : as0) {
        List<Tuple3> eqs = (List<Tuple3>) t.d;
        List<Pair<List<String>, List<String>>> eqs0 = new LinkedList<>();
        for (Tuple3 x : eqs) {
            eqs0.add(new Pair(x.a, x.c));
        }
        as.add(new FOED((String) t.b, (String) t.c, eqs0));
    }
    Tuple4 b = (Tuple4) ooo1.b;
    String src = (String) b.b;
    String dst = (String) b.c;
    String i = (String) b.d;
    XSOED ret = new XSOED(es, as, src, dst, i);
    return ret;
}
Also used : FOED(catdata.fpql.XExp.XSOED.FOED) SuperFOED(catdata.fpql.XExp.XSuperED.SuperFOED) XSOED(catdata.fpql.XExp.XSOED) LinkedList(java.util.LinkedList) Tuple4(org.jparsec.functors.Tuple4) Triple(catdata.Triple) Tuple5(org.jparsec.functors.Tuple5) Tuple3(org.jparsec.functors.Tuple3) List(java.util.List) LinkedList(java.util.LinkedList) Pair(catdata.Pair) XPair(catdata.fpql.XExp.XPair)

Example 42 with Tuple5

use of org.jparsec.functors.Tuple5 in project fql by CategoricalData.

the class XParser method toMapping.

private static XMapConst toMapping(Object decl) {
    Tuple5 y = (Tuple5) decl;
    org.jparsec.functors.Pair x = (org.jparsec.functors.Pair) y.a;
    Tuple3 nodes = (Tuple3) x.a;
    Tuple3 arrows = (Tuple3) x.b;
    List nodes0 = (List) nodes.b;
    List arrows0 = (List) arrows.b;
    List<Pair<String, String>> nodesX = new LinkedList<>();
    for (Object o : nodes0) {
        Tuple3 u = (Tuple3) o;
        String n = (String) u.a;
        String l = (String) u.c;
        nodesX.add(new Pair<>(n, l));
    }
    List<Pair<String, List<String>>> eqsX = new LinkedList<>();
    for (Object o : arrows0) {
        Tuple3 u = (Tuple3) o;
        String n = (String) u.a;
        List<String> m = (List<String>) u.c;
        eqsX.add(new Pair<>(n, m));
    }
    XMapConst ret = new XMapConst(toExp(y.c), toExp(y.e), nodesX, eqsX);
    return ret;
}
Also used : LinkedList(java.util.LinkedList) Tuple5(org.jparsec.functors.Tuple5) Tuple3(org.jparsec.functors.Tuple3) List(java.util.List) LinkedList(java.util.LinkedList) Pair(catdata.Pair) XPair(catdata.fpql.XExp.XPair) XMapConst(catdata.fpql.XExp.XMapConst)

Example 43 with Tuple5

use of org.jparsec.functors.Tuple5 in project fql by CategoricalData.

the class RaToFql method toEInsertValues.

@SuppressWarnings({ "rawtypes", "unchecked" })
private static EInsertValues toEInsertValues(Object decl) {
    Tuple5 t = (Tuple5) decl;
    String target = t.b.toString();
    List<Tuple3> x = (List<Tuple3>) t.d;
    List<List<String>> values = new LinkedList<>();
    for (Tuple3 y : x) {
        List<String> l = (List<String>) y.b;
        values.add(l);
    }
    return new EInsertValues(target, values);
}
Also used : Tuple5(org.jparsec.functors.Tuple5) Tuple3(org.jparsec.functors.Tuple3)

Example 44 with Tuple5

use of org.jparsec.functors.Tuple5 in project fql by CategoricalData.

the class SqlToFql method toEInsertValues.

@SuppressWarnings({ "rawtypes", "unchecked" })
private static EInsertValues toEInsertValues(Object decl) {
    Tuple5 t = (Tuple5) decl;
    String target = t.b.toString();
    List<Tuple3> x = (List<Tuple3>) t.d;
    List<List<String>> values = new LinkedList<>();
    for (Tuple3 y : x) {
        List<String> l = (List<String>) y.b;
        values.add(l);
    }
    return new EInsertValues(target, values);
}
Also used : Tuple5(org.jparsec.functors.Tuple5) Tuple3(org.jparsec.functors.Tuple3) LinkedList(java.util.LinkedList) List(java.util.List) LinkedList(java.util.LinkedList)

Example 45 with Tuple5

use of org.jparsec.functors.Tuple5 in project fql by CategoricalData.

the class SqlToFql 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 {
            types.add(new Pair<>(p.a.toString(), p.b.toString()));
        }
    }
    return new ECreateTable(name, types, fks);
}
Also used : LinkedList(java.util.LinkedList) Tuple4(org.jparsec.functors.Tuple4) Tuple5(org.jparsec.functors.Tuple5) Tuple3(org.jparsec.functors.Tuple3) LinkedList(java.util.LinkedList) List(java.util.List) Pair(catdata.Pair)

Aggregations

Tuple5 (org.jparsec.functors.Tuple5)47 Tuple3 (org.jparsec.functors.Tuple3)41 Pair (catdata.Pair)36 LinkedList (java.util.LinkedList)36 List (java.util.List)36 HashMap (java.util.HashMap)21 Tuple4 (org.jparsec.functors.Tuple4)20 Triple (catdata.Triple)10 HashSet (java.util.HashSet)10 LinkedHashMap (java.util.LinkedHashMap)10 XPair (catdata.fpql.XExp.XPair)9 Map (java.util.Map)8 Set (java.util.Set)5 Apply (catdata.fqlpp.FunctorExp.Apply)4 Var (catdata.fqlpp.FunctorExp.Var)4 PeterApply (catdata.fqlpp.TransExp.PeterApply)4 Pair (org.jparsec.functors.Pair)4 XSchema (catdata.fpql.XExp.XSchema)3 Plus (catdata.fqlpp.CatExp.Plus)3 Program (catdata.Program)2