]> gerrit.simantics Code Review - simantics/platform.git/commitdiff
Merge changes I764df2ec,Ieb979991
authorTuukka Lehtonen <tuukka.lehtonen@semantum.fi>
Wed, 14 Aug 2019 10:46:03 +0000 (10:46 +0000)
committerGerrit Code Review <gerrit2@simantics>
Wed, 14 Aug 2019 10:46:03 +0000 (10:46 +0000)
* changes:
  Switch from org.apache.log4j to org.slf4j.
  Added missing creation of RelatedElementRuleFactory.

25 files changed:
bundles/org.simantics.objmap2/META-INF/MANIFEST.MF
bundles/org.simantics.objmap2/src/org/simantics/objmap/graph/annotations/factories/UpdateMethodFactory.java
bundles/org.simantics.objmap2/src/org/simantics/objmap/graph/impl/Mapping.java
bundles/org.simantics.objmap2/src/org/simantics/objmap/graph/rules/MappedElementRule.java
bundles/org.simantics.objmap2/src/org/simantics/objmap/graph/rules/MappedElementsRule.java
bundles/org.simantics.objmap2/src/org/simantics/objmap/graph/rules/ValueRule.java
bundles/org.simantics.objmap2/src/org/simantics/objmap/graph/rules/domain/CompoundValueAccessor.java
bundles/org.simantics.objmap2/src/org/simantics/objmap/graph/rules/domain/MappingUtils.java
bundles/org.simantics.objmap2/src/org/simantics/objmap/graph/rules/domain/RelatedObjectAccessor.java
bundles/org.simantics.objmap2/src/org/simantics/objmap/graph/rules/domain/RelatedObjectsAccessor.java
bundles/org.simantics.objmap2/src/org/simantics/objmap/graph/rules/domain/RelatedOrderedSetElementsAccessor.java
bundles/org.simantics.objmap2/src/org/simantics/objmap/graph/rules/domain/RelatedValueAccessor.java
bundles/org.simantics.objmap2/src/org/simantics/objmap/graph/rules/range/FieldAccessor.java
bundles/org.simantics.objmap2/src/org/simantics/objmap/graph/schema/AdaptedLinkType.java
bundles/org.simantics.objmap2/src/org/simantics/objmap/graph/schema/MappingSchemas.java
bundles/org.simantics.objmap2/src/org/simantics/objmap/graph/schema/SimpleLinkType.java
bundles/org.simantics.objmap2/src/org/simantics/objmap/structural/annotations/factories/UpdateMethodFactory.java
bundles/org.simantics.objmap2/src/org/simantics/objmap/structural/rules/domain/RelatedObjectAccessor.java
bundles/org.simantics.objmap2/src/org/simantics/objmap/structural/rules/domain/RelatedObjectsAccessor.java
bundles/org.simantics.objmap2/src/org/simantics/objmap/structural/rules/domain/RelatedOrderedSetElementsAccessor.java
bundles/org.simantics.objmap2/src/org/simantics/objmap/structural/rules/domain/RelatedValueAccessor.java
bundles/org.simantics.objmap2/src/org/simantics/objmap/structural/rules/domain/StructuralRelatedObjectAccessor.java
bundles/org.simantics.objmap2/src/org/simantics/objmap/structural/rules/domain/StructuralRelatedObjectsAccessor.java
bundles/org.simantics.objmap2/src/org/simantics/objmap/structural/schema/AdaptedLinkType.java
bundles/org.simantics.objmap2/src/org/simantics/objmap/structural/schema/SimpleLinkType.java

index efd050e10959b97df1d4420dde9f0140e7d9dbdd..db84bf0c590ba30cc6a203dc614ddb4f151d07d8 100644 (file)
@@ -8,9 +8,9 @@ Require-Bundle: org.simantics.db;bundle-version="1.1.0",
  gnu.trove3;bundle-version="3.0.0",
  org.eclipse.core.runtime;bundle-version="3.7.0",
  org.simantics.layer0;bundle-version="1.0.0",
- org.apache.log4j;bundle-version="1.2.15",
  org.simantics.db.common;bundle-version="1.1.0",
- org.simantics.structural.ontology;bundle-version="1.1.0"
+ org.simantics.structural.ontology;bundle-version="1.1.0",
+ org.slf4j.api
 Export-Package: org.simantics.objmap.backward,
  org.simantics.objmap.bidirectional,
  org.simantics.objmap.exceptions,
index 10f64be78d5eef552a2c3a7f7fc69cb41894ceb6..b201176261496f98942dbd31edc9e1597db68cf1 100644 (file)
@@ -14,7 +14,8 @@ package org.simantics.objmap.graph.annotations.factories;
 import java.lang.annotation.Annotation;
 import java.lang.reflect.Method;
 
-import org.apache.log4j.Logger;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.simantics.db.ReadGraph;
 import org.simantics.db.WriteGraph;
 import org.simantics.db.exception.DatabaseException;
