| 
					
				 | 
			
			
				@@ -71,6 +71,9 @@ class TripalEntityService_v0_1 extends TripalWebService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     $term = reset($term); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     $vocab = $term->vocab; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    // Convert the term to a simple array 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    $term = tripal_get_term_details($term->vocab->vocabulary, $term->accession); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     // Get the TripalEntity 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     $entity = tripal_load_entity('TripalEntity', array('id' => $entity_id)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     $entity = reset($entity); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -87,17 +90,14 @@ class TripalEntityService_v0_1 extends TripalWebService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     list($field, $instance, $term) = $this->findField($bundle, $expfield); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     // Next add in the ID and Type for this resources. 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    $key = $term['name']; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    $key_adj = strtolower(preg_replace('/ /', '_', $term['name'])); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    $this->resource->addContextItem($key_adj, $term['url']); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    $this->resource->setID(urlencode($key)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    $this->resource->setType($key_adj); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    $this->setResourceType($this->resource, $term); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    $this->resource->setID(urlencode($term['name'])); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     // Attach the field and then add it's values to the response. 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     field_attach_load($entity->type, array($entity->id => $entity), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         FIELD_LOAD_CURRENT, array('field_id' => $field['id'])); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    $this->addEntityField($key_adj, $term, $entity, $bundle, $field, $instance, $service_path, $expfield); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    $this->addEntityField($term, $entity, $bundle, $field, $instance, $service_path, $expfield); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   /** 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -130,10 +130,12 @@ class TripalEntityService_v0_1 extends TripalWebService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     $bundle = tripal_load_bundle_entity(array('label' => $ctype)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     $term = entity_load('TripalTerm', array('id' => $bundle->term_id)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     $term = reset($term); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    $vocab = $term->vocab; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    // Convert the $term to a simple array 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    $term = tripal_get_term_details($term->vocab->vocabulary, $term->accession); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     // Add the vocabulary to the context. 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    $this->resource->addContextItem($term->name, $term->url); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    $this->resource->addContextItem($term['name'], $term['url']); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     // Get the TripalEntity. 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     $entity = tripal_load_entity('TripalEntity', array('id' => $entity_id)); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -151,16 +153,12 @@ class TripalEntityService_v0_1 extends TripalWebService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     $itemPage = tripal_get_term_details('schema', 'ItemPage'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     $label = tripal_get_term_details('rdfs', 'label'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     $this->resource->setID($entity_id); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    $this->resource->setType($term->name); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    $this->resource->addContextItem('label', $label['url']); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    $this->resource->addContextItem('ItemPage', $itemPage['url']); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    $this->resource->addProperty('label', $entity->title); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    $this->resource->addProperty('ItemPage', url('/bio_data/' . $entity->id, array('absolute' => TRUE))); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    $this->setResourceType($this->resource, $term); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    $this->addResourceProperty($this->resource, $label, $entity->title); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    $this->addResourceProperty($this->resource, $itemPage, url('/bio_data/' . $entity->id, array('absolute' => TRUE))); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    // Add in the entitie's fields. 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     $this->addEntityFields($entity, $bundle, $term, $service_path); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-//    tripal_ws_services_v0_1_get_content_add_fields($entity, $bundle, $api_url, $response, $ws_path, $ctype, $entity_id, $params); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-//    tripal_ws_services_v0_1_write_context($response, $ctype); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   /** 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -237,8 +235,6 @@ class TripalEntityService_v0_1 extends TripalWebService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				       if (!$term) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         continue; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				       } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      $key = $term['name']; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      $key_adj = strtolower(preg_replace('/ /', '_', $key)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				       // If this field should not be attached by default then just add a link 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				       // so that the caller can get the information separately. 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -250,27 +246,25 @@ class TripalEntityService_v0_1 extends TripalWebService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         // that information. 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         $items = field_get_items('TripalEntity', $entity, $field_name); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         if ($items and count($items) > 0 and $items[0]['value']) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-          $this->resource->addContextItem($key_adj, $term['url']); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-          $this->resource->addProperty($key_adj, $service_path . '/' . $entity->id . '/' . urlencode($term['name'])); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          $this->addResourceProperty($this->resource, $term, $service_path . '/' . $entity->id . '/' . urlencode($term['name'])); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				           if ($hide_fields == 'show') { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            $this->resource->addContextItem($key_adj, $term['url']); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            $this->resource->addProperty($key_adj, NULL); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            $this->addResourceProperty($this->resource, $term, NULL); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				           } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         continue; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				       } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				       // Get the details for this field for the JSON-LD response. 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      $this->addEntityField($key_adj, $term, $entity, $bundle, $field, $instance, $service_path); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      $this->addEntityField($term, $entity, $bundle, $field, $instance, $service_path); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    * Adds the field as a property of the entity resource. 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  private function addEntityField($key, $term, $entity, $bundle, $field, $instance, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  private function addEntityField($term, $entity, $bundle, $field, $instance, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				       $service_path, $expfield = NULL) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -295,7 +289,7 @@ class TripalEntityService_v0_1 extends TripalWebService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     $values = array(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     for ($i = 0; $i < count($items); $i++) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      $values[$i] = $this->sanitizeFieldKeys($items[$i]['value'], $bundle, $service_path); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      $values[$i] = $this->sanitizeFieldKeys($this->resource, $items[$i]['value'], $bundle, $service_path); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     if ($hide_fields == 'hide' and empty($values[0])) { 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -314,15 +308,13 @@ class TripalEntityService_v0_1 extends TripalWebService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				           } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-          $this->resource->addContextItem($key, $term['url']); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-          $this->resource->addProperty($key, $values[0]); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          $this->addResourceProperty($this->resource, $term, $values[0]); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				       } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				       // If the value is not an array it's a scalar so add it as is to the 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				       // response. 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				       else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        $this->resource->addContextItem($key, $term['url']); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        $this->resource->addProperty($key, $values[0]); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        $this->addResourceProperty($this->resource, $term, $values[0]); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				       } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -333,8 +325,7 @@ class TripalEntityService_v0_1 extends TripalWebService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				       // the resource for a collection. 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				       $response = new TripalWebServiceCollection($service_path . '/' . urlencode($expfield), $this->params); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				       $label = tripal_get_term_details('rdfs', 'label'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      $response->addContextItem('label', $label['url']); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      $response->addProperty('label', $instance['label']); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      $this->addResourceProperty($response, $label, $instance['label']); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				       $i = 0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				       foreach ($values as $delta => $element) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         $member = new TripalWebServiceResource($service_path . '/' . urlencode($expfield)); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -342,7 +333,7 @@ class TripalEntityService_v0_1 extends TripalWebService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         // Add the context of the parent resource because all of the keys 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         // were santizied and set to match the proper context. 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         $member->setContext($this->resource); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        $member->setType($key); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        $this->setResourceType($member, $term); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         foreach ($element as $key => $value) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				           $member->addProperty($key, $value); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -361,7 +352,7 @@ class TripalEntityService_v0_1 extends TripalWebService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    * Rewrites the keys of a field's items array for use with web services. 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  private function sanitizeFieldKeys($value, $bundle, $service_path) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  private function sanitizeFieldKeys($resource, $value, $bundle, $service_path) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     // If the entity is set to hide fields that have no values then we 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     // want to honor that in the web services too. 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     $hide_fields = tripal_get_bundle_variable('hide_empty_field', $bundle->id, 'hide'); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -383,15 +374,15 @@ class TripalEntityService_v0_1 extends TripalWebService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				           $vocabulary = $matches[1]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				           $accession = $matches[2]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				           $term = tripal_get_term_details($vocabulary, $accession); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          $key = $this->addContextTerm($resource, $term); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-          $key_adj = strtolower(preg_replace('/ /', '_', $term['name'])); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				           if (is_array($v)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            $temp[$key_adj] = $this->sanitizeFieldKeys($v, $bundle, $service_path); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            $temp[$key] = $this->sanitizeFieldKeys($resource, $v, $bundle, $service_path); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				           } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				           else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            $temp[$key_adj] = $v; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            $temp[$key] = $v; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				           } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-          $this->resource->addContextItem($key_adj, $term['url']); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          $term['name'] = $key; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         else { 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -748,9 +739,7 @@ class TripalEntityService_v0_1 extends TripalWebService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   private function doContentTypeList($ctype) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     $service_path = $this->getServicePath() . '/' . urlencode($ctype); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    $label = tripal_get_term_details('rdfs', 'label'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     $this->resource = new TripalWebServiceCollection($service_path, $this->params); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    $this->resource->addContextItem('label', $label['url']); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     // Get the TripalBundle, TripalTerm and TripalVocab type for this type. 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     $bundle = tripal_load_bundle_entity(array('label' => $ctype)); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -758,7 +747,8 @@ class TripalEntityService_v0_1 extends TripalWebService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     $term = reset($term); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     // Set the label for this collection. 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    $this->resource->addProperty('label', $bundle->label . " collection"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    $label = tripal_get_term_details('rdfs', 'label'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    $this->addResourceProperty($this->resource, $label, $bundle->label . " collection"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     // For quick lookup, get the mapping of WS keys to their appropriate fields. 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     $field_mapping = $this->getFieldMapping($bundle); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -839,13 +829,10 @@ class TripalEntityService_v0_1 extends TripalWebService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				       $itemPage = tripal_get_term_details('schema', 'ItemPage'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				       $label = tripal_get_term_details('rdfs', 'label'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				       $member = new TripalWebServiceResource($service_path); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      $member->addContextItem('label', $label['url']); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      $member->addContextItem('ItemPage', $itemPage['url']); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      $member->addContextItem($term->name, $term->url); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				       $member->setID($entity->id); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      $member->setType($term->name); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      $member->addProperty('label', $entity->title); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      $member->addProperty('ItemPage', url('/bio_data/' . $entity->id, array('absolute' => TRUE))); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      $this->setResourceType($member, $term); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      $this->addResourceProperty($member, $label, $entity->title); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      $this->addResourceProperty($member, $itemPage, url('/bio_data/' . $entity->id, array('absolute' => TRUE))); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				       $this->resource->addMember($member); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   } 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -855,10 +842,10 @@ class TripalEntityService_v0_1 extends TripalWebService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   private function doAllTypesList() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     $service_path = $this->getServicePath(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    $label = tripal_get_term_details('rdfs', 'label'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     $this->resource = new TripalWebServiceCollection($service_path, $this->params); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    $this->resource->addContextItem('label', $label['url']); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    $this->resource->addProperty('label', 'Content Types'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    $label = tripal_get_term_details('rdfs', 'label'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    $this->addResourceProperty($this->resource, $label, 'Content Types'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     // Get the list of published terms (these are the bundle IDs) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     $bundles = db_select('tripal_bundle', 'tb') 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -873,16 +860,21 @@ class TripalEntityService_v0_1 extends TripalWebService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				       $term = reset($entity); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				       $vocab = $term->vocab; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      // Convert the term to a simple array 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      $term = tripal_get_term_details($term->vocab->vocabulary, $term->accession); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				       $member = new TripalWebServiceResource($service_path); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      $member->setID(urlencode($bundle->label)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				       // If the term has no URL then we'll default to using thie site's 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				       // term lookup service. 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      $url = $term->url; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      $url = $term['url']; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				       if (!$url) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        $url = url('cv/lookup/' . $term->vocab->vocabulary . '/' . $term->accession , array('absolute' => TRUE)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        $url = url('cv/lookup/' . $term['vocabulary']['short_name'] . '/' . $term['accession'] , array('absolute' => TRUE)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        $term['url'] = $url; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				       } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      $member->addContextItem($term->name, $url); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      $member->addContextItem('label', $label['url']); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      $member->addProperty('label', $bundle->label); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      $this->setResourceType($member, $term); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      $this->addResourceProperty($member, $label, $bundle->label); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				       $member->addContextItem('description', 'hydra:description'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				       // Get the bundle description. If no description is provided then 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				       // use the term definition 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -894,9 +886,6 @@ class TripalEntityService_v0_1 extends TripalWebService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         $description = ''; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				       } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				       $member->addProperty('description', $description); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      $member->setID(urlencode($bundle->label)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      $member->setType($term->name); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				       $this->resource->addMember($member); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 |