Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,20 @@
* Marks a class as a Flamingock change template and configures its execution mode.
*
* <p>All template classes must extend {@link AbstractChangeTemplate} and be annotated with
* this annotation to specify whether they process single or multiple steps.
* this annotation to specify their unique identifier and whether they process single or multiple steps.
*
* <p><b>Simple templates</b> (default, {@code steppable = false}):
* <p><b>Simple templates</b> (default, {@code multiStep = false}):
* <pre>
* id: create-users-table
* template: SqlTemplate
* template: sql # Uses the template id
* apply: "CREATE TABLE users (id INT PRIMARY KEY)"
* rollback: "DROP TABLE users"
* </pre>
*
* <p><b>Steppable templates</b> ({@code steppable = true}) process multiple operations:
* <p><b>Steppable templates</b> ({@code multiStep = true}) process multiple operations:
* <pre>
* id: setup-orders
* template: MongoTemplate
* template: mongo # Uses the template id
* steps:
* - apply: { type: createCollection, collection: orders }
* rollback: { type: dropCollection, collection: orders }
Expand All @@ -59,6 +59,18 @@
@Target(ElementType.TYPE)
public @interface ChangeTemplate {

/**
* Unique identifier for the template. Used in YAML files to reference
* the template (e.g., {@code template: "sql"}).
*
* <p>This is a mandatory field - all templates must have a unique identifier.
* The id should be short, descriptive, and use lowercase with hyphens
* (e.g., "sql", "mongodb", "dynamodb").
*
* @return the unique template identifier
*/
String id();

/**
* When {@code true}, the template expects a {@code steps} array in YAML.
* When {@code false} (default), it expects {@code apply} and optional {@code rollback} at root.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public static class AnotherAdditionalClass {
}

// Test template with custom generic types
@ChangeTemplate
@ChangeTemplate(id = "test-custom-types")
public static class TestTemplateWithCustomTypes
extends AbstractChangeTemplate<TestConfig, TestApplyPayload, TestRollbackPayload> {

Expand All @@ -67,7 +67,7 @@ public void apply() {
}

// Test template with additional reflective classes
@ChangeTemplate
@ChangeTemplate(id = "test-additional-classes")
public static class TestTemplateWithAdditionalClasses
extends AbstractChangeTemplate<TestConfig, TestApplyPayload, TestRollbackPayload> {

Expand All @@ -82,7 +82,7 @@ public void apply() {
}

// Test template with Void configuration
@ChangeTemplate
@ChangeTemplate(id = "test-void-config")
public static class TestTemplateWithVoidConfig
extends AbstractChangeTemplate<Void, String, String> {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@
package io.flamingock.internal.common.core.metadata;

import io.flamingock.internal.common.core.preview.PreviewPipeline;
import io.flamingock.internal.common.core.template.TemplateMetadata;

import java.util.List;
import java.util.Map;

public class FlamingockMetadata {
Expand All @@ -25,6 +27,7 @@ public class FlamingockMetadata {
private String configFile;
private Map<String, String> properties;
private BuilderProviderInfo builderProvider;
private List<TemplateMetadata> templates;

public FlamingockMetadata() {
}
Expand Down Expand Up @@ -75,11 +78,20 @@ public boolean hasValidBuilderProvider() {
return builderProvider != null && builderProvider.isValid();
}

public List<TemplateMetadata> getTemplates() {
return templates;
}

public void setTemplates(List<TemplateMetadata> templates) {
this.templates = templates;
}

@Override
public String toString() {
return "FlamingockMetadata{" + "pipeline=" + pipeline +
", configFile='" + configFile + '\'' +
", builderProvider=" + builderProvider +
", templates=" + templates +
'}';
}
}

This file was deleted.

Loading
Loading