예제 #1
0
 /**
  * Save a new lead or return true if existing.
  *
  * @param principal
  */
 public boolean saveLead(String principal) {
   Identity identity = identityRepository.findByPrincipal(principal);
   List<Lead> leads = leadRepository.findByPrincipal(principal);
   if (identity == null && (leads == null || leads.size() == 0)) {
     leadRepository.save(new Lead(principal, new Date()));
     return false;
   }
   return true;
 }
예제 #2
0
 /**
  * Create and save a new lead.
  *
  * @param id
  * @param principal
  */
 public Lead createLead(Integer id, String principal) {
   Lead lead = new Lead(id, principal, new Date());
   lead.setToken(createToken());
   return leadRepository.saveAndFlush(lead);
 }