use of org.jaffa.applications.jaffa.modules.admin.domain.User in project jaffa-framework by jaffa-projects.
the class RequestPasswordComponent method sendEmail.
public void sendEmail() {
Criteria criteria = new Criteria();
criteria.setTable(UserMeta.getName());
if (this.getUserName() != null)
criteria.addCriteria(UserMeta.USER_NAME, this.getUserName());
if (this.getEmail() != null)
criteria.addCriteria(UserMeta.E_MAIL_ADDRESS, this.getEmail());
if (!this.getSecurityQuestion().equalsIgnoreCase("None"))
criteria.addCriteria(UserMeta.SECURITY_QUESTION, this.getSecurityQuestion());
if (this.getSecurityAnswer() != null)
criteria.addCriteria(UserMeta.SECURITY_ANSWER, this.getSecurityAnswer());
criteria.addCriteria(UserMeta.STATUS, "A");
try {
UOW uow = new UOW();
if (!uow.query(criteria).isEmpty()) {
StringBuffer body = new StringBuffer();
if (uow.query(criteria).size() > 1) {
body.append("You have " + uow.query(criteria).size() + " Active Accounts");
int counter = 1;
for (Iterator itr = uow.query(criteria).iterator(); itr.hasNext(); ) {
User ur = (User) itr.next();
body.append(", Account " + counter++ + ", User Name is " + ur.getUserName() + ", Security Question is '" + MessageHelper.replaceTokens("[label.Jaffa.User.UserRequest.SecurityQuestion." + ur.getSecurityQuestion() + "]") + "'");
}
} else {
User ur = (User) uow.query(criteria).iterator().next();
if (this.getUserName() != null) {
body.append("You have the following Active Account ");
body.append(", User Name is " + ur.getUserName() + ", Password is " + ur.getPassword() + ".");
} else if (this.getSecurityQuestion() != null && new Long(this.getSecurityQuestion()).equals(ur.getSecurityQuestion()) && (this.getSecurityAnswer().equals(ur.getSecurityAnswer()))) {
body.append("You have the following Active Account ");
body.append(", User Name is " + ur.getUserName() + ", Password is " + ur.getPassword() + ".");
} else {
body.append("You have the following Active Account");
body.append(", User Name is " + ur.getUserName() + ", Security Question is '" + MessageHelper.replaceTokens("[label.Jaffa.User.UserRequest.SecurityQuestion." + ur.getSecurityQuestion() + "]") + "'.");
}
}
EmailerBean email = new EmailerBean();
String[] to = new String[] { this.getEmail() };
try {
email.sendMail(to, "Account Information", body.toString());
} catch (MessagingException e) {
e.printStackTrace();
}
}
} catch (UOWException e) {
e.printStackTrace();
}
}
use of org.jaffa.applications.jaffa.modules.admin.domain.User in project jaffa-framework by jaffa-projects.
the class UserFinderTx method buildDto.
// .//GEN-END:_buildCriteria_3_be
// .//GEN-BEGIN:_buildDto_1_be
private UserFinderOutDto buildDto(UOW uow, Collection results, UserFinderInDto input) throws UOWException {
UserFinderOutDto output = new UserFinderOutDto();
int maxRecords = input.getMaxRecords() != null ? input.getMaxRecords().intValue() : 0;
int counter = 0;
for (Iterator i = results.iterator(); i.hasNext(); ) {
if (++counter > maxRecords && maxRecords > 0) {
output.setMoreRecordsExist(Boolean.TRUE);
break;
}
UserFinderOutRowDto row = new UserFinderOutRowDto();
User user = (User) i.next();
// .//GEN-END:_buildDto_1_be
// Add custom code before all the setters //GEN-FIRST:_buildDto_1
// .//GEN-LAST:_buildDto_1
// .//GEN-BEGIN:_buildDto_UserName_1_be
row.setUserName(user.getUserName());
// .//GEN-END:_buildDto_UserName_1_be
// .//GEN-BEGIN:_buildDto_FirstName_1_be
row.setFirstName(user.getFirstName());
// .//GEN-END:_buildDto_FirstName_1_be
// .//GEN-BEGIN:_buildDto_LastName_1_be
row.setLastName(user.getLastName());
// .//GEN-END:_buildDto_LastName_1_be
// .//GEN-BEGIN:_buildDto_Status_1_be
row.setStatus(user.getStatus());
// .//GEN-END:_buildDto_Status_1_be
// .//GEN-BEGIN:_buildDto_StatusDescription_1_be
row.setStatusDescription(user.getStatus());
// .//GEN-END:_buildDto_StatusDescription_1_be
// .//GEN-BEGIN:_buildDto_EMailAddress_1_be
row.setEMailAddress(user.getEMailAddress());
// .//GEN-END:_buildDto_EMailAddress_1_be
// .//GEN-BEGIN:_buildDto_CreatedOn_1_be
row.setCreatedOn(user.getCreatedOn());
// .//GEN-END:_buildDto_CreatedOn_1_be
// .//GEN-BEGIN:_buildDto_CreatedBy_1_be
row.setCreatedBy(user.getCreatedBy());
// .//GEN-END:_buildDto_CreatedBy_1_be
// .//GEN-BEGIN:_buildDto_LastUpdatedOn_1_be
row.setLastUpdatedOn(user.getLastUpdatedOn());
// .//GEN-END:_buildDto_LastUpdatedOn_1_be
// .//GEN-BEGIN:_buildDto_LastUpdatedBy_1_be
row.setLastUpdatedBy(user.getLastUpdatedBy());
// .//GEN-END:_buildDto_LastUpdatedBy_1_be
// Add custom code to pass values to the dto //GEN-FIRST:_buildDto_2
// .//GEN-LAST:_buildDto_2
// .//GEN-BEGIN:_buildDto_3_be
output.addRows(row);
}
return output;
}
use of org.jaffa.applications.jaffa.modules.admin.domain.User in project jaffa-framework by jaffa-projects.
the class UserLookupTx method buildDto.
// .//GEN-END:_buildCriteria_3_be
// .//GEN-BEGIN:_buildDto_1_be
private UserLookupOutDto buildDto(UOW uow, Collection results, UserLookupInDto input) throws UOWException {
UserLookupOutDto output = new UserLookupOutDto();
int maxRecords = input.getMaxRecords() != null ? input.getMaxRecords().intValue() : 0;
int counter = 0;
for (Iterator i = results.iterator(); i.hasNext(); ) {
if (++counter > maxRecords && maxRecords > 0) {
output.setMoreRecordsExist(Boolean.TRUE);
break;
}
UserLookupOutRowDto row = new UserLookupOutRowDto();
User user = (User) i.next();
// .//GEN-END:_buildDto_1_be
// Add custom code before all the setters //GEN-FIRST:_buildDto_1
// .//GEN-LAST:_buildDto_1
// .//GEN-BEGIN:_buildDto_UserName_1_be
row.setUserName(user.getUserName());
// .//GEN-END:_buildDto_UserName_1_be
// .//GEN-BEGIN:_buildDto_FirstName_1_be
row.setFirstName(user.getFirstName());
// .//GEN-END:_buildDto_FirstName_1_be
// .//GEN-BEGIN:_buildDto_LastName_1_be
row.setLastName(user.getLastName());
// .//GEN-END:_buildDto_LastName_1_be
// .//GEN-BEGIN:_buildDto_Status_1_be
row.setStatus(user.getStatus());
// .//GEN-END:_buildDto_Status_1_be
// .//GEN-BEGIN:_buildDto_StatusDescription_1_be
row.setStatusDescription(user.getStatus());
// .//GEN-END:_buildDto_StatusDescription_1_be
// .//GEN-BEGIN:_buildDto_EMailAddress_1_be
row.setEMailAddress(user.getEMailAddress());
// .//GEN-END:_buildDto_EMailAddress_1_be
// .//GEN-BEGIN:_buildDto_CreatedOn_1_be
row.setCreatedOn(user.getCreatedOn());
// .//GEN-END:_buildDto_CreatedOn_1_be
// .//GEN-BEGIN:_buildDto_CreatedBy_1_be
row.setCreatedBy(user.getCreatedBy());
// .//GEN-END:_buildDto_CreatedBy_1_be
// .//GEN-BEGIN:_buildDto_LastUpdatedOn_1_be
row.setLastUpdatedOn(user.getLastUpdatedOn());
// .//GEN-END:_buildDto_LastUpdatedOn_1_be
// .//GEN-BEGIN:_buildDto_LastUpdatedBy_1_be
row.setLastUpdatedBy(user.getLastUpdatedBy());
// .//GEN-END:_buildDto_LastUpdatedBy_1_be
// Add custom code to pass values to the dto //GEN-FIRST:_buildDto_2
// .//GEN-LAST:_buildDto_2
// .//GEN-BEGIN:_buildDto_3_be
output.addRows(row);
}
return output;
}
use of org.jaffa.applications.jaffa.modules.admin.domain.User in project jaffa-framework by jaffa-projects.
the class UserMaintenanceTx method update.
// .//GEN-END:_prevalidateUpdate_1_be
// .//GEN-BEGIN:_update_1_be
/**
* Updates an existing instance of User.
* @param input The new values for the domain object.
* @throws ApplicationExceptions This will be thrown if the input contains invalid data.
* @throws FrameworkException Indicates some system error.
* @return The object details.
*/
public UserMaintenanceRetrieveOutDto update(UserMaintenanceUpdateInDto input) throws FrameworkException, ApplicationExceptions {
UOW uow = null;
try {
// Print Debug Information for the input
if (log.isDebugEnabled())
log.debug("Input: " + (input != null ? input.toString() : null));
// create the UOW
uow = new UOW();
// Preprocess the input
preprocess(uow, input);
// Retrieve the object
User domain = load(uow, input);
// Ensure the domain object has not been modified
domainObjectChangedTest(input.getPerformDirtyReadCheck(), domain, input.getLastUpdatedOn());
// Validate the foreign objects
validateForeignObjects(uow, input);
// Update the domain object
updateDomain(uow, input, domain, false);
uow.update(domain);
// Commit the changes
uow.commit();
// Print Debug Information for the output
if (log.isDebugEnabled())
log.debug("Successfully updated the domain object. Now retrieving the object details.");
// Build the outbound dto by performing a retrieve
UserMaintenanceRetrieveInDto retrieveInDto = new UserMaintenanceRetrieveInDto();
retrieveInDto.setHeaderDto(input.getHeaderDto());
retrieveInDto.setUserName(input.getUserName());
UserMaintenanceRetrieveOutDto output = retrieve(retrieveInDto);
return output;
} catch (FrameworkException e) {
// If it is, then re-throw as ApplicationsExceptions, else throw the FrameworkException.
if (e.getCause() != null && e.getCause() instanceof ApplicationExceptions) {
throw (ApplicationExceptions) e.getCause();
} else if (e.getCause() != null && e.getCause() instanceof ApplicationException) {
ApplicationExceptions appExps = new ApplicationExceptions();
appExps.add((ApplicationException) e.getCause());
throw appExps;
} else
throw e;
} finally {
if (uow != null)
uow.rollback();
}
}
use of org.jaffa.applications.jaffa.modules.admin.domain.User in project jaffa-framework by jaffa-projects.
the class UserMaintenanceTx method delete.
/**
* Deletes an existing instance of User.
* @param input The key values for the domain object to be deleted.
* @param uow The delete will be performed using the input UOW.
* @throws ApplicationExceptions This will be thrown if the input contains invalid data.
* @throws FrameworkException Indicates some system error.
*/
public void delete(UserMaintenanceDeleteInDto input, UOW uow) throws FrameworkException, ApplicationExceptions {
// Print Debug Information for the input
if (log.isDebugEnabled())
log.debug("Input: " + (input != null ? input.toString() : null));
// Preprocess the input
preprocess(uow, input);
// Retrieve the object
User domain = load(uow, input);
// Ensure the domain object has not been modified
domainObjectChangedTest(input.getPerformDirtyReadCheck(), domain, input.getLastUpdatedOn());
// Delete the domain object
deleteDomain(uow, input, domain);
// Print Debug Information for the output
if (log.isDebugEnabled())
log.debug("The domain object has been marked for deletion. It will be deleted when the UOW is committed");
}
Aggregations