Search in sources :

Example 16 with OfficePersistence

use of org.mifos.customers.office.persistence.OfficePersistence in project head by mifos.

the class TestObjectFactory method createCenter.

public static CenterBO createCenter(final String customerName, final MeetingBO meeting, final Short officeId, final Short personnelId, final List<FeeDto> fees) {
    CenterBO center;
    try {
        center = new CenterBO(TestUtils.makeUserWithLocales(), customerName, null, null, fees, null, null, new OfficePersistence().getOffice(officeId), meeting, ApplicationContextProvider.getBean(LegacyPersonnelDao.class).getPersonnel(personnelId), new CustomerPersistence());
        new CenterPersistence().saveCenter(center);
        StaticHibernateUtil.flushSession();
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
    return center;
}
Also used : MifosRuntimeException(org.mifos.core.MifosRuntimeException) CenterBO(org.mifos.customers.center.business.CenterBO) LegacyPersonnelDao(org.mifos.customers.personnel.persistence.LegacyPersonnelDao) CustomerPersistence(org.mifos.customers.persistence.CustomerPersistence) OfficePersistence(org.mifos.customers.office.persistence.OfficePersistence) SystemException(org.mifos.framework.exceptions.SystemException) MifosRuntimeException(org.mifos.core.MifosRuntimeException) ProductDefinitionException(org.mifos.accounts.productdefinition.exceptions.ProductDefinitionException) ApplicationException(org.mifos.framework.exceptions.ApplicationException) CustomerException(org.mifos.customers.exceptions.CustomerException) PersistenceException(org.mifos.framework.exceptions.PersistenceException) MeetingException(org.mifos.application.meeting.exceptions.MeetingException) OfficeException(org.mifos.customers.office.exceptions.OfficeException) CenterPersistence(org.mifos.customers.center.persistence.CenterPersistence)

Example 17 with OfficePersistence

use of org.mifos.customers.office.persistence.OfficePersistence in project head by mifos.

the class TestObjectFactory method generateOfficeGlobalNo.

private static String generateOfficeGlobalNo() throws OfficeException {
    try {
        /*
             * TODO: Why not auto-increment? Fetching the max and adding one would seem to have a race condition.
             */
        String officeGlobelNo = String.valueOf(new OfficePersistence().getMaxOfficeId().intValue() + 1);
        if (officeGlobelNo.length() > 4) {
            throw new OfficeException(OfficeConstants.MAXOFFICELIMITREACHED);
        }
        StringBuilder temp = new StringBuilder("");
        for (int i = officeGlobelNo.length(); i < 4; i++) {
            temp.append("0");
        }
        return officeGlobelNo = temp.append(officeGlobelNo).toString();
    } catch (PersistenceException e) {
        throw new OfficeException(e);
    }
}
Also used : OfficeException(org.mifos.customers.office.exceptions.OfficeException) PersistenceException(org.mifos.framework.exceptions.PersistenceException) OfficePersistence(org.mifos.customers.office.persistence.OfficePersistence)

Example 18 with OfficePersistence

use of org.mifos.customers.office.persistence.OfficePersistence in project head by mifos.

the class ConfigurationIntegrationTest method testHeadOfficeConfiguration.

@Test
public void testHeadOfficeConfiguration() throws Exception {
    OfficeBO headOffice = new OfficePersistence().getHeadOffice();
    OfficeConfig officeConfig = configuration.getOfficeConfig(headOffice.getOfficeId());
    assertForAccountConfig(officeConfig.getAccountConfig());
}
Also used : OfficeBO(org.mifos.customers.office.business.OfficeBO) OfficePersistence(org.mifos.customers.office.persistence.OfficePersistence) Test(org.junit.Test)

Example 19 with OfficePersistence

use of org.mifos.customers.office.persistence.OfficePersistence in project head by mifos.

the class GroupPersistenceIntegrationTest method setUp.

@Before
public void setUp() throws Exception {
    this.officePersistence = new OfficePersistence();
    this.centerPersistence = new CenterPersistence();
    this.groupPersistence = new GroupPersistence();
    initializeStatisticsService();
}
Also used : OfficePersistence(org.mifos.customers.office.persistence.OfficePersistence) CenterPersistence(org.mifos.customers.center.persistence.CenterPersistence) Before(org.junit.Before)

Example 20 with OfficePersistence

use of org.mifos.customers.office.persistence.OfficePersistence in project head by mifos.

the class AddGroupMembershipActionStrutsTest method createAndSetClientInSession.

private void createAndSetClientInSession() throws Exception {
    OfficeBO office = new OfficePersistence().getOffice(TestObjectFactory.HEAD_OFFICE);
    PersonnelBO personnel = legacyPersonnelDao.getPersonnel(PersonnelConstants.TEST_USER);
    meeting = getMeeting();
    ClientNameDetailDto clientNameDetailDto = new ClientNameDetailDto(NameType.CLIENT.getValue(), 1, "Client", "", "1", "");
    clientNameDetailDto.setNames(ClientRules.getNameSequence());
    ClientNameDetailDto spouseNameDetailView = new ClientNameDetailDto(NameType.SPOUSE.getValue(), 1, "first", "middle", "last", "secondLast");
    spouseNameDetailView.setNames(ClientRules.getNameSequence());
    ClientPersonalDetailDto clientPersonalDetailDto = new ClientPersonalDetailDto(1, 1, 1, 1, 1, 1, Short.valueOf("1"), Short.valueOf("1"), Short.valueOf("41"));
    client = new ClientBO(TestUtils.makeUser(), clientNameDetailDto.getDisplayName(), CustomerStatus.fromInt(new Short("1")), null, null, new Address(), getCustomFields(), null, null, personnel, office, meeting, personnel, new java.util.Date(), null, null, null, YesNoFlag.NO.getValue(), clientNameDetailDto, spouseNameDetailView, clientPersonalDetailDto, null);
    legacyClientDao.saveClient(client);
    StaticHibernateUtil.flushSession();
    client = TestObjectFactory.getClient(Integer.valueOf(client.getCustomerId()).intValue());
    request.setAttribute(Constants.CURRENTFLOWKEY, flowKey);
    SessionUtils.setAttribute(Constants.BUSINESS_KEY, client, request);
}
Also used : Address(org.mifos.framework.business.util.Address) OfficeBO(org.mifos.customers.office.business.OfficeBO) PersonnelBO(org.mifos.customers.personnel.business.PersonnelBO) ClientNameDetailDto(org.mifos.dto.screen.ClientNameDetailDto) ClientPersonalDetailDto(org.mifos.dto.screen.ClientPersonalDetailDto) ClientBO(org.mifos.customers.client.business.ClientBO) OfficePersistence(org.mifos.customers.office.persistence.OfficePersistence)

Aggregations

OfficePersistence (org.mifos.customers.office.persistence.OfficePersistence)37 PersistenceException (org.mifos.framework.exceptions.PersistenceException)17 OfficeBO (org.mifos.customers.office.business.OfficeBO)16 Test (org.junit.Test)11 MifosRuntimeException (org.mifos.core.MifosRuntimeException)11 OfficeException (org.mifos.customers.office.exceptions.OfficeException)11 PersonnelBO (org.mifos.customers.personnel.business.PersonnelBO)8 ClientNameDetailDto (org.mifos.dto.screen.ClientNameDetailDto)8 ClientPersonalDetailDto (org.mifos.dto.screen.ClientPersonalDetailDto)8 ArrayList (java.util.ArrayList)7 CustomerException (org.mifos.customers.exceptions.CustomerException)7 ClientBO (org.mifos.customers.client.business.ClientBO)6 ProductDefinitionException (org.mifos.accounts.productdefinition.exceptions.ProductDefinitionException)5 MeetingException (org.mifos.application.meeting.exceptions.MeetingException)5 OfficeDetailsDto (org.mifos.dto.domain.OfficeDetailsDto)5 Date (java.util.Date)4 MessageLookup (org.mifos.application.master.MessageLookup)4 CustomerPersistence (org.mifos.customers.persistence.CustomerPersistence)4 Address (org.mifos.framework.business.util.Address)4 ApplicationException (org.mifos.framework.exceptions.ApplicationException)4