You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@openwhisk.apache.org by GitBox <gi...@apache.org> on 2018/01/09 11:53:03 UTC

[GitHub] markusthoemmes commented on a change in pull request #3162: Add type property to entity documents

markusthoemmes commented on a change in pull request #3162: Add type property to entity documents 
URL: https://github.com/apache/incubator-openwhisk/pull/3162#discussion_r160386687
 
 

 ##########
 File path: common/scala/src/main/scala/whisk/core/entity/WhiskStore.scala
 ##########
 @@ -69,6 +69,14 @@ protected[core] trait WhiskDocument extends DocumentSerializer with DocumentRevi
    */
   protected[core] final def docinfo: DocInfo = DocInfo(docid, rev)
 
+  /**
+   * Determines entity type based on entity class name
+   */
+  protected[core] def documentType: String = {
+    val typeName = this.getClass.getSimpleName.toLowerCase
+    if (typeName.startsWith("whisk")) typeName.substring(5) else typeName
+  }
 
 Review comment:
   Should we rather override this property in the specific subtypes instead of relying on "magic"?
   
   Alternatively, maybe we can get away with something like:
   
   ```scala
   protected[core] def documentType: String = this match {
     case _: WhiskAction => "action"
     case _: WhiskRule => "rule"
     ...
   }
   ```
   
   Didn't test this though.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services