Search in sources :

Example 1 with MarkLogicConnectionProperties

use of org.talend.components.marklogic.tmarklogicconnection.MarkLogicConnectionProperties in project components by Talend.

the class MarkLogicWizardDefinition method createWizard.

@Override
public ComponentWizard createWizard(ComponentProperties properties, String location) {
    MarkLogicWizard markLogicWizard = new MarkLogicWizard(this, location);
    MarkLogicConnectionProperties connectionProperties = (MarkLogicConnectionProperties) properties;
    markLogicWizard.loadProperties(connectionProperties);
    return markLogicWizard;
}
Also used : MarkLogicConnectionProperties(org.talend.components.marklogic.tmarklogicconnection.MarkLogicConnectionProperties)

Example 2 with MarkLogicConnectionProperties

use of org.talend.components.marklogic.tmarklogicconnection.MarkLogicConnectionProperties in project components by Talend.

the class MarkLogicSourceOrSinkTest method testGetMarkLogicConnectionProperties.

@Test
public void testGetMarkLogicConnectionProperties() {
    MarkLogicInputProperties expectedInputProperties = new MarkLogicInputProperties("inputProperties");
    expectedInputProperties.init();
    sourceOrSink.initialize(null, expectedInputProperties);
    MarkLogicConnectionProperties actualConnectionProperties = sourceOrSink.getMarkLogicConnectionProperties();
    assertEquals(expectedInputProperties.connection, actualConnectionProperties);
}
Also used : MarkLogicConnectionProperties(org.talend.components.marklogic.tmarklogicconnection.MarkLogicConnectionProperties) MarkLogicInputProperties(org.talend.components.marklogic.tmarklogicinput.MarkLogicInputProperties) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 3 with MarkLogicConnectionProperties

use of org.talend.components.marklogic.tmarklogicconnection.MarkLogicConnectionProperties in project components by Talend.

the class MarkLogicInputPropertiesTest method testUseExistedConnectionHideConnectionWidget.

@Test
public void testUseExistedConnectionHideConnectionWidget() {
    MarkLogicConnectionProperties someConnection = new MarkLogicConnectionProperties("connection");
    testInputProperties.setupProperties();
    testInputProperties.connection.init();
    testInputProperties.datasetProperties.init();
    testInputProperties.inputSchema.init();
    testInputProperties.setupLayout();
    someConnection.init();
    testInputProperties.connection.referencedComponent.setReference(someConnection);
    testInputProperties.connection.referencedComponent.componentInstanceId.setValue(MarkLogicConnectionDefinition.COMPONENT_NAME + "_1");
    testInputProperties.refreshLayout(testInputProperties.getForm(Form.MAIN));
    boolean isConnectionHostPropertyHidden = testInputProperties.connection.getForm(Form.MAIN).getWidget(testInputProperties.connection.host).isHidden();
    boolean isConnectionPortPropertyHidden = testInputProperties.connection.getForm(Form.MAIN).getWidget(testInputProperties.connection.port).isHidden();
    boolean isUserNameHidden = testInputProperties.connection.getForm(Form.MAIN).getWidget(testInputProperties.connection.username).isHidden();
    boolean isPasswordHidden = testInputProperties.connection.getForm(Form.MAIN).getWidget(testInputProperties.connection.password).isHidden();
    boolean isConnectionDatabasePropertyHidden = testInputProperties.connection.getForm(Form.MAIN).getWidget(testInputProperties.connection.database).isHidden();
    assertTrue(isConnectionHostPropertyHidden);
    assertTrue(isConnectionPortPropertyHidden);
    assertTrue(isUserNameHidden);
    assertTrue(isPasswordHidden);
    assertTrue(isConnectionDatabasePropertyHidden);
}
Also used : MarkLogicConnectionProperties(org.talend.components.marklogic.tmarklogicconnection.MarkLogicConnectionProperties) Test(org.junit.Test) MarkLogicConnectionPropertiesTest(org.talend.components.marklogic.tmarklogicconnection.MarkLogicConnectionPropertiesTest)

Example 4 with MarkLogicConnectionProperties

use of org.talend.components.marklogic.tmarklogicconnection.MarkLogicConnectionProperties in project components by Talend.

the class MarkLogicConnection method connect.

/**
 * Creates new {@link DatabaseClient} connection or gets referenced one from container.
 *
 * @param container
 * @return connection to MarkLogic database.
 * @throws IOException thrown if referenced connection is not connected.
 */
