Examples of Calc


Examples of com.jengine.orm.model.multi.field.Calc

        // distinct test
        check( Transaction.cls.select("member.library").distinct().<Library>list().size() == 1 );

        //order testing
        check( CollectionUtil.equals(Author.cls.select("id").order("lastName").list(), list(2l, 3l, 1l)) );
        List members = Member.cls.select(new Calc("f", Long.class, "%s + 1", "id")).order("library.name").order("f").list();
        check( CollectionUtil.equals(members, list(2l, 3l, 4l, 5l, 6l)) );
        check( Transaction.cls.select("member").distinct().page(0, 1).<Member>list().size() == 1 );

        check( Transaction.cls.select().<Transaction>list().size() == 3 );
    }
View Full Code Here

Examples of com.jengine.orm.model.multi.field.Calc

        check( Author.cls.<Long>max(Author.id) == 3l );
        check( Author.cls.<Long>sum(Author.id) == 6l );
        check( Author.cls.<Long>min(Author.id) == 1l );
        check( Book.cls.count() == 3l );
        check( Book.cls.select(new Calc("counter", Long.class, "id + 1", "id")).filter("id = ?", 1l).<Long>one() == 2l );
        Book.cls.select("id", new Max("id")).filter("id = ?", 1l).group("id").one();
        check( Book.cls.<Long>calc("sum", Long.class, "max(%s) + 2", Book.id) == 5l );
        Transaction.cls.select("id", new Max("book.id")).filter("book.id = ?", 1l).group("id").one();
    }
View Full Code Here

Examples of com.jengine.orm.model.multi.field.Calc

        check( cluster1.<Long>sum("Transaction.id") == 6);
        check( cluster1.count() == 3);
        check( cluster1.count("Book.id") == 3);
//        check( cluster1.<Long>calc("%s + 10", "Transaction.id") > 0);
//        check( new Cluster("Transaction >> Book").fields("Transaction.id", new Calc("calc_field", Long.class, "%s + 10", "Transaction.id")).select().list() != null );
        check( new Cluster("Transaction >> Book").fields("Transaction.id", new Calc("calc_field", Long.class, "%s + 10", "Transaction.id")).select().list()
                .equals(list(list(1l, 11l), list(2l, 12l), list(3l, 13l), list(null, null))) );
        check( new Cluster("Transaction >> Book").fields("Transaction.id""Book.id", "Book.title", new Max("Transaction.id")).select().group("Book.title").list()
                .equals(list(list(1l, 1l, "The Dark Tower", 1l), list(2l, 2l, "The Shining", 3l), list(null, 3l, "Vingt mille lieues sous les mers", null))) );
        check( new Cluster("Transaction >> Book").fields("Transaction.id""Book.id", "Book.title", new Max("Transaction.id")).groupCluster("Book.title").select().list()
                .equals(list(list(1l, 1l, "The Dark Tower", 1l), list(2l, 2l, "The Shining", 3l), list(null, 3l, "Vingt mille lieues sous les mers", null))) );
View Full Code Here

Examples of com.jengine.orm.model.multi.field.Calc

        // distinct test
        check( Transaction.cls.select("member.library").distinct().<Library>list().size() == 1 );

        //order testing
        check( CollectionUtil.equals(Author.cls.select("id").order("lastName").list(), list(2l, 3l, 1l)) );
        List members = Member.cls.select(new Calc("f", Long.class, "%s + 1", "id")).order("library.name").order("f").list();
        check( CollectionUtil.equals(members, list(2l, 3l, 4l, 5l, 6l)) );
        check( Transaction.cls.select("member").distinct().page(0, 1).<Member>list().size() == 1 );

        check( Transaction.cls.select().<Transaction>list().size() == 3 );
    }
View Full Code Here

Examples of com.jengine.orm.model.multi.field.Calc

        check( Author.cls.<Long>max(Author.id) == 3l );
        check( Author.cls.<Long>sum(Author.id) == 6l );
        check( Author.cls.<Long>min(Author.id) == 1l );
        check( Book.cls.count() == 3l );
        check( Book.cls.select(new Calc("counter", Long.class, "id + 1", "id")).filter("id = ?", 1l).<Long>one() == 2l );
        Book.cls.select("id", new Max("id")).filter("id = ?", 1l).group("id").one();
        check( Book.cls.<Long>calc("sum", Long.class, "max(%s) + 2", Book.id) == 5l );
        Transaction.cls.select("id", new Max("book.id")).filter("book.id = ?", 1l).group("id").one();
    }
View Full Code Here

Examples of com.jengine.orm.model.multi.field.Calc

        check( cluster1.<Long>sum("Transaction.id") == 6);
        check( cluster1.count() == 3);
        check( cluster1.count("Book.id") == 3);
//        check( cluster1.<Long>calc("%s + 10", "Transaction.id") > 0);
//        check( new Cluster("Transaction >> Book").fields("Transaction.id", new Calc("calc_field", Long.class, "%s + 10", "Transaction.id")).select().list() != null );
        check( new Cluster("Transaction >> Book").fields("Transaction.id", new Calc("calc_field", Long.class, "%s + 10", "Transaction.id")).select().list()
                .equals(list(list(1l, 11l), list(2l, 12l), list(3l, 13l), list(null, null))) );
        check( new Cluster("Transaction >> Book").fields("Transaction.id""Book.id", "Book.title", new Max("Transaction.id")).select().group("Book.title").list()
                .equals(list(list(1l, 1l, "The Dark Tower", 1l), list(2l, 2l, "The Shining", 3l), list(null, 3l, "Vingt mille lieues sous les mers", null))) );
        check( new Cluster("Transaction >> Book").fields("Transaction.id""Book.id", "Book.title", new Max("Transaction.id")).groupCluster("Book.title").select().list()
                .equals(list(list(1l, 1l, "The Dark Tower", 1l), list(2l, 2l, "The Shining", 3l), list(null, 3l, "Vingt mille lieues sous les mers", null))) );
