getReferentFieldByFullPath method

NsgDataBaseReferenceField<NsgDataItem>? getReferentFieldByFullPath(
  1. Type dataType,
  2. String fullPath
)

Implementation

NsgDataBaseReferenceField? getReferentFieldByFullPath(Type dataType, String fullPath) {
  var splitedPath = fullPath.split('.');
  var type = dataType;
  var fieldFound = false;
  NsgDataBaseReferenceField? foundField;
  for (var i = 0; i < splitedPath.length; i++) {
    fieldFound = false;
    var fieldList = NsgDataClient.client.getFieldList(type);
    if (fieldList.fields.containsKey(splitedPath[i])) {
      var field = fieldList.fields[splitedPath[i]];
      if (field is NsgDataReferenceField) {
        type = field.referentType;
        foundField = field;
        fieldFound = true;
      } else if (field is NsgDataReferenceListField) {
        type = field.referentElementType;
        fieldFound = true;
        foundField = field;
      }
    }
  }
  if (fieldFound) {
    return foundField;
  } else {
    return null;
  }
}