public DatabaseClient connect(RuntimeContainer container) {
    MarkLogicConnectionProperties properties = getMarkLogicConnectionProperties();
    if (properties.getReferencedComponentId() != null && container != null) {
        DatabaseClient client = (DatabaseClient) container.getComponentData(properties.getReferencedComponentId(), CONNECTION);
        if (client != null) {
            return client;
        }
        throw new MarkLogicException(new MarkLogicErrorCode(MESSAGES.getMessage("error.invalid.referenceConnection", properties.getReferencedComponentId())));
    }
    SecurityContext context = "BASIC".equals(properties.authentication.getValue()) ? new DatabaseClientFactory.BasicAuthContext(properties.username.getValue(), properties.password.getValue()) : new DatabaseClientFactory.DigestAuthContext(properties.username.getValue(), properties.password.getValue());
    DatabaseClient client = DatabaseClientFactory.newClient(properties.host.getValue(), properties.port.getValue(), properties.database.getValue(), context);
    testConnection(client);
    LOGGER.info("Connected to MarkLogic server");
    if (container != null) {
        container.setComponentData(container.getCurrentComponentId(), CONNECTION, client);
        LOGGER.info("Connection stored in container");
    }
    return client;
}
Also used : MarkLogicException(org.talend.components.marklogic.exceptions.MarkLogicException) DatabaseClient(com.marklogic.client.DatabaseClient) DatabaseClientFactory(com.marklogic.client.DatabaseClientFactory) MarkLogicConnectionProperties(org.talend.components.marklogic.tmarklogicconnection.MarkLogicConnectionProperties) MarkLogicErrorCode(org.talend.components.marklogic.exceptions.MarkLogicErrorCode) SecurityContext(com.marklogic.client.DatabaseClientFactory.SecurityContext)

Example 5 with MarkLogicConnectionProperties

use of org.talend.components.marklogic.tmarklogicconnection.MarkLogicConnectionProperties in project components by Talend.

the class MarkLogicInternalBulkLoadRunnerTest method setUp.

@Before
public void setUp() {
    connectionProperties = new MarkLogicConnectionProperties("connectionProperties");
    bulkLoadProperties = new MarkLogicBulkLoadProperties("bulkLoadProperties");
    bulkLoadRuntime = new MarkLogicBulkLoad();
}
Also used : MarkLogicConnectionProperties(org.talend.components.marklogic.tmarklogicconnection.MarkLogicConnectionProperties) MarkLogicBulkLoadProperties(org.talend.components.marklogic.tmarklogicbulkload.MarkLogicBulkLoadProperties) Before(org.junit.Before)

Aggregations

MarkLogicConnectionProperties (org.talend.components.marklogic.tmarklogicconnection.MarkLogicConnectionProperties)17 Test (org.junit.Test)8 Before (org.junit.Before)7 DatabaseClient (com.marklogic.client.DatabaseClient)4 MarkLogicConnectionPropertiesTest (org.talend.components.marklogic.tmarklogicconnection.MarkLogicConnectionPropertiesTest)4 RuntimeContainer (org.talend.components.api.container.RuntimeContainer)3 MarkLogicBulkLoadProperties (org.talend.components.marklogic.tmarklogicbulkload.MarkLogicBulkLoadProperties)3 SecurityContext (com.marklogic.client.DatabaseClientFactory.SecurityContext)2 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)2 MarkLogicInputProperties (org.talend.components.marklogic.tmarklogicinput.MarkLogicInputProperties)2 DatabaseClientFactory (com.marklogic.client.DatabaseClientFactory)1 GenericDocumentManager (com.marklogic.client.document.GenericDocumentManager)1 SearchHandle (com.marklogic.client.io.SearchHandle)1 MatchDocumentSummary (com.marklogic.client.query.MatchDocumentSummary)1 QueryManager (com.marklogic.client.query.QueryManager)1 StringQueryDefinition (com.marklogic.client.query.StringQueryDefinition)1 IndexedRecord (org.apache.avro.generic.IndexedRecord)1 MarkLogicErrorCode (org.talend.components.marklogic.exceptions.MarkLogicErrorCode)1 MarkLogicException (org.talend.components.marklogic.exceptions.MarkLogicException)1 ValidationResult (org.talend.daikon.properties.ValidationResult)1