Difference between revisions of "GetFrags"

From ARK
Jump to: navigation, search
(Created page with "This method is used to get a list of data fragments of a specific dataclass and/or classtype within the ARK instance. It will return a JSON array of all the different data fragme...")
 
(Optional)
 
(3 intermediate revisions by the same user not shown)
Line 3: Line 3:
 
===Path===
 
===Path===
  
http://your.ark.instance/api.php?request=getFrags
+
http://your.ark.instance/api.php?req=getFrags
  
 
===Arguments===
 
===Arguments===
Line 13: Line 13:
 
*'''item_value''' - this is the ARK item that you are interested in. This should be sent in the form item_key=item_value. As an example: cxt_cd=LK12_1. A list of available items can be supplied by [[describeItems]].
 
*'''item_value''' - this is the ARK item that you are interested in. This should be sent in the form item_key=item_value. As an example: cxt_cd=LK12_1. A list of available items can be supplied by [[describeItems]].
  
*'''dataclass''' -  
+
*'''dataclass''' - this can be any of the main dataclasses, e.g. [[action]],[[attribute]], [[date]], [[span]], [[xmi]], [[txt]], [[number]],[[file]]. If you want to return all of the possible data fragment types then set the argument to 'all'.
  
 
====Optional====
 
====Optional====
  
*
+
*'''classtype''' - if you are only interested in a particular type of data then you can send the classtype as well and this will limit the results
 +
 
 +
*'''aliased''' - set this argument to 'true' if you want the human-readable aliases to be returned
  
 
If anonymous logins are not enabled a username and password will need to be supplied:
 
If anonymous logins are not enabled a username and password will need to be supplied:
Line 24: Line 26:
  
 
*'''passwd''' - password
 
*'''passwd''' - password
 +
 +
The method returns a JSON array unless otherwise specified:
 +
 +
*'''format''' - 'json' by default, but sending 'html' prints a human-readable array to screen
  
 
===Example===
 
===Example===
  
http://your.ark.instance/api.php?request=getItems&item_key=hut_cd&handle=johndoe&passwd=johndoepassword
+
====Example 1 - Retrieve all attributes attached to an item====
 +
 
 +
http://your.ark.instance/api.php?req=getFrags&dataclass=attribute&item_key=hut_cd&hut_cd=LK12_1&handle=johndoe&passwd=johndoepassword
  
 
Example return (returned JSONified - displayed as an array here for ease of viewing):
 
Example return (returned JSONified - displayed as an array here for ease of viewing):
  
