]> gerrit.simantics Code Review - simantics/platform.git/commitdiff
Changed SCLTypeUtils to not log warnings for non-property relations 68/4268/1
authorTuukka Lehtonen <tuukka.lehtonen@semantum.fi>
Wed, 3 Jun 2020 09:40:35 +0000 (12:40 +0300)
committerTuukka Lehtonen <tuukka.lehtonen@semantum.fi>
Wed, 3 Jun 2020 09:40:35 +0000 (12:40 +0300)
For example procedural UCs and their substructure requests would report
tons of these all the time, which is worthless.

Also added an SCL type for MOD.ChangeInformation to avoid having to see
warnings about the SCL type of MOD.ChangeInformation not being
available:

```
WARN  [...] org.simantics.modeling.SCLTypeUtils: SCLTypeUtils.getType
cannot transform data type '{
    createdBy : String,
    createdAt : Long,
    modifiedBy : String,
    modifiedAt : Long
}' to type. Returns a as default.
```

gitlab #546

Change-Id: I30210fb3055a4d844fe6e9b07c64490a45c14ecd

bundles/org.simantics.modeling.ontology/graph/Modeling.pgraph
bundles/org.simantics.modeling/scl/Simantics/ChangeInformation.scl [new file with mode: 0644]
bundles/org.simantics.modeling/src/org/simantics/modeling/SCLTypeUtils.java

index 82808f837b425f2726f1f9df57f279249997d29e..865f03e989527c9571d51d8c3be511586c1fd49e 100644 (file)
@@ -375,6 +375,7 @@ MOD.HasSourceInformation --> MOD.SourceInformation <R L0.IsRelatedTo : L0.Functi
 //##########################################################################
 
 MOD.ChangeInformation <T L0.Literal
 //##########################################################################
 
 MOD.ChangeInformation <T L0.Literal
+    @L0.assert L0.HasValueType "ChangeInformation"
     @L0.assert L0.HasDataType ${ createdBy : String, createdAt : Long, modifiedBy : String, modifiedAt : Long }
 
 MOD.Functions.modificationTimeTextLong : L0.Function
     @L0.assert L0.HasDataType ${ createdBy : String, createdAt : Long, modifiedBy : String, modifiedAt : Long }
 
 MOD.Functions.modificationTimeTextLong : L0.Function
diff --git a/bundles/org.simantics.modeling/scl/Simantics/ChangeInformation.scl b/bundles/org.simantics.modeling/scl/Simantics/ChangeInformation.scl
new file mode 100644 (file)
index 0000000..9d858d9
--- /dev/null
@@ -0,0 +1,2 @@
+importJava "org.simantics.modeling.adapters.ChangeInformation" where
+    data ChangeInformation
index 27955fb7ee2ae99d95eab3d19653e71c8bbc7441..eeabbd960b4e6583bc0a05d35d2b89998e5f8883 100644 (file)
@@ -13,6 +13,7 @@ import org.simantics.databoard.type.LongType;
 import org.simantics.databoard.type.StringType;
 import org.simantics.db.layer0.request.PropertyInfo;
 import org.simantics.scl.compiler.types.TCon;
 import org.simantics.databoard.type.StringType;
 import org.simantics.db.layer0.request.PropertyInfo;
 import org.simantics.scl.compiler.types.TCon;
+import org.simantics.scl.compiler.types.TVar;
 import org.simantics.scl.compiler.types.Type;
 import org.simantics.scl.compiler.types.Types;
 import org.simantics.scl.compiler.types.kinds.Kinds;
 import org.simantics.scl.compiler.types.Type;
 import org.simantics.scl.compiler.types.Types;
 import org.simantics.scl.compiler.types.kinds.Kinds;
