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/07/05 01:10:35 UTC

svn commit: r1357438 [4/5] - in /incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo: jdo-applib/ jdo-applib/src/ jdo-applib/src/main/ jdo-applib/src/main/java/ jdo-applib/src/main/resources/ jdo-applib/src/site/ jdo-applib/src/site/apt/ jdo-...

Added: incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-metamodel/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/metamodel/facets/prop/primarykey/JdoPrimaryKeyFacetImpl.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-metamodel/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/metamodel/facets/prop/primarykey/JdoPrimaryKeyFacetImpl.java?rev=1357438&view=auto
==============================================================================
--- incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-metamodel/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/metamodel/facets/prop/primarykey/JdoPrimaryKeyFacetImpl.java (added)
+++ incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-metamodel/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/metamodel/facets/prop/primarykey/JdoPrimaryKeyFacetImpl.java Wed Jul  4 23:10:27 2012
@@ -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);
+    }
+
+}

Added: incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-metamodel/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/metamodel/facets/prop/primarykey/OptionalFacetDerivedFromJdoPrimaryKeyAnnotation.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-metamodel/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/metamodel/facets/prop/primarykey/OptionalFacetDerivedFromJdoPrimaryKeyAnnotation.java?rev=1357438&view=auto
==============================================================================
--- incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-metamodel/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/metamodel/facets/prop/primarykey/OptionalFacetDerivedFromJdoPrimaryKeyAnnotation.java (added)
+++ incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-metamodel/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/metamodel/facets/prop/primarykey/OptionalFacetDerivedFromJdoPrimaryKeyAnnotation.java Wed Jul  4 23:10:27 2012
@@ -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 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.
+ * 
+ * @see OptionalFacetDerivedFromJdoVersionAnnotation
+ */
+public class OptionalFacetDerivedFromJdoPrimaryKeyAnnotation extends
+        MandatoryFacetDefault {
+
+    public OptionalFacetDerivedFromJdoPrimaryKeyAnnotation(final FacetHolder holder) {
+        super(holder);
+    }
+
+    @Override
+    public boolean isInvertedSemantics() {
+        return true;
+    }
+
+
+}

Added: incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-metamodel/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/metamodel/facets/prop/primarykey/package-info.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-metamodel/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/metamodel/facets/prop/primarykey/package-info.java?rev=1357438&view=auto
==============================================================================
--- incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-metamodel/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/metamodel/facets/prop/primarykey/package-info.java (added)
+++ incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-metamodel/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/metamodel/facets/prop/primarykey/package-info.java Wed Jul  4 23:10:27 2012
@@ -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

Added: incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-metamodel/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/metamodel/specloader/progmodelfacets/JdoProgrammingModelFacets.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-metamodel/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/metamodel/specloader/progmodelfacets/JdoProgrammingModelFacets.java?rev=1357438&view=auto
==============================================================================
--- incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-metamodel/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/metamodel/specloader/progmodelfacets/JdoProgrammingModelFacets.java (added)
+++ incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-metamodel/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/metamodel/specloader/progmodelfacets/JdoProgrammingModelFacets.java Wed Jul  4 23:10:27 2012
@@ -0,0 +1,54 @@
+/*
+ *  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.progmodelfacets;
+
+
+import org.apache.isis.progmodels.dflt.ProgrammingModelFacetsJava5;
+import org.apache.isis.runtimes.dflt.objectstores.jdo.metamodel.facets.object.discriminator.JdoDiscriminatorAnnotationFacetFactory;
+import org.apache.isis.runtimes.dflt.objectstores.jdo.metamodel.facets.object.embeddedonly.JdoEmbeddedOnlyAnnotationFacetFactory;
+import org.apache.isis.runtimes.dflt.objectstores.jdo.metamodel.facets.object.persistencecapable.JdoPersistenceCapableAnnotationFacetFactory;
+import org.apache.isis.runtimes.dflt.objectstores.jdo.metamodel.facets.object.query.JdoQueryAnnotationFacetFactory;
+import org.apache.isis.runtimes.dflt.objectstores.jdo.metamodel.facets.object.version.JdoVersionAnnotationFacetFactory;
+import org.apache.isis.runtimes.dflt.objectstores.jdo.metamodel.facets.prop.primarykey.JdoPrimaryKeyAnnotationFacetFactory;
+
+/**
+ * As per the {@link ProgrammingModelFacetsJava5 Java 5 default programming
+ * model}, but also
+ * includes support for JPA.
+ * <p>
+ * Intended to be used by the {@link JpaJavaReflectorInstaller}, which
+ * additionally sets up other required components needed for JPA support.
+ */
+public class JdoProgrammingModelFacets extends ProgrammingModelFacetsJava5 {
+
+    public JdoProgrammingModelFacets() {
+        addFactory(JdoPersistenceCapableAnnotationFacetFactory.class);
+        addFactory(JdoEmbeddedOnlyAnnotationFacetFactory.class);
+
+        addFactory(JdoPrimaryKeyAnnotationFacetFactory.class);
+        addFactory(JdoDiscriminatorAnnotationFacetFactory.class);
+
+        addFactory(JdoVersionAnnotationFacetFactory.class);
+        addFactory(JdoQueryAnnotationFacetFactory.class);
+    }
+
+}
+
+
+// Copyright (c) Naked Objects Group Ltd.

