Opening Metamodel

Below is the example of using the GetMs operation to open a metamodel. The request contains an instance of opened modeling container and a pattern for opening the metamodel. The response contains the opened metamodel.

SOAP request:

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<GetMs xmlns="http://www.prognoz.ru/PP.SOM.Som">
<tMs xmlns="">
  <id>CGKEECJHPGLBFOAENHCHCNMCBALKLKEEEKBNGDKPHJENHLDI!M!S!CHPOBOCJHPGLBFOAEIBNAJLANGNCFIOLENLIGJEOCACFCIOLB</id>
  </tMs>
<tArg xmlns="">
<pattern>
  <obInst>true</obInst>
  <scenarios>None</scenarios>
<item>
  <key>89990</key>
<problem>
<metamodel>
  <calculationChain>Get</calculationChain>
<calcChainPattern>
<metaModelPattern>
  <calculationChain>Get</calculationChain>
<calcChainPattern>
<modelPattern>
  <generatedName>true</generatedName>
  </modelPattern>
  </calcChainPattern>
  </metaModelPattern>
<modelPattern>
  <generatedName>true</generatedName>
  </modelPattern>
  </calcChainPattern>
<visualControllerPattern>
  <variableRubricatorKey>true</variableRubricatorKey>
  <freeVariables>true</freeVariables>
  </visualControllerPattern>
  </metamodel>
  </problem>
  </item>
  </pattern>
  </tArg>
  </GetMs>
  </s:Body>
  </s:Envelope>

SOAP response:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<GetMsResult xmlns="http://www.prognoz.ru/PP.SOM.Som" xmlns:q1="http://www.prognoz.ru/PP.SOM.Som" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<id xmlns="">
  <id>CGKEECJHPGLBFOAENHCHCNMCBALKLKEEEKBNGDKPHJENHLDI!M!S!CHPOBOCJHPGLBFOAEIBNAJLANGNCFIOLENLIGJEOCACFCIOLB</id>
  </id>
<meta xmlns="">
<obInst>
<obDesc isShortcut="0" isLink="0" fullUrl="http://v-shp-development.dev.fs.fsight.world/" ver="2" hf="0">
  <i>MODELSPACE</i>
  <n>Modeling container</n>
  <k>1581</k>
  <c>5121</c>
  <p>1580</p>
  <h>0</h>
  <hasPrv>0</hasPrv>
  <ic>0</ic>
  <isPermanent>1</isPermanent>
  <isTemp>0</isTemp>
  </obDesc>
  </obInst>
  <dirty>0</dirty>
<item>
  <k>89990</k>
  <id>MODEL</id>
  <n>MODEL</n>
  <vis>1</vis>
  <type>Problem</type>
<problemMd>
<metamodel>
  <k>89991</k>
<calculationChain>
<its>
<Item>
  <k>1</k>
  <n>Output variable</n>
  <vis>1</vis>
  <type>Variable</type>
  <excluded>0</excluded>
  <graphMeta>{"Geometry":{"x":10,"y":10,"width":150,"height":50}}</graphMeta>
<chainVariable>
<slice>
  <k>0</k>
  <id>Output variable|A</id>
  <n>Output variable|A</n>
  <vis>1</vis>
  <variableKey>1</variableKey>
  <stubKey>89992</stubKey>
<selections>
<its>
<Item>
<id>
  <id>90004</id>
  </id>
  <variant>1</variant>
  </Item>
  </its>
  </selections>
  <aggregator>None</aggregator>
<parametrizedDimensions>
<its>
<Item>
  <dimension>0</dimension>
  <parameter>0</parameter>
  </Item>
  </its>
  </parametrizedDimensions>
<unitInfo>
  <unit>4294967295</unit>
  <measure>4294967295</measure>
  <baseUnit>4294967295</baseUnit>
  <unitsDimensionKey>0</unitsDimensionKey>
  </unitInfo>
  <level>Year</level>
  </slice>
  <fullName>Output variable|A</fullName>
  <originalName>Output variable</originalName>
  <originalShortName>Output variable</originalShortName>
  <useCustomName>0</useCustomName>
  </chainVariable>
  </Item>
