Search in sources :

Example 1 with PostgreSQLStatementBuilder

use of org.hisp.dhis.jdbc.statementbuilder.PostgreSQLStatementBuilder in project dhis2-core by dhis2.

the class DataApprovalStoreIntegrationTest method setUpTest.

// -------------------------------------------------------------------------
// Set up/tear down
// -------------------------------------------------------------------------
@Override
public void setUpTest() throws Exception {
    dataApprovalStore = new HibernateDataApprovalStore(sessionFactory, jdbcTemplate, publisher, cacheProvider, periodService, periodStore, currentUserService, categoryService, systemSettingManager, new PostgreSQLStatementBuilder());
    // ---------------------------------------------------------------------
    // Add supporting data
    // ---------------------------------------------------------------------
    level1 = new DataApprovalLevel("01", 1, null);
    dataApprovalLevelService.addDataApprovalLevel(level1);
    userApprovalLevels = ListUtils.newList(level1);
    PeriodType periodType = PeriodType.getPeriodTypeByName("Monthly");
    workflowA = new DataApprovalWorkflow("workflowA1", periodType, newHashSet(level1));
    dataApprovalService.addWorkflow(workflowA);
    sourceA = createOrganisationUnit('A');
    sourceA.setHierarchyLevel(1);
    organisationUnitService.addOrganisationUnit(sourceA);
    dataSetA = createDataSet('A', new MonthlyPeriodType(), categoryComboA);
    dataSetA.assignWorkflow(workflowA);
    dataSetA.addOrganisationUnit(sourceA);
    dataSetService.addDataSet(dataSetA);
    periodJan = createPeriod("202001");
    periodFeb = createPeriod("202002");
    periodMay = createPeriod("202005");
    periodJun = createPeriod("202006");
    periodService.addPeriod(periodJan);
    periodService.addPeriod(periodFeb);
    periodService.addPeriod(periodMay);
    periodService.addPeriod(periodJun);
    userA = createUser('A');
    userB = createUser('B');
    userA.addOrganisationUnit(sourceA);
    userB.addOrganisationUnit(sourceA);
    userService.addUser(userA);
    userService.addUser(userB);
    userGroupA = createUserGroup('A', Sets.newHashSet(userA));
    userGroupB = createUserGroup('B', Sets.newHashSet(userB));
    userGroupService.addUserGroup(userGroupA);
    userGroupService.addUserGroup(userGroupB);
    userA.getGroups().add(userGroupA);
    userB.getGroups().add(userGroupB);
    userService.updateUser(userA);
    userService.updateUser(userB);
    categoryOptionA = createCategoryOption('A');
    categoryOptionB = createCategoryOption('B');
    categoryOptionA.setPublicAccess("--------");
    categoryOptionB.setPublicAccess("--------");
    categoryService.addCategoryOption(categoryOptionA);
    categoryService.addCategoryOption(categoryOptionB);
    categoryA = createCategory('A', categoryOptionA, categoryOptionB);
    categoryService.addCategory(categoryA);
    categoryComboA = createCategoryCombo('A', categoryA);
    categoryService.addCategoryCombo(categoryComboA);
    categoryOptionCombo = createCategoryOptionCombo(categoryComboA, categoryOptionA, categoryOptionB);
    categoryOptionCombo.setName("categoryOptionCombo");
    categoryOptionCombo.setUid("optComboUid");
    categoryService.addCategoryOptionCombo(categoryOptionCombo);
    categoryComboA.getOptionCombos().add(categoryOptionCombo);
    categoryService.updateCategoryCombo(categoryComboA);
}
Also used : MonthlyPeriodType(org.hisp.dhis.period.MonthlyPeriodType) PeriodType(org.hisp.dhis.period.PeriodType) MonthlyPeriodType(org.hisp.dhis.period.MonthlyPeriodType) HibernateDataApprovalStore(org.hisp.dhis.dataapproval.hibernate.HibernateDataApprovalStore) PostgreSQLStatementBuilder(org.hisp.dhis.jdbc.statementbuilder.PostgreSQLStatementBuilder)