Added: incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-metamodel/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/metamodel/specloader/validator/JdoMetaModelValidator.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-metamodel/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/metamodel/specloader/validator/JdoMetaModelValidator.java?rev=1357438&view=auto
==============================================================================
--- incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-metamodel/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/metamodel/specloader/validator/JdoMetaModelValidator.java (added)
+++ incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-metamodel/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/metamodel/specloader/validator/JdoMetaModelValidator.java Wed Jul  4 23:10:27 2012
@@ -0,0 +1,106 @@
+/*
+ *  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 java.text.MessageFormat;
+import java.util.Collection;
+
+import org.apache.isis.core.metamodel.spec.ObjectSpecification;
+import org.apache.isis.core.metamodel.spec.feature.OneToOneAssociation;
+import org.apache.isis.core.metamodel.specloader.validator.MetaModelInvalidException;
+import org.apache.isis.core.metamodel.specloader.validator.MetaModelValidatorAbstract;
+import org.apache.isis.runtimes.dflt.objectstores.jdo.metamodel.facets.object.discriminator.JdoDiscriminatorFacet;
+import org.apache.isis.runtimes.dflt.objectstores.jdo.metamodel.facets.object.embeddedonly.JdoEmbeddedOnlyFacet;
+import org.apache.isis.runtimes.dflt.objectstores.jdo.metamodel.facets.object.persistencecapable.JdoPersistenceCapableFacet;
+import org.apache.isis.runtimes.dflt.objectstores.jdo.metamodel.util.JdoPropertyUtils;
+
+public class JdoMetaModelValidator extends MetaModelValidatorAbstract {
+
+    public void validate() {
+        try {
+            ensureFoundAnnotatedEntities();
+            ensureAllSpecificationsValid();
+        } catch (final ClassNotFoundException e) {
+            throw new MetaModelInvalidException(e);
+        }
+    }
+
+    private void ensureFoundAnnotatedEntities() {
+        final Collection<ObjectSpecification> objectSpecs = getSpecificationLoader().allSpecifications();
+        for (final ObjectSpecification objectSpec : objectSpecs) {
+            if (objectSpec.containsFacet(JdoPersistenceCapableFacet.class)) {
+                return;
+            }
+        }
+        throw new MetaModelInvalidException("No annotated entities found; " + "are they annotated with @Entity? " + "are the entities referenced by the registered services? " + "are all services registered? " + "are you using the JPA reflector");
+    }
+
+    private void ensureAllSpecificationsValid() throws ClassNotFoundException {
+        final Collection<ObjectSpecification> objectSpecs = getSpecificationLoader().allSpecifications();
+        for (final ObjectSpecification objSpec : objectSpecs) {
+            ensureNotAnnotatedAsBothEntityAndEmbeddedOnly(objSpec);
+            ensureEntityIfAnnotatedAsSuchHasOrInheritsAnPrimaryKyProperty(objSpec);
+            ensureEntityIfAnnotatedAsSuchAndConcreteHasDiscriminatorFacet(objSpec);
+        }
+    }
+
+    private void ensureNotAnnotatedAsBothEntityAndEmbeddedOnly(final ObjectSpecification objSpec) {
+        final JdoPersistenceCapableFacet entityFacet = objSpec.getFacet(JdoPersistenceCapableFacet.class);
+        final JdoEmbeddedOnlyFacet embeddableFacet = objSpec.getFacet(JdoEmbeddedOnlyFacet.class);
+        if (entityFacet == null || embeddableFacet == null) {
+            return;
+        }
+
+        final String classFullName = objSpec.getFullIdentifier();
+        throw new MetaModelInvalidException(MessageFormat.format("Class {0} is mapped as both @Entity and @Embeddable; " + "not supported", classFullName));
+    }
+
+    private void ensureEntityIfAnnotatedAsSuchHasOrInheritsAnPrimaryKyProperty(final ObjectSpecification objSpec) throws ClassNotFoundException {
+        if (!objSpec.containsFacet(JdoPersistenceCapableFacet.class)) {
+            return;
+        }
+
+        final String classFullName = objSpec.getFullIdentifier();
+        final Class<?> cls = Class.forName(classFullName);
+
+        if (cls.isInterface()) {
+            // TODO: could possibly have a FacetFactory to check that the
+            // @javax.persistence.Transient
+            // annotation has been set on all properties?
+            return;
+        }
+
+        final OneToOneAssociation idProperty = JdoPropertyUtils.getIdPropertyFor(objSpec);
+        if (idProperty == null) {
+            throw new MetaModelInvalidException(MessageFormat.format("Class {0} does not have a single property with IdFacet", classFullName));
+        }
+    }
+
+    private void ensureEntityIfAnnotatedAsSuchAndConcreteHasDiscriminatorFacet(final ObjectSpecification objSpec) {
+        if (!objSpec.containsFacet(JdoPersistenceCapableFacet.class)) {
+            return;
+        }
+        if (objSpec.isAbstract() || objSpec.containsFacet(JdoDiscriminatorFacet.class)) {
+            return;
+        }
+        final String classFullName = objSpec.getFullIdentifier();
+        throw new MetaModelInvalidException(MessageFormat.format("OpenJpa object store requires that concrete class {0} mapped by @Entity " + "must also have an @DiscriminatorValue annotation", classFullName));
+    }
+
+}

Added: incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-metamodel/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/metamodel/util/JdoPrimaryKeyPropertyFilter.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-metamodel/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/metamodel/util/JdoPrimaryKeyPropertyFilter.java?rev=1357438&view=auto
==============================================================================
--- incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-metamodel/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/metamodel/util/JdoPrimaryKeyPropertyFilter.java (added)
+++ incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-metamodel/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/metamodel/util/JdoPrimaryKeyPropertyFilter.java Wed Jul  4 23:10:27 2012
@@ -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.
+ */
+final class JdoPrimaryKeyPropertyFilter implements Filter<ObjectAssociation> {
+    @Override
+    public boolean accept(final ObjectAssociation noa) {
+        return noa.isOneToOneAssociation() &&
+                noa.containsFacet(JdoPrimaryKeyFacet.class) &&
+                noa.containsFacet(PropertyOrCollectionAccessorFacet.class);
+    }
+}

