You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@isis.apache.org by da...@apache.org on 2017/11/14 23:13:23 UTC

[isis] branch master updated: ISIS-1769: adds openRestApi mixin for Object.

This is an automated email from the ASF dual-hosted git repository.

danhaywood pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/isis.git


The following commit(s) were added to refs/heads/master by this push:
     new a81ab04  ISIS-1769: adds openRestApi mixin for Object.
a81ab04 is described below

commit a81ab04a05305e5188964551c1d769319a55e2b0
Author: Dan Haywood <da...@haywood-associates.co.uk>
AuthorDate: Tue Nov 14 23:08:52 2017 +0000

    ISIS-1769: adds openRestApi mixin for Object.
---
 .../guides/rgcms/_rgcms_classes_mixins_Object.adoc | 89 +++++++++++++---------
 .../rgcms/_rgcms_classes_mixins_Persistable.adoc   | 19 ++---
 .../applib/services/layout/Object_openRestApi.java | 64 ++++++++++++++++
 3 files changed, 124 insertions(+), 48 deletions(-)

diff --git a/adocs/documentation/src/main/asciidoc/guides/rgcms/_rgcms_classes_mixins_Object.adoc b/adocs/documentation/src/main/asciidoc/guides/rgcms/_rgcms_classes_mixins_Object.adoc
index edfaa62..c64d7bc 100644
--- a/adocs/documentation/src/main/asciidoc/guides/rgcms/_rgcms_classes_mixins_Object.adoc
+++ b/adocs/documentation/src/main/asciidoc/guides/rgcms/_rgcms_classes_mixins_Object.adoc
@@ -5,7 +5,11 @@
 :_imagesdir: images/
 
 
-The framework provides a single mixin that contributes to simply `java.lang.Object`.  It provides the ability to download the layout XML for any domain object (in practical terms: entities and view models).
+The framework provides a single mixin that contributes to simply `java.lang.Object`.
+It provides the ability to download the layout XML for any domain object (in practical terms: entities and view models).
+
+These mixin actions are all associated with the "Metadata" fieldset.
+A number of other xref:../rgcms/rgcms.adoc#_rgcms_classes_mixins_Persistable[mixins] also contribute properties or actions to the "Metadata" fieldset.
 
 
 
@@ -13,10 +17,9 @@ The framework provides a single mixin that contributes to simply `java.lang.Obje
 == `clearHints()`
 
 When a domain object is rendered the end-user can select different tabs, and for collections can sort the columns,
-navigate to second pages, or select different views of collections.  If the user revisits that object, the
-xref:../ugvw/ugvw.adoc#[Wicket viewer] will remember these hints and render the domain object in the same state.  These
-rendering hints are also included if the user copies the URL using the anchor link (to right hand of the object's
-title).
+navigate to second pages, or select different views of collections.
+If the user revisits that object, the xref:../ugvw/ugvw.adoc#[Wicket viewer] will remember these hints and render the domain object in the same state.
+These rendering hints are also included if the user copies the URL using the anchor link (to right hand of the object's title).
 
 The `Object_clearHints` mixin provides the ability for the end-user to discard these hints so that the object is
 rendered in its initial state:
@@ -28,26 +31,17 @@ public void clearHints() {
 }
 ----
 
-
-=== Appearance in the UI
-
-This mixin actions are all associated with the "Metadata" fieldset.  If there is no such field set, then the action
- will be rendered as a top-level action).
-
-
-
-
 === Related Services
 
-This mixin uses the xref:../rgsvc/rgsvc.adoc#_rgsvc_presentation-layer-spi_HintStore[`HintStore`] service to store and retrieve UI hints for
-each rendered object, per user.
+This mixin uses the xref:../rgsvc/rgsvc.adoc#_rgsvc_presentation-layer-spi_HintStore[`HintStore`] service to store and retrieve UI hints for each rendered object, per user.
 
 
 
 [[__rgcms_classes_mixins_Object_downloadLayoutXml]]
 == `downloadLayoutXml()`
 
-The `Object_downloadLayoutXml` mixin provides an action to download the xref:../ugvw/ugvw.adoc#_ugvw_layout_file-based[layout XML] for the current domain object.  It has the following signature:
+The `Object_downloadLayoutXml` mixin provides an action to download the xref:../ugvw/ugvw.adoc#_ugvw_layout_file-based[layout XML] for the current domain object.
+It has the following signature:
 
 [source,java]
 ----
@@ -64,14 +58,6 @@ See the documentation on xref:../ugvw/ugvw.adoc#_ugvw_layout_file-based[layout X
 the xref:../rgsvc/rgsvc.adoc#_rgsvc_metadata-api_LayoutService[`LayoutService`] for more information on these styles
 
 
-=== Appearance in the UI
-
-This mixin actions are all associated with the "Metadata" fieldset.
-
-A number of other xref:../rgcms/rgcms.adoc#_rgcms_classes_mixins_Persistable[mixins] also contribute properties and actions to the "Metadata" fieldset.
-
-
-
 === Related Services
 
 This mixin calls xref:../rgsvc/rgsvc.adoc#_rgsvc_metadata-api_LayoutService[`LayoutService`] to obtain the layout XML.
@@ -82,9 +68,8 @@ This mixin calls xref:../rgsvc/rgsvc.adoc#_rgsvc_metadata-api_LayoutService[`Lay
 [[__rgcms_classes_mixins_Object_rebuildMetamodel]]
 == `rebuildMetamodel()`
 