@@ -26,7 +27,7 @@ import org.simantics.objmap.graph.rules.factory.IMethodRuleFactory;
 
 public class UpdateMethodFactory<Domain, Range> implements IMethodRuleFactory<Domain, Range> {
 
-    static Logger LOGGER = Logger.getLogger("org.simantics.objmap");
+    static Logger LOGGER = LoggerFactory.getLogger(UpdateMethodFactory.class);
     
     @Override
     public IBidirectionalMappingRule<Domain, Range> create(ReadGraph g, 
index f105a2894c42866f6ccca0cf6d8650c2dc36b406..9f048f7752b1a900a1730eae5242d53519d21a8b 100644 (file)
@@ -21,7 +21,8 @@ import java.util.Iterator;
 import java.util.List;
 import java.util.Set;
 
-import org.apache.log4j.Logger;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.simantics.db.ReadGraph;
 import org.simantics.db.WriteGraph;
 import org.simantics.db.exception.DatabaseException;
@@ -42,7 +43,7 @@ import org.simantics.objmap.graph.schema.IMappingSchema;
  */
 public class Mapping<Domain, Range> implements IMapping<Domain, Range> {
 
-       static Logger LOGGER = Logger.getLogger("org.simantics.objmap");
+       static final Logger LOGGER = LoggerFactory.getLogger(Mapping.class);
        
        
        IMappingSchema<Domain, Range> schema;
index 3b6fac31d4299f9d75efb5d41a2f2391aa137b75..5e4eec39feb51cc768c15d31de1bc8633ba706b2 100644 (file)
@@ -11,7 +11,6 @@
  *******************************************************************************/
 package org.simantics.objmap.graph.rules;
 
-import org.apache.log4j.Logger;
 import org.simantics.db.ReadGraph;
 import org.simantics.db.WriteGraph;
 import org.simantics.objmap.backward.IBackwardMapping;
@@ -20,9 +19,8 @@ import org.simantics.objmap.exceptions.MappingException;
 import org.simantics.objmap.forward.IForwardMapping;
 import org.simantics.objmap.graph.rules.domain.IDomainAccessor;
 import org.simantics.objmap.graph.rules.range.IRangeAccessor;
-
-
-
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * A rule that synchronizes collection of elements between
@@ -32,7 +30,7 @@ import org.simantics.objmap.graph.rules.range.IRangeAccessor;
  */
 public class MappedElementRule<Domain, Range> implements IBidirectionalMappingRule<Domain, Range> {
     
-    static Logger LOGGER = Logger.getLogger("org.simantics.objmap");
+    static final Logger LOGGER = LoggerFactory.getLogger(MappedElementRule.class);
     
        IDomainAccessor<Domain,Domain> domainAccessor;
        IRangeAccessor<Range,Range> rangeAccessor;
index cd295e583d426b08f5fd9d163bf6b0f9c17b6564..43a8ff49325fc46436954243092c5a22e391998b 100644 (file)
@@ -14,7 +14,6 @@ package org.simantics.objmap.graph.rules;
 import java.util.ArrayList;
 import java.util.Collection;
 
-import org.apache.log4j.Logger;
 import org.simantics.db.ReadGraph;
 import org.simantics.db.WriteGraph;
 import org.simantics.objmap.backward.IBackwardMapping;
@@ -23,6 +22,8 @@ import org.simantics.objmap.exceptions.MappingException;
 import org.simantics.objmap.forward.IForwardMapping;
 import org.simantics.objmap.graph.rules.domain.IDomainAccessor;
 import org.simantics.objmap.graph.rules.range.IRangeAccessor;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 
 /**
@@ -33,7 +34,7 @@ import org.simantics.objmap.graph.rules.range.IRangeAccessor;
  */
 public class MappedElementsRule<Domain, Range> implements IBidirectionalMappingRule<Domain, Range> {
 
-    static Logger LOGGER = Logger.getLogger("org.simantics.objmap");
+    static final Logger LOGGER = LoggerFactory.getLogger(MappedElementsRule.class);
 
     IDomainAccessor<Domain,Collection<Domain>> domainAccessor;
     IRangeAccessor<Range,Collection<Range>> rangeAccessor;
index 718bc7c2d780ec46ded879a5416cf37d6051a7a1..d40c44f2b3287975c1d9c12a2e791048a83be1d7 100644 (file)
@@ -11,7 +11,8 @@
  *******************************************************************************/
 package org.simantics.objmap.graph.rules;
 
-import org.apache.log4j.Logger;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.simantics.db.ReadGraph;
 import org.simantics.db.WriteGraph;
 import org.simantics.objmap.backward.IBackwardMapping;
@@ -29,7 +30,7 @@ import org.simantics.objmap.graph.rules.range.IRangeAccessor;
  */
 public class ValueRule<Domain, Range> implements IBidirectionalMappingRule<Domain, Range> {
     
-    static Logger LOGGER = Logger.getLogger("org.simantics.objmap");
+    static Logger LOGGER = LoggerFactory.getLogger(ValueRule.class);
     
        IDomainAccessor<Domain,Object> domainAccessor;
        IRangeAccessor<Range,Object> rangeAccessor;
index 78b48430310356fd0c4f0561aaefb0736f8f907d..1c7e267c7d869d80cc6d89743b0683c015cd5468 100644 (file)
@@ -16,7 +16,6 @@ import java.util.Collection;
 import java.util.HashMap;
 import java.util.Map;
 
-import org.apache.log4j.Logger;
 import org.simantics.db.ReadGraph;
 import org.simantics.db.Resource;
 import org.simantics.db.Statement;
@@ -25,6 +24,8 @@ import org.simantics.db.exception.DatabaseException;
 import org.simantics.layer0.Layer0;
 import org.simantics.objmap.exceptions.MappingException;
 import org.simantics.objmap.graph.annotations.factories.CompoundRelatedGetSetValueRuleFactory;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * 
@@ -32,7 +33,7 @@ import org.simantics.objmap.graph.annotations.factories.CompoundRelatedGetSetVal
  */
 public class CompoundValueAccessor implements IDomainAccessor<Resource,Object> {
 
-    static Logger LOGGER = Logger.getLogger("org.simantics.objmap");
+    static final Logger LOGGER = LoggerFactory.getLogger(CompoundValueAccessor.class);
     
        Resource objRelation;
        Resource objType;
index a0d0d4dac2df176cc881fb9759f4173a911a1db1..dbda44e34f837578692e70d2906b4bf304ed86ba 100644 (file)
@@ -14,7 +14,8 @@ package org.simantics.objmap.graph.rules.domain;
 import java.util.Arrays;
 import java.util.Collection;
 
-import org.apache.log4j.Logger;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.simantics.db.Resource;
 import org.simantics.db.WriteGraph;
 import org.simantics.db.exception.DatabaseException;
@@ -25,7 +26,7 @@ import org.simantics.db.exception.DatabaseException;
  */
 public class MappingUtils {
 
-    static Logger LOGGER = Logger.getLogger("org.simantics.objmap");
+    static final Logger LOGGER = LoggerFactory.getLogger(MappingUtils.class);
     
     /**
      * Adds and removes statements to/from the database so that <code>objects</code>
index 99253790cf0e0f0611eadcf06c9f297189882892..2cfc98185f5b3cd842255363c8a17e71f5bf3b07 100644 (file)
@@ -11,7 +11,8 @@
  *******************************************************************************/
 package org.simantics.objmap.graph.rules.domain;
 
-import org.apache.log4j.Logger;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.simantics.db.ReadGraph;
 import org.simantics.db.Resource;
 import org.simantics.db.WriteGraph;
@@ -24,7 +25,7 @@ import org.simantics.objmap.exceptions.MappingException;
  */
 public class RelatedObjectAccessor implements IDomainAccessor<Resource,Resource> {
 
-    static Logger LOGGER = Logger.getLogger("org.simantics.objmap");
+    static Logger LOGGER = LoggerFactory.getLogger(RelatedObjectAccessor.class);
     
        Resource relation;
        
index 9653ab370c28f5dc058b6be7e09edd6074c02743..d8002d976022398ff7196fbd43606c26d79ba257 100644 (file)
@@ -13,7 +13,8 @@ package org.simantics.objmap.graph.rules.domain;
 
 import java.util.Collection;
 
-import org.apache.log4j.Logger;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.simantics.db.ReadGraph;
 import org.simantics.db.Resource;
 import org.simantics.db.WriteGraph;
@@ -26,7 +27,7 @@ import org.simantics.objmap.exceptions.MappingException;
  */
 public class RelatedObjectsAccessor implements IDomainAccessor<Resource,Collection<Resource>> {
 
-    static Logger LOGGER = Logger.getLogger("org.simantics.objmap");
+    static Logger LOGGER = LoggerFactory.getLogger(RelatedObjectsAccessor.class);
     
        Resource relation;
        boolean deleteExtraObjects;
index c033751e506eb7797e92918257520b8463203d6d..a272b4f0bc4dd0786688d6ff25719089ee1545f0 100644 (file)
@@ -13,7 +13,8 @@ package org.simantics.objmap.graph.rules.domain;
 
 import java.util.Collection;
 
-import org.apache.log4j.Logger;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.simantics.db.ReadGraph;
 import org.simantics.db.Resource;
 import org.simantics.db.WriteGraph;
@@ -27,7 +28,7 @@ import org.simantics.objmap.exceptions.MappingException;
  */
 public class RelatedOrderedSetElementsAccessor implements IDomainAccessor<Resource, Collection<Resource>> {
 
-    static Logger LOGGER = Logger.getLogger("org.simantics.objmap");
+    static Logger LOGGER = LoggerFactory.getLogger(RelatedOrderedSetElementsAccessor.class);
     
        boolean deleteExtraObjects;
 
index d5ad40b77cd8f82f2369978872c7e967e24aac7d..9ede881774873f5c8ba6feabe8bcec4a13f878fc 100644 (file)
@@ -13,7 +13,8 @@ package org.simantics.objmap.graph.rules.domain;
 
 import java.util.Arrays;
 
-import org.apache.log4j.Logger;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.simantics.db.ReadGraph;
 import org.simantics.db.Resource;
 import org.simantics.db.Statement;
@@ -28,7 +29,7 @@ import org.simantics.objmap.exceptions.MappingException;
  */
 public class RelatedValueAccessor implements IDomainAccessor<Resource,Object> {
 
-    static Logger LOGGER = Logger.getLogger("org.simantics.objmap");
+    static Logger LOGGER = LoggerFactory.getLogger(RelatedValueAccessor.class);
     
        Resource relation;
        Resource valueType;
index 6615e94fb41edf507f55e646cbb9b539bca679c0..278c35a89503a32798b22b6fd31054836d385f98 100644 (file)
@@ -13,8 +13,9 @@ package org.simantics.objmap.graph.rules.range;
 
 import java.lang.reflect.Field;
 
-import org.apache.log4j.Logger;
 import org.simantics.objmap.exceptions.MappingException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 
 /**
@@ -23,7 +24,7 @@ import org.simantics.objmap.exceptions.MappingException;
  */
 public class FieldAccessor<Range,T> implements IRangeAccessor<Range,T> {
     
-    static Logger LOGGER = Logger.getLogger("org.simantics.objmap");
+    static final Logger LOGGER = LoggerFactory.getLogger(FieldAccessor.class);
     
        Field field;
 
index 046a744cf4d332cac824bd03b2429ad959d20fc7..9b02d5d50c9bec9d4bcb77ed9a1277fd6c015267 100644 (file)
@@ -11,7 +11,7 @@
  *******************************************************************************/
 package org.simantics.objmap.graph.schema;
 
-//import org.apache.log4j.Logger;
+//import org.slf4j.Logger;
 import org.eclipse.core.runtime.IAdaptable;
 import org.simantics.db.ReadGraph;
 import org.simantics.db.Resource;
index 871d46bdaebce02c458098fa1b690717fc9ed741..56aa5da205ed21fb0cde31f9e3fd325d18a0a7f3 100644 (file)
@@ -30,6 +30,7 @@ import org.simantics.objmap.graph.annotations.HasSetter;
 import org.simantics.objmap.graph.annotations.OptionalRelatedElements;
 import org.simantics.objmap.graph.annotations.OrderedElementsGet;
 import org.simantics.objmap.graph.annotations.OrderedSetType;
+import org.simantics.objmap.graph.annotations.RelatedElement;
 import org.simantics.objmap.graph.annotations.RelatedElements;
 import org.simantics.objmap.graph.annotations.RelatedElementsGet;
 import org.simantics.objmap.graph.annotations.RelatedGetObj;
@@ -40,6 +41,7 @@ import org.simantics.objmap.graph.annotations.UpdateMethod;
 import org.simantics.objmap.graph.annotations.factories.CompoundRelatedGetSetValueRuleFactory;
 import org.simantics.objmap.graph.annotations.factories.OptionalRelatedElementsRuleFactory;
 import org.simantics.objmap.graph.annotations.factories.OrderedElementsRuleFactory;
+import org.simantics.objmap.graph.annotations.factories.RelatedElementRuleFactory;
 import org.simantics.objmap.graph.annotations.factories.RelatedElementsRuleFactory;
 import org.simantics.objmap.graph.annotations.factories.RelatedElementsRuleFactory2;
 import org.simantics.objmap.graph.annotations.factories.RelatedGetSetObjRuleFactory;
@@ -57,52 +59,60 @@ import org.simantics.objmap.graph.rules.factory.ICollectionRuleFactory;
 import org.simantics.objmap.graph.rules.factory.IFieldRuleFactory;
 import org.simantics.objmap.graph.rules.factory.IGetSetRuleFactory;
 import org.simantics.objmap.graph.rules.factory.IMethodRuleFactory;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 
 public class MappingSchemas {
-       /**
+    private static final Logger LOGGER = LoggerFactory.getLogger(MappingSchemas.class);
+
+    /**
      * Creates a new SimpleLinkType based on the annotations in the given class.
      * @throws IllegalAccessException 
      * @throws InstantiationException 
      * @see GraphType
      * @see RelatedValue
      */
-       public static SimpleLinkType<Object> fromAnnotations(ReadGraph g, Class<?> clazz) throws DatabaseException, InstantiationException, IllegalAccessException {
-           GraphType graphType = clazz.getAnnotation(GraphType.class);
-           
-           if (graphType != null) {
-                   ArrayList<IBidirectionalMappingRule<Resource, Object>> rules = new ArrayList<IBidirectionalMappingRule<Resource, Object>>();
-                   collectRulesFromAnnotations(g, clazz, rules);
-                   
-                   return new SimpleLinkType<Object>(g.getResource(graphType.value()), clazz, rules);  
-           }
-           DynamicGraphType dynamicType = clazz.getAnnotation(DynamicGraphType.class);
-           if (dynamicType != null) {
-               ArrayList<IBidirectionalMappingRule<Resource, Object>> rules = new ArrayList<IBidirectionalMappingRule<Resource, Object>>();
-                   collectRulesFromAnnotations(g, clazz, rules);
-                   
-                   return new DynamicSimpleLinkType<Object>(g.getResource(dynamicType.value()), clazz, rules);
-           }
-           OrderedSetType orderedSetType = clazz.getAnnotation(OrderedSetType.class);
-           if (orderedSetType != null) {
-               ArrayList<IBidirectionalMappingRule<Resource, Object>> rules = new ArrayList<IBidirectionalMappingRule<Resource, Object>>();
-                   collectRulesFromAnnotations(g, clazz, rules);
-                   
-                   return new OrderedSetSimpleLinkType<Object>(g.getResource(orderedSetType.value()), clazz, rules);
-           }
-           throw new IllegalArgumentException("Class " + clazz.toString() + " does not contain annotations.");
-       }
-       
-       public static void collectRulesFromAnnotations(ReadGraph g, Class<?> clazz, Collection<IBidirectionalMappingRule<Resource, Object>> rules) throws DatabaseException, InstantiationException, IllegalAccessException {
-           Class<?> superclass = clazz.getSuperclass();
-           if(superclass != null)
-               collectRulesFromAnnotations(g, superclass, rules);
-               
+    public static SimpleLinkType<Object> fromAnnotations(ReadGraph g, Class<?> clazz) throws DatabaseException, InstantiationException, IllegalAccessException {
+        GraphType graphType = clazz.getAnnotation(GraphType.class);
+
+        if (graphType != null) {
+            ArrayList<IBidirectionalMappingRule<Resource, Object>> rules = new ArrayList<IBidirectionalMappingRule<Resource, Object>>();
+            collectRulesFromAnnotations(g, clazz, rules);
+
+            return new SimpleLinkType<Object>(g.getResource(graphType.value()), clazz, rules);  
+        }
+        DynamicGraphType dynamicType = clazz.getAnnotation(DynamicGraphType.class);
+        if (dynamicType != null) {
+            ArrayList<IBidirectionalMappingRule<Resource, Object>> rules = new ArrayList<IBidirectionalMappingRule<Resource, Object>>();
+            collectRulesFromAnnotations(g, clazz, rules);
+
+            return new DynamicSimpleLinkType<Object>(g.getResource(dynamicType.value()), clazz, rules);
+        }
+        OrderedSetType orderedSetType = clazz.getAnnotation(OrderedSetType.class);
+        if (orderedSetType != null) {
+            ArrayList<IBidirectionalMappingRule<Resource, Object>> rules = new ArrayList<IBidirectionalMappingRule<Resource, Object>>();
+            collectRulesFromAnnotations(g, clazz, rules);
+
+            return new OrderedSetSimpleLinkType<Object>(g.getResource(orderedSetType.value()), clazz, rules);
+        }
+        throw new IllegalArgumentException("Class " + clazz.toString() + " does not contain annotations.");
+    }
+
+    public static void collectRulesFromAnnotations(ReadGraph g, Class<?> clazz, Collection<IBidirectionalMappingRule<Resource, Object>> rules) throws DatabaseException, InstantiationException, IllegalAccessException {
+        Class<?> superclass = clazz.getSuperclass();
+        if(superclass != null)
+            collectRulesFromAnnotations(g, superclass, rules);
+
         for(Annotation annotation : clazz.getAnnotations()) {
 
-               IsClassRule tag = annotation.annotationType().getAnnotation(IsClassRule.class);
+            IsClassRule tag = annotation.annotationType().getAnnotation(IsClassRule.class);
             if(tag!= null) {
-               rules.add(createClassRule(g, annotation, clazz).create(g, annotation, clazz));
+                final IClassRuleFactory<Resource, Object> ruleFactory = createClassRule(g, annotation, clazz);
+                if (ruleFactory != null)
+                    rules.add(ruleFactory.create(g, annotation, clazz));
+                else
+                    LOGGER.warn("No rule factory found for {}", annotation);
             }
         }
 
@@ -111,9 +121,13 @@ public class MappingSchemas {
 
             for(Annotation annotation : f.getAnnotations()) {
 
-               IsFieldRule tag = annotation.annotationType().getAnnotation(IsFieldRule.class);
+                IsFieldRule tag = annotation.annotationType().getAnnotation(IsFieldRule.class);
                 if(tag != null) {
-                    rules.add(createFieldRule(g, annotation, f).create(g, annotation, f));
+                    final IFieldRuleFactory<Resource, Object> ruleFactory = createFieldRule(g, annotation, f);
+                    if (ruleFactory != null)
+                        rules.add(ruleFactory.create(g, annotation, f));
+                    else
+                        LOGGER.warn("No rule factory found for {}", annotation);
                 }
             }
         }
@@ -122,140 +136,150 @@ public class MappingSchemas {
             m.setAccessible(true);
 
             for(Annotation annotation : m.getAnnotations()) {
-               IsMethodRule tag = 
+                IsMethodRule tag = 
                         annotation.annotationType().getAnnotation(IsMethodRule.class);
                 if(tag != null) {
-                       rules.add(createMethodRule(g, annotation, m).create(g, annotation, m));
+                    final IMethodRuleFactory<Resource, Object> ruleFactory = createMethodRule(g, annotation, m);
+                    if (ruleFactory != null)
+                        rules.add(ruleFactory.create(g, annotation, m));
+                    else
+                        LOGGER.warn("No rule factory found for {}", annotation);
                 }
             }
         }
-        
+
         for (Method m : clazz.getDeclaredMethods()) {
-               m.setAccessible(true);
-               for (Annotation annotation : m.getAnnotations()) {
-                       Class<? extends Annotation> annotationType = annotation.annotationType();
-
-                        IsGetSetRule tag = 
-                         annotationType.getAnnotation(IsGetSetRule.class);
-                        if (tag != null) {
-                                
-                                HasSetter setterAnnType = annotationType.getAnnotation(HasSetter.class);
-                                
-                                Class<? extends Annotation> setterAnn = setterAnnType.value();
-                                
-                                Method getter = m;
-                                
-                                IGetSetRuleFactory<Resource,Object> ruleFactory = createGetSetRuleFactory(g, annotation, getter);
-                                
-                                
-                                Method setter = null;
-                                
-                                for (Method m2 : clazz.getDeclaredMethods()) {
-                                        Annotation set = m2.getAnnotation(setterAnn);
-                                        if (set != null && ruleFactory.isSetter(annotation, set))
-                                                setter = m2;
-                                }
-
-                                rules.add(ruleFactory.create(g, annotation, getter, setter));
-                        }
-                
-               }
+            m.setAccessible(true);
+            for (Annotation annotation : m.getAnnotations()) {
+                Class<? extends Annotation> annotationType = annotation.annotationType();
+
+                IsGetSetRule tag = 
+                        annotationType.getAnnotation(IsGetSetRule.class);
+                if (tag != null) {
+
+                    HasSetter setterAnnType = annotationType.getAnnotation(HasSetter.class);
+
+                    Class<? extends Annotation> setterAnn = setterAnnType.value();
+
+                    Method getter = m;
+
+                    IGetSetRuleFactory<Resource,Object> ruleFactory = createGetSetRuleFactory(g, annotation, getter);
+                    if (ruleFactory != null) {
+                        Method setter = null;
+    
+                        for (Method m2 : clazz.getDeclaredMethods()) {
+                            Annotation set = m2.getAnnotation(setterAnn);
+                            if (set != null && ruleFactory.isSetter(annotation, set))
+                                setter = m2;
+                        }
+    
+                        rules.add(ruleFactory.create(g, annotation, getter, setter));
+                    }
+                    else {
+                        LOGGER.warn("No rule factory found for {}", annotation);
+                    }
+                }
+
+            }
         }
-        
+
         for (Method m : clazz.getDeclaredMethods()) {
-               m.setAccessible(true);
-               for (Annotation annotation : m.getAnnotations()) {
-                       Class<? extends Annotation> annotationType = annotation.annotationType();
-
-                        IsCollectionRule tag = 
-                         annotationType.getAnnotation(IsCollectionRule.class);
-                        if (tag != null) {
-                                
-                                HasCollectionAdder adderAnnType = annotationType.getAnnotation(HasCollectionAdder.class);
-                                HasCollectionRemover removerAnnType = annotationType.getAnnotation(HasCollectionRemover.class);
-                
-                                Class<? extends Annotation> adderAnn = adderAnnType.value();
-                                Class<? extends Annotation> removerAnn = removerAnnType.value();
-                                
-                                Method getter = m;
-                                
-                                ICollectionRuleFactory<Resource,Object> ruleFactory = createCollectionRuleFactory(g, annotation, getter);
-                                
-                                
-                                Method adder = null;
-                                Method remover = null;
-                                
-                                for (Method m2 : clazz.getDeclaredMethods()) {
-                                        Annotation add = m2.getAnnotation(adderAnn);
-                                        Annotation rem = m2.getAnnotation(removerAnn);
-                                        if (add != null && ruleFactory.isAdder(annotation, add))
-                                                adder = m2;
-                                        if (rem != null && ruleFactory.isRemover(annotation, rem))
-                                                remover = m2;
-                                }
-                                
-                                
-                                
-                                rules.add(ruleFactory.create(g, annotation, getter,adder,remover));
-                        }
-                
-               }
+            m.setAccessible(true);
+            for (Annotation annotation : m.getAnnotations()) {
+                Class<? extends Annotation> annotationType = annotation.annotationType();
+
+                IsCollectionRule tag = 
+                        annotationType.getAnnotation(IsCollectionRule.class);
+                if (tag != null) {
+
+                    HasCollectionAdder adderAnnType = annotationType.getAnnotation(HasCollectionAdder.class);
+                    HasCollectionRemover removerAnnType = annotationType.getAnnotation(HasCollectionRemover.class);
+
+                    Class<? extends Annotation> adderAnn = adderAnnType.value();
+                    Class<? extends Annotation> removerAnn = removerAnnType.value();
+
+                    Method getter = m;
+
+                    ICollectionRuleFactory<Resource,Object> ruleFactory = createCollectionRuleFactory(g, annotation, getter);
+                    if (ruleFactory != null) {
+                        Method adder = null;
+                        Method remover = null;
+    
+                        for (Method m2 : clazz.getDeclaredMethods()) {
+                            Annotation add = m2.getAnnotation(adderAnn);
+                            Annotation rem = m2.getAnnotation(removerAnn);
+                            if (add != null && ruleFactory.isAdder(annotation, add))
+                                adder = m2;
+                            if (rem != null && ruleFactory.isRemover(annotation, rem))
+                                remover = m2;
+                        }
+    
+                        rules.add(ruleFactory.create(g, annotation, getter,adder,remover));
+                    }
+                    else {
+                        LOGGER.warn("No rule factory found for {}", annotation);
+                    }
+                }
+
+            }
         }
     }
-       
-       public static IClassRuleFactory<Resource, Object> createClassRule(ReadGraph g, Annotation annotation, Class<?> clazz) {
-               return null;
-       }
-       
-       public static IFieldRuleFactory<Resource,Object> createFieldRule(ReadGraph g, Annotation annotation, Field field) {
-               if (annotation.annotationType().equals(RelatedElements.class))
-                       return new RelatedElementsRuleFactory<Object>();
-               if (annotation.annotationType().equals(RelatedValue.class))
-                       return new RelatedValueRuleFactory<Object>();
-               if (annotation.annotationType().equals(OptionalRelatedElements.class))
-                       return new OptionalRelatedElementsRuleFactory<Object>();
-               if (annotation.annotationType().equals(RelatedOrderedSetElements.class))
-                       return new RelatedOrderedSetElementsRuleFactory<Object>();
-               return null;
-       }
-       
-       public static IMethodRuleFactory<Resource, Object> createMethodRule(ReadGraph g, Annotation annotation, Method m) {
-               if (annotation.annotationType().equals(UpdateMethod.class))
-                       return new UpdateMethodFactory<Resource,Object>();
-               return null;
-       }
-       
-       public static IGetSetRuleFactory<Resource,Object> createGetSetRuleFactory(ReadGraph g, Annotation annotation, Method getter) {
-               if (annotation.annotationType().equals(RelatedGetValue.class))
-                       return new RelatedGetSetValueRuleFactory<Object>();
-               if (annotation.annotationType().equals(RelatedGetObj.class))
-                       return new RelatedGetSetObjRuleFactory<Object>();
-               if (annotation.annotationType().equals(CompoundRelatedGetValue.class))
-                       return new CompoundRelatedGetSetValueRuleFactory<Object>();
-               return null;
-       }
-       
-       public static ICollectionRuleFactory<Resource,Object> createCollectionRuleFactory(ReadGraph g, Annotation annotation, Method getter) {
-               if (annotation.annotationType().equals(RelatedElementsGet.class))
-                       return new RelatedElementsRuleFactory2<Object>();
-               if (annotation.annotationType().equals(OrderedElementsGet.class))
-                       return new OrderedElementsRuleFactory<Object>();
-               return null;
-       }
-       
-       /**
+
+    public static IClassRuleFactory<Resource, Object> createClassRule(ReadGraph g, Annotation annotation, Class<?> clazz) {
+        return null;
+    }
+
+    public static IFieldRuleFactory<Resource,Object> createFieldRule(ReadGraph g, Annotation annotation, Field field) {
+        if (annotation.annotationType().equals(RelatedElement.class))
+            return new RelatedElementRuleFactory<Object>();
+        if (annotation.annotationType().equals(RelatedElements.class))
+            return new RelatedElementsRuleFactory<Object>();
+        if (annotation.annotationType().equals(RelatedValue.class))
+            return new RelatedValueRuleFactory<Object>();
+        if (annotation.annotationType().equals(OptionalRelatedElements.class))
+            return new OptionalRelatedElementsRuleFactory<Object>();
+        if (annotation.annotationType().equals(RelatedOrderedSetElements.class))
+            return new RelatedOrderedSetElementsRuleFactory<Object>();
+        return null;
+    }
+
+    public static IMethodRuleFactory<Resource, Object> createMethodRule(ReadGraph g, Annotation annotation, Method m) {
+        if (annotation.annotationType().equals(UpdateMethod.class))
+            return new UpdateMethodFactory<Resource,Object>();
+        return null;
+    }
+
+    public static IGetSetRuleFactory<Resource,Object> createGetSetRuleFactory(ReadGraph g, Annotation annotation, Method getter) {
+        if (annotation.annotationType().equals(RelatedGetValue.class))
+            return new RelatedGetSetValueRuleFactory<Object>();
+        if (annotation.annotationType().equals(RelatedGetObj.class))
+            return new RelatedGetSetObjRuleFactory<Object>();
+        if (annotation.annotationType().equals(CompoundRelatedGetValue.class))
+            return new CompoundRelatedGetSetValueRuleFactory<Object>();
+        return null;
+    }
+
+    public static ICollectionRuleFactory<Resource,Object> createCollectionRuleFactory(ReadGraph g, Annotation annotation, Method getter) {
+        if (annotation.annotationType().equals(RelatedElementsGet.class))
+            return new RelatedElementsRuleFactory2<Object>();
+        if (annotation.annotationType().equals(OrderedElementsGet.class))
+            return new OrderedElementsRuleFactory<Object>();
+        return null;
+    }
+
+    /**
      * Creates a new SimpleLinkType based on the annotations in the given class.
      * @throws IllegalAccessException 
      * @throws InstantiationException 
      * @see GraphType
      * @see RelatedValue
      */
-       
-       public static AdaptedLinkType<Object> fromAdaptable(ReadGraph g, String type, Class<?> clazz) throws DatabaseException, InstantiationException, IllegalAccessException {
-           
-           
-           return new AdaptedLinkType<Object>(g.getResource(type), clazz);    
-       }
-       
-       
+
+    public static AdaptedLinkType<Object> fromAdaptable(ReadGraph g, String type, Class<?> clazz) throws DatabaseException, InstantiationException, IllegalAccessException {
+
+
+        return new AdaptedLinkType<Object>(g.getResource(type), clazz);    
+    }
+
+
 }
index fcfb3b012a802439398bc6d020325e9875494f38..1de0e31fab355321e8fd84f06d6822dc17778216 100644 (file)
@@ -13,7 +13,8 @@ package org.simantics.objmap.graph.schema;
 
 import java.util.ArrayList;
 
-import org.apache.log4j.Logger;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.simantics.db.ReadGraph;
 import org.simantics.db.Resource;
 import org.simantics.db.WriteGraph;
@@ -34,7 +35,7 @@ import org.simantics.objmap.forward.IForwardMapping;
  */
 public class SimpleLinkType<Range> implements ILinkType<Resource,Range> {
     
-    static Logger LOGGER = Logger.getLogger("org.simantics.objmap");
+    static Logger LOGGER = LoggerFactory.getLogger(SimpleLinkType.class);
     
     public Resource domainType;
     public Class<?> rangeType;
index a5dc78f9120196e76dca9432ad3514f7d0799085..1ce1ef1c61e9f74dc91e449d961f6185bda98d13 100644 (file)
@@ -14,7 +14,8 @@ package org.simantics.objmap.structural.annotations.factories;
 import java.lang.annotation.Annotation;
 import java.lang.reflect.Method;
 
-import org.apache.log4j.Logger;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.simantics.db.ReadGraph;
 import org.simantics.db.WriteGraph;
 import org.simantics.db.exception.DatabaseException;
@@ -26,7 +27,7 @@ import org.simantics.objmap.graph.rules.factory.IMethodRuleFactory;
 
 public class UpdateMethodFactory<Domain, Range> implements IMethodRuleFactory<Domain, Range> {
 
-    static Logger LOGGER = Logger.getLogger("org.simantics.objmap");
+    static Logger LOGGER = LoggerFactory.getLogger(UpdateMethodFactory.class);
     
     @Override
     public IBidirectionalMappingRule<Domain, Range> create(ReadGraph g, 
index 295e60e2f29796eb96ea7ce88a90c2610018efd0..736f86b39c2a889b9962d8dd8334e809d8426ea8 100644 (file)
@@ -11,7 +11,8 @@
  *******************************************************************************/
 package org.simantics.objmap.structural.rules.domain;
 
-import org.apache.log4j.Logger;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.simantics.db.ReadGraph;
 import org.simantics.db.Resource;
 import org.simantics.db.WriteGraph;
@@ -23,7 +24,7 @@ import org.simantics.objmap.structural.StructuralResource;
 
 public class RelatedObjectAccessor implements IDomainAccessor<StructuralResource,StructuralResource> {
 
-    static Logger LOGGER = Logger.getLogger("org.simantics.objmap");
+    static Logger LOGGER = LoggerFactory.getLogger(RelatedObjectAccessor.class);
     
        Resource relation;
        boolean useTypeResource;
index cbd4ef3b40c9e5f1fae6b5e0159eb98e3f2e68cd..1e1be5b76df10f81935f760dc5cd48cf4b21593e 100644 (file)
@@ -16,7 +16,8 @@ import java.util.Collection;
 import java.util.Collections;
 import java.util.List;
 
-import org.apache.log4j.Logger;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.simantics.db.ReadGraph;
 import org.simantics.db.Resource;
 import org.simantics.db.WriteGraph;
@@ -29,7 +30,7 @@ import org.simantics.objmap.structural.StructuralResource;
 
 public class RelatedObjectsAccessor implements IDomainAccessor<StructuralResource,Collection<StructuralResource>> {
 
-    static Logger LOGGER = Logger.getLogger("org.simantics.objmap");
+    static Logger LOGGER = LoggerFactory.getLogger(RelatedObjectsAccessor.class);
     
        Resource relation;
        boolean deleteExtraObjects;
index 6c1ed3aa2777038fbfa958ee7735c7c3441313ac..97fde226f2fa522ac8ca472b94146db55feca996 100644 (file)
@@ -16,7 +16,8 @@ import java.util.Collection;
 import java.util.Collections;
 import java.util.List;
 
-import org.apache.log4j.Logger;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.simantics.db.ReadGraph;
 import org.simantics.db.Resource;
 import org.simantics.db.WriteGraph;
@@ -28,7 +29,7 @@ import org.simantics.objmap.structural.StructuralResource;
 
 public class RelatedOrderedSetElementsAccessor implements IDomainAccessor<StructuralResource, Collection<StructuralResource>> {
 
-    static Logger LOGGER = Logger.getLogger("org.simantics.objmap");
+    static Logger LOGGER = LoggerFactory.getLogger(RelatedOrderedSetElementsAccessor.class);
     
        boolean deleteExtraObjects;
        boolean useTypeResource;
index 2d3a24230e88c3b6d0edd51377c75c52f1fc0903..41279d1aba8fede41e5bde9fa42b9eeeb33a9c04 100644 (file)
@@ -13,7 +13,8 @@ package org.simantics.objmap.structural.rules.domain;
 
 import java.util.Arrays;
 
-import org.apache.log4j.Logger;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.simantics.db.ReadGraph;
 import org.simantics.db.Resource;
 import org.simantics.db.Statement;
@@ -27,7 +28,7 @@ import org.simantics.objmap.structural.StructuralResource;
 
 public class RelatedValueAccessor implements IDomainAccessor<StructuralResource,Object> {
 
-    static Logger LOGGER = Logger.getLogger("org.simantics.objmap");
+    static Logger LOGGER = LoggerFactory.getLogger(RelatedValueAccessor.class);
     
        Resource relation;
        Resource valueType;
index 32b8fd38ce0125b44b946ea29a75ce7d4c7ef75c..865d4249ea78553645dbed7296bc9e4bc0ac8664 100644 (file)
@@ -14,7 +14,8 @@ package org.simantics.objmap.structural.rules.domain;
 import java.util.ArrayList;
 import java.util.List;
 
-import org.apache.log4j.Logger;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.simantics.db.ReadGraph;
 import org.simantics.db.Resource;
 import org.simantics.db.WriteGraph;
@@ -26,7 +27,7 @@ import org.simantics.objmap.structural.StructuralResource;
 
 public class StructuralRelatedObjectAccessor implements IDomainAccessor<StructuralResource,StructuralResource> {
 
-    static Logger LOGGER = Logger.getLogger("org.simantics.objmap");
+    static Logger LOGGER = LoggerFactory.getLogger(StructuralRelatedObjectAccessor.class);
     
        Resource relation;
        boolean useTypeResource;
index 730edc2696cec373b64643d8c8e632634073ec4e..6984bdcd02269a556eaef001f210d7be4268db96 100644 (file)
@@ -16,7 +16,8 @@ import java.util.Collection;
 import java.util.Collections;
 import java.util.List;
 
-import org.apache.log4j.Logger;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.simantics.db.ReadGraph;
 import org.simantics.db.Resource;
 import org.simantics.db.WriteGraph;
@@ -29,7 +30,7 @@ import org.simantics.objmap.structural.StructuralResource;
 
 public class StructuralRelatedObjectsAccessor implements IDomainAccessor<StructuralResource,Collection<StructuralResource>> {
 
-    static Logger LOGGER = Logger.getLogger("org.simantics.objmap");
+    static Logger LOGGER = LoggerFactory.getLogger(StructuralRelatedObjectsAccessor.class);
     
        Resource relation;
        boolean deleteExtraObjects;
index 4f55084861ef9413a548a9a6181b1ec9608893de..203863a6c74c61606d26e71d9c9dabf5964d675f 100644 (file)
@@ -11,7 +11,7 @@
  *******************************************************************************/
 package org.simantics.objmap.structural.schema;
 
-//import org.apache.log4j.Logger;
+//import org.slf4j.Logger;
 import org.eclipse.core.runtime.IAdaptable;
 import org.simantics.db.ReadGraph;
 import org.simantics.db.Resource;
index 8a7091fd46e828ff2774df30265d7ff719bee8e4..ded0f40db8c15e3e1e4e0daad19e82344ac331f3 100644 (file)
@@ -15,7 +15,8 @@ import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
 
-import org.apache.log4j.Logger;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.simantics.db.ReadGraph;
 import org.simantics.db.Resource;
 import org.simantics.db.WriteGraph;
@@ -34,7 +35,7 @@ import org.simantics.objmap.structural.StructuralResource;
 
 public class SimpleLinkType implements ILinkType<StructuralResource,IStructuralObject> {
     
-    static Logger LOGGER = Logger.getLogger("org.simantics.objmap");
+    static Logger LOGGER = LoggerFactory.getLogger(SimpleLinkType.class);
     
     public Resource domainType;
     public Class<?> rangeType;