use of org.talend.sdk.component.form.model.uischema.UiSchema in project component-runtime by Talend.
the class UiSpecServiceTest method gridLayout.
@Test
void gridLayout() throws Exception {
final Ui payload = service.convert(load("rest-api.json")).toCompletableFuture().get();
final UiSchema tableDataSet = payload.getUiSchema().iterator().next();
assertEquals(2, tableDataSet.getItems().size());
final Iterator<UiSchema> tableDataSetIt = tableDataSet.getItems().iterator();
final UiSchema tableDataSetMain = tableDataSetIt.next();
assertEquals("Main", tableDataSetMain.getTitle());
assertEquals(5, tableDataSetMain.getItems().size());
assertEquals(asList("dataStore", "commonConfig", "Query", "Ordered", "Order"), tableDataSetMain.getItems().stream().map(UiSchema::getTitle).collect(toList()));
final Iterator<UiSchema> mainIt = tableDataSetMain.getItems().iterator();
final UiSchema dataStore = mainIt.next();
Iterator<UiSchema> dataStoreIt = dataStore.getItems().iterator();
dataStoreIt.next();
final UiSchema credentials = dataStoreIt.next();
assertEquals("columns", credentials.getWidget());
assertEquals(asList("Username", "Password"), credentials.getItems().stream().map(UiSchema::getTitle).collect(toList()));
final UiSchema tableDataSetAdvanced = tableDataSetIt.next();
assertEquals("Advanced", tableDataSetAdvanced.getTitle());
}
use of org.talend.sdk.component.form.model.uischema.UiSchema in project component-runtime by Talend.
the class AbstractWidgetConverter method newOrphanSchema.
protected UiSchema newOrphanSchema(final PropertyContext ctx) {
final UiSchema schema = new UiSchema();
schema.setTitle(ctx.getProperty().getDisplayName());
schema.setKey(ctx.getProperty().getPath());
schema.setRequired(ctx.isRequired());
schema.setPlaceholder(ctx.getProperty().getPlaceholder());
if (actions != null) {
ofNullable(ctx.getProperty().getMetadata().get("action::validation")).flatMap(v -> actions.stream().filter(a -> a.getName().equals(v) && "validation".equals(a.getType())).findFirst()).ifPresent(ref -> schema.setTriggers(singletonList(toTrigger(properties, ctx.getProperty(), ref))));
}
schema.setConditions(createConditions(ctx));
return schema;
}
use of org.talend.sdk.component.form.model.uischema.UiSchema in project component-runtime by Talend.
the class CodeWidgetConverter method convert.
@Override
public CompletionStage<PropertyContext> convert(final CompletionStage<PropertyContext> cs) {
return cs.thenApply(context -> {
final UiSchema schema = newUiSchema(context);
final String codeLang = context.getProperty().getMetadata().get("ui::code::value");
schema.setWidget("code");
schema.setOptions(singletonMap("language", codeLang));
return context;
});
}
use of org.talend.sdk.component.form.model.uischema.UiSchema in project component-runtime by Talend.
the class CredentialWidgetConverter method convert.
@Override
public CompletionStage<PropertyContext> convert(final CompletionStage<PropertyContext> cs) {
return cs.thenApply(context -> {
final UiSchema schema = newUiSchema(context);
schema.setWidget("text");
schema.setType("password");
return context;
});
}
use of org.talend.sdk.component.form.model.uischema.UiSchema in project component-runtime by Talend.
the class DataListWidgetConverter method convert.
@Override
public CompletionStage<PropertyContext> convert(final CompletionStage<PropertyContext> cs) {
return cs.thenApply(context -> {
final UiSchema schema = newUiSchema(context);
schema.setWidget("datalist");
final JsonSchema jsonSchema = new JsonSchema();
jsonSchema.setType("string");
schema.setSchema(jsonSchema);
if (context.getProperty().getValidation().getEnumValues() != null) {
schema.setTitleMap(context.getProperty().getProposalDisplayNames() != null ? context.getProperty().getProposalDisplayNames().entrySet().stream().map(v -> {
final UiSchema.NameValue nameValue = new UiSchema.NameValue();
nameValue.setName(v.getKey());
nameValue.setValue(v.getValue());
return nameValue;
}).collect(toList()) : context.getProperty().getValidation().getEnumValues().stream().sorted().map(v -> {
final UiSchema.NameValue nameValue = new UiSchema.NameValue();
nameValue.setName(v);
nameValue.setValue(v);
return nameValue;
}).collect(toList()));
jsonSchema.setEnumValues(context.getProperty().getValidation().getEnumValues());
} else {
schema.setTitleMap(emptyList());
jsonSchema.setEnumValues(emptyList());
}
return context;
});
}
Aggregations