Added: incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-metamodel/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/metamodel/util/JdoPropertyUtils.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-metamodel/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/metamodel/util/JdoPropertyUtils.java?rev=1357438&view=auto
==============================================================================
--- incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-metamodel/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/metamodel/util/JdoPropertyUtils.java (added)
+++ incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-metamodel/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/metamodel/util/JdoPropertyUtils.java Wed Jul  4 23:10:27 2012
@@ -0,0 +1,118 @@
+/*
+ *  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 java.text.MessageFormat;
+import java.util.List;
+
+import javax.jdo.annotations.Version;
+
+import org.apache.isis.applib.filter.Filter;
+import org.apache.isis.core.commons.exceptions.IsisException;
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.adapter.ObjectAdapterFactory;
+import org.apache.isis.core.metamodel.adapter.oid.RootOid;
+import org.apache.isis.core.metamodel.facets.accessor.PropertyOrCollectionAccessorFacet;
+import org.apache.isis.core.metamodel.facets.object.encodeable.EncodableFacet;
+import org.apache.isis.core.metamodel.spec.ObjectSpecification;
+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.object.persistencecapable.JdoPersistenceCapableFacet;
+
+public final class JdoPropertyUtils {
+
+    private JdoPropertyUtils() {
+    }
+
+    /**
+     * Searches for the property annotated with {@link Id}.
+     * <p>
+     * Returns the {@link OneToOneAssociation} if there is precisely one; else
+     * <tt>null</tt>.
+     * 
+     * @see JdoPrimaryKeyPropertyFilter
+     */
+    public static OneToOneAssociation getIdPropertyFor(final ObjectSpecification objectSpec) {
+        return getPropertyFor(objectSpec, "@Id", new JdoPrimaryKeyPropertyFilter());
+    }
+
+    /**
+     * Searches for the property annotated with {@link Version}.
+     * <p>
+     * Returns the {@link OneToOneAssociation} if there is precisely one; else
+     * <tt>null</tt>.
+     * 
+     * @see JdoVersionPropertyFilter
+     */
+    public static OneToOneAssociation getVersionPropertyFor(final ObjectSpecification objectSpec) {
+        return getPropertyFor(objectSpec, "@Version", new JdoVersionPropertyFilter());
+    }
+
+    private static OneToOneAssociation getPropertyFor(final ObjectSpecification objSpec, final String annotationName, final Filter<ObjectAssociation> filter) {
+        if (objSpec == null || !objSpec.containsFacet(JdoPersistenceCapableFacet.class)) {
+            return null;
+        }
+        final List<? extends ObjectAssociation> propertyList = objSpec.getAssociations(filter);
+        if (propertyList.size() == 0) {
+            return JdoPropertyUtils.getPropertyFor(objSpec.superclass(), annotationName, filter);
+        }
+        if (propertyList.size() > 1) {
+            throw new IllegalStateException(MessageFormat.format("Shouldn''t have more than one property annotated with {0} (''{1}'')", annotationName, objSpec.getFullIdentifier()));
+        }
+        return (OneToOneAssociation) propertyList.get(0);
+    }
+
+    public static void setPropertyIdFromOid(final ObjectAdapter adapter, final ObjectAdapterFactory adapterFactory) {
+
+        final RootOid oid = (RootOid) adapter.getOid();
+        final ObjectSpecification objectSpec = adapter.getSpecification();
+        final Object idValue = idValueOf(oid, objectSpec);
+        final ObjectAdapter jpaIdAdapter = adapterFactory.createAdapter(idValue, null);
+
+        setId(adapter, jpaIdAdapter);
+    }
+    
+    public static Object idValueOf(final RootOid oid, ObjectSpecification objectSpec) {
+        final OneToOneAssociation idProperty = getIdPropertyFor(objectSpec);
+        final EncodableFacet idPropEncodableFacet = idProperty.getFacet(EncodableFacet.class);
+        final ObjectAdapter idPropValueAdapter = idPropEncodableFacet.fromEncodedString(oid.getIdentifier());
+        return idPropValueAdapter.getObject();
+    }
+
+
+    private static void setId(final ObjectAdapter adapter, final ObjectAdapter idValueAdapter) {
+        final ObjectSpecification objectSpec = adapter.getSpecification();
+        final OneToOneAssociation idProperty = getIdPropertyFor(objectSpec);
+        if (idProperty == null) {
+            throw new IsisException("Specification {0} does not have a single property with IdFacet", objectSpec.getFullIdentifier());
+        }
+        idProperty.set(adapter, idValueAdapter);
+    }
+
+    public static Object getIdFor(final ObjectAdapter adapter) {
+        final OneToOneAssociation idPropertyFor = getIdPropertyFor(adapter.getSpecification());
+        if (idPropertyFor == null) {
+            return null;
+        }
+        final PropertyOrCollectionAccessorFacet facet = idPropertyFor.getFacet(PropertyOrCollectionAccessorFacet.class);
+        return facet.getProperty(adapter);
+    }
+
+
+}

