import BaseApplicationGenerator from '../base-application/index.mjs';
import { GENERATOR_SPRING_DATA_ELASTICSEARCH, GENERATOR_BOOTSTRAP_APPLICATION } from '../generator-list.mjs';
import writeElasticsearchFilesTask from './files.mjs';
import cleanupElasticsearchFilesTask from './cleanup.mjs';
import writeElasticsearchEntityFilesTask, { cleanupElasticsearchEntityFilesTask } from './entity-files.mjs';
export default class ElasticsearchGenerator extends BaseApplicationGenerator {
    async beforeQueue() {
        if (!this.fromBlueprint) {
            await this.composeWithBlueprints(GENERATOR_SPRING_DATA_ELASTICSEARCH);
        }
        if (!this.delegateToBlueprint) {
            await this.dependsOnJHipster(GENERATOR_BOOTSTRAP_APPLICATION);
        }
    }
    get writing() {
        return {
            cleanupElasticsearchFilesTask,
            writeElasticsearchFilesTask,
        };
    }
    get [BaseApplicationGenerator.WRITING]() {
        return this.delegateTasksToBlueprint(() => this.writing);
    }
    get writingEntities() {
        return {
            cleanupElasticsearchEntityFilesTask,
            writeElasticsearchEntityFilesTask,
        };
    }
    get [BaseApplicationGenerator.WRITING_ENTITIES]() {
        return this.delegateTasksToBlueprint(() => this.writingEntities);
    }
    get postWriting() {
        return this.asPostWritingTaskGroup({
            addDependencies({ application, source }) {
                if (application.buildToolMaven) {
                    source.addMavenProperty?.({
                        property: 'awaitility.version',
                        value: application.javaDependencies.awaitility,
                    });
                    source.addMavenDependency?.([
                        {
                            groupId: 'org.springframework.boot',
                            artifactId: 'spring-boot-starter-data-elasticsearch',
                        },
                        {
                            groupId: 'org.awaitility',
                            artifactId: 'awaitility',
                            version: '${awaitility.version}',
                            scope: 'test',
                        },
                        {
                            groupId: 'org.apache.commons',
                            artifactId: 'commons-collections4',
                        },
                        {
                            groupId: 'org.testcontainers',
                            artifactId: 'junit-jupiter',
                            scope: 'test',
                        },
                        {
                            groupId: 'org.testcontainers',
                            artifactId: 'testcontainers',
                            scope: 'test',
                        },
                        {
                            groupId: 'org.testcontainers',
                            artifactId: 'elasticsearch',
                            scope: 'test',
                        },
                    ]);
                }
            },
        });
    }
    get [BaseApplicationGenerator.POST_WRITING]() {
        return this.asPostWritingTaskGroup(this.delegateTasksToBlueprint(() => this.postWriting));
    }
}
