Using the @Structure
annotation
-
API:
@org.talend.sdk.component.api.configuration.ui.widget.Structure
According the specified field type, you will acess to
-
the column names list with
List<String>
-
a subset or all wanted metadata with
List<MySchemaMeta>
(see below)
@Data
@GridLayout({ @GridLayout.Row({ "dataset" }),
@GridLayout.Row({ "incomingSchema" }) }) (5)
public class OutputConfig implements Serializable {
@Option
@Documentation("My dataset.")
private Dataset dataset;
@Option (1)
@Documentation("Incoming metadata.")
@Structure(type = Structure.Type.IN) (2) (3)
private List<SchemaInfo> incomingSchema; (4)
1 | @Option : mark class’s attributes as being a configuration entry. |
2 | @Structure : mark this configuration entry as a schema container. |
3 | Structure.Type.IN : marks the schema for an incoming flow (Output).
Use Structure.Type.OUT for outgoing flow (Input). |
4 | List<SchemaInfo> : is a custom class for holding metadata. |
5 | @GridLayout : option should be defined in the UI layout. |
Then, we should have a class SchemaInfo
as following:
Defining a specific class for holding metadata
If you don’t want just only column names (using List<String>
), you’ll have to define a custom class.
@Data
@GridLayout({ @GridLayout.Row({ "label", "key", "talendType", "nullable", "pattern" }) })
@Documentation("Schema definition.")
public class SchemaInfo implements Serializable {
@Option
@Documentation("Column name.")
private String label;
@Option
@Documentation("Is it a Key column.")
private boolean key;
@Option
@Documentation("Talend type such as id_String.")
private String talendType;
@Option
@Documentation("Is it a Nullable column.")
private boolean nullable;
@Option
@Documentation("Pattern used for datetime processing.")
private String pattern = "yyyy-MM-dd HH:mm";
}
Available Studio metadata informations
Field name | Type | Name in Studio |
---|---|---|
|
String |
Column |
|
String |
Db Column |
|
Boolean |
Key |
|
String |
DB Type |
|
String |
Type |
|
Boolean |
Nullable |
|
String |
Date Pattern |
|
int |
Length |
|
int |
Precision |
|
String |
Default |
|
String |
Comment |