Example usage for java.text NumberFormat setMinimumFractionDigits

List of usage examples for java.text NumberFormat setMinimumFractionDigits

Introduction

In this page you can find the example usage for java.text NumberFormat setMinimumFractionDigits.

Prototype

public void setMinimumFractionDigits(int newValue) 

Source Link

Document

Sets the minimum number of digits allowed in the fraction portion of a number.

Usage

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

private static List<ProjectAppOwnerModel> getProjectAppOwners(String prismId) {
    List<ProjectAppOwnerModel> rc = new ArrayList<ProjectAppOwnerModel>();

    // TODO:  port over to hibernate later
    // logger.error(msgHeader + "getProjectAppOwners called with prismId: "+ prismId);
    ResultSet rs = null;//  ww w .  ja  v  a 2 s  .c om
    Connection conn = null;
    PreparedStatement preparedStatement = null;

    try {
        conn = DBUtility.getDBConnection();
        // SQL query command
        String SQL = " SELECT " + "      apa.UUID " + "      ,apa.DueDate " + "      ,apa.CompletionDate "
                + "      ,apa.PercentageComplete " + "      ,apa.ArtifactName " + "      ,apa.PRISMId "
                + "      ,apa.ApplicationName " + "      ,apa.ModuleId " + "      ,apa.IsPrimaryOwner "
                + "      ,apa.MileStoneId " + "      ,apa.ExecutionPercentage "
                + "      ,apa.ProjectCloseOutPercentage " + "      ,isnull(apa.DateCreated,'') as DateCreated "
                + "      ,apa.UpdatedByUUID " + "      ,apa.SystemNote " + "      ,app.ApplicationId "
                + "  FROM AppProjectArtifactOwners apa join Applications app  "
                + "  On app.ApplicationName = apa.ApplicationName "
                + "  Where apa.PRISMId = ? and apa.isPrimaryOwner = 1 "
                + "  Order by apa.ApplicationName, apa.ArtifactName, apa.UUID ";

        preparedStatement = conn.prepareStatement(SQL);
        preparedStatement.setString(1, prismId);
        rs = preparedStatement.executeQuery();
        int rowCount = 0;

        while (rs.next()) {
            rowCount++;
            SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            SimpleDateFormat yFormat = new SimpleDateFormat("MM/dd/yyyy");
            // for percentage
            NumberFormat defaultFormat = NumberFormat.getPercentInstance();
            defaultFormat.setMinimumFractionDigits(0);

            //
            String uuid = rs.getString("UUID");
            //
            String theDueDate = rs.getString("DueDate");
            String dueDate = yFormat.format(format.parse(theDueDate));
            // 
            String theCompDate = rs.getString("CompletionDate") == null ? "1900-01-01 14:58:00.00"
                    : rs.getString("CompletionDate");
            String completionDate = yFormat.format(format.parse(theCompDate));

            //
            String pCompletedDtr = rs.getString("PercentageComplete") == null ? "0.00"
                    : rs.getString("PercentageComplete");
            double percentComplete = Double.parseDouble(
                    rs.getString("PercentageComplete") == null ? "0" : rs.getString("PercentageComplete"));
            String PercentCompleted = defaultFormat.format(percentComplete);
            //
            String artifactName = rs.getString("ArtifactName");
            //
            String applicationName = rs.getString("ApplicationName");
            //
            String moduleId = rs.getString("ModuleId");
            // 
            String isPrimary = rs.getString("IsPrimaryOwner");
            // 
            String mileStoneId = rs.getString("MileStoneId");
            //
            double ExecPercent = Double.parseDouble(
                    rs.getString("ExecutionPercentage") == null ? "0" : rs.getString("ExecutionPercentage"));
            String ExecutionPercentage = defaultFormat.format(ExecPercent);
            //
            double prjCOPercent = Double.parseDouble(rs.getString("ProjectCloseOutPercentage") == null ? "0"
                    : rs.getString("ProjectCloseOutPercentage"));
            String PrjCloseOutPercentage = defaultFormat.format(prjCOPercent);
            //
            String dCreated = rs.getString("DateCreated");
            String dateCreated = yFormat.format(format.parse(dCreated));
            //
            String updatedByUUID = rs.getString("UpdatedByUUID");
            //
            String systemNote = rs.getString("SystemNote");
            //
            String applicationId = rs.getString("ApplicationId");

            // create a projectDetailPersonnel and add it to list
            ProjectAppOwnerModel p = new ProjectAppOwnerModel();
            p.setUUID(uuid);
            p.setDueDate(dueDate);
            p.setCompletionDate(completionDate);
            p.setPercentageComplete(PercentCompleted);
            p.setPercentageCompleteStr(pCompletedDtr);
            p.setArtifactName(artifactName);
            p.setPrismId(prismId);
            p.setApplicationName(applicationName);
            p.setModuleId(moduleId);
            p.setIsPrimaryOwner(isPrimary.equalsIgnoreCase("1"));
            p.setMileStoneId(mileStoneId);
            p.setExecutionPercentage(ExecutionPercentage);
            p.setProjectCloseOutPercentage(PrjCloseOutPercentage);
            p.setDateCreated(dateCreated);
            p.setUpdatedByUUID(updatedByUUID);
            p.setSystemNote(systemNote);
            p.setApplicationId(applicationId);

            rc.add(p);
        }
        logger.error(msgHeader + "getProjectAppOwners called, got results: " + rowCount);
    } catch (SQLException e) {
        logger.error(e.getMessage());
    } catch (Exception e) {
        logger.error(e.getMessage());
    } finally {
        try {
            if (rs != null)
                rs.close();
        } catch (Exception e) {
        }
        ;
        try {
            if (preparedStatement != null)
                preparedStatement.close();
        } catch (Exception e) {
        }
        ;
        try {
            if (conn != null)
                conn.close();
        } catch (Exception e) {
        }
        ;
    }

    return rc;
}

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

