use of org.talend.daikon.properties.property.Property in project components by Talend.
the class FixedConnectorsComponentProperties method setConnectedSchema.
@SuppressWarnings("unchecked")
@Override
public void setConnectedSchema(Connector connector, Schema schema, boolean isOutputConnection) {
if (connector instanceof PropertyPathConnector) {
NamedThing property = getProperty(((PropertyPathConnector) connector).getPropertyPath());
if (property != null) {
if (property instanceof SchemaProperties) {
SchemaProperties schemaProperties = (SchemaProperties) property;
schemaProperties.schema.setValue(schema);
} else if (property instanceof Property) {
((Property<Schema>) property).setValue(schema);
}
} else {
// else path not found so throw exception
throw new ComponentException(ComponentsErrorCode.WRONG_CONNECTOR, ExceptionContext.build().put("properties", this.getClass().getCanonicalName()));
}
}
// not a connector handled by this class
}
use of org.talend.daikon.properties.property.Property in project components by Talend.
the class FixedConnectorsComponentProperties method getSchema.
/**
* This default implementation uses {@link PropertyPathConnector} to find the SchemaProperties or Property of type
* Schema instances avaialble in this Object. It return null if none found
*/
@SuppressWarnings("unchecked")
@Override
public Schema getSchema(Connector connector, boolean isOutputConnection) {
if (connector instanceof PropertyPathConnector) {
NamedThing property = getProperty(((PropertyPathConnector) connector).getPropertyPath());
if (property != null) {
Property<Schema> schemaProp = null;
if (property instanceof SchemaProperties) {
SchemaProperties schemaProperties = (SchemaProperties) property;
schemaProp = schemaProperties.schema;
} else if (property instanceof Property) {
schemaProp = (Property<Schema>) property;
}
return schemaProp != null ? schemaProp.getValue() : null;
} else {
// else path not found so throw exception
throw new ComponentException(ComponentsErrorCode.WRONG_CONNECTOR, ExceptionContext.build().put("properties", this.getClass().getCanonicalName()));
}
}
// else not a connector handled by this class so return null
return null;
}
use of org.talend.daikon.properties.property.Property in project components by Talend.
the class TestComponentDefinition method getReturnProperties.
@Override
public Property[] getReturnProperties() {
StringProperty return1 = newProperty("return1");
setupI18N(new Property<?>[] { return1 });
return new Property[] { return1, RETURN_ERROR_MESSAGE_PROP, RETURN_TOTAL_RECORD_COUNT_PROP, RETURN_SUCCESS_RECORD_COUNT_PROP, RETURN_REJECT_RECORD_COUNT_PROP };
}
use of org.talend.daikon.properties.property.Property in project components by Talend.
the class FileDelimitedWizardTestIT method testWizard.
@Test
public void testWizard() throws Throwable {
final List<RepoProps> repoProps = new ArrayList<>();
Repository repo = new TestRepository(repoProps);
getComponentService().setRepository(repo);
Set<ComponentWizardDefinition> wizards = getComponentService().getTopLevelComponentWizards();
int count = 0;
ComponentWizardDefinition wizardDef = null;
for (ComponentWizardDefinition wizardDefinition : wizards) {
if (wizardDefinition instanceof FileDelimitedWizardDefinition) {
wizardDef = wizardDefinition;
count++;
}
}
assertEquals(1, count);
assertEquals("file delimited", wizardDef.getMenuItemName());
ComponentWizard wiz = getComponentService().getComponentWizard(FileDelimitedWizardDefinition.COMPONENT_WIZARD_NAME, "nodeFileDelimited");
assertNotNull(wiz);
assertEquals("nodeFileDelimited", wiz.getRepositoryLocation());
FileDelimitedWizard swiz = (FileDelimitedWizard) wiz;
List<Form> forms = wiz.getForms();
Form formWizard = forms.get(0);
assertEquals("Wizard", formWizard.getName());
assertFalse(formWizard.isAllowBack());
assertFalse(formWizard.isAllowForward());
assertFalse(formWizard.isAllowFinish());
assertEquals("Delimited File Settings", formWizard.getTitle());
assertEquals("", formWizard.getSubtitle());
FileDelimitedProperties wizardProps = (FileDelimitedProperties) formWizard.getProperties();
Object image = getComponentService().getWizardPngImage(FileDelimitedWizardDefinition.COMPONENT_WIZARD_NAME, WizardImageType.TREE_ICON_16X16);
assertNotNull(image);
image = getComponentService().getWizardPngImage(FileDelimitedWizardDefinition.COMPONENT_WIZARD_NAME, WizardImageType.WIZARD_BANNER_75X66);
assertNotNull(image);
// Check the non-top-level wizard
assertEquals("Name", wizardProps.getProperty("name").getDisplayName());
wizardProps.name.setValue("connName");
setupProps(wizardProps);
Form encodingForm = (Form) formWizard.getWidget("encoding").getContent();
assertEquals("Main", encodingForm.getDisplayName());
Property encodingType = (Property) encodingForm.getWidget("encodingType").getContent();
assertEquals("Encoding", encodingType.getDisplayName());
assertFalse(formWizard.getWidget(wizardProps.encoding.getName()).isHidden());
assertFalse(encodingForm.getWidget(wizardProps.encoding.encodingType.getName()).isHidden());
assertTrue(encodingForm.getWidget(wizardProps.encoding.customEncoding.getName()).isHidden());
wizardProps.encoding.encodingType.setValue(EncodingTypeProperties.ENCODING_TYPE_CUSTOM);
assertTrue(encodingForm.getWidget(wizardProps.encoding.encodingType.getName()).isCallAfter());
getComponentService().afterProperty(wizardProps.encoding.encodingType.getName(), wizardProps.encoding);
assertFalse(encodingForm.getWidget(wizardProps.encoding.customEncoding.getName()).isHidden());
wizardProps.main.schema.setValue(BASIC_SCHEMA);
ValidationResult result = wizardProps.afterFormFinishWizard(repo);
assertEquals(ValidationResult.OK, result);
// TODO Continue when finish the wizard
}
use of org.talend.daikon.properties.property.Property in project components by Talend.
the class MarkLogicInputProperties method setupLayout.
@Override
public void setupLayout() {
super.setupLayout();
Form referenceForm = new Form(this, Form.REFERENCE);
referenceForm.addRow(datasetProperties.getForm(Form.REFERENCE));
referenceForm.getWidget(datasetProperties).setVisible();
Form mainForm = new Form(this, Form.MAIN);
mainForm.addRow(connection.getForm(Form.REFERENCE));
mainForm.addRow(referenceForm);
mainForm.addRow(inputSchema.getForm(Form.REFERENCE));
mainForm.getWidget(inputSchema).setHidden();
Form inputSchemaForm = ((Form) mainForm.getWidget(inputSchema).getContent());
((Property) inputSchemaForm.getWidget(inputSchema.schema).getContent()).removeFlag(Property.Flags.HIDDEN);
mainForm.addRow(criteriaSearch);
mainForm.addRow(datasetProperties.getForm(Form.MAIN));
mainForm.addColumn(widget(docIdColumn).setWidgetType(Widget.ENUMERATION_WIDGET_TYPE));
Form advancedForm = new Form(this, Form.ADVANCED);
advancedForm.addRow(maxRetrieve);
advancedForm.addRow(datasetProperties.getForm(Form.ADVANCED));
}
Aggregations