Example 2 with PostgreSQLStatementBuilder

use of org.hisp.dhis.jdbc.statementbuilder.PostgreSQLStatementBuilder in project dhis2-core by dhis2.

the class ProgramSqlGeneratorVariablesTest method setUp.

@BeforeEach
public void setUp() {
    statementBuilder = new PostgreSQLStatementBuilder();
    eventIndicator = new ProgramIndicator();
    eventIndicator.setAnalyticsType(AnalyticsType.EVENT);
    enrollmentIndicator = makeEnrollmentProgramIndicator();
}
Also used : PostgreSQLStatementBuilder(org.hisp.dhis.jdbc.statementbuilder.PostgreSQLStatementBuilder) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 3 with PostgreSQLStatementBuilder

use of org.hisp.dhis.jdbc.statementbuilder.PostgreSQLStatementBuilder in project dhis2-core by dhis2.

the class AbstractJdbcEventAnalyticsManagerTest method setUp.

@BeforeEach
public void setUp() {
    StatementBuilder statementBuilder = new PostgreSQLStatementBuilder();
    DefaultProgramIndicatorSubqueryBuilder programIndicatorSubqueryBuilder = new DefaultProgramIndicatorSubqueryBuilder(programIndicatorService);
    subject = new JdbcEventAnalyticsManager(jdbcTemplate, statementBuilder, programIndicatorService, programIndicatorSubqueryBuilder, new EventTimeFieldSqlRenderer(statementBuilder), executionPlanStore);
    // data init
    programA = createProgram('A');
    dataElementA = createDataElement('A', ValueType.INTEGER, AggregationType.SUM);
    dataElementA.setUid("fWIAEtYVEGk");
}
Also used : PostgreSQLStatementBuilder(org.hisp.dhis.jdbc.statementbuilder.PostgreSQLStatementBuilder) StatementBuilder(org.hisp.dhis.jdbc.StatementBuilder) DefaultProgramIndicatorSubqueryBuilder(org.hisp.dhis.analytics.event.data.programindicator.DefaultProgramIndicatorSubqueryBuilder) PostgreSQLStatementBuilder(org.hisp.dhis.jdbc.statementbuilder.PostgreSQLStatementBuilder) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 4 with PostgreSQLStatementBuilder

use of org.hisp.dhis.jdbc.statementbuilder.PostgreSQLStatementBuilder in project dhis2-core by dhis2.

the class EnrollmentAnalyticsManagerTest method setUp.

@BeforeEach
public void setUp() {
    when(jdbcTemplate.queryForRowSet(anyString())).thenReturn(this.rowSet);
    StatementBuilder statementBuilder = new PostgreSQLStatementBuilder();
    DefaultProgramIndicatorSubqueryBuilder programIndicatorSubqueryBuilder = new DefaultProgramIndicatorSubqueryBuilder(programIndicatorService);
    subject = new JdbcEnrollmentAnalyticsManager(jdbcTemplate, statementBuilder, programIndicatorService, programIndicatorSubqueryBuilder, new EnrollmentTimeFieldSqlRenderer(statementBuilder), executionPlanStore);
}
Also used : PostgreSQLStatementBuilder(org.hisp.dhis.jdbc.statementbuilder.PostgreSQLStatementBuilder) StatementBuilder(org.hisp.dhis.jdbc.StatementBuilder) DefaultProgramIndicatorSubqueryBuilder(org.hisp.dhis.analytics.event.data.programindicator.DefaultProgramIndicatorSubqueryBuilder) PostgreSQLStatementBuilder(org.hisp.dhis.jdbc.statementbuilder.PostgreSQLStatementBuilder) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 5 with PostgreSQLStatementBuilder

use of org.hisp.dhis.jdbc.statementbuilder.PostgreSQLStatementBuilder in project dhis2-core by dhis2.

the class ProgramSqlGeneratorFunctionsTest method setUp.

@BeforeEach
public void setUp() {
    dataElementA = createDataElement('A');
    dataElementA.setDomainType(DataElementDomain.TRACKER);
    dataElementA.setUid("DataElmentA");
    dataElementB = createDataElement('B');
    dataElementB.setDomainType(DataElementDomain.TRACKER);
    dataElementB.setUid("DataElmentB");
    dataElementC = createDataElement('C');
    dataElementC.setDomainType(DataElementDomain.TRACKER);
    dataElementC.setUid("DataElmentC");
    dataElementC.setValueType(ValueType.DATE);
    dataElementD = createDataElement('D');
    dataElementD.setDomainType(DataElementDomain.TRACKER);
    dataElementD.setUid("DataElmentD");
    dataElementD.setValueType(ValueType.DATE);
    attributeA = createTrackedEntityAttribute('A', ValueType.NUMBER);
    attributeA.setUid("Attribute0A");
    OrganisationUnit organisationUnit = createOrganisationUnit('A');
    programStageA = new ProgramStage("StageA", programA);
    programStageA.setSortOrder(1);
    programStageA.setUid("ProgrmStagA");
    programStageB = new ProgramStage("StageB", programA);
    programStageB.setSortOrder(2);
    programStageB.setUid("ProgrmStagB");
    Set<ProgramStage> programStages = new HashSet<>();
    programStages.add(programStageA);
    programStages.add(programStageB);
    programA = createProgram('A', new HashSet<>(), organisationUnit);
    programA.setUid("Program000A");
    programA.setProgramStages(programStages);
    statementBuilder = new PostgreSQLStatementBuilder();
    programIndicator = new ProgramIndicator();
    programIndicator.setProgram(programA);
    programIndicator.setAnalyticsType(AnalyticsType.EVENT);
    relTypeA = new RelationshipType();
    relTypeA.setUid("RelatnTypeA");
}
Also used : OrganisationUnit(org.hisp.dhis.organisationunit.OrganisationUnit) RelationshipType(org.hisp.dhis.relationship.RelationshipType) PostgreSQLStatementBuilder(org.hisp.dhis.jdbc.statementbuilder.PostgreSQLStatementBuilder) HashSet(java.util.HashSet) LinkedHashSet(java.util.LinkedHashSet) BeforeEach(org.junit.jupiter.api.BeforeEach)

Aggregations

PostgreSQLStatementBuilder (org.hisp.dhis.jdbc.statementbuilder.PostgreSQLStatementBuilder)9 BeforeEach (org.junit.jupiter.api.BeforeEach)8 DefaultProgramIndicatorSubqueryBuilder (org.hisp.dhis.analytics.event.data.programindicator.DefaultProgramIndicatorSubqueryBuilder)3 StatementBuilder (org.hisp.dhis.jdbc.StatementBuilder)3 HashSet (java.util.HashSet)2 LinkedHashSet (java.util.LinkedHashSet)2 OrganisationUnit (org.hisp.dhis.organisationunit.OrganisationUnit)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 ImmutableMap (com.google.common.collect.ImmutableMap)1 DataSource (javax.sql.DataSource)1 AntlrParserUtils.castString (org.hisp.dhis.antlr.AntlrParserUtils.castString)1 Constant (org.hisp.dhis.constant.Constant)1 HibernateDataApprovalStore (org.hisp.dhis.dataapproval.hibernate.HibernateDataApprovalStore)1 MonthlyPeriodType (org.hisp.dhis.period.MonthlyPeriodType)1 PeriodType (org.hisp.dhis.period.PeriodType)1 ProgramIndicatorService (org.hisp.dhis.program.ProgramIndicatorService)1 RelationshipType (org.hisp.dhis.relationship.RelationshipType)1