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 2015/11/25 23:11:07 UTC

isis git commit: ISIS-1262: implementation and documentation for Persistable_downloadJdoMetadata mixin.

Repository: isis
Updated Branches:
  refs/heads/master 8cf480de9 -> 302da22ce


ISIS-1262: implementation and documentation for Persistable_downloadJdoMetadata mixin.

also tiny tweaks to the home page.


Project: http://git-wip-us.apache.org/repos/asf/isis/repo
Commit: http://git-wip-us.apache.org/repos/asf/isis/commit/302da22c
Tree: http://git-wip-us.apache.org/repos/asf/isis/tree/302da22c
Diff: http://git-wip-us.apache.org/repos/asf/isis/diff/302da22c

Branch: refs/heads/master
Commit: 302da22ce3f5e549cda6c137c387cafd637ace55
Parents: 8cf480d
Author: Dan Haywood <da...@haywood-associates.co.uk>
Authored: Wed Nov 25 22:10:21 2015 +0000
Committer: Dan Haywood <da...@haywood-associates.co.uk>
Committed: Wed Nov 25 22:10:21 2015 +0000

----------------------------------------------------------------------
 .../src/main/asciidoc/documentation.adoc        | 10 ++-
 .../main/asciidoc/guides/_rg_classes_roles.adoc |  2 +
 .../_rg_classes_roles_manpage-Persistable.adoc  | 34 ++++++++
 .../Persistable_downloadJdoMetadata.java        | 81 ++++++++++++++++++++
 .../metamodel/services/jdosupport/Util.java     | 33 ++++++++
 .../specimpl/ObjectActionMixedIn.java           |  3 +-
 6 files changed, 159 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/isis/blob/302da22c/adocs/documentation/src/main/asciidoc/documentation.adoc
----------------------------------------------------------------------
diff --git a/adocs/documentation/src/main/asciidoc/documentation.adoc b/adocs/documentation/src/main/asciidoc/documentation.adoc
index ebcbc6e..88b25e5 100644
--- a/adocs/documentation/src/main/asciidoc/documentation.adoc
+++ b/adocs/documentation/src/main/asciidoc/documentation.adoc
@@ -45,10 +45,10 @@ pass:[<br/>]
 * *link:./cheat-sheet.html[Cheat Sheet]*
 * link:./icons.html[Icons]
 
-*Isis Add-ons*
+*3rd-party add-ons (not ASF)*
 
-* http://isisaddons.org[Isis addons] (not ASF)
-* link:https://github.com/isisaddons/isis-app-simpledsl/[isis-script DSL] (not ASF)
+* http://isisaddons.org[Isis addons]
+* http://catalog.incode.org[Incode Catalog]
 
 
 |===
@@ -118,6 +118,9 @@ including:
 * http://github.com/isisaddons/isis-app-kitchensink[Kitchensink] (link:http://mmyco.co.uk:8180/kitchensink/[online demo, v1.10.0])
 * http://github.com/isisaddons/isis-app-neoapp[Neo4J Example]
 * http://github.com/isisaddons/isis-app-quickstart[Quickstart]
+
+tools (not ASF):
+
 * http://github.com/isisaddons/isis-app-simpledsl[Isis DSL Example]
 
 
@@ -131,6 +134,7 @@ including:
 * link:./articles-and-presentations.html[Articles, Conferences, Podcasts]
 * link:./books.html[Books]
 * link:./resources/thesis/Pawson-Naked-Objects-thesis.pdf[Naked Objects PhD thesis] (Pawson)
+* link:https://github.com/isisaddons/isis-app-simpledsl/[isis-script DSL]
 //* link:./downloadable-presentations.html[Downloadable Presentations]
 
 

http://git-wip-us.apache.org/repos/asf/isis/blob/302da22c/adocs/documentation/src/main/asciidoc/guides/_rg_classes_roles.adoc
----------------------------------------------------------------------
diff --git a/adocs/documentation/src/main/asciidoc/guides/_rg_classes_roles.adoc b/adocs/documentation/src/main/asciidoc/guides/_rg_classes_roles.adoc
index 138c3d2..4f7cde8 100644
--- a/adocs/documentation/src/main/asciidoc/guides/_rg_classes_roles.adoc
+++ b/adocs/documentation/src/main/asciidoc/guides/_rg_classes_roles.adoc
@@ -13,4 +13,6 @@ include::_rg_classes_roles_manpage-HoldsUpdatedAt.adoc[leveloffset=+1]
 include::_rg_classes_roles_manpage-HoldsUpdatedBy.adoc[leveloffset=+1]
 include::_rg_classes_roles_manpage-Timestampable.adoc[leveloffset=+1]
 include::_rg_classes_roles_manpage-Dto.adoc[leveloffset=+1]
+include::_rg_classes_roles_manpage-Persistable.adoc[leveloffset=+1]
+
 

