2809: Merge branch 'master' into 2809-workbench-rails4 refs #2809
[arvados.git] / apps / workbench / app / models / collection.rb
index cfbb6405041a41f5efb0de50f11ab6dbbf179835..6022d82433ec843a1aff509d619c964608259b84 100644 (file)
@@ -1,4 +1,17 @@
 class Collection < ArvadosBase
+  include ApplicationHelper
+
+  MD5_EMPTY = 'd41d8cd98f00b204e9800998ecf8427e'
+
+  # Return true if the given string is the locator of a zero-length blob
+  def self.is_empty_blob_locator? locator
+    !!locator.to_s.match("^#{MD5_EMPTY}(\\+.*)?\$")
+  end
+
+  def content_summary
+    human_readable_bytes_html(total_bytes) + " " + super
+  end
+
   def total_bytes
     if files
       tot = 0
@@ -12,4 +25,17 @@ class Collection < ArvadosBase
   def attribute_editable?(attr)
     false
   end
+
+  def self.creatable?
+    false
+  end
+
+  def provenance
+    arvados_api_client.api "collections/#{self.uuid}/", "provenance"
+  end
+
+  def used_by
+    arvados_api_client.api "collections/#{self.uuid}/", "used_by"
+  end
+
 end