/**
  * Builds the Json Document for the storage w.r.t their docId
  *
  * @param document
  *            - document for storage
  * @param jsonObjDoc
  *            - jsonDoc object for storage
  *
  */
 function buildJsonDocument($document, $jsonObjDoc)
 {
     $jsonObjDoc = new JSONObject($jsonObjDoc);
     if ($jsonObjDoc->has("loc") && $jsonObjDoc->__get("loc") != null) {
         $geoArray = $jsonObjDoc->getJSONArray("loc");
         for ($i = 0; $i < count($geoArray); $i++) {
             if (count($geoArray) == 2) {
                 $geoTag = new GeoTag();
                 $geoTag->setLat($geoArray[0]);
                 $geoTag->setLng($geoArray[1]);
                 $document->setLocation($geoTag);
                 $jsonObjDoc->remove("loc");
             }
         }
     }
     if ($jsonObjDoc->has("_id") && $jsonObjDoc->__get("_id") != null) {
         $idObj = $jsonObjDoc->__get("_id");
         $oIdObj = $idObj->__get("\$oid");
         $document->setDocId($oIdObj);
         $jsonObjDoc->remove("_id");
     }
     if ($jsonObjDoc->has("_\$updatedAt") && $jsonObjDoc->__get("_\$updatedAt") != null) {
         $updatedObj = $jsonObjDoc->__get("_\$updatedAt");
         $document->setUpdatedAt($updatedObj);
         $jsonObjDoc->remove("_\$updatedAt");
     }
     if ($jsonObjDoc->has("_\$createdAt") && $jsonObjDoc->__get("_\$createdAt") != null) {
         $createdAtObj = $jsonObjDoc->__get("_\$createdAt");
         $document->setCreatedAt($createdAtObj);
         $jsonObjDoc->remove("_\$createdAt");
     }
     if ($jsonObjDoc->has("_\$event") && $jsonObjDoc->__get("_\$event") != null) {
         $eventObj = $jsonObjDoc->__get("_\$event");
         $document->setEvent($eventObj);
         $jsonObjDoc->remove("_\$event");
     }
     if ($jsonObjDoc->has("_\$owner") && $jsonObjDoc->__get("_\$owner") != null) {
         $idObj = $jsonObjDoc->__get("_\$owner");
         $ownerObj = $idObj->__get("owner");
         $document->setOwner($ownerObj);
         $jsonObjDoc->remove("_\$owner");
     }
     $document->setJsonDoc($jsonObjDoc);
 }
 function buildJsonFacebookProfileLink($me, $friendJSONObj)
 {
     $jsonObjMe = new JSONObject($friendJSONObj);
     if ($jsonObjMe->has("id") && $jsonObjMe->__get("id") != null) {
         $me->setId($jsonObjMe->__get("id"));
         $me->setName($jsonObjMe->__get("name"));
         $me->setPicture($jsonObjMe->__get("picture"));
         $me->setFirstName($jsonObjMe->__get("firstName"));
         $me->setLastName($jsonObjMe->__get("lastName"));
         $me->setGender($jsonObjMe->__get("gender"));
         $me->setLink($jsonObjMe->__get("link"));
         $me->setLocale($jsonObjMe->__get("locale"));
         $me->setUserName($jsonObjMe->__get("username"));
     }
 }
 function buildJsonFacebookProfile($me, $friendJSONObj)
 {
     $jsonObjMe = new JSONObject($friendJSONObj);
     if ($jsonObjMe->has("id") && $jsonObjMe->__get("id") != null) {
         $me->setId($jsonObjMe->__get("id"));
         $me->setName($jsonObjMe->__get("name"));
         $me->setPicture($jsonObjMe->__get("picture"));
     }
 }