Search in sources :

Example 31 with OfficePersistence

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

the class CenterPersistenceIntegrationTest method setUp.

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

Example 32 with OfficePersistence

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

the class TestObjectFactory method createClient.

public static ClientBO createClient(final String customerName, final CustomerStatus status, final CustomerBO parentCustomer, final Date startDate) {
    ClientBO client;
    Short personnel = PersonnelConstants.SYSTEM_USER;
    try {
        ClientNameDetailDto clientNameDetailDto = new ClientNameDetailDto(NameType.MAYBE_CLIENT.getValue(), SAMPLE_SALUTATION, customerName, "", customerName, "");
        clientNameDetailDto.setNames(ClientRules.getNameSequence());
        ClientNameDetailDto spouseNameDetailView = new ClientNameDetailDto(NameType.SPOUSE.getValue(), SAMPLE_SALUTATION, customerName, "middle", customerName, "secondLast");
        ClientPersonalDetailDto clientPersonalDetailDto = new ClientPersonalDetailDto(1, 1, 1, 1, 1, 1, Short.valueOf("1"), Short.valueOf("1"), Short.valueOf("41"));
        // groups
        if (null == parentCustomer) {
            client = new // UserContext
            ClientBO(// UserContext
            TestUtils.makeUserWithLocales(), // String
            clientNameDetailDto.getDisplayName(), // CustomerStatus
            status, // String externalId
            null, // Date mfiJoiningDate
            null, // Address
            null, // List<CustomFieldDto> customFields
            null, // List<FeeDto> fees
            getFees(), // List<SavingsOfferingBO> offeringsSelected
            null, // Short
            getPersonnel(personnel), // Short
            new OfficePersistence().getOffice(SAMPLE_BRANCH_OFFICE), // MeetingBO
            null, // Short loanOfficerId
            null, // Date dateOfBirth
            null, // String governmentId
            "", // Short trained
            null, // Date trainedDate
            null, // Short groupFlag
            YesNoFlag.NO.getValue(), // ClientNameDetailDto
            clientNameDetailDto, // ClientNameDetailDto
            spouseNameDetailView, // ClientPersonalDetailDto
            clientPersonalDetailDto, // InputStream picture
            null);
        } else {
            client = new ClientBO(TestUtils.makeUserWithLocales(), clientNameDetailDto.getDisplayName(), status, null, null, null, null, getFees(), null, getPersonnel(personnel), parentCustomer.getOffice(), parentCustomer, null, null, null, null, YesNoFlag.YES.getValue(), clientNameDetailDto, spouseNameDetailView, clientPersonalDetailDto);
        }
        ApplicationContextProvider.getBean(LegacyClientDao.class).saveClient(client);
        StaticHibernateUtil.flushSession();
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
    return client;
}
Also used : MifosRuntimeException(org.mifos.core.MifosRuntimeException) ClientNameDetailDto(org.mifos.dto.screen.ClientNameDetailDto) ClientBO(org.mifos.customers.client.business.ClientBO) ClientPersonalDetailDto(org.mifos.dto.screen.ClientPersonalDetailDto) LegacyClientDao(org.mifos.customers.client.persistence.LegacyClientDao) 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)

Example 33 with OfficePersistence

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

the class TestObjectFactory method createClient.

public static ClientBO createClient(final String customerName, final CustomerStatus status, final CustomerBO parentCustomer, final List<FeeDto> fees, final String governmentId, final Date dateOfBirth, final Address address) {
    ClientPersonalDetailDto clientPersonalDetailDto = new ClientPersonalDetailDto(132, 1, 1, 1, 1, 1, Short.valueOf("1"), Short.valueOf("1"), Short.valueOf("41"));
    ClientNameDetailDto clientNameDetailDto = clientNameView(NameType.CLIENT, customerName);
    ClientNameDetailDto spouseNameDetailView = clientNameView(NameType.SPOUSE, customerName);
    ClientBO client;
    try {
        client = new ClientBO(TestUtils.makeUserWithLocales(), customerName, status, null, null, address, null, fees, null, getPersonnel(PersonnelConstants.SYSTEM_USER), new OfficePersistence().getOffice(SAMPLE_BRANCH_OFFICE), parentCustomer, dateOfBirth, governmentId, null, null, YesNoFlag.YES.getValue(), clientNameDetailDto, spouseNameDetailView, clientPersonalDetailDto);
        ApplicationContextProvider.getBean(LegacyClientDao.class).saveClient(client);
    } catch (CustomerException e) {
        throw new RuntimeException(e);
    } catch (PersistenceException e) {
        throw new RuntimeException(e);
    }
    StaticHibernateUtil.flushSession();
    return client;
}
Also used : CustomerException(org.mifos.customers.exceptions.CustomerException) MifosRuntimeException(org.mifos.core.MifosRuntimeException) ClientNameDetailDto(org.mifos.dto.screen.ClientNameDetailDto) ClientPersonalDetailDto(org.mifos.dto.screen.ClientPersonalDetailDto) ClientBO(org.mifos.customers.client.business.ClientBO) LegacyClientDao(org.mifos.customers.client.persistence.LegacyClientDao) PersistenceException(org.mifos.framework.exceptions.PersistenceException) OfficePersistence(org.mifos.customers.office.persistence.OfficePersistence)