@RequestMapping(value = "/addProjectStatus/{prismId}/{applicationId}", method = RequestMethod.POST)
public String addProjectStatus(@PathVariable("prismId") String prismId,
        @PathVariable("applicationId") String applicationId,
        @Valid @ModelAttribute("projectStatusViewModel") ProjectStatusViewModel projectStatusViewModel,
        HttpServletRequest request, BindingResult result) {
    String sessionUser = (String) request.getSession().getAttribute("loginUser");
    if (sessionUser == null || sessionUser.isEmpty() || "Not Logged In".equalsIgnoreCase(sessionUser)) {
        request.getSession().setAttribute("loginUser", "Not Logged In");
        logger.error("[Merce]: user not logged in.. redirecting to logout page");
        return "redirect:/logout";
    }//from   w w w.  java 2  s.com

    NumberFormat defaultFormat = NumberFormat.getPercentInstance();
    defaultFormat.setMinimumFractionDigits(0);
    SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy");
    int appId = Integer.parseInt(applicationId);
    String appName = DataService.getApplicationNameByPrismIdApplicationId(appId, prismId);
    int impactTypeId = DataService.getImpactTypeIdByPrismIdAndApplicationName(prismId, appName);

    if (result.hasErrors()) {
        StringBuilder sb = new StringBuilder();
        for (ObjectError r : result.getAllErrors()) {
            sb.append(r.getDefaultMessage());
        }
        logger.error(msgHeader + " addProjectStatus errors: " + sb.toString());
    }

    // refresh cahce?
    if (artifactHistory != null) {
        artifactHistory = null;
    }
    DataService.initializeProjectAppOwnerByPrismId(prismId);

    // TO
    if (impactTypeId != 3 && impactTypeId != 4) {
        // prefix. Agile
        if (projectStatusViewModel.getAgilePercentageComplete() == null
                || projectStatusViewModel.getAgilePercentageComplete().isEmpty()) {
            logger.error(msgHeader + " addProjectStatus Agile is not set, so keep record in database as is.");
        } else {
            logger.error(msgHeader + " addProjectStatus Agile is set, updateing ..");

            ProjectAppOwnerModel mod = DataService.getProjectAppOwnerByPrismIdAppNameArtifactNamePrimaryOwner(
                    prismId, Integer.valueOf(applicationId), PiratesConstants.AGILE);
            if (mod != null && !mod.getPercentageComplete()
                    .equalsIgnoreCase(defaultFormat.format(
                            Double.parseDouble(projectStatusViewModel.getAgilePercentageComplete() == null ? "0"
                                    : projectStatusViewModel.getAgilePercentageComplete())))) {
                ProjectAppOwnerModel p = cloneProjectAppOwnerModel(mod);
                // now change the percentage completed to user input value
                mod.setPercentageComplete(projectStatusViewModel.getAgilePercentageComplete());

                // check if percentcomplete user entered is 100%, if so, check if the datecreated has been changed to an earlier date
                try {
                    if (projectStatusViewModel.getAgilePercentageComplete().equalsIgnoreCase("1.00")
                            && !sdf.format(sdf.parse(projectStatusViewModel.getAgileDateCreatedT()))
                                    .equals(sdf.format(new Date()))) {
                        logger.error(
                                "100% complete and user changed datecreated to a date that's other than today, using this date instead of today.. "
                                        + projectStatusViewModel.getAgileDateCreatedT());
                        mod.setDateCreated(projectStatusViewModel.getAgileDateCreatedT());
                    } else {
                        logger.error("User chooses to use today as datecreated, using it .. "
                                + projectStatusViewModel.getAgileDateCreatedT());
                        mod.setDateCreated(projectStatusViewModel.getAgileDateCreatedT());
                    }
                } catch (ParseException ex) {
                    logger.error(msgHeader + ex.getMessage());
                }

                DataService.processProjectStatusForArtifact(mod, PiratesConstants.AGILE, sessionUser, p);
            } else {
                if (mod != null && mod.getPercentageComplete()
                        .equalsIgnoreCase(defaultFormat.format(Double
                                .parseDouble(projectStatusViewModel.getAgilePercentageComplete() == null ? "0"
                                        : projectStatusViewModel.getAgilePercentageComplete())))) {
                    logger.error("Agile has same value as in the DB, ignoring..");
                } else {
                    logger.error(
                            "addProjectStatus error DataService.getProjectAppOwnerByPrismIdAppNameArtifactNamePrimaryOwner returned null");
                }
            }
        }

        // 1. BR
        if (projectStatusViewModel.getBRPercentageComplete() == null
                || projectStatusViewModel.getBRPercentageComplete().isEmpty()) {
            logger.error(msgHeader + " addProjectStatus BR is not set, so keep record in database as is.");
        } else {
            logger.error(msgHeader + " addProjectStatus BR is set, updateing ..");

            ProjectAppOwnerModel mod = DataService.getProjectAppOwnerByPrismIdAppNameArtifactNamePrimaryOwner(
                    prismId, Integer.valueOf(applicationId), PiratesConstants.BR);
            if (mod != null && !mod.getPercentageComplete()
                    .equalsIgnoreCase(defaultFormat.format(
                            Double.parseDouble(projectStatusViewModel.getBRPercentageComplete() == null ? "0"
                                    : projectStatusViewModel.getBRPercentageComplete())))) {
                ProjectAppOwnerModel p = cloneProjectAppOwnerModel(mod);
                // now change the percentage completed to user input value
                mod.setPercentageComplete(projectStatusViewModel.getBRPercentageComplete());

                // check if percentcomplete user entered is 100%, if so, check if the datecreated has been changed to an earlier date
                try {
                    if (projectStatusViewModel.getBRPercentageComplete().equalsIgnoreCase("1.00")
                            && !sdf.format(sdf.parse(projectStatusViewModel.getBRDateCreatedT()))
                                    .equals(sdf.format(new Date()))) {
                        logger.error(
                                "100% complete and user changed datecreated to a date that's other than today, using this date instead of today.. "
                                        + projectStatusViewModel.getBRDateCreatedT());
                        mod.setDateCreated(projectStatusViewModel.getBRDateCreatedT());

                    } else {
                        logger.error("User chooses to use today as datecreated, using it .. "
                                + projectStatusViewModel.getBRDateCreatedT());
                        mod.setDateCreated(projectStatusViewModel.getBRDateCreatedT());
                    }
                } catch (ParseException ex) {
                    logger.error(msgHeader + ex.getMessage());
                }

                DataService.processProjectStatusForArtifact(mod, PiratesConstants.BR, sessionUser, p);
            } else {
                if (mod != null && mod.getPercentageComplete()
                        .equalsIgnoreCase(defaultFormat.format(Double
                                .parseDouble(projectStatusViewModel.getBRPercentageComplete() == null ? "0"
                                        : projectStatusViewModel.getBRPercentageComplete())))) {
                    logger.error("BR has same value as in the DB, ignoring..");
                } else {
                    logger.error(
                            "addProjectStatus error DataService.getProjectAppOwnerByPrismIdAppNameArtifactNamePrimaryOwner returned null");
                }
            }
        }

        // 2. SR
        if (projectStatusViewModel.getSRPercentageComplete() == null
                || projectStatusViewModel.getSRPercentageComplete().isEmpty()) {
            logger.error(msgHeader + " addProjectStatus SR is not set, so keep record in database as is.");
        } else {
            logger.error(msgHeader + " addProjectStatus SR is set, updateing ..");
            ProjectAppOwnerModel mod = DataService.getProjectAppOwnerByPrismIdAppNameArtifactNamePrimaryOwner(
                    prismId, Integer.valueOf(applicationId), PiratesConstants.SR);
            if (mod != null && !mod.getPercentageComplete()
                    .equalsIgnoreCase(defaultFormat.format(
                            Double.parseDouble(projectStatusViewModel.getSRPercentageComplete() == null ? "0"
                                    : projectStatusViewModel.getSRPercentageComplete())))) {
                ProjectAppOwnerModel p = cloneProjectAppOwnerModel(mod);
                // now change the percentage completed to user input value
                mod.setPercentageComplete(projectStatusViewModel.getSRPercentageComplete());

                // check if percentcomplete user entered is 100%, if so, check if the datecreated has been changed to an earlier date
                try {
                    if (projectStatusViewModel.getSRPercentageComplete().equalsIgnoreCase("1.00")
                            && !sdf.format(sdf.parse(projectStatusViewModel.getSRDateCreatedT()))
                                    .equals(sdf.format(new Date()))) {
                        logger.error(
                                "100% complete and user changed datecreated to a date that's other than today, using this date instead of today.. "
                                        + projectStatusViewModel.getSRDateCreatedT());
                        mod.setDateCreated(projectStatusViewModel.getSRDateCreatedT());

                    } else {
                        logger.error("User chooses to use today as datecreated, using it .. "
                                + projectStatusViewModel.getSRDateCreatedT());
                        mod.setDateCreated(projectStatusViewModel.getSRDateCreatedT());
                    }
                } catch (ParseException ex) {
                    logger.error(msgHeader + ex.getMessage());
                }

                DataService.processProjectStatusForArtifact(mod, PiratesConstants.SR, sessionUser, p);
            } else {
                if (mod != null && mod.getPercentageComplete()
                        .equalsIgnoreCase(defaultFormat.format(Double
                                .parseDouble(projectStatusViewModel.getSRPercentageComplete() == null ? "0"
                                        : projectStatusViewModel.getSRPercentageComplete())))) {
                    logger.error("SR has same value as in the DB, ignoring..");
                } else {
                    logger.error(
                            "addProjectStatus error DataService.getProjectAppOwnerByPrismIdAppNameArtifactNamePrimaryOwner returned null");
                }

            }
        }

        // 3. HLD
        if (projectStatusViewModel.getHLDPercentageComplete() == null
                || projectStatusViewModel.getHLDPercentageComplete().isEmpty()) {
            logger.error(msgHeader + " addProjectStatus HLD is not set, so keep record in database as is.");
        } else {
            logger.error(
                    msgHeader + " addProjectStatus HLD is set, updateing .. " + prismId + ", " + applicationId);
            ProjectAppOwnerModel mod = DataService.getProjectAppOwnerByPrismIdAppNameArtifactNamePrimaryOwner(
                    prismId, Integer.valueOf(applicationId), PiratesConstants.HLD);
            if (mod != null && !mod.getPercentageComplete()
                    .equalsIgnoreCase(defaultFormat.format(
                            Double.parseDouble(projectStatusViewModel.getHLDPercentageComplete() == null ? "0"
                                    : projectStatusViewModel.getHLDPercentageComplete())))) {
                ProjectAppOwnerModel p = cloneProjectAppOwnerModel(mod);
                // now change the percentage completed to user input value
                mod.setPercentageComplete(projectStatusViewModel.getHLDPercentageComplete());

                // check if percentcomplete user entered is 100%, if so, check if the datecreated has been changed to an earlier date
                try {
                    if (projectStatusViewModel.getHLDPercentageComplete().equalsIgnoreCase("1.00")
                            && !sdf.format(sdf.parse(projectStatusViewModel.getHLDDateCreatedT()))
                                    .equals(sdf.format(new Date()))) {
                        logger.error(
                                "100% complete and user changed datecreated to a date that's other than today, using this date instead of today.. "
                                        + projectStatusViewModel.getHLDDateCreatedT());
                        mod.setDateCreated(projectStatusViewModel.getHLDDateCreatedT());

                    } else {
                        logger.error("User chooses to use today as datecreated, using it .. "
                                + projectStatusViewModel.getHLDDateCreatedT());
                        mod.setDateCreated(projectStatusViewModel.getHLDDateCreatedT());
                    }
                } catch (ParseException ex) {
                    logger.error(msgHeader + ex.getMessage());
                }

                DataService.processProjectStatusForArtifact(mod, PiratesConstants.HLD, sessionUser, p);
            } else {
                if (mod != null && mod.getPercentageComplete()
                        .equalsIgnoreCase(defaultFormat.format(Double
                                .parseDouble(projectStatusViewModel.getHLDPercentageComplete() == null ? "0"
                                        : projectStatusViewModel.getHLDPercentageComplete())))) {
                    logger.error("HLD has same value as in the DB, ignoring..");
                } else {
                    logger.error(
                            "addProjectStatus error DataService.getProjectAppOwnerByPrismIdAppNameArtifactNamePrimaryOwner returned null");
                }
            }
        }

        // 4. AID
        if (projectStatusViewModel.getAIDPercentageComplete() == null
                || projectStatusViewModel.getAIDPercentageComplete().isEmpty()) {
            logger.error(msgHeader + " addProjectStatus AID is not set, so keep record in database as is.");
        } else {
            logger.error(msgHeader + " addProjectStatus AID is set, updateing ..");
            ProjectAppOwnerModel mod = DataService.getProjectAppOwnerByPrismIdAppNameArtifactNamePrimaryOwner(
                    prismId, Integer.valueOf(applicationId), PiratesConstants.AID);
            if (mod != null && !mod.getPercentageComplete()
                    .equalsIgnoreCase(defaultFormat.format(
                            Double.parseDouble(projectStatusViewModel.getAIDPercentageComplete() == null ? "0"
                                    : projectStatusViewModel.getAIDPercentageComplete())))) {
                ProjectAppOwnerModel p = cloneProjectAppOwnerModel(mod);
                // now change the percentage completed to user input value
                mod.setPercentageComplete(projectStatusViewModel.getAIDPercentageComplete());

                // check if percentcomplete user entered is 100%, if so, check if the datecreated has been changed to an earlier date
                try {
                    if (projectStatusViewModel.getAIDPercentageComplete().equalsIgnoreCase("1.00")
                            && !sdf.format(sdf.parse(projectStatusViewModel.getAIDDateCreatedT()))
                                    .equals(sdf.format(new Date()))) {
                        logger.error(
                                "100% complete and user changed datecreated to a date that's other than today, using this date instead of today.. "
                                        + projectStatusViewModel.getAIDDateCreatedT());
                        mod.setDateCreated(projectStatusViewModel.getAIDDateCreatedT());

                    } else {
                        logger.error("User chooses to use today as datecreated, using it .. "
                                + projectStatusViewModel.getAIDDateCreatedT());
                        mod.setDateCreated(projectStatusViewModel.getAIDDateCreatedT());
                    }
                } catch (ParseException ex) {
                    logger.error(msgHeader + ex.getMessage());
                }

                DataService.processProjectStatusForArtifact(mod, PiratesConstants.AID, sessionUser, p);
            } else {
                if (mod != null && mod.getPercentageComplete()
                        .equalsIgnoreCase(defaultFormat.format(Double
                                .parseDouble(projectStatusViewModel.getAIDPercentageComplete() == null ? "0"
                                        : projectStatusViewModel.getAIDPercentageComplete())))) {
                    logger.error("AID has same value as in the DB, ignoring..");
                } else {
                    logger.error(
                            "addProjectStatus error DataService.getProjectAppOwnerByPrismIdAppNameArtifactNamePrimaryOwner returned null");
                }
            }
        }

        // 5. DES
        if (projectStatusViewModel.getDESPercentageComplete() == null
                || projectStatusViewModel.getDESPercentageComplete().isEmpty()) {
            logger.error(msgHeader + " addProjectStatus DES is not set, so keep record in database as is.");
        } else {
            logger.error(msgHeader + " addProjectStatus DES is set, updateing ..");
            ProjectAppOwnerModel mod = DataService.getProjectAppOwnerByPrismIdAppNameArtifactNamePrimaryOwner(
                    prismId, Integer.valueOf(applicationId), PiratesConstants.DES);
            if (mod != null && !mod.getPercentageComplete()
                    .equalsIgnoreCase(defaultFormat.format(
                            Double.parseDouble(projectStatusViewModel.getDESPercentageComplete() == null ? "0"
                                    : projectStatusViewModel.getDESPercentageComplete())))) {
                ProjectAppOwnerModel p = cloneProjectAppOwnerModel(mod);
                // now change the percentage completed to user input value
                mod.setPercentageComplete(projectStatusViewModel.getDESPercentageComplete());

                // check if percentcomplete user entered is 100%, if so, check if the datecreated has been changed to an earlier date
                try {
                    if (projectStatusViewModel.getDESPercentageComplete().equalsIgnoreCase("1.00")
                            && !sdf.format(sdf.parse(projectStatusViewModel.getDESDateCreatedT()))
                                    .equals(sdf.format(new Date()))) {
                        logger.error(
                                "100% complete and user changed datecreated to a date that's other than today, using this date instead of today.. "
                                        + projectStatusViewModel.getDESDateCreatedT());
                        mod.setDateCreated(projectStatusViewModel.getDESDateCreatedT());

                    } else {
                        logger.error("User chooses to use today as datecreated, using it .. "
                                + projectStatusViewModel.getDESDateCreatedT());
                        mod.setDateCreated(projectStatusViewModel.getDESDateCreatedT());
                    }
                } catch (ParseException ex) {
                    logger.error(msgHeader + ex.getMessage());
                }

                DataService.processProjectStatusForArtifact(mod, PiratesConstants.DES, sessionUser, p);
            } else {
                if (mod != null && mod.getPercentageComplete()
                        .equalsIgnoreCase(defaultFormat.format(Double
                                .parseDouble(projectStatusViewModel.getDESPercentageComplete() == null ? "0"
                                        : projectStatusViewModel.getDESPercentageComplete())))) {
                    logger.error("DES has same value as in the DB, ignoring..");
                } else {
                    logger.error(
                            "addProjectStatus error DataService.getProjectAppOwnerByPrismIdAppNameArtifactNamePrimaryOwner returned null");
                }
            }
        }

        // 6. DEV
        if (projectStatusViewModel.getDEVPercentageComplete() == null
                || projectStatusViewModel.getDEVPercentageComplete().isEmpty()) {
            logger.error(msgHeader + " addProjectStatus DEV is not set, so keep record in database as is.");
        } else {
            logger.error(msgHeader + " addProjectStatus DEV is set, updateing ..");
            ProjectAppOwnerModel mod = DataService.getProjectAppOwnerByPrismIdAppNameArtifactNamePrimaryOwner(
                    prismId, Integer.valueOf(applicationId), PiratesConstants.DEV);
            if (mod != null && !mod.getPercentageComplete()
                    .equalsIgnoreCase(defaultFormat.format(
                            Double.parseDouble(projectStatusViewModel.getDEVPercentageComplete() == null ? "0"
                                    : projectStatusViewModel.getDEVPercentageComplete())))) {
                ProjectAppOwnerModel p = cloneProjectAppOwnerModel(mod);
                // now change the percentage completed to user input value
                mod.setPercentageComplete(projectStatusViewModel.getDEVPercentageComplete());

                // check if percentcomplete user entered is 100%, if so, check if the datecreated has been changed to an earlier date
                try {
                    if (projectStatusViewModel.getDEVPercentageComplete().equalsIgnoreCase("1.00")
                            && !sdf.format(sdf.parse(projectStatusViewModel.getDEVDateCreatedT()))
                                    .equals(sdf.format(new Date()))) {
                        logger.error(
                                "100% complete and user changed datecreated to a date that's other than today, using this date instead of today.. "
                                        + projectStatusViewModel.getDEVDateCreatedT());
                        mod.setDateCreated(projectStatusViewModel.getDEVDateCreatedT());

                    } else {
                        logger.error("User chooses to use today as datecreated, using it .. "
                                + projectStatusViewModel.getDEVDateCreatedT());
                        mod.setDateCreated(projectStatusViewModel.getDEVDateCreatedT());
                    }
                } catch (ParseException ex) {
                    logger.error(msgHeader + ex.getMessage());
                }

                DataService.processProjectStatusForArtifact(mod, PiratesConstants.DEV, sessionUser, p);
            } else {
                if (mod != null && mod.getPercentageComplete()
                        .equalsIgnoreCase(defaultFormat.format(Double
                                .parseDouble(projectStatusViewModel.getDEVPercentageComplete() == null ? "0"
                                        : projectStatusViewModel.getDEVPercentageComplete())))) {
                    logger.error("DEV has same value as in the DB, ignoring..");
                } else {
                    logger.error(
                            "addProjectStatus error DataService.getProjectAppOwnerByPrismIdAppNameArtifactNamePrimaryOwner returned null");
                }
            }
        }

    } // end not impacttypeid = 3, to and tso 4

    // 7. IST
    if (projectStatusViewModel.getISTPercentageComplete() == null
            || projectStatusViewModel.getISTPercentageComplete().isEmpty()) {
        logger.error(msgHeader + " addProjectStatus IST is not set, so keep record in database as is.");
    } else {
        logger.error(msgHeader + " addProjectStatus IST is set, updateing ..");
        ProjectAppOwnerModel mod = DataService.getProjectAppOwnerByPrismIdAppNameArtifactNamePrimaryOwner(
                prismId, Integer.valueOf(applicationId), PiratesConstants.IST);
        if (mod != null && !mod.getPercentageComplete()
                .equalsIgnoreCase(defaultFormat.format(
                        Double.parseDouble(projectStatusViewModel.getISTPercentageComplete() == null ? "0"
                                : projectStatusViewModel.getISTPercentageComplete())))) {
            ProjectAppOwnerModel p = cloneProjectAppOwnerModel(mod);
            // now change the percentage completed to user input value
            mod.setPercentageComplete(projectStatusViewModel.getISTPercentageComplete());

            // check if percentcomplete user entered is 100%, if so, check if the datecreated has been changed to an earlier date
            try {
                if (projectStatusViewModel.getISTPercentageComplete().equalsIgnoreCase("1.00")
                        && !sdf.format(sdf.parse(projectStatusViewModel.getISTDateCreatedT()))
                                .equals(sdf.format(new Date()))) {
                    logger.error(
                            "100% complete and user changed datecreated to a date that's other than today, using this date instead of today.. "
                                    + projectStatusViewModel.getISTDateCreatedT());
                    mod.setDateCreated(projectStatusViewModel.getISTDateCreatedT());

                } else {
                    logger.error("User chooses to use today as datecreated, using it .. "
                            + projectStatusViewModel.getISTDateCreatedT());
                    mod.setDateCreated(projectStatusViewModel.getISTDateCreatedT());
                }
            } catch (ParseException ex) {
                logger.error(msgHeader + ex.getMessage());
            }

            DataService.processProjectStatusForArtifact(mod, PiratesConstants.IST, sessionUser, p);
        } else {
            if (mod != null && mod.getPercentageComplete()
                    .equalsIgnoreCase(defaultFormat.format(
                            Double.parseDouble(projectStatusViewModel.getISTPercentageComplete() == null ? "0"
                                    : projectStatusViewModel.getISTPercentageComplete())))) {
                logger.error("IST has same value as in the DB, ignoring..");
            } else {
                logger.error(
                        "addProjectStatus error DataService.getProjectAppOwnerByPrismIdAppNameArtifactNamePrimaryOwner returned null");
            }
        }
    }

    // 8. ISTExec
    if (projectStatusViewModel.getISTExecPercentageComplete() == null
            || projectStatusViewModel.getISTExecPercentageComplete().isEmpty()) {
        logger.error(msgHeader + " addProjectStatus ISTExec is not set, so keep record in database as is.");
    } else {
        logger.error(msgHeader + " addProjectStatus ISTExec is set, updateing ..");
        ProjectAppOwnerModel mod = DataService.getProjectAppOwnerByPrismIdAppNameArtifactNamePrimaryOwner(
                prismId, Integer.valueOf(applicationId), PiratesConstants.ISTExec);
        if (mod != null && !mod.getPercentageComplete()
                .equalsIgnoreCase(defaultFormat.format(
                        Double.parseDouble(projectStatusViewModel.getISTExecPercentageComplete() == null ? "0"
                                : projectStatusViewModel.getISTExecPercentageComplete())))) {
            ProjectAppOwnerModel p = cloneProjectAppOwnerModel(mod);
            // now change the percentage completed to user input value
            mod.setPercentageComplete(projectStatusViewModel.getISTExecPercentageComplete());

            // check if percentcomplete user entered is 100%, if so, check if the datecreated has been changed to an earlier date
            try {
                if (projectStatusViewModel.getISTExecPercentageComplete().equalsIgnoreCase("1.00")
                        && !sdf.format(sdf.parse(projectStatusViewModel.getISTExecDateCreatedT()))
                                .equals(sdf.format(new Date()))) {
                    logger.error(
                            "100% complete and user changed datecreated to a date that's other than today, using this date instead of today.. "
                                    + projectStatusViewModel.getISTExecDateCreatedT());
                    mod.setDateCreated(projectStatusViewModel.getISTExecDateCreatedT());

                } else {
                    logger.error("User chooses to use today as datecreated, using it .. "
                            + projectStatusViewModel.getISTExecDateCreatedT());
                    mod.setDateCreated(projectStatusViewModel.getISTExecDateCreatedT());
                }
            } catch (ParseException ex) {
                logger.error(msgHeader + ex.getMessage());
            }

            DataService.processProjectStatusForArtifact(mod, PiratesConstants.ISTExec, sessionUser, p);
        } else {
            if (mod != null && mod.getPercentageComplete()
                    .equalsIgnoreCase(defaultFormat.format(Double
                            .parseDouble(projectStatusViewModel.getISTExecPercentageComplete() == null ? "0"
                                    : projectStatusViewModel.getISTExecPercentageComplete())))) {
                logger.error("ISTExec has same value as in the DB, ignoring..");
            } else {
                logger.error(
                        "addProjectStatus error DataService.getProjectAppOwnerByPrismIdAppNameArtifactNamePrimaryOwner returned null");
            }
        }
    }

    if (impactTypeId != 3 && impactTypeId != 4) {
        // 8. CloseOut
        if (projectStatusViewModel.getCloseOutPercentageComplete() == null
                || projectStatusViewModel.getCloseOutPercentageComplete().isEmpty()) {
            logger.error(
                    msgHeader + " addProjectStatus Closeout is not set, so keep record in database as is.");
        } else {
            logger.error(msgHeader + " addProjectStatus Closeout is set, updateing ..");
            ProjectAppOwnerModel mod = DataService.getProjectAppOwnerByPrismIdAppNameArtifactNamePrimaryOwner(
                    prismId, Integer.valueOf(applicationId), PiratesConstants.CLOSEOUT);
            if (mod != null && !mod.getPercentageComplete()
                    .equalsIgnoreCase(defaultFormat.format(Double
                            .parseDouble(projectStatusViewModel.getCloseOutPercentageComplete() == null ? "0"
                                    : projectStatusViewModel.getCloseOutPercentageComplete())))) {
                ProjectAppOwnerModel p = cloneProjectAppOwnerModel(mod);
                // now change the percentage completed to user input value
                mod.setPercentageComplete(projectStatusViewModel.getCloseOutPercentageComplete());

                // check if percentcomplete user entered is 100%, if so, check if the datecreated has been changed to an earlier date
                try {
                    if (projectStatusViewModel.getCloseOutPercentageComplete().equalsIgnoreCase("1.00")
                            && !sdf.format(sdf.parse(projectStatusViewModel.getCODateCreatedT()))
                                    .equals(sdf.format(new Date()))) {
                        logger.error(
                                "100% complete and user changed datecreated to a date that's other than today, using this date instead of today.. "
                                        + projectStatusViewModel.getCODateCreatedT());
                        mod.setDateCreated(projectStatusViewModel.getCODateCreatedT());

                    } else {
                        logger.error("User chooses to use today as datecreated, using it .. "
                                + projectStatusViewModel.getCODateCreatedT());
                        mod.setDateCreated(projectStatusViewModel.getCODateCreatedT());
                    }
                } catch (ParseException ex) {
                    logger.error(msgHeader + ex.getMessage());
                }

                DataService.processProjectStatusForArtifact(mod, PiratesConstants.CLOSEOUT, sessionUser, p);
            } else {
                if (mod != null && mod.getPercentageComplete()
                        .equalsIgnoreCase(defaultFormat.format(Double.parseDouble(
                                projectStatusViewModel.getCloseOutPercentageComplete() == null ? "0"
                                        : projectStatusViewModel.getCloseOutPercentageComplete())))) {
                    logger.error("CloseOut has same value as in the DB, ignoring..");
                } else {
                    logger.error(
                            "addProjectStatus error DataService.getProjectAppOwnerByPrismIdAppNameArtifactNamePrimaryOwner returned null");
                }
            }
        }
    } // end  && impactTypeId != 4 (TSO) &&  && impactTypeId != 3 (TO)

    // prismId will be considered while expanding the placeholders
    // return "redirect:/impact_pirates/projects/index/{prismId}";
    if (artifactHistory != null) {
        artifactHistory = null;
    }
    DataService.initializeProjectAppOwnerByPrismId(prismId);
    return "redirect:/projects/index/{prismId}";
}