Search in sources :

Example 61 with NamedThing

use of org.talend.daikon.NamedThing in project components by Talend.

the class MarketoCustomObjectsSchemasProperties method afterFormFinishCustomObjects.

public ValidationResult afterFormFinishCustomObjects(Repository<Properties> repo) throws Exception {
    try (SandboxedInstance sandboxedInstance = getSandboxedInstance(RUNTIME_SOURCEORSINK_CLASS, USE_CURRENT_JVM_PROPS)) {
        MarketoSourceOrSinkRuntime sos = (MarketoSourceOrSinkRuntime) sandboxedInstance.getInstance();
        sos.initialize(null, this);
        try {
            String repoLoc = repo.storeProperties(connection, connection.name.getValue(), repositoryLocation, null);
            String storeId;
            for (NamedThing nl : selectedCustomObjectsNames.getValue()) {
                String customObjectId = nl.getName();
                storeId = nl.getName().replaceAll("-", "_").replaceAll(" ", "_");
                MarketoComponentWizardBaseProperties customObjectProps = new MarketoComponentWizardBaseProperties(customObjectId);
                customObjectProps.init();
                customObjectProps.connection = connection;
                customObjectProps.inputOperation.setValue(InputOperation.CustomObject);
                customObjectProps.outputOperation.setValue(OutputOperation.syncCustomObjects);
                customObjectProps.customObjectAction.setValue(CustomObjectAction.get);
                customObjectProps.customObjectSyncAction.setValue(CustomObjectSyncAction.createOrUpdate);
                customObjectProps.schemaInput.schema.setValue(sos.getEndpointSchema(null, customObjectId));
                customObjectProps.customObjectName.setValue(nl.getName());
                repo.storeProperties(customObjectProps, storeId, repoLoc, "schemaInput.schema");
            }
        } catch (Exception e) {
            ValidationResultMutable vr = new ValidationResultMutable();
            vr.setStatus(Result.ERROR);
            vr.setMessage(e.getMessage());
            return vr;
        }
    }
    return ValidationResult.OK;
}
Also used : MarketoComponentDefinition.getSandboxedInstance(org.talend.components.marketo.MarketoComponentDefinition.getSandboxedInstance) SandboxedInstance(org.talend.daikon.sandbox.SandboxedInstance) MarketoSourceOrSinkRuntime(org.talend.components.marketo.runtime.MarketoSourceOrSinkRuntime) ValidationResultMutable(org.talend.daikon.properties.ValidationResultMutable) NamedThing(org.talend.daikon.NamedThing) IOException(java.io.IOException)

Example 62 with NamedThing

use of org.talend.daikon.NamedThing in project components by Talend.

the class MarketoSourceOrSinkTestIT method testGetSchemaNames.

@Test
public void testGetSchemaNames() throws Exception {
    TMarketoInputProperties props = new TMarketoInputProperties("test");
    props.connection.setupProperties();
    props.setupProperties();
    props.connection.endpoint.setValue(MarketoBaseTestIT.ENDPOINT_REST);
    props.connection.clientAccessId.setValue(MarketoBaseTestIT.USERID_REST);
    props.connection.secretKey.setValue(MarketoBaseTestIT.SECRETKEY_REST);
    MarketoSourceOrSink sos = new MarketoSourceOrSink();
    sos.initialize(null, props);
    List<NamedThing> cos = sos.getSchemaNames(null);
    assertFalse(cos.isEmpty());
}
Also used : TMarketoInputProperties(org.talend.components.marketo.tmarketoinput.TMarketoInputProperties) NamedThing(org.talend.daikon.NamedThing) Test(org.junit.Test)

Example 63 with NamedThing

use of org.talend.daikon.NamedThing in project components by Talend.

the class NetSuiteDatasetRuntimeImpl method getRecordTypes.

@Override
public List<NamedThing> getRecordTypes() {
    try {
        Collection<RecordTypeInfo> recordTypeList = metaDataSource.getRecordTypes();
        List<NamedThing> recordTypes = new ArrayList<>(recordTypeList.size());
        for (RecordTypeInfo recordTypeInfo : recordTypeList) {
            recordTypes.add(new SimpleNamedThing(recordTypeInfo.getName(), recordTypeInfo.getDisplayName()));
        }
        // Sort by display name in alphabetical order
        Collections.sort(recordTypes, new Comparator<NamedThing>() {

            @Override
            public int compare(NamedThing o1, NamedThing o2) {
                return o1.getDisplayName().compareTo(o2.getDisplayName());
            }
        });
        return recordTypes;
    } catch (NetSuiteException e) {
        throw new ComponentException(e);
    }
}
Also used : RecordTypeInfo(org.talend.components.netsuite.client.model.RecordTypeInfo) CustomRecordTypeInfo(org.talend.components.netsuite.client.model.CustomRecordTypeInfo) SimpleNamedThing(org.talend.daikon.SimpleNamedThing) ArrayList(java.util.ArrayList) ComponentException(org.talend.components.api.exception.ComponentException) NetSuiteException(org.talend.components.netsuite.client.NetSuiteException) NamedThing(org.talend.daikon.NamedThing) SimpleNamedThing(org.talend.daikon.SimpleNamedThing)