<pre>
+
<pre>Array
Array
 
 
(
 
(
     [hut] => Array
+
     [LK12_1] => Array
 
         (
 
         (
 
             [0] => Array
 
             [0] => Array
 
                 (
 
                 (
                     [0] => LK12_1
+
                     [0] => Array
                    [hut_cd] => LK12_1
+
                        (
                    [1] => 1
+
                            [dataclass] => attribute
                     [hut_no] => 1
+
                            [id] => 39
                    [2] => LK12
+
                            [attribute] => 89
                    [ste_cd] => LK12
+
                            [attributetype] => 14
                    [3] => 1
+
                            [boolean] => 1
                    [cre_by] => 1
+
                            [attached_frags] =>  
                    [4] => 2012-05-24 00:00:00
+
                        )
                    [cre_on] => 2012-05-24 00:00:00
+
 
 +
                     [1] => Array
 +
                        (
 +
                            [dataclass] => attribute
 +
                            [id] => 63
 +
                            [attribute] => 92
 +
                            [attributetype] => 15
 +
                            [boolean] => 1
 +
                            [attached_frags] =>  
 +
                        )
 +
 
 
                 )
 
                 )
  
             [1] => Array
+
        )
 +
 
 +
)
 +
</pre>
 +
 
 +
====Example 2 - Retrieve all text of classtype 'notes' attached to an item====
 +
 
 +
http://your.ark.instance/api.php?req=getFrags&dataclass=txt&classtype=notes&item_key=hut_cd&hut_cd=LK12_1&handle=johndoe&passwd=johndoepassword
 +
 
 +
Example return (returned JSONified - displayed as an array here for ease of viewing):
 +
 
 +
<pre>Array
 +
(
 +
    [LK12_1] => Array
 +
        (
 +
             [0] => Array
 
                 (
 
                 (
                     [0] => LK12_2
+
                     [0] => Array
                    [hut_cd] => LK12_2
+
                        (
                    [1] => 2
+
                            [dataclass] => txt
                    [hut_no] => 2
+
                            [id] => 1
                    [2] => LK12
+
                            [txt] => House 1
                    [ste_cd] => LK12
+
                            [txttype] => 108
                    [3] => 1
+
                            [attached_frags] =>  
                    [cre_by] => 1
+
                        )
                    [4] => 2012-05-24 00:00:00
+
 
                    [cre_on] => 2012-05-24 00:00:00
 
 
                 )
 
                 )
  
             [2] => Array
+
        )
 +
 
 +
)
 +
</pre>
 +
 
 +
====Example 3 - Retrieve all data fragments attached to an item with Aliases====
 +
 
 +
http://your.ark.instance/api.php?req=getFrags&dataclass=all&item_key=hut_cd&hut_cd=LK12_1&aliased=true&handle=johndoe&passwd=johndoepassword
 +
 
 +
Example return (returned JSONified - displayed as an array here for ease of viewing):
 +
 
 +
<pre>Array
 +
(
 +
    [LK12_1] => Array
 +
        (
 +
             [0] => Array
 
                 (
 
                 (
                     [0] => LK12_3
+
                     [0] => Array
                     [hut_cd] => LK12_3
+
                        (
                     [1] => 3
+
                            [dataclass] => attribute
                     [hut_no] => 3
+
                            [id] => 39
                     [2] => LK12
+
                            [attribute] => 89
                     [ste_cd] => LK12
+
                            [attributetype] => 14
                    [3] => 0
+
                            [boolean] => 1
                     [cre_by] => 0
+
                            [attached_frags] =>
                     [4] => 0000-00-00 00:00:00
+
                            [attribute_alias] => WSW
                    [cre_on] => 0000-00-00 00:00:00
+
                            [alias] => WSW
 +
                        )
 +
 
 +
                     [1] => Array
 +
                        (
 +
                            [dataclass] => attribute
 +
                            [id] => 63
 +
                            [attribute] => 92
 +
                            [attributetype] => 15
 +
                            [boolean] => 1
 +
                            [attached_frags] =>
 +
                            [attribute_alias] => House
 +
                            [alias] => House
 +
                        )
 +
 
 +
                     [2] => Array
 +
                        (
 +
                            [dataclass] => txt
 +
                            [id] => 1
 +
                            [txt] => House 1
 +
                            [txttype] => 108
 +
                            [attached_frags] =>  
 +
                            [alias] => Notes
 +
                        )
 +
 
 +
                    [3] => Array
 +
                        (
 +
                            [dataclass] => number
 +
                            [id] => 1
 +
                            [number] => 12
 +
                            [numbertype] => 14
 +
                            [attached_frags] =>
 +
                            [alias] => Diameter
 +
                        )
 +
 
 +
                    [4] => Array
 +
                        (
 +
                            [dataclass] => number
 +
                            [id] => 22
 +
                            [number] => 13
 +
                            [numbertype] => 15
 +
                            [attached_frags] =>
 +
                            [alias] => Number of Huts that Can See this Hut
 +
                        )
 +
 
 +
                     [5] => Array
 +
                        (
 +
                            [dataclass] => file
 +
                            [id] => 1
 +
                            [file] => 1
 +
                            [filetype] => 1
 +
                            [attached_frags] =>
 +
                            [alias] => Stone Worlds
 +
                        )
 +
 
 +
                     [6] => Array
 +
                        (
 +
                            [dataclass] => file
 +
                            [id] => 2
 +
                            [file] => 2
 +
                            [filetype] => 1
 +
                            [attached_frags] =>
 +
                            [alias] => Stone Worlds
 +
                        )
 +
 
 +
                     [7] => Array
 +
                        (
 +
                            [dataclass] => file
 +
                            [id] => 3
 +
                            [file] => 3
 +
                            [filetype] => 1
 +
                            [attached_frags] =>  
 +
                            [alias] => Stone Worlds
 +
                        )
 +
 
 +
                     [8] => Array
 +
                        (
 +
                            [dataclass] => file
 +
                            [id] => 70
 +
                            [file] => 70
 +
                            [filetype] => 2
 +
                            [attached_frags] =>
 +
                            [alias] => Photo
 +
                        )
 +
 
 +
                     [9] => Array
 +
                        (
 +
                            [dataclass] => file
 +
                            [id] => 71
 +
                            [file] => 71
 +
                            [filetype] => 2
 +
                            [attached_frags] =>  
 +
                            [alias] => Photo
 +
                        )
 +
 
 
                 )
 
                 )
  
 
         )
 
         )
 +
 
)
 
)
 
</pre>
 
</pre>

Latest revision as of 15:51, 15 November 2013

This method is used to get a list of data fragments of a specific dataclass and/or classtype within the ARK instance. It will return a JSON array of all the different data fragments attached to a specific item

Path

http://your.ark.instance/api.php?req=getFrags

Arguments

