-
-
Notifications
You must be signed in to change notification settings - Fork 215
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10971 from renanfranca/10651-move-preset-logic-to…
…-module-bounded-context move preset logic to "module" bounded context
- Loading branch information
Showing
27 changed files
with
292 additions
and
280 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
src/main/java/tech/jhipster/lite/module/domain/JHipsterModuleSlugs.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package tech.jhipster.lite.module.domain; | ||
|
||
import java.util.Collection; | ||
import tech.jhipster.lite.shared.error.domain.Assert; | ||
|
||
public record JHipsterModuleSlugs(Collection<JHipsterModuleSlug> modules) { | ||
public JHipsterModuleSlugs { | ||
Assert.notEmpty("modules", modules); | ||
} | ||
|
||
public static JHipsterModuleSlugs from(Collection<String> modules) { | ||
return new JHipsterModuleSlugs(modules.stream().map(JHipsterModuleSlug::new).toList()); | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
src/main/java/tech/jhipster/lite/module/domain/JHipsterPresetRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package tech.jhipster.lite.module.domain; | ||
|
||
import java.util.Collection; | ||
import tech.jhipster.lite.module.domain.preset.Preset; | ||
|
||
public interface JHipsterPresetRepository { | ||
Collection<Preset> getPresets(); | ||
} |
11 changes: 11 additions & 0 deletions
11
src/main/java/tech/jhipster/lite/module/domain/preset/Preset.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package tech.jhipster.lite.module.domain.preset; | ||
|
||
import tech.jhipster.lite.module.domain.JHipsterModuleSlugs; | ||
import tech.jhipster.lite.shared.error.domain.Assert; | ||
|
||
public record Preset(PresetName name, JHipsterModuleSlugs modules) { | ||
public Preset { | ||
Assert.notNull("name", name); | ||
Assert.notNull("modules", modules); | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
...ite/project/domain/preset/PresetName.java → ...lite/module/domain/preset/PresetName.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 3 additions & 3 deletions
6
...astructure/primary/RestModuleToApply.java → ...astructure/primary/RestModuleToApply.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
package tech.jhipster.lite.project.infrastructure.primary; | ||
package tech.jhipster.lite.module.infrastructure.primary; | ||
|
||
import io.swagger.v3.oas.annotations.media.Schema; | ||
import tech.jhipster.lite.project.domain.ModuleSlug; | ||
import tech.jhipster.lite.module.domain.JHipsterModuleSlug; | ||
|
||
@Schema(name = "ModuleToApply", description = "Information for a module to apply") | ||
record RestModuleToApply(@Schema(description = "Slug of the module to apply") String slug) { | ||
public static RestModuleToApply from(ModuleSlug moduleSlug) { | ||
public static RestModuleToApply from(JHipsterModuleSlug moduleSlug) { | ||
return new RestModuleToApply(moduleSlug.get()); | ||
} | ||
} |
4 changes: 2 additions & 2 deletions
4
...ct/infrastructure/primary/RestPreset.java → ...le/infrastructure/primary/RestPreset.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
...t/infrastructure/primary/RestPresets.java → ...e/infrastructure/primary/RestPresets.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
...ech/jhipster/lite/module/infrastructure/secondary/FileSystemJHipsterPresetRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package tech.jhipster.lite.module.infrastructure.secondary; | ||
|
||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import java.io.IOException; | ||
import java.util.Collection; | ||
import org.springframework.beans.factory.annotation.Value; | ||
import org.springframework.stereotype.Repository; | ||
import tech.jhipster.lite.module.domain.JHipsterPresetRepository; | ||
import tech.jhipster.lite.module.domain.ProjectFiles; | ||
import tech.jhipster.lite.module.domain.preset.Preset; | ||
import tech.jhipster.lite.module.domain.preset.PresetName; | ||
import tech.jhipster.lite.shared.error.domain.GeneratorException; | ||
|
||
@Repository | ||
class FileSystemJHipsterPresetRepository implements JHipsterPresetRepository { | ||
|
||
private static final String PRESET_FOLDER = "/"; | ||
|
||
private final ObjectMapper json; | ||
private final ProjectFiles projectFiles; | ||
private final PresetName presetName; | ||
|
||
public FileSystemJHipsterPresetRepository( | ||
ObjectMapper json, | ||
ProjectFiles projectFiles, | ||
@Value("${jhlite-preset-file.name:preset.json}") String presetFileName | ||
) { | ||
this.json = json; | ||
this.projectFiles = projectFiles; | ||
this.presetName = PresetName.from(presetFileName); | ||
} | ||
|
||
@Override | ||
public Collection<Preset> getPresets() { | ||
try { | ||
return json.readValue(projectFiles.readBytes(presetFilePath()), PersistedPresets.class).toDomain(); | ||
} catch (IOException e) { | ||
throw GeneratorException.technicalError("Can't read presets: " + e.getMessage(), e); | ||
} | ||
} | ||
|
||
private String presetFilePath() { | ||
return PRESET_FOLDER + presetName.name(); | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
src/main/java/tech/jhipster/lite/module/infrastructure/secondary/PersistedPreset.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package tech.jhipster.lite.module.infrastructure.secondary; | ||
|
||
import java.util.Collection; | ||
import tech.jhipster.lite.module.domain.JHipsterModuleSlugs; | ||
import tech.jhipster.lite.module.domain.preset.Preset; | ||
import tech.jhipster.lite.module.domain.preset.PresetName; | ||
|
||
record PersistedPreset(String name, Collection<String> modules) { | ||
public Preset toDomain() { | ||
return new Preset(PresetName.from(name), JHipsterModuleSlugs.from(modules)); | ||
} | ||
} |
4 changes: 2 additions & 2 deletions
4
...structure/secondary/PersistedPresets.java → ...structure/secondary/PersistedPresets.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 0 additions & 14 deletions
14
src/main/java/tech/jhipster/lite/project/domain/ModulesSlugs.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 0 additions & 11 deletions
11
src/main/java/tech/jhipster/lite/project/domain/preset/Preset.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 0 additions & 12 deletions
12
src/main/java/tech/jhipster/lite/project/infrastructure/secondary/PersistedPreset.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.