Example usage for java.util Date toString

List of usage examples for java.util Date toString

Introduction

In this page you can find the example usage for java.util Date toString.

Prototype

public String toString() 

Source Link

Document

Converts this Date object to a String of the form:
 dow mon dd hh:mm:ss zzz yyyy
where:
  • dow is the day of the week ( Sun, Mon, Tue, Wed, Thu, Fri, Sat ).

    Usage

    From source file:com.xpn.xwiki.XWiki.java

    public String formatDate(Date date, String format, XWikiContext context) {
        if (date == null) {
            return "";
        }//  ww w.  ja va2 s. c o m
        String xformat = format;
        String defaultFormat = "yyyy/MM/dd HH:mm";
    
        if (format == null) {
            xformat = getXWikiPreference("dateformat", defaultFormat, context);
        }
    
        try {
            DateFormatSymbols formatSymbols = null;
            try {
                String language = getLanguagePreference(context);
                formatSymbols = new DateFormatSymbols(new Locale(language));
            } catch (Exception e2) {
                String language = getXWikiPreference("default_language", context);
                if ((language != null) && (!language.equals(""))) {
                    formatSymbols = new DateFormatSymbols(new Locale(language));
                }
            }
    
            SimpleDateFormat sdf;
            if (formatSymbols != null) {
                sdf = new SimpleDateFormat(xformat, formatSymbols);
            } else {
                sdf = new SimpleDateFormat(xformat);
            }
    
            try {
                sdf.setTimeZone(TimeZone.getTimeZone(getUserTimeZone(context)));
            } catch (Exception e) {
            }
    
            return sdf.format(date);
        } catch (Exception e) {
            LOGGER.info("Failed to format date [" + date + "] with pattern [" + xformat + "]: " + e.getMessage());
            if (format == null) {
                if (xformat.equals(defaultFormat)) {
                    return date.toString();
                } else {
                    return formatDate(date, defaultFormat, context);
                }
            } else {
                return formatDate(date, null, context);
            }
        }
    }
    

    From source file:edu.harvard.iq.dvn.core.web.subsetting.AnalysisPage.java

    public String dwnldAction() {
        dbgLog.fine("***** within dwnldAction() *****");
    
        resetMsgDwnldButton();//from  w  ww.  ja  v  a  2  s . co m
    
        if (checkDwnldParameters()) {
    
            FacesContext cntxt = FacesContext.getCurrentInstance();
    
            HttpServletResponse res = (HttpServletResponse) cntxt.getExternalContext().getResponse();
    
            HttpServletRequest req = (HttpServletRequest) cntxt.getExternalContext().getRequest();
    
            StudyFile sf = dataTable.getStudyFile();
    
            Long noRecords = dataTable.getRecordsPerCase();
    
            String dsbUrl = getDsbUrl();
            dbgLog.fine("dsbUrl=" + dsbUrl);
    
            String serverPrefix = req.getScheme() + "://" + req.getServerName() + ":" + req.getServerPort()
                    + req.getContextPath();
    
            dbgLog.fine("serverPrefix" + serverPrefix);
    
            Map<String, List<String>> mpl = new HashMap<String, List<String>>();
    
            // File inFile = new File(sf.getFileSystemLocation());
            // File origFile = new File(inFile.getParent(), "_" + sf.getFileSystemName());
    
            String formatType = (String) dwnldFileTypeSet.getValue();
            dbgLog.fine("file type from the binding=" + formatType);
            if (formatType == null) {
                formatType = dwnldFileTypeSelected;
                dbgLog.fine("file type from the value=" + dwnldFileTypeSelected);
            }
            mpl.put("dtdwnld", Arrays.asList(formatType));
    
            dbgLog.fine("citation info to be sent:\n" + getCitation());
    
            mpl.put("studytitle", Arrays.asList(getStudyTitle()));
            dbgLog.fine("studyId=" + getStudyId().toString());
            mpl.put("studyno", Arrays.asList(getStudyId().toString()));
            mpl.put("studyURL", Arrays.asList(studyURL));
    
            mpl.put("", Arrays.asList(""));
            mpl.put("browserType", Arrays.asList(browserType));
    
            mpl.put("recodedVarIdSet", getRecodedVarIdSet());
            mpl.put("recodedVarNameSet", getRecodedVarNameSet());
            mpl.put("recodedVarLabelSet", getRecodedVarLabelSet());
            mpl.put("recodedVarTypeSet", getRecodedVariableType());
            mpl.put("recodedVarBaseTypeSet", getBaseVariableTypeForRecodedVariable());
    
            mpl.put("baseVarIdSet", getBaseVarIdSetFromRecodedVarIdSet());
            mpl.put("baseVarNameSet", getBaseVarNameSetFromRecodedVarIdSet());
    
            mpl.put("requestType", Arrays.asList("Download"));
    
            // Added by Matt Owen to find a way to sneak in Metadata that is lost between Rdata -> Tab 
            mpl.put("originalFile", Arrays.asList(getOriginalFileSystemLocation().getAbsolutePath()));
    
            // -----------------------------------------------------
            // Processing route, step by step:
            // 
            // Step 0. Locate the data file and its attributes
    
            String fileId = sf.getId().toString();
    
            String fileloc = sf.getFileSystemLocation();
            String tabflnm = sf.getFileName();
            boolean sbstOK = sf.isSubsettable();
            String flct = sf.getFileType();
    
            // Output debug statements
            dbgLog.info("location=" + fileloc);
            dbgLog.info("filename=" + tabflnm);
            dbgLog.info("subsettable=" + sbstOK);
            dbgLog.info("filetype=" + flct);
            dbgLog.info("studyUrl = " + studyURL);
            dbgLog.info("original file asbolute path = " + getOriginalFileSystemLocation().getAbsolutePath());
    
            // D
            DvnRJobRequest sro = null;
    
            List<File> zipFileList = new ArrayList();
    
            File tmpsbfl = null;
    
            if (sbstOK) {
    
                try {
    
                    // this temp file will store the requested column(s):
                    tmpsbfl = File.createTempFile("tempsubsetfile.", ".tab");
                    deleteTempFileList.add(tmpsbfl);
    
                    // to produce this file, we'll either open the stream
                    // and run our local subsetting code on it, or request
                    // the subsetting to be performed natively by the access
                    // driver, if it supports the functionality:
    
                    // check whether a source file is tab-delimited or not
    
                    boolean fieldcut = true;
                    if ((noRecords != null) && (noRecords >= 1)) {
                        fieldcut = false;
                    }
    
                    DataAccessRequest daReq = new DataAccessRequest();
                    daReq.setParameter("noVarHeader", "1");
    
                    DataAccessObject accessObject = DataAccess.createDataAccessObject(sf, daReq);
    
                    if (accessObject.isSubsetSupported()) {
                        dbgLog.fine("Using NATIVE subset functionality of the repository.");
                        daReq.setParameter("vars", getVariableNamesForSubset());
    
                        accessObject.open();
    
                        InputStream inSubset = accessObject.getInputStream();
                        OutputStream outSubset = new BufferedOutputStream(
                                new FileOutputStream(tmpsbfl.getAbsolutePath()));
    
                        int bufsize = 8192;
                        byte[] subsetDataBuffer = new byte[bufsize];
                        while ((bufsize = inSubset.read(subsetDataBuffer)) != -1) {
                            outSubset.write(subsetDataBuffer, 0, bufsize);
                        }
    
                        inSubset.close();
                        outSubset.close();
    
                        // TODO: catch exceptions; reset the state of the page
                        // if anything went wrong. See the fixed-field section
                        // below for an example.
    
                    } else {
                        accessObject.open();
    
                        if (fieldcut) {
                            // Cutting requested fields of data from a TAB-delimited stream:
    
                            Set<Integer> fields = getFieldNumbersForSubsetting();
                            dbgLog.fine("subsetting fields=" + fields);
    
                            // Create an instance of DvnJavaFieldCutter
                            FieldCutter fc = new DvnJavaFieldCutter();
    
                            // Executes the subsetting request
                            fc.subsetFile(accessObject.getInputStream(), tmpsbfl.getAbsolutePath(), fields,
                                    dataTable.getCaseQuantity(), "\t");
    
                            // TODO: catch exceptions; reset the state of the page
                            // if anything went wrong. See the fixed-field section
                            // below for an example.
    
                        } else {
                            // Cutting requested columns of data from a fixed-field stream:
    
                            Map<Long, List<List<Integer>>> varMetaSet = getSubsettingMetaData(noRecords);
                            DvnNewJavaFieldCutter fc = new DvnNewJavaFieldCutter(varMetaSet);
    
                            try {
                                //fc.cutColumns(new File(cutOp1), noRecords.intValue(), 0, "\t", tmpsbfl.getAbsolutePath());
                                fc.cutColumns(accessObject.getInputStream(), noRecords.intValue(), 0, "\t",
                                        tmpsbfl.getAbsolutePath());
                            } catch (FileNotFoundException e) {
                                e.printStackTrace();
    
                                msgDwnldButton.setValue("* could not generate subset due to an IO problem");
                                msgDwnldButton.setVisible(true);
                                dbgLog.warning("exiting dwnldAction() due to an IO problem ");
                                getVDCRequestBean().setSelectedTab("tabDwnld");
                                dvnDSBTimerService.createTimer(deleteTempFileList, TEMP_FILE_LIFETIME);
                                return "";
    
                            } catch (RuntimeException re) {
                                re.printStackTrace();
    
                                msgDwnldButton.setValue("* could not generate subset due to an runtime error");
                                msgDwnldButton.setVisible(true);
                                dbgLog.warning("exiting dwnldAction() due to an runtime error");
                                getVDCRequestBean().setSelectedTab("tabDwnld");
                                dvnDSBTimerService.createTimer(deleteTempFileList, TEMP_FILE_LIFETIME);
                                return "";
    
                            }
    
                        }
                    }
    
                    // Checks the resulting subset file:
    
                    if (tmpsbfl.exists()) {
                        Long subsetFileSize = tmpsbfl.length();
                        dbgLog.fine("subset file:Length=" + subsetFileSize);
                        dbgLog.fine("subset file:name=" + tmpsbfl.getAbsolutePath());
    
                        if (subsetFileSize > 0) {
                            mpl.put("subsetFileName", Arrays.asList(tmpsbfl.getAbsolutePath()));
                            mpl.put("subsetDataFileName", Arrays.asList(tmpsbfl.getName()));
                        } else {
                            // subset file exists but it is empty
    
                            msgDwnldButton.setValue("* an subset file is empty");
                            msgDwnldButton.setVisible(true);
                            dbgLog.warning(
                                    "exiting dwnldAction() due to a subsetting error:" + "a subset file is empty");
                            getVDCRequestBean().setSelectedTab("tabDwnld");
                            dvnDSBTimerService.createTimer(deleteTempFileList, TEMP_FILE_LIFETIME);
                            return "";
    
                        }
                    } else {
                        // subset file was not created
                        msgDwnldButton.setValue("* a subset file was not created");
                        msgDwnldButton.setVisible(true);
                        dbgLog.warning("exiting dwnldAction() due to a subsetting error:"
                                + "a subset file was not created");
                        getVDCRequestBean().setSelectedTab("tabDwnld");
                        dvnDSBTimerService.createTimer(deleteTempFileList, TEMP_FILE_LIFETIME);
                        return "";
    
                    }
    
                    // If we've made it this far, we can increment the number of
                    // downloads for the study file:
    
                    VDC vdc = vdcService.getVDCFromRequest(req);
                    GuestBookResponse guestbookResponse = (GuestBookResponse) getVDCSessionBean()
                            .getGuestbookResponseMap().get("guestBookResponse_" + sf.getStudy().getId());
    
                    if (guestbookResponse == null) {
                        //need to set up dummy network response
                        guestbookResponse = guestBookResponseServiceBean.initNetworkGuestBookResponse(sf.getStudy(),
                                sf, getVDCSessionBean().getLoginBean());
                    }
                    guestbookResponse.setStudyVersion(sf.getStudy().getStudyVersionByNumber(versionNumber));
                    String jsessionId = null;
                    Cookie cookies[] = req.getCookies();
    
                    for (int i = 0; i < cookies.length; i++) {
                        if ("JSESSIONID".equals(cookies[i].getName())) {
                            jsessionId = cookies[i].getValue();
                        }
                    }
    
                    if (jsessionId == null || "".equals(jsessionId)) {
                        String[] stringArray = getVDCSessionBean().toString().split("@");
                        jsessionId = stringArray[1];
                    }
    
                    guestbookResponse.setSessionId(jsessionId);
    
                    String friendlyFormatName = "";
                    String formatRequestedMimeType = "";
    
                    if (formatType != null && !"".equals(formatType)) {
                        if (formatType.equals("D00")) {
                            formatRequestedMimeType = "text/tab-separated-values"; // tabular
                        } else if (formatType.equals("D01")) {
                            formatRequestedMimeType = "text/tab-separated-values"; // fixed-field
                        } else {
                            for (DataFileFormatType type : studyService.getDataFileFormatTypes()) {
                                if (formatType.equals(type.getValue())) {
                                    formatRequestedMimeType = type.getMimeType();
                                }
                            }
                        }
                    }
    
                    if (formatRequestedMimeType == null || "".equals(formatRequestedMimeType)) {
                        formatRequestedMimeType = "application/x-unknown";
                    }
    
                    friendlyFormatName = FileUtil.getUserFriendlyTypeForMime(formatRequestedMimeType);
                    guestbookResponse.setDownloadtype("Subsetting - " + friendlyFormatName);
    
                    if (vdc != null) {
                        studyService.incrementNumberOfDownloads(sf.getId(), vdc.getId(),
                                (GuestBookResponse) guestbookResponse);
                    } else {
                        studyService.incrementNumberOfDownloads(sf.getId(), (Long) null,
                                (GuestBookResponse) guestbookResponse);
                    }
    
                    // Step 3. Organizes parameters/metadata to be sent to the implemented
                    // data-analysis-service class
    
                    // skip the Rserve call completely (for plain tab file format, with no recoding)! -- L.A.
                    if (!formatType.equals("D01") || (recodeSchema.size() > 0)) {
    
                        Map<String, Map<String, String>> vls = getValueTablesForAllRequestedVariables();
    
                        // New (as of 3.6): support for ordered categorical variables 
                        // (ingested from R ordered factors). 
                        // Note that this is only being added here, i.e., to the 
                        // download-and-save part; if/when we make the analysis 
                        // and statistics utilize/handle these ordered categories 
                        // in some special way, we'll need to add the actual 
                        // ordered values to the SRO objects there as well. -- L.A. 
    
                        Map<String, List<String>> categoryOrders = getCategoryValueOrdersForAllRequestedVariables();
    
                        if (categoryOrders != null) {
                            sro = new DvnRJobRequest(getDataVariableForRequest(), mpl, vls, recodeSchema,
                                    categoryOrders, null);
                        } else {
                            sro = new DvnRJobRequest(getDataVariableForRequest(), mpl, vls, recodeSchema);
                        }
    
                        /*
                         * Add the recoded -> base variable name map; (new as of v3.6;)
                         * TODO: (?) do the same for the other action requests. 
                         *          -- L.A.
                         */
                        sro.setRecodedToBaseVar(getRecodedVarToBaseVarName());
    
                        // dbgLog.fine("sro dump:\n"+ToStringBuilder.reflectionToString(sro, ToStringStyle.MULTI_LINE_STYLE));
    
                        // Step 4. Creates an instance of the the implemented
                        // data-analysis-service class
    
                        DvnRDataAnalysisServiceImpl das = new DvnRDataAnalysisServiceImpl();
    
                        // Executes a download or data analysis request and
                        // stores the results in a Map <String, String>
    
                        resultInfo = das.execute(sro);
    
                        // Step 5. Check the exit status of the R process:
    
                        if (resultInfo.get("RexecError").equals("true")) {
    
                            msgDwnldButton.setValue("* The Request failed due to an R-runtime error");
                            msgDwnldButton.setVisible(true);
                            dbgLog.fine("exiting dwnldAction() due to an R-runtime error");
                            getVDCRequestBean().setSelectedTab("tabDwnld");
                            dvnDSBTimerService.createTimer(deleteTempFileList, TEMP_FILE_LIFETIME);
                            return "";
                        }
                    }
    
                    if (recodeSchema.size() > 0) {
                        resultInfo.put("subsettingCriteria", sro.getSubsetConditionsForCitation());
                    } else {
                        resultInfo.put("subsettingCriteria", "variables: " + getVariableNamesForSubset());
                    }
    
                } catch (MalformedURLException e) {
                    e.printStackTrace();
    
                    msgDwnldButton.setValue("* file URL is malformed");
                    msgDwnldButton.setVisible(true);
                    dbgLog.warning("exiting dwnldAction() due to a URL problem ");
                    getVDCRequestBean().setSelectedTab("tabDwnld");
    
                    return "";
    
                } catch (IOException e) {
                    // this may occur if the dataverse is not released,
                    // or if the file exists, but it is not accessible, etc.
                    e.printStackTrace();
    
                    msgDwnldButton.setValue("* an IO problem occurred");
                    msgDwnldButton.setVisible(true);
                    dbgLog.warning("exiting dwnldAction() due to an IO problem ");
                    getVDCRequestBean().setSelectedTab("tabDwnld");
    
                    return "";
                }
    
                // end of subset-OK case
            } else {
                // not subsettable data file
                msgDwnldButton.setValue("* this data file is not subsettable file");
                msgDwnldButton.setVisible(true);
                dbgLog.warning("exiting dwnldAction(): the data file is not subsettable ");
                getVDCRequestBean().setSelectedTab("tabDwnld");
                dvnDSBTimerService.createTimer(deleteTempFileList, TEMP_FILE_LIFETIME);
                return "";
    
            } // end:subsetNotOKcase
    
            // final processing steps for all successful cases
            // add study-metadata to the resultInfo map
    
            if (formatType.equals("D01") && !(recodeSchema.size() > 0)) {
                resultInfo.put("wbDataFileName", tmpsbfl.getAbsolutePath());
                // Fields that would normally be populated by R:
    
                resultInfo.put("PID", "N/A");
                resultInfo.put("R_min_verion_no", "N/A");
                resultInfo.put("dsbHost", "N/A");
                Date now = new Date();
                resultInfo.put("RexecDate", now.toString());
            } else {
                resultInfo.put("R_min_verion_no", resultInfo.get("Rversion").substring(2));
            }
    
            resultInfo.put("offlineCitation", getCitation());
            resultInfo.put("studyTitle", getStudyTitle());
            resultInfo.put("studyNo", getStudyId().toString());
            resultInfo.put("dtId", dtId.toString());
            if (versionNumber != null) {
                resultInfo.put("versionNumber", versionNumber.toString());
            }
            resultInfo.put("studyURL", studyURL);
            resultInfo.put("dataverse_version_no", dvnVersionNumber);
    
            resultInfo.put("option", "subset");
            resultInfo.put("variableList", getVariableNamesForSubset());
    
            // calculate UNF (locally, on the application side):
    
            List<DataVariable> subsetVariableList = getDataVariableForRequest();
    
            String subsetUNFvalue = "[NOT CALCULATED]";
    
            String[] unfValues = new String[subsetVariableList.size()];
    
            for (int i = 0; i < subsetVariableList.size(); i++) {
                unfValues[i] = subsetVariableList.get(i).getUnf();
            }
    
            dbgLog.fine("unf set:\n" + Arrays.deepToString(unfValues));
    
            try {
                subsetUNFvalue = UNF5Util.calculateUNF(unfValues);
    
            } catch (NumberFormatException ex) {
                // if anything went wrong during the UNF calculation, it's not
                // a fatal condition; we'll just be displaying "not calculated"
                // instead of the UNF in the final README file.
    
                dbgLog.fine("error while trying to calculate subset UNF: Number Format Exception.");
                ex.printStackTrace();
            } catch (IOException ex) {
                dbgLog.fine("error while trying to calculate subset UNF: IO Exception.");
                ex.printStackTrace();
            }
    
            resultInfo.put("fileUNF", subsetUNFvalue);
    
            // writing necessary files:
    
            try {
    
                if (formatType.equals("D01") && !(recodeSchema.size() > 0)) {
                    // (2) tab-delimited-format-only step:
                    //
                    // In the final zip file we package the subset file
                    // and a replication README file (also contains citation). 
                    // We also *used to* include the SAS, SPSS and R control
                    // files created by R. We are not doing this anymore, but 
                    // I left the code commented-out below. 
                    //                  -- L.A. Jan. 2012
                    //
                    // We are also adding the variable header to the file here.
    
                    /* SKIP CODE FILES -- L.A.
                    String codeFileSas = "codeFile_sas_" + resultInfo.get("PID") + ".sas";
                    File tmpCCsasfl = new File(TEMP_DIR, codeFileSas);
                            
                    deleteTempFileList.add(tmpCCsasfl);
                    zipFileList.add(tmpCCsasfl);
                            
                    String codeFileSpss = "codeFile_spss_" + resultInfo.get("PID") + ".sps";
                    File tmpCCspsfl = new File(TEMP_DIR, codeFileSpss);
                            
                    deleteTempFileList.add(tmpCCspsfl);
                    zipFileList.add(tmpCCspsfl);
                            
                    String codeFileStata = "codeFile_stata_" + resultInfo.get("PID") + ".do";
                    File tmpCCdofl  = new File(TEMP_DIR, codeFileStata);
                            
                    deleteTempFileList.add(tmpCCdofl);
                    zipFileList.add(tmpCCdofl);
                            
                    StatisticalCodeFileWriter scfw = new StatisticalCodeFileWriter(sro);
                    scfw.write(tmpCCsasfl, tmpCCspsfl, tmpCCdofl);
                     */
    
                    // add the subset file:
    
                    File tmpsbflnew = File.createTempFile("tempsubsetfile_new.", ".tab");
                    deleteTempFileList.add(tmpsbflnew);
    
                    InputStream inb = new BufferedInputStream(new FileInputStream(tmpsbfl));
                    OutputStream outb = new BufferedOutputStream(new FileOutputStream(tmpsbflnew));
    
                    String varHeaderLine = getVariableHeaderForSubset();
                    // Add the variable header to the subset file:
                    byte[] varHeaderBuffer = null;
                    varHeaderBuffer = varHeaderLine.getBytes();
                    outb.write(varHeaderBuffer);
                    outb.flush();
    
                    int bufsize;
                    byte[] bffr = new byte[8192];
                    while ((bufsize = inb.read(bffr)) != -1) {
                        outb.write(bffr, 0, bufsize);
                    }
                    inb.close();
                    outb.close();
    
                    dbgLog.fine("adding tab file: " + tmpsbflnew.getName());
                    zipFileList.add(tmpsbflnew);
    
                } else {
    
                    // (2)The format-converted subset data file
                    String wbDataFileName = resultInfo.get("wbDataFileName");
                    dbgLog.fine("wbDataFileName=" + wbDataFileName);
    
                    File wbSubsetDataFile = new File(wbDataFileName);
                    if (wbSubsetDataFile.exists()) {
                        dbgLog.fine("wbSubsetDataFile:length=" + wbSubsetDataFile.length());
                        deleteTempFileList.add(wbSubsetDataFile);
                        zipFileList.add(wbSubsetDataFile);
                    } else {
                        // the data file was not created
                        dbgLog.fine("wbSubsetDataFile does not exist");
    
                        msgDwnldButton.setValue("* The requested data file is not available");
                        msgDwnldButton.setVisible(true);
                        dbgLog.warning("exiting dwnldAction(): data file was not transferred");
                        getVDCRequestBean().setSelectedTab("tabDwnld");
                        dvnDSBTimerService.createTimer(deleteTempFileList, TEMP_FILE_LIFETIME);
                        return "";
                    }
                }
    
                // Create README file:
    
                String readMeFileName = null;
    
                if (resultInfo.get("PID") != null && !resultInfo.get("PID").equals("N/A")) {
                    readMeFileName = REP_README_FILE_PREFIX + resultInfo.get("PID") + ".txt";
                } else {
                    readMeFileName = REP_README_FILE_PREFIX + fileId + ".txt";
                }
    
                File readMeFile = new File(TEMP_DIR, readMeFileName);
    
                DvnReplicationREADMEFileWriter rw = new DvnReplicationREADMEFileWriter(resultInfo);
                rw.writeREADMEfile(readMeFile, true);
    
                zipFileList.add(readMeFile);
                deleteTempFileList.add(readMeFile);
    
                for (File f : zipFileList) {
                    dbgLog.fine("file to zip: path=" + f.getAbsolutePath() + "\tname=" + f.getName());
                }
    
                // We can now zip all the required files"
                try {
                    String zipFilePrefix = null;
    
                    if (resultInfo.get("PID") != null && !resultInfo.get("PID").equals("N/A")) {
                        zipFilePrefix = "zipFile_" + resultInfo.get("PID") + ".zip";
                    } else {
                        zipFilePrefix = "zipFile_" + fileId + ".zip";
    
                    }
                    File zipFile = new File(TEMP_DIR, zipFilePrefix);
    
                    //deleteTempFileList.add(zipFile);
                    String zfname = zipFile.getName();
                    zipFileName = zfname;
                    zipFiles(new FileOutputStream(zipFile), zipFileList);
    
                    /*
                    try {
                    Thread.sleep(1000);
                    } catch (Exception e) {
                            
                    }
                     */
    
                    zipResourceDynFileName = new ByteArrayResource(
                            toByteArray(new FileInputStream(zipFile.getAbsolutePath())));
                    dbgLog.info("Subsetting: zipFileName=" + zipFileName);
                    dbgLog.info("Subsetting: zipFile, absolute path: " + zipFile.getAbsolutePath());
                    dvnDSBTimerService.createTimer(deleteTempFileList, TEMP_FILE_LIFETIME);
    
                    // Hide 'Create' button, show 'Download' button:
                    dwnldButton.setRendered(false);
                    dwnloadSubsetButton.setRendered(true);
                    dbgLog.info("***** within dwnldAction(): ends here *****");
    
                    /*
                     * Navigation: 
                     *  - is it necessary to use "faces-redirect" navigation here? 
                     *    Or should we simply return "" as long as we want to stay 
                     *    on the subsetting page?
                    if (versionNumber != null) {
                        return "/study/SubsettingPage?faces-redirect=true&dtId=" + dtId + "&versionNumber=" + versionNumber;
                    }
                    return "/study/SubsettingPage?faces-redirect=true&dtId=" + dtId;
                     */
                    return "";
    
                } catch (IOException e) {
                    // file-access problem, etc.
                    e.printStackTrace();
                    dbgLog.fine("download zipping IO exception");
                    msgDwnldButton.setValue("* an IO problem occurred");
                    msgDwnldButton.setVisible(true);
                    dbgLog.warning("exiting dwnldAction() due to an IO problem ");
                    getVDCRequestBean().setSelectedTab("tabDwnld");
                    dvnDSBTimerService.createTimer(deleteTempFileList, TEMP_FILE_LIFETIME);
                    return "";
                }
                // end of zipping step
    
            } catch (IOException e) {
                e.printStackTrace();
    
                msgDwnldButton.setValue("* an IO problem occurred");
                msgDwnldButton.setVisible(true);
                dbgLog.warning("exiting dwnldAction() due to an IO problem ");
                getVDCRequestBean().setSelectedTab("tabDwnld");
                dvnDSBTimerService.createTimer(deleteTempFileList, TEMP_FILE_LIFETIME);
                return "";
            }
    
            // end: params are OK-case
        } else {
            // the selection is incomplete
            // show error message;
            pgDwnldErrMsg.setRendered(true);
            msgDwnldButton.setValue("* Error: Select a file format");
            msgDwnldButton.setVisible(true);
            dbgLog.warning("exiting dwnldAction() due to incomplete data ");
            getVDCRequestBean().setSelectedTab("tabDwnld");
    
            return "";
        } // end: checking params
    
    }
    

    From source file:org.openmrs.web.servlet.ShowGraphServlet.java

    /**
     * The main method for this class. It will create a JFreeChart object to be written to the
     * response./*from w  w  w.  jav a 2  s  .  c  om*/
     *
     * @param request the current request will all the parameters needed
     * @return JFreeChart object to be rendered
     * @should set value axis label to given units
     * @should set value axis label to concept numeric units if given units is null
     */
    protected JFreeChart getChart(HttpServletRequest request) {
        // All available GET parameters
        String patientId = request.getParameter("patientId"); // required
        String conceptId1 = request.getParameter("conceptId"); // required
        String conceptId2 = request.getParameter("conceptId2");
        String chartTitle = request.getParameter("chartTitle");
        String units = request.getParameter("units");
    
        String minRangeString = request.getParameter("minRange");
        String maxRangeString = request.getParameter("maxRange");
    
        String hideDate = request.getParameter("hideDate");
    
        Patient patient = Context.getPatientService().getPatient(Integer.parseInt(patientId));
    
        // Set date range to passed values, otherwise set a default date range to the last 12 months
        Calendar cal = Calendar.getInstance();
        Date fromDate = getFromDate(request.getParameter("fromDate"));
        Date toDate = getToDate(request.getParameter("toDate"));
    
        // Swap if fromDate is after toDate
        if (fromDate.getTime() > toDate.getTime()) {
            Long temp = fromDate.getTime();
            fromDate.setTime(toDate.getTime());
            toDate.setTime(temp);
        }
    
        // Graph parameters
        Double minRange = null;
        Double maxRange = null;
        Double normalLow = null;
        Double normalHigh = null;
        Double criticalLow = null;
        Double criticalHigh = null;
        String timeAxisTitle = null;
        String rangeAxisTitle = null;
        boolean userSpecifiedMaxRange = false;
        boolean userSpecifiedMinRange = false;
    
        // Fetching obs
        List<Obs> observations1 = new ArrayList<Obs>();
        List<Obs> observations2 = new ArrayList<Obs>();
        Concept concept1 = null, concept2 = null;
        if (conceptId1 != null) {
            concept1 = Context.getConceptService().getConcept(Integer.parseInt(conceptId1));
        }
        if (conceptId2 != null) {
            concept2 = Context.getConceptService().getConcept(Integer.parseInt(conceptId2));
        }
        if (concept1 != null) {
            observations1 = Context.getObsService().getObservationsByPersonAndConcept(patient, concept1);
            chartTitle = concept1.getName().getName();
            rangeAxisTitle = ((ConceptNumeric) concept1).getUnits();
            minRange = ((ConceptNumeric) concept1).getLowAbsolute();
            maxRange = ((ConceptNumeric) concept1).getHiAbsolute();
            normalLow = ((ConceptNumeric) concept1).getLowNormal();
            normalHigh = ((ConceptNumeric) concept1).getHiNormal();
            criticalLow = ((ConceptNumeric) concept1).getLowCritical();
            criticalHigh = ((ConceptNumeric) concept1).getHiCritical();
    
            // Only get observations2 if both concepts share the same units; update chart title and ranges
            if (concept2 != null) {
                String concept2Units = ((ConceptNumeric) concept2).getUnits();
                if (concept2Units != null && concept2Units.equals(rangeAxisTitle)) {
                    observations2 = Context.getObsService().getObservationsByPersonAndConcept(patient, concept2);
                    chartTitle += " + " + concept2.getName().getName();
                    if (((ConceptNumeric) concept2).getHiAbsolute() != null
                            && ((ConceptNumeric) concept2).getHiAbsolute() > maxRange) {
                        maxRange = ((ConceptNumeric) concept2).getHiAbsolute();
                    }
                    if (((ConceptNumeric) concept2).getLowAbsolute() != null
                            && ((ConceptNumeric) concept2).getLowAbsolute() < minRange) {
                        minRange = ((ConceptNumeric) concept2).getLowAbsolute();
                    }
                } else {
                    log.warn("Units for concept id: " + conceptId2 + " don't match units for concept id: "
                            + conceptId1 + ". Only displaying " + conceptId1);
                    concept2 = null; // nullify concept2 so that the legend isn't shown later
                }
            }
        } else {
            chartTitle = "Concept " + conceptId1 + " not found";
            rangeAxisTitle = "Value";
        }
    
        // Overwrite with user-specified values, otherwise use default values
        if (units != null && units.length() > 0) {
            rangeAxisTitle = units;
        }
        if (minRangeString != null) {
            minRange = Double.parseDouble(minRangeString);
            userSpecifiedMinRange = true;
        }
        if (maxRangeString != null) {
            maxRange = Double.parseDouble(maxRangeString);
            userSpecifiedMaxRange = true;
        }
        if (chartTitle == null) {
            chartTitle = "";
        }
        if (rangeAxisTitle == null) {
            rangeAxisTitle = "";
        }
        if (minRange == null) {
            minRange = 0.0;
        }
        if (maxRange == null) {
            maxRange = 200.0;
        }
    
        // Create data set
        TimeSeriesCollection dataset = new TimeSeriesCollection();
        TimeSeries series1, series2;
    
        // Interval-dependent units
        Class<? extends RegularTimePeriod> timeScale = null;
        if (toDate.getTime() - fromDate.getTime() <= 86400000) {
            // Interval <= 1 day: minutely
            timeScale = Minute.class;
            timeAxisTitle = "Time";
        } else if (toDate.getTime() - fromDate.getTime() <= 259200000) {
            // Interval <= 3 days: hourly
            timeScale = Hour.class;
            timeAxisTitle = "Time";
        } else {
            timeScale = Day.class;
            timeAxisTitle = "Date";
        }
        if (concept1 == null) {
            series1 = new TimeSeries("NULL", Hour.class);
        } else {
            series1 = new TimeSeries(concept1.getName().getName(), timeScale);
        }
        if (concept2 == null) {
            series2 = new TimeSeries("NULL", Hour.class);
        } else {
            series2 = new TimeSeries(concept2.getName().getName(), timeScale);
        }
    
        // Add data points for concept1
        for (Obs obs : observations1) {
            if (obs.getValueNumeric() != null && obs.getObsDatetime().getTime() >= fromDate.getTime()
                    && obs.getObsDatetime().getTime() < toDate.getTime()) {
                cal.setTime(obs.getObsDatetime());
                if (timeScale == Minute.class) {
                    Minute min = new Minute(cal.get(Calendar.MINUTE), cal.get(Calendar.HOUR_OF_DAY),
                            cal.get(Calendar.DAY_OF_MONTH), cal.get(Calendar.MONTH) + 1, cal.get(Calendar.YEAR));
                    series1.addOrUpdate(min, obs.getValueNumeric());
                } else if (timeScale == Hour.class) {
                    Hour hour = new Hour(cal.get(Calendar.HOUR_OF_DAY), cal.get(Calendar.DAY_OF_MONTH),
                            cal.get(Calendar.MONTH) + 1, cal.get(Calendar.YEAR));
                    series1.addOrUpdate(hour, obs.getValueNumeric());
                } else {
                    Day day = new Day(cal.get(Calendar.DAY_OF_MONTH), cal.get(Calendar.MONTH) + 1,
                            cal.get(Calendar.YEAR));
                    series1.addOrUpdate(day, obs.getValueNumeric());
                }
            }
        }
    
        // Add data points for concept2
        for (Obs obs : observations2) {
            if (obs.getValueNumeric() != null && obs.getObsDatetime().getTime() >= fromDate.getTime()
                    && obs.getObsDatetime().getTime() < toDate.getTime()) {
                cal.setTime(obs.getObsDatetime());
                if (timeScale == Minute.class) {
                    Minute min = new Minute(cal.get(Calendar.MINUTE), cal.get(Calendar.HOUR_OF_DAY),
                            cal.get(Calendar.DAY_OF_MONTH), cal.get(Calendar.MONTH) + 1, cal.get(Calendar.YEAR));
                    series2.addOrUpdate(min, obs.getValueNumeric());
                } else if (timeScale == Hour.class) {
                    Hour hour = new Hour(cal.get(Calendar.HOUR_OF_DAY), cal.get(Calendar.DAY_OF_MONTH),
                            cal.get(Calendar.MONTH) + 1, cal.get(Calendar.YEAR));
                    series2.addOrUpdate(hour, obs.getValueNumeric());
                } else {
                    Day day = new Day(cal.get(Calendar.DAY_OF_MONTH), cal.get(Calendar.MONTH) + 1,
                            cal.get(Calendar.YEAR));
                    series2.addOrUpdate(day, obs.getValueNumeric());
                }
            }
        }
    
        // Add series to dataset
        dataset.addSeries(series1);
        if (!series2.isEmpty()) {
            dataset.addSeries(series2);
        }
    
        // As of JFreeChart 1.0.11 the default background color is dark grey instead of white.
        // This line restores the original white background.
        ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme());
    
        JFreeChart chart = null;
    
        // Show legend only if more than one series
        if (concept2 == null) {
            chart = ChartFactory.createTimeSeriesChart(chartTitle, timeAxisTitle, rangeAxisTitle, dataset, false,
                    false, false);
        } else {
            chart = ChartFactory.createTimeSeriesChart(chartTitle, timeAxisTitle, rangeAxisTitle, dataset, true,
                    false, false);
        }
    
        // Customize title font
        Font font = new Font("Arial", Font.BOLD, 12);
        TextTitle title = chart.getTitle();
        title.setFont(font);
        chart.setTitle(title);
    
        // Add subtitle, unless 'hideDate' has been passed
        if (hideDate == null) {
            TextTitle subtitle = new TextTitle(fromDate.toString() + " - " + toDate.toString());
            subtitle.setFont(font);
            chart.addSubtitle(subtitle);
        }
    
        XYPlot plot = (XYPlot) chart.getPlot();
        plot.setNoDataMessage("No Data Available");
    
        // Add abnormal/critical range background color (only for single-concept graphs)
        if (concept2 == null) {
            IntervalMarker abnormalLow, abnormalHigh, critical;
            if (normalHigh != null) {
                abnormalHigh = new IntervalMarker(normalHigh, maxRange, COLOR_ABNORMAL);
                plot.addRangeMarker(abnormalHigh);
            }
            if (normalLow != null) {
                abnormalLow = new IntervalMarker(minRange, normalLow, COLOR_ABNORMAL);
                plot.addRangeMarker(abnormalLow);
            }
            if (criticalHigh != null) {
                critical = new IntervalMarker(criticalHigh, maxRange, COLOR_CRITICAL);
                plot.addRangeMarker(critical);
            }
            if (criticalLow != null) {
                critical = new IntervalMarker(minRange, criticalLow, COLOR_CRITICAL);
                plot.addRangeMarker(critical);
            }
    
            // there is data outside of the absolute lower limits for this concept (or of what the user specified as minrange)
            if (plot.getRangeAxis().getLowerBound() < minRange) {
                IntervalMarker error = new IntervalMarker(plot.getRangeAxis().getLowerBound(), minRange,
                        COLOR_ERROR);
                plot.addRangeMarker(error);
            }
    
            if (plot.getRangeAxis().getUpperBound() > maxRange) {
                IntervalMarker error = new IntervalMarker(maxRange, plot.getRangeAxis().getUpperBound(),
                        COLOR_ERROR);
                plot.addRangeMarker(error);
            }
    
        }
    
        // Visuals
        XYItemRenderer r = plot.getRenderer();
        if (r instanceof XYLineAndShapeRenderer) {
            XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) r;
            renderer.setBaseShapesFilled(true);
            renderer.setBaseShapesVisible(true);
        }
    
        // Customize the plot (range and domain axes)
    
        // Modify x-axis (datetime)
        DateAxis timeAxis = (DateAxis) plot.getDomainAxis();
        if (timeScale == Day.class) {
            timeAxis.setDateFormatOverride(new SimpleDateFormat("dd-MMM-yyyy"));
        }
    
        timeAxis.setRange(fromDate, toDate);
    
        // Set y-axis range (values)
        NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
        rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    
        if (userSpecifiedMinRange) {
            minRange = (rangeAxis.getLowerBound() < minRange) ? rangeAxis.getLowerBound() : minRange;
        }
    
        if (userSpecifiedMaxRange) {
            // otherwise we just use default range
            maxRange = (rangeAxis.getUpperBound() > maxRange) ? rangeAxis.getUpperBound() : maxRange;
        }
    
        rangeAxis.setRange(minRange, maxRange);
    
        return chart;
    }
    

    From source file:com.zimbra.cs.account.ldap.LdapProvisioning.java

    void verifyPreAuth(Domain domain, String acctNameForLogging, String acctValue, String acctBy, long timestamp,
            long expires, String preAuth, boolean admin, Map<String, Object> authCtxt) throws ServiceException {
    
        if (preAuth == null || preAuth.length() == 0)
            throw ServiceException.INVALID_REQUEST("preAuth must not be empty", null);
    
        if (acctNameForLogging == null) {
            acctNameForLogging = acctValue;/*from  w ww  .  ja va  2s . c om*/
        }
    
        // see if domain is configured for preauth
        String domainPreAuthKey = domain.getAttr(Provisioning.A_zimbraPreAuthKey, null);
        if (domainPreAuthKey == null)
            throw ServiceException.INVALID_REQUEST("domain is not configured for preauth", null);
    
        // see if request is recent
        long now = System.currentTimeMillis();
        long diff = Math.abs(now - timestamp);
        if (diff > TIMESTAMP_WINDOW) {
            Date nowDate = new Date(now);
            Date preauthDate = new Date(timestamp);
            throw AuthFailedServiceException.AUTH_FAILED(acctNameForLogging, AuthMechanism.namePassedIn(authCtxt),
                    "preauth timestamp is too old, server time: " + nowDate.toString() + ", preauth timestamp: "
                            + preauthDate.toString());
        }
    
        // compute expected preAuth
        HashMap<String, String> params = new HashMap<String, String>();
        params.put("account", acctValue);
        if (admin)
            params.put("admin", "1");
        params.put("by", acctBy);
        params.put("timestamp", timestamp + "");
        params.put("expires", expires + "");
        String computedPreAuth = PreAuthKey.computePreAuth(params, domainPreAuthKey);
        if (!computedPreAuth.equalsIgnoreCase(preAuth)) {
            throw AuthFailedServiceException.AUTH_FAILED(acctNameForLogging, AuthMechanism.namePassedIn(authCtxt),
                    "preauth mismatch");
        }
    
    }
    

    From source file:org.celllife.idart.gui.packaging.NewPatientPackaging.java

    /**
     * Once the Submit button has been pressed, create the package, add in the
     * packaged stock entries//  w w  w . j a  va2 s . co m
     * 
     * @param dispenseNow
     *            boolean
     * @param allPackagedDrugsList
     *            java.util.List<PackageDrugInfo>
     * @throws Exception 
     * @throws IOException 
     * @throws FileNotFoundException 
     */
    private void submitForm(boolean dispenseNow, java.util.List<PackageDrugInfo> allPackagedDrugsList)
            throws Exception {
    
        Transaction tx = null;
        Map<Object, Integer> labelQuantities = new HashMap<Object, Integer>();
        try {
            ConexaoJDBC conn = new ConexaoJDBC();
            if (conn.dispensadonoperiodo(allPackagedDrugsList.get(0).getPatientId()))
    
            {
                System.out.println("Num of Days: " + dias);
                MessageBox mbox = new MessageBox(new Shell(), SWT.YES | SWT.NO | SWT.ICON_WARNING);
                mbox.setText("Levantamento de ARVs");
    
                mbox.setMessage("ATENO:\nO PACIENTE " + txtPatientId.getText()
                        + " J? FORAM DISPENSADOS MEDICAMENTOS NESTE PER?ODO!\n \nA LTIMA DISPENSA FOI H? "
                        + dias + " DIA(s)\n \nQUER DISPENSAR DE NOVO?");
    
                switch (mbox.open()) {
    
                case SWT.YES: {
                    //***************Ainda a configurar a informacao mais correcta 
                    ConfirmWithPasswordDialogAdapter passwordDialog = new ConfirmWithPasswordDialogAdapter(
                            getShell(), getHSession());
                    passwordDialog.setMessage("Por favor insserir a Password");
                    // if password verified
                    String messg = passwordDialog.open();
                    if (messg.equalsIgnoreCase("verified")) {
    
                    }
    
                    tx = getHSession().beginTransaction();
                    if (newPack.getPrescription() != null) {
                        if (previousPack != null) {
                            savePillCounts();
                        }
    
                        // Check if package contains ARV, and
                        // do ARV Start date check.
                        // Should be moved to a facade or manager class
                        for (PackageDrugInfo info : allPackagedDrugsList) {
                            if (!info.isSideTreatment()) {
                                // Check the ARV Start Date if an
                                // ARV package is present.
                                checkARVStartDate();
                                break;
                            }
                        }
    
                        savePackageAndPackagedDrugs(dispenseNow, allPackagedDrugsList);
                        getLog().info("savePackageAndPackagedDrugs() called");
                        setNextAppointmentDate();
    
                        if (allPackagedDrugsList.size() > 0) {
    
                            // This map keeps a track of drugs dispensed in separate
                            // batches
                            Map<String, String> drugNames = new HashMap<String, String>();
    
                            // Update pdi's to include accum drugs
                            for (PackageDrugInfo info : allPackagedDrugsList) {
    
                                info.setQtyInHand(PackageManager.getQuantityDispensedForLabel(
                                        newPack.getAccumulatedDrugs(), info.getDispensedQty(), info.getDrugName(),
                                        info.getPackagedDrug().getStock().getDrug().getPackSize(), false, true));
    
                                labelQuantities.put(info, 1);
                                // set the String that will print out on each drug label
                                // to indicate
                                // (<amount dispensed> + <accumulated amount>)
    
                                if (drugNames.containsKey(info.getDrugName())) {
                                    // not first batch, exclude pillcount value
                                    info.setSummaryQtyInHand(PackageManager.getQuantityDispensedForLabel(
                                            newPack.getAccumulatedDrugs(), info.getDispensedQty(),
                                            info.getDrugName(), info.getDispensedQty(), false, false));
                                } else {
    
                                    info.setSummaryQtyInHand(PackageManager.getQuantityDispensedForLabel(
                                            newPack.getAccumulatedDrugs(), info.getDispensedQty(),
                                            info.getDrugName(), info.getDispensedQty(), false, true));
                                }
                                drugNames.put(info.getDrugName(), "test");
                                // set the String that will print out on the
                                // prescription summary label to indicate
                                // for each drug the (<total amount dispensed> + <total
                                // accumulated amount>)
    
                                // before printing the labels, save pdi List
                                TemporaryRecordsManager.savePackageDrugInfosToDB(getHSession(),
                                        allPackagedDrugsList);
                                getHSession().flush();
    
                            }
                        }
                        tx.commit();
    
                        /*if (iDartProperties.printDrugLabels) {
                           // Add the qty for the summary label
                           labelQuantities.put(ScriptSummaryLabel.KEY,
                                 rdBtnPrintSummaryLabelYes.getSelection() ? 1 : 0);
                           //Add the qty for the next appointment
                           labelQuantities.put(CommonObjects.NEXT_APPOINTMENT_KEY, ( (rdBtnDispenseLater.getSelection()  ||  rdBtnYesAppointmentDate.getSelection()) ? 1 : 0));
                           // Add the qty for the package label
                           labelQuantities.put(PackageCoverLabel.KEY,
                            rdBtnDispenseLater.getSelection() ? 1 : 0);
                           // print labels
                           PackageManager.printLabels(getHSession(),
                                 allPackagedDrugsList, labelQuantities);
                        }*/
                    }
    
                    /*
                     * 
                     * 
                     * Leitura da dispensa de ARV no formulario pelo botao create package, e a posterior insercao na tabela t_tarv do MS ACCESS
                     * 
                     */
                    Vector<String> vMedicamentos = new Vector<String>();
                    //ConexaoJDBC conn=new ConexaoJDBC();
                    ConexaoODBC conn2 = new ConexaoODBC();
    
                    //Inicializa as variaveis para a insercao n acess
                    int dispensedQty = allPackagedDrugsList.get(0).getDispensedQty();
                    String notes = allPackagedDrugsList.get(0).getNotes();
                    String patientId = allPackagedDrugsList.get(0).getPatientId();
                    String specialInstructions1 = allPackagedDrugsList.get(0).getSpecialInstructions1();
                    String specialInstructions2 = allPackagedDrugsList.get(0).getSpecialInstructions2();
                    Date dispenseDate = allPackagedDrugsList.get(0).getDispenseDate();
                    int weeksSupply = allPackagedDrugsList.get(0).getWeeksSupply();
                    int prescriptionDuration = allPackagedDrugsList.get(0).getPrescriptionDuration();
                    String dateExpectedString = allPackagedDrugsList.get(0).getDateExpectedString();
    
                    List<PrescriptionToPatient> lp = conn.listPtP(allPackagedDrugsList.get(0).getPatientId());
                    String reasonforupdate = lp.get(0).getReasonforupdate();
                    String regime = lp.get(0).getRegimeesquema();
                    int idade = lp.get(0).getIdade();
                    Date dataInicioNoutroServico = lp.get(0).getDataInicionoutroservico();
                    String motivomudanca = lp.get(0).getMotivomudanca();
                    String linha = lp.get(0).getLinha();
    
                    for (int i = 0; i < allPackagedDrugsList.size(); i++) {
                        //adiciona os medicantos no vector
                        vMedicamentos.add(new String(allPackagedDrugsList.get(i).getDrugName()));
    
                        /*
                         *   vMedicamentos.add( new String(allPackagedDrugsList.get(i).getDrugName()));
                         * System.out.println("\n\n\n********************************** leitua de dados gui criacao de package");
                                 System.out.println("amountPerTime = "+allPackagedDrugsList.get(i).getAmountPerTime());
                                  System.out.println("this.batchNumber = "+allPackagedDrugsList.get(i).getBatchNumber());
                                  System.out.println("this.clinic = "+allPackagedDrugsList.get(i).getClinic());
                                  System.out.println("this.dispensedQty ="+ allPackagedDrugsList.get(i).getDispensedQty());
                                  System.out.println("this.formLanguage1 ="+ allPackagedDrugsList.get(i).getFormLanguage1());
                                  System.out.println("this.formLanguage2 ="+ allPackagedDrugsList.get(i).getFormLanguage2());
                                 System.out.println("this.formLanguage3 = "+allPackagedDrugsList.get(i).getFormLanguage3());
                                 System.out.println("this.drugName ="+ allPackagedDrugsList.get(i).getDrugName());
                                 System.out.println("this.expiryDate ="+ allPackagedDrugsList.get(i).getExpiryDate());
                                 System.out.println("this.notes = "+allPackagedDrugsList.get(i).getNotes());
                                 System.out.println("this.patientId ="+ allPackagedDrugsList.get(i).getPatientId());
                                 System.out.println("this.patientFirstName ="+ allPackagedDrugsList.get(i).getPatientFirstName());
                                 System.out.println("this.patientLastName = "+allPackagedDrugsList.get(i).getPatientLastName());
                                 System.out.println("this.specialInstructions1 ="+ allPackagedDrugsList.get(i).getSpecialInstructions1());
                                 System.out.println("this.specialInstructions2 ="+ allPackagedDrugsList.get(i).getSpecialInstructions2());
                                 System.out.println("this.stockId = "+allPackagedDrugsList.get(i).getStockId());
                                 System.out.println("this.timesPerDay = "+allPackagedDrugsList.get(i).getTimesPerDay());
                                 System.out.println("this.numberOfLabels ="+ allPackagedDrugsList.get(i).getNumberOfLabels());
                                 System.out.println("this.sideTreatment ="+ allPackagedDrugsList.get(i).isSideTreatment());
                                 System.out.println("this.cluser = "+allPackagedDrugsList.get(i).getCluser());
                                 System.out.println("this.dispenseDate ="+ allPackagedDrugsList.get(i).getDispenseDate());
                                 System.out.println("this.packageIndex ="+ allPackagedDrugsList.get(i).getPackageIndex());
                                 System.out.println("this.weeksSupply = "+allPackagedDrugsList.get(i).getWeeksSupply());
                                 System.out.println("this.packagedDrug = "+allPackagedDrugsList.get(i).getPackagedDrug());
                                 System.out.println("this.qtyInHand = "+allPackagedDrugsList.get(i).getQtyInHand());
                                 System.out.println("this.summaryQtyInHand = "+allPackagedDrugsList.get(i).getSummaryQtyInHand());
                                 System.out.println("this.qtyInLastBatch = "+allPackagedDrugsList.get(i).getQtyInLastBatch());
                                 System.out.println("this.prescriptionDuration = "+allPackagedDrugsList.get(i).getPrescriptionDuration());
                                 System.out.println("this.dateExpectedString = "+allPackagedDrugsList.get(i).getDateExpectedString());
                                 System.out.println("this.packageId = "+allPackagedDrugsList.get(i).getPackageId());
                         */ }
    
                    if (vMedicamentos != null)
                        for (int i = 0; i < vMedicamentos.size(); i++)
                            System.out.println("Medicamento " + i + " " + vMedicamentos.get(i));
    
                    System.out.println(" Quantidade: " + allPackagedDrugsList.get(0).getDispensedQty());
                    System.out.println(" Notes: " + allPackagedDrugsList.get(0).getNotes());
                    System.out.println(" NID: " + allPackagedDrugsList.get(0).getPatientId());
                    System.out.println(" Instucaao1: " + allPackagedDrugsList.get(0).getSpecialInstructions1());
                    System.out.println(" Instruncao2: " + allPackagedDrugsList.get(0).getSpecialInstructions2());
                    System.out.println(" Data de dispensa: " + allPackagedDrugsList.get(0).getDispenseDate());
                    System.out.println(" Semanas: " + allPackagedDrugsList.get(0).getWeeksSupply());
                    System.out.println(" duracao da prescricao semanas: "
                            + allPackagedDrugsList.get(0).getPrescriptionDuration());
                    System.out.println(
                            " data proxima visita: " + allPackagedDrugsList.get(0).getDateExpectedString());
                    System.out.println(" tipotarv: " + lp.get(0).getReasonforupdate());
                    System.out.println(" Regime: " + lp.get(0).getRegimeesquema());
                    System.out.println(" Idade: " + lp.get(0).getIdade());
    
                    System.out.println(" DAta inicio noutro servico: " + dataInicioNoutroServico);
                    System.out.println(" Motivo da mudanca: " + motivomudanca);
                    System.out.println(" Linha Terapeutica: " + linha);
    
                    //convertendo a data para adequar com a coluna datatarv do ms access - t_tarv 
                    SimpleDateFormat parseFormat = new SimpleDateFormat("EEE MMM dd HH:mm:ss z yyyy",
                            Locale.ENGLISH);
                    Date datatarv = parseFormat.parse(dispenseDate.toString());
                    SimpleDateFormat format = new SimpleDateFormat("MM/dd/yyyy", Locale.ENGLISH);
                    String resultdatatarv = format.format(datatarv);
    
                    //Convertendo a data de String para Date. proxima visita
                    Date dateproximavisita = conn.converteData(dateExpectedString);
                    System.out.println(" Date proxima: " + dateproximavisita);
    
                    SimpleDateFormat parseFormat2 = new SimpleDateFormat("yyyy-MM-dd", Locale.ENGLISH);
                    Date dateproxima = parseFormat2.parse(dateproximavisita.toString());
                    SimpleDateFormat format2 = new SimpleDateFormat("MM/dd/yyyy", Locale.ENGLISH);
                    String resultdataproximaconsulta = format2.format(dateproxima);
    
                    String dataNoutroServico = "";
                    if (dataInicioNoutroServico != null)
                        dataNoutroServico = format2.format(dataInicioNoutroServico);
    
                    if (motivomudanca != null && motivomudanca.length() > 0)
                        //quando ha motivo de mudanca
                        conn2.insereT_tarvMotivo(vMedicamentos, patientId, resultdatatarv, dispensedQty, regime,
                                weeksSupply, reasonforupdate, resultdataproximaconsulta, idade, motivomudanca,
                                linha);
    
                    else if (dataInicioNoutroServico != null)
    
                        //Quando  transferido de 
                        conn2.insereT_tarvTransferidoDE(vMedicamentos, patientId, resultdatatarv, dispensedQty,
                                regime, weeksSupply, reasonforupdate, resultdataproximaconsulta, idade,
                                dataNoutroServico, linha);
    
                    else
                        //metodo invocado para a insercao em t_tarv no ms access   
                        conn2.insereT_tarv(vMedicamentos, patientId, resultdatatarv, dispensedQty, regime,
                                weeksSupply, reasonforupdate, resultdataproximaconsulta, idade, linha);
    
                }
    
                    break;
                }
    
            } else {
                tx = getHSession().beginTransaction();
                if (newPack.getPrescription() != null) {
                    if (previousPack != null) {
                        savePillCounts();
                    }
    
                    // Check if package contains ARV, and
                    // do ARV Start date check.
                    // Should be moved to a facade or manager class
                    for (PackageDrugInfo info : allPackagedDrugsList) {
                        if (!info.isSideTreatment()) {
                            // Check the ARV Start Date if an
                            // ARV package is present.
                            checkARVStartDate();
                            break;
                        }
                    }
    
                    savePackageAndPackagedDrugs(dispenseNow, allPackagedDrugsList);
                    getLog().info("savePackageAndPackagedDrugs() called");
                    setNextAppointmentDate();
    
                    if (allPackagedDrugsList.size() > 0) {
    
                        // This map keeps a track of drugs dispensed in separate
                        // batches
                        Map<String, String> drugNames = new HashMap<String, String>();
    
                        // Update pdi's to include accum drugs
                        for (PackageDrugInfo info : allPackagedDrugsList) {
    
                            info.setQtyInHand(PackageManager.getQuantityDispensedForLabel(
                                    newPack.getAccumulatedDrugs(), info.getDispensedQty(), info.getDrugName(),
                                    info.getPackagedDrug().getStock().getDrug().getPackSize(), false, true));
    
                            labelQuantities.put(info, 1);
                            // set the String that will print out on each drug label
                            // to indicate
                            // (<amount dispensed> + <accumulated amount>)
    
                            if (drugNames.containsKey(info.getDrugName())) {
                                // not first batch, exclude pillcount value
                                info.setSummaryQtyInHand(PackageManager.getQuantityDispensedForLabel(
                                        newPack.getAccumulatedDrugs(), info.getDispensedQty(), info.getDrugName(),
                                        info.getDispensedQty(), false, false));
                            } else {
    
                                info.setSummaryQtyInHand(PackageManager.getQuantityDispensedForLabel(
                                        newPack.getAccumulatedDrugs(), info.getDispensedQty(), info.getDrugName(),
                                        info.getDispensedQty(), false, true));
                            }
                            drugNames.put(info.getDrugName(), "test");
                            // set the String that will print out on the
                            // prescription summary label to indicate
                            // for each drug the (<total amount dispensed> + <total
                            // accumulated amount>)
    
                            // before printing the labels, save pdi List
                            TemporaryRecordsManager.savePackageDrugInfosToDB(getHSession(), allPackagedDrugsList);
                            getHSession().flush();
    
                        }
                    }
                    tx.commit();
    
                    /*if (iDartProperties.printDrugLabels) {
                       // Add the qty for the summary label
                       labelQuantities.put(ScriptSummaryLabel.KEY,
                             rdBtnPrintSummaryLabelYes.getSelection() ? 1 : 0);
                       //Add the qty for the next appointment
                       labelQuantities.put(CommonObjects.NEXT_APPOINTMENT_KEY, ( (rdBtnDispenseLater.getSelection()  ||  rdBtnYesAppointmentDate.getSelection()) ? 1 : 0));
                       // Add the qty for the package label
                       labelQuantities.put(PackageCoverLabel.KEY,
                        rdBtnDispenseLater.getSelection() ? 1 : 0);
                       // print labels
                       PackageManager.printLabels(getHSession(),
                             allPackagedDrugsList, labelQuantities);
                    }*/
                }
    
                /*
                 * 
                 * 
                 * Leitura da dispensa de ARV no formulario pelo botao create package, e a posterior insercao na tabela t_tarv do MS ACCESS
                 * 
                 */
                Vector<String> vMedicamentos = new Vector<String>();
                //ConexaoJDBC conn=new ConexaoJDBC();
                ConexaoODBC conn2 = new ConexaoODBC();
    
                //Inicializa as variaveis para a insercao n acess
                int dispensedQty = allPackagedDrugsList.get(0).getDispensedQty();
                String notes = allPackagedDrugsList.get(0).getNotes();
                String patientId = allPackagedDrugsList.get(0).getPatientId();
                String specialInstructions1 = allPackagedDrugsList.get(0).getSpecialInstructions1();
                String specialInstructions2 = allPackagedDrugsList.get(0).getSpecialInstructions2();
                Date dispenseDate = allPackagedDrugsList.get(0).getDispenseDate();
                int weeksSupply = allPackagedDrugsList.get(0).getWeeksSupply();
                int prescriptionDuration = allPackagedDrugsList.get(0).getPrescriptionDuration();
                String dateExpectedString = allPackagedDrugsList.get(0).getDateExpectedString();
    
                List<PrescriptionToPatient> lp = conn.listPtP(allPackagedDrugsList.get(0).getPatientId());
                String reasonforupdate = lp.get(0).getReasonforupdate();
                String regime = lp.get(0).getRegimeesquema();
                int idade = lp.get(0).getIdade();
                Date dataInicioNoutroServico = lp.get(0).getDataInicionoutroservico();
                String motivomudanca = lp.get(0).getMotivomudanca();
                String linha = lp.get(0).getLinha();
    
                for (int i = 0; i < allPackagedDrugsList.size(); i++) {
                    //adiciona os medicantos no vector
                    vMedicamentos.add(new String(allPackagedDrugsList.get(i).getDrugName()));
    
                    /*
                     *   vMedicamentos.add( new String(allPackagedDrugsList.get(i).getDrugName()));
                     * System.out.println("\n\n\n********************************** leitua de dados gui criacao de package");
                             System.out.println("amountPerTime = "+allPackagedDrugsList.get(i).getAmountPerTime());
                              System.out.println("this.batchNumber = "+allPackagedDrugsList.get(i).getBatchNumber());
                              System.out.println("this.clinic = "+allPackagedDrugsList.get(i).getClinic());
                              System.out.println("this.dispensedQty ="+ allPackagedDrugsList.get(i).getDispensedQty());
                              System.out.println("this.formLanguage1 ="+ allPackagedDrugsList.get(i).getFormLanguage1());
                              System.out.println("this.formLanguage2 ="+ allPackagedDrugsList.get(i).getFormLanguage2());
                             System.out.println("this.formLanguage3 = "+allPackagedDrugsList.get(i).getFormLanguage3());
                             System.out.println("this.drugName ="+ allPackagedDrugsList.get(i).getDrugName());
                             System.out.println("this.expiryDate ="+ allPackagedDrugsList.get(i).getExpiryDate());
                             System.out.println("this.notes = "+allPackagedDrugsList.get(i).getNotes());
                             System.out.println("this.patientId ="+ allPackagedDrugsList.get(i).getPatientId());
                             System.out.println("this.patientFirstName ="+ allPackagedDrugsList.get(i).getPatientFirstName());
                             System.out.println("this.patientLastName = "+allPackagedDrugsList.get(i).getPatientLastName());
                             System.out.println("this.specialInstructions1 ="+ allPackagedDrugsList.get(i).getSpecialInstructions1());
                             System.out.println("this.specialInstructions2 ="+ allPackagedDrugsList.get(i).getSpecialInstructions2());
                             System.out.println("this.stockId = "+allPackagedDrugsList.get(i).getStockId());
                             System.out.println("this.timesPerDay = "+allPackagedDrugsList.get(i).getTimesPerDay());
                             System.out.println("this.numberOfLabels ="+ allPackagedDrugsList.get(i).getNumberOfLabels());
                             System.out.println("this.sideTreatment ="+ allPackagedDrugsList.get(i).isSideTreatment());
                             System.out.println("this.cluser = "+allPackagedDrugsList.get(i).getCluser());
                             System.out.println("this.dispenseDate ="+ allPackagedDrugsList.get(i).getDispenseDate());
                             System.out.println("this.packageIndex ="+ allPackagedDrugsList.get(i).getPackageIndex());
                             System.out.println("this.weeksSupply = "+allPackagedDrugsList.get(i).getWeeksSupply());
                             System.out.println("this.packagedDrug = "+allPackagedDrugsList.get(i).getPackagedDrug());
                             System.out.println("this.qtyInHand = "+allPackagedDrugsList.get(i).getQtyInHand());
                             System.out.println("this.summaryQtyInHand = "+allPackagedDrugsList.get(i).getSummaryQtyInHand());
                             System.out.println("this.qtyInLastBatch = "+allPackagedDrugsList.get(i).getQtyInLastBatch());
                             System.out.println("this.prescriptionDuration = "+allPackagedDrugsList.get(i).getPrescriptionDuration());
                             System.out.println("this.dateExpectedString = "+allPackagedDrugsList.get(i).getDateExpectedString());
                             System.out.println("this.packageId = "+allPackagedDrugsList.get(i).getPackageId());
                     */ }
    
                if (vMedicamentos != null)
                    for (int i = 0; i < vMedicamentos.size(); i++)
                        System.out.println("Medicamento " + i + " " + vMedicamentos.get(i));
    
                System.out.println(" Quantidade: " + allPackagedDrugsList.get(0).getDispensedQty());
                System.out.println(" Notes: " + allPackagedDrugsList.get(0).getNotes());
                System.out.println(" NID: " + allPackagedDrugsList.get(0).getPatientId());
                System.out.println(" Instucaao1: " + allPackagedDrugsList.get(0).getSpecialInstructions1());
                System.out.println(" Instruncao2: " + allPackagedDrugsList.get(0).getSpecialInstructions2());
                System.out.println(" Data de dispensa: " + allPackagedDrugsList.get(0).getDispenseDate());
                System.out.println(" Semanas: " + allPackagedDrugsList.get(0).getWeeksSupply());
                System.out.println(
                        " duracao da prescricao semanas: " + allPackagedDrugsList.get(0).getPrescriptionDuration());
                System.out.println(" data proxima visita: " + allPackagedDrugsList.get(0).getDateExpectedString());
                System.out.println(" tipotarv: " + lp.get(0).getReasonforupdate());
                System.out.println(" Regime: " + lp.get(0).getRegimeesquema());
                System.out.println(" Idade: " + lp.get(0).getIdade());
    
                System.out.println(" DAta inicio noutro servico: " + dataInicioNoutroServico);
                System.out.println(" Motivo da mudanca: " + motivomudanca);
                System.out.println(" Linha Terapeutica: " + linha);
    
                //convertendo a data para adequar com a coluna datatarv do ms access - t_tarv 
                SimpleDateFormat parseFormat = new SimpleDateFormat("EEE MMM dd HH:mm:ss z yyyy", Locale.ENGLISH);
                Date datatarv = parseFormat.parse(dispenseDate.toString());
                SimpleDateFormat format = new SimpleDateFormat("MM/dd/yyyy", Locale.ENGLISH);
                String resultdatatarv = format.format(datatarv);
    
                //Convertendo a data de String para Date. proxima visita
                Date dateproximavisita = conn.converteData(dateExpectedString);
                System.out.println(" Date proxima: " + dateproximavisita);
    
                SimpleDateFormat parseFormat2 = new SimpleDateFormat("yyyy-MM-dd", Locale.ENGLISH);
                Date dateproxima = parseFormat2.parse(dateproximavisita.toString());
                SimpleDateFormat format2 = new SimpleDateFormat("MM/dd/yyyy", Locale.ENGLISH);
                String resultdataproximaconsulta = format2.format(dateproxima);
    
                String dataNoutroServico = "";
                if (dataInicioNoutroServico != null)
                    dataNoutroServico = format2.format(dataInicioNoutroServico);
    
                if (motivomudanca != null && motivomudanca.length() > 0)
                    //quando ha motivo de mudanca
                    conn2.insereT_tarvMotivo(vMedicamentos, patientId, resultdatatarv, dispensedQty, regime,
                            weeksSupply, reasonforupdate, resultdataproximaconsulta, idade, motivomudanca, linha);
    
                else if (dataInicioNoutroServico != null)
    
                    //Quando  transferido de 
                    conn2.insereT_tarvTransferidoDE(vMedicamentos, patientId, resultdatatarv, dispensedQty, regime,
                            weeksSupply, reasonforupdate, resultdataproximaconsulta, idade, dataNoutroServico,
                            linha);
    
                else
                    //metodo invocado para a insercao em t_tarv no ms access   
                    conn2.insereT_tarv(vMedicamentos, patientId, resultdatatarv, dispensedQty, regime, weeksSupply,
                            reasonforupdate, resultdataproximaconsulta, idade, linha);
    
            }
    
        } catch (HibernateException he) {//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
            getLog().error("Problem with Saving this package", he);
            if (tx != null) {
                tx.rollback();
            }
    
            MessageBox m = new MessageBox(getShell(), SWT.OK | SWT.ICON_INFORMATION);
            m.setText("Problem Saving Package");
            m.setMessage("There was a problem saving this package of drugs.");
    
            m.open();
        }
    
        setScreenToInitialState();
    
        tblPrescriptionInfo.clearAll();
        pillCountTable.clearTable();
    
    }
    

    From source file:com.portfolio.data.provider.MysqlDataProvider.java

    @Override
    public String createUser(String username) throws Exception {
        PreparedStatement st;//from  ww w . j  av  a 2 s. c  om
        String sql;
        ResultSet res;
        String retval = "0";
    
        try {
            Date date = new Date();
            sql = "INSERT INTO credential SET login=?, display_firstname=?, display_lastname='', password=UNHEX(SHA1(?))";
            if (dbserveur.equals("oracle")) {
                sql = "INSERT INTO credential SET login=?, display_firstname=?, display_lastname='', password=crypt(?)";
            }
            st = connection.prepareStatement(sql, Statement.RETURN_GENERATED_KEYS);
            if (dbserveur.equals("oracle")) {
                st = connection.prepareStatement(sql, new String[] { "userid" });
            }
            st.setString(1, username);
            st.setString(2, username);
            st.setString(3, date.toString() + "somesalt");
            st.executeUpdate();
            res = st.getGeneratedKeys();
            if (res.next())
                retval = Integer.toString(res.getInt(1));
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    
        return retval;
    }
    

    From source file:com.att.pirates.controller.ProjectController.java

    public static List<ProjectDetailsStatusViewModel> getProjectDetailsStatus(String prismId, String uuid) {
        List<ProjectDetailsStatusViewModel> detailStatus = new ArrayList<ProjectDetailsStatusViewModel>();
    
        try {//  w ww . ja  v a 2 s .c o m
            // logger.error("getProjectDetailsStatus, before calling getProjectAppOwners(prismId)");
            List<ProjectAppOwnerModel> results = getProjectAppOwners(prismId);
            // logger.error("getProjectDetailsStatus, after calling getProjectAppOwners(prismId)");
    
            if (!results.isEmpty()) {
                ArrayList<String> list = new ArrayList<String>();
                for (ProjectAppOwnerModel p : results) {
                    list.add(p.getApplicationName());
                }
                // convert the List into a Set
                Set<String> set = new HashSet<String>(list);
                // create a new List from the Set
                // now, they are unique
                ArrayList<String> distinctApps = new ArrayList<String>(set);
                Collections.sort(distinctApps);
    
                for (String app : distinctApps) {
                    int impactTypeId = DataService.getImpactTypeIdByPrismIdAndApplicationName(prismId, app);
                    boolean validateThreshold = !(impactTypeId == 4);
    
                    ProjectDetailsStatusViewModel aRow = new ProjectDetailsStatusViewModel();
                    List<ProjectAppOwnerModel> thisAppRows = getAppOwnerModelObjectsByAppName(results, app);
    
                    if (!thisAppRows.isEmpty()) {
                        aRow.setApplicationId(thisAppRows.get(0).getApplicationId());
                        aRow.setApplication(app);
                        aRow.setImpactType(impactTypeId);
    
                        // 1. BR
                        List<ProjectAppOwnerModel> allBRs = getProjectAppOwnerModelObjectByArtifactName(thisAppRows,
                                PiratesConstants.BR);
                        if (!allBRs.isEmpty()) {
                            aRow.setBR(allBRs.get(0).getPercentageComplete());
                            aRow.setBRheaderDueDate(allBRs.get(0).getDueDate());
                            aRow.setBRDuedate(allBRs.get(0).getDateCreated());
                            aRow.setUpdatedByUUID(allBRs.get(0).getUpdatedByUUID());
    
                            // get history records
                            List<AppProjectArtifactOwnersHistory> history = getStatusHistoryListByApplicationOwner(
                                    allBRs.get(0));
                            if (!history.isEmpty()) {
                                for (AppProjectArtifactOwnersHistory h : history) {
                                    // for percentage
                                    aRow.setBR(aRow.getBR() + "," + h.getPercentageComplete());
                                    aRow.setBRDuedate(aRow.getBRDuedate() + "," + h.getDateLogged());
                                    aRow.setUpdatedByUUID(aRow.getUpdatedByUUID() + "," + h.getUpdatedByUUID());
                                }
                            } // after processing each history record
                            aRow.setBRStr(getRowDueDatePercentageString(aRow.getBR(), aRow.getBRDuedate(),
                                    aRow.getUpdatedByUUID(), uuid, aRow.getBRheaderDueDate(), false,
                                    validateThreshold));
                        } // end processing isEmpty()
                        else {
                            aRow.setBR("0%");
                            aRow.setBRDuedate("NA");
                            aRow.setUpdatedByUUID("NA");
                            aRow.setBRheaderDueDate("NA");
                            aRow.setBRStr(getRowDueDatePercentageString(aRow.getBR(), aRow.getBRDuedate(),
                                    aRow.getUpdatedByUUID(), uuid, aRow.getBRheaderDueDate(), false,
                                    validateThreshold));
                        }
                        // end of BR
    
                        // 2. SR
                        List<ProjectAppOwnerModel> allSRs = getProjectAppOwnerModelObjectByArtifactName(thisAppRows,
                                PiratesConstants.SR);
                        if (!allSRs.isEmpty()) {
                            aRow.setSR(allSRs.get(0).getPercentageComplete());
                            aRow.setSRheaderDueDate(allSRs.get(0).getDueDate());
                            aRow.setSRDuedate(allSRs.get(0).getDateCreated());
                            aRow.setUpdatedByUUID(allSRs.get(0).getUpdatedByUUID());
    
                            // get history records
                            List<AppProjectArtifactOwnersHistory> history = getStatusHistoryListByApplicationOwner(
                                    allSRs.get(0));
                            if (!history.isEmpty()) {
                                for (AppProjectArtifactOwnersHistory h : history) {
                                    // for percentage
                                    aRow.setSR(aRow.getSR() + "," + h.getPercentageComplete());
                                    aRow.setSRDuedate(aRow.getSRDuedate() + "," + h.getDateLogged());
                                    aRow.setUpdatedByUUID(aRow.getUpdatedByUUID() + "," + h.getUpdatedByUUID());
                                }
                            } // after processing each history record
                            aRow.setSRStr(getRowDueDatePercentageString(aRow.getSR(), aRow.getSRDuedate(),
                                    aRow.getUpdatedByUUID(), uuid, aRow.getSRheaderDueDate(), true,
                                    validateThreshold));
                        } // end processing isEmpty()
                        else {
                            aRow.setSR("0%");
                            aRow.setSRDuedate("NA");
                            aRow.setUpdatedByUUID("NA");
                            aRow.setSRheaderDueDate("NA");
                            aRow.setSRStr(getRowDueDatePercentageString(aRow.getSR(), aRow.getSRDuedate(),
                                    aRow.getUpdatedByUUID(), uuid, aRow.getSRheaderDueDate(), true,
                                    validateThreshold));
                        }
                        // end of SR                        
    
                        // 3. HLD
                        List<ProjectAppOwnerModel> allHLDs = getProjectAppOwnerModelObjectByArtifactName(
                                thisAppRows, PiratesConstants.HLD);
                        if (!allHLDs.isEmpty()) {
                            aRow.setHLD(allHLDs.get(0).getPercentageComplete());
                            aRow.setHLDheaderDueDate(allHLDs.get(0).getDueDate());
                            aRow.setHLDDuedate(allHLDs.get(0).getDateCreated());
                            aRow.setUpdatedByUUID(allHLDs.get(0).getUpdatedByUUID());
    
                            // get history records
                            List<AppProjectArtifactOwnersHistory> history = getStatusHistoryListByApplicationOwner(
                                    allHLDs.get(0));
                            if (!history.isEmpty()) {
                                for (AppProjectArtifactOwnersHistory h : history) {
                                    // for percentage
                                    aRow.setHLD(aRow.getHLD() + "," + h.getPercentageComplete());
                                    aRow.setHLDDuedate(aRow.getHLDDuedate() + "," + h.getDateLogged());
                                    aRow.setUpdatedByUUID(aRow.getUpdatedByUUID() + "," + h.getUpdatedByUUID());
                                }
                            } // after processing each history record
                            aRow.setHLDStr(getRowDueDatePercentageString(aRow.getHLD(), aRow.getHLDDuedate(),
                                    aRow.getUpdatedByUUID(), uuid, aRow.getHLDheaderDueDate(), true,
                                    validateThreshold));
                        } // end processing isEmpty()
                        else {
                            aRow.setHLD("0%");
                            aRow.setHLDDuedate("NA");
                            aRow.setUpdatedByUUID("NA");
                            aRow.setHLDheaderDueDate("NA");
                            aRow.setHLDStr(getRowDueDatePercentageString(aRow.getHLD(), aRow.getHLDDuedate(),
                                    aRow.getUpdatedByUUID(), uuid, aRow.getHLDheaderDueDate(), true,
                                    validateThreshold));
                        }
                        // end of HLD
    
                        // 4. AID
                        List<ProjectAppOwnerModel> allAIDs = getProjectAppOwnerModelObjectByArtifactName(
                                thisAppRows, PiratesConstants.AID);
                        if (!allAIDs.isEmpty()) {
                            aRow.setAID(allAIDs.get(0).getPercentageComplete());
                            aRow.setAIDheaderDueDate(allAIDs.get(0).getDueDate());
                            aRow.setAIDDuedate(allAIDs.get(0).getDateCreated());
                            aRow.setUpdatedByUUID(allAIDs.get(0).getUpdatedByUUID());
    
                            // get history records
                            List<AppProjectArtifactOwnersHistory> history = getStatusHistoryListByApplicationOwner(
                                    allAIDs.get(0));
                            if (!history.isEmpty()) {
                                for (AppProjectArtifactOwnersHistory h : history) {
                                    // for percentage
                                    aRow.setAID(aRow.getAID() + "," + h.getPercentageComplete());
                                    aRow.setAIDDuedate(aRow.getAIDDuedate() + "," + h.getDateLogged());
                                    aRow.setUpdatedByUUID(aRow.getUpdatedByUUID() + "," + h.getUpdatedByUUID());
                                }
                            } // after processing each history record
                            aRow.setAIDStr(getRowDueDatePercentageString(aRow.getAID(), aRow.getAIDDuedate(),
                                    aRow.getUpdatedByUUID(), uuid, aRow.getAIDheaderDueDate(), true,
                                    validateThreshold));
                        } // end processing isEmpty()
                        else {
                            aRow.setAID("0%");
                            aRow.setAIDDuedate("NA");
                            aRow.setUpdatedByUUID("NA");
                            aRow.setAIDheaderDueDate("NA");
                            aRow.setAIDStr(getRowDueDatePercentageString(aRow.getAID(), aRow.getAIDDuedate(),
                                    aRow.getUpdatedByUUID(), uuid, aRow.getAIDheaderDueDate(), true,
                                    validateThreshold));
                        }
                        // end of AID
    
                        // 5. AD
                        List<ProjectAppOwnerModel> allADs = getProjectAppOwnerModelObjectByArtifactName(thisAppRows,
                                PiratesConstants.DES);
                        if (!allADs.isEmpty()) {
                            aRow.setDES(allADs.get(0).getPercentageComplete());
                            aRow.setDESheaderDueDate(allADs.get(0).getDueDate());
                            aRow.setDESDuedate(allADs.get(0).getDateCreated());
                            aRow.setUpdatedByUUID(allADs.get(0).getUpdatedByUUID());
    
                            // get history records
                            List<AppProjectArtifactOwnersHistory> history = getStatusHistoryListByApplicationOwner(
                                    allADs.get(0));
                            if (!history.isEmpty()) {
                                for (AppProjectArtifactOwnersHistory h : history) {
                                    // for percentage
                                    aRow.setDES(aRow.getDES() + "," + h.getPercentageComplete());
                                    aRow.setDESDuedate(aRow.getDESDuedate() + "," + h.getDateLogged());
                                    aRow.setUpdatedByUUID(aRow.getUpdatedByUUID() + "," + h.getUpdatedByUUID());
                                }
                            } // after processing each history record
                            aRow.setDESStr(getRowDueDatePercentageString(aRow.getDES(), aRow.getDESDuedate(),
                                    aRow.getUpdatedByUUID(), uuid, aRow.getDESheaderDueDate(), true,
                                    validateThreshold));
                        } // end processing isEmpty()
                        else {
                            aRow.setDES("0%");
                            aRow.setDESDuedate("NA");
                            aRow.setUpdatedByUUID("NA");
                            aRow.setDESheaderDueDate("NA");
                            aRow.setDESStr(getRowDueDatePercentageString(aRow.getDES(), aRow.getDESDuedate(),
                                    aRow.getUpdatedByUUID(), uuid, aRow.getDESheaderDueDate(), true,
                                    validateThreshold));
                        }
                        // end of DES                        
    
                        // 6. DEV
                        List<ProjectAppOwnerModel> allDEVs = getProjectAppOwnerModelObjectByArtifactName(
                                thisAppRows, PiratesConstants.DEV);
                        if (!allDEVs.isEmpty()) {
                            aRow.setDEV(allDEVs.get(0).getPercentageComplete());
                            aRow.setDEVheaderDueDate(allDEVs.get(0).getDueDate());
                            aRow.setDEVDuedate(allDEVs.get(0).getDateCreated());
                            aRow.setUpdatedByUUID(allDEVs.get(0).getUpdatedByUUID());
    
                            // get history records
                            List<AppProjectArtifactOwnersHistory> history = getStatusHistoryListByApplicationOwner(
                                    allDEVs.get(0));
                            if (!history.isEmpty()) {
                                for (AppProjectArtifactOwnersHistory h : history) {
                                    // for percentage
                                    aRow.setDEV(aRow.getDEV() + "," + h.getPercentageComplete());
                                    aRow.setDEVDuedate(aRow.getDEVDuedate() + "," + h.getDateLogged());
                                    aRow.setUpdatedByUUID(aRow.getUpdatedByUUID() + "," + h.getUpdatedByUUID());
                                }
                            } // after processing each history record
                            aRow.setDEVStr(getRowDueDatePercentageString(aRow.getDEV(), aRow.getDEVDuedate(),
                                    aRow.getUpdatedByUUID(), uuid, aRow.getDEVheaderDueDate(), true,
                                    validateThreshold));
                        } // end processing isEmpty()
                        else {
                            aRow.setDEV("0%");
                            aRow.setDEVDuedate("NA");
                            aRow.setUpdatedByUUID("NA");
                            aRow.setDEVheaderDueDate("NA");
                            aRow.setDEVStr(getRowDueDatePercentageString(aRow.getDEV(), aRow.getDEVDuedate(),
                                    aRow.getUpdatedByUUID(), uuid, aRow.getDEVheaderDueDate(), true,
                                    validateThreshold));
                        }
                        // end of DEV                        
    
                        // 7. IST
                        List<ProjectAppOwnerModel> allISTs = getProjectAppOwnerModelObjectByArtifactName(
                                thisAppRows, PiratesConstants.IST);
                        if (!allISTs.isEmpty()) {
                            aRow.setIST(allISTs.get(0).getPercentageComplete());
                            aRow.setISTheaderDueDate(allISTs.get(0).getDueDate());
                            aRow.setISTDuedate(allISTs.get(0).getDateCreated());
                            aRow.setUpdatedByUUID(allISTs.get(0).getUpdatedByUUID());
    
                            // get history records
                            List<AppProjectArtifactOwnersHistory> history = getStatusHistoryListByApplicationOwner(
                                    allISTs.get(0));
                            if (!history.isEmpty()) {
                                for (AppProjectArtifactOwnersHistory h : history) {
                                    // for percentage
                                    aRow.setIST(aRow.getIST() + "," + h.getPercentageComplete());
                                    aRow.setISTDuedate(aRow.getISTDuedate() + "," + h.getDateLogged());
                                    aRow.setUpdatedByUUID(aRow.getUpdatedByUUID() + "," + h.getUpdatedByUUID());
                                }
                            } // after processing each history record
                            aRow.setISTStr(getRowDueDatePercentageString(aRow.getIST(), aRow.getISTDuedate(),
                                    aRow.getUpdatedByUUID(), uuid, aRow.getISTheaderDueDate(), true,
                                    validateThreshold));
                        } // end processing isEmpty()
                        else {
                            aRow.setIST("0%");
                            aRow.setISTDuedate("NA");
                            aRow.setUpdatedByUUID("NA");
                            aRow.setISTheaderDueDate("NA");
                            aRow.setISTStr(getRowDueDatePercentageString(aRow.getIST(), aRow.getISTDuedate(),
                                    aRow.getUpdatedByUUID(), uuid, aRow.getISTheaderDueDate(), true,
                                    validateThreshold));
                        }
                        // end of IST                             
    
                        // 8. ISTExec
                        List<ProjectAppOwnerModel> allISTExecs = getProjectAppOwnerModelObjectByArtifactName(
                                thisAppRows, PiratesConstants.ISTExec);
                        if (!allISTExecs.isEmpty() && impactTypeId != 4) {
                            aRow.setISTExec(allISTExecs.get(0).getPercentageComplete());
                            aRow.setISTExecheaderDueDate(allISTExecs.get(0).getDueDate());
                            aRow.setISTExecDuedate(allISTExecs.get(0).getDateCreated());
                            aRow.setUpdatedByUUID(allISTExecs.get(0).getUpdatedByUUID());
    
                            // get history records
                            List<AppProjectArtifactOwnersHistory> history = getStatusHistoryListByApplicationOwner(
                                    allISTExecs.get(0));
                            if (!history.isEmpty()) {
                                for (AppProjectArtifactOwnersHistory h : history) {
                                    // for percentage
                                    aRow.setISTExec(aRow.getISTExec() + "," + h.getPercentageComplete());
                                    aRow.setISTExecDuedate(aRow.getISTExecDuedate() + "," + h.getDateLogged());
                                    aRow.setUpdatedByUUID(aRow.getUpdatedByUUID() + "," + h.getUpdatedByUUID());
                                }
                            } // after processing each history record
                            aRow.setISTExecStr(getRowDueDatePercentageString(aRow.getISTExec(),
                                    aRow.getISTExecDuedate(), aRow.getUpdatedByUUID(), uuid,
                                    aRow.getISTExecheaderDueDate(), true, validateThreshold));
                        } // end processing isEmpty()
                        else {
                            aRow.setISTExec("0%");
                            aRow.setISTExecDuedate("NA");
                            aRow.setUpdatedByUUID("NA");
                            aRow.setISTExecheaderDueDate("NA");
                            aRow.setISTExecStr(getRowDueDatePercentageString(aRow.getISTExec(),
                                    aRow.getISTExecDuedate(), aRow.getUpdatedByUUID(), uuid,
                                    aRow.getISTExecheaderDueDate(), true, validateThreshold));
                        }
                        // end of ISTExec 
    
                        // 9. CloseOut
                        List<ProjectAppOwnerModel> allCloseout = getProjectAppOwnerModelObjectByArtifactName(
                                thisAppRows, PiratesConstants.CLOSEOUT);
                        if (!allCloseout.isEmpty()) {
                            aRow.setCloseOut(allCloseout.get(0).getPercentageComplete());
                            aRow.setCloseOutheaderDueDate(allCloseout.get(0).getDueDate());
                            aRow.setCloseOutDuedate(allCloseout.get(0).getDateCreated());
                            aRow.setUpdatedByUUID(allCloseout.get(0).getUpdatedByUUID());
    
                            // get history records
                            List<AppProjectArtifactOwnersHistory> history = getStatusHistoryListByApplicationOwner(
                                    allCloseout.get(0));
                            if (!history.isEmpty()) {
                                for (AppProjectArtifactOwnersHistory h : history) {
                                    // for percentage
                                    aRow.setCloseOut(aRow.getCloseOut() + "," + h.getPercentageComplete());
                                    aRow.setCloseOutDuedate(aRow.getCloseOutDuedate() + "," + h.getDateLogged());
                                    aRow.setUpdatedByUUID(aRow.getUpdatedByUUID() + "," + h.getUpdatedByUUID());
                                }
                            } // after processing each history record
                            aRow.setCloseOutStr(getRowDueDatePercentageString(aRow.getCloseOut(),
                                    aRow.getCloseOutDuedate(), aRow.getUpdatedByUUID(), uuid,
                                    aRow.getCloseOutheaderDueDate(), true, validateThreshold));
                        } // end processing isEmpty()
                        else {
                            aRow.setCloseOut("0%");
                            aRow.setCloseOutDuedate("NA");
                            aRow.setUpdatedByUUID("NA");
                            aRow.setCloseOutheaderDueDate("NA");
                            aRow.setCloseOutStr(getRowDueDatePercentageString(aRow.getCloseOut(),
                                    aRow.getCloseOutDuedate(), aRow.getUpdatedByUUID(), uuid,
                                    aRow.getCloseOutheaderDueDate(), true, validateThreshold));
                        }
                        // end of CloseOut
    
                        // 10. Agile
                        List<ProjectAppOwnerModel> allAgile = getProjectAppOwnerModelObjectByArtifactName(
                                thisAppRows, PiratesConstants.AGILE);
                        if (!allAgile.isEmpty()) {
                            aRow.setAgile(allAgile.get(0).getPercentageComplete());
                            aRow.setAgileheaderDueDate(allAgile.get(0).getDueDate());
                            aRow.setAgileDuedate(allAgile.get(0).getDateCreated());
                            aRow.setUpdatedByUUID(allAgile.get(0).getUpdatedByUUID());
    
                            // get history records
                            List<AppProjectArtifactOwnersHistory> history = getStatusHistoryListByApplicationOwner(
                                    allAgile.get(0));
                            if (!history.isEmpty()) {
                                for (AppProjectArtifactOwnersHistory h : history) {
                                    // for percentage
                                    aRow.setAgile(aRow.getAgile() + "," + h.getPercentageComplete());
                                    aRow.setAgileDuedate(aRow.getAgileDuedate() + "," + h.getDateLogged());
                                    aRow.setUpdatedByUUID(aRow.getUpdatedByUUID() + "," + h.getUpdatedByUUID());
                                }
                            } // after processing each history record
                            aRow.setAgileStr(getRowDueDatePercentageString(aRow.getAgile(), aRow.getAgileDuedate(),
                                    aRow.getUpdatedByUUID(), uuid, aRow.getAgileheaderDueDate(), true,
                                    validateThreshold));
                        } // end processing isEmpty()
                        else {
                            aRow.setAgile("0%");
                            aRow.setAgileDuedate("NA");
                            aRow.setUpdatedByUUID("NA");
                            aRow.setAgileheaderDueDate("NA");
                            aRow.setAgileStr(getRowDueDatePercentageString(aRow.getAgile(), aRow.getAgileDuedate(),
                                    aRow.getUpdatedByUUID(), uuid, aRow.getAgileheaderDueDate(), true,
                                    validateThreshold));
                        }
                        // end of Agile                        
    
                        aRow.setPrismId(prismId);
                        detailStatus.add(aRow);
                    } // end thisAppRow.ANY() check
                } // end distinct appName loop
            }
        } catch (Exception ex) {
            logger.error(msgHeader + "Error occurred getProjectDetailsStatuc... " + ex.getMessage());
        }
    
        // new code
        SimpleDateFormat yFormat = new SimpleDateFormat("MM/dd/yyyy");
        List<Date> tmpDates = new ArrayList<Date>();
        Date BR = null;
        Date SR = null;
        Date HLD = null;
        Date AID = null;
        Date AD = null;
        Date DEV = null;
        Date IST = null;
        Date ISTExec = null;
        Date CloseOut = null;
        Date Agile = null;
    
        // Process BR
        for (ProjectDetailsStatusViewModel i : detailStatus) {
            if (!("NA".equalsIgnoreCase(i.getBRheaderDueDate()))) {
                try {
                    Date t = yFormat.parse(i.getBRheaderDueDate());
                    tmpDates.add(t);
                } catch (ParseException pe) {
                    logger.error("can't parse date from value " + i.getBRheaderDueDate()
                            + ", so skipping .. exception: " + pe.getMessage());
                }
            }
        }
        if (tmpDates.size() > 0) {
            // sort all BRduedates, pick the earliest one as the final one
            Collections.sort(tmpDates, new Comparator<Date>() {
                @Override
                public int compare(Date o1, Date o2) {
                    return o1.compareTo(o2);
                }
            });
            BR = tmpDates.get(0);
        }
        tmpDates.clear();
    
        // Process SR
        for (ProjectDetailsStatusViewModel i : detailStatus) {
            if (!("NA".equalsIgnoreCase(i.getSRheaderDueDate()))) {
                try {
                    Date t = yFormat.parse(i.getSRheaderDueDate());
                    tmpDates.add(t);
                } catch (ParseException pe) {
                    logger.error("can't parse date from value " + i.getSRheaderDueDate()
                            + ", so skipping .. exception: " + pe.getMessage());
                }
            }
        }
        if (tmpDates.size() > 0) {
            // sort all BRduedates, pick the earliest one as the final one
            Collections.sort(tmpDates, new Comparator<Date>() {
                @Override
                public int compare(Date o1, Date o2) {
                    return o1.compareTo(o2);
                }
            });
            SR = tmpDates.get(0);
        }
        tmpDates.clear();
    
        // Process HLD
        for (ProjectDetailsStatusViewModel i : detailStatus) {
            if (!("NA".equalsIgnoreCase(i.getHLDheaderDueDate()))) {
                try {
                    Date t = yFormat.parse(i.getHLDheaderDueDate());
                    tmpDates.add(t);
                } catch (ParseException pe) {
                    logger.error("can't parse date from value " + i.getHLDheaderDueDate()
                            + ", so skipping .. exception: " + pe.getMessage());
                }
            }
        }
        if (tmpDates.size() > 0) {
            // sort all BRduedates, pick the earliest one as the final one
            Collections.sort(tmpDates, new Comparator<Date>() {
                @Override
                public int compare(Date o1, Date o2) {
                    return o1.compareTo(o2);
                }
            });
            HLD = tmpDates.get(0);
        }
        tmpDates.clear();
    
        // Process AID
        for (ProjectDetailsStatusViewModel i : detailStatus) {
            if (!("NA".equalsIgnoreCase(i.getAIDheaderDueDate()))) {
                try {
                    Date t = yFormat.parse(i.getAIDheaderDueDate());
                    tmpDates.add(t);
                } catch (ParseException pe) {
                    logger.error("can't parse date from value " + i.getAIDheaderDueDate()
                            + ", so skipping .. exception: " + pe.getMessage());
                }
            }
        }
        if (tmpDates.size() > 0) {
            // sort all BRduedates, pick the earliest one as the final one
            Collections.sort(tmpDates, new Comparator<Date>() {
                @Override
                public int compare(Date o1, Date o2) {
                    return o1.compareTo(o2);
                }
            });
            AID = tmpDates.get(0);
        }
        tmpDates.clear();
    
        // Process AD
        for (ProjectDetailsStatusViewModel i : detailStatus) {
            if (!("NA".equalsIgnoreCase(i.getDESheaderDueDate()))) {
                try {
                    Date t = yFormat.parse(i.getDESheaderDueDate());
                    tmpDates.add(t);
                } catch (ParseException pe) {
                    logger.error("can't parse date from value " + i.getDESheaderDueDate()
                            + ", so skipping .. exception: " + pe.getMessage());
                }
            }
        }
        if (tmpDates.size() > 0) {
            // sort all BRduedates, pick the earliest one as the final one
            Collections.sort(tmpDates, new Comparator<Date>() {
                @Override
                public int compare(Date o1, Date o2) {
                    return o1.compareTo(o2);
                }
            });
            AD = tmpDates.get(0);
        }
        tmpDates.clear();
    
        // Process DEV
        for (ProjectDetailsStatusViewModel i : detailStatus) {
            if (!("NA".equalsIgnoreCase(i.getDEVheaderDueDate()))) {
                try {
                    Date t = yFormat.parse(i.getDEVheaderDueDate());
                    tmpDates.add(t);
                } catch (ParseException pe) {
                    logger.error("can't parse date from value " + i.getDEVheaderDueDate()
                            + ", so skipping .. exception: " + pe.getMessage());
                }
            }
        }
        if (tmpDates.size() > 0) {
            // sort all BRduedates, pick the earliest one as the final one
            Collections.sort(tmpDates, new Comparator<Date>() {
                @Override
                public int compare(Date o1, Date o2) {
                    return o1.compareTo(o2);
                }
            });
            DEV = tmpDates.get(0);
        }
        tmpDates.clear();
    
        // Process IST
        for (ProjectDetailsStatusViewModel i : detailStatus) {
            if (!("NA".equalsIgnoreCase(i.getISTheaderDueDate()))) {
                try {
                    Date t = yFormat.parse(i.getISTheaderDueDate());
                    tmpDates.add(t);
                } catch (ParseException pe) {
                    logger.error("can't parse date from value " + i.getISTheaderDueDate()
                            + ", so skipping .. exception: " + pe.getMessage());
                }
            }
        }
        if (tmpDates.size() > 0) {
            // sort all BRduedates, pick the earliest one as the final one
            Collections.sort(tmpDates, new Comparator<Date>() {
                @Override
                public int compare(Date o1, Date o2) {
                    return o1.compareTo(o2);
                }
            });
            IST = tmpDates.get(0);
        }
        tmpDates.clear();
    
        // Process ISTExec
        for (ProjectDetailsStatusViewModel i : detailStatus) {
            if (!("NA".equalsIgnoreCase(i.getISTExecheaderDueDate()))) {
                try {
                    Date t = yFormat.parse(i.getISTExecheaderDueDate());
                    tmpDates.add(t);
                } catch (ParseException pe) {
                    logger.error("can't parse date from value " + i.getISTExecheaderDueDate()
                            + ", so skipping .. exception: " + pe.getMessage());
                }
            }
        }
        if (tmpDates.size() > 0) {
            // sort all BRduedates, pick the earliest one as the final one
            Collections.sort(tmpDates, new Comparator<Date>() {
                @Override
                public int compare(Date o1, Date o2) {
                    return o1.compareTo(o2);
                }
            });
            ISTExec = tmpDates.get(0);
        }
        tmpDates.clear();
    
        // Process Closeout
        for (ProjectDetailsStatusViewModel i : detailStatus) {
            if (!("NA".equalsIgnoreCase(i.getCloseOutheaderDueDate()))) {
                try {
                    Date t = yFormat.parse(i.getCloseOutheaderDueDate());
                    tmpDates.add(t);
                } catch (ParseException pe) {
                    logger.error("can't parse date from value " + i.getCloseOutheaderDueDate()
                            + ", so skipping .. exception: " + pe.getMessage());
                }
            }
        }
        if (tmpDates.size() > 0) {
            // sort all BRduedates, pick the earliest one as the final one
            Collections.sort(tmpDates, new Comparator<Date>() {
                @Override
                public int compare(Date o1, Date o2) {
                    return o1.compareTo(o2);
                }
            });
            CloseOut = tmpDates.get(0);
        }
        tmpDates.clear();
    
        // Process Agile
        for (ProjectDetailsStatusViewModel i : detailStatus) {
            if (!("NA".equalsIgnoreCase(i.getAgileheaderDueDate()))) {
                try {
                    Date t = yFormat.parse(i.getAgileheaderDueDate());
                    tmpDates.add(t);
                } catch (ParseException pe) {
                    logger.error("can't parse date from value " + i.getAgileheaderDueDate()
                            + ", so skipping .. exception: " + pe.getMessage());
                }
            }
        }
        if (tmpDates.size() > 0) {
            // sort all BRduedates, pick the earliest one as the final one
            Collections.sort(tmpDates, new Comparator<Date>() {
                @Override
                public int compare(Date o1, Date o2) {
                    return o1.compareTo(o2);
                }
            });
            Agile = tmpDates.get(0);
        }
        tmpDates.clear();
    
        // TODO
        if (BR != null) {
            try {
                for (ProjectDetailsStatusViewModel i : detailStatus) {
                    i.setBRheaderDueDate(yFormat.format(BR));
                }
            } catch (Exception pe) {
                logger.error("Can not convert BR from Date " + BR.toString() + ", pe: " + pe.getMessage()
                        + ".  Skipping..");
            }
        }
    
        if (SR != null) {
            try {
                for (ProjectDetailsStatusViewModel i : detailStatus) {
                    i.setSRheaderDueDate(yFormat.format(SR));
                }
            } catch (Exception pe) {
                logger.error("Can not convert SR from Date " + SR.toString() + ", pe: " + pe.getMessage()
                        + ".  Skipping..");
            }
        }
    
        if (HLD != null) {
            try {
                for (ProjectDetailsStatusViewModel i : detailStatus) {
                    i.setHLDheaderDueDate(yFormat.format(HLD));
                }
            } catch (Exception pe) {
                logger.error("Can not convert HLD from Date " + HLD.toString() + ", pe: " + pe.getMessage()
                        + ".  Skipping..");
            }
        }
    
        if (AID != null) {
            try {
                for (ProjectDetailsStatusViewModel i : detailStatus) {
                    i.setAIDheaderDueDate(yFormat.format(AID));
                }
            } catch (Exception pe) {
                logger.error("Can not convert AID from Date " + AID.toString() + ", pe: " + pe.getMessage()
                        + ".  Skipping..");
            }
        }
    
        if (AD != null) {
            try {
                for (ProjectDetailsStatusViewModel i : detailStatus) {
                    i.setDESheaderDueDate(yFormat.format(AD));
                }
            } catch (Exception pe) {
                logger.error("Can not convert AD from Date " + AD.toString() + ", pe: " + pe.getMessage()
                        + ".  Skipping..");
            }
        }
    
        if (DEV != null) {
            try {
                for (ProjectDetailsStatusViewModel i : detailStatus) {
                    i.setDEVheaderDueDate(yFormat.format(DEV));
                }
            } catch (Exception pe) {
                logger.error("Can not convert DEV from Date " + DEV.toString() + ", pe: " + pe.getMessage()
                        + ".  Skipping..");
            }
        }
    
        if (IST != null) {
            try {
                for (ProjectDetailsStatusViewModel i : detailStatus) {
                    i.setISTheaderDueDate(yFormat.format(IST));
                }
            } catch (Exception pe) {
                logger.error("Can not convert IST from Date " + IST.toString() + ", pe: " + pe.getMessage()
                        + ".  Skipping..");
            }
        }
    
        if (ISTExec != null) {
            try {
                for (ProjectDetailsStatusViewModel i : detailStatus) {
                    i.setISTExecheaderDueDate(yFormat.format(ISTExec));
                }
            } catch (Exception pe) {
                logger.error("Can not convert ISTExec from Date " + ISTExec.toString() + ", pe: " + pe.getMessage()
                        + ".  Skipping..");
            }
        }
    
        if (CloseOut != null) {
            try {
                for (ProjectDetailsStatusViewModel i : detailStatus) {
                    i.setCloseOutheaderDueDate(yFormat.format(CloseOut));
                }
            } catch (Exception pe) {
                logger.error("Can not convert CloseOut from Date " + CloseOut.toString() + ", pe: "
                        + pe.getMessage() + ".  Skipping..");
            }
        }
    
        if (Agile != null) {
            try {
                for (ProjectDetailsStatusViewModel i : detailStatus) {
                    i.setAgileheaderDueDate(yFormat.format(Agile));
                }
            } catch (Exception pe) {
                logger.error("Can not convert Agile from Date " + Agile.toString() + ", pe: " + pe.getMessage()
                        + ".  Skipping..");
            }
        }
    
        return detailStatus;
    }