889 |
889 |
* Enter description here...
|
890 |
890 |
*
|
891 |
891 |
* @param string $resourceURI
|
892 |
|
* @param mixed $pageSize
|
893 |
|
* The maximum number of entities returned per page (can be NULL
|
|
892 |
* @param int $pageSize
|
|
893 |
* The maximum number of entities returned per page.
|
|
894 |
* The default page size as configured in the cdm server
|
|
895 |
* will be used if set to NULL
|
894 |
896 |
* to return all entities in a single page).
|
895 |
897 |
* @param int $pageNumber
|
896 |
898 |
* The number of the page to be returned, the first page has the
|
897 |
|
* pageNumber = 1.
|
|
899 |
* pageNumber = 0
|
|
900 |
*
|
|
901 |
* @return the a CDM Pager object
|
898 |
902 |
*
|
899 |
|
* @return unknown
|
900 |
|
* FIXME seems to be out of date, maybe uused? webservices are using pageNumber parameter?
|
901 |
903 |
*/
|
902 |
904 |
function cdm_ws_page($resourceURI, $pageSize, $pageNumber) {
|
903 |
905 |
return cdm_ws_get($resourceURI, NULL, queryString(array(
|
904 |
|
"page" => $pageNumber,
|
|
906 |
"pageNumber" => $pageNumber,
|
905 |
907 |
'pageSize' => $pageSize,
|
906 |
908 |
)));
|
907 |
909 |
}
|
908 |
910 |
|
|
911 |
/**
|
|
912 |
* Fetches all entities from the given REST endpoint using the pager mechanism.
|
|
913 |
*
|
|
914 |
* @param string $resourceURI
|
|
915 |
*
|
|
916 |
* @return array
|
|
917 |
* A list of CDM entitites
|
|
918 |
*
|
|
919 |
*/
|
|
920 |
function cdm_ws_fetch_all($resourceURI) {
|
|
921 |
$page_index = 0;
|
|
922 |
// using a bigger page size to avoid to many multiple requests
|
|
923 |
$page_size = 200;
|
|
924 |
$entities = array();
|
|
925 |
|
|
926 |
while ($page_index !== FALSE){
|
|
927 |
$pager = cdm_ws_page($resourceURI, $page_size, $page_index);
|
|
928 |
if(isset($pager->records) && is_array($pager->records)) {
|
|
929 |
$entities = $pager->records;
|
|
930 |
if(!empty($pager->nextIndex)){
|
|
931 |
$page_index = $pager->nextIndex;
|
|
932 |
} else {
|
|
933 |
$page_index = FALSE;
|
|
934 |
}
|
|
935 |
} else {
|
|
936 |
$page_index = FALSE;
|
|
937 |
}
|
|
938 |
}
|
|
939 |
return $entities;
|
|
940 |
}
|
|
941 |
|
909 |
942 |
/*
|
910 |
943 |
function cdm_ws_taxonomy_compose_resourcePath($path = NULL){
|
911 |
944 |
$viewrank = _cdm_taxonomy_compose_viewrank();
|
... | ... | |
1209 |
1242 |
*/
|
1210 |
1243 |
function cdm_ws_getAnnotationsFor(&$cdmBase, $includeTypes = FALSE) {
|
1211 |
1244 |
|
1212 |
|
$annotations = array();
|
1213 |
|
|
1214 |
1245 |
if(!isset($cdmBase->annotations)){
|
1215 |
1246 |
$annotationUrl = cdm_compose_annotations_url($cdmBase);
|
1216 |
|
if ($annotationUrl) {
|
1217 |
|
$annotationPager = cdm_ws_get($annotationUrl, NULL, NULL, NULL, TRUE);
|
1218 |
|
if (isset($annotationPager->records) && is_array($annotationPager->records)) {
|
1219 |
|
$cdmBase->annotations = $annotationPager->records;
|
1220 |
|
} else {
|
1221 |
|
$cdmBase->annotations = array();
|
1222 |
|
}
|
1223 |
|
}
|
|
1247 |
$cdmBase->annotations = cdm_ws_fetch_all($annotationUrl);
|
1224 |
1248 |
}
|
1225 |
1249 |
|
|
1250 |
$annotations = array();
|
1226 |
1251 |
foreach ($cdmBase->annotations as $annotation) {
|
1227 |
1252 |
if ($includeTypes) {
|
1228 |
1253 |
if ((isset($annotation->annotationType->uuid) && in_array($annotation->annotationType->uuid, $includeTypes, TRUE)) || ($annotation->annotationType === NULL && in_array('NULL_VALUE', $includeTypes, TRUE))) {
|
fixing #2971 (cdm_ws_getAnnotationsFor() returns only the first page of annotations) and related improvements