Package com.cin.dto

Examples of com.cin.dto.UserDTO


  public int calculateQuoteForPolicy(InsurencePolicyDTO policy)
      throws MissingInformationException, InvalidInputValueException {

    try{
      UserDTO user = retrieveUserRecord(policy.getUserSSN());

      if( policy.getDeductibles() < 0 ){
        throw new InvalidInputValueException("Deductibles can't be negative.");
      }
      if( policy.getPropertyName() == null || policy.getPropertyName().equals("")){
        throw new MissingInputValueException("Property name is missing.");
      }
      if( policy.getPropertyValue() <= 0 ){
        throw new InvalidInputValueException("Property value must be positive.");
      }
     
      double quote = (policy.getPropertyValue() - policy.getDeductibles()) * 0.1;
      if (policy.getDeductibles() > policy.getPropertyValue() * 0.2) {
        quote *= 0.90;
      } else if (policy.getDeductibles() > policy.getPropertyValue() * 0.1) {
        quote *= 0.95;
      }

      calculateScoreForUser(user);
      if (user.getScore() >= 90) {
        quote *= 0.90;
      } else if (10 <= user.getScore() && user.getScore() <= 75) {
        double ration = 2.0 - user.getScore() / 100.0;
        quote = quote * ration;
      } else if (user.getScore() < 10) {
        quote = 2 * quote;
      }

      if( quote < 1 ){
        quote = 1;
View Full Code Here


    assertTrue(cache.hasUser(101));
    assertTrue(cache.hasUser(102));
    assertTrue(cache.hasUser(103));
   
    // new user
    UserDTO user = new UserDTO(100);
    user.setScore(51);
    user.setZipCode("12345");

    cache.addUser(user);

   
    assertTrue(cache.hasUser(100));
    assertEquals(51, cache.getScore(100));

    // try adding the user again
    try {
      UserDTO user2 = new UserDTO(100);
      cache.addUser(user2);
      fail("Shouldn't add same user 2nd time.");
    } catch (IllegalStateException ex) {
    }
View Full Code Here

  }
 
  @Test
  public void testMissingZip() {
    // user without zip is added and removed
    UserDTO user = new UserDTO(100);
    user.setScore(51);
   
    cache.addUser(user);
    cache.clear(user.getSsn());
    assertFalse(cache.hasUser(user.getSsn()));
  }
View Full Code Here

    // check if customer exists
    if (invitation.getCustomer() == null) {
      throw new IllegalArgumentException(
          "Invitation must include customer.");
    }
    UserDTO customer;
    try{
      customer = retrieveUserRecord(invitation.getCustomer());
    }catch(UserNotFoundException e){
      throw new UserNotFoundException(
          "Customer with ssn "+ invitation.getCustomer().getSsn()+" cannot be found.");
    }

    // check if agent exists
    if (invitation.getAgent() == null) {
      throw new IllegalArgumentException("Invitation must include agent.");
    }
   
    UserDTO agent;
    try{
      agent = retrieveUserRecord(invitation.getAgent());
    } catch(UserNotFoundException e){
      throw new UserNotFoundException(
          "Agent with ssn " + invitation.getAgent().getSsn() + " cannot be found.");
View Full Code Here

   */
  public InsurencePolicyDTO purchasePolicy(InsurencePolicyDTO policy)
      throws PurchaseException, InvalidInputValueException, MissingInformationException {

    // verify all data of the policy
    UserDTO user;
    try{
      user = retrieveUserRecord(policy.getUserSSN());
    }catch(UserNotFoundException e){
      throw new UserNotFoundException("Customer on the policy is not registered.");
    }
   
    calculateScoreForUser(user);
    if (user.getScore() <= 0) {
      throw new PurchaseException("Customer is not eligible for policy.");
    }

    int newQuote = calculateQuoteForPolicy(policy);
    if (newQuote != policy.getQuote()) {
View Full Code Here

    }
  }
 
  public void recommendUser(UserDTO pUser) {
    // TODO: this is not finished
    UserDTO user = userFactory.findUserBySsn(pUser.getSsn());
    if(user.getJobDetails() != null) {
      int occCode = user.getJobDetails().getOccupationCode();
      int indCode = user.getJobDetails().getIndustryCode();
     
    }
  }
View Full Code Here

    return userFactory.findUserBySsn(user.getSsn());
  }
 
  public UserDTO createAUser(GenericRequest greq)
  {
    UserDTO theUser = new UserDTO ();
    theUser = userFactory.addUser(greq.getUser());
   
    return theUser ;
  }
View Full Code Here

   
  }

  public UserDTO checkUserExistence(GenericRequest pRequest) {
    // TODO: this can't be right
    UserDTO uDto = new UserDTO();
   
    DataTranslator aTranslator = new DataTranslator();

    if ((uDto = userFactory.findUserBySsn(pRequest.getUser().getSsn())) == null)
    {    System.out.println("Failed to authenticate: SSN not found");
View Full Code Here

 
 
  public UserDTO calculateLikelinessFactor(UserDTO pUser) throws MissingInformationException,PersistenceException {
   
    UserDTO user = userFactory.findUserBySsn(pUser.getSsn());
    StatisticsService aStatsService = new StatisticsService();
    StatisticsDTO aUserStateStats = new StatisticsDTO();
    if(user.getZipCode() == null || user.getZipCode().trim().length() > 0) {
     
      throw new MissingInformationException("Location information is missing for user.Update the info and calculate the factor");
    }
    if(user.getJobDetails() != null) {
     
      ZipDTO zip = aRemote.findStateForZip(Integer.parseInt(user.getZipCode()));
     
      if(zip != null) {
     
        aUserStateStats.setState(zip.getState());
      }
      aUserStateStats.setIndustryCode(user.getJobDetails().getIndustryCode());
      aUserStateStats.setOccCode(user.getJobDetails().getOccupationCode());
    }
    GenericResponse aResponse = aStatsService.calculateWeeklyWage(aUserStateStats);
    int userStateAvgWage = 0;
    int numOfStates = 0;
    if(aResponse != null && aResponse.getStatistics() != null
        && aResponse.isResponseStatus()) {
     
      userStateAvgWage = aResponse.getStatistics().getAvgWeekWage();
    }
    List<StateAbbvDTO> theStates = aRemote.findAllStates();
    StatisticsDTO otherStatesStats = new StatisticsDTO();
    for(StateAbbvDTO aState : theStates) {
      String aStateName = aState.getAbbv();
      otherStatesStats.setIndustryCode(user.getJobDetails().getIndustryCode());
      otherStatesStats.setOccCode(user.getJobDetails().getOccupationCode());
      otherStatesStats.setState(aStateName);
      aResponse = aStatsService.calculateWeeklyWage(aUserStateStats);
      if(aResponse != null && aResponse.getStatistics() != null
          && aResponse.isResponseStatus()) {
       
        if(userStateAvgWage < aResponse.getStatistics().getAvgWeekWage()) {
          numOfStates++;
        }
      }
      int aPercentage = 0;
      if(theStates.size() > 0)
      aPercentage = (numOfStates/theStates.size())*100;
      if(aPercentage > ApplicationConstants.ACCEPTABLE_LIMIT_PERCENTAGE) {
        user.setLikelinessFactor(true);
      }
    }
    return user;
  }
View Full Code Here

    Userrecord pEntity = (Userrecord) manager.find(Userrecord.class, pSsn);
    if( pEntity == null ){
      return null;
    } else {
      return new UserDTO(pEntity);
    }
  }
View Full Code Here

TOP

Related Classes of com.cin.dto.UserDTO

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.