From 30afbfb61954848d94e668daccc21eb38a7a63b4 Mon Sep 17 00:00:00 2001
From: Manas Bajaj <manas.bajaj@gmail.com>
Date: Mon, 29 Jan 2024 19:17:13 -0500
Subject: [PATCH 1/2] Added Element_Owned_Elements recipe and a Spacecraft
 example for Req Str Behavior decomposition recipe

---
 Element_Owned_Elements.ipynb                  | 480 ++++++++++++++++++
 Project_Commit_Branch_Tag_Recipe.ipynb        |   2 +-
 ...omposition_Recipe_Spacecraft_Example.ipynb | 386 ++++++++++++++
 3 files changed, 867 insertions(+), 1 deletion(-)
 create mode 100644 Element_Owned_Elements.ipynb
 create mode 100644 Req_Str_Beh_Decomposition_Recipe_Spacecraft_Example.ipynb

diff --git a/Element_Owned_Elements.ipynb b/Element_Owned_Elements.ipynb
new file mode 100644
index 0000000..181365a
--- /dev/null
+++ b/Element_Owned_Elements.ipynb
@@ -0,0 +1,480 @@
+{
+ "cells": [
+  {
+   "cell_type": "markdown",
+   "id": "3ee4834f",
+   "metadata": {},
+   "source": [
+    "# Initializing the SysML v2 API"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 12,
+   "id": "6b5fef59",
+   "metadata": {},
+   "outputs": [],
+   "source": [
+    "from __future__ import print_function\n",
+    "\n",
+    "import time\n",
+    "import requests\n",
+    "from pprint import pprint\n",
+    "import pandas as pd\n",
+    "import json\n",
+    "\n",
+    "#host = \"<specify protocol://host:port of the server that is a provider of the SysML v2 REST/HTTP API\"\n",
+    "host = \"Specify the URL of the SysML v2 API and Service Repository\""
+   ]
+  },
+  {
+   "cell_type": "markdown",
+   "id": "04c1ff93",
+   "metadata": {},
+   "source": [
+    "# Get projects"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 13,
+   "id": "78788ed9",
+   "metadata": {},
+   "outputs": [
+    {
+     "data": {
+      "text/html": [
+       "<div>\n",
+       "<style scoped>\n",
+       "    .dataframe tbody tr th:only-of-type {\n",
+       "        vertical-align: middle;\n",
+       "    }\n",
+       "\n",
+       "    .dataframe tbody tr th {\n",
+       "        vertical-align: top;\n",
+       "    }\n",
+       "\n",
+       "    .dataframe thead th {\n",
+       "        text-align: right;\n",
+       "    }\n",
+       "</style>\n",
+       "<table border=\"1\" class=\"dataframe\">\n",
+       "  <thead>\n",
+       "    <tr style=\"text-align: right;\">\n",
+       "      <th></th>\n",
+       "      <th>Project Name</th>\n",
+       "      <th>Project ID</th>\n",
+       "    </tr>\n",
+       "  </thead>\n",
+       "  <tbody>\n",
+       "    <tr>\n",
+       "      <th>0</th>\n",
+       "      <td>5-State-based Behavior-1a Fri Mar 10 17:37:14 ...</td>\n",
+       "      <td>024b1aa6-7489-4106-bf2d-498f441f3d56</td>\n",
+       "    </tr>\n",
+       "    <tr>\n",
+       "      <th>1</th>\n",
+       "      <td>13a-Model Containment Fri Mar 10 16:52:40 EST ...</td>\n",
+       "      <td>083a7c88-757c-41ff-89db-bc34a12b7794</td>\n",
+       "    </tr>\n",
+       "    <tr>\n",
+       "      <th>2</th>\n",
+       "      <td>SimpleQuadcopter Fri Mar 10 17:54:58 EST 2023</td>\n",
+       "      <td>092dd68d-887f-4553-8ed2-05d405fb3a47</td>\n",
+       "    </tr>\n",
+       "    <tr>\n",
+       "      <th>3</th>\n",
+       "      <td>15_05-Unification of Expression and Constraint...</td>\n",
+       "      <td>098d5715-5dee-46d1-bdf8-ab96f1cc9fc6</td>\n",
+       "    </tr>\n",
+       "    <tr>\n",
+       "      <th>4</th>\n",
+       "      <td>7b-Variant Configurations Fri Mar 10 17:38:53 ...</td>\n",
+       "      <td>0b773e83-226e-4e20-ad89-5cbf1381b401</td>\n",
+       "    </tr>\n",
+       "    <tr>\n",
+       "      <th>...</th>\n",
+       "      <td>...</td>\n",
+       "      <td>...</td>\n",
+       "    </tr>\n",
+       "    <tr>\n",
+       "      <th>89</th>\n",
+       "      <td>14b-Language Extensions Fri Mar 10 17:49:37 ES...</td>\n",
+       "      <td>f97580aa-646c-4895-a8cb-006cd7538bb6</td>\n",
+       "    </tr>\n",
+       "    <tr>\n",
+       "      <th>90</th>\n",
+       "      <td>18-Use Case Fri Mar 10 17:00:37 EST 2023</td>\n",
+       "      <td>fa2bae57-4b5e-46e0-a0ef-ede2f121ea1f</td>\n",
+       "    </tr>\n",
+       "    <tr>\n",
+       "      <th>91</th>\n",
+       "      <td>AnalysisAnnotation2 Wed Aug 30 04:36:12 UTC 2023</td>\n",
+       "      <td>fb6d4f79-04e0-4a73-b11a-09263b79d7c3</td>\n",
+       "    </tr>\n",
+       "    <tr>\n",
+       "      <th>92</th>\n",
+       "      <td>11b-Safety and Security Feature Views Fri Mar ...</td>\n",
+       "      <td>fc58c0ac-58ea-4a19-90d7-c9e2f1c6da84</td>\n",
+       "    </tr>\n",
+       "    <tr>\n",
+       "      <th>93</th>\n",
+       "      <td>5-State-based Behavior-1 Fri Mar 10 17:36:13 E...</td>\n",
+       "      <td>fd341050-37b5-419e-be67-987ab836f668</td>\n",
+       "    </tr>\n",
+       "  </tbody>\n",
+       "</table>\n",
+       "<p>94 rows × 2 columns</p>\n",
+       "</div>"
+      ],
+      "text/plain": [
+       "                                         Project Name  \\\n",
+       "0   5-State-based Behavior-1a Fri Mar 10 17:37:14 ...   \n",
+       "1   13a-Model Containment Fri Mar 10 16:52:40 EST ...   \n",
+       "2       SimpleQuadcopter Fri Mar 10 17:54:58 EST 2023   \n",
+       "3   15_05-Unification of Expression and Constraint...   \n",
+       "4   7b-Variant Configurations Fri Mar 10 17:38:53 ...   \n",
+       "..                                                ...   \n",
+       "89  14b-Language Extensions Fri Mar 10 17:49:37 ES...   \n",
+       "90           18-Use Case Fri Mar 10 17:00:37 EST 2023   \n",
+       "91   AnalysisAnnotation2 Wed Aug 30 04:36:12 UTC 2023   \n",
+       "92  11b-Safety and Security Feature Views Fri Mar ...   \n",
+       "93  5-State-based Behavior-1 Fri Mar 10 17:36:13 E...   \n",
+       "\n",
+       "                              Project ID  \n",
+       "0   024b1aa6-7489-4106-bf2d-498f441f3d56  \n",
+       "1   083a7c88-757c-41ff-89db-bc34a12b7794  \n",
+       "2   092dd68d-887f-4553-8ed2-05d405fb3a47  \n",
+       "3   098d5715-5dee-46d1-bdf8-ab96f1cc9fc6  \n",
+       "4   0b773e83-226e-4e20-ad89-5cbf1381b401  \n",
+       "..                                   ...  \n",
+       "89  f97580aa-646c-4895-a8cb-006cd7538bb6  \n",
+       "90  fa2bae57-4b5e-46e0-a0ef-ede2f121ea1f  \n",
+       "91  fb6d4f79-04e0-4a73-b11a-09263b79d7c3  \n",
+       "92  fc58c0ac-58ea-4a19-90d7-c9e2f1c6da84  \n",
+       "93  fd341050-37b5-419e-be67-987ab836f668  \n",
+       "\n",
+       "[94 rows x 2 columns]"
+      ]
+     },
+     "metadata": {},
+     "output_type": "display_data"
+    }
+   ],
+   "source": [
+    "projects_url = f\"{host}/projects\" \n",
+    "projects_response = requests.get(projects_url)\n",
+    "\n",
+    "if projects_response.status_code == 200:\n",
+    "    projects = projects_response.json()\n",
+    "    \n",
+    "    df = pd.DataFrame({'Project Name':[], 'Project ID':[]})\n",
+    "    for p in projects:\n",
+    "        df = pd.concat([df, pd.DataFrame({'Project Name':[p['name']], 'Project ID':[p['@id']]})], ignore_index=True)\n",
+    "    display(df)"
+   ]
+  },
+  {
+   "cell_type": "markdown",
+   "id": "d815e4fe",
+   "metadata": {},
+   "source": [
+    "# Define functions to get owned elements - immediate and recursive\n",
+    "## Define a function to get an element and print its name and type"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 14,
+   "id": "24e17d21-71ce-4573-960f-7533aca63337",
+   "metadata": {},
+   "outputs": [],
+   "source": [
+    "def get_element(project_id, commit_id, element_id, indent):\n",
+    "     # Fetch the element in the given commit of the given project\n",
+    "    element_url = f\"{host}/projects/{project_id}/commits/{commit_id}/elements/{element_id}\" \n",
+    "    response = requests.get(element_url)\n",
+    "    \n",
+    "    if response.status_code == 200:\n",
+    "        element_data = response.json()\n",
+    "        element_name_to_print = element_data['name'] if element_data['name'] else 'N/A'\n",
+    "        element_type = element_data ['@type']\n",
+    "        print(f\"{indent} - {element_name_to_print} ({element_type})\")\n",
+    "        return element_data\n",
+    "    else:\n",
+    "        return None"
+   ]
+  },
+  {
+   "cell_type": "markdown",
+   "id": "6a004c71-9feb-4b7b-926c-c9378efd8587",
+   "metadata": {},
+   "source": [
+    "## Define a function to get owned elements (immediate) for a given element"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 15,
+   "id": "07216712-9c1c-4729-b940-cfa220bd8291",
+   "metadata": {},
+   "outputs": [],
+   "source": [
+    "# Returns direct / immediate owned elements for a given element in a given commit of a given project\n",
+    "def get_owned_elements_immediate(project_id, commit_id, element_id, indent):\n",
+    "    \n",
+    "    # Fetch the element in the given commit of the given project\n",
+    "    element_data = get_element(project_id, commit_id, element_id, indent)\n",
+    "    \n",
+    "    if element_data:\n",
+    "        owned_elements = element_data['ownedElement']\n",
+    "        if len(owned_elements) > 0:\n",
+    "            for owned_element in owned_elements:\n",
+    "                get_element(project_id, commit_id, owned_element['@id'], indent + '  ')\n",
+    "    else:\n",
+    "        print(f\"Unable to fetch element with id '{element_id}' in commit '{commit_id}' of project '{project_id}'\")"
+   ]
+  },
+  {
+   "cell_type": "markdown",
+   "id": "65b74b05-7037-4382-b799-4df2cc6b0e03",
+   "metadata": {},
+   "source": [
+    "## Define a function to get owned elements (recursive) for a given element"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 16,
+   "id": "f55e9cb8-f693-461a-aeaa-6416d40d7858",
+   "metadata": {},
+   "outputs": [],
+   "source": [
+    "# Returns directly / immediate owned elements for a given element in a given commit of a given project\n",
+    "def get_owned_elements(project_id, commit_id, element_id, indent):\n",
+    "    \n",
+    "    # Fetch the element in the given commit of the given project\n",
+    "    element_data = get_element(project_id, commit_id, element_id, indent)\n",
+    "    \n",
+    "    if element_data:\n",
+    "        owned_elements = element_data['ownedElement']\n",
+    "        if len(owned_elements) > 0:\n",
+    "            for owned_element in owned_elements:\n",
+    "                get_owned_elements(project_id, commit_id, owned_element['@id'], indent+' ')\n",
+    "    else:\n",
+    "        print(f\"Unable to fetch element with id '{element_id}' in commit '{commit_id}' of project '{project_id}'\")"
+   ]
+  },
+  {
+   "cell_type": "markdown",
+   "id": "f020a542-14fe-4f12-9680-0faa51819cce",
+   "metadata": {},
+   "source": [
+    "# Test for an example element in a given commit of a project"
+   ]
+  },
+  {
+   "cell_type": "markdown",
+   "id": "d718111e-1804-4a3c-b4cd-2719c8c78356",
+   "metadata": {},
+   "source": [
+    "## Specify test project, commit, and element"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 17,
+   "id": "3c378cb5-e7bb-48c4-ac27-67fd893aebc5",
+   "metadata": {},
+   "outputs": [],
+   "source": [
+    "# Specify a project id\n",
+    "test_project_id = 'b0c4aec0-8fce-4d82-af3d-f9abdd25af19' # 1c-Parts Tree Redifinition project\n",
+    "\n",
+    "# Specify a commit id in the project\n",
+    "test_commit_id = 'caa160a2-e964-4545-bb3c-c7686d5d2979' # Latest commit in the main branch of the project\n",
+    "\n",
+    "# Specify an element id in the commit of that project\n",
+    "test_element_id = '2a361c0a-a332-4910-a288-c8b4b35bd2ab' #1c-Parts Tree Redifinition package"
+   ]
+  },
+  {
+   "cell_type": "markdown",
+   "id": "27033be6-564c-4588-8404-0176b6d5f5df",
+   "metadata": {},
+   "source": [
+    "## Get owned elements (immediate) for the given element in the given commit of the given project"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 18,
+   "id": "1ae44ade-1147-4057-b253-84d564e432b2",
+   "metadata": {},
+   "outputs": [
+    {
+     "name": "stdout",
+     "output_type": "stream",
+     "text": [
+      " - 1c-Parts Tree Redefinition (Package)\n",
+      "   - Definitions (Package)\n",
+      "   - Usages (Package)\n"
+     ]
+    }
+   ],
+   "source": [
+    "get_owned_elements_immediate(test_project_id, test_commit_id, test_element_id, '')"
+   ]
+  },
+  {
+   "cell_type": "markdown",
+   "id": "8adca507-c239-43c9-843a-ae77ff715c98",
+   "metadata": {},
+   "source": [
+    "## Get owned elements (recursive) for the given element in the given commit of the given project"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 19,
+   "id": "0288f81f-7513-42e0-a0c7-a7e873d92e91",
+   "metadata": {},
+   "outputs": [
+    {
+     "name": "stdout",
+     "output_type": "stream",
+     "text": [
+      " - 1c-Parts Tree Redefinition (Package)\n",
+      "  - Definitions (Package)\n",
+      "   - Vehicle (PartDefinition)\n",
+      "    - mass (AttributeUsage)\n",
+      "     - N/A (Multiplicity)\n",
+      "   - AxleAssembly (PartDefinition)\n",
+      "   - Axle (PartDefinition)\n",
+      "    - mass (AttributeUsage)\n",
+      "     - N/A (Multiplicity)\n",
+      "   - FrontAxle (PartDefinition)\n",
+      "    - steeringAngle (AttributeUsage)\n",
+      "     - N/A (Multiplicity)\n",
+      "   - Wheel (PartDefinition)\n",
+      "  - Usages (Package)\n",
+      "   - vehicle1 (PartUsage)\n",
+      "    - mass (AttributeUsage)\n",
+      "     - N/A (OperatorExpression)\n",
+      "      - x (Feature)\n",
+      "       - N/A (LiteralInteger)\n",
+      "        - result (Feature)\n",
+      "      - y (Feature)\n",
+      "       - N/A (FeatureReferenceExpression)\n",
+      "        - result (Feature)\n",
+      "      - result (Feature)\n",
+      "     - N/A (Documentation)\n",
+      "    - frontAxleAssembly (PartUsage)\n",
+      "     - frontAxle (PartUsage)\n",
+      "      - N/A (Multiplicity)\n",
+      "     - frontWheel (PartUsage)\n",
+      "      - N/A (MultiplicityRange)\n",
+      "       - N/A (LiteralInteger)\n",
+      "        - result (Feature)\n",
+      "     - N/A (Multiplicity)\n",
+      "    - rearAxleAssembly (PartUsage)\n",
+      "     - rearAxle (PartUsage)\n",
+      "      - N/A (Multiplicity)\n",
+      "     - rearWheel (PartUsage)\n",
+      "      - N/A (MultiplicityRange)\n",
+      "       - N/A (LiteralInteger)\n",
+      "        - result (Feature)\n",
+      "     - N/A (Multiplicity)\n",
+      "   - vehicle1_c1 (PartUsage)\n",
+      "    - N/A (Comment)\n",
+      "    - mass (AttributeUsage)\n",
+      "     - N/A (OperatorExpression)\n",
+      "      - x (Feature)\n",
+      "       - N/A (LiteralInteger)\n",
+      "        - result (Feature)\n",
+      "      - y (Feature)\n",
+      "       - N/A (FeatureReferenceExpression)\n",
+      "        - result (Feature)\n",
+      "      - result (Feature)\n",
+      "     - N/A (Comment)\n",
+      "    - frontAxleAssembly_c1 (PartUsage)\n",
+      "     - frontAxle_c1 (PartUsage)\n",
+      "      - N/A (Comment)\n",
+      "     - N/A (Comment)\n",
+      "     - frontWheel_1 (PartUsage)\n",
+      "      - N/A (OperatorExpression)\n",
+      "       - seq (Feature)\n",
+      "        - N/A (FeatureReferenceExpression)\n",
+      "         - result (Feature)\n",
+      "       - index (Feature)\n",
+      "        - N/A (LiteralInteger)\n",
+      "         - result (Feature)\n",
+      "       - result (Feature)\n",
+      "     - frontWheel_2 (PartUsage)\n",
+      "      - N/A (OperatorExpression)\n",
+      "       - seq (Feature)\n",
+      "        - N/A (FeatureReferenceExpression)\n",
+      "         - result (Feature)\n",
+      "       - index (Feature)\n",
+      "        - N/A (LiteralInteger)\n",
+      "         - result (Feature)\n",
+      "       - result (Feature)\n",
+      "    - rearAxleAssembly_c1 (PartUsage)\n",
+      "     - rearAxle_c1 (PartUsage)\n",
+      "      - N/A (Comment)\n",
+      "     - rearWheel_1 (PartUsage)\n",
+      "      - N/A (OperatorExpression)\n",
+      "       - seq (Feature)\n",
+      "        - N/A (FeatureReferenceExpression)\n",
+      "         - result (Feature)\n",
+      "       - index (Feature)\n",
+      "        - N/A (LiteralInteger)\n",
+      "         - result (Feature)\n",
+      "       - result (Feature)\n",
+      "     - rearWheel_2 (PartUsage)\n",
+      "      - N/A (OperatorExpression)\n",
+      "       - seq (Feature)\n",
+      "        - N/A (FeatureReferenceExpression)\n",
+      "         - result (Feature)\n",
+      "       - index (Feature)\n",
+      "        - N/A (LiteralInteger)\n",
+      "         - result (Feature)\n",
+      "       - result (Feature)\n"
+     ]
+    }
+   ],
+   "source": [
+    "get_owned_elements(test_project_id, test_commit_id, test_element_id, '')"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": null,
+   "id": "3aca7044-3063-47b6-8916-f4a2ef8e3105",
+   "metadata": {},
+   "outputs": [],
+   "source": []
+  }
+ ],
+ "metadata": {
+  "kernelspec": {
+   "display_name": "Python 3 (ipykernel)",
+   "language": "python",
+   "name": "python3"
+  },
+  "language_info": {
+   "codemirror_mode": {
+    "name": "ipython",
+    "version": 3
+   },
+   "file_extension": ".py",
+   "mimetype": "text/x-python",
+   "name": "python",
+   "nbconvert_exporter": "python",
+   "pygments_lexer": "ipython3",
+   "version": "3.8.16"
+  }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 5
+}
diff --git a/Project_Commit_Branch_Tag_Recipe.ipynb b/Project_Commit_Branch_Tag_Recipe.ipynb
index f6672ed..c1fc018 100644
--- a/Project_Commit_Branch_Tag_Recipe.ipynb
+++ b/Project_Commit_Branch_Tag_Recipe.ipynb
@@ -1470,7 +1470,7 @@
    "name": "python",
    "nbconvert_exporter": "python",
    "pygments_lexer": "ipython3",
-   "version": "3.8.13"
+   "version": "3.8.16"
   }
  },
  "nbformat": 4,
diff --git a/Req_Str_Beh_Decomposition_Recipe_Spacecraft_Example.ipynb b/Req_Str_Beh_Decomposition_Recipe_Spacecraft_Example.ipynb
new file mode 100644
index 0000000..d284368
--- /dev/null
+++ b/Req_Str_Beh_Decomposition_Recipe_Spacecraft_Example.ipynb
@@ -0,0 +1,386 @@
+{
+ "cells": [
+  {
+   "cell_type": "markdown",
+   "id": "3ee4834f",
+   "metadata": {},
+   "source": [
+    "# Initializing the SysML v2 API"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 33,
+   "id": "6b5fef59",
+   "metadata": {},
+   "outputs": [],
+   "source": [
+    "from __future__ import print_function\n",
+    "\n",
+    "import time\n",
+    "import requests\n",
+    "from pprint import pprint\n",
+    "import pandas as pd\n",
+    "import json\n",
+    "\n",
+    "#host = \"<SysML2-API-Repo-Host:Port>\"\n",
+    "#host = \"Specify the URL of the SysML v2 API and Service Repository\"\n",
+    "host = \"http://sysml2-sst.intercax.com:9000\""
+   ]
+  },
+  {
+   "cell_type": "markdown",
+   "id": "04c1ff93",
+   "metadata": {},
+   "source": [
+    "# Get projects"
+   ]
+  },
+  {
+   "cell_type": "markdown",
+   "id": "dfe02baa-a9be-46f1-8c3d-bcc76402c6ae",
+   "metadata": {},
+   "source": [
+    "projects_url = f\"{host}/projects\" \n",
+    "projects_response = requests.get(projects_url)\n",
+    "\n",
+    "if projects_response.status_code == 200:\n",
+    "    projects = projects_response.json()\n",
+    "    \n",
+    "    df = pd.DataFrame({'Project Name':[], 'Project ID':[]})\n",
+    "    for p in projects:\n",
+    "        df = pd.concat([df, pd.DataFrame({'Project Name':[p['name']], 'Project ID':[p['@id']]})], ignore_index=True)\n",
+    "    display(df)"
+   ]
+  },
+  {
+   "cell_type": "markdown",
+   "id": "d815e4fe",
+   "metadata": {},
+   "source": [
+    "# Define a function to recursively iterate over feature members \n",
+    "## Recursive graph traversal using FeatureMembership relations"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 34,
+   "id": "24ec6146",
+   "metadata": {},
+   "outputs": [],
+   "source": [
+    "def get_member_features(project_id, commit_id, element_id, member_type, indent):\n",
+    "    \n",
+    "    # Fetch the element\n",
+    "    element_url = f\"{host}/projects/{project_id}/commits/{commit_id}/elements/{element_id}\" \n",
+    "    response = requests.get(element_url)\n",
+    "    \n",
+    "    element_data = response.json()\n",
+    "    element_name = element_data['name']\n",
+    "    element_id = element_data['@id']\n",
+    "    element_type = element_data ['@type']\n",
+    "    \n",
+    "    if element_type == member_type:\n",
+    "        print(f\"{indent} - {element_name} (id = {element_id}, type = {element_type})\")\n",
+    "        # Feature memberships\n",
+    "        element_features = element_data['feature']\n",
+    "        if len(element_features) > 0:\n",
+    "            for feature in element_features:\n",
+    "                get_member_features(project_id, commit_id, feature['@id'], member_type, indent + \"  \")\n"
+   ]
+  },
+  {
+   "cell_type": "markdown",
+   "id": "a47d1b56-9176-4c97-b0f8-443e159a1f20",
+   "metadata": {},
+   "source": [
+    "## Project"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 35,
+   "id": "a8cb5b5b-f182-49cd-bc83-a82dc94c422a",
+   "metadata": {},
+   "outputs": [],
+   "source": [
+    "spacecraft_project_id = 'a24a3f81-db33-4514-8cee-11b8db59d3e8'"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 36,
+   "id": "482ddfe4",
+   "metadata": {},
+   "outputs": [
+    {
+     "name": "stdout",
+     "output_type": "stream",
+     "text": [
+      "[{'@id': '40666fb1-cab2-415e-8764-75121b14ec87',\n",
+      "  '@type': 'Commit',\n",
+      "  'created': '2023-06-13T18:54:44.606759-04:00',\n",
+      "  'description': None,\n",
+      "  'owningProject': {'@id': 'a24a3f81-db33-4514-8cee-11b8db59d3e8'},\n",
+      "  'previousCommit': None}]\n"
+     ]
+    }
+   ],
+   "source": [
+    "spacecraft_project_commit_id = ''\n",
+    "\n",
+    "commits_url = f\"{host}/projects/{spacecraft_project_id}/commits\" \n",
+    "commits_response = requests.get(commits_url)\n",
+    "if commits_response.status_code == 200:\n",
+    "    commits = commits_response.json()\n",
+    "    pprint(commits)\n",
+    "    spacecraft_project_commit_id = commits[0]['@id']\n"
+   ]
+  },
+  {
+   "cell_type": "markdown",
+   "id": "487c0624",
+   "metadata": {},
+   "source": [
+    "## Query to find Spacecraft part"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 37,
+   "id": "3d724e27",
+   "metadata": {},
+   "outputs": [
+    {
+     "name": "stdout",
+     "output_type": "stream",
+     "text": [
+      "[{'@id': '6a262fe1-6958-4c05-8ff1-c19d4cd68c41',\n",
+      "  '@type': 'PartUsage',\n",
+      "  'name': 'Spacecraft',\n",
+      "  'owner': {'@id': 'e51d38d7-3459-4c19-b760-1d6a257641b1'}}]\n"
+     ]
+    }
+   ],
+   "source": [
+    " \n",
+    "data = {\n",
+    "  '@type':'Query',\n",
+    "  'select': ['name','@id','@type','owner'],\n",
+    "  'where': {\n",
+    "    '@type': 'CompositeConstraint',\n",
+    "    'operator': 'and',\n",
+    "    'constraint': [\n",
+    "        {\n",
+    "            '@type': 'PrimitiveConstraint',\n",
+    "            'inverse': False,\n",
+    "            'operator': '=',\n",
+    "            'property': 'name',\n",
+    "            'value': 'Spacecraft'\n",
+    "        },\n",
+    "        {\n",
+    "            '@type': 'PrimitiveConstraint',\n",
+    "            'inverse': False,\n",
+    "            'operator': '=',\n",
+    "            'property': '@type',\n",
+    "            'value': 'PartUsage'\n",
+    "        }\n",
+    "    ]\n",
+    "  }\n",
+    "}\n",
+    "\n",
+    "payload = json.dumps(data)\n",
+    "\n",
+    "vehicle1_id = ''\n",
+    "query_url = f\"{host}/projects/{spacecraft_project_id}/query-results\" \n",
+    "\n",
+    "query_response = requests.post(query_url, json=data)\n",
+    "\n",
+    "if query_response.status_code == 200:\n",
+    "    query_response_json = query_response.json()\n",
+    "    pprint(query_response_json)\n",
+    "    spacecraft_part_id = query_response_json[0]['@id']"
+   ]
+  },
+  {
+   "cell_type": "markdown",
+   "id": "0092a660",
+   "metadata": {},
+   "source": [
+    "## Parts tree for Spacecraft (recursive FeatureMembership relation navigation)"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 38,
+   "id": "406504bf",
+   "metadata": {},
+   "outputs": [
+    {
+     "name": "stdout",
+     "output_type": "stream",
+     "text": [
+      "  - Spacecraft (id = 6a262fe1-6958-4c05-8ff1-c19d4cd68c41, type = PartUsage)\n",
+      "    - Payload_Subsystem (id = 091aada9-3687-4bfc-a683-7d8b92972935, type = PartUsage)\n",
+      "      - Payload_sensor (id = 9a2721e1-410c-49f9-9551-9c8721ef589e, type = PartUsage)\n",
+      "      - Payload_software (id = 31fc0cdb-4ac4-4da3-bee8-713b41e5781c, type = PartUsage)\n",
+      "    - Power_Subsystem (id = 32ab132f-9db6-4ea0-9c77-d399fdf41faa, type = PartUsage)\n",
+      "      - Solar_Array (id = 97713133-38b4-42a3-929f-6a1f024ba37d, type = PartUsage)\n",
+      "      - Battery (id = 4518e4c0-a6a5-441e-b007-38b66a4fc589, type = PartUsage)\n",
+      "    - Communications_Subsystem (id = be62763d-fdff-425a-a993-d81cdf5fcf93, type = PartUsage)\n",
+      "      - Communication_Software (id = f88566d8-65cd-4a9e-91df-44eda6faf7db, type = PartUsage)\n",
+      "      - High_Rate_Antenna (id = cf7f9c85-f994-4496-a80e-2517d2bc75c7, type = PartUsage)\n",
+      "    - Thermal_Subsystem (id = 0411b359-503e-43ef-af18-1b904f6b35b2, type = PartUsage)\n",
+      "      - Radiator (id = 87963be9-6564-4e5b-b890-ab195f2faeb4, type = PartUsage)\n",
+      "      - Heat_Pipe (id = b37ae9c9-68d1-4e36-894b-fe2dbbfaadb0, type = PartUsage)\n",
+      "    - Structure_and_Mechanisms_Subsystem (id = 777e9209-3e37-4b85-9105-4229199f1405, type = PartUsage)\n",
+      "      - Antenna_Gimbal (id = d3b285e5-3e73-4b0a-a7b9-1cd80c562f5d, type = PartUsage)\n",
+      "      - Solar_Array_Gimbal (id = 4971b596-e0b0-4d4c-b41b-1e115b14295d, type = PartUsage)\n",
+      "    - Avionics_Subsystem (id = c71bee28-2fda-49c1-8b8b-46ee864ba1c1, type = PartUsage)\n",
+      "      - Onboard_Controller (id = 672471b6-6395-4900-a48c-66e37589b679, type = PartUsage)\n",
+      "      - System_Controller (id = ef4e6b6a-7da6-4029-8ff8-5545d32e4e48, type = PartUsage)\n",
+      "      - Onboard_Computer (id = a0142360-ed07-4411-92ad-bc6a30b87f58, type = PartUsage)\n",
+      "        - Mission_Software (id = 8ab1b5d8-8675-4e54-8573-9df7389a75c2, type = PartUsage)\n",
+      "        - Flight_Software (id = c1706220-0a73-434b-a6bd-3d5184346bf3, type = PartUsage)\n",
+      "    - GNC_Subsystem (id = d5ec8534-e7ed-4c4f-ae12-663f8df74f9c, type = PartUsage)\n",
+      "      - Reaction_Wheel (id = 31c8c58d-48ef-4d27-8fbd-c98a5b461f68, type = PartUsage)\n",
+      "      - GNC_Software (id = d8866c3b-f07a-4583-9bdb-a8ec2266cbc3, type = PartUsage)\n",
+      "    - Propulsion_Subsystem (id = dc94ce90-5390-415e-be7d-5f10e6b8867a, type = PartUsage)\n",
+      "      - Propellant_Line (id = 5c34b5b1-b7b0-4844-948e-a0046f14c0d4, type = PartUsage)\n",
+      "      - Propulsion_Software (id = d2544b57-2b06-42cf-92e3-414630bcd7ac, type = PartUsage)\n",
+      "    - Harness_Subsystem (id = 789d0600-10de-4d09-9632-49d80cf9d386, type = PartUsage)\n",
+      "      - Power_Harness (id = cfcdbe53-3075-416a-8200-5226fc9c5267, type = PartUsage)\n",
+      "      - Data_Harness (id = 206d7021-5396-4fbe-a8a6-7e1704d2c5d3, type = PartUsage)\n"
+     ]
+    }
+   ],
+   "source": [
+    "get_member_features(spacecraft_project_id,spacecraft_project_commit_id, spacecraft_part_id,'PartUsage',\" \")"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 39,
+   "id": "5fa94a05-c45e-4d93-a145-7e5967a87cd9",
+   "metadata": {},
+   "outputs": [
+    {
+     "name": "stdout",
+     "output_type": "stream",
+     "text": [
+      "[{'@id': '459f5ec9-dc82-45c0-87e3-d013ed6773e5',\n",
+      "  '@type': 'RequirementUsage',\n",
+      "  'name': 'Spacecraft_Specification',\n",
+      "  'owner': {'@id': '26bc955e-5ea4-4a51-8099-db42169e7436'}}]\n"
+     ]
+    }
+   ],
+   "source": [
+    "data = {\n",
+    "  '@type':'Query',\n",
+    "  'select': ['name','@id','@type','owner'],\n",
+    "  'where': {\n",
+    "    '@type': 'CompositeConstraint',\n",
+    "    'operator': 'and',\n",
+    "    'constraint': [\n",
+    "        {\n",
+    "            '@type': 'PrimitiveConstraint',\n",
+    "            'inverse': False,\n",
+    "            'operator': '=',\n",
+    "            'property': 'name',\n",
+    "            'value': 'Spacecraft_Specification'\n",
+    "        },\n",
+    "        {\n",
+    "            '@type': 'PrimitiveConstraint',\n",
+    "            'inverse': False,\n",
+    "            'operator': '=',\n",
+    "            'property': '@type',\n",
+    "            'value': 'RequirementUsage'\n",
+    "        }\n",
+    "    ]\n",
+    "  }\n",
+    "}\n",
+    "\n",
+    "payload = json.dumps(data)\n",
+    "\n",
+    "vehicle_specification_id = ''\n",
+    "query_url = f\"{host}/projects/{spacecraft_project_id}/query-results\" \n",
+    "\n",
+    "query_response = requests.post(query_url, json=data)\n",
+    "\n",
+    "if query_response.status_code == 200:\n",
+    "    query_response_json = query_response.json()\n",
+    "    pprint(query_response_json)\n",
+    "    spacecraft_specification_id = query_response_json[0]['@id']"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 40,
+   "id": "bd2276aa",
+   "metadata": {},
+   "outputs": [
+    {
+     "name": "stdout",
+     "output_type": "stream",
+     "text": [
+      "  - Spacecraft_Specification (id = 459f5ec9-dc82-45c0-87e3-d013ed6773e5, type = RequirementUsage)\n",
+      "    - Launch_Vehicle_Interface (id = 9df26fa1-e5c6-4679-8c45-4c482b544497, type = RequirementUsage)\n",
+      "      - Launch_Vehicle_Mechanical_Interface (id = 6a262fdd-1964-490b-ad2b-b8f444aa60d7, type = RequirementUsage)\n",
+      "      - Launch_Vehicle_Electrics_Interface (id = 0674630a-ee6e-4e03-8ada-3d24cc82f700, type = RequirementUsage)\n",
+      "    - Functional_and_Performance (id = b2a2a88e-d6c8-4277-a43c-ce9c7e74bf95, type = RequirementUsage)\n",
+      "      - Probability_of_Detection (id = b896853b-cdc3-4776-b28e-b11dba0701f7, type = RequirementUsage)\n",
+      "      - Probability_of_False_Alarm (id = d1941cc0-fd36-4a74-933c-cc444e105d5d, type = RequirementUsage)\n",
+      "      - Pointing_Accuracy (id = 24f75812-2686-4445-9c48-dd842b0a0b17, type = RequirementUsage)\n",
+      "      - Downlink_Capacity (id = 71d84b57-0033-4a20-a598-781d547d5c51, type = RequirementUsage)\n",
+      "      - Data_Storage (id = 9d9bcba4-4d1c-421a-b947-ebd1d19fc931, type = RequirementUsage)\n",
+      "      - Fault_Management (id = ac07ab51-7583-4ef3-89c9-661e974ffae9, type = RequirementUsage)\n",
+      "    - Physical (id = a9f208ca-a42e-4a49-9da5-4e7422d1e1da, type = RequirementUsage)\n",
+      "      - Mass (id = 9b9737fa-96bd-460f-8d05-d76917f1c90b, type = RequirementUsage)\n",
+      "      - Electrical_Power (id = 83a0bea4-ef39-49ee-af64-ea2e205c880f, type = RequirementUsage)\n",
+      "      - Orbit_Constraints (id = f2e61320-d428-4f91-93aa-af2ac87154ea, type = RequirementUsage)\n",
+      "      - Thermal_Protection (id = 14796f3e-6d17-479b-8d3c-ef29ed9166a2, type = RequirementUsage)\n",
+      "      - Payload_Accomodation (id = 79ed4e4b-d99e-45f9-9a0a-cdd7cbbc41ae, type = RequirementUsage)\n",
+      "      - Structural_Integrity (id = 9bbef78f-ed8c-47f3-b76a-4c203b07046d, type = RequirementUsage)\n",
+      "    - Quality_Characteristics (id = 0a412f71-01f4-481b-a616-371f3263435a, type = RequirementUsage)\n",
+      "      - Reliability (id = a465415d-c243-46a6-8148-4a42cbe0acd2, type = RequirementUsage)\n",
+      "      - Lifetime (id = 59e08f8f-3e3e-4316-8b9a-0fe5db46b7fb, type = RequirementUsage)\n",
+      "      - Unit_Cost (id = 1b9e87f8-4acd-4a32-9570-6e19a7f7caf0, type = RequirementUsage)\n"
+     ]
+    }
+   ],
+   "source": [
+    "get_member_features(spacecraft_project_id, spacecraft_project_commit_id, spacecraft_specification_id,\"RequirementUsage\",\" \")"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": null,
+   "id": "c9d67e6b-d814-42d0-b180-41458eb34eb6",
+   "metadata": {},
+   "outputs": [],
+   "source": []
+  }
+ ],
+ "metadata": {
+  "kernelspec": {
+   "display_name": "Python 3 (ipykernel)",
+   "language": "python",
+   "name": "python3"
+  },
+  "language_info": {
+   "codemirror_mode": {
+    "name": "ipython",
+    "version": 3
+   },
+   "file_extension": ".py",
+   "mimetype": "text/x-python",
+   "name": "python",
+   "nbconvert_exporter": "python",
+   "pygments_lexer": "ipython3",
+   "version": "3.8.16"
+  }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 5
+}

From f6e49e8ed46992a3a7825a118ade524e8b37ba44 Mon Sep 17 00:00:00 2001
From: Manas Bajaj <manas.bajaj@intercax.com>
Date: Mon, 29 Jan 2024 19:24:19 -0500
Subject: [PATCH 2/2] Update README.md

---
 README.md | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/README.md b/README.md
index 2f4451f..bd950d3 100644
--- a/README.md
+++ b/README.md
@@ -10,6 +10,11 @@ This recipe shows patterns and examples for navigating the decomposition of requ
 
 See the Jupyter notebook **Req_Str_Beh_Decomposition_Recipe.ipynb** for details.
 
+### Requirement, Structure, Behavior decomposition recipe for Spacecraft example
+This notebook shows the use of the Requirement, Structure, Behavior decomposition recipe (above) for a Spacecraft example. 
+
+See the Jupyter notebook **Req_Str_Beh_Decomposition_Recipe_Spacecraft_Example.ipynb** for details.
+
 ### Project, Commit, Branch, and Tag recipe
 This recipe shows patterns and examples for fetching and creating commits, branches, and tags in a project. It shows an example scenario for SysML v2 project evolution over time with concurrent users working on different branches, creating new commits, and creating tags for baseline or milestone releases of the project.
 
@@ -20,6 +25,11 @@ This recipe shows patterns and examples for creating, updating, and deleting ele
 
 See the Jupyter notebook **Element_Create_Update_Delete.ipynb** for details.
 
+### Element Owned Elements recipe
+This recipe shows patterns and examples to fetch the owned elements (immediate and recursive) for a given element in a given commit of a project.
+
+See the Jupyter notebook **Element_Owned_Elements.ipynb** for details.
+
 ### Queries recipe
 This recipe shows patterns and examples for formulating and executing queries in a project. Examples show queries with multiple constraints.