Example usage for org.apache.poi.ss.usermodel IndexedColors CORNFLOWER_BLUE

List of usage examples for org.apache.poi.ss.usermodel IndexedColors CORNFLOWER_BLUE

Introduction

In this page you can find the example usage for org.apache.poi.ss.usermodel IndexedColors CORNFLOWER_BLUE.

Prototype

IndexedColors CORNFLOWER_BLUE

To view the source code for org.apache.poi.ss.usermodel IndexedColors CORNFLOWER_BLUE.

Click Source Link

Usage

From source file:com.mycompany.excelreadandwrite.WritetoExcel.java

public void writeSongsListToExcel(List<Song> songList) {

    /*/*from   ww  w .ja  v a  2s .  com*/
    Use XSSF for xlsx format and for xls use HSSF
    */
    Workbook workbook = new XSSFWorkbook();

    /*
    create new sheet 
    */
    Sheet songsSheet = workbook.createSheet("Albums");

    XSSFCellStyle my_style = (XSSFCellStyle) workbook.createCellStyle();
    /* Create XSSFFont object from the workbook */
    XSSFFont my_font = (XSSFFont) workbook.createFont();

    /*
    setting cell color
    */
    CellStyle style = workbook.createCellStyle();
    style.setFillForegroundColor(IndexedColors.LEMON_CHIFFON.getIndex());
    style.setFillPattern(CellStyle.SOLID_FOREGROUND);

    /*
     setting Header color
    */
    CellStyle style2 = workbook.createCellStyle();
    style2.setFillForegroundColor(IndexedColors.DARK_RED.getIndex());
    style2.setFillPattern(CellStyle.SOLID_FOREGROUND);

    Row rowName = songsSheet.createRow(1);

    /*
    Merging the cells
    */
    songsSheet.addMergedRegion(new CellRangeAddress(1, 1, 2, 3));

    /*
    Applying style to attribute name
    */
    int nameCellIndex = 1;
    Cell namecell = rowName.createCell(nameCellIndex++);
    namecell.setCellValue("Name");
    namecell.setCellStyle(style);

    Cell cel = rowName.createCell(nameCellIndex++);
    cel.setCellValue("Lastname, Firstname");

    /*
    Applying underline to Name
    */
    my_font.setUnderline(XSSFFont.U_SINGLE);
    my_style.setFont(my_font);
    /* Attaching the style to the cell */
    CellStyle combined = workbook.createCellStyle();
    combined.cloneStyleFrom(my_style);
    combined.cloneStyleFrom(style);
    cel.setCellStyle(combined);

    /*
    Applying  colors to header 
    */

    Row rowMain = songsSheet.createRow(3);
    SheetConditionalFormatting sheetCF = songsSheet.getSheetConditionalFormatting();
    ConditionalFormattingRule rule1 = sheetCF.createConditionalFormattingRule("3");
    PatternFormatting fill1 = rule1.createPatternFormatting();
    fill1.setFillBackgroundColor(IndexedColors.CORNFLOWER_BLUE.index);
    fill1.setFillPattern(PatternFormatting.SOLID_FOREGROUND);

    CellRangeAddress[] regions = { CellRangeAddress.valueOf("A4:G4") };

    sheetCF.addConditionalFormatting(regions, rule1);

    /*
    setting new rule to apply alternate colors to cells having same Genre
    */
    ConditionalFormattingRule rule2 = sheetCF.createConditionalFormattingRule("4");
    PatternFormatting fill2 = rule2.createPatternFormatting();
    fill2.setFillBackgroundColor(IndexedColors.LEMON_CHIFFON.index);
    fill2.setFillPattern(PatternFormatting.SOLID_FOREGROUND);

    CellRangeAddress[] regionsAction = { CellRangeAddress.valueOf("A5:G5"), CellRangeAddress.valueOf("A6:G6"),
            CellRangeAddress.valueOf("A7:G7"), CellRangeAddress.valueOf("A8:G8"),
            CellRangeAddress.valueOf("A13:G13"), CellRangeAddress.valueOf("A14:G14"),
            CellRangeAddress.valueOf("A15:G15"), CellRangeAddress.valueOf("A16:G16"),
            CellRangeAddress.valueOf("A23:G23"), CellRangeAddress.valueOf("A24:G24"),
            CellRangeAddress.valueOf("A25:G25"), CellRangeAddress.valueOf("A26:G26")

    };

    /*        
    setting new rule to apply alternate colors to cells having same Genre
     */
    ConditionalFormattingRule rule3 = sheetCF.createConditionalFormattingRule("4");
    PatternFormatting fill3 = rule3.createPatternFormatting();
    fill3.setFillBackgroundColor(IndexedColors.LIGHT_CORNFLOWER_BLUE.index);
    fill3.setFillPattern(PatternFormatting.SOLID_FOREGROUND);

    CellRangeAddress[] regionsAdv = { CellRangeAddress.valueOf("A9:G9"), CellRangeAddress.valueOf("A10:G10"),
            CellRangeAddress.valueOf("A11:G11"), CellRangeAddress.valueOf("A12:G12"),
            CellRangeAddress.valueOf("A17:G17"), CellRangeAddress.valueOf("A18:G18"),
            CellRangeAddress.valueOf("A19:G19"), CellRangeAddress.valueOf("A20:G20"),
            CellRangeAddress.valueOf("A21:G21"), CellRangeAddress.valueOf("A22:G22"),
            CellRangeAddress.valueOf("A27:G27"), CellRangeAddress.valueOf("A28:G28"),
            CellRangeAddress.valueOf("A29:G29") };

    /*
    Applying above created rule formatting to cells
    */
    sheetCF.addConditionalFormatting(regionsAction, rule2);
    sheetCF.addConditionalFormatting(regionsAdv, rule3);

    /*
     Setting coloumn header values
    */
    int mainCellIndex = 0;

    rowMain.createCell(mainCellIndex++).setCellValue("SNO");
    rowMain.createCell(mainCellIndex++).setCellValue("Genre");
    rowMain.createCell(mainCellIndex++).setCellValue("Rating");
    rowMain.createCell(mainCellIndex++).setCellValue("Movie Name");
    rowMain.createCell(mainCellIndex++).setCellValue("Director");
    rowMain.createCell(mainCellIndex++).setCellValue("Release Date");
    rowMain.createCell(mainCellIndex++).setCellValue("Budget");

    /*
    populating cell values
    */
    int rowIndex = 4;
    int sno = 1;
    for (Song song : songList) {
        if (song.getSno() != 0) {

            Row row = songsSheet.createRow(rowIndex++);
            int cellIndex = 0;

            /*
            first place in row is Sno
            */
            row.createCell(cellIndex++).setCellValue(sno++);

            /*
            second place in row is  Genre
            */
            row.createCell(cellIndex++).setCellValue(song.getGenre());

            /*
            third place in row is Critic score
            */
            row.createCell(cellIndex++).setCellValue(song.getCriticscore());

            /*
            fourth place in row is Album name
            */
            row.createCell(cellIndex++).setCellValue(song.getAlbumname());

            /*
            fifth place in row is Artist
            */
            row.createCell(cellIndex++).setCellValue(song.getArtist());

            /*
            sixth place in row is marks in date
            */
            if (song.getReleasedate() != null) {

                Cell date = row.createCell(cellIndex++);

                DataFormat format = workbook.createDataFormat();
                CellStyle dateStyle = workbook.createCellStyle();
                dateStyle.setDataFormat(format.getFormat("dd-MMM-yyyy"));
                date.setCellStyle(dateStyle);

                date.setCellValue(song.getReleasedate());

                /*
                auto-resizing columns
                */
                songsSheet.autoSizeColumn(6);
                songsSheet.autoSizeColumn(5);
                songsSheet.autoSizeColumn(4);
                songsSheet.autoSizeColumn(3);
                songsSheet.autoSizeColumn(2);
            }

        }
    }

    /*
    writing this workbook to excel file.
    */
    try {
        FileOutputStream fos = new FileOutputStream(FILE_PATH);
        workbook.write(fos);
        fos.close();

        System.out.println(FILE_PATH + " is successfully written");
    } catch (FileNotFoundException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }

}

