Package com.sun.faban.common

Examples of com.sun.faban.common.SortableTableModel


        String sortColumn = req.getParameter("sortColumn");
        String sortDirection = req.getParameter("sortDirection");
        if (sortColumn != null && !"".equals(sortColumn)) {
            col = Integer.parseInt(sortColumn);
        }
        SortableTableModel resultTable = null;
        boolean tagSearch = false;
        String feedURL = "/controller/results/feed";
        if (tag != null && !"".equals(tag)) {
            tag = tag.trim();
            if (tag.length() > 0) {
View Full Code Here


        String viewAll = req.getParameter("viewAll");
        String viewMy = req.getParameter("viewMy");
        if (sortColumn != null && !"".equals(sortColumn)) {
            col = Integer.parseInt(sortColumn);
        }
        SortableTableModel targetTable = null;
        boolean targetSearch = false;
        if (target != null && !"".equals(target)) {
            target = target.trim();
            if (target.length() > 0) {
                targetSearch = true;
View Full Code Here

        UserEnv usrEnv = (UserEnv) session.getAttribute("usrEnv");
        if (usrEnv == null) {
            usrEnv = new UserEnv();
            session.setAttribute("usrEnv", usrEnv);
        }
        SortableTableModel resultTable = RunResult.getResultTable(usrEnv.getSubject(), 5, "DESCENDING");
        String feedURL = "/controller/results/feed";
        request.setAttribute("feedURL", feedURL );
        request.setAttribute("table.model", resultTable);
        return "/resultlist.jsp";
View Full Code Here

    static SortableTableModel generateTargetTable(List<Target> targets, int column,
            String sortDirection) {

        // 1. Generate table header
        SortableTableModel table = new SortableTableModel(9);

        String sort = "<img src=/img/sort_asc.gif></img>";
        if(sortDirection.equals("DESCENDING")){
             sort = "<img src=\"/img/sort_asc.gif\" border=\"0\"></img>";
        }else if(sortDirection.equals("ASCENDING")){
             sort = "<img src=\"/img/sort_desc.gif\" border=\"0\"></img>";
        }
        if(column == 0)
            table.setHeader(0, "Targets " + sort);
        else
            table.setHeader(0, "Targets");

        if(column == 1)
            table.setHeader(1, "Owner " + sort);
        else
            table.setHeader(1, "Owner");

        if(column == 2)
            table.setHeader(2, "Status " + sort);
        else
            table.setHeader(2, "Status");

        if(column == 3)
            table.setHeader(3, "Achieved Metric " + sort);
        else
            table.setHeader(3, "Achieved Metric");

        if(column == 4)
            table.setHeader(4, "Metric " + sort);
        else
            table.setHeader(4, "Metric");

        if(column == 5)
            table.setHeader(5, "Tags " + sort);
        else
            table.setHeader(5, "Tags");

        // 2. Generate table rows.
        for (Target target : targets) {
            //int idx = table.newRow();
            Comparable[] row = table.newRow();
            row[0] = target.name;
            row[1] = target.owner;
            row[2] = target.status;
            row[3] = target.achievedMetric+ " " + target.achievedMetricunit;
            row[4] = target.metric + " " + target.metricunit;
            row[5] = target.tags;
            row[6] = target.red;
            row[7] = target.orange;
            row[8] = target.yellow;
        }

        SortDirection enumValForDirection = SortDirection.valueOf(sortDirection);
        table.sort(column, enumValForDirection);
        return table;
    }
View Full Code Here

       
        if (result0 == null) // No rows!
            return null;

        // 2. Generate table header
        SortableTableModel table = new SortableTableModel(9);
        String sort = "<img src=/img/sort_asc.gif></img>";
        if(sortDirection.equals("DESCENDING")){
             sort = "<img src=\"/img/sort_asc.gif\" border=\"0\"></img>";
        }else if(sortDirection.equals("ASCENDING")){
             sort = "<img src=\"/img/sort_desc.gif\" border=\"0\"></img>";
        }
        if(column == 0)
            table.setHeader(0, "RunID " + sort);
        else
            table.setHeader(0, "RunID");

        if(column == 1)
            table.setHeader(1, "Description " + sort);
        else
            table.setHeader(1, "Description");

        if(column == 2)
            table.setHeader(2, "Result " + sort);
        else
            table.setHeader(2, "Result");

        boolean singleScale = false;
        if (scaleNames.size() == 1 && scaleUnits.size() == 1) {
            singleScale = true;
            if (result0.scaleName.length() > 0 &&
                    result0.scaleUnit.length() > 0){
                table.setHeader(3, result0.scaleName + " (" +
                        result0.scaleUnit + ')');
            }else if (result0.scaleName.length() > 0){
                table.setHeader(3, result0.scaleName);
            }else if (result0.scaleUnit.length() > 0){
                table.setHeader(3, result0.scaleUnit);
            }else{
                if(column == 3)
                    table.setHeader(3, "Scale " + sort);
                else
                    table.setHeader(3, "Scale");
            }

        } else {
            if(column == 3)
                table.setHeader(3, "Scale " + sort);
            else
                table.setHeader(3, "Scale");
        }

        boolean singleMetric = false;
        if (metricUnits.size() == 1) {
            singleMetric = true;
            if (result0.metricUnit.length() > 0){
                table.setHeader(4, result0.metricUnit);
            }else{
                if(column == 4)
                    table.setHeader(4, "Metric " + sort);
                else
                    table.setHeader(4, "Metric");
            }
        } else {
            if(column == 4)
                table.setHeader(4, "Metric " + sort);
            else
                table.setHeader(4, "Metric");
        }

        //table.setHeader(5, "Status");
        if(column == 5)
            table.setHeader(5, "Date/Time " + sort);
        else
            table.setHeader(5, "Date/Time");

        if(column == 6)
            table.setHeader(6, "Submitter " + sort);
        else
            table.setHeader(6, "Submitter");

        if(column == 7)
            table.setHeader(7, "Tags " + sort);
        else
            table.setHeader(7, "Tags");

        // Pseudo-column for the link.
        table.setHeader(8, "Link");

        // 3. Generate table rows.
        StringBuilder b = new StringBuilder();
        // The output format.
        SimpleDateFormat dateFormat = (SimpleDateFormat) dateFormatOrig.clone();
        for (RunResult result : runs) {
            //int idx = table.newRow();
            Comparable[] row = table.newRow();
            row[0] = result.runId;
            if (result.description == null || result.description.length() == 0)
                row[1] = "UNAVAILABLE";
            else
                row[1] = result.description;

            row[8] = ""; // Initialize the link to zero string in case it does not get set.
            ResultField<String> r = new ResultField<String>();
            if (result.result != null) {
                r.value = result.result;
                if (result.resultLink != null){
                    if(result.result.equals("PASSED"))
                        r.text = "<img onmouseover=\"showtip('" + result.result.toString() + "')\" onmouseout=\"hideddrivetip()\" class=\"icon\"; src='/img/passed.png'></img>";
                    else if(result.result.equals("FAILED"))
                        r.text = "<img onmouseover=\"showtip('" + result.result.toString() + "')\" onmouseout=\"hideddrivetip()\" class=\"icon\"; src='/img/failed.png'></img>";
                    row[8] = result.resultLink;
                }
            } else if (result.status != null) {
                r.value = result.status;
                if (result.logLink != null){
                    if(result.status.equals("FAILED"))
                        r.text = "<img onmouseover=\"showtip('" + result.status.toString() + "')\" onmouseout=\"hideddrivetip()\" class=\"icon\"; src='/img/incomplete.png'></img>";
                    else if(result.status.equals("KILLED"))
                        r.text = "<img onmouseover=\"showtip('" + result.status.toString() + "')\" onmouseout=\"hideddrivetip()\" class=\"icon\"; src='/img/killed.png'></img>";
                    else if(result.status.equals("RECEIVED"))
                        r.text = "<img onmouseover=\"showtip('" + result.status.toString() + "')\" onmouseout=\"hideddrivetip()\" class=\"icon\"; src='/img/received.png'></img>";
                    else if(result.status.equals("STARTED"))
                        r.text = "<img onmouseover=\"showtip('" + result.status.toString() + "')\" onmouseout=\"hideddrivetip()\" class=\"icon\"; src='/img/running.png'></img>";
                    else if(result.status.equals("COMPLETED"))
                        r.text = "<img onmouseover=\"showtip('" + result.status.toString() + "')\" onmouseout=\"hideddrivetip()\" class=\"icon\"; src='/img/failed.png'></img>";
                    else if(result.status.equals("UNKNOWN"))
                        r.text = "<img onmouseover=\"showtip('unknown')\" onmouseout=\"hideddrivetip()\" class=\"icon\"; src='/img/unknown.png'></img>";
                    row[8] = result.logLink;
                }
            } else {
                r.value = NOT_AVAILABLE;
                r.text = "<img onmouseover=\"showtip('unknown')\" onmouseout=\"hideddrivetip()\" class=\"icon\"; src='/img/unknown.png'></img>";
            }
            row[2] = r;

            ResultField<Integer> scale = new ResultField<Integer>();
            if (result.scale == null || result.scale.length() < 1) {
                scale.text = "N/A";
                scale.value = Integer.MIN_VALUE;
            } else if (singleScale) {
                scale.text = result.scale;
                scale.value = new Integer(result.scale);
            } else {
                b.append(result.scale);
                if (result.scaleName.length() > 0)
                    b.append(' ').append(result.scaleName).append(' ');
                if (result.scaleUnit.length() > 0)
                    b.append(' ').append(result.scaleUnit);
                scale.text = b.toString();
                scale.value = new Integer(result.scale);
                b.setLength(0);
            }
            row[3] = scale;


            ResultField<Double> metric = new ResultField<Double>();
            if (result.metric.text == null) {
                metric.text = "N/A";
                metric.value = -1d;
            } else if (singleMetric) {
                metric.text = result.metric.text;
                metric.value = result.metric.value;
            } else {
                b.append(result.metric);
                if (result.metricUnit.length() > 0)
                    b.append(' ').append(result.metricUnit);
                metric.text = b.toString();
                metric.value = result.metric.value;
                b.setLength(0);
            }
            row[4] = metric;

            /*ResultField<String> status = new ResultField<String>();
            if (result.status != null) {
                status.value = result.status;
                if (result.logLink != null)
                    status.text = "<a href=\""+ result.logLink + "\">" +
                            result.status + "</a>";
                else
                    status.text = result.status;
            } else {
                status.value = NOT_AVAILABLE;
                status.text = "UNKNOWN";
            }
            row[5] = status;*/

            ResultField<Long> dateTime = new ResultField<Long>();
            if (result.dateTime != null) {
                dateTime.text = dateFormat.format(result.dateTime);
                dateTime.value = result.dateTime.getTime();
            } else {
                dateTime.text = "N/A";
                dateTime.value = 0l;
            }
            row[5] = dateTime;

            if (result.submitter != null)
                row[6] = result.submitter;
            else
                row[6] = "&nbsp;";


            if (result.tags != null && result.tags.length > 0) {
                for (String tag : result.tags) {
                    b.append(tag).append(' ');
                }
                b.setLength(b.length() - 1);
                row[7] = b.toString();
                b.setLength(0);
            } else {
                row[7] = "&nbsp;";
            }
        }

        SortDirection enumValForDirection = SortDirection.valueOf(sortDirection);
        table.sort(column, enumValForDirection);
        return table;
    }
View Full Code Here

TOP

Related Classes of com.sun.faban.common.SortableTableModel

Copyright © 2018 www.massapicom. 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.