use of org.talend.components.netsuite.client.model.RecordTypeDesc in project components by Talend.
the class NetSuiteDatasetRuntimeImpl method readCustomRecord.
/**
* Read custom record meta data from a given <code>JsonProperties</code>.
*
* @see NetSuiteSchemaConstants
*
* @param basicMetaData basic meta data
* @param properties properties object which to read meta data from
* @return custom record type info or <code>null</code> if meta data was not found
*/
public static CustomRecordTypeInfo readCustomRecord(BasicMetaData basicMetaData, JsonProperties properties) {
String scriptId = properties.getProp(NetSuiteSchemaConstants.NS_CUSTOM_RECORD_SCRIPT_ID);
if (StringUtils.isEmpty(scriptId)) {
return null;
}
String internalId = properties.getProp(NetSuiteSchemaConstants.NS_CUSTOM_RECORD_INTERNAL_ID);
String customizationType = properties.getProp(NetSuiteSchemaConstants.NS_CUSTOM_RECORD_CUSTOMIZATION_TYPE);
String recordType = properties.getProp(NetSuiteSchemaConstants.NS_CUSTOM_RECORD_TYPE);
NsRef ref = new NsRef();
ref.setRefType(RefType.CUSTOMIZATION_REF);
ref.setScriptId(scriptId);
ref.setInternalId(internalId);
ref.setType(customizationType);
RecordTypeDesc recordTypeDesc = basicMetaData.getRecordType(recordType);
CustomRecordTypeInfo recordTypeInfo = new CustomRecordTypeInfo(scriptId, recordTypeDesc, ref);
return recordTypeInfo;
}
use of org.talend.components.netsuite.client.model.RecordTypeDesc 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()));
}
}
use of org.talend.components.netsuite.client.model.RecordTypeDesc in project components by Talend.
the class DefaultMetaDataSource method getRecordTypes.
/**
* {@inheritDoc}
*/
@Override
public Collection<RecordTypeInfo> getRecordTypes() {
List<RecordTypeInfo> recordTypes = new ArrayList<>();
Collection<RecordTypeDesc> standardRecordTypes = clientService.getBasicMetaData().getRecordTypes();
for (RecordTypeDesc recordType : standardRecordTypes) {
recordTypes.add(new RecordTypeInfo(recordType));
}
if (customizationEnabled) {
recordTypes.addAll(customMetaDataSource.getCustomRecordTypes());
}
return recordTypes;
}
use of org.talend.components.netsuite.client.model.RecordTypeDesc in project components by Talend.
the class DefaultCustomMetaDataSource method retrieveCustomRecordTypes.
/**
* Retrieve custom record types from NetSuite web service.
*
* @see #customRecordTypeMap
*
* @throws NetSuiteException if an error occurs during retrieving of customization data
*/
protected void retrieveCustomRecordTypes() throws NetSuiteException {
if (customRecordTypesLoaded) {
return;
}
List<NsRef> customTypes = new ArrayList<>();
List<NsRef> customRecordTypes = customMetaDataRetriever.retrieveCustomizationIds(BasicRecordType.CUSTOM_RECORD_TYPE);
customTypes.addAll(customRecordTypes);
List<NsRef> customTransactionTypes = customMetaDataRetriever.retrieveCustomizationIds(BasicRecordType.CUSTOM_TRANSACTION_TYPE);
customTypes.addAll(customTransactionTypes);
for (NsRef customizationRef : customTypes) {
String recordType = customizationRef.getType();
RecordTypeDesc recordTypeDesc = null;
BasicRecordType basicRecordType = BasicRecordType.getByType(recordType);
if (basicRecordType != null) {
recordTypeDesc = clientService.getBasicMetaData().getRecordType(toInitialUpper(basicRecordType.getSearchType()));
}
CustomRecordTypeInfo customRecordTypeInfo = new CustomRecordTypeInfo(customizationRef.getScriptId(), recordTypeDesc, customizationRef);
customRecordTypeMap.put(customRecordTypeInfo.getName(), customRecordTypeInfo);
}
customRecordTypesLoaded = true;
}
use of org.talend.components.netsuite.client.model.RecordTypeDesc in project components by Talend.
the class DefaultCustomMetaDataSource method getCustomFieldsImpl.
/**
* Get custom field descriptors for a given record type.
*
* @param recordTypeInfo record type info
* @return custom field descriptors as map
* @throws NetSuiteException if an error occurs during obtaining of customization data
*/
protected Map<String, CustomFieldDesc> getCustomFieldsImpl(RecordTypeInfo recordTypeInfo) throws NetSuiteException {
RecordTypeDesc recordType = recordTypeInfo.getRecordType();
Map<String, CustomFieldDesc> fieldDescMap;
if (recordTypeInfo instanceof CustomRecordTypeInfo) {
fieldDescMap = customRecordCustomFieldMap.get(recordTypeInfo.getName());
if (fieldDescMap == null) {
retrieveCustomRecordCustomFields((CustomRecordTypeInfo) recordTypeInfo);
fieldDescMap = customRecordCustomFieldMap.get(recordTypeInfo.getName());
}
} else {
fieldDescMap = recordCustomFieldMap.get(recordType.getType());
if (fieldDescMap == null) {
retrieveCustomFields(recordType);
fieldDescMap = recordCustomFieldMap.get(recordType.getType());
}
}
return fieldDescMap;
}
Aggregations