View Full Code Here

Examples of com.sun.grid.jgdi.util.OutputTable.Calc

            table.addCol("department", "department", 15);
        }
        table.addCol("state", "state", 5);
        if (sge_time) {

            Calc timeCalc = new Calc() {

                public Object getValue(Object obj) {
                    JobSummary js = (JobSummary) obj;
                    if (js.isRunning()) {
                        return js.getStartTime();
                    } else {
                        return js.getSubmitTime();
                    }
                }
            };
            table.addCol("submitTime", "submit/start at     ", 19, DEFAULT_DATE_FORMAT, timeCalc);
        }
        if (sge_urg) {
            table.addCol("deadline", "deadline", 15);
        }
        if (sge_ext) {
            table.addCol("cpuUsage", "cpu", 8, new CpuUsageCalc());
            table.addCol("memUsage", "mem", 7, OutputTable.Column.RIGHT, new MemUsageCalc());
            table.addCol("ioUsage", "io", 7, OutputTable.Column.RIGHT, new IOUsageCalc());
            table.addCol("tickets", "tckts", 8, new TicketCalc(sge_ext) {

                public long getValue(JobSummary js) {
                    return js.getTickets();
                }
            });
            table.addCol("overrideTickets", "ovrts", 8, new TicketCalc(sge_ext) {

                public long getValue(JobSummary js) {
                    return js.getOverrideTickets();
                }
            });
            table.addCol("otickets", "otckt", 8, new TicketCalc(sge_ext) {

                public long getValue(JobSummary js) {
                    return js.getOtickets();
                }
            });
            table.addCol("ftickets", "ftckt", 8, new TicketCalc(sge_ext) {

                public long getValue(JobSummary js) {
                    return js.getFtickets();
                }
            });
            table.addCol("stickets", "stckt", 8, new TicketCalc(sge_ext) {

                public long getValue(JobSummary js) {
                    return js.getStickets();
                }
            });

            table.addCol("share", "share", 8, new ShareCalc(sge_ext));
        }
        //table.addCol("queueAssigned", "qs", 5);
        if (!options.showFullOutput()) {
            table.addCol("queue", "queue", 30);
        }
        // if (options.showPEJobs()) {
        if (options.showExtendedSubTaskInfo()) {
            table.addCol("masterQueue", "master", 8, OutputTable.Column.LEFT);
        } else {
            table.addCol("slots", "slots", 8, OutputTable.Column.RIGHT);
        }
        table.addCol("ja-taskId", "ja-task-ID", 10, new JaTaskIdCalc());


        if (tsk_ext) {
            Calc fixedValue = new Calc() {

                public Object getValue(Object obj) {
                    return "   NA ";
                }
            };
View Full Code Here

Examples of com.sun.grid.jgdi.util.OutputTable.Calc

        OutputTable ret = new OutputTable(QueueInstanceSummary.class);

        ret.addCol("name", "queuename", 30);
        ret.addCol("queueType", "qtype", 5);

        Calc slotCalc = new Calc() {

            public Object getValue(Object obj) {

                QueueInstanceSummary qi = (QueueInstanceSummary) obj;

                StringBuilder ret = new StringBuilder();
                ret.append(qi.getReservedSlots());
                ret.append('/');
                ret.append(qi.getUsedSlots());
                ret.append('/');
                ret.append(qi.getTotalSlots());
                return ret.toString();
            }
        };

        ret.addCol("totalSlots", "resv/used/tot.", 14, slotCalc);

        Calc loadAvgCalc = new Calc() {

            public Object getValue(Object obj) {

                QueueInstanceSummary qi = (QueueInstanceSummary) obj;
                if (qi.isHasLoadValueFromObject()) {
View Full Code Here

Examples of com.sun.grid.jgdi.util.OutputTable.Calc

    private static OutputTable createHostQueueTable() throws IntrospectionException {
        OutputTable ret = new OutputTable(QueueInfo.class);
        ret.addCol("qname", "qname", 20);
        ret.addCol("qType", "qtype", 5);

        Calc slotCalc = new Calc() {

            public Object getValue(Object obj) {
                StringBuilder ret = new StringBuilder();
                QueueInfo qi = (QueueInfo) obj;
                // ret.append(qi.getReservedSlots());
View Full Code Here

Examples of com.sun.grid.jgdi.util.OutputTable.Calc

        ret.addCol("id", "job-ID ", 7, OutputTable.Column.RIGHT);
        ret.addCol("priority", "prior", 7, OutputTable.POINT_FIVE_FORMAT);
        ret.addCol("name", "name", 10);
        ret.addCol("user", "user", 12);
        ret.addCol("state", "state", 5);
        Calc timeCalc = new Calc() {

            public Object getValue(Object obj) {
                JobInfo ji = (JobInfo) obj;
                return ji.getStartTime();
            }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.