From source file:org.alanwilliamson.openbd.plugin.spreadsheet.SpreadSheetFormatOptions.java

License:Open Source License

public static void initialize() {
    lookup_colors = new HashMap<String, Short>();
    lookup_alignment = new HashMap<String, Short>();
    lookup_border = new HashMap<String, Short>();
    lookup_fillpatten = new HashMap<String, Short>();
    lookup_underline = new HashMap<String, Byte>();
    lookup_color = new HashMap<String, Color>();

    lookup_underline.put("double", Font.U_DOUBLE);
    lookup_underline.put("double_accounting", Font.U_DOUBLE_ACCOUNTING);
    lookup_underline.put("single", Font.U_SINGLE);
    lookup_underline.put("single_accounting", Font.U_SINGLE_ACCOUNTING);
    lookup_underline.put("none", Font.U_NONE);

    lookup_colors.put("black", IndexedColors.BLACK.getIndex());
    lookup_colors.put("brown", IndexedColors.BROWN.getIndex());
    lookup_colors.put("olive_green", IndexedColors.OLIVE_GREEN.getIndex());
    lookup_colors.put("dark_green", IndexedColors.DARK_GREEN.getIndex());
    lookup_colors.put("dark_teal", IndexedColors.DARK_TEAL.getIndex());
    lookup_colors.put("dark_blue", IndexedColors.DARK_BLUE.getIndex());
    lookup_colors.put("indigo", IndexedColors.INDIGO.getIndex());
    lookup_colors.put("grey_80_percent", IndexedColors.GREY_80_PERCENT.getIndex());
    lookup_colors.put("grey_50_percent", IndexedColors.GREY_50_PERCENT.getIndex());
    lookup_colors.put("grey_40_percent", IndexedColors.GREY_40_PERCENT.getIndex());
    lookup_colors.put("grey_25_percent", IndexedColors.GREY_25_PERCENT.getIndex());
    lookup_colors.put("orange", IndexedColors.ORANGE.getIndex());
    lookup_colors.put("dark_yellow", IndexedColors.DARK_YELLOW.getIndex());
    lookup_colors.put("green", IndexedColors.GREEN.getIndex());
    lookup_colors.put("teal", IndexedColors.TEAL.getIndex());
    lookup_colors.put("blue", IndexedColors.BLUE.getIndex());
    lookup_colors.put("blue_grey", IndexedColors.BLUE_GREY.getIndex());
    lookup_colors.put("red", IndexedColors.RED.getIndex());
    lookup_colors.put("light_orange", IndexedColors.LIGHT_ORANGE.getIndex());
    lookup_colors.put("lime", IndexedColors.LIME.getIndex());
    lookup_colors.put("sea_green", IndexedColors.SEA_GREEN.getIndex());
    lookup_colors.put("aqua", IndexedColors.AQUA.getIndex());
    lookup_colors.put("light_blue", IndexedColors.LIGHT_BLUE.getIndex());
    lookup_colors.put("violet", IndexedColors.VIOLET.getIndex());
    lookup_colors.put("pink", IndexedColors.PINK.getIndex());
    lookup_colors.put("gold", IndexedColors.GOLD.getIndex());
    lookup_colors.put("yellow", IndexedColors.YELLOW.getIndex());
    lookup_colors.put("bright_green", IndexedColors.BRIGHT_GREEN.getIndex());
    lookup_colors.put("turquoise", IndexedColors.TURQUOISE.getIndex());
    lookup_colors.put("dark_red", IndexedColors.DARK_RED.getIndex());
    lookup_colors.put("sky_blue", IndexedColors.SKY_BLUE.getIndex());
    lookup_colors.put("plum", IndexedColors.PLUM.getIndex());
    lookup_colors.put("rose", IndexedColors.ROSE.getIndex());
    lookup_colors.put("light_yellow", IndexedColors.LIGHT_YELLOW.getIndex());
    lookup_colors.put("light_green", IndexedColors.LIGHT_GREEN.getIndex());
    lookup_colors.put("light_turquoise", IndexedColors.LIGHT_TURQUOISE.getIndex());
    lookup_colors.put("pale_blue", IndexedColors.PALE_BLUE.getIndex());
    lookup_colors.put("lavender", IndexedColors.LAVENDER.getIndex());
    lookup_colors.put("white", IndexedColors.WHITE.getIndex());
    lookup_colors.put("cornflower_blue", IndexedColors.CORNFLOWER_BLUE.getIndex());
    lookup_colors.put("lemon_chiffon", IndexedColors.LEMON_CHIFFON.getIndex());
    lookup_colors.put("maroon", IndexedColors.MAROON.getIndex());
    lookup_colors.put("orchid", IndexedColors.ORCHID.getIndex());
    lookup_colors.put("coral", IndexedColors.CORAL.getIndex());
    lookup_colors.put("royal_blue", IndexedColors.ROYAL_BLUE.getIndex());
    lookup_colors.put("light_cornflower_blue", IndexedColors.LIGHT_CORNFLOWER_BLUE.getIndex());

    lookup_alignment.put("left", CellStyle.ALIGN_LEFT);
    lookup_alignment.put("right", CellStyle.ALIGN_RIGHT);
    lookup_alignment.put("center", CellStyle.ALIGN_CENTER);
    lookup_alignment.put("justify", CellStyle.ALIGN_JUSTIFY);
    lookup_alignment.put("general", CellStyle.ALIGN_GENERAL);
    lookup_alignment.put("fill", CellStyle.ALIGN_FILL);
    lookup_alignment.put("center_selection", CellStyle.ALIGN_CENTER_SELECTION);
    lookup_alignment.put("vertical_top", CellStyle.VERTICAL_TOP);
    lookup_alignment.put("vertical_bottom", CellStyle.VERTICAL_BOTTOM);
    lookup_alignment.put("vertical_center", CellStyle.VERTICAL_CENTER);
    lookup_alignment.put("vertical_justify", CellStyle.VERTICAL_JUSTIFY);

    lookup_border.put("none", CellStyle.BORDER_NONE);
    lookup_border.put("thin", CellStyle.BORDER_THIN);
    lookup_border.put("medium", CellStyle.BORDER_MEDIUM);
    lookup_border.put("dashed", CellStyle.BORDER_DASHED);
    lookup_border.put("hair", CellStyle.BORDER_HAIR);
    lookup_border.put("thick", CellStyle.BORDER_THICK);
    lookup_border.put("double", CellStyle.BORDER_DOUBLE);
    lookup_border.put("dotted", CellStyle.BORDER_DOTTED);
    lookup_border.put("medium_dashed", CellStyle.BORDER_MEDIUM_DASHED);
    lookup_border.put("dash_dot", CellStyle.BORDER_DASH_DOT);
    lookup_border.put("medium_dash_dot", CellStyle.BORDER_MEDIUM_DASH_DOT);
    lookup_border.put("dash_dot_dot", CellStyle.BORDER_DASH_DOT_DOT);
    lookup_border.put("medium_dash_dot_dot", CellStyle.BORDER_MEDIUM_DASH_DOT_DOT);
    lookup_border.put("slanted_dash_dot", CellStyle.BORDER_SLANTED_DASH_DOT);

    lookup_fillpatten.put("big_spots", CellStyle.BIG_SPOTS);
    lookup_fillpatten.put("squares", CellStyle.SQUARES);
    lookup_fillpatten.put("nofill", CellStyle.NO_FILL);
    lookup_fillpatten.put("solid_foreground", CellStyle.SOLID_FOREGROUND);
    lookup_fillpatten.put("fine_dots", CellStyle.FINE_DOTS);
    lookup_fillpatten.put("alt_bars", CellStyle.ALT_BARS);
    lookup_fillpatten.put("sparse_dots", CellStyle.SPARSE_DOTS);
    lookup_fillpatten.put("thick_horz_bands", CellStyle.THICK_HORZ_BANDS);
    lookup_fillpatten.put("thick_vert_bands", CellStyle.THICK_VERT_BANDS);
    lookup_fillpatten.put("thick_backward_diag", CellStyle.THICK_BACKWARD_DIAG);
    lookup_fillpatten.put("thick_forward_diag", CellStyle.THICK_FORWARD_DIAG);
    lookup_fillpatten.put("thin_horz_bands", CellStyle.THIN_HORZ_BANDS);
    lookup_fillpatten.put("thin_vert_bands", CellStyle.THIN_VERT_BANDS);
    lookup_fillpatten.put("thin_backward_diag", CellStyle.THIN_BACKWARD_DIAG);
    lookup_fillpatten.put("thin_forward_diag", CellStyle.THIN_FORWARD_DIAG);
    lookup_fillpatten.put("diamonds", CellStyle.DIAMONDS);
    lookup_fillpatten.put("less_dots", CellStyle.LESS_DOTS);
    lookup_fillpatten.put("least_dots", CellStyle.LEAST_DOTS);

    lookup_color.put("black", Color.BLACK);
    lookup_color.put("blue", Color.BLUE);
    lookup_color.put("cyan", Color.CYAN);
    lookup_color.put("dark_gray", Color.DARK_GRAY);
    lookup_color.put("darkGray", Color.DARK_GRAY);
    lookup_color.put("gray", Color.GRAY);
    lookup_color.put("green", Color.GREEN);
    lookup_color.put("light_gray", Color.LIGHT_GRAY);
    lookup_color.put("lightGray", Color.LIGHT_GRAY);
    lookup_color.put("magenta", Color.MAGENTA);
    lookup_color.put("orange", Color.ORANGE);
    lookup_color.put("pink", Color.PINK);
    lookup_color.put("red", Color.RED);
    lookup_color.put("white", Color.WHITE);
    lookup_color.put("yellow", Color.YELLOW);
}

