use of org.jaffa.applications.jaffa.modules.admin.domain.User in project jaffa-framework by jaffa-projects.
the class UserMaintenanceTx method create.
// .//GEN-END:_prevalidateCreate_1_be
// .//GEN-BEGIN:_create_1_be
/**
* Persists a new 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 create(UserMaintenanceCreateInDto 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);
// Do not allow a Duplicate record
duplicateCheck(uow, input);
// Validate the foreign objects
validateForeignObjects(uow, input);
// Create the domain object
User domain = createDomain(uow, input, false);
uow.add(domain);
domain = postCreate(uow, input, domain, false);
// Commit the changes
uow.commit();
// Print Debug Information for the output
if (log.isDebugEnabled())
log.debug("Successfully created the domain object. Now retrieving the object details.");
if (input.getUserName() == null) {
if (log.isDebugEnabled())
log.debug("The Key is not set completely. Probably using AutoGenerated keys. Cannot re-retrieve the object details. Returning NULL instead");
return null;
}
// 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 prevalidateCreate.
// .//GEN-END:_destroy_2_be
// .//GEN-BEGIN:_prevalidateCreate_1_be
/**
* This method is used to perform prevalidations before creating a new 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 UserMaintenancePrevalidateOutDto prevalidateCreate(UserMaintenanceCreateInDto 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);
// Do not allow a Duplicate record
duplicateCheck(uow, input);
// Validate the foreign objects
validateForeignObjects(uow, input);
// Create the domain object
User domain = createDomain(uow, input, true);
domain = postCreate(uow, input, domain, true);
// Build the outbound dto
UserMaintenancePrevalidateOutDto output = createPrevalidateOutDto(uow, domain, input);
// Print Debug Information for the output
if (log.isDebugEnabled())
log.debug("Output: " + (output != null ? output.toString() : null));
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 prevalidateUpdate.
// .//GEN-END:_retrieve_1_be
// .//GEN-BEGIN:_prevalidateUpdate_1_be
/**
* This method is used to perform prevalidations before updating 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 UserMaintenancePrevalidateOutDto prevalidateUpdate(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, true);
// Build the outbound dto
UserMaintenancePrevalidateOutDto output = createPrevalidateOutDto(uow, domain, input);
// Print Debug Information for the output
if (log.isDebugEnabled())
log.debug("Output: " + (output != null ? output.toString() : null));
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 UserViewerTx method buildDto.
// .//GEN-END:_buildCriteria_3_be
// .//GEN-BEGIN:_buildDto_1_be
private UserViewerOutDto buildDto(UOW uow, Collection results) throws UOWException {
UserViewerOutDto output = null;
Iterator itr = results.iterator();
if (itr.hasNext()) {
// just return the details for the 1st record retrieved.
User user = (User) itr.next();
output = new UserViewerOutDto();
// .//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
output.setUserName(user.getUserName());
// .//GEN-END:_buildDto_UserName_1_be
// .//GEN-BEGIN:_buildDto_FirstName_1_be
output.setFirstName(user.getFirstName());
// .//GEN-END:_buildDto_FirstName_1_be
// .//GEN-BEGIN:_buildDto_LastName_1_be
output.setLastName(user.getLastName());
// .//GEN-END:_buildDto_LastName_1_be
// .//GEN-BEGIN:_buildDto_Status_1_be
output.setStatus(user.getStatus());
// .//GEN-END:_buildDto_Status_1_be
// .//GEN-BEGIN:_buildDto_StatusDescription_1_be
output.setStatusDescription(user.getStatus());
// .//GEN-END:_buildDto_StatusDescription_1_be
// .//GEN-BEGIN:_buildDto_EMailAddress_1_be
output.setEMailAddress(user.getEMailAddress());
// .//GEN-END:_buildDto_EMailAddress_1_be
// .//GEN-BEGIN:_buildDto_CreatedOn_1_be
output.setCreatedOn(user.getCreatedOn());
// .//GEN-END:_buildDto_CreatedOn_1_be
// .//GEN-BEGIN:_buildDto_CreatedBy_1_be
output.setCreatedBy(user.getCreatedBy());
// .//GEN-END:_buildDto_CreatedBy_1_be
// .//GEN-BEGIN:_buildDto_LastUpdatedOn_1_be
output.setLastUpdatedOn(user.getLastUpdatedOn());
// .//GEN-END:_buildDto_LastUpdatedOn_1_be
// .//GEN-BEGIN:_buildDto_LastUpdatedBy_1_be
output.setLastUpdatedBy(user.getLastUpdatedBy());
// .//GEN-END:_buildDto_LastUpdatedBy_1_be
// .//GEN-BEGIN:_buildDto_2_be
// Add related objects, if required
addRelatedDtos(uow, output, user);
// .//GEN-END:_buildDto_2_be
// Add custom code to pass values to the dto //GEN-FIRST:_buildDto_2
// .//GEN-LAST:_buildDto_2
// .//GEN-BEGIN:_buildDto_3_be
}
return output;
}
use of org.jaffa.applications.jaffa.modules.admin.domain.User in project jaffa-framework by jaffa-projects.
the class UserRole method findUserObject.
/**
* Finds the related foreign User object.
* If checkExistenceOnly is false, then the foreign object will be fetched and assigned to the corresponding member variable of this class.
* If checkExistenceOnly is true, then a mere existence check is performed for the foreign object, as oppposed to fetching all the values for that object.
*/
private void findUserObject(boolean checkExistenceOnly) throws ValidationException, FrameworkException {
UOW uow = getUOW();
boolean localUow = false;
try {
if (m_userObject == null && getUserName() != null) {
Criteria criteria = new Criteria();
criteria.setTable(UserMeta.getName());
criteria.addCriteria(UserMeta.USER_NAME, getUserName());
if (checkExistenceOnly)
criteria.addFunction(Criteria.FUNCTION_COUNT, null, Criteria.ID_FUNCTION_COUNT);
Number count = null;
if (uow == null || !uow.isActive()) {
uow = new UOW();
localUow = true;
}
Iterator itr = uow.query(criteria).iterator();
if (itr.hasNext()) {
if (checkExistenceOnly)
count = (Number) ((Map) itr.next()).get(Criteria.ID_FUNCTION_COUNT);
else
m_userObject = (User) itr.next();
}
if (m_userObject == null && (count == null || count.intValue() <= 0))
throw new InvalidForeignKeyException(UserRoleMeta.META_USER_NAME.getLabelToken(), new Object[] { UserMeta.getLabelToken(), UserMeta.META_USER_NAME.getLabelToken() });
}
} finally {
if (localUow && uow != null)
uow.rollback();
}
}
Aggregations