-

   rss_rss_hh_new

 - e-mail

 

 -

 LiveInternet.ru:
: 17.03.2011
:
:
: 51

:


[] RESTForms REST API InterSystems Cach'e

, 14 2017 . 09:19 +

RESTForms REST API -.
REST API , , , REST API :


  • -

, -, RESTForms .


:


  • Cach'e, ( ) REST API.
  • Cach'e REST API.


JS -, JS RESTForms, ..



RESTForms:


  • CRUD , , .
  • CRUD , , .
  • R ( SQL) SQL-.
  • Selfdiscovery , , CRUD .


API, , RESTForms.


URL
test
form/info
form/info/all
form/info/:class
form/field/:class
form/field/:class
form/field/:class/:property
form/object/:class/:id
form/object/:class/:id/:property
form/object/:class
form/object/:class/:id
form/object/:class
form/object/:class/:id
form/objects/:class/:query SQL
form/objects/:class/custom/:query SQL


  1. 20161.xml ( Cach'e 2016.1) 201162.xml ( Cach'e 2016.2 +)
  2. - /forms Form.REST.Main
  3. http://localhost:57772/forms/test?Debug , ( {"Status": "OK"}, , ).
  4. , :
    do ##class(Form.Util.Init).populateTestForms()

RESTForms?


  1. GitHub (: (submodule) ).
  2. , RESTForms:
    • (Form.Adaptor)
    • , ""
    • ,
  3. RESTForms API . UI RESTForms UI. , RESTForms UI Person

C :


:



-, , . , :


http://localhost:57772/forms/form/info

- :


[
   { "name":"Company",     "class":"Form.Test.Company" },
   { "name":"Person",      "class":"Form.Test.Person"  },
   { "name":"Simple form", "class":"Form.Test.Simple"  }
]

RESTForms 3 . Person ( Form.Test.Person). , :


http://localhost:57772/forms/form/info/Form.Test.Person

:
{
   "name":"Person",
   "class":"Form.Test.Person",
   "displayProperty":"name",
   "objpermissions":"CRUD",
   "fields":[
      {
         "name":"name",
         "type":"%Library.String",
         "collection":"",
         "displayName":"Name",
         "required":0,
         "category":"datatype"
      },
      {
         "name":"dob",
         "type":"%Library.Date",
         "collection":"",
         "displayName":"Date of Birth",
         "required":0,
         "category":"datatype"
      },
      {
         "name":"ts",
         "type":"%Library.TimeStamp",
         "collection":"",
         "displayName":"Timestamp",
         "required":0,
         "category":"datatype"
      },
      {
         "name":"num",
         "type":"%Library.Numeric",
         "collection":"",
         "displayName":"Number",
         "required":0,
         "category":"datatype"
      },
      {
         "name":"ge",
         "type":"%Library.Integer",
         "collection":"",
         "displayName":"Age",
         "required":0,
         "category":"datatype"
      },
      {
         "name":"relative",
         "type":"Form.Test.Person",
         "collection":"",
         "displayName":"Relative",
         "required":0,
         "category":"form"
      },
      {
         "name":"Home",
         "type":"Form.Test.Address",
         "collection":"",
         "displayName":"House",
         "required":0,
         "category":"serial"
      },
      {
         "name":"company",
         "type":"Form.Test.Company",
         "collection":"",
         "displayName":"Company",
         "required":0,
         "category":"form"
      }
   ]
}

?


:


  • name
  • class
  • displayProperty ,
  • objpermissions . (Read), (Create) , (Update) (Delete) .

:


  • name
  • collection ( )
  • displayName
  • required
  • type
  • category . Cach'e, , RESTForms "form"

:
/// Test form: Person
Class Form.Test.Person Extends (%Persistent, Form.Adaptor)
{

///   
Parameter FORMNAME = "Person";

/// 
///       (C),  (R),  (U),   (D)
Parameter OBJPERMISSIONS As %String = "CRUD";

///  "" 
Parameter DISPLAYPROPERTY As %String = "name";

///   -
Parameter FORMORDERBY As %String = "dob";

/// 
Property name As %String(DISPLAYNAME = "Name");

///  
Property dob As %Date(DISPLAYNAME = "Date of Birth");

/// 
Property num As %Numeric(DISPLAYNAME = "Number") [ InitialExpression = "2.15" ];

/// ,  
Property ge As %Integer(DISPLAYNAME = "Age") [ Calculated, SqlComputeCode = { set {*}=##class(Form.Test.Person).currentAge({dob})}, SqlComputed, SqlComputeOnChange = dob ];

///  
ClassMethod currentAge(date As %Date = "") As %Integer [ CodeMode = expression ]
{
$Select(date="":"",1:($ZD($H,8)-$ZD(date,8)\10000))
}

///  -      Form.Test.Person
Property relative As Form.Test.Person(DISPLAYNAME = "Relative");

/// 
Property Home As Form.Test.Address(DISPLAYNAME = "House");

///   ,    
/// http://docs.intersystems.com/latest/csp/docbook/DocBook.UI.Page.cls?KEY=GOBJ_relationships
Relationship company As Form.Test.Company(DISPLAYNAME = "Company") [ Cardinality = one, Inverse = employees ];
}

RESTForms


RESTForms, :


  1. Form.Adaptor
  2. FORMNAME
  3. OBJPERMISSIONS (CRUD)
  4. DISPLAYPROPERTY ,
  5. FORMORDERBY RESTForms
  6. , , DISPLAYNAME

(. , 4), Person 1. , :


http://localhost:57772/forms/form/object/Form.Test.Person/1

:


{
   "_class":"Form.Test.Person",
   "_id":1,
   "name":"Klingman,Rhonda H.",
   "dob":"1996-10-18",
   "ts":"2016-09-20T10:51:31.375Z",
   "num":2.15,
   "ge":20,
   "relative":null,
   "Home":{
      "_class":"Form.Test.Address",
      "House":430,
      "Street":"5337 Second Place",
      "City":"Jackson"
   },
   "company":{
      "_class":"Form.Test.Company",
      "_id":60,
      "name":"XenaSys.com",
      "employees":[
         null
      ]
   }
}

( , num), :


PUT http://localhost:57772/forms/form/object/Form.Test.Person

:


{
   "_class":"Form.Test.Person",
   "_id":1,
   "num":3.15
}

, , _class, _id .


, . :


POST http://localhost:57772/forms/form/object/Form.Test.Person

:


{
   "_class":"Form.Test.Person",
    "name":"Test person",
    "dob":"2000-01-18",
    "ts":"2016-09-20T10:51:31.375Z",
    "num":2.15,
    "company":{ "_class":"Form.Test.Company", "_id":1 }
}

, RESTForms :


{"Id": "101"}

, JSON. , _class _id.



RESTForms (: Demo, : Demo).
, RESTFormsUI RESTForms. (: Demo, : Demo). :



RESTForms , REST API .


?


RESTForms. , , SQL-.



Original source: habrahabr.ru (comments, light).

https://habrahabr.ru/post/330822/

:  

: [1] []
 

:
: 

: ( )

:

  URL