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 2012/12/06 17:59:48 UTC
[39/52] [partial] ISIS-188: more reorganizing of artifacts into
physical directories.
http://git-wip-us.apache.org/repos/asf/isis/blob/0861ed93/framework/component/objectstore/jdo/jdo-metamodel/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/metamodel/facets/object/query/JdoQueryAnnotationFacetFactory.java
----------------------------------------------------------------------
diff --git a/framework/component/objectstore/jdo/jdo-metamodel/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/metamodel/facets/object/query/JdoQueryAnnotationFacetFactory.java b/framework/component/objectstore/jdo/jdo-metamodel/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/metamodel/facets/object/query/JdoQueryAnnotationFacetFactory.java
new file mode 100644
index 0000000..a699684
--- /dev/null
+++ b/framework/component/objectstore/jdo/jdo-metamodel/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/metamodel/facets/object/query/JdoQueryAnnotationFacetFactory.java
@@ -0,0 +1,55 @@
+/*
+ * 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.runtimes.dflt.objectstores.jdo.metamodel.facets.object.query;
+
+import javax.jdo.annotations.Queries;
+import javax.jdo.annotations.Query;
+
+import org.apache.isis.core.metamodel.facetapi.FacetHolder;
+import org.apache.isis.core.metamodel.facetapi.FacetUtil;
+import org.apache.isis.core.metamodel.facetapi.FeatureType;
+import org.apache.isis.core.metamodel.facets.Annotations;
+import org.apache.isis.core.metamodel.facets.FacetFactoryAbstract;
+
+
+public class JdoQueryAnnotationFacetFactory extends FacetFactoryAbstract {
+
+ public JdoQueryAnnotationFacetFactory() {
+ super(FeatureType.OBJECTS_ONLY);
+ }
+
+ @Override
+ public void process(ProcessClassContext processClassContext) {
+ final Class<?> cls = processClassContext.getCls();
+ final Queries namedQueriesAnnotation = Annotations.getAnnotation(cls, Queries.class);
+ final FacetHolder facetHolder = processClassContext.getFacetHolder();
+
+ if (namedQueriesAnnotation != null) {
+ FacetUtil.addFacet(new JdoQueriesFacetAnnotation(
+ namedQueriesAnnotation.value(), facetHolder));
+ return;
+ }
+
+ final Query namedQueryAnnotation = Annotations.getAnnotation(cls, Query.class);
+ if (namedQueryAnnotation != null) {
+ FacetUtil.addFacet(new JdoQueryFacetAnnotation(
+ namedQueryAnnotation, facetHolder));
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/0861ed93/framework/component/objectstore/jdo/jdo-metamodel/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/metamodel/facets/object/query/JdoQueryFacet.java
----------------------------------------------------------------------
diff --git a/framework/component/objectstore/jdo/jdo-metamodel/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/metamodel/facets/object/query/JdoQueryFacet.java b/framework/component/objectstore/jdo/jdo-metamodel/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/metamodel/facets/object/query/JdoQueryFacet.java
new file mode 100644
index 0000000..dc4a455
--- /dev/null
+++ b/framework/component/objectstore/jdo/jdo-metamodel/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/metamodel/facets/object/query/JdoQueryFacet.java
@@ -0,0 +1,59 @@
+/*
+ * 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.runtimes.dflt.objectstores.jdo.metamodel.facets.object.query;
+
+import java.util.List;
+
+import javax.jdo.annotations.Query;
+
+import org.apache.isis.core.metamodel.facetapi.Facet;
+
+
+/**
+ * In the standard JDO Model, corresponds to annotating the class with either
+ * {@link javax.jdo.annotations.Query} or
+ * {@link javax.jdo.annotations.Queries}.
+ * <p>
+ * For a {@link javax.jdo.annotations.Query}, returns a singleton list of
+ * {@link JdoNamedQuery}.
+ * For a {@link javax.jdo.annotations.Queries}, returns a list of
+ * {@link JdoNamedQuery}s.
+ * <p>
+ * In both cases, mapping is as follows
+ * <ul>
+ * <li>{@link javax.jdo.annotations.Query#name()} ->
+ * {@link JdoNamedQuery#getName()
+ * getName()} property of JDO Object Store's own
+ * {@link JdoNamedQuery} value object</li>
+ * <li>{@link javax.jdo.annotations.Query#value()} ->
+ * {@link JdoNamedQuery#getQuery()}
+ * property of JDO Object Store's own
+ * {@link JdoNamedQuery} value object</li>
+ * </ul>
+ *
+ * <p>
+ * Optional attributes of the {@link Query} annotation are not currently mapped.
+ */
+public interface JdoQueryFacet extends Facet {
+
+ /**
+ * Returns an immutable {@link List}.
+ */
+ List<JdoNamedQuery> getNamedQueries();
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/0861ed93/framework/component/objectstore/jdo/jdo-metamodel/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/metamodel/facets/object/query/JdoQueryFacetAbstract.java
----------------------------------------------------------------------
diff --git a/framework/component/objectstore/jdo/jdo-metamodel/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/metamodel/facets/object/query/JdoQueryFacetAbstract.java b/framework/component/objectstore/jdo/jdo-metamodel/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/metamodel/facets/object/query/JdoQueryFacetAbstract.java
new file mode 100644
index 0000000..a33ead1
--- /dev/null
+++ b/framework/component/objectstore/jdo/jdo-metamodel/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/metamodel/facets/object/query/JdoQueryFacetAbstract.java
@@ -0,0 +1,57 @@
+/*
+ * 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.runtimes.dflt.objectstores.jdo.metamodel.facets.object.query;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import javax.jdo.annotations.Query;
+
+import org.apache.isis.core.metamodel.facetapi.Facet;
+import org.apache.isis.core.metamodel.facetapi.FacetAbstract;
+import org.apache.isis.core.metamodel.facetapi.FacetHolder;
+import org.apache.isis.core.metamodel.spec.ObjectSpecification;
+
+
+public class JdoQueryFacetAbstract extends FacetAbstract implements
+ JdoQueryFacet {
+
+ public static Class<? extends Facet> type() {
+ return JdoQueryFacet.class;
+ }
+
+ private final List<JdoNamedQuery> namedQueries = new ArrayList<JdoNamedQuery>();
+
+ public JdoQueryFacetAbstract(final FacetHolder holder) {
+ super(JdoQueryFacetAbstract.type(), holder, Derivation.NOT_DERIVED);
+ }
+
+ protected void add(final Query... jdoNamedQueries) {
+ final ObjectSpecification objSpec = (ObjectSpecification) getFacetHolder();
+ for (final Query jdoNamedQuery : jdoNamedQueries) {
+ namedQueries.add(new JdoNamedQuery(jdoNamedQuery, objSpec));
+ }
+ }
+
+ public List<JdoNamedQuery> getNamedQueries() {
+ return Collections.unmodifiableList(namedQueries);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/0861ed93/framework/component/objectstore/jdo/jdo-metamodel/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/metamodel/facets/object/query/JdoQueryFacetAnnotation.java
----------------------------------------------------------------------
diff --git a/framework/component/objectstore/jdo/jdo-metamodel/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/metamodel/facets/object/query/JdoQueryFacetAnnotation.java b/framework/component/objectstore/jdo/jdo-metamodel/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/metamodel/facets/object/query/JdoQueryFacetAnnotation.java
new file mode 100644
index 0000000..518d97e
--- /dev/null
+++ b/framework/component/objectstore/jdo/jdo-metamodel/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/metamodel/facets/object/query/JdoQueryFacetAnnotation.java
@@ -0,0 +1,36 @@
+/*
+ * 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.runtimes.dflt.objectstores.jdo.metamodel.facets.object.query;
+
+import javax.jdo.annotations.Query;
+
+import org.apache.isis.core.metamodel.facetapi.FacetHolder;
+
+
+public class JdoQueryFacetAnnotation extends JdoQueryFacetAbstract
+ implements JdoQueryFacet {
+
+ public JdoQueryFacetAnnotation(final Query jdoNamedQuery,
+ final FacetHolder holder) {
+ super(holder);
+ add(jdoNamedQuery);
+ }
+
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/0861ed93/framework/component/objectstore/jdo/jdo-metamodel/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/metamodel/facets/prop/primarykey/DisabledFacetDerivedFromJdoPrimaryKeyAnnotation.java
----------------------------------------------------------------------
diff --git a/framework/component/objectstore/jdo/jdo-metamodel/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/metamodel/facets/prop/primarykey/DisabledFacetDerivedFromJdoPrimaryKeyAnnotation.java b/framework/component/objectstore/jdo/jdo-metamodel/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/metamodel/facets/prop/primarykey/DisabledFacetDerivedFromJdoPrimaryKeyAnnotation.java
new file mode 100644
index 0000000..45e1f31
--- /dev/null
+++ b/framework/component/objectstore/jdo/jdo-metamodel/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/metamodel/facets/prop/primarykey/DisabledFacetDerivedFromJdoPrimaryKeyAnnotation.java
@@ -0,0 +1,36 @@
+/*
+ * 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.runtimes.dflt.objectstores.jdo.metamodel.facets.prop.primarykey;
+
+import org.apache.isis.applib.annotation.When;
+import org.apache.isis.applib.annotation.Where;
+import org.apache.isis.core.metamodel.facetapi.FacetHolder;
+import org.apache.isis.core.progmodel.facets.members.disabled.DisabledFacetImpl;
+
+
+/**
+ * Derived from being {@link Transient}.
+ */
+public class DisabledFacetDerivedFromJdoPrimaryKeyAnnotation extends DisabledFacetImpl {
+
+ public DisabledFacetDerivedFromJdoPrimaryKeyAnnotation(final FacetHolder holder) {
+ super(When.ALWAYS, Where.ANYWHERE, holder);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/0861ed93/framework/component/objectstore/jdo/jdo-metamodel/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/metamodel/facets/prop/primarykey/JdoPrimaryKeyAnnotationFacetFactory.java
----------------------------------------------------------------------
diff --git a/framework/component/objectstore/jdo/jdo-metamodel/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/metamodel/facets/prop/primarykey/JdoPrimaryKeyAnnotationFacetFactory.java b/framework/component/objectstore/jdo/jdo-metamodel/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/metamodel/facets/prop/primarykey/JdoPrimaryKeyAnnotationFacetFactory.java
new file mode 100644
index 0000000..93687f0
--- /dev/null
+++ b/framework/component/objectstore/jdo/jdo-metamodel/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/metamodel/facets/prop/primarykey/JdoPrimaryKeyAnnotationFacetFactory.java
@@ -0,0 +1,48 @@
+/*
+ * 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.runtimes.dflt.objectstores.jdo.metamodel.facets.prop.primarykey;
+
+import javax.jdo.annotations.PrimaryKey;
+
+import org.apache.isis.core.metamodel.facetapi.FacetUtil;
+import org.apache.isis.core.metamodel.facetapi.FeatureType;
+import org.apache.isis.core.metamodel.facets.Annotations;
+import org.apache.isis.core.metamodel.facets.FacetFactoryAbstract;
+import org.apache.isis.core.metamodel.facets.FacetedMethod;
+
+
+public class JdoPrimaryKeyAnnotationFacetFactory extends FacetFactoryAbstract {
+
+ public JdoPrimaryKeyAnnotationFacetFactory() {
+ super(FeatureType.PROPERTIES_ONLY);
+ }
+
+ @Override
+ public void process(ProcessMethodContext processMethodContext) {
+ final PrimaryKey annotation = Annotations.getAnnotation(processMethodContext.getMethod(), PrimaryKey.class);
+ if (annotation == null) {
+ return;
+ }
+
+ final FacetedMethod holder = processMethodContext.getFacetHolder();
+ FacetUtil.addFacet(new JdoPrimaryKeyFacetAnnotation(holder));
+ FacetUtil.addFacet(new OptionalFacetDerivedFromJdoPrimaryKeyAnnotation(holder));
+ FacetUtil.addFacet(new DisabledFacetDerivedFromJdoPrimaryKeyAnnotation(holder));
+ }
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/0861ed93/framework/component/objectstore/jdo/jdo-metamodel/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/metamodel/facets/prop/primarykey/JdoPrimaryKeyFacet.java
----------------------------------------------------------------------
diff --git a/framework/component/objectstore/jdo/jdo-metamodel/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/metamodel/facets/prop/primarykey/JdoPrimaryKeyFacet.java b/framework/component/objectstore/jdo/jdo-metamodel/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/metamodel/facets/prop/primarykey/JdoPrimaryKeyFacet.java
new file mode 100644
index 0000000..d371e44
--- /dev/null
+++ b/framework/component/objectstore/jdo/jdo-metamodel/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/metamodel/facets/prop/primarykey/JdoPrimaryKeyFacet.java
@@ -0,0 +1,34 @@
+/*
+ * 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.runtimes.dflt.objectstores.jdo.metamodel.facets.prop.primarykey;
+
+import javax.jdo.annotations.PrimaryKey;
+
+import org.apache.isis.core.metamodel.facets.MarkerFacet;
+
+
+/**
+ * Corresponds to the property with the {@link PrimaryKey} annotation.
+ * <p>
+ * The JDO {@link PrimaryKey} annotation is used internally the JDO object store to
+ * create the {@link Oid}.
+ */
+public interface JdoPrimaryKeyFacet extends MarkerFacet {
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/0861ed93/framework/component/objectstore/jdo/jdo-metamodel/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/metamodel/facets/prop/primarykey/JdoPrimaryKeyFacetAbstract.java
----------------------------------------------------------------------
diff --git a/framework/component/objectstore/jdo/jdo-metamodel/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/metamodel/facets/prop/primarykey/JdoPrimaryKeyFacetAbstract.java b/framework/component/objectstore/jdo/jdo-metamodel/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/metamodel/facets/prop/primarykey/JdoPrimaryKeyFacetAbstract.java
new file mode 100644
index 0000000..bb81b37
--- /dev/null
+++ b/framework/component/objectstore/jdo/jdo-metamodel/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/metamodel/facets/prop/primarykey/JdoPrimaryKeyFacetAbstract.java
@@ -0,0 +1,36 @@
+/*
+ * 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.runtimes.dflt.objectstores.jdo.metamodel.facets.prop.primarykey;
+
+import org.apache.isis.core.metamodel.facetapi.Facet;
+import org.apache.isis.core.metamodel.facetapi.FacetHolder;
+import org.apache.isis.core.metamodel.facets.MarkerFacetAbstract;
+
+
+public abstract class JdoPrimaryKeyFacetAbstract extends MarkerFacetAbstract implements
+ JdoPrimaryKeyFacet {
+
+ public static Class<? extends Facet> type() {
+ return JdoPrimaryKeyFacet.class;
+ }
+
+ public JdoPrimaryKeyFacetAbstract(final FacetHolder holder) {
+ super(JdoPrimaryKeyFacetAbstract.type(), holder);
+ }
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/0861ed93/framework/component/objectstore/jdo/jdo-metamodel/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/metamodel/facets/prop/primarykey/JdoPrimaryKeyFacetAnnotation.java
----------------------------------------------------------------------
diff --git a/framework/component/objectstore/jdo/jdo-metamodel/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/metamodel/facets/prop/primarykey/JdoPrimaryKeyFacetAnnotation.java b/framework/component/objectstore/jdo/jdo-metamodel/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/metamodel/facets/prop/primarykey/JdoPrimaryKeyFacetAnnotation.java
new file mode 100644
index 0000000..d69272c
--- /dev/null
+++ b/framework/component/objectstore/jdo/jdo-metamodel/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/metamodel/facets/prop/primarykey/JdoPrimaryKeyFacetAnnotation.java
@@ -0,0 +1,30 @@
+/*
+ * 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.runtimes.dflt.objectstores.jdo.metamodel.facets.prop.primarykey;
+
+import org.apache.isis.core.metamodel.facetapi.FacetHolder;
+
+
+public class JdoPrimaryKeyFacetAnnotation extends JdoPrimaryKeyFacetImpl {
+
+ public JdoPrimaryKeyFacetAnnotation(final FacetHolder holder) {
+ super(holder);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/0861ed93/framework/component/objectstore/jdo/jdo-metamodel/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/metamodel/facets/prop/primarykey/JdoPrimaryKeyFacetImpl.java
----------------------------------------------------------------------
diff --git a/framework/component/objectstore/jdo/jdo-metamodel/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/metamodel/facets/prop/primarykey/JdoPrimaryKeyFacetImpl.java b/framework/component/objectstore/jdo/jdo-metamodel/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/metamodel/facets/prop/primarykey/JdoPrimaryKeyFacetImpl.java
new file mode 100644
index 0000000..60e16f6
--- /dev/null
+++ b/framework/component/objectstore/jdo/jdo-metamodel/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/metamodel/facets/prop/primarykey/JdoPrimaryKeyFacetImpl.java
@@ -0,0 +1,30 @@
+/*
+ * 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.runtimes.dflt.objectstores.jdo.metamodel.facets.prop.primarykey;
+
+import org.apache.isis.core.metamodel.facetapi.FacetHolder;
+
+
+public class JdoPrimaryKeyFacetImpl extends JdoPrimaryKeyFacetAbstract {
+
+ public JdoPrimaryKeyFacetImpl(final FacetHolder holder) {
+ super(holder);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/0861ed93/framework/component/objectstore/jdo/jdo-metamodel/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/metamodel/facets/prop/primarykey/OptionalFacetDerivedFromJdoPrimaryKeyAnnotation.java
----------------------------------------------------------------------
diff --git a/framework/component/objectstore/jdo/jdo-metamodel/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/metamodel/facets/prop/primarykey/OptionalFacetDerivedFromJdoPrimaryKeyAnnotation.java b/framework/component/objectstore/jdo/jdo-metamodel/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/metamodel/facets/prop/primarykey/OptionalFacetDerivedFromJdoPrimaryKeyAnnotation.java
new file mode 100644
index 0000000..df17b91
--- /dev/null
+++ b/framework/component/objectstore/jdo/jdo-metamodel/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/metamodel/facets/prop/primarykey/OptionalFacetDerivedFromJdoPrimaryKeyAnnotation.java
@@ -0,0 +1,50 @@
+/*
+ * 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.runtimes.dflt.objectstores.jdo.metamodel.facets.prop.primarykey;
+
+import javax.jdo.annotations.PrimaryKey;
+
+import org.apache.isis.core.metamodel.facetapi.FacetHolder;
+import org.apache.isis.core.metamodel.facets.mandatory.MandatoryFacetDefault;
+import org.apache.isis.core.metamodel.facets.properties.defaults.PropertyDefaultFacet;
+
+
+/**
+ * Derived by presence of {@link PrimaryKey}.
+ *
+ * <p>
+ * By default mandatory properties are initialized using the
+ * {@link PropertyDefaultFacet} facet. We don't want this, so this facet marks
+ * the property as optional, meaning that the {@link PrimaryKey} property is left
+ * untouched by Isis.
+ */
+public class OptionalFacetDerivedFromJdoPrimaryKeyAnnotation extends
+ MandatoryFacetDefault {
+
+ public OptionalFacetDerivedFromJdoPrimaryKeyAnnotation(final FacetHolder holder) {
+ super(holder);
+ }
+
+ @Override
+ public boolean isInvertedSemantics() {
+ return true;
+ }
+
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/0861ed93/framework/component/objectstore/jdo/jdo-metamodel/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/metamodel/facets/prop/primarykey/package-info.java
----------------------------------------------------------------------
diff --git a/framework/component/objectstore/jdo/jdo-metamodel/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/metamodel/facets/prop/primarykey/package-info.java b/framework/component/objectstore/jdo/jdo-metamodel/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/metamodel/facets/prop/primarykey/package-info.java
new file mode 100644
index 0000000..746c0a3
--- /dev/null
+++ b/framework/component/objectstore/jdo/jdo-metamodel/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/metamodel/facets/prop/primarykey/package-info.java
@@ -0,0 +1,22 @@
+/**
+ * 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.
+ */
+/**
+ *
+ *
+ * @version $Rev$ $Date$
+ */
+package org.apache.isis.runtimes.dflt.objectstores.jdo.metamodel.facets.prop.primarykey;
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/isis/blob/0861ed93/framework/component/objectstore/jdo/jdo-metamodel/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/metamodel/specloader/validator/JdoMetaModelValidator.java
----------------------------------------------------------------------
diff --git a/framework/component/objectstore/jdo/jdo-metamodel/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/metamodel/specloader/validator/JdoMetaModelValidator.java b/framework/component/objectstore/jdo/jdo-metamodel/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/metamodel/specloader/validator/JdoMetaModelValidator.java
new file mode 100644
index 0000000..0468402
--- /dev/null
+++ b/framework/component/objectstore/jdo/jdo-metamodel/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/metamodel/specloader/validator/JdoMetaModelValidator.java
@@ -0,0 +1,85 @@
+/*
+ * 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.runtimes.dflt.objectstores.jdo.metamodel.specloader.validator;
+
+import javax.jdo.annotations.IdentityType;
+
+import org.apache.isis.core.metamodel.spec.ObjectSpecification;
+import org.apache.isis.core.metamodel.specloader.validator.MetaModelValidatorComposite;
+import org.apache.isis.core.metamodel.specloader.validator.MetaModelValidatorVisiting;
+import org.apache.isis.core.metamodel.specloader.validator.ValidationFailures;
+import org.apache.isis.runtimes.dflt.objectstores.jdo.metamodel.facets.object.persistencecapable.JdoPersistenceCapableFacet;
+
+public class JdoMetaModelValidator extends MetaModelValidatorComposite {
+
+ public JdoMetaModelValidator() {
+ addValidatorToEnsurePersistenceCapables();
+
+ addValidatorToEnsureIdentityType();
+ }
+
+ private void addValidatorToEnsurePersistenceCapables() {
+ final MetaModelValidatorVisiting.SummarizingVisitor ensurePersistenceCapables = new MetaModelValidatorVisiting.SummarizingVisitor(){
+
+ private boolean found = false;
+ @Override
+ public boolean visit(ObjectSpecification objectSpec, ValidationFailures validationFailures) {
+ boolean containsFacet = objectSpec.containsFacet(JdoPersistenceCapableFacet.class);
+ if(containsFacet) {
+ found = true;
+ return false; // no need to keep searching
+ }
+ return true; // keep searching
+ }
+
+ @Override
+ public void summarize(ValidationFailures validationFailures) {
+ if(!found) {
+ validationFailures.add("DataNucleus object store: no @PersistenceCapable found. " +
+ "(Are the entities referenced by the registered services? " +
+ "are all services registered? " +
+ "are you using the JDO programming model facets?)");
+ }
+ }
+ };
+ add(new MetaModelValidatorVisiting(ensurePersistenceCapables));
+ }
+
+ private void addValidatorToEnsureIdentityType() {
+ MetaModelValidatorVisiting.Visitor ensureIdentityType = new MetaModelValidatorVisiting.Visitor(){
+ @Override
+ public boolean visit(ObjectSpecification objSpec, ValidationFailures validationFailures) {
+ final JdoPersistenceCapableFacet jpcf = objSpec.getFacet(JdoPersistenceCapableFacet.class);
+ if(jpcf == null) {
+ return true;
+ }
+ final IdentityType identityType = jpcf.getIdentityType();
+ if(identityType != IdentityType.DATASTORE && identityType != IdentityType.UNSPECIFIED) {
+ validationFailures.add("DataNucleus object store: %s must be annotated with @PersistenceCapable, with an identityType of either DATASTORE or UNSPECIFIED (has an identityType of %s)", objSpec.getFullIdentifier(), identityType);
+ }
+
+ return true;
+ // TODO: ensure that DATASTORE has recognised @DatastoreIdentity attribute
+ }};
+
+ add(new MetaModelValidatorVisiting(ensureIdentityType));
+ }
+
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/0861ed93/framework/component/objectstore/jdo/jdo-metamodel/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/metamodel/util/JdoPrimaryKeyPropertyFilter.java
----------------------------------------------------------------------
diff --git a/framework/component/objectstore/jdo/jdo-metamodel/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/metamodel/util/JdoPrimaryKeyPropertyFilter.java b/framework/component/objectstore/jdo/jdo-metamodel/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/metamodel/util/JdoPrimaryKeyPropertyFilter.java
new file mode 100644
index 0000000..bef761f
--- /dev/null
+++ b/framework/component/objectstore/jdo/jdo-metamodel/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/metamodel/util/JdoPrimaryKeyPropertyFilter.java
@@ -0,0 +1,47 @@
+/*
+ * 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.runtimes.dflt.objectstores.jdo.metamodel.util;
+
+
+import javax.jdo.annotations.PrimaryKey;
+
+import org.apache.isis.applib.filter.Filter;
+import org.apache.isis.core.metamodel.facets.accessor.PropertyOrCollectionAccessorFacet;
+import org.apache.isis.core.metamodel.facets.properties.modify.PropertySetterFacet;
+import org.apache.isis.core.metamodel.spec.feature.ObjectAssociation;
+import org.apache.isis.core.metamodel.spec.feature.OneToOneAssociation;
+import org.apache.isis.runtimes.dflt.objectstores.jdo.metamodel.facets.prop.primarykey.JdoPrimaryKeyFacet;
+
+/**
+ * Use to locate the property annotated with {@link PrimaryKey}.
+ * <p>
+ * In addition, must also be a {@link OneToOneAssociation}, and can be
+ * {@link PropertyAccessorFacet read}.
+ * <p>
+ * Note that it is NOT necessary for there to be a facet to
+ * {@link PropertySetterFacet set} the property.
+ */
+public final class JdoPrimaryKeyPropertyFilter implements Filter<ObjectAssociation> {
+ @Override
+ public boolean accept(final ObjectAssociation noa) {
+ return noa.isOneToOneAssociation() &&
+ noa.containsFacet(JdoPrimaryKeyFacet.class) &&
+ noa.containsFacet(PropertyOrCollectionAccessorFacet.class);
+ }
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/0861ed93/framework/component/objectstore/jdo/jdo-metamodel/src/site/apt/index.apt
----------------------------------------------------------------------
diff --git a/framework/component/objectstore/jdo/jdo-metamodel/src/site/apt/index.apt b/framework/component/objectstore/jdo/jdo-metamodel/src/site/apt/index.apt
new file mode 100644
index 0000000..2438dcf
--- /dev/null
+++ b/framework/component/objectstore/jdo/jdo-metamodel/src/site/apt/index.apt
@@ -0,0 +1,22 @@
+~~ 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.
+
+
+
+MetaModel
+
+ The <metamodel> module ...
http://git-wip-us.apache.org/repos/asf/isis/blob/0861ed93/framework/component/objectstore/jdo/jdo-metamodel/src/site/apt/jottings.apt
----------------------------------------------------------------------
diff --git a/framework/component/objectstore/jdo/jdo-metamodel/src/site/apt/jottings.apt b/framework/component/objectstore/jdo/jdo-metamodel/src/site/apt/jottings.apt
new file mode 100644
index 0000000..c5d1200
--- /dev/null
+++ b/framework/component/objectstore/jdo/jdo-metamodel/src/site/apt/jottings.apt
@@ -0,0 +1,24 @@
+~~ 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.
+
+
+
+Jottings
+
+ This page is to capture any random jottings relating to this module prior
+ to being moved into formal documentation.
+
http://git-wip-us.apache.org/repos/asf/isis/blob/0861ed93/framework/component/objectstore/jdo/jdo-metamodel/src/site/site.xml
----------------------------------------------------------------------
diff --git a/framework/component/objectstore/jdo/jdo-metamodel/src/site/site.xml b/framework/component/objectstore/jdo/jdo-metamodel/src/site/site.xml
new file mode 100644
index 0000000..50018d0
--- /dev/null
+++ b/framework/component/objectstore/jdo/jdo-metamodel/src/site/site.xml
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+-->
+<project name="${project.name}">
+ <body>
+ <breadcrumbs>
+ <item name="Metamodel" href="index.html"/>
+ </breadcrumbs>
+
+ <menu name="JDO Metamodel">
+ <item name="About" href="index.html" />
+ <item name="Jottings" href="jottings.html" />
+ </menu>
+
+ <menu name="JDO Modules">
+ <item name="Applib" href="../jdo-applib/index.html" />
+ <item name="Metamodel" href="../jdo-metamodel/index.html" />
+ <item name="DataNucleus" href="../jdo-datanucleus/index.html" />
+ </menu>
+
+ <menu name="Maven Reports" ref="reports" />
+ </body>
+</project>
http://git-wip-us.apache.org/repos/asf/isis/blob/0861ed93/framework/component/objectstore/jdo/jdo-metamodel/src/test/java/org/apache/isis/runtimes/dflt/objectstores/jdo/metamodel/facets/object/auditable/GivenAuditableAnnotationFacetFactoryTest.java
----------------------------------------------------------------------
diff --git a/framework/component/objectstore/jdo/jdo-metamodel/src/test/java/org/apache/isis/runtimes/dflt/objectstores/jdo/metamodel/facets/object/auditable/GivenAuditableAnnotationFacetFactoryTest.java b/framework/component/objectstore/jdo/jdo-metamodel/src/test/java/org/apache/isis/runtimes/dflt/objectstores/jdo/metamodel/facets/object/auditable/GivenAuditableAnnotationFacetFactoryTest.java
new file mode 100644
index 0000000..d3767e6
--- /dev/null
+++ b/framework/component/objectstore/jdo/jdo-metamodel/src/test/java/org/apache/isis/runtimes/dflt/objectstores/jdo/metamodel/facets/object/auditable/GivenAuditableAnnotationFacetFactoryTest.java
@@ -0,0 +1,101 @@
+/*
+ * 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.runtimes.dflt.objectstores.jdo.metamodel.facets.object.auditable;
+
+import java.util.List;
+
+import javax.jdo.annotations.DatastoreIdentity;
+import javax.jdo.annotations.IdGeneratorStrategy;
+import javax.jdo.annotations.PersistenceCapable;
+
+import junit.framework.Assert;
+
+import org.apache.isis.core.metamodel.facetapi.Facet;
+import org.apache.isis.core.metamodel.facetapi.FeatureType;
+import org.apache.isis.core.metamodel.facets.FacetFactory;
+import org.apache.isis.core.progmodel.facets.AbstractFacetFactoryTest;
+import org.apache.isis.runtimes.dflt.objectstores.jdo.applib.annotations.Auditable;
+import org.apache.isis.runtimes.dflt.objectstores.jdo.metamodel.facets.object.persistencecapable.JdoPersistenceCapableAnnotationFacetFactory;
+import org.apache.isis.runtimes.dflt.objectstores.jdo.metamodel.facets.object.persistencecapable.JdoPersistenceCapableFacet;
+import org.apache.isis.runtimes.dflt.objectstores.jdo.metamodel.facets.object.persistencecapable.JdoPersistenceCapableFacetAnnotation;
+
+
+public class GivenAuditableAnnotationFacetFactoryTest extends
+ AbstractFacetFactoryTest {
+
+ private AuditableAnnotationFacetFactory facetFactory;
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+
+ facetFactory = new AuditableAnnotationFacetFactory();
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ facetFactory = null;
+ super.tearDown();
+ }
+
+ public void testFeatureTypes() {
+ final List<FeatureType> featureTypes = facetFactory
+ .getFeatureTypes();
+ Assert.assertTrue(contains(featureTypes, FeatureType.OBJECT));
+ assertFalse(contains(featureTypes, FeatureType.PROPERTY));
+ assertFalse(contains(featureTypes, FeatureType.COLLECTION));
+ Assert.assertFalse(contains(featureTypes, FeatureType.ACTION));
+ assertFalse(contains(featureTypes,
+ FeatureType.ACTION_PARAMETER));
+ }
+
+ public void testAuditableAnnotationPickedUpOnClass() {
+ @Auditable
+ class Customer {
+ }
+
+ facetFactory.process(new FacetFactory.ProcessClassContext(Customer.class, methodRemover, facetHolder));
+
+ final Facet facet = facetHolder.getFacet(AuditableFacet.class);
+ assertNotNull(facet);
+ assertTrue(facet instanceof AuditableFacetAnnotation);
+ }
+
+ public void testIfNoAuditableAnnotationThenNoFacet() {
+
+ class Customer {
+ }
+
+ facetFactory.process(new FacetFactory.ProcessClassContext(Customer.class, methodRemover, facetHolder));
+
+ final Facet facet = facetHolder.getFacet(AuditableFacet.class);
+ assertNull(facet);
+ }
+
+
+ public void testNoMethodsRemoved() {
+ @PersistenceCapable
+ class Customer {
+ }
+
+ facetFactory.process(new FacetFactory.ProcessClassContext(Customer.class, methodRemover, facetHolder));
+
+ assertNoMethodsRemoved();
+ }
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/0861ed93/framework/component/objectstore/jdo/jdo-metamodel/src/test/java/org/apache/isis/runtimes/dflt/objectstores/jdo/metamodel/facets/object/auditable/GivenAuditableMarkerInterfaceFacetFactoryTest.java
----------------------------------------------------------------------
diff --git a/framework/component/objectstore/jdo/jdo-metamodel/src/test/java/org/apache/isis/runtimes/dflt/objectstores/jdo/metamodel/facets/object/auditable/GivenAuditableMarkerInterfaceFacetFactoryTest.java b/framework/component/objectstore/jdo/jdo-metamodel/src/test/java/org/apache/isis/runtimes/dflt/objectstores/jdo/metamodel/facets/object/auditable/GivenAuditableMarkerInterfaceFacetFactoryTest.java
new file mode 100644
index 0000000..13c4803
--- /dev/null
+++ b/framework/component/objectstore/jdo/jdo-metamodel/src/test/java/org/apache/isis/runtimes/dflt/objectstores/jdo/metamodel/facets/object/auditable/GivenAuditableMarkerInterfaceFacetFactoryTest.java
@@ -0,0 +1,95 @@
+/*
+ * 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.runtimes.dflt.objectstores.jdo.metamodel.facets.object.auditable;
+
+import java.util.List;
+
+import javax.jdo.annotations.PersistenceCapable;
+
+import junit.framework.Assert;
+
+import org.apache.isis.core.metamodel.facetapi.Facet;
+import org.apache.isis.core.metamodel.facetapi.FeatureType;
+import org.apache.isis.core.metamodel.facets.FacetFactory;
+import org.apache.isis.core.progmodel.facets.AbstractFacetFactoryTest;
+import org.apache.isis.runtimes.dflt.objectstores.jdo.applib.Auditable;
+
+
+public class GivenAuditableMarkerInterfaceFacetFactoryTest extends
+ AbstractFacetFactoryTest {
+
+ private AuditableMarkerInterfaceFacetFactory facetFactory;
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+
+ facetFactory = new AuditableMarkerInterfaceFacetFactory();
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ facetFactory = null;
+ super.tearDown();
+ }
+
+ public void testFeatureTypes() {
+ final List<FeatureType> featureTypes = facetFactory
+ .getFeatureTypes();
+ Assert.assertTrue(contains(featureTypes, FeatureType.OBJECT));
+ assertFalse(contains(featureTypes, FeatureType.PROPERTY));
+ assertFalse(contains(featureTypes, FeatureType.COLLECTION));
+ Assert.assertFalse(contains(featureTypes, FeatureType.ACTION));
+ assertFalse(contains(featureTypes,
+ FeatureType.ACTION_PARAMETER));
+ }
+
+ public void testAuditableMarkerInterfacePickedUpOnClass() {
+ class Customer implements Auditable {
+ }
+
+ facetFactory.process(new FacetFactory.ProcessClassContext(Customer.class, methodRemover, facetHolder));
+
+ final Facet facet = facetHolder.getFacet(AuditableFacet.class);
+ assertNotNull(facet);
+ assertTrue(facet instanceof AuditableFacetMarkerInterface);
+ }
+
+ public void testIfNoAuditableMarkerInterfaceThenNoFacet() {
+
+ class Customer {
+ }
+
+ facetFactory.process(new FacetFactory.ProcessClassContext(Customer.class, methodRemover, facetHolder));
+
+ final Facet facet = facetHolder.getFacet(AuditableFacet.class);
+ assertNull(facet);
+ }
+
+
+ public void testNoMethodsRemoved() {
+ @PersistenceCapable
+ class Customer {
+ }
+
+ facetFactory.process(new FacetFactory.ProcessClassContext(Customer.class, methodRemover, facetHolder));
+
+ assertNoMethodsRemoved();
+ }
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/0861ed93/framework/component/objectstore/jdo/jdo-metamodel/src/test/java/org/apache/isis/runtimes/dflt/objectstores/jdo/metamodel/facets/object/datastoreidentity/GivenJdoDatastoreIdentityAnnotationFacetFactoryTest.java
----------------------------------------------------------------------
diff --git a/framework/component/objectstore/jdo/jdo-metamodel/src/test/java/org/apache/isis/runtimes/dflt/objectstores/jdo/metamodel/facets/object/datastoreidentity/GivenJdoDatastoreIdentityAnnotationFacetFactoryTest.java b/framework/component/objectstore/jdo/jdo-metamodel/src/test/java/org/apache/isis/runtimes/dflt/objectstores/jdo/metamodel/facets/object/datastoreidentity/GivenJdoDatastoreIdentityAnnotationFacetFactoryTest.java
new file mode 100644
index 0000000..4e119ae
--- /dev/null
+++ b/framework/component/objectstore/jdo/jdo-metamodel/src/test/java/org/apache/isis/runtimes/dflt/objectstores/jdo/metamodel/facets/object/datastoreidentity/GivenJdoDatastoreIdentityAnnotationFacetFactoryTest.java
@@ -0,0 +1,122 @@
+/*
+ * 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.runtimes.dflt.objectstores.jdo.metamodel.facets.object.datastoreidentity;
+
+import java.util.List;
+
+import javax.jdo.annotations.DatastoreIdentity;
+import javax.jdo.annotations.IdGeneratorStrategy;
+import javax.jdo.annotations.PersistenceCapable;
+
+import junit.framework.Assert;
+
+import org.apache.isis.core.metamodel.facetapi.Facet;
+import org.apache.isis.core.metamodel.facetapi.FeatureType;
+import org.apache.isis.core.metamodel.facets.FacetFactory;
+import org.apache.isis.core.progmodel.facets.AbstractFacetFactoryTest;
+import org.apache.isis.runtimes.dflt.objectstores.jdo.metamodel.facets.object.persistencecapable.JdoPersistenceCapableAnnotationFacetFactory;
+import org.apache.isis.runtimes.dflt.objectstores.jdo.metamodel.facets.object.persistencecapable.JdoPersistenceCapableFacet;
+import org.apache.isis.runtimes.dflt.objectstores.jdo.metamodel.facets.object.persistencecapable.JdoPersistenceCapableFacetAnnotation;
+
+
+public class GivenJdoDatastoreIdentityAnnotationFacetFactoryTest extends
+ AbstractFacetFactoryTest {
+
+ private JdoDatastoreIdentityAnnotationFacetFactory facetFactory;
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+
+ facetFactory = new JdoDatastoreIdentityAnnotationFacetFactory();
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ facetFactory = null;
+ super.tearDown();
+ }
+
+ public void testFeatureTypes() {
+ final List<FeatureType> featureTypes = facetFactory
+ .getFeatureTypes();
+ Assert.assertTrue(contains(featureTypes, FeatureType.OBJECT));
+ assertFalse(contains(featureTypes, FeatureType.PROPERTY));
+ assertFalse(contains(featureTypes, FeatureType.COLLECTION));
+ Assert.assertFalse(contains(featureTypes, FeatureType.ACTION));
+ assertFalse(contains(featureTypes,
+ FeatureType.ACTION_PARAMETER));
+ }
+
+ public void testDatastoreIdentityAnnotationPickedUpOnClass() {
+ @DatastoreIdentity()
+ class Customer {
+ }
+
+ facetFactory.process(new FacetFactory.ProcessClassContext(Customer.class, methodRemover, facetHolder));
+
+ final Facet facet = facetHolder.getFacet(JdoDatastoreIdentityFacet.class);
+ assertNotNull(facet);
+ assertTrue(facet instanceof JdoDatastoreIdentityFacetAnnotation);
+ }
+
+ public void testIfNoDatastoreIdentityAnnotationThenNoFacet() {
+
+ class Customer {
+ }
+
+ facetFactory.process(new FacetFactory.ProcessClassContext(Customer.class, methodRemover, facetHolder));
+
+ final Facet facet = facetHolder.getFacet(JdoDatastoreIdentityFacet.class);
+ assertNull(facet);
+ }
+
+ public void testDatastoreIdentityAnnotationWithNoExplicitStrategyDefaultsToUnspecified() {
+ @DatastoreIdentity()
+ class Customer {
+ }
+ facetFactory.process(new FacetFactory.ProcessClassContext(Customer.class, methodRemover, facetHolder));
+
+ final JdoDatastoreIdentityFacet entityFacet = facetHolder
+ .getFacet(JdoDatastoreIdentityFacet.class);
+ assertEquals(IdGeneratorStrategy.UNSPECIFIED, entityFacet.getStrategy());
+ }
+
+ public void testEntityAnnotationWithExplicitStrategyAttributeProvided() {
+ @DatastoreIdentity(strategy=IdGeneratorStrategy.IDENTITY)
+ class Customer {
+ }
+
+ facetFactory.process(new FacetFactory.ProcessClassContext(Customer.class, methodRemover, facetHolder));
+
+ final JdoDatastoreIdentityFacet entityFacet = facetHolder
+ .getFacet(JdoDatastoreIdentityFacet.class);
+ assertEquals(IdGeneratorStrategy.IDENTITY, entityFacet.getStrategy());
+ }
+
+ public void testNoMethodsRemoved() {
+ @PersistenceCapable
+ class Customer {
+ }
+
+ facetFactory.process(new FacetFactory.ProcessClassContext(Customer.class, methodRemover, facetHolder));
+
+ assertNoMethodsRemoved();
+ }
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/0861ed93/framework/component/objectstore/jdo/jdo-metamodel/src/test/java/org/apache/isis/runtimes/dflt/objectstores/jdo/metamodel/facets/object/discriminator/GivenJdoDiscriminatorAnnotationFacetFactoryTest.java
----------------------------------------------------------------------
diff --git a/framework/component/objectstore/jdo/jdo-metamodel/src/test/java/org/apache/isis/runtimes/dflt/objectstores/jdo/metamodel/facets/object/discriminator/GivenJdoDiscriminatorAnnotationFacetFactoryTest.java b/framework/component/objectstore/jdo/jdo-metamodel/src/test/java/org/apache/isis/runtimes/dflt/objectstores/jdo/metamodel/facets/object/discriminator/GivenJdoDiscriminatorAnnotationFacetFactoryTest.java
new file mode 100644
index 0000000..c50fee0
--- /dev/null
+++ b/framework/component/objectstore/jdo/jdo-metamodel/src/test/java/org/apache/isis/runtimes/dflt/objectstores/jdo/metamodel/facets/object/discriminator/GivenJdoDiscriminatorAnnotationFacetFactoryTest.java
@@ -0,0 +1,104 @@
+/*
+ * 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.runtimes.dflt.objectstores.jdo.metamodel.facets.object.discriminator;
+
+import java.util.List;
+
+import javax.jdo.annotations.Discriminator;
+import javax.jdo.annotations.PersistenceCapable;
+
+import junit.framework.Assert;
+
+import org.apache.isis.core.metamodel.facetapi.Facet;
+import org.apache.isis.core.metamodel.facetapi.FeatureType;
+import org.apache.isis.core.metamodel.facets.FacetFactory;
+import org.apache.isis.core.metamodel.facets.object.objecttype.ObjectSpecIdFacet;
+import org.apache.isis.core.metamodel.spec.ObjectSpecId;
+import org.apache.isis.core.progmodel.facets.AbstractFacetFactoryTest;
+
+public class GivenJdoDiscriminatorAnnotationFacetFactoryTest extends AbstractFacetFactoryTest {
+
+ private JdoDiscriminatorAnnotationFacetFactory facetFactory;
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+
+ facetFactory = new JdoDiscriminatorAnnotationFacetFactory();
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ facetFactory = null;
+ super.tearDown();
+ }
+
+ public void testFeatureTypes() {
+ final List<FeatureType> featureTypes = facetFactory.getFeatureTypes();
+ Assert.assertTrue(contains(featureTypes, FeatureType.OBJECT));
+ assertFalse(contains(featureTypes, FeatureType.PROPERTY));
+ assertFalse(contains(featureTypes, FeatureType.COLLECTION));
+ Assert.assertFalse(contains(featureTypes, FeatureType.ACTION));
+ assertFalse(contains(featureTypes, FeatureType.ACTION_PARAMETER));
+ }
+
+ public void testDiscriminatorValueAnnotationPickedUpOnClass() {
+ @Discriminator("CUS")
+ class Customer {
+ }
+
+ facetFactory.process(new FacetFactory.ProcessClassContext(Customer.class, methodRemover, facetHolder));
+
+ final Facet facet = facetHolder.getFacet(ObjectSpecIdFacet.class);
+ assertNotNull(facet);
+ Assert.assertTrue(facet instanceof ObjectSpecIdFacetInferredFromJdoDiscriminatorValueAnnotation);
+ }
+
+ public void testIfNoEntityAnnotationThenNoFacet() {
+
+ class Customer {
+ }
+
+ facetFactory.process(new FacetFactory.ProcessClassContext(Customer.class, methodRemover, facetHolder));
+
+ final Facet facet = facetHolder.getFacet(ObjectSpecIdFacet.class);
+ assertNull(facet);
+ }
+
+ public void testAnnotationValue() {
+ @Discriminator("CUS")
+ class Customer {
+ }
+
+ facetFactory.process(new FacetFactory.ProcessClassContext(Customer.class, methodRemover, facetHolder));
+
+ final ObjectSpecIdFacet discriminatorValueFacet = facetHolder.getFacet(ObjectSpecIdFacet.class);
+ assertEquals(ObjectSpecId.of("CUS"), discriminatorValueFacet.value());
+ }
+
+ public void testNoMethodsRemoved() {
+ @PersistenceCapable
+ class Customer {
+ }
+
+ facetFactory.process(new FacetFactory.ProcessClassContext(Customer.class, methodRemover, facetHolder));
+
+ assertNoMethodsRemoved();
+ }
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/0861ed93/framework/component/objectstore/jdo/jdo-metamodel/src/test/java/org/apache/isis/runtimes/dflt/objectstores/jdo/metamodel/facets/object/embeddedonly/GivenJdoEmbeddedOnlyAnnotationFacetFactoryTest.java
----------------------------------------------------------------------
diff --git a/framework/component/objectstore/jdo/jdo-metamodel/src/test/java/org/apache/isis/runtimes/dflt/objectstores/jdo/metamodel/facets/object/embeddedonly/GivenJdoEmbeddedOnlyAnnotationFacetFactoryTest.java b/framework/component/objectstore/jdo/jdo-metamodel/src/test/java/org/apache/isis/runtimes/dflt/objectstores/jdo/metamodel/facets/object/embeddedonly/GivenJdoEmbeddedOnlyAnnotationFacetFactoryTest.java
new file mode 100644
index 0000000..414f422
--- /dev/null
+++ b/framework/component/objectstore/jdo/jdo-metamodel/src/test/java/org/apache/isis/runtimes/dflt/objectstores/jdo/metamodel/facets/object/embeddedonly/GivenJdoEmbeddedOnlyAnnotationFacetFactoryTest.java
@@ -0,0 +1,90 @@
+/*
+ * 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.runtimes.dflt.objectstores.jdo.metamodel.facets.object.embeddedonly;
+
+import java.util.List;
+
+import junit.framework.Assert;
+
+import org.apache.isis.core.metamodel.facetapi.Facet;
+import org.apache.isis.core.metamodel.facetapi.FeatureType;
+import org.apache.isis.core.metamodel.facets.FacetFactory;
+import org.apache.isis.core.metamodel.facets.object.aggregated.ParentedFacet;
+import org.apache.isis.core.progmodel.facets.AbstractFacetFactoryTest;
+
+
+public class GivenJdoEmbeddedOnlyAnnotationFacetFactoryTest extends
+ AbstractFacetFactoryTest {
+
+ private JdoEmbeddedOnlyAnnotationFacetFactory facetFactory;
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+
+ facetFactory = new JdoEmbeddedOnlyAnnotationFacetFactory();
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ facetFactory = null;
+ super.tearDown();
+ }
+
+ public void testFeatureTypes() {
+ final List<FeatureType> featureTypes = facetFactory
+ .getFeatureTypes();
+ Assert
+ .assertTrue(contains(featureTypes,
+ FeatureType.OBJECT));
+ assertFalse(contains(featureTypes,
+ FeatureType.PROPERTY));
+ assertFalse(contains(featureTypes,
+ FeatureType.COLLECTION));
+ Assert
+ .assertFalse(contains(featureTypes,
+ FeatureType.ACTION));
+ assertFalse(contains(featureTypes,
+ FeatureType.ACTION_PARAMETER));
+ }
+
+
+ public void testAggregatedFacetPickedUpOnType() throws Exception {
+ facetFactory.process(new FacetFactory.ProcessClassContext(SimpleObjectWithEmbeddedOnly.class, methodRemover, facetHolder));
+
+ final Facet facet = facetHolder.getFacet(ParentedFacet.class);
+ assertNotNull(facet);
+ Assert
+ .assertTrue(facet instanceof ParentedFacetDerivedFromJdoEmbeddedOnlyAnnotation);
+ }
+
+ public void testJpaEmbeddableFacetPickedUpOnType() throws Exception {
+ facetFactory.process(new FacetFactory.ProcessClassContext(SimpleObjectWithEmbeddedOnly.class, methodRemover, facetHolder));
+
+ final Facet facet = facetHolder.getFacet(JdoEmbeddedOnlyFacet.class);
+ assertNotNull(facet);
+ assertTrue(facet instanceof JdoEmbeddedOnlyFacetAnnotation);
+ }
+
+
+ public void testNoMethodsRemovedForType() throws Exception {
+ facetFactory.process(new FacetFactory.ProcessClassContext(SimpleObjectWithEmbeddedOnly.class, methodRemover, facetHolder));
+ assertNoMethodsRemoved();
+ }
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/0861ed93/framework/component/objectstore/jdo/jdo-metamodel/src/test/java/org/apache/isis/runtimes/dflt/objectstores/jdo/metamodel/facets/object/embeddedonly/SimpleObjectWithEmbeddedOnly.java
----------------------------------------------------------------------
diff --git a/framework/component/objectstore/jdo/jdo-metamodel/src/test/java/org/apache/isis/runtimes/dflt/objectstores/jdo/metamodel/facets/object/embeddedonly/SimpleObjectWithEmbeddedOnly.java b/framework/component/objectstore/jdo/jdo-metamodel/src/test/java/org/apache/isis/runtimes/dflt/objectstores/jdo/metamodel/facets/object/embeddedonly/SimpleObjectWithEmbeddedOnly.java
new file mode 100644
index 0000000..de86749
--- /dev/null
+++ b/framework/component/objectstore/jdo/jdo-metamodel/src/test/java/org/apache/isis/runtimes/dflt/objectstores/jdo/metamodel/facets/object/embeddedonly/SimpleObjectWithEmbeddedOnly.java
@@ -0,0 +1,37 @@
+/*
+ * 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.runtimes.dflt.objectstores.jdo.metamodel.facets.object.embeddedonly;
+
+import javax.jdo.annotations.EmbeddedOnly;
+import javax.jdo.annotations.PrimaryKey;
+
+@EmbeddedOnly
+public class SimpleObjectWithEmbeddedOnly {
+
+ private Long id;
+
+ @PrimaryKey
+ public Long getId() {
+ return id;
+ }
+
+ public void setId(final Long id) {
+ this.id = id;
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/isis/blob/0861ed93/framework/component/objectstore/jdo/jdo-metamodel/src/test/java/org/apache/isis/runtimes/dflt/objectstores/jdo/metamodel/facets/object/persistencecapable/GivenJdoPersistenceCapableAnnotationFacetFactoryTest.java
----------------------------------------------------------------------
diff --git a/framework/component/objectstore/jdo/jdo-metamodel/src/test/java/org/apache/isis/runtimes/dflt/objectstores/jdo/metamodel/facets/object/persistencecapable/GivenJdoPersistenceCapableAnnotationFacetFactoryTest.java b/framework/component/objectstore/jdo/jdo-metamodel/src/test/java/org/apache/isis/runtimes/dflt/objectstores/jdo/metamodel/facets/object/persistencecapable/GivenJdoPersistenceCapableAnnotationFacetFactoryTest.java
new file mode 100644
index 0000000..c6984ff
--- /dev/null
+++ b/framework/component/objectstore/jdo/jdo-metamodel/src/test/java/org/apache/isis/runtimes/dflt/objectstores/jdo/metamodel/facets/object/persistencecapable/GivenJdoPersistenceCapableAnnotationFacetFactoryTest.java
@@ -0,0 +1,150 @@
+/*
+ * 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.runtimes.dflt.objectstores.jdo.metamodel.facets.object.persistencecapable;
+
+import java.util.List;
+
+import javax.jdo.annotations.IdentityType;
+import javax.jdo.annotations.PersistenceCapable;
+
+import junit.framework.Assert;
+
+import org.apache.isis.core.metamodel.facetapi.Facet;
+import org.apache.isis.core.metamodel.facetapi.FeatureType;
+import org.apache.isis.core.metamodel.facets.FacetFactory;
+import org.apache.isis.core.progmodel.facets.AbstractFacetFactoryTest;
+import org.apache.isis.runtimes.dflt.objectstores.jdo.metamodel.facets.object.persistencecapable.JdoPersistenceCapableAnnotationFacetFactory;
+import org.apache.isis.runtimes.dflt.objectstores.jdo.metamodel.facets.object.persistencecapable.JdoPersistenceCapableFacet;
+import org.apache.isis.runtimes.dflt.objectstores.jdo.metamodel.facets.object.persistencecapable.JdoPersistenceCapableFacetAnnotation;
+
+
+public class GivenJdoPersistenceCapableAnnotationFacetFactoryTest extends
+ AbstractFacetFactoryTest {
+
+ private JdoPersistenceCapableAnnotationFacetFactory facetFactory;
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+
+ facetFactory = new JdoPersistenceCapableAnnotationFacetFactory();
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ facetFactory = null;
+ super.tearDown();
+ }
+
+ public void testFeatureTypes() {
+ final List<FeatureType> featureTypes = facetFactory
+ .getFeatureTypes();
+ Assert
+ .assertTrue(contains(featureTypes,
+ FeatureType.OBJECT));
+ assertFalse(contains(featureTypes,
+ FeatureType.PROPERTY));
+ assertFalse(contains(featureTypes,
+ FeatureType.COLLECTION));
+ Assert
+ .assertFalse(contains(featureTypes,
+ FeatureType.ACTION));
+ assertFalse(contains(featureTypes,
+ FeatureType.ACTION_PARAMETER));
+ }
+
+ public void testPersistenceCapableAnnotationPickedUpOnClass() {
+ @PersistenceCapable
+ class Customer {
+ }
+
+ facetFactory.process(new FacetFactory.ProcessClassContext(Customer.class, methodRemover, facetHolder));
+
+ final Facet facet = facetHolder.getFacet(JdoPersistenceCapableFacet.class);
+ assertNotNull(facet);
+ assertTrue(facet instanceof JdoPersistenceCapableFacetAnnotation);
+ }
+
+ public void testIfNoPersistenceCapableAnnotationThenNoFacet() {
+
+ class Customer {
+ }
+
+ facetFactory.process(new FacetFactory.ProcessClassContext(Customer.class, methodRemover, facetHolder));
+
+ final Facet facet = facetHolder.getFacet(JdoPersistenceCapableFacet.class);
+ assertNull(facet);
+ }
+
+ public void testEntityAnnotationWithNoExplicitNameDefaultsToClassName() {
+ @PersistenceCapable()
+ class Customer {
+ }
+ facetFactory.process(new FacetFactory.ProcessClassContext(Customer.class, methodRemover, facetHolder));
+
+ final JdoPersistenceCapableFacet entityFacet = facetHolder
+ .getFacet(JdoPersistenceCapableFacet.class);
+ assertEquals("Customer", entityFacet.getTable());
+ }
+
+ public void testPersistenceCapableAnnotationWithNoExplicitIdentityTypeDefaultsToUnspecified() {
+ @PersistenceCapable()
+ class Customer {
+ }
+ facetFactory.process(new FacetFactory.ProcessClassContext(Customer.class, methodRemover, facetHolder));
+
+ final JdoPersistenceCapableFacet entityFacet = facetHolder
+ .getFacet(JdoPersistenceCapableFacet.class);
+ assertEquals(IdentityType.UNSPECIFIED, entityFacet.getIdentityType());
+ }
+
+ public void testPersistenceCapableAnnotationWithExplicitNameAttributeProvided() {
+ @PersistenceCapable(table = "CUS_CUSTOMER")
+ class Customer {
+ }
+
+ facetFactory.process(new FacetFactory.ProcessClassContext(Customer.class, methodRemover, facetHolder));
+
+ final JdoPersistenceCapableFacet entityFacet = facetHolder
+ .getFacet(JdoPersistenceCapableFacet.class);
+ assertEquals("CUS_CUSTOMER", entityFacet.getTable());
+ }
+
+ public void testPersistenceCapableAnnotationWithExplicitIdentityTypeAttributeProvided() {
+ @PersistenceCapable(identityType=IdentityType.DATASTORE)
+ class Customer {
+ }
+
+ facetFactory.process(new FacetFactory.ProcessClassContext(Customer.class, methodRemover, facetHolder));
+
+ final JdoPersistenceCapableFacet entityFacet = facetHolder
+ .getFacet(JdoPersistenceCapableFacet.class);
+ assertEquals(IdentityType.DATASTORE, entityFacet.getIdentityType());
+ }
+
+ public void testNoMethodsRemoved() {
+ @PersistenceCapable
+ class Customer {
+ }
+
+ facetFactory.process(new FacetFactory.ProcessClassContext(Customer.class, methodRemover, facetHolder));
+
+ assertNoMethodsRemoved();
+ }
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/0861ed93/framework/component/objectstore/jdo/jdo-metamodel/src/test/java/org/apache/isis/runtimes/dflt/objectstores/jdo/metamodel/facets/prop/primarykey/GivenJdoPrimaryKeyAnnotationFacetFactoryTest.java
----------------------------------------------------------------------
diff --git a/framework/component/objectstore/jdo/jdo-metamodel/src/test/java/org/apache/isis/runtimes/dflt/objectstores/jdo/metamodel/facets/prop/primarykey/GivenJdoPrimaryKeyAnnotationFacetFactoryTest.java b/framework/component/objectstore/jdo/jdo-metamodel/src/test/java/org/apache/isis/runtimes/dflt/objectstores/jdo/metamodel/facets/prop/primarykey/GivenJdoPrimaryKeyAnnotationFacetFactoryTest.java
new file mode 100644
index 0000000..fe0f5e7
--- /dev/null
+++ b/framework/component/objectstore/jdo/jdo-metamodel/src/test/java/org/apache/isis/runtimes/dflt/objectstores/jdo/metamodel/facets/prop/primarykey/GivenJdoPrimaryKeyAnnotationFacetFactoryTest.java
@@ -0,0 +1,138 @@
+/*
+ * 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.runtimes.dflt.objectstores.jdo.metamodel.facets.prop.primarykey;
+
+import java.lang.reflect.Method;
+import java.util.List;
+
+import javax.jdo.annotations.PrimaryKey;
+
+import junit.framework.Assert;
+
+import org.apache.isis.core.metamodel.facetapi.Facet;
+import org.apache.isis.core.metamodel.facetapi.FeatureType;
+import org.apache.isis.core.metamodel.facets.FacetFactory;
+import org.apache.isis.core.metamodel.facets.mandatory.MandatoryFacet;
+import org.apache.isis.core.progmodel.facets.AbstractFacetFactoryTest;
+import org.apache.isis.core.progmodel.facets.members.disabled.DisabledFacet;
+
+public class GivenJdoPrimaryKeyAnnotationFacetFactoryTest extends AbstractFacetFactoryTest {
+
+ private JdoPrimaryKeyAnnotationFacetFactory facetFactory;
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+
+ facetFactory = new JdoPrimaryKeyAnnotationFacetFactory();
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ facetFactory = null;
+ super.tearDown();
+ }
+
+ public void testFeatureTypes() {
+ final List<FeatureType> featureTypes = facetFactory.getFeatureTypes();
+ Assert.assertFalse(contains(featureTypes, FeatureType.OBJECT));
+ assertTrue(contains(featureTypes, FeatureType.PROPERTY));
+ assertFalse(contains(featureTypes, FeatureType.COLLECTION));
+ Assert.assertFalse(contains(featureTypes, FeatureType.ACTION));
+ assertFalse(contains(featureTypes, FeatureType.ACTION_PARAMETER));
+ }
+
+ public void testIdAnnotationPickedUpOnProperty() throws Exception {
+ final Class<?> cls = SimpleObjectWithPrimaryKey.class;
+ final Method method = cls.getMethod("getId");
+ facetFactory.process(new FacetFactory.ProcessMethodContext(cls, method, methodRemover, facetedMethod));
+
+ final Facet facet = facetedMethod.getFacet(JdoPrimaryKeyFacet.class);
+ assertNotNull(facet);
+ assertTrue(facet instanceof JdoPrimaryKeyFacet);
+ }
+
+ public void testOptionalDerivedFromId() throws Exception {
+ final Class<?> cls = SimpleObjectWithPrimaryKey.class;
+ final Method method = cls.getMethod("getId");
+ facetFactory.process(new FacetFactory.ProcessMethodContext(cls, method, methodRemover, facetedMethod));
+
+ final Facet facet = facetedMethod.getFacet(MandatoryFacet.class);
+ assertNotNull(facet);
+ Assert.assertTrue(facet instanceof OptionalFacetDerivedFromJdoPrimaryKeyAnnotation);
+ }
+
+ public void testDisabledDerivedFromId() throws Exception {
+ final Class<?> cls = SimpleObjectWithPrimaryKey.class;
+ final Method method = cls.getMethod("getId");
+ facetFactory.process(new FacetFactory.ProcessMethodContext(cls, method, methodRemover, facetedMethod));
+
+ final Facet facet = facetedMethod.getFacet(DisabledFacet.class);
+ assertNotNull(facet);
+ Assert.assertTrue(facet instanceof DisabledFacetDerivedFromJdoPrimaryKeyAnnotation);
+ }
+
+ public void testIfNoIdAnnotationThenNoFacet() throws Exception {
+
+ class Customer {
+ private Long id;
+
+ // @Id missing
+ @SuppressWarnings("unused")
+ public Long getId() {
+ return id;
+ }
+
+ @SuppressWarnings("unused")
+ public void setId(final Long id) {
+ this.id = id;
+ }
+ }
+
+ final Class<?> cls = Customer.class;
+ final Method method = cls.getMethod("getId");
+ facetFactory.process(new FacetFactory.ProcessMethodContext(cls, method, methodRemover, facetedMethod));
+
+ final Facet facet = facetedMethod.getFacet(JdoPrimaryKeyFacet.class);
+ assertNull(facet);
+ }
+
+ public void testNoMethodsRemoved() throws Exception {
+ class Customer {
+ private Long id;
+
+ @SuppressWarnings("unused")
+ @PrimaryKey
+ public Long getId() {
+ return id;
+ }
+
+ @SuppressWarnings("unused")
+ public void setId(final Long id) {
+ this.id = id;
+ }
+ }
+
+ final Class<?> cls = Customer.class;
+ final Method method = cls.getMethod("getId");
+ facetFactory.process(new FacetFactory.ProcessMethodContext(cls, method, methodRemover, facetedMethod));
+
+ assertNoMethodsRemoved();
+ }
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/0861ed93/framework/component/objectstore/jdo/jdo-metamodel/src/test/java/org/apache/isis/runtimes/dflt/objectstores/jdo/metamodel/facets/prop/primarykey/SimpleObjectWithPrimaryKey.java
----------------------------------------------------------------------
diff --git a/framework/component/objectstore/jdo/jdo-metamodel/src/test/java/org/apache/isis/runtimes/dflt/objectstores/jdo/metamodel/facets/prop/primarykey/SimpleObjectWithPrimaryKey.java b/framework/component/objectstore/jdo/jdo-metamodel/src/test/java/org/apache/isis/runtimes/dflt/objectstores/jdo/metamodel/facets/prop/primarykey/SimpleObjectWithPrimaryKey.java
new file mode 100644
index 0000000..dc69b32
--- /dev/null
+++ b/framework/component/objectstore/jdo/jdo-metamodel/src/test/java/org/apache/isis/runtimes/dflt/objectstores/jdo/metamodel/facets/prop/primarykey/SimpleObjectWithPrimaryKey.java
@@ -0,0 +1,36 @@
+/*
+ * 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.runtimes.dflt.objectstores.jdo.metamodel.facets.prop.primarykey;
+
+import javax.jdo.annotations.PrimaryKey;
+
+
+public class SimpleObjectWithPrimaryKey {
+
+ private Long id;
+
+ @PrimaryKey
+ public Long getId() {
+ return id;
+ }
+
+ public void setId(final Long id) {
+ this.id = id;
+ }
+}
\ No newline at end of file