Example 34 with OfficePersistence

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

the class TestObjectFactory method createClient.

public static ClientBO createClient(final String customerName, final MeetingBO meeting, final CustomerStatus status) {
    ClientBO client;
    try {
        PersonnelBO systemUser = getPersonnel(PersonnelConstants.SYSTEM_USER);
        ClientNameDetailDto clientNameDetailDto = new ClientNameDetailDto(NameType.CLIENT.getValue(), SAMPLE_SALUTATION, customerName, "middle", customerName, "secondLast");
        clientNameDetailDto.setNames(ClientRules.getNameSequence());
        ClientNameDetailDto spouseNameDetailView = new ClientNameDetailDto(NameType.SPOUSE.getValue(), SAMPLE_SALUTATION, customerName, "middle", customerName, "secondLast");
        ClientPersonalDetailDto clientPersonalDetailDto = new ClientPersonalDetailDto(1, 1, 1, 1, 1, 1, Short.valueOf("1"), Short.valueOf("1"), Short.valueOf("41"));
        client = new ClientBO(TestUtils.makeUserWithLocales(), clientNameDetailDto.getDisplayName(), status, null, null, null, null, getFees(), null, systemUser, new OfficePersistence().getOffice(SAMPLE_BRANCH_OFFICE), meeting, systemUser, new DateTimeService().getCurrentJavaDateTime(), null, null, null, YesNoFlag.NO.getValue(), clientNameDetailDto, spouseNameDetailView, clientPersonalDetailDto, null);
        ApplicationContextProvider.getBean(LegacyClientDao.class).saveClient(client);
        StaticHibernateUtil.flushSession();
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
    return client;
}
Also used : MifosRuntimeException(org.mifos.core.MifosRuntimeException) PersonnelBO(org.mifos.customers.personnel.business.PersonnelBO) ClientNameDetailDto(org.mifos.dto.screen.ClientNameDetailDto) ClientBO(org.mifos.customers.client.business.ClientBO) ClientPersonalDetailDto(org.mifos.dto.screen.ClientPersonalDetailDto) LegacyClientDao(org.mifos.customers.client.persistence.LegacyClientDao) OfficePersistence(org.mifos.customers.office.persistence.OfficePersistence) DateTimeService(org.mifos.framework.util.DateTimeService) 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)

Example 35 with OfficePersistence

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

the class TestObjectFactory method createOffice.

public static OfficeBO createOffice(final OfficeLevel level, final OfficeBO parentOffice, final String officeName, final String shortName) throws Exception {
    OfficeBO officeBO = new OfficeBO(TestUtils.makeUserWithLocales(), level, parentOffice, null, officeName, shortName, null, OperationMode.REMOTE_SERVER);
    String searchId = generateSearchId(parentOffice);
    officeBO.setSearchId(searchId);
    String globalOfficeNum = generateOfficeGlobalNo();
    officeBO.setGlobalOfficeNum(globalOfficeNum);
    try {
        StaticHibernateUtil.startTransaction();
        new OfficePersistence().save(officeBO);
        StaticHibernateUtil.commitTransaction();
    } catch (Exception e) {
        StaticHibernateUtil.rollbackTransaction();
        throw new MifosRuntimeException(e);
    } finally {
        StaticHibernateUtil.closeSession();
    }
    return officeBO;
}
Also used : OfficeBO(org.mifos.customers.office.business.OfficeBO) 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) MifosRuntimeException(org.mifos.core.MifosRuntimeException)

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