private Function createFunctionFromARecord(ARecord functionRecord) {
    String dataverseName =
        ((AString)
                functionRecord.getValueByPos(
                    MetadataRecordTypes.FUNCTION_ARECORD_DATAVERSENAME_FIELD_INDEX))
            .getStringValue();
    String functionName =
        ((AString)
                functionRecord.getValueByPos(
                    MetadataRecordTypes.FUNCTION_ARECORD_FUNCTIONNAME_FIELD_INDEX))
            .getStringValue();
    String arity =
        ((AString)
                functionRecord.getValueByPos(
                    MetadataRecordTypes.FUNCTION_ARECORD_FUNCTION_ARITY_FIELD_INDEX))
            .getStringValue();

    IACursor cursor =
        ((AOrderedList)
                functionRecord.getValueByPos(
                    MetadataRecordTypes.FUNCTION_ARECORD_FUNCTION_PARAM_LIST_FIELD_INDEX))
            .getCursor();
    List<String> params = new ArrayList<String>();
    while (cursor.next()) {
      params.add(((AString) cursor.get()).getStringValue());
    }

    String returnType =
        ((AString)
                functionRecord.getValueByPos(
                    MetadataRecordTypes.FUNCTION_ARECORD_FUNCTION_RETURN_TYPE_FIELD_INDEX))
            .getStringValue();

    String definition =
        ((AString)
                functionRecord.getValueByPos(
                    MetadataRecordTypes.FUNCTION_ARECORD_FUNCTION_DEFINITION_FIELD_INDEX))
            .getStringValue();

    String language =
        ((AString)
                functionRecord.getValueByPos(
                    MetadataRecordTypes.FUNCTION_ARECORD_FUNCTION_LANGUAGE_FIELD_INDEX))
            .getStringValue();

    String functionKind =
        ((AString)
                functionRecord.getValueByPos(
                    MetadataRecordTypes.FUNCTION_ARECORD_FUNCTION_KIND_FIELD_INDEX))
            .getStringValue();
    return new Function(
        dataverseName,
        functionName,
        Integer.parseInt(arity),
        params,
        returnType,
        definition,
        language,
        functionKind);
  }
  private Feed createFeedFromARecord(ARecord feedRecord) {
    Feed feed = null;
    String dataverseName =
        ((AString)
                feedRecord.getValueByPos(
                    MetadataRecordTypes.FEED_ARECORD_DATAVERSE_NAME_FIELD_INDEX))
            .getStringValue();
    String feedName =
        ((AString) feedRecord.getValueByPos(MetadataRecordTypes.FEED_ARECORD_FEED_NAME_FIELD_INDEX))
            .getStringValue();

    Object o = feedRecord.getValueByPos(MetadataRecordTypes.FEED_ARECORD_FUNCTION_FIELD_INDEX);
    FunctionSignature signature = null;
    if (!(o instanceof ANull)) {
      String functionName = ((AString) o).getStringValue();
      signature = new FunctionSignature(dataverseName, functionName, 1);
    }

    String feedType =
        ((AString) feedRecord.getValueByPos(MetadataRecordTypes.FEED_ARECORD_FEED_TYPE_FIELD_INDEX))
            .getStringValue();

    FeedType feedTypeEnum = FeedType.valueOf(feedType.toUpperCase());
    switch (feedTypeEnum) {
      case PRIMARY:
        {
          ARecord feedTypeDetailsRecord =
              (ARecord)
                  feedRecord.getValueByPos(
                      MetadataRecordTypes.FEED_ARECORD_PRIMARY_TYPE_DETAILS_FIELD_INDEX);
          String adapterName =
              ((AString)
                      feedTypeDetailsRecord.getValueByPos(
                          MetadataRecordTypes
                              .FEED_ARECORD_PRIMARY_FIELD_DETAILS_ADAPTOR_NAME_FIELD_INDEX))
                  .getStringValue();

          IACursor cursor =
              ((AUnorderedList)
                      feedTypeDetailsRecord.getValueByPos(
                          MetadataRecordTypes
                              .FEED_ARECORD_PRIMARY_FIELD_DETAILS_ADAPTOR_CONFIGURATION_FIELD_INDEX))
                  .getCursor();
          String key;
          String value;
          Map<String, String> adaptorConfiguration = new HashMap<String, String>();
          while (cursor.next()) {
            ARecord field = (ARecord) cursor.get();
            key =
                ((AString) field.getValueByPos(MetadataRecordTypes.PROPERTIES_NAME_FIELD_INDEX))
                    .getStringValue();
            value =
                ((AString) field.getValueByPos(MetadataRecordTypes.PROPERTIES_VALUE_FIELD_INDEX))
                    .getStringValue();
            adaptorConfiguration.put(key, value);
          }
          feed =
              new PrimaryFeed(
                  dataverseName, feedName, adapterName, adaptorConfiguration, signature);
        }
        break;
      case SECONDARY:
        {
          ARecord feedTypeDetailsRecord =
              (ARecord)
                  feedRecord.getValueByPos(
                      MetadataRecordTypes.FEED_ARECORD_SECONDARY_TYPE_DETAILS_FIELD_INDEX);

          String sourceFeedName =
              ((AString)
                      feedTypeDetailsRecord.getValueByPos(
                          MetadataRecordTypes
                              .FEED_TYPE_SECONDARY_ARECORD_SOURCE_FEED_NAME_FIELD_INDEX))
                  .getStringValue();

          feed = new SecondaryFeed(dataverseName, feedName, sourceFeedName, signature);
        }
        break;
    }

    return feed;
  }