You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@isis.apache.org by ah...@apache.org on 2021/02/19 08:10:05 UTC
[isis] branch master updated: ISIS-2535: handle
@PersistenceCapable(schema=...) when classifying bean types
This is an automated email from the ASF dual-hosted git repository.
ahuber pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/isis.git
The following commit(s) were added to refs/heads/master by this push:
new e642cf2 ISIS-2535: handle @PersistenceCapable(schema=...) when classifying bean types
e642cf2 is described below
commit e642cf27f4887600873ba89e438f86c25c49dc68
Author: Andi Huber <ah...@apache.org>
AuthorDate: Fri Feb 19 09:09:50 2021 +0100
ISIS-2535: handle @PersistenceCapable(schema=...) when classifying bean
types
also remove duplicated class
---
.../integration/config/JdoBeanTypeClassifier.java | 58 ----------------------
.../metamodel/JdoPrimaryKeyPropertyPredicate.java | 2 +-
.../jdo/metamodel/beans/JdoBeanTypeClassifier.java | 7 +++
3 files changed, 8 insertions(+), 59 deletions(-)
diff --git a/persistence/jdo/integration/src/main/java/org/apache/isis/persistence/jdo/integration/config/JdoBeanTypeClassifier.java b/persistence/jdo/integration/src/main/java/org/apache/isis/persistence/jdo/integration/config/JdoBeanTypeClassifier.java
deleted file mode 100644
index aaf0392..0000000
--- a/persistence/jdo/integration/src/main/java/org/apache/isis/persistence/jdo/integration/config/JdoBeanTypeClassifier.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * 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.persistence.jdo.integration.config;
-
-import javax.jdo.annotations.EmbeddedOnly;
-
-import org.apache.isis.applib.services.metamodel.BeanSort;
-import org.apache.isis.core.config.beans.IsisBeanTypeClassifier;
-import org.apache.isis.core.metamodel.facets.Annotations;
-
-import static org.apache.isis.commons.internal.reflection._Annotations.findNearestAnnotation;
-
-import lombok.val;
-
-/**
- * ServiceLoader plugin, classifies PersistenceCapable types into {@link BeanSort#ENTITY}
- * @since 2.0
- */
-public class JdoBeanTypeClassifier implements IsisBeanTypeClassifier {
-
- @Override
- public BeanClassification classify(Class<?> type) {
-
- val persistenceCapableAnnot = findNearestAnnotation(type, javax.jdo.annotations.PersistenceCapable.class);
- if(persistenceCapableAnnot.isPresent()) {
-
- val embeddedOnlyAttribute = persistenceCapableAnnot.get().embeddedOnly();
- // Whether objects of this type can only be embedded,
- // hence have no ID that binds them to the persistence layer
- final boolean embeddedOnly = Boolean.valueOf(embeddedOnlyAttribute)
- || Annotations.getAnnotation(type, EmbeddedOnly.class)!=null;
- if(embeddedOnly) {
- return null; // don't categorize as entity ... fall through in the caller's logic
- }
-
- return BeanClassification.selfManaged(BeanSort.ENTITY);
- }
-
- return null; // we don't feel responsible to classify given type
- }
-
-}
diff --git a/persistence/jdo/integration/src/main/java/org/apache/isis/persistence/jdo/integration/metamodel/JdoPrimaryKeyPropertyPredicate.java b/persistence/jdo/integration/src/main/java/org/apache/isis/persistence/jdo/integration/metamodel/JdoPrimaryKeyPropertyPredicate.java
index 2054c7a..27fc4fd 100644
--- a/persistence/jdo/integration/src/main/java/org/apache/isis/persistence/jdo/integration/metamodel/JdoPrimaryKeyPropertyPredicate.java
+++ b/persistence/jdo/integration/src/main/java/org/apache/isis/persistence/jdo/integration/metamodel/JdoPrimaryKeyPropertyPredicate.java
@@ -33,7 +33,7 @@ import org.apache.isis.persistence.jdo.provider.metamodel.facets.prop.primarykey
* Use to locate the property annotated with {@link PrimaryKey}.
* <p>
* In addition, must also be a {@link OneToOneAssociation}, and can be
- * {@link PropertyAccessorFacet read}.
+ * {@link PropertyOrCollectionAccessorFacet read}.
* <p>
* Note that it is NOT necessary for there to be a facet to
* {@link PropertySetterFacet set} the property.
diff --git a/persistence/jdo/metamodel/src/main/java/org/apache/isis/persistence/jdo/metamodel/beans/JdoBeanTypeClassifier.java b/persistence/jdo/metamodel/src/main/java/org/apache/isis/persistence/jdo/metamodel/beans/JdoBeanTypeClassifier.java
index 210232e..3704f76 100644
--- a/persistence/jdo/metamodel/src/main/java/org/apache/isis/persistence/jdo/metamodel/beans/JdoBeanTypeClassifier.java
+++ b/persistence/jdo/metamodel/src/main/java/org/apache/isis/persistence/jdo/metamodel/beans/JdoBeanTypeClassifier.java
@@ -21,6 +21,7 @@ package org.apache.isis.persistence.jdo.metamodel.beans;
import javax.jdo.annotations.EmbeddedOnly;
import org.apache.isis.applib.services.metamodel.BeanSort;
+import org.apache.isis.commons.internal.base._Strings;
import org.apache.isis.core.config.beans.IsisBeanTypeClassifier;
import org.apache.isis.core.metamodel.facets.Annotations;
@@ -49,6 +50,12 @@ public class JdoBeanTypeClassifier implements IsisBeanTypeClassifier {
return null; // don't categorize as entity ... fall through in the caller's logic
}
+ val schema = persistenceCapableAnnot.get().schema();
+ if(_Strings.isNotEmpty(schema)) {
+ BeanClassification.selfManaged(
+ BeanSort.ENTITY,
+ String.format("%s.%s", schema, type.getSimpleName()));
+ }
return BeanClassification.selfManaged(BeanSort.ENTITY);
}