From source file:org.jcvi.ometa.utils.JsonProducer.java

License:Open Source License

public void jsonHelper(String projectNames, String attributes, String screenAttributes, String sorting,
        String fileName, String filePath, String domain) {
    String PROJECT_STATUS = "Project Status";
    try {//from w w w .j  av  a 2s .c om
        JSONObject json = new JSONObject();

        File directory = new File(filePath);
        if (!directory.exists() || !directory.isDirectory()) {
            if ((new File(directory.getParent())).canWrite())
                directory.mkdir();
            else
                throw new Exception();
        }
        //Json file Creation
        File tempFile = new File(filePath + File.separator + fileName + "_temp.json");
        FileWriter fileWriter = new FileWriter(tempFile);
        BufferedWriter bufferedWriter = new BufferedWriter(fileWriter);

        //Normal status data retrieval
        LookupValue tempLookupValue;

        List<String> projectNameList = new ArrayList<String>();
        if (projectNames.contains(","))
            projectNameList.addAll(Arrays.asList(projectNames.split(",")));
        else
            projectNameList.add(projectNames);

        List<String> availableAttributes = new ArrayList<String>();
        availableAttributes.add("Sample Name");

        List<Project> projects = pseEjb.getProjects(projectNameList);
        List<Long> projectIds = new ArrayList<Long>();
        Map<String, Long> projectNameVsId = new HashMap<String, Long>();
        for (Project project : projects) {
            projectIds.add(project.getProjectId());
            projectNameVsId.put(project.getProjectName(), project.getProjectId());
        }

        List<ProjectMetaAttribute> allProjectMetaAttributes = pseEjb.getProjectMetaAttributes(projectIds);
        for (ProjectMetaAttribute pma : allProjectMetaAttributes) {
            if (!availableAttributes.contains(pma.getLookupValue().getName()))
                availableAttributes.add(pma.getLookupValue().getName());
        }
        List<SampleMetaAttribute> allSampleMetaAttributes = pseEjb.getSampleMetaAttributes(projectIds);
        for (SampleMetaAttribute sma : allSampleMetaAttributes) {
            if (!availableAttributes.contains(sma.getLookupValue().getName()))
                availableAttributes.add(sma.getLookupValue().getName());
        }
        List<EventMetaAttribute> allEventMetaAttributes = pseEjb.getEventMetaAttributes(projectIds);
        for (EventMetaAttribute ema : allEventMetaAttributes) {
            if (!availableAttributes.contains(ema.getLookupValue().getName()))
                availableAttributes.add(ema.getLookupValue().getName());
        }

        List<String> parameterizedAttributes = null;
        if (attributes == null || attributes.equals("") || "ALL".equals(attributes)) {
            parameterizedAttributes = availableAttributes;
        } else {
            parameterizedAttributes = new ArrayList<String>();

            ArrayList<String> tokenizedAttribute = new ArrayList<String>(Arrays.asList(attributes.split(",")));

            for (String tempAttribute : tokenizedAttribute) {
                if (availableAttributes.contains(tempAttribute))
                    parameterizedAttributes.add(tempAttribute);
            }
        }
        parameterizedAttributes.removeAll(Arrays.asList(forbiddenAttributes));

        /*------------ XLS Part ------------*/
        //Excel file Creation
        Workbook workBook = new HSSFWorkbook();
        Sheet workSheet = workBook.createSheet();
        int cellIndex = 0, rowIndex = 0;
        Row singleRow = workSheet.createRow(rowIndex++);
        Cell headerCell = null;

        //Header row cell style
        CellStyle style = workBook.createCellStyle();
        style.setFillBackgroundColor(IndexedColors.CORNFLOWER_BLUE.getIndex());
        style.setFillForegroundColor(IndexedColors.LIGHT_BLUE.getIndex());
        style.setFillPattern(CellStyle.SOLID_FOREGROUND);
        Font font = workBook.createFont();
        font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
        font.setColor(IndexedColors.WHITE.getIndex());
        style.setFont(font);
        /*------------ XLS Part END ------------*/

        List<String> attributeList = new ArrayList<String>();

        for (String tempAttribute : parameterizedAttributes) {
            attributeList.add(tempAttribute);
            headerCell = singleRow.createCell(cellIndex++);
            headerCell.setCellValue(tempAttribute);
            headerCell.setCellStyle(style);
        }

        if (screenAttributes == null || screenAttributes.equals("") || screenAttributes.equals("ALL")) {
            json.put("attributes", attributeList);
        } else {
            json.put("attributes", Arrays.asList(screenAttributes.split(",")));
        }

        json.put("sorting", (sorting == null || sorting.isEmpty() || sorting.equals("-") ? null : sorting));
        json.put("projectNames", projectNames);

        List<ProjectAttribute> allProjectAttributes = pseEjb.getProjectAttributes(projectIds);
        Map<Long, List<ProjectAttribute>> projIdVsAttributes = new HashMap<Long, List<ProjectAttribute>>();
        for (ProjectAttribute pa : allProjectAttributes) {
            List<ProjectAttribute> paList = projIdVsAttributes.get(pa.getProjectId());
            if (paList == null) {
                paList = new ArrayList<ProjectAttribute>();
                projIdVsAttributes.put(pa.getProjectId(), paList);
            }
            paList.add(pa);
        }

        List<Sample> allSamplesAllProjects = pseEjb.getSamplesForProjects(projectIds);
        Map<Long, List<Sample>> projectIdVsSampleList = new HashMap<Long, List<Sample>>();
        for (Sample sample : allSamplesAllProjects) {
            List<Sample> thisProjectsSamples = projectIdVsSampleList.get(sample.getProjectId());
            if (thisProjectsSamples == null) {
                thisProjectsSamples = new ArrayList<Sample>();
                projectIdVsSampleList.put(sample.getProjectId(), thisProjectsSamples);
            }
            thisProjectsSamples.add(sample);
        }

        /************* Main LOOP starts *****************/
        List<JSONObject> sampleList = new ArrayList<JSONObject>();
        List<String> statusList = new ArrayList<String>();
        List<JSONObject> sumList = new ArrayList<JSONObject>();

        for (Project project : projects) {
            JSONObject currSum = new JSONObject();

            if (project.getIsPublic() == 0)
                continue;

            Long tempProjectId = project.getProjectId();
            List<ProjectAttribute> paList = projIdVsAttributes.get(tempProjectId);
            Map<String, Object> projectAttrMap = new HashMap<String, Object>();
            if (paList != null) {
                for (ProjectAttribute pa : paList) {
                    ProjectMetaAttribute projectMeta = pa.getMetaAttribute();
                    tempLookupValue = projectMeta.getLookupValue();
                    projectAttrMap.put(tempLookupValue.getName(),
                            ModelValidator.getModelValue(tempLookupValue, pa));

                    if (projectMeta.getLabel() != null) { //add another key-value pair for a labeled attribute
                        projectAttrMap.put(projectMeta.getLabel(),
                                ModelValidator.getModelValue(tempLookupValue, pa));
                    }
                }
            }

            if (!projectAttrMap.containsKey(Constants.ATTR_PROJECT_NAME))
                projectAttrMap.put(Constants.ATTR_PROJECT_NAME, project.getProjectName());

            currSum.put("p_n", project.getProjectName());
            currSum.put("p_s", projectAttrMap.get(PROJECT_STATUS));
            currSum.put("p_g", projectAttrMap.get("Project Group"));

            List<Long> sampleIdList = getSampleIdList(getSamplesFromList(projectIdVsSampleList, tempProjectId));
            Map<Long, List<SampleAttribute>> sampleIdVsAttributeList = getSampleVsAttributeList(sampleIdList);
            Map<Long, List<Event>> sampleIdVsEventList = getSampleIdVsEventList(sampleIdList);

            List<Sample> samplesForProject = getSamplesFromList(projectIdVsSampleList, tempProjectId);
            currSum.put("tot", samplesForProject.size());

            for (Sample sample : samplesForProject) {
                Map<String, Object> sampleAttrMap = new HashMap<String, Object>();
                sampleAttrMap.putAll(projectAttrMap);
                sampleAttrMap.put(Constants.ATTR_SAMPLE_NAME, sample.getSampleName());
                sampleAttrMap.put("sampleId", sample.getSampleId());

                List<SampleAttribute> sampleAttributes = sampleIdVsAttributeList.get(sample.getSampleId());
                if (sampleAttributes != null && sampleAttributes.size() > 0) {
                    for (SampleAttribute sa : sampleAttributes) {
                        if (sa.getMetaAttribute() == null)
                            continue;
                        SampleMetaAttribute sampleMeta = sa.getMetaAttribute();
                        tempLookupValue = sampleMeta.getLookupValue();
                        Object sav = ModelValidator.getModelValue(tempLookupValue, sa);
                        sampleAttrMap.put(tempLookupValue.getName(), sav);

                        if (sampleMeta.getLabel() != null) { //add another key-value pair for a labeled attribute
                            sampleAttrMap.put(sampleMeta.getLabel(), sav);
                        }

                        if (SAMPLE_STATUS.equals(tempLookupValue.getName())) {
                            String currStatus = (String) sav;
                            if (!statusList.contains(currStatus)) //add new status value
                                statusList.add(currStatus);
                            currSum.put(currStatus,
                                    currSum.has(currStatus) ? currSum.getInt(currStatus) + 1 : 1); //count
                        }

                    }
                }

                List<Event> sampleEvents = sampleIdVsEventList.get(sample.getSampleId());
                if (sampleEvents != null && sampleEvents.size() > 0) {
                    Map<Long, List<EventAttribute>> eventIdVsAttributes = getEventIdVsAttributeList(
                            sampleEvents, tempProjectId);
                    //skip sample status value in event attributes
                    String[] skipArrForEventAttribute = { "Sample Status" };

                    for (Event evt : sampleEvents) {
                        List<EventAttribute> eventAttributes = eventIdVsAttributes.get(evt.getEventId());
                        if (eventAttributes == null)
                            continue;

                        sampleAttrMap.putAll(CommonTool.getAttributeValueMap(eventAttributes, false,
                                skipArrForEventAttribute));
                    }
                }

                if (!sampleAttrMap.containsKey("Organism")) { //manually add Organism attribute if not exist for GCID projects
                    sampleAttrMap.put("Organism", "");
                }

                JSONObject sampleJsonObj = new JSONObject();
                for (String key : sampleAttrMap.keySet()) {
                    //this is custom decorating process for json data file only
                    //in status.shtml page, link on an organism should land to the project page rather than sample detail page
                    if (key.equals("Organism")) {
                        String organismVal = (String) sampleAttrMap.get(key);
                        if (organismVal == null) { //get different attribute value for GCID projects
                            organismVal = (String) sampleAttrMap.get("Species Source Common Name(CS4)");
                        }

                        sampleJsonObj.put("OrganismUrl", (PROD_SERVER_ADDRESS + Constants.SAMPLE_DETAIL_URL
                                + "iss=true" + "&projectName=" + project.getProjectName() + "&projectId="
                                + project.getProjectId() + "&sampleName=" + sampleAttrMap.get("Sample Name")
                                + "&sampleId=" + sampleAttrMap.get("sampleId")).replaceAll("\\\"", "\\\\\""));
                        if (domain != null && !"none".equals(domain)) {
                            String projectGroup = (String) sampleAttrMap.get("Project Group");
                            organismVal = convertIntoATag(String.format(Constants.PROJECT_SPECIFIC_PAGE, domain, //hostName != null && hostName.contains("spike") ? fileName + "-dev" : fileName,
                                    (projectGroup == null ? "" : projectGroup.toLowerCase()),
                                    project.getProjectName().replaceAll(" ", "_")), organismVal);
                        }
                        sampleJsonObj.put(key, organismVal);
                    } else {
                        sampleJsonObj.put(key, CommonTool.decorateAttribute(sampleAttrMap, key, project));
                    }
                }
                sampleList.add(sampleJsonObj);

                cellIndex = 0;
                singleRow = workSheet.createRow(rowIndex++);
                for (String tempAttribute : parameterizedAttributes) {
                    singleRow.createCell(cellIndex++)
                            .setCellValue(sampleAttrMap.get(tempAttribute) != null
                                    ? "" + sampleAttrMap.get(tempAttribute)
                                    : "");
                }
            }
            sumList.add(currSum);
        }

        JSONObject sumMap = new JSONObject();
        sumMap.put("s_l", statusList);
        sumMap.put("data", sumList);
        json.put("sums", sumMap);

        json.put("samples", sampleList);
        //bufferedWriter.write("]");
        bufferedWriter.write(json.toString());
        bufferedWriter.close();

        if (tempFile.exists() && tempFile.length() > 0) {
            File dataFile = new File(filePath + File.separator + fileName + ".json");
            tempFile.renameTo(dataFile);

            FileOutputStream fileOut = new FileOutputStream(filePath + File.separator + fileName + ".xls");
            workBook.write(fileOut);
            fileOut.close();
        } else
            throw new Exception("Failure in retrieving data for " + fileName
                    + ". File does not exist or file size is zero.");

        logger.info("[JsonProducer-MBean] JsonProducer process succeeded for " + projectNames);
    } catch (Exception ex) {
        logger.info("[JsonProducer-MBean] JsonProducer failed for " + projectNames);
        ex.printStackTrace();

        /*if( hostName.contains( "dmzweb" ) ) { //Send error notification for DMZs only
        new EmailSender().send(
                "json",
                "[PST]Failure in generating Json Data file on : " + hostName,
                ex.toString()
        );
        }*/
    }
}