Search in sources :

Example 6 with ModelDefinition

use of com.serotonin.m2m2.module.ModelDefinition in project ma-core-public by infiniteautomation.

the class ModuleRegistry method ensureModelDefinitions.

private static void ensureModelDefinitions() {
    if (MODEL_DEFINITIONS == null) {
        synchronized (LOCK) {
            if (MODEL_DEFINITIONS == null) {
                Map<String, ModelDefinition> map = new HashMap<String, ModelDefinition>();
                for (ModelDefinition def : Module.getDefinitions(preDefaults, ModelDefinition.class)) {
                    map.put(def.getModelTypeName(), def);
                }
                for (Module module : MODULES.values()) {
                    for (ModelDefinition def : module.getDefinitions(ModelDefinition.class)) map.put(def.getModelTypeName(), def);
                }
                for (ModelDefinition def : Module.getDefinitions(postDefaults, ModelDefinition.class)) {
                    map.put(def.getModelTypeName(), def);
                }
                MODEL_DEFINITIONS = map;
            }
        }
    }
}
Also used : LinkedHashMap(java.util.LinkedHashMap) HashMap(java.util.HashMap) RestErrorModelDefinition(com.serotonin.m2m2.web.mvc.rest.v1.model.RestErrorModelDefinition)

Aggregations

ModelDefinition (com.serotonin.m2m2.module.ModelDefinition)5 IOException (java.io.IOException)3 JsonNode (com.fasterxml.jackson.databind.JsonNode)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)2 HashMap (java.util.HashMap)2 JsonException (com.serotonin.json.JsonException)1 JsonReader (com.serotonin.json.JsonReader)1 JsonObject (com.serotonin.json.type.JsonObject)1 JsonTypeReader (com.serotonin.json.type.JsonTypeReader)1 JsonValue (com.serotonin.json.type.JsonValue)1 ModelNotFoundException (com.serotonin.m2m2.web.mvc.rest.v1.exception.ModelNotFoundException)1 RestErrorModelDefinition (com.serotonin.m2m2.web.mvc.rest.v1.model.RestErrorModelDefinition)1 SuperclassModel (com.serotonin.m2m2.web.mvc.rest.v1.model.SuperclassModel)1 PointLocatorModel (com.serotonin.m2m2.web.mvc.rest.v1.model.dataPoint.PointLocatorModel)1 PropertyEditor (java.beans.PropertyEditor)1 InputStreamReader (java.io.InputStreamReader)1 Field (java.lang.reflect.Field)1 Method (java.lang.reflect.Method)1 LinkedHashMap (java.util.LinkedHashMap)1