Search in sources :

Example 1 with SearchFieldInfo

use of org.talend.components.netsuite.schema.SearchFieldInfo in project components by Talend.

the class NetSuiteDatasetRuntimeImpl method getSearchInfo.

@Override
public SearchInfo getSearchInfo(String typeName) {
    try {
        final SearchRecordTypeDesc searchInfo = metaDataSource.getSearchRecordType(typeName);
        final TypeDesc searchRecordInfo = metaDataSource.getBasicMetaData().getTypeInfo(searchInfo.getSearchBasicClass());
        List<FieldDesc> fieldDescList = searchRecordInfo.getFields();
        List<SearchFieldInfo> fields = new ArrayList<>(fieldDescList.size());
        for (FieldDesc fieldDesc : fieldDescList) {
            SearchFieldInfo field = new SearchFieldInfo(fieldDesc.getName(), fieldDesc.getValueType());
            fields.add(field);
        }
        // Sort by display name in alphabetical order
        Collections.sort(fields, new Comparator<SearchFieldInfo>() {

            @Override
            public int compare(SearchFieldInfo o1, SearchFieldInfo o2) {
                return o1.getName().compareTo(o2.getName());
            }
        });
        return new SearchInfo(searchRecordInfo.getTypeName(), fields);
    } catch (NetSuiteException e) {
        throw new ComponentException(e);
    }
}
Also used : SearchRecordTypeDesc(org.talend.components.netsuite.client.model.SearchRecordTypeDesc) SearchFieldInfo(org.talend.components.netsuite.schema.SearchFieldInfo) SearchInfo(org.talend.components.netsuite.schema.SearchInfo) SearchRecordTypeDesc(org.talend.components.netsuite.client.model.SearchRecordTypeDesc) RecordTypeDesc(org.talend.components.netsuite.client.model.RecordTypeDesc) TypeDesc(org.talend.components.netsuite.client.model.TypeDesc) ArrayList(java.util.ArrayList) ComponentException(org.talend.components.api.exception.ComponentException) NetSuiteException(org.talend.components.netsuite.client.NetSuiteException) CustomFieldDesc(org.talend.components.netsuite.client.model.CustomFieldDesc) FieldDesc(org.talend.components.netsuite.client.model.FieldDesc)

Example 2 with SearchFieldInfo

use of org.talend.components.netsuite.schema.SearchFieldInfo in project components by Talend.

the class NetSuitePropertiesTestBase method createTestDataset1.

protected TestDataset createTestDataset1() {
    TestDataset dataset = new TestDataset();
    dataset.getRecordTypes().addAll(Arrays.<NamedThing>asList(new SimpleNamedThing("Account"), new SimpleNamedThing("Opportunity")));
    dataset.getSearchableTypes().addAll(Arrays.<NamedThing>asList(new SimpleNamedThing("Account"), new SimpleNamedThing("Opportunity"), new SimpleNamedThing("Transaction")));
    dataset.getTypeSchemaMap().put("Account", SchemaBuilder.builder().record("Account").fields().name("AccountField1").type(AvroUtils._boolean()).noDefault().name("AccountField2").type(AvroUtils._string()).noDefault().name("AccountField3").type(AvroUtils._logicalTimestamp()).noDefault().endRecord());
    dataset.getTypeSchemaMap().put("Opportunity", SchemaBuilder.builder().record("Opportunity").fields().name("OpportunityField1").type(AvroUtils._boolean()).noDefault().name("OpportunityField2").type(AvroUtils._double()).noDefault().name("OpportunityField3").type(AvroUtils._logicalTimestamp()).noDefault().endRecord());
    dataset.getTypeSchemaMap().put("RecordRef", SchemaBuilder.builder().record("RecordRef").fields().name("InternalId").type(AvroUtils._boolean()).noDefault().name("Type").type(AvroUtils._string()).noDefault().endRecord());
    dataset.getSearchOperators().addAll(Arrays.<NamedThing>asList(new SimpleNamedThing("Boolean"), new SimpleNamedThing("Date.onOrAfter"), new SimpleNamedThing("String.contains")));
    dataset.getSearchInfoMap().put("Account", new SearchInfo("Account", Arrays.asList(new SearchFieldInfo("AccountField1", Boolean.class), new SearchFieldInfo("AccountField2", String.class), new SearchFieldInfo("AccountField3", XMLGregorianCalendar.class))));
    dataset.getSearchInfoMap().put("Opportunity", new SearchInfo("Opportunity", Arrays.asList(new SearchFieldInfo("OpportunityField1", Boolean.class), new SearchFieldInfo("OpportunityField2", Double.class), new SearchFieldInfo("OpportunityField3", XMLGregorianCalendar.class))));
    return dataset;
}
Also used : XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar) SearchInfo(org.talend.components.netsuite.schema.SearchInfo) SearchFieldInfo(org.talend.components.netsuite.schema.SearchFieldInfo) SimpleNamedThing(org.talend.daikon.SimpleNamedThing) Matchers.anyString(org.mockito.Matchers.anyString)

Example 3 with SearchFieldInfo

use of org.talend.components.netsuite.schema.SearchFieldInfo in project components by Talend.

the class NetSuiteInputModuleProperties method setupSearchSchema.

/**
 * Set up search query design-time model.
 */
private void setupSearchSchema() {
    assertModuleName();
    SearchInfo searchSchema = getSearchInfo(moduleName.getValue());
    List<String> fieldNames = new ArrayList<>(searchSchema.getFields().size());
    for (SearchFieldInfo field : searchSchema.getFields()) {
        fieldNames.add(field.getName());
    }
    // Set up list of available search fields
    searchQuery.field.setPossibleValues(fieldNames);
    searchQuery.field.setValue(new ArrayList<String>());
    // Set up list of search operators
    searchQuery.operator.setPossibleValues(getSearchFieldOperators());
    searchQuery.operator.setValue(new ArrayList<String>());
    // Clear search values
    searchQuery.value1.setValue(new ArrayList<>());
    searchQuery.value2.setValue(new ArrayList<>());
    searchQuery.refreshLayout(searchQuery.getForm(Form.MAIN));
}
Also used : SearchInfo(org.talend.components.netsuite.schema.SearchInfo) SearchFieldInfo(org.talend.components.netsuite.schema.SearchFieldInfo) ArrayList(java.util.ArrayList)

Aggregations

SearchFieldInfo (org.talend.components.netsuite.schema.SearchFieldInfo)3 SearchInfo (org.talend.components.netsuite.schema.SearchInfo)3 ArrayList (java.util.ArrayList)2 XMLGregorianCalendar (javax.xml.datatype.XMLGregorianCalendar)1 Matchers.anyString (org.mockito.Matchers.anyString)1 ComponentException (org.talend.components.api.exception.ComponentException)1 NetSuiteException (org.talend.components.netsuite.client.NetSuiteException)1 CustomFieldDesc (org.talend.components.netsuite.client.model.CustomFieldDesc)1 FieldDesc (org.talend.components.netsuite.client.model.FieldDesc)1 RecordTypeDesc (org.talend.components.netsuite.client.model.RecordTypeDesc)1 SearchRecordTypeDesc (org.talend.components.netsuite.client.model.SearchRecordTypeDesc)1 TypeDesc (org.talend.components.netsuite.client.model.TypeDesc)1 SimpleNamedThing (org.talend.daikon.SimpleNamedThing)1