Search in sources :

Example 36 with Property

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
}
Also used : PropertyPathConnector(org.talend.components.api.component.PropertyPathConnector) Schema(org.apache.avro.Schema) ComponentException(org.talend.components.api.exception.ComponentException) NamedThing(org.talend.daikon.NamedThing) Property(org.talend.daikon.properties.property.Property)

Example 37 with Property

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;
}
Also used : PropertyPathConnector(org.talend.components.api.component.PropertyPathConnector) Schema(org.apache.avro.Schema) ComponentException(org.talend.components.api.exception.ComponentException) NamedThing(org.talend.daikon.NamedThing) Property(org.talend.daikon.properties.property.Property)

Example 38 with Property

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 };
}
Also used : StringProperty(org.talend.daikon.properties.property.StringProperty) Property(org.talend.daikon.properties.property.Property) PropertyFactory.newProperty(org.talend.daikon.properties.property.PropertyFactory.newProperty) StringProperty(org.talend.daikon.properties.property.StringProperty)

Example 39 with Property

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
}
Also used : Form(org.talend.daikon.properties.presentation.Form) ArrayList(java.util.ArrayList) ValidationResult(org.talend.daikon.properties.ValidationResult) Repository(org.talend.daikon.properties.service.Repository) ComponentWizard(org.talend.components.api.wizard.ComponentWizard) FileDelimitedProperties(org.talend.components.filedelimited.FileDelimitedProperties) ComponentWizardDefinition(org.talend.components.api.wizard.ComponentWizardDefinition) Property(org.talend.daikon.properties.property.Property) Test(org.junit.Test)

Example 40 with Property

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));
}
Also used : Form(org.talend.daikon.properties.presentation.Form) Property(org.talend.daikon.properties.property.Property)

Aggregations

Property (org.talend.daikon.properties.property.Property)42 ComponentProperties (org.talend.components.api.properties.ComponentProperties)20 NamedThing (org.talend.daikon.NamedThing)17 Form (org.talend.daikon.properties.presentation.Form)13 ArrayList (java.util.ArrayList)11 Test (org.junit.Test)10 List (java.util.List)7 Schema (org.apache.avro.Schema)7 Properties (org.talend.daikon.properties.Properties)6 SchemaProperty (org.talend.daikon.properties.property.SchemaProperty)6 PresentationItem (org.talend.daikon.properties.PresentationItem)5 StringProperty (org.talend.daikon.properties.property.StringProperty)5 HashMap (java.util.HashMap)4 SalesforceConnectionProperties (org.talend.components.salesforce.SalesforceConnectionProperties)4 TSalesforceInputProperties (org.talend.components.salesforce.tsalesforceinput.TSalesforceInputProperties)4 SimpleNamedThing (org.talend.daikon.SimpleNamedThing)4 Map (java.util.Map)3 PropertyPathConnector (org.talend.components.api.component.PropertyPathConnector)3 ComponentWizard (org.talend.components.api.wizard.ComponentWizard)3 SalesforceModuleProperties (org.talend.components.salesforce.SalesforceModuleProperties)3