public static function prepareDataSource(EnvironmentMetaModel $environment_metamodel, $datamartNode) {
        $datasource = new DataSourceMetaData();
        $datasource->name = self::prepareDataSourceName($datamartNode);
        $datasource->publicName = $datamartNode->title;
        $datasource->description = get_node_field_value($datamartNode, 'field_datamart_desc');

        $datasource->parentName = get_node_field_value($datamartNode, 'field_datamart_parent_sysname');
        $datasource->type = get_node_field_value($datamartNode, 'field_datamart_type');
        $datasource->readonly = get_node_field_boolean_value($datamartNode, 'field_datamart_readonly');

        $datasource->initializeFrom(get_node_field_object_value($datamartNode, 'field_datamart_options'));

        // datasource system properties
        $datasource->nid = $datamartNode->nid;

        // marking as public to prevent the property from being populated from parent data source (which can be private)
        $datasource->markAsPublic();

        $environment_metamodel->registerDataSource($datasource);

        return $datasource;
    }
    public static function prepareDataset(MetaModel $metamodel, $datasetNode, array $datasetColumnNodes = NULL, DataSourceMetaData $datasource) {
        $dataset = new DatasetMetaData();
        $dataset->name = get_node_field_value($datasetNode, 'field_dataset_sysname', 0, 'value', TRUE);
        $dataset->publicName = $datasetNode->title;

        // preparing the dataset alternative names (aliases)
        $aliasIndex = 0;
        while (($alias = get_node_field_value($datasetNode, 'field_dataset_alias', $aliasIndex)) != NULL) {
            $dataset->aliases[] = $alias;

            $aliasIndex++;
        }

        $dataset->description = get_node_field_value($datasetNode, 'field_dataset_desc');

        $dataset->datasourceName = $datasource->name;

        // preparing source configuration properties
        $dataset->sourceType = get_node_field_value($datasetNode, 'field_dataset_source_type', 0, 'value', TRUE);
        $dataset->source = get_node_field_value($datasetNode, 'field_dataset_source', 0, 'value', TRUE);
        // preparing source properties as an associative array
        $dataset->configuration = get_node_field_object_value($datasetNode, 'field_dataset_source_properties');

        // dataset system properties
        $dataset->uuid = get_node_field_value($datasetNode, 'field_dataset_uuid', 0, 'value', TRUE);
        $dataset->nid = $datasetNode->nid;

        // preparing dataset columns
        if (isset($datasetColumnNodes)) {
            foreach ($datasetColumnNodes as $columnNode) {
                $column = $dataset->initiateColumn();
                $column->used = $columnNode->status == NODE_PUBLISHED;

                $column->name = get_node_field_value($columnNode, 'field_column_sysname', 0, 'value', TRUE);
                $column->publicName = $columnNode->title;
                $column->description = get_node_field_value($columnNode, 'field_column_desc');
                $column->key = get_node_field_boolean_value($columnNode, 'field_column_key');

                // column data type
                $column->type->applicationType = get_node_field_value($columnNode, 'field_column_datatype', 0, 'value', $column->used);
                if (isset($column->type->applicationType) && ($column->type->getReferencedDatasetName() == NULL)) {
                    $column->type->logicalApplicationType = NameSpaceHelper::addNameSpace(NAME_SPACE__STAR_SCHEMA, $column->type->applicationType);
                }
                $format = get_node_field_object_value($columnNode, 'field_column_format');
                if (isset($format->scale)) {
                    $column->type->scale = $format->scale;
                }

                $column->columnIndex = get_node_field_int_value($columnNode, 'field_column_index', 0, 'value', TRUE);
                $column->source = get_node_field_value($columnNode, 'field_column_source');
                $column->persistence = get_node_field_int_value($columnNode, 'field_column_persistence', 0, 'value', TRUE);

                // attribute system properties
                $column->nid = $columnNode->nid;

                $dataset->registerColumnInstance($column);
            }
        }

        // marking that the dataset object contains complete meta data
        $dataset->markAsComplete();

        $metamodel->registerDataset($dataset);

        return $dataset;
    }