http://git-wip-us.apache.org/repos/asf/isis/blob/302da22c/adocs/documentation/src/main/asciidoc/guides/_rg_classes_roles_manpage-Persistable.adoc
----------------------------------------------------------------------
diff --git a/adocs/documentation/src/main/asciidoc/guides/_rg_classes_roles_manpage-Persistable.adoc b/adocs/documentation/src/main/asciidoc/guides/_rg_classes_roles_manpage-Persistable.adoc
new file mode 100644
index 0000000..024512d
--- /dev/null
+++ b/adocs/documentation/src/main/asciidoc/guides/_rg_classes_roles_manpage-Persistable.adoc
@@ -0,0 +1,34 @@
+[[_rg_classes_mixins_Persistable]]
+= `Persistable` (`1.11.0-SNAPSHOT`)
+:Notice: 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.
+:_basedir: ../
+:_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`).  So as a developer you do not
+need to write any code for this role interface.
+
+Nevertheless, the `Persistable_downloadJdoMetadata` mixin (`1.11.0-SNAPSHOT`) provides the ability to download the
+JDO link:http://www.datanucleus.org/products/datanucleus/jdo/metadata_xml.html[class metadata in XML] form.  The mixin
+defines the following action:
+
+[source,java]
+----
+@Mixin
+public class Persistable_downloadJdoMetadata {
+    public Persistable_downloadJdoMetadata(final Persistable persistable) { ... }   // <1>
+    public Object downloadJdoMetadata(final String fileName) { ... }                // <2>
+    ...
+}
+----
+<1> provided as an action to any domain entity
+<2> actually this is '$$' in the code, a "special case" that means to use the derive the action name from the class name.
+
+This will return the XML text wrapped up in a xref:rg.adoc#_rg_classes_value-types_manpage-Clob[`Clob`].
+
+
+== Related Services
+
+The mixin delegates to the xref:rg.adoc#_rg_services-api_manpage-IsisJdoSupport[`IsisJdoSupport`] service to obtain
+a reference to the JDO `PersistenceManagerFactory`.

http://git-wip-us.apache.org/repos/asf/isis/blob/302da22c/core/metamodel/src/main/java/org/apache/isis/core/metamodel/services/jdosupport/Persistable_downloadJdoMetadata.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/services/jdosupport/Persistable_downloadJdoMetadata.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/services/jdosupport/Persistable_downloadJdoMetadata.java
new file mode 100644
index 0000000..1fdb08e
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/services/jdosupport/Persistable_downloadJdoMetadata.java
@@ -0,0 +1,81 @@
+/**
+ *  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.core.metamodel.services.jdosupport;
+
+import java.io.IOException;
+
+import javax.inject.Inject;
+import javax.jdo.PersistenceManagerFactory;
+import javax.jdo.metadata.TypeMetadata;
+import javax.xml.bind.JAXBException;
+
+import org.datanucleus.enhancement.Persistable;
+
+import org.apache.isis.applib.annotation.Action;
+import org.apache.isis.applib.annotation.ActionLayout;
+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.dto.Dto;
+import org.apache.isis.applib.services.jdosupport.IsisJdoSupport;
+import org.apache.isis.applib.value.Clob;
+
+@Mixin
+public class Persistable_downloadJdoMetadata {
+
+    private final Persistable persistable;
+
+    public Persistable_downloadJdoMetadata(final Persistable persistable) {
+        this.persistable = persistable;
+    }
+
+    public static class ActionDomainEvent extends org.apache.isis.applib.IsisApplibModule.ActionDomainEvent<Dto> {}
+
+    @Action(
+            domainEvent = ActionDomainEvent.class,
+            semantics = SemanticsOf.SAFE,
+            restrictTo = RestrictTo.PROTOTYPING
+    )
+    @ActionLayout(
+            cssClassFa = "fa-download"
+    )
+    @MemberOrder(sequence = "800.1")
+    public Object $$(final String fileName) throws JAXBException, IOException {
+
+        final Class<? extends Persistable> objClass = persistable.getClass();
+        final String objClassName = objClass.getName();
+
+        final TypeMetadata metadata = getPersistenceManagerFactory().getMetadata(objClassName);
+        final String xml = metadata.toString();
+
+        return new Clob(Util.withSuffix(fileName, "jdo"), "text/xml", xml);
+    }
+
+
+    public String default0$$() {
+        return Util.withSuffix(persistable.getClass().getName(), "jdo");
+    }
+
+    PersistenceManagerFactory getPersistenceManagerFactory() {
+        return jdoSupport.getJdoPersistenceManager().getPersistenceManagerFactory();
+    }
+
+    @Inject
+    IsisJdoSupport jdoSupport;
+
+}

http://git-wip-us.apache.org/repos/asf/isis/blob/302da22c/core/metamodel/src/main/java/org/apache/isis/core/metamodel/services/jdosupport/Util.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/services/jdosupport/Util.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/services/jdosupport/Util.java
new file mode 100644
index 0000000..9b92275
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/services/jdosupport/Util.java
@@ -0,0 +1,33 @@
+/**
+ *  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.core.metamodel.services.jdosupport;
+
+class Util {
+
+    private Util(){}
+
+    static String withSuffix(String fileName, String suffix) {
+        if(!suffix.startsWith(".")) {
+            suffix = "." + suffix;
+        }
+        if(!fileName.endsWith(suffix)) {
+            fileName += suffix;
+        }
+        return fileName;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/isis/blob/302da22c/core/metamodel/src/main/java/org/apache/isis/core/metamodel/specloader/specimpl/ObjectActionMixedIn.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/specloader/specimpl/ObjectActionMixedIn.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/specloader/specimpl/ObjectActionMixedIn.java
index 758ff12..37906df 100644
--- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/specloader/specimpl/ObjectActionMixedIn.java
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/specloader/specimpl/ObjectActionMixedIn.java
@@ -20,6 +20,7 @@ import java.util.Collections;
 import java.util.List;
 
 import com.google.common.base.Objects;
+import com.google.common.base.Strings;
 import com.google.common.collect.Lists;
 
 import org.apache.isis.applib.Identifier;
@@ -94,7 +95,7 @@ public class ObjectActionMixedIn extends ObjectActionDefault implements MixedInM
         // adjust name if necessary
         final String name = getName();
 
-        if(Objects.equal(name, DEFAULT_MEMBER_NAME)) {
+        if(Strings.isNullOrEmpty(name) || Objects.equal(name, DEFAULT_MEMBER_NAME)) {
             String memberName = determineNameFrom(mixinAction);
             FacetUtil.addFacet(new NamedFacetInferred(memberName, facetHolder));
         }