@@ -23,6 +24,8 @@ public class SCLTypeUtils {
     private static final Logger LOGGER = LoggerFactory.getLogger(SCLTypeUtils.class);
     private static final THashMap<String, Type> TYPE_MAP = new THashMap<String, Type>();
     
     private static final Logger LOGGER = LoggerFactory.getLogger(SCLTypeUtils.class);
     private static final THashMap<String, Type> TYPE_MAP = new THashMap<String, Type>();
     
+    private static final TVar STAR = Types.var(Kinds.STAR);
+    
     private static void add(TCon type) {
         TYPE_MAP.put(type.name, type);
     }
     private static void add(TCon type) {
         TYPE_MAP.put(type.name, type);
     }
@@ -66,6 +69,7 @@ public class SCLTypeUtils {
                 Types.functionE(new Type[] {variable, Types.RESOURCE}, Types.READ_GRAPH, Types.RESOURCE));
 
         add((TCon)Types.RESOURCE);
                 Types.functionE(new Type[] {variable, Types.RESOURCE}, Types.READ_GRAPH, Types.RESOURCE));
 
         add((TCon)Types.RESOURCE);
+        add(Types.con("Simantics/ChangeInformation", "ChangeInformation")); // MOD.ChangeInformation
         add(Types.con("Simantics/GUID", "GUID")); // L0.GUID
         add(Types.con("Simantics/Variables", "StructuredProperty")); // L0.methods
         add(Types.con("Simantics/Variables", "ValueAccessor")); // L0.ValueAccessor
         add(Types.con("Simantics/GUID", "GUID")); // L0.GUID
         add(Types.con("Simantics/Variables", "StructuredProperty")); // L0.methods
         add(Types.con("Simantics/Variables", "ValueAccessor")); // L0.ValueAccessor
@@ -81,7 +85,7 @@ public class SCLTypeUtils {
         Type type = TYPE_MAP.get(typeText);
         if(type == null) {
             LOGGER.warn("SCLTypeUtils.getType cannot transform '" + typeText + "' to type. Returns a as default.");
         Type type = TYPE_MAP.get(typeText);
         if(type == null) {
             LOGGER.warn("SCLTypeUtils.getType cannot transform '" + typeText + "' to type. Returns a as default.");
-            return Types.var(Kinds.STAR);
+            return STAR;
         }
         return type;
     }
         }
         return type;
     }
@@ -105,18 +109,23 @@ public class SCLTypeUtils {
             return Types.list(getType(((ArrayType)dataType).componentType));
         else {
             LOGGER.warn("SCLTypeUtils.getType cannot transform data type '" + dataType + "' to type. Returns a as default.");
             return Types.list(getType(((ArrayType)dataType).componentType));
         else {
             LOGGER.warn("SCLTypeUtils.getType cannot transform data type '" + dataType + "' to type. Returns a as default.");
-            return Types.var(Kinds.STAR);
+            return STAR;
         }
     }
     
         }
     }
     
-    public static Type getType(PropertyInfo propertyInfo) {
+    public static Type getType(PropertyInfo propertyInfo, boolean warnOfNoTypeInformation) {
         if(propertyInfo.requiredValueType != null)
             return getType(propertyInfo.requiredValueType);
         else if(propertyInfo.requiredDatatype != null)
             return getType(propertyInfo.requiredDatatype);
         else {
         if(propertyInfo.requiredValueType != null)
             return getType(propertyInfo.requiredValueType);
         else if(propertyInfo.requiredDatatype != null)
             return getType(propertyInfo.requiredDatatype);
         else {
-            LOGGER.warn(propertyInfo.name + " doesn't have type information. Returns a as default.");
-            return Types.var(Kinds.STAR);
+            if (warnOfNoTypeInformation)
+                LOGGER.warn(propertyInfo.name + " doesn't have type information. Returns a as default.");
+            return STAR;
         }
     }
         }
     }
+    
+    public static Type getType(PropertyInfo propertyInfo) {
+        return getType(propertyInfo, propertyInfo.isHasProperty);
+    }
 }
 }