Mandatory

  • item_key - this is the item_key of the required module (for instance 'cxt_cd').
  • item_value - this is the ARK item that you are interested in. This should be sent in the form item_key=item_value. As an example: cxt_cd=LK12_1. A list of available items can be supplied by describeItems.
  • dataclass - this can be any of the main dataclasses, e.g. action,attribute, date, span, xmi, txt, number,file. If you want to return all of the possible data fragment types then set the argument to 'all'.

Optional

  • classtype - if you are only interested in a particular type of data then you can send the classtype as well and this will limit the results
  • aliased - set this argument to 'true' if you want the human-readable aliases to be returned

If anonymous logins are not enabled a username and password will need to be supplied:

  • handle - username
  • passwd - password

The method returns a JSON array unless otherwise specified:

  • format - 'json' by default, but sending 'html' prints a human-readable array to screen

Example

Example 1 - Retrieve all attributes attached to an item

http://your.ark.instance/api.php?req=getFrags&dataclass=attribute&item_key=hut_cd&hut_cd=LK12_1&handle=johndoe&passwd=johndoepassword

Example return (returned JSONified - displayed as an array here for ease of viewing):

Array
(
    [LK12_1] => Array
        (
            [0] => Array
                (
                    [0] => Array
                        (
                            [dataclass] => attribute
                            [id] => 39
                            [attribute] => 89
                            [attributetype] => 14
                            [boolean] => 1
                            [attached_frags] => 
                        )

                    [1] => Array
                        (
                            [dataclass] => attribute
                            [id] => 63
                            [attribute] => 92
                            [attributetype] => 15
                            [boolean] => 1
                            [attached_frags] => 
                        )

                )

        )

)

Example 2 - Retrieve all text of classtype 'notes' attached to an item

http://your.ark.instance/api.php?req=getFrags&dataclass=txt&classtype=notes&item_key=hut_cd&hut_cd=LK12_1&handle=johndoe&passwd=johndoepassword

Example return (returned JSONified - displayed as an array here for ease of viewing):

Array
(
    [LK12_1] => Array
        (
            [0] => Array
                (
                    [0] => Array
                        (
                            [dataclass] => txt
                            [id] => 1
                            [txt] => House 1
                            [txttype] => 108
                            [attached_frags] => 
                        )

                )

        )

)

Example 3 - Retrieve all data fragments attached to an item with Aliases

http://your.ark.instance/api.php?req=getFrags&dataclass=all&item_key=hut_cd&hut_cd=LK12_1&aliased=true&handle=johndoe&passwd=johndoepassword

Example return (returned JSONified - displayed as an array here for ease of viewing):

Array
(
    [LK12_1] => Array
        (
            [0] => Array
                (
                    [0] => Array
                        (
                            [dataclass] => attribute
                            [id] => 39
                            [attribute] => 89
                            [attributetype] => 14
                            [boolean] => 1
                            [attached_frags] => 
                            [attribute_alias] => WSW
                            [alias] => WSW
                        )

                    [1] => Array
                        (
                            [dataclass] => attribute
                            [id] => 63
                            [attribute] => 92
                            [attributetype] => 15
                            [boolean] => 1
                            [attached_frags] => 
                            [attribute_alias] => House
                            [alias] => House
                        )

                    [2] => Array
                        (
                            [dataclass] => txt
                            [id] => 1
                            [txt] => House 1
                            [txttype] => 108
                            [attached_frags] => 
                            [alias] => Notes
                        )

                    [3] => Array
                        (
                            [dataclass] => number
                            [id] => 1
                            [number] => 12
                            [numbertype] => 14
                            [attached_frags] => 
                            [alias] => Diameter
                        )

                    [4] => Array
                        (
                            [dataclass] => number
                            [id] => 22
                            [number] => 13
                            [numbertype] => 15
                            [attached_frags] => 
                            [alias] => Number of Huts that Can See this Hut
                        )

                    [5] => Array
                        (
                            [dataclass] => file
                            [id] => 1
                            [file] => 1
                            [filetype] => 1
                            [attached_frags] => 
                            [alias] => Stone Worlds 
                        )

                    [6] => Array
                        (
                            [dataclass] => file
                            [id] => 2
                            [file] => 2
                            [filetype] => 1
                            [attached_frags] => 
                            [alias] => Stone Worlds 
                        )

                    [7] => Array
                        (
                            [dataclass] => file
                            [id] => 3
                            [file] => 3
                            [filetype] => 1
                            [attached_frags] => 
                            [alias] => Stone Worlds 
                        )

                    [8] => Array
                        (
                            [dataclass] => file
                            [id] => 70
                            [file] => 70
                            [filetype] => 2
                            [attached_frags] => 
                            [alias] => Photo
                        )

                    [9] => Array
                        (
                            [dataclass] => file
                            [id] => 71
                            [file] => 71
                            [filetype] => 2
                            [attached_frags] => 
                            [alias] => Photo
                        )

                )

        )

)