Search in sources :

Example 1 with EntityMaster

use of org.mifos.framework.business.EntityMaster in project head by mifos.

the class EntityMasterData method init.

/**
     * This method creates a map of entity master table as sets it into the
     * servletcontext so that it is available till the application is up.
     *
     * @throws HibernateProcessException
     */
public void init() throws HibernateProcessException {
    Session session = null;
    try {
        session = StaticHibernateUtil.getSessionTL();
        Query query = session.getNamedQuery(NamedQueryConstants.GET_ENTITY_MASTER);
        List<EntityMaster> entityMasterData = query.list();
        for (EntityMaster entityMaster : entityMasterData) {
            entityMap.put(entityMaster.getEntityType(), entityMaster.getId());
        }
    } catch (HibernateException e) {
        logger.error("table entity_master could not be fetched", e);
    }
}
Also used : Query(org.hibernate.Query) HibernateException(org.hibernate.HibernateException) EntityMaster(org.mifos.framework.business.EntityMaster) Session(org.hibernate.Session)

Example 2 with EntityMaster

use of org.mifos.framework.business.EntityMaster in project head by mifos.

the class QuestionnaireServiceImpl method defineQuestionGroup.

@Override
public QuestionGroupDetail defineQuestionGroup(QuestionGroupDetail questionGroupDetail) throws SystemException {
    questionnaireValidator.validateForDefineQuestionGroup(questionGroupDetail);
    generateNicknamesForQuestions(questionGroupDetail);
    QuestionGroup questionGroup = questionnaireMapper.mapToQuestionGroup(questionGroupDetail);
    questionGroupDao.create(questionGroup);
    List<EntityMaster> usedSources = new ArrayList<EntityMaster>();
    for (Section section : questionGroup.getSections()) {
        for (SectionQuestion sectionQuestion : section.getQuestions()) {
            usedSources.clear();
            for (EventSourceEntity eventSourceEntity : questionGroup.getEventSources()) {
                if (!(eventSourceEntity.getSource().getEntityType().equals("Client") || eventSourceEntity.getSource().getEntityType().equals("Loan"))) {
                    continue;
                }
                InformationOrder informationOrder = new InformationOrder(null, "additional", sectionQuestion.getId(), eventSourceEntity.getSource().getEntityType(), 999);
                if (!sectionQuestion.isShowOnPage()) {
                    informationOrderService.removeAdditionalQuestionIfExists(informationOrder);
                }
                if (usedSources.contains(eventSourceEntity.getSource())) {
                    continue;
                }
                if (sectionQuestion.isShowOnPage()) {
                    informationOrderService.addAdditionalQuestionIfNotExists(informationOrder);
                }
                usedSources.add(eventSourceEntity.getSource());
            }
        }
    }
    return questionnaireMapper.mapToQuestionGroupDetail(questionGroup);
}
Also used : InformationOrder(org.mifos.platform.questionnaire.service.InformationOrder) ArrayList(java.util.ArrayList) EntityMaster(org.mifos.framework.business.EntityMaster)

Example 3 with EntityMaster

use of org.mifos.framework.business.EntityMaster in project head by mifos.

the class FieldConfigIntegrationTest method testIsFieldHidden.

@Test
public void testIsFieldHidden() throws HibernateProcessException, PersistenceException {
    EntityMasterData.getInstance().init();
    List<EntityMaster> entityMasterList = legacyFieldConfigurationDao.getEntityMasterList();
    for (EntityMaster entityMaster : entityMasterList) {
        fieldConfig.getEntityFieldMap().put(entityMaster.getId(), legacyFieldConfigurationDao.getListOfFields(entityMaster.getId()));
    }
    Assert.assertEquals(fieldConfig.isFieldHidden("Loan.PurposeOfLoan"), false);
    Assert.assertEquals(fieldConfig.isFieldHidden("Group.City"), true);
    fieldConfig.getEntityFieldMap().clear();
}
Also used : EntityMaster(org.mifos.framework.business.EntityMaster) Test(org.junit.Test)

Example 4 with EntityMaster

use of org.mifos.framework.business.EntityMaster in project head by mifos.

the class QuestionnaireServiceTest method getEventSources.

private HashSet<EventSourceEntity> getEventSources(String event, String source) {
    EventSourceEntity eventSourceEntity = new EventSourceEntity();
    EventEntity eventEntity = new EventEntity();
    eventEntity.setName(event);
    eventSourceEntity.setEvent(eventEntity);
    EntityMaster entityMaster = new EntityMaster();
    entityMaster.setEntityType(source);
    eventSourceEntity.setSource(entityMaster);
    HashSet<EventSourceEntity> eventSources = new HashSet<EventSourceEntity>();
    eventSources.add(eventSourceEntity);
    return eventSources;
}
Also used : EntityMaster(org.mifos.framework.business.EntityMaster) HashSet(java.util.HashSet)

Example 5 with EntityMaster

use of org.mifos.framework.business.EntityMaster in project head by mifos.

the class FieldConfig method init.

/* This method is used to intialize the mandatory and entiyField maps */
public void init() throws HibernateProcessException, PersistenceException {
    List<EntityMaster> entityMasterList = legacyFieldConfigurationDao.getEntityMasterList();
    for (EntityMaster entityMaster : entityMasterList) {
        getEntityFieldMap().put(entityMaster.getId(), legacyFieldConfigurationDao.getListOfFields(entityMaster.getId()));
        getEntityMandatoryFieldMap().put(entityMaster.getId(), getMandatoryFieldList(entityMaster.getId()));
    }
}
Also used : EntityMaster(org.mifos.framework.business.EntityMaster)

Aggregations

EntityMaster (org.mifos.framework.business.EntityMaster)10 EventEntity (org.mifos.platform.questionnaire.domain.EventEntity)3 EventSourceEntity (org.mifos.platform.questionnaire.domain.EventSourceEntity)3 ArrayList (java.util.ArrayList)2 HashSet (java.util.HashSet)2 Test (org.junit.Test)2 HibernateException (org.hibernate.HibernateException)1 Query (org.hibernate.Query)1 Session (org.hibernate.Session)1 InformationOrder (org.mifos.platform.questionnaire.service.InformationOrder)1