Added: incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-metamodel/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/metamodel/util/JdoVersionPropertyFilter.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-metamodel/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/metamodel/util/JdoVersionPropertyFilter.java?rev=1357438&view=auto
==============================================================================
--- incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-metamodel/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/metamodel/util/JdoVersionPropertyFilter.java (added)
+++ incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-metamodel/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/metamodel/util/JdoVersionPropertyFilter.java Wed Jul  4 23:10:27 2012
@@ -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.Version;
+
+import org.apache.isis.applib.filter.Filter;
+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.core.progmodel.facets.properties.accessor.PropertyAccessorFacetViaAccessor;
+import org.apache.isis.runtimes.dflt.objectstores.jdo.metamodel.facets.object.version.JdoVersionFacet;
+
+/**
+ * Use to locate the property annotated with {@link Version}.
+ * <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, since JPA/Hibernate does this
+ * for us.
+ */
+final class JdoVersionPropertyFilter implements Filter<ObjectAssociation> {
+    @Override
+    public boolean accept(final ObjectAssociation noa) {
+        return noa.isOneToOneAssociation() && 
+                noa.containsFacet(JdoVersionFacet.class) && 
+                noa.containsFacet(PropertyAccessorFacetViaAccessor.class);
+    }
+}

Added: incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-metamodel/src/site/apt/index.apt
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-metamodel/src/site/apt/index.apt?rev=1357438&view=auto
==============================================================================
--- incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-metamodel/src/site/apt/index.apt (added)
+++ incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-metamodel/src/site/apt/index.apt Wed Jul  4 23:10:27 2012
@@ -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 ...

Added: incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-metamodel/src/site/apt/jottings.apt
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-metamodel/src/site/apt/jottings.apt?rev=1357438&view=auto
==============================================================================
--- incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-metamodel/src/site/apt/jottings.apt (added)
+++ incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-metamodel/src/site/apt/jottings.apt Wed Jul  4 23:10:27 2012
@@ -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. 
+ 

Added: incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-metamodel/src/site/site.xml
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-metamodel/src/site/site.xml?rev=1357438&view=auto
==============================================================================
--- incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-metamodel/src/site/site.xml (added)
+++ incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-metamodel/src/site/site.xml Wed Jul  4 23:10:27 2012
@@ -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="JPA Metamodel">
+			<item name="About" href="index.html" />
+            <item name="Jottings" href="jottings.html" />
+		</menu>
+
+        <menu name="JPA Modules">
+            <item name="Applib" href="../jpa-applib/index.html" />
+            <item name="Metamodel" href="../jpa-metamodel/index.html" />
+            <item name="OpenJPA" href="../jpa-openjpa/index.html" />
+        </menu>
+
+		<menu name="Maven Reports" ref="reports" />
+	</body>
+</project>

Added: incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-metamodel/src/test/java/org/apache/isis/runtimes/dflt/objectstores/jdo/metamodel/GivenJdoProgrammingModelWhenInitializedThenFacetsContentsTest.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-metamodel/src/test/java/org/apache/isis/runtimes/dflt/objectstores/jdo/metamodel/GivenJdoProgrammingModelWhenInitializedThenFacetsContentsTest.java?rev=1357438&view=auto
==============================================================================
--- incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-metamodel/src/test/java/org/apache/isis/runtimes/dflt/objectstores/jdo/metamodel/GivenJdoProgrammingModelWhenInitializedThenFacetsContentsTest.java (added)
+++ incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-metamodel/src/test/java/org/apache/isis/runtimes/dflt/objectstores/jdo/metamodel/GivenJdoProgrammingModelWhenInitializedThenFacetsContentsTest.java Wed Jul  4 23:10:27 2012
@@ -0,0 +1,68 @@
+/*
+ *  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;
+
+import static org.hamcrest.CoreMatchers.instanceOf;
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertThat;
+
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.List;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
+
+import org.apache.isis.core.commons.matchers.IsisMatchers;
+import org.apache.isis.core.metamodel.facets.FacetFactory;
+import org.apache.isis.runtimes.dflt.objectstores.jdo.metamodel.facets.object.persistencecapable.JdoPersistenceCapableAnnotationFacetFactory;
+import org.apache.isis.runtimes.dflt.objectstores.jdo.metamodel.facets.prop.primarykey.JdoPrimaryKeyAnnotationFacetFactory;
+import org.apache.isis.runtimes.dflt.objectstores.jdo.metamodel.specloader.progmodelfacets.JdoProgrammingModelFacets;
+
+@RunWith(Parameterized.class)
+public class GivenJdoProgrammingModelWhenInitializedThenFacetsContentsTest {
+
+    @Parameters
+    public static Collection<Object[]> data() {
+        return Arrays.asList(new Object[][] {
+                { JdoPersistenceCapableAnnotationFacetFactory.class },
+                { JdoPrimaryKeyAnnotationFacetFactory.class },
+                });
+    }
+
+
+    private final Class<?> facetFactoryClass;
+
+    public GivenJdoProgrammingModelWhenInitializedThenFacetsContentsTest(
+            final Class<?> facetFactoryClass) {
+        this.facetFactoryClass = facetFactoryClass;
+    }
+
+
+    @Test
+    public void shouldContainSpecifiedFacetFactory() throws Exception {
+        final JdoProgrammingModelFacets jpaProgrammingModelFacets = new JdoProgrammingModelFacets();
+        jpaProgrammingModelFacets.init();
+        final List<FacetFactory> list = jpaProgrammingModelFacets.getList();
+        assertThat(list, IsisMatchers
+                .containsElementThat(is(instanceOf(facetFactoryClass))));
+    }
+}

Added: incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-metamodel/src/test/java/org/apache/isis/runtimes/dflt/objectstores/jdo/metamodel/GivenJdoProgrammingModelWhenInitializingTest.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-metamodel/src/test/java/org/apache/isis/runtimes/dflt/objectstores/jdo/metamodel/GivenJdoProgrammingModelWhenInitializingTest.java?rev=1357438&view=auto
==============================================================================
--- incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-metamodel/src/test/java/org/apache/isis/runtimes/dflt/objectstores/jdo/metamodel/GivenJdoProgrammingModelWhenInitializingTest.java (added)
+++ incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-metamodel/src/test/java/org/apache/isis/runtimes/dflt/objectstores/jdo/metamodel/GivenJdoProgrammingModelWhenInitializingTest.java Wed Jul  4 23:10:27 2012
@@ -0,0 +1,62 @@
+/*
+ *  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;
+
+import static org.hamcrest.CoreMatchers.instanceOf;
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertThat;
+
+import java.util.List;
+
+import org.junit.Before;
+import org.junit.Test;
+
+import org.apache.isis.core.commons.matchers.IsisMatchers;
+import org.apache.isis.core.metamodel.facets.FacetFactory;
+import org.apache.isis.runtimes.dflt.objectstores.jdo.metamodel.facets.object.persistencecapable.JdoPersistenceCapableAnnotationFacetFactory;
+import org.apache.isis.runtimes.dflt.objectstores.jdo.metamodel.specloader.progmodelfacets.JdoProgrammingModelFacets;
+
+public class GivenJdoProgrammingModelWhenInitializingTest {
+
+    private JdoProgrammingModelFacets jpaProgrammingModelFacets;
+
+
+    @Before
+    public void setUp() throws Exception {
+        jpaProgrammingModelFacets = new JdoProgrammingModelFacets();
+    }
+
+
+    @Test
+    public void hasNoFacetFactoriesRegisteredIfNotInitialized()
+            throws Exception {
+        final List<FacetFactory> list = jpaProgrammingModelFacets.getList();
+        assertThat(list.size(), is(0));
+    }
+
+    @Test
+    public void onceInitializedShouldContainEntityAnnotationFacetFactory()
+            throws Exception {
+        jpaProgrammingModelFacets.init();
+        final List<FacetFactory> list = jpaProgrammingModelFacets.getList();
+        assertThat(
+                list,
+                IsisMatchers.containsElementThat(is(instanceOf(JdoPersistenceCapableAnnotationFacetFactory.class))));
+    }
+}

Added: incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-metamodel/src/test/java/org/apache/isis/runtimes/dflt/objectstores/jdo/metamodel/facets/object/discriminator/GivenJdoDiscriminatorAnnotationFacetFactoryTest.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-metamodel/src/test/java/org/apache/isis/runtimes/dflt/objectstores/jdo/metamodel/facets/object/discriminator/GivenJdoDiscriminatorAnnotationFacetFactoryTest.java?rev=1357438&view=auto
==============================================================================
--- incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-metamodel/src/test/java/org/apache/isis/runtimes/dflt/objectstores/jdo/metamodel/facets/object/discriminator/GivenJdoDiscriminatorAnnotationFacetFactoryTest.java (added)
+++ incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-metamodel/src/test/java/org/apache/isis/runtimes/dflt/objectstores/jdo/metamodel/facets/object/discriminator/GivenJdoDiscriminatorAnnotationFacetFactoryTest.java Wed Jul  4 23:10:27 2012
@@ -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();
+    }
+}

Added: incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-metamodel/src/test/java/org/apache/isis/runtimes/dflt/objectstores/jdo/metamodel/facets/object/embeddedonly/GivenJdoEmbeddedOnlyAnnotationFacetFactoryTest.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-metamodel/src/test/java/org/apache/isis/runtimes/dflt/objectstores/jdo/metamodel/facets/object/embeddedonly/GivenJdoEmbeddedOnlyAnnotationFacetFactoryTest.java?rev=1357438&view=auto
==============================================================================
--- incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-metamodel/src/test/java/org/apache/isis/runtimes/dflt/objectstores/jdo/metamodel/facets/object/embeddedonly/GivenJdoEmbeddedOnlyAnnotationFacetFactoryTest.java (added)
+++ incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-metamodel/src/test/java/org/apache/isis/runtimes/dflt/objectstores/jdo/metamodel/facets/object/embeddedonly/GivenJdoEmbeddedOnlyAnnotationFacetFactoryTest.java Wed Jul  4 23:10:27 2012
@@ -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();
+    }
+}

Added: incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-metamodel/src/test/java/org/apache/isis/runtimes/dflt/objectstores/jdo/metamodel/facets/object/embeddedonly/SimpleObjectWithEmbeddedOnly.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-metamodel/src/test/java/org/apache/isis/runtimes/dflt/objectstores/jdo/metamodel/facets/object/embeddedonly/SimpleObjectWithEmbeddedOnly.java?rev=1357438&view=auto
==============================================================================
--- incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-metamodel/src/test/java/org/apache/isis/runtimes/dflt/objectstores/jdo/metamodel/facets/object/embeddedonly/SimpleObjectWithEmbeddedOnly.java (added)
+++ incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-metamodel/src/test/java/org/apache/isis/runtimes/dflt/objectstores/jdo/metamodel/facets/object/embeddedonly/SimpleObjectWithEmbeddedOnly.java Wed Jul  4 23:10:27 2012
@@ -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

Added: incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-metamodel/src/test/java/org/apache/isis/runtimes/dflt/objectstores/jdo/metamodel/facets/object/entity/GivenJdoPersistenceCapableAnnotationFacetFactoryTest.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-metamodel/src/test/java/org/apache/isis/runtimes/dflt/objectstores/jdo/metamodel/facets/object/entity/GivenJdoPersistenceCapableAnnotationFacetFactoryTest.java?rev=1357438&view=auto
==============================================================================
--- incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-metamodel/src/test/java/org/apache/isis/runtimes/dflt/objectstores/jdo/metamodel/facets/object/entity/GivenJdoPersistenceCapableAnnotationFacetFactoryTest.java (added)
+++ incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-metamodel/src/test/java/org/apache/isis/runtimes/dflt/objectstores/jdo/metamodel/facets/object/entity/GivenJdoPersistenceCapableAnnotationFacetFactoryTest.java Wed Jul  4 23:10:27 2012
@@ -0,0 +1,126 @@
+/*
+ *  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.entity;
+
+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.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 testIfNoEntityAnnotationThenNoFacet() {
+
+        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 testEntityAnnotationWithExplicitNameAttributeProvided() {
+        @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 testNoMethodsRemoved() {
+        @PersistenceCapable
+        class Customer {
+        }
+
+        facetFactory.process(new FacetFactory.ProcessClassContext(Customer.class, methodRemover, facetHolder));
+
+        assertNoMethodsRemoved();
+    }
+}

Added: incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-metamodel/src/test/java/org/apache/isis/runtimes/dflt/objectstores/jdo/metamodel/facets/object/version/GivenJdoVersionAnnotationFacetFactoryTest.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-metamodel/src/test/java/org/apache/isis/runtimes/dflt/objectstores/jdo/metamodel/facets/object/version/GivenJdoVersionAnnotationFacetFactoryTest.java?rev=1357438&view=auto
==============================================================================
--- incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-metamodel/src/test/java/org/apache/isis/runtimes/dflt/objectstores/jdo/metamodel/facets/object/version/GivenJdoVersionAnnotationFacetFactoryTest.java (added)
+++ incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-metamodel/src/test/java/org/apache/isis/runtimes/dflt/objectstores/jdo/metamodel/facets/object/version/GivenJdoVersionAnnotationFacetFactoryTest.java Wed Jul  4 23:10:27 2012
@@ -0,0 +1,129 @@
+/*
+ *  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.version;
+
+import java.lang.reflect.Method;
+import java.util.List;
+
+import junit.framework.Assert;
+
+import org.jmock.Expectations;
+
+import org.apache.isis.core.commons.matchers.IsisMatchers;
+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.metamodel.spec.ObjectSpecification;
+import org.apache.isis.core.metamodel.spec.feature.OneToOneAssociation;
+import org.apache.isis.core.progmodel.facets.AbstractFacetFactoryTest;
+import org.apache.isis.core.progmodel.facets.members.disable.DisabledFacet;
+import org.apache.isis.core.testsupport.jmock.JUnitRuleMockery2;
+import org.apache.isis.core.testsupport.jmock.JUnitRuleMockery2.Mode;
+
+public class GivenJdoVersionAnnotationFacetFactoryTest extends AbstractFacetFactoryTest {
+
+    private JdoVersionAnnotationFacetFactory facetFactory;
+
+    public JUnitRuleMockery2 context = JUnitRuleMockery2.createFor(Mode.INTERFACES_AND_CLASSES);
+
+    private ObjectSpecification objectSpec;
+    private OneToOneAssociation versionOtoa;
+
+    @Override
+    protected void setUp() throws Exception {
+        super.setUp();
+
+        objectSpec = context.mock(ObjectSpecification.class);
+        versionOtoa = context.mock(OneToOneAssociation.class);
+        
+        context.checking(new Expectations() {
+            {
+                allowing(objectSpec).getAssociation("versionColumn");
+                will(returnValue(versionOtoa));
+
+                allowing(objectSpec).getAssociation("nonExistentColumn");
+                will(returnValue(null));
+
+                allowing(versionOtoa).getId();
+                will(returnValue("versionColumn"));
+            }
+        });
+        facetFactory = new JdoVersionAnnotationFacetFactory();
+    }
+
+    @Override
+    protected void tearDown() throws Exception {
+        facetFactory = null;
+        super.tearDown();
+    }
+
+    public void testFeatureTypes() {
+        final List<FeatureType> featureTypes = facetFactory.getFeatureTypes();
+        assertTrue(contains(featureTypes, FeatureType.OBJECT));
+        assertFalse(contains(featureTypes, FeatureType.PROPERTY));
+        assertFalse(contains(featureTypes, FeatureType.COLLECTION));
+        assertFalse(contains(featureTypes, FeatureType.ACTION));
+        assertFalse(contains(featureTypes, FeatureType.ACTION_PARAMETER));
+    }
+
+    public void testVersionFacetAndRelatedInstalledOnProperty() throws Exception {
+
+        context.checking(new Expectations() {
+            {
+                one(versionOtoa).addFacet(with(IsisMatchers.anInstanceOf(JdoVersionFacetAnnotation.class)));
+                one(versionOtoa).addFacet(with(IsisMatchers.anInstanceOf(DisabledFacetDerivedFromJdoVersionAnnotation.class)));
+                one(versionOtoa).addFacet(with(IsisMatchers.anInstanceOf(OptionalFacetDerivedFromJdoVersionAnnotation.class)));
+            }
+        });
+
+        final Class<?> cls = SimpleObjectWithVersionAnnotation.class;
+        facetFactory.process(new FacetFactory.ProcessClassContext(cls, methodRemover, objectSpec));
+
+        assertNoMethodsRemoved();
+    }
+
+    public void testIfInvalidVersionAnnotationThenThrowsException() throws Exception {
+
+        final Class<?> cls = SimpleObjectWithInvalidVersionAnnotation.class;
+        try {
+            facetFactory.process(new FacetFactory.ProcessClassContext(cls, methodRemover, objectSpec));
+            fail();
+        } catch(RuntimeException ex) {
+            // expected
+        }
+    }
+
+    public void testIfNoVersionAnnotationThenNoVersionFacet() throws Exception {
+
+        final Class<?> cls = SimpleObjectWithNoVersionAnnotation.class;
+        facetFactory.process(new FacetFactory.ProcessClassContext(cls, methodRemover, objectSpec));
+
+        assertNull(facetedMethod.getFacet(JdoVersionFacet.class));
+    }
+
+    public void testIfNoTransientAnnotationThenNoDisabledFacet() throws Exception {
+
+        final Class<?> cls = SimpleObjectWithNoVersionAnnotation.class;
+        facetFactory.process(new FacetFactory.ProcessClassContext(cls, methodRemover, objectSpec));
+
+        assertNull(facetedMethod.getFacet(DisabledFacet.class));
+    }
+
+}

Added: incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-metamodel/src/test/java/org/apache/isis/runtimes/dflt/objectstores/jdo/metamodel/facets/object/version/SimpleObjectWithInvalidVersionAnnotation.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-metamodel/src/test/java/org/apache/isis/runtimes/dflt/objectstores/jdo/metamodel/facets/object/version/SimpleObjectWithInvalidVersionAnnotation.java?rev=1357438&view=auto
==============================================================================
--- incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-metamodel/src/test/java/org/apache/isis/runtimes/dflt/objectstores/jdo/metamodel/facets/object/version/SimpleObjectWithInvalidVersionAnnotation.java (added)
+++ incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-metamodel/src/test/java/org/apache/isis/runtimes/dflt/objectstores/jdo/metamodel/facets/object/version/SimpleObjectWithInvalidVersionAnnotation.java Wed Jul  4 23:10:27 2012
@@ -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.version;
+
+import javax.jdo.annotations.Version;
+
+@Version(column="nonExistentColumn")
+public class SimpleObjectWithInvalidVersionAnnotation {
+
+
+    private Long versionColumn;
+
+    public Long getVersionColumn() {
+        return versionColumn;
+    }
+
+    public void setVersionColumn(final Long versionColumn) {
+        this.versionColumn = versionColumn;
+    }
+}
\ No newline at end of file

Added: incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-metamodel/src/test/java/org/apache/isis/runtimes/dflt/objectstores/jdo/metamodel/facets/object/version/SimpleObjectWithNoVersionAnnotation.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-metamodel/src/test/java/org/apache/isis/runtimes/dflt/objectstores/jdo/metamodel/facets/object/version/SimpleObjectWithNoVersionAnnotation.java?rev=1357438&view=auto
==============================================================================
--- incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-metamodel/src/test/java/org/apache/isis/runtimes/dflt/objectstores/jdo/metamodel/facets/object/version/SimpleObjectWithNoVersionAnnotation.java (added)
+++ incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-metamodel/src/test/java/org/apache/isis/runtimes/dflt/objectstores/jdo/metamodel/facets/object/version/SimpleObjectWithNoVersionAnnotation.java Wed Jul  4 23:10:27 2012
@@ -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.object.version;
+
+
+public class SimpleObjectWithNoVersionAnnotation {
+
+
+    private Long versionColumn;
+
+    public Long getVersionColumn() {
+        return versionColumn;
+    }
+
+    public void setVersionColumn(final Long versionColumn) {
+        this.versionColumn = versionColumn;
+    }
+}
\ No newline at end of file

Added: incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-metamodel/src/test/java/org/apache/isis/runtimes/dflt/objectstores/jdo/metamodel/facets/object/version/SimpleObjectWithVersionAnnotation.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-metamodel/src/test/java/org/apache/isis/runtimes/dflt/objectstores/jdo/metamodel/facets/object/version/SimpleObjectWithVersionAnnotation.java?rev=1357438&view=auto
==============================================================================
--- incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-metamodel/src/test/java/org/apache/isis/runtimes/dflt/objectstores/jdo/metamodel/facets/object/version/SimpleObjectWithVersionAnnotation.java (added)
+++ incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-metamodel/src/test/java/org/apache/isis/runtimes/dflt/objectstores/jdo/metamodel/facets/object/version/SimpleObjectWithVersionAnnotation.java Wed Jul  4 23:10:27 2012
@@ -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.version;
+
+import javax.jdo.annotations.Version;
+
+@Version(column="versionColumn")
+public class SimpleObjectWithVersionAnnotation {
+
+
+    private Long versionColumn;
+
+    public Long getVersionColumn() {
+        return versionColumn;
+    }
+
+    public void setVersionColumn(final Long versionColumn) {
+        this.versionColumn = versionColumn;
+    }
+}
\ No newline at end of file

Added: incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-metamodel/src/test/java/org/apache/isis/runtimes/dflt/objectstores/jdo/metamodel/facets/prop/primarykey/GivenJdoPrimaryKeyAnnotationFacetFactoryTest.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-metamodel/src/test/java/org/apache/isis/runtimes/dflt/objectstores/jdo/metamodel/facets/prop/primarykey/GivenJdoPrimaryKeyAnnotationFacetFactoryTest.java?rev=1357438&view=auto
==============================================================================
--- incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-metamodel/src/test/java/org/apache/isis/runtimes/dflt/objectstores/jdo/metamodel/facets/prop/primarykey/GivenJdoPrimaryKeyAnnotationFacetFactoryTest.java (added)
+++ incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-metamodel/src/test/java/org/apache/isis/runtimes/dflt/objectstores/jdo/metamodel/facets/prop/primarykey/GivenJdoPrimaryKeyAnnotationFacetFactoryTest.java Wed Jul  4 23:10:27 2012
@@ -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.disable.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();
+    }
+}

Added: incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-metamodel/src/test/java/org/apache/isis/runtimes/dflt/objectstores/jdo/metamodel/facets/prop/primarykey/SimpleObjectWithPrimaryKey.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-metamodel/src/test/java/org/apache/isis/runtimes/dflt/objectstores/jdo/metamodel/facets/prop/primarykey/SimpleObjectWithPrimaryKey.java?rev=1357438&view=auto
==============================================================================
--- incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-metamodel/src/test/java/org/apache/isis/runtimes/dflt/objectstores/jdo/metamodel/facets/prop/primarykey/SimpleObjectWithPrimaryKey.java (added)
+++ incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-metamodel/src/test/java/org/apache/isis/runtimes/dflt/objectstores/jdo/metamodel/facets/prop/primarykey/SimpleObjectWithPrimaryKey.java Wed Jul  4 23:10:27 2012
@@ -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

Added: incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/src/docbkx/images/admons/blank.png
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/src/docbkx/images/admons/blank.png?rev=1357438&view=auto
==============================================================================
Binary file - no diff available.

Propchange: incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/src/docbkx/images/admons/blank.png
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/src/docbkx/images/admons/caution.gif
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/src/docbkx/images/admons/caution.gif?rev=1357438&view=auto
==============================================================================
Binary file - no diff available.

Propchange: incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/src/docbkx/images/admons/caution.gif
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/src/docbkx/images/admons/caution.png
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/src/docbkx/images/admons/caution.png?rev=1357438&view=auto
==============================================================================
Binary file - no diff available.

Propchange: incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/src/docbkx/images/admons/caution.png
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/src/docbkx/images/admons/caution.tif
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/src/docbkx/images/admons/caution.tif?rev=1357438&view=auto
==============================================================================
Binary file - no diff available.

Propchange: incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/src/docbkx/images/admons/caution.tif
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/src/docbkx/images/admons/draft.png
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/src/docbkx/images/admons/draft.png?rev=1357438&view=auto
==============================================================================
Binary file - no diff available.

Propchange: incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/src/docbkx/images/admons/draft.png
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/src/docbkx/images/admons/home.gif
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/src/docbkx/images/admons/home.gif?rev=1357438&view=auto
==============================================================================
Binary file - no diff available.

Propchange: incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/src/docbkx/images/admons/home.gif
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/src/docbkx/images/admons/home.png
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/src/docbkx/images/admons/home.png?rev=1357438&view=auto
==============================================================================
Binary file - no diff available.

Propchange: incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/src/docbkx/images/admons/home.png
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/src/docbkx/images/admons/important.gif
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/src/docbkx/images/admons/important.gif?rev=1357438&view=auto
==============================================================================
Binary file - no diff available.

Propchange: incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/src/docbkx/images/admons/important.gif
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/src/docbkx/images/admons/important.png
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/src/docbkx/images/admons/important.png?rev=1357438&view=auto
==============================================================================
Binary file - no diff available.

Propchange: incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/src/docbkx/images/admons/important.png
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/src/docbkx/images/admons/important.tif
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/src/docbkx/images/admons/important.tif?rev=1357438&view=auto
==============================================================================
Binary file - no diff available.

Propchange: incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/src/docbkx/images/admons/important.tif
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/src/docbkx/images/admons/next.gif
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/src/docbkx/images/admons/next.gif?rev=1357438&view=auto
==============================================================================
Binary file - no diff available.

Propchange: incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/src/docbkx/images/admons/next.gif
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/src/docbkx/images/admons/next.png
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/src/docbkx/images/admons/next.png?rev=1357438&view=auto
==============================================================================
Binary file - no diff available.

Propchange: incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/src/docbkx/images/admons/next.png
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/src/docbkx/images/admons/note.gif
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/src/docbkx/images/admons/note.gif?rev=1357438&view=auto
==============================================================================
Binary file - no diff available.

Propchange: incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/src/docbkx/images/admons/note.gif
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream