use of org.mifos.framework.util.DateTimeService in project head by mifos.
the class AuditLogServiceImpl method addAuditLogRegistry.
@Override
public void addAuditLogRegistry(QuestionGroupDetail questionGroupDetail, QuestionGroupDetail oldQuestionGroupDetail, int creatorId, int entityId, String source, String event) {
PersonnelBusinessService pbs = new PersonnelBusinessService();
String modifierName;
if (oldQuestionGroupDetail != null && event.toLowerCase().equals(CREATE)) {
String questionGroupName;
String sectionName;
String fieldName;
String fieldValue;
try {
modifierName = pbs.getPersonnel((short) creatorId).getDisplayName();
} catch (ServiceException e) {
modifierName = "";
}
questionGroupName = questionGroupDetail.getTitle();
AuditLog auditLog = new AuditLog(entityId, EntityType.getEntityValue(source.toUpperCase()), modifierName, new DateTimeService().getCurrentJavaSqlDate(), (short) creatorId);
Set<AuditLogRecord> auditLogRecords = new HashSet<AuditLogRecord>();
for (int sectionPosition = 0; sectionPosition < questionGroupDetail.getSectionDetails().size(); sectionPosition++) {
SectionDetail sectionDetail = questionGroupDetail.getSectionDetails().get(sectionPosition);
sectionName = sectionDetail.getName();
for (int questionPosition = 0; questionPosition < sectionDetail.getQuestions().size(); questionPosition++) {
SectionQuestionDetail sectionQuestionDetail = sectionDetail.getQuestions().get(questionPosition);
fieldName = sectionQuestionDetail.getText();
fieldValue = sectionQuestionDetail.getAnswer();
String oldFieldValue = null;
for (SectionDetail oldSectionDetail : oldQuestionGroupDetail.getSectionDetails()) {
if (oldSectionDetail.getName().equals(sectionName)) {
for (SectionQuestionDetail oldSectionQuestionDetail : oldSectionDetail.getQuestions()) {
if (oldSectionQuestionDetail.getText().equals(fieldName)) {
oldFieldValue = oldSectionQuestionDetail.getAnswer();
break;
}
}
break;
}
}
if (!fieldValue.equals("")) {
if (oldFieldValue != null && !oldFieldValue.equals("")) {
if (!oldFieldValue.equals(fieldValue)) {
auditLogRecords.add(new AuditLogRecord(trimField(questionGroupName + "/" + sectionName + "/" + fieldName, 100), trimField(oldFieldValue, 200), trimField(fieldValue, 200), auditLog));
}
} else {
auditLogRecords.add(new AuditLogRecord(trimField(questionGroupName + "/" + sectionName + "/" + fieldName, 100), "-", trimField(fieldValue, 200), auditLog));
}
}
}
}
if (!auditLogRecords.isEmpty()) {
auditLog.addAuditLogRecords(auditLogRecords);
legacyAuditDao.save(auditLog);
}
}
}
use of org.mifos.framework.util.DateTimeService in project head by mifos.
the class PersonAction method translateFormToCreatePersonnelInformationDto.
@SuppressWarnings("unchecked")
private CreateOrUpdatePersonnelInformation translateFormToCreatePersonnelInformationDto(HttpServletRequest request, PersonActionForm personActionForm) throws PageExpiredException, InvalidDateException {
UserContext userContext = getUserContext(request);
PersonnelLevel level = PersonnelLevel.fromInt(getShortValue(personActionForm.getLevel()));
PersonnelStatus personnelStatus = PersonnelStatus.ACTIVE;
if (StringUtils.isNotBlank(personActionForm.getStatus())) {
personnelStatus = PersonnelStatus.getPersonnelStatus(getShortValue(personActionForm.getStatus()));
}
OfficeBO office = (OfficeBO) SessionUtils.getAttribute(PersonnelConstants.OFFICE, request);
if (office == null) {
Short officeId = getShortValue(personActionForm.getOfficeId());
office = this.officeDao.findOfficeById(officeId);
}
Integer title = getIntegerValue(personActionForm.getTitle());
Short preferredLocale = Localization.getInstance().getConfiguredLocaleId();
preferredLocale = getPerefferedLocale(personActionForm, userContext);
Date dob = null;
if (personActionForm.getDob() != null && !personActionForm.getDob().equals("")) {
dob = DateUtils.getDate(personActionForm.getDob());
}
Date dateOfJoiningMFI = null;
if (personActionForm.getDateOfJoiningMFI() != null && !personActionForm.getDateOfJoiningMFI().equals("")) {
dateOfJoiningMFI = DateUtils.getDateAsSentFromBrowser(personActionForm.getDateOfJoiningMFI());
}
Date passwordExpirationDate = null;
if (personActionForm.getPasswordExpirationDate() != null && !personActionForm.getPasswordExpirationDate().equals("")) {
passwordExpirationDate = DateUtils.getDate(personActionForm.getPasswordExpirationDate());
}
List<RoleBO> roles = new ArrayList<RoleBO>();
boolean addFlag = false;
List<RoleBO> selectList = new ArrayList<RoleBO>();
List<RoleBO> masterList = (List<RoleBO>) SessionUtils.getAttribute(PersonnelConstants.ROLEMASTERLIST, request);
if (personActionForm.getPersonnelRoles() != null) {
for (RoleBO role : masterList) {
for (String roleId : personActionForm.getPersonnelRoles()) {
if (roleId != null && role.getId().intValue() == Integer.valueOf(roleId).intValue()) {
selectList.add(role);
addFlag = true;
}
}
}
}
if (addFlag) {
roles = selectList;
}
List<ListElement> roleList = new ArrayList<ListElement>();
for (RoleBO element : roles) {
ListElement listElement = new ListElement(new Integer(element.getId()), element.getName());
roleList.add(listElement);
}
Address address = personActionForm.getAddress();
AddressDto addressDto = new AddressDto(address.getLine1(), address.getLine2(), address.getLine3(), address.getCity(), address.getState(), address.getCountry(), address.getZip(), address.getPhoneNumber());
Long id = null;
if (StringUtils.isNotBlank(personActionForm.getPersonnelId())) {
id = Long.valueOf(personActionForm.getPersonnelId());
}
CreateOrUpdatePersonnelInformation perosonnelInfo = new CreateOrUpdatePersonnelInformation(id, level.getValue(), office.getOfficeId(), title, preferredLocale, personActionForm.getUserPassword(), personActionForm.getLoginName(), personActionForm.getEmailId(), roleList, personActionForm.getCustomFields(), personActionForm.getFirstName(), personActionForm.getMiddleName(), personActionForm.getLastName(), personActionForm.getSecondLastName(), personActionForm.getGovernmentIdNumber(), new DateTime(dob), getIntegerValue(personActionForm.getMaritalStatus()), getIntegerValue(personActionForm.getGender()), new DateTime(dateOfJoiningMFI), new DateTimeService().getCurrentDateTime(), addressDto, personnelStatus.getValue(), new DateTime(passwordExpirationDate));
return perosonnelInfo;
}
use of org.mifos.framework.util.DateTimeService in project head by mifos.
the class CloseLoanActionStrutsTest method tearDown.
@After
public void tearDown() throws Exception {
new ConfigurationPersistence().updateConfigurationKeyValueInteger(LoanConstants.REPAYMENT_SCHEDULES_INDEPENDENT_OF_MEETING_IS_ENABLED, lsim);
new DateTimeService().resetToCurrentSystemDateTime();
loanBO = null;
group = null;
center = null;
}
use of org.mifos.framework.util.DateTimeService in project head by mifos.
the class CloseLoanActionStrutsTest method getLoanAccount.
private LoanBO getLoanAccount() {
Date startDate = new DateTimeService().getCurrentJavaDateTime();
MeetingBO meeting = TestObjectFactory.createMeeting(TestObjectFactory.getTypicalMeeting());
center = TestObjectFactory.createWeeklyFeeCenter("Center", meeting);
group = TestObjectFactory.createWeeklyFeeGroupUnderCenter("Group", CustomerStatus.GROUP_ACTIVE, center);
LoanOfferingBO loanOffering = TestObjectFactory.createLoanOffering(startDate, meeting);
return TestObjectFactory.createLoanAccount("42423142341", group, AccountState.LOAN_ACTIVE_IN_GOOD_STANDING, startDate, loanOffering);
}
use of org.mifos.framework.util.DateTimeService in project head by mifos.
the class CloseLoanActionStrutsTest method setUp.
@Before
public void setUp() throws Exception {
currentDate = new DateTime(2010, 12, 23, 12, 0, 0, 0);
new DateTimeService().setCurrentDateTime(currentDate);
ConfigurationPersistence configurationPersistence = new ConfigurationPersistence();
lsim = configurationPersistence.getConfigurationValueInteger(LoanConstants.REPAYMENT_SCHEDULES_INDEPENDENT_OF_MEETING_IS_ENABLED);
configurationPersistence.updateConfigurationKeyValueInteger(LoanConstants.REPAYMENT_SCHEDULES_INDEPENDENT_OF_MEETING_IS_ENABLED, 1);
userContext = TestObjectFactory.getContext();
request.getSession().setAttribute(Constants.USERCONTEXT, userContext);
addRequestParameter("recordLoanOfficerId", "1");
addRequestParameter("recordOfficeId", "1");
request.getSession(false).setAttribute("ActivityContext", TestObjectFactory.getActivityContext());
flowKey = createFlow(request, LoanDisbursementAction.class);
setRequestPathInfo("/editStatusAction");
}
Aggregations