-The `Object_rebuildMetamodel` mixin provides the ability to discard the current internal metamodel data (an instance
-of `ObjectSpecification`) for the domain class of the rendered object, and recreate from code and other sources (most
-notably, layout XML data).  It has the following signature:
+The `Object_rebuildMetamodel` mixin provides the ability to discard the current internal metamodel data (an instance of `ObjectSpecification`) for the domain class of the rendered object, and recreate from code and other sources (most notably, layout XML data).
+It has the following signature:
 
 [source,java]
 ----
@@ -94,18 +79,54 @@ public void rebuildMetamodel() {
 ----
 
 
-=== Appearance in the UI
+=== Related Services
+
+This mixin calls xref:../rgsvc/rgsvc.adoc#_rgsvc_metadata-api_MetamodelService[`MetaModelService`] and the xref:../rgsvc/rgsvc.adoc#_rgsvc_presentation-layer-spi_GridService[`GridService`] to invalidate their caches.
 
-This mixin actions are all associated with the "Metadata" fieldset.
 
-A number of other xref:../rgcms/rgcms.adoc#_rgcms_classes_mixins_Persistable[mixins] also contribute properties and actions to
-the "Metadata" fieldset.
 
+[[__rgcms_classes_mixins_Object_downloadLayoutXml]]
+== `downloadLayoutXml()`
+
+The `Object_downloadLayoutXml` mixin provides an action to download the xref:../ugvw/ugvw.adoc#_ugvw_layout_file-based[layout XML] for the current domain object.
+It has the following signature:
+
+[source,java]
+----
+public Object downloadLayoutXml(
+    @ParameterLayout(named = "File name")
+    final String fileName,
+    final LayoutService.Style style) {          // <1>
+    ...
+}
+----
+<1> either current, complete, normalized or minimal.
+
+See the documentation on xref:../ugvw/ugvw.adoc#_ugvw_layout_file-based[layout XML] and also
+the xref:../rgsvc/rgsvc.adoc#_rgsvc_metadata-api_LayoutService[`LayoutService`] for more information on these styles
+
+
+=== Related Services
+
+This mixin calls xref:../rgsvc/rgsvc.adoc#_rgsvc_metadata-api_LayoutService[`LayoutService`] to obtain the layout XML.
+
+
+
+[[__rgcms_classes_mixins_Object_openRestApi]]
+== `openRestApi()` (`1.16.0-SNAPSHOT`)
+
+The `Object_openRestApi` mixin provides an action to navigate to the URL of the xref:../ugvro/ugvro.adoc#[Restful Objects resource] corresponding to the domain object.
+It has the following signature:
+
+[source,java]
+----
+public URL openRestApi() { ... }
+----
 
 
 === Related Services
 
-This mixin calls xref:../rgsvc/rgsvc.adoc#_rgsvc_metadata-api_MetamodelService[`MetaModelService`] and the
-xref:../rgsvc/rgsvc.adoc#_rgsvc_presentation-layer-spi_GridService[`GridService`] to invalidate their caches.
+This mixin calls xref:../rgsvc/rgsvc.adoc#_rgsvc_integration-api_BookmarkService[`BookmarkService`] to build the URL.
+
 
 
diff --git a/adocs/documentation/src/main/asciidoc/guides/rgcms/_rgcms_classes_mixins_Persistable.adoc b/adocs/documentation/src/main/asciidoc/guides/rgcms/_rgcms_classes_mixins_Persistable.adoc
index 644353a..41b267a 100644
--- a/adocs/documentation/src/main/asciidoc/guides/rgcms/_rgcms_classes_mixins_Persistable.adoc
+++ b/adocs/documentation/src/main/asciidoc/guides/rgcms/_rgcms_classes_mixins_Persistable.adoc
@@ -5,10 +5,13 @@
 :_imagesdir: images/
 
 
-All domain entities automatically implement the DataNucleus `Persistable` role interface as a result of the enhancer
-process (the fully qualified class name is `org.datanucleus.enhancement.Persistable`).
+All domain entities automatically implement the DataNucleus `Persistable` role interface as a result of the enhancer process (the fully qualified class name is `org.datanucleus.enhancement.Persistable`).
 So as a developer you do not need to write any code to obtain the mixins that contribute to this interface.
 
+These mixin properties/actions are all associated with the "Metadata" fieldset.
+A number of other xref:../rgcms/rgcms.adoc#_rgcms_classes_mixins_Object[mixins] also contribute properties or actions to the "Metadata" fieldset.
+
+
 
 [[__rgcms_classes_mixins_Persistable_downloadJdoMetadata]]
 == `downloadJdoMetadata()`
@@ -27,12 +30,6 @@ public Clob downloadJdoMetadata(                    // <1>
 <1> returns the XML text wrapped up in a xref:../rgcms/rgcms.adoc#_rgcms_classes_value-types_Clob[`Clob`].
 
 
-=== Appearance in the UI
-
-This mixin action is associated with the "Metadata" fieldset, and will appear as a panel drop-down action.
-
-These mixin properties are all associated with the "Metadata" fieldset.
-The xref:../rgcms/rgcms.adoc#_rgcms_classes_mixins_Object[Object mixin] also contribute an action to the "Metadata" fieldset.
 
 === Related Services
 
@@ -54,9 +51,3 @@ Otherwise the property will be hidden.
 * `Persistable_datanucleusVersionLong` will expose the entity's version, assuming that the version is or can be cast to `java.lang.Long`.
 Otherwise the property will be hidden.
 
-=== Appearance in the UI
-
-These mixin properties are all associated with the "Metadata" fieldset.
-The xref:../rgcms/rgcms.adoc#_rgcms_classes_mixins_Object[Object mixin] also contribute an action to the "Metadata" fieldset.
-
-
diff --git a/core/applib/src/main/java/org/apache/isis/applib/services/layout/Object_openRestApi.java b/core/applib/src/main/java/org/apache/isis/applib/services/layout/Object_openRestApi.java
new file mode 100644
index 0000000..e4e203b
--- /dev/null
+++ b/core/applib/src/main/java/org/apache/isis/applib/services/layout/Object_openRestApi.java
@@ -0,0 +1,64 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.isis.applib.services.layout;
+
+import java.net.MalformedURLException;
+
+import org.apache.isis.applib.annotation.Action;
+import org.apache.isis.applib.annotation.ActionLayout;
+import org.apache.isis.applib.annotation.Contributed;
+import org.apache.isis.applib.annotation.MemberOrder;
+import org.apache.isis.applib.annotation.Mixin;
+import org.apache.isis.applib.annotation.RestrictTo;
+import org.apache.isis.applib.annotation.SemanticsOf;
+import org.apache.isis.applib.services.bookmark.Bookmark;
+import org.apache.isis.applib.services.bookmark.BookmarkService2;
+
+@Mixin(method="act")
+public class Object_openRestApi {
+
+    private final Object object;
+
+    public Object_openRestApi(final Object object) {
+        this.object = object;
+    }
+
+    public static class ActionDomainEvent extends org.apache.isis.applib.IsisApplibModule.ActionDomainEvent<Object_openRestApi> {}
+
+    @Action(
+            domainEvent = ActionDomainEvent.class,
+            semantics = SemanticsOf.SAFE,
+            restrictTo = RestrictTo.PROTOTYPING
+    )
+    @ActionLayout(
+            contributed = Contributed.AS_ACTION,
+            cssClassFa = "fa-external-link",
+            position = ActionLayout.Position.PANEL_DROPDOWN
+    )
+    @MemberOrder(name = "datanucleusIdLong", sequence = "750.1")
+    public java.net.URL act() throws MalformedURLException {
+        Bookmark bookmark = bookmarkService2.bookmarkFor(object);
+        return new java.net.URL(String.format(
+                "http:///restful/objects/%s/%s",
+                bookmark.getObjectType(),
+                bookmark.getIdentifier()));
+    }
+
+    @javax.inject.Inject
+    BookmarkService2 bookmarkService2;
+
+}

-- 
To stop receiving notification emails like this one, please contact
['"commits@isis.apache.org" <co...@isis.apache.org>'].