Example 64 with NamedThing

use of org.talend.daikon.NamedThing in project components by Talend.

the class MetaDataSourceTest method testGetSearchableTypes.

@Test
public void testGetSearchableTypes() {
    Collection<NamedThing> searchableTypeNamedThings = metaDataSource.getSearchableTypes();
    assertNotNull(searchableTypeNamedThings);
    assertFalse(searchableTypeNamedThings.isEmpty());
    Set<String> searchableTypeNames = new HashSet<>();
    for (NamedThing namedThing : searchableTypeNamedThings) {
        assertNotNull(namedThing);
        searchableTypeNames.add(namedThing.getName());
    }
    for (RecordTypeDesc recordTypeDesc : TestRecordTypeEnum.values()) {
        if (recordTypeDesc.getSearchRecordType() != null) {
            assertTrue(recordTypeDesc.getTypeName(), searchableTypeNames.contains(recordTypeDesc.getTypeName()));
        }
    }
    for (RecordTypeInfo recordTypeInfo : customMetaDataSource.getCustomRecordTypes()) {
        assertTrue(recordTypeInfo.getName(), searchableTypeNames.contains(recordTypeInfo.getName()));
    }
}
Also used : RecordTypeInfo(org.talend.components.netsuite.client.model.RecordTypeInfo) SearchRecordTypeDesc(org.talend.components.netsuite.client.model.SearchRecordTypeDesc) RecordTypeDesc(org.talend.components.netsuite.client.model.RecordTypeDesc) NamedThing(org.talend.daikon.NamedThing) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 65 with NamedThing

use of org.talend.daikon.NamedThing in project components by Talend.

the class NetSuiteClientServiceIT method testGetSearchableTypes.

@Test
public void testGetSearchableTypes() throws Exception {
    NetSuiteClientService<?> connection = webServiceTestFixture.getClientService();
    connection.login();
    Collection<NamedThing> searches = connection.getMetaDataSource().getSearchableTypes();
    for (NamedThing search : searches) {
        assertNotNull(search);
        assertNotNull(search.getName());
        assertNotNull(search.getDisplayName());
        SearchRecordTypeDesc searchRecordInfo = connection.getMetaDataSource().getSearchRecordType(search.getName());
        assertNotNull("Search record def found: " + search.getName(), searchRecordInfo);
    }
}
Also used : SearchRecordTypeDesc(org.talend.components.netsuite.client.model.SearchRecordTypeDesc) NamedThing(org.talend.daikon.NamedThing) Test(org.junit.Test)

Aggregations

NamedThing (org.talend.daikon.NamedThing)71 SimpleNamedThing (org.talend.daikon.SimpleNamedThing)34 ArrayList (java.util.ArrayList)33 Test (org.junit.Test)21 Property (org.talend.daikon.properties.property.Property)17 ComponentProperties (org.talend.components.api.properties.ComponentProperties)15 ComponentException (org.talend.components.api.exception.ComponentException)14 Schema (org.apache.avro.Schema)11 SandboxedInstance (org.talend.daikon.sandbox.SandboxedInstance)9 ValidationResult (org.talend.daikon.properties.ValidationResult)8 Form (org.talend.daikon.properties.presentation.Form)8 List (java.util.List)7 IOException (java.io.IOException)6 PresentationItem (org.talend.daikon.properties.PresentationItem)6 Properties (org.talend.daikon.properties.Properties)6 ComponentWizard (org.talend.components.api.wizard.ComponentWizard)5 GenericElementParameter (org.talend.designer.core.generic.model.GenericElementParameter)5 PropertyPathConnector (org.talend.components.api.component.PropertyPathConnector)4 ComponentWizardDefinition (org.talend.components.api.wizard.ComponentWizardDefinition)4 SearchRecordTypeDesc (org.talend.components.netsuite.client.model.SearchRecordTypeDesc)4