<Item>
  <k>2</k>
  <n>Input variable</n>
  <vis>1</vis>
  <type>Variable</type>
  <excluded>0</excluded>
  <graphMeta>{"Geometry":{"x":10,"y":70,"width":150,"height":50}}</graphMeta>
<chainVariable>
<slice>
  <k>0</k>
  <id>Input variable|A</id>
  <n>Input variable|A</n>
  <vis>1</vis>
  <variableKey>2</variableKey>
  <stubKey>89992</stubKey>
<selections>
<its>
<Item>
<id>
  <id>90004</id>
  </id>
  <variant>2</variant>
  </Item>
  </its>
  </selections>
  <aggregator>None</aggregator>
<parametrizedDimensions>
<its>
<Item>
  <dimension>0</dimension>
  <parameter>0</parameter>
  </Item>
  </its>
  </parametrizedDimensions>
<unitInfo>
  <unit>4294967295</unit>
  <measure>4294967295</measure>
  <baseUnit>4294967295</baseUnit>
  <unitsDimensionKey>0</unitsDimensionKey>
  </unitInfo>
  <level>Year</level>
  </slice>
  <fullName>Input variable|A</fullName>
  <originalName>Input variable</originalName>
  <originalShortName>Input variable</originalShortName>
  <useCustomName>0</useCustomName>
  </chainVariable>
  </Item>
<Item>
  <k>3</k>
  <id>OBJ3</id>
  <n>Output variable|A[t] = A0 + A1*Input variable|A[t], (From parent)-(From parent)</n>
  <vis>1</vis>
  <type>Model</type>
  <excluded>0</excluded>
  <graphMeta />
<model>
  <generatedName>Output variable|A[t] = A0 + A1*Input variable|A[t]</generatedName>
  <readOnly>0</readOnly>
  </model>
  </Item>
  </its>
  </calculationChain>
<visualController>
  <variableRubricatorKey>89992</variableRubricatorKey>
<freeVariables>
  <its />
  </freeVariables>
  <userRPath />
  <isRExist>0</isRExist>
  </visualController>
<suppressEmptyFilter>
  <suppressEmpty>0</suppressEmpty>
  <suppressEmptyArea>SerieBounds</suppressEmptyArea>
  </suppressEmptyFilter>
  <readOnly>0</readOnly>
  <variableTestUseR>0</variableTestUseR>
  <calculateIdentOnFact>0</calculateIdentOnFact>
  </metamodel>
  <useScenarios>0</useScenarios>
  <readOnly>0</readOnly>
  </problemMd>
  </item>
  </meta>
  </GetMsResult>
  </soapenv:Body>
  </soapenv:Envelope>

JSON request:

{
 "GetMs" : 
  {
   "tMs" : 
    {
     "id" : "CGKEECJHPGLBFOAENHCHCNMCBALKLKEEEKBNGDKPHJENHLDI!M!S!CHPOBOCJHPGLBFOAEIBNAJLANGNCFIOLENLIGJEOCACFCIOLB"
    },
   "tArg" : 
    {
     "pattern" : 
      {
       "obInst" : "true",
       "scenarios" : "None",
       "item" : 
        {
         "key" : "89990",
         "problem" : 
          {
           "metamodel" : 
            {
             "calculationChain" : "Get",
             "calcChainPattern" : 
              {
               "metaModelPattern" : 
                {
                 "calculationChain" : "Get",
                 "calcChainPattern" : 
                  {
                   "modelPattern" : 
                    {
                     "generatedName" : "true"
                    }
                  }
                },
               "modelPattern" : 
                {
                 "generatedName" : "true"
                }
              },
             "visualControllerPattern" : 
              {
               "variableRubricatorKey" : "true",
               "freeVariables" : "true"
              }
            }
          }
        }
      }
    }
  }
}

