Search in sources :

Example 1 with SurveyTemplateService

use of com.khartec.waltz.service.survey.SurveyTemplateService in project waltz by khartec.

the class SurveyHarness method surveyTempateHarness.

private static void surveyTempateHarness(AnnotationConfigApplicationContext ctx) {
    SurveyTemplateService surveyTemplateService = ctx.getBean(SurveyTemplateService.class);
    SurveyQuestionService surveyQuestionService = ctx.getBean(SurveyQuestionService.class);
    SurveyTemplateChangeCommand surveyTemplateChangeCommand = ImmutableSurveyTemplateChangeCommand.builder().name("AAA").description("BBB").targetEntityKind(EntityKind.CHANGE_INITIATIVE).build();
    long templateId = surveyTemplateService.create("admin", surveyTemplateChangeCommand);
    System.out.println("Created: template create with ID = " + templateId);
    SurveyQuestion surveyQuestion = ImmutableSurveyQuestion.builder().surveyTemplateId(templateId).sectionName("SSS").questionText("QQQ").helpText("HHH").fieldType(SurveyQuestionFieldType.TEXTAREA).position(1).isMandatory(false).allowComment(true).build();
    long questionId = surveyQuestionService.create(surveyQuestion);
    System.out.println("Created: question create with ID = " + questionId);
}
Also used : SurveyQuestionService(com.khartec.waltz.service.survey.SurveyQuestionService) SurveyTemplateService(com.khartec.waltz.service.survey.SurveyTemplateService)

Example 2 with SurveyTemplateService

use of com.khartec.waltz.service.survey.SurveyTemplateService in project waltz by khartec.

the class SurveyTemplateGenerator method main.

public static void main(String[] args) {
    try {
        AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(DIConfiguration.class);
        DSLContext dsl = ctx.getBean(DSLContext.class);
        SurveyTemplateService surveyTemplateService = ctx.getBean(SurveyTemplateService.class);
        SurveyQuestionService surveyQuestionService = ctx.getBean(SurveyQuestionService.class);
        dsl.deleteFrom(SURVEY_TEMPLATE).execute();
        dsl.deleteFrom(SURVEY_QUESTION).execute();
        ReleaseLifecycleStatusChangeCommand statusChangeCommand = ImmutableReleaseLifecycleStatusChangeCommand.builder().newStatus(ReleaseLifecycleStatus.ACTIVE).build();
        SurveyTemplateChangeCommand appSurvey = mkAppSurvey();
        long aid = surveyTemplateService.create("admin", appSurvey);
        List<SurveyQuestion> appQs = mkAppQuestions(aid);
        appQs.forEach(surveyQuestionService::create);
        surveyTemplateService.updateStatus("admin", aid, statusChangeCommand);
        SurveyTemplateChangeCommand projectSurvey = mkProjectSurvey();
        long pid = surveyTemplateService.create("admin", projectSurvey);
        List<SurveyQuestion> projQs = mkProjQuestions(pid);
        projQs.forEach(surveyQuestionService::create);
        surveyTemplateService.updateStatus("admin", pid, statusChangeCommand);
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : SurveyQuestionService(com.khartec.waltz.service.survey.SurveyQuestionService) AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) ImmutableReleaseLifecycleStatusChangeCommand(com.khartec.waltz.model.ImmutableReleaseLifecycleStatusChangeCommand) ReleaseLifecycleStatusChangeCommand(com.khartec.waltz.model.ReleaseLifecycleStatusChangeCommand) DSLContext(org.jooq.DSLContext) SurveyTemplateService(com.khartec.waltz.service.survey.SurveyTemplateService)

Aggregations

SurveyQuestionService (com.khartec.waltz.service.survey.SurveyQuestionService)2 SurveyTemplateService (com.khartec.waltz.service.survey.SurveyTemplateService)2 ImmutableReleaseLifecycleStatusChangeCommand (com.khartec.waltz.model.ImmutableReleaseLifecycleStatusChangeCommand)1 ReleaseLifecycleStatusChangeCommand (com.khartec.waltz.model.ReleaseLifecycleStatusChangeCommand)1 DSLContext (org.jooq.DSLContext)1 AnnotationConfigApplicationContext (org.springframework.context.annotation.AnnotationConfigApplicationContext)1