changeset 102:68e759210b53

add option in getSource/TargetRelations() to match all object classes with "*".
author Robert Casties <casties@mpiwg-berlin.mpg.de>
date Fri, 09 Nov 2018 15:12:17 +0100
parents c418851eeb86
children 1149eb948036
files src/main/java/org/mpi/openmind/repository/bo/Entity.java
diffstat 1 files changed, 12 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/src/main/java/org/mpi/openmind/repository/bo/Entity.java	Fri Nov 09 13:53:27 2018 +0100
+++ b/src/main/java/org/mpi/openmind/repository/bo/Entity.java	Fri Nov 09 15:12:17 2018 +0100
@@ -178,6 +178,8 @@
     /**
      * Returns a list of source Relations of this Entity with the given relation name and target object class.
      * 
+     * tarObjClass="*" accepts all target objects.
+     * 
      * @param relationName
      * @param tarObjClass
      * @return
@@ -189,8 +191,10 @@
                 throw new IllegalAccessException("This Entity is lightweight, so its relations and attributes were not loaded from the DB.");
             }
             for (Relation relation : this.getSourceRelations()) {
-                if (relation.getOwnValue().equals(relationName) && relation.getTargetObjectClass().equals(tarObjClass)) {
-                    list.add(relation);
+                if (relation.getObjectClass().equals(relationName)) {
+                	if (tarObjClass.equals("*") || relation.getTargetObjectClass().equals(tarObjClass)) {
+                		list.add(relation);
+                    }
                 }
             }
         } catch (Exception e) {
@@ -202,6 +206,8 @@
     /**
      * Returns a list of target Relations of this Entity with the given relation name and source object class.
      * 
+     * srcObjClass="*" accepts all source objects.
+     * 
      * @param relationName
      * @param srcObjClass
      * @return
@@ -213,8 +219,10 @@
                 throw new IllegalAccessException("This Entity is lightweight, so its relations and attributes were not loaded from the DB.");
             }
             for (Relation relation : this.getTargetRelations()) {
-                if (relation.getOwnValue().equals(relationName) && relation.getSourceObjectClass().equals(srcObjClass)) {
-                    list.add(relation);
+                if (relation.getObjectClass().equals(relationName)) {
+                	if (srcObjClass.equals("*") || relation.getSourceObjectClass().equals(srcObjClass)) {
+                		list.add(relation);
+                    }
                 }
             }
         } catch (Exception e) {