JSON response:

{
 "GetMsResult" : 
  {
   "id" : 
    {
     "id" : "CGKEECJHPGLBFOAENHCHCNMCBALKLKEEEKBNGDKPHJENHLDI!M!S!CHPOBOCJHPGLBFOAEIBNAJLANGNCFIOLENLIGJEOCACFCIOLB"
    },
   "meta" : 
    {
     "obInst" : 
      {
       "obDesc" : 
        {
         "@fullUrl" : "http:\/\/v-shp-development.dev.fs.fsight.world\/",
         "@isShortcut" : "0",
         "@isLink" : "0",
         "@ver" : "2",
         "@hf" : "0",
         "i" : "MODELSPACE",
         "n" : "Modeling container",
         "k" : "1581",
         "c" : "5121",
         "p" : "1580",
         "h" : "0",
         "hasPrv" : "0",
         "ic" : "0",
         "isPermanent" : "1",
         "isTemp" : "0"
        }
      },
     "dirty" : "0",
     "item" : 
      {
       "k" : "89990",
       "id" : "MODEL",
       "n" : "MODEL",
       "vis" : "1",
       "type" : "Problem",
       "problemMd" : 
        {
         "metamodel" : 
          {
           "k" : "89991",
           "calculationChain" : 
            {
             "its" : 
              {
               "Item" : 
                [
                  {
                   "k" : "1",
                   "n" : "Output variable",
                   "vis" : "1",
                   "type" : "Variable",
                   "excluded" : "0",
                   "graphMeta" : "{"Geometry":{"x":10,"y":10,"width":150,"height":50}}",
                   "chainVariable" : 
                    {
                     "slice" : 
                      {
                       "k" : "0",
                       "id" : "Output variable|A",
                       "n" : "Output variable|A",
                       "vis" : "1",
                       "variableKey" : "1",
                       "stubKey" : "89992",
                       "selections" : 
                        {
                         "its" : 
                          {
                           "Item" : 
                            {
                             "id" : 
                              {
                               "id" : "90004"
                              },
                             "variant" : "1"
                            }
                          }
                        },
                       "aggregator" : "None",
                       "parametrizedDimensions" : 
                        {
                         "its" : 
                          {
                           "Item" : 
                            {
                             "dimension" : "0",
                             "parameter" : "0"
                            }
                          }
                        },
                       "unitInfo" : 
                        {
                         "unit" : "4294967295",
                         "measure" : "4294967295",
                         "baseUnit" : "4294967295",
                         "unitsDimensionKey" : "0"
                        },
                       "level" : "Year"
                      },
                     "fullName" : "Output variable|A",
                     "originalName" : "Output variable",
                     "originalShortName" : "Output variable",
                     "useCustomName" : "0"
                    }
                  },
                  {
                   "k" : "2",
                   "n" : "Input variable",
                   "vis" : "1",
                   "type" : "Variable",
                   "excluded" : "0",
                   "graphMeta" : "{"Geometry":{"x":10,"y":70,"width":150,"height":50}}",
                   "chainVariable" : 
                    {
                     "slice" : 
                      {
                       "k" : "0",
                       "id" : "Input variable|A",
                       "n" : "Input variable|A",
                       "vis" : "1",
                       "variableKey" : "2",
                       "stubKey" : "89992",
                       "selections" : 
                        {
                         "its" : 
                          {
                           "Item" : 
                            {
                             "id" : 
                              {
                               "id" : "90004"
                              },
                             "variant" : "2"
                            }
                          }
                        },
                       "aggregator" : "None",
                       "parametrizedDimensions" : 
                        {
                         "its" : 
                          {
                           "Item" : 
                            {
                             "dimension" : "0",
                             "parameter" : "0"
                            }
                          }
                        },
                       "unitInfo" : 
                        {
                         "unit" : "4294967295",
                         "measure" : "4294967295",
                         "baseUnit" : "4294967295",
                         "unitsDimensionKey" : "0"
                        },
                       "level" : "Year"
                      },
                     "fullName" : "Input variable|A",
                     "originalName" : "Input variable",
                     "originalShortName" : "Input variable",
                     "useCustomName" : "0"
                    }
                  },
                  {
                   "k" : "3",
                   "id" : "OBJ3",
                   "n" : "Output variable|A[t] = A0 + A1*Input variable|A[t], (From parent)-(From parent)",
                   "vis" : "1",
                   "type" : "Model",
                   "excluded" : "0",
                   "graphMeta" : "",
                   "model" : 
                    {
                     "generatedName" : "Output variable|A[t] = A0 + A1*Input variable|A[t]",
                     "readOnly" : "0"
                    }
                  }
                ]
              }
            },
           "visualController" : 
            {
             "variableRubricatorKey" : "89992",
             "freeVariables" : 
              {
               "its" : ""
              },
             "userRPath" : "",
             "isRExist" : "0"
            },
           "suppressEmptyFilter" : 
            {
             "suppressEmpty" : "0",
             "suppressEmptyArea" : "SerieBounds"
            },
           "readOnly" : "0",
           "variableTestUseR" : "0",
           "calculateIdentOnFact" : "0"
          },
         "useScenarios" : "0",
         "readOnly" : "0"
        }
      }
    }
  }
}
public static MsMetaModel GetMsCalcChain(MsId ms, ulong modelKey)
{
    var getMsOp = new GetMs();
    // Set operation execution parameters
    getMsOp.tMs = ms;
    getMsOp.tArg = new GetMsArg()
    {  // Set general data getting pattern
        pattern = new MsMdPattern()
        {
            scenarios = ListOperation.None,
            item = new MsItemPattern()
            {   // Set open model key
                key = modelKey,
                // Set model data getting pattern
                problem = new MsProblemPattern()
                {   // Set metamodel data getting pattern
                    metamodel = new MsMetaModelPattern()
                    {   // Set calculation chain data getting pattern
                        calculationChain = ListOperation.Get,
                        calcChainPattern = new MsCalculationChainPattern()
                        {
                            metaModelPattern = new MsMetaModelPattern()
                            {   // Set calculation chain data getting pattern
                                calculationChain = ListOperation.Get,
                                calcChainPattern = new MsCalculationChainPattern()
                                {  
                                    modelPattern = new MsModelPattern() { generatedName = true}
                                }
                            },
                            modelPattern = new MsModelPattern(){ generatedName = true}
                        },
                        // Set data getting pattern for visual model building
                        visualControllerPattern = new MsMetaModelVisualControllerPattern()
                        {
                            variableRubricatorKey = true,
                            freeVariables = true
                        }
                    }
                }
            }
        }
    };
    // Create a proxy object for operation execution
    var somClient = new SomPortTypeClient();
    // Open model
    GetMsResult getMsResult = somClient.GetMs(getMsOp);
    MsMetaModel mModel = getMsResult.meta.item.problemMd.metamodel;
    // Get calculation chain
    MsCalculationChainEntries calcChain = mModel.calculationChain;
    // Output data about chain into console window
    Console.WriteLine("Calculation chain: ");
    foreach (MsCalculationChainEntry calcEl in calcChain.its) 
    {
        switch(calcEl.type)
        {
            case MsCalculationChainType.Model:
                Console.WriteLine("".PadRight(2) + "model: " + calcEl.model.generatedName);
                break;
            case MsCalculationChainType.MetaModel:
                Console.WriteLine("".PadRight(2) + "metamodel with key: " + calcEl.metaModel.k);
                break;
        };
        Console.WriteLine("".PadRight(4) + "element is excluded from calculation: " + calcEl.excluded);
        Console.WriteLine("".PadRight(4) + "parent element key: " + calcEl.parentKey);
    }
    return mModel;
}
 

See also:

GetMs: Operation