workflow app bug fix

Change-Id: I993331ac445dbd6d82cdea2e83926af0eba5200a
diff --git a/apps/workflow/api/src/main/java/org/onosproject/workflow/api/JsonDataModel.java b/apps/workflow/api/src/main/java/org/onosproject/workflow/api/JsonDataModel.java
index 1dc8e52..fb26642 100644
--- a/apps/workflow/api/src/main/java/org/onosproject/workflow/api/JsonDataModel.java
+++ b/apps/workflow/api/src/main/java/org/onosproject/workflow/api/JsonDataModel.java
@@ -15,7 +15,6 @@
  */
 package org.onosproject.workflow.api;
 
-import com.fasterxml.jackson.databind.JsonNode;
 
 import java.lang.annotation.ElementType;
 import java.lang.annotation.Retention;
@@ -32,18 +31,14 @@
 
     /**
      * Path of data model.
+     *
      * @return path of data model
      */
     String path() default "/";
 
     /**
-     * Type of data model.
-     * @return type of data model
-     */
-    Class<?> type() default JsonNode.class;
-
-    /**
      * Representing whether this data model is optional or not.
+     *
      * @return optional or not
      */
     boolean optional() default false;
diff --git a/apps/workflow/api/src/main/java/org/onosproject/workflow/api/JsonDataModelInjector.java b/apps/workflow/api/src/main/java/org/onosproject/workflow/api/JsonDataModelInjector.java
index d76aa52..6f87411 100644
--- a/apps/workflow/api/src/main/java/org/onosproject/workflow/api/JsonDataModelInjector.java
+++ b/apps/workflow/api/src/main/java/org/onosproject/workflow/api/JsonDataModelInjector.java
@@ -42,6 +42,7 @@
 
     /**
      * Injects data model to work-let.
+     *
      * @param worklet work-let to be injected
      * @param context workflow context
      * @throws WorkflowException workflow exception
@@ -53,6 +54,7 @@
 
     /**
      * Inhales data model from work-let.
+     *
      * @param worklet work-let to be inhaled
      * @param context workflow context
      * @throws WorkflowException workflow exception
@@ -71,12 +73,12 @@
             return;
         }
 
-        for (Field field: fields) {
+        for (Field field : fields) {
             Annotation[] annotations = field.getAnnotations();
             if (Objects.isNull(annotations)) {
                 continue;
             }
-            for (Annotation annotation: annotations) {
+            for (Annotation annotation : annotations) {
                 if (!(annotation instanceof JsonDataModel)) {
                     continue;
                 }
@@ -111,6 +113,7 @@
     }
 
     private static Map<Class, DataModelFieldBehavior> injectTypeMap = new HashMap<>();
+
     static {
         injectTypeMap.put(String.class, JsonDataModelInjector::injectText);
         injectTypeMap.put(Integer.class, JsonDataModelInjector::injectInteger);
@@ -122,28 +125,30 @@
 
     /**
      * Injects data model on the filed of work-let.
+     *
      * @param worklet work-let
      * @param context workflow context
-     * @param field the field of work-let
-     * @param model data model for the field
+     * @param field   the field of work-let
+     * @param model   data model for the field
      * @throws WorkflowException workflow exception
      */
     private void injectModel(Worklet worklet, WorkflowContext context, Field field, JsonDataModel model)
             throws WorkflowException {
 
-        DataModelFieldBehavior behavior = injectTypeMap.get(model.type());
+        DataModelFieldBehavior behavior = injectTypeMap.get(field.getType());
         if (Objects.isNull(behavior)) {
-            throw new WorkflowException("Not supported type(" + model.type() + ")");
+            throw new WorkflowException("Not supported type(" + field.getType() + ")");
         }
         behavior.apply(worklet, context, field, model);
     }
 
     /**
      * Injects text data model on the filed of work-let.
+     *
      * @param worklet work-let
      * @param context workflow context
-     * @param field the field of work-let
-     * @param model text data model for the field
+     * @param field   the field of work-let
+     * @param model   text data model for the field
      * @throws WorkflowException workflow exception
      */
     private static void injectText(Worklet worklet, WorkflowContext context, Field field, JsonDataModel model)
@@ -171,15 +176,15 @@
 
     /**
      * Injects integer data model on the filed of work-let.
+     *
      * @param worklet work-let
      * @param context workflow context
-     * @param field the field of work-let
-     * @param model integer data model for the field
+     * @param field   the field of work-let
+     * @param model   integer data model for the field
      * @throws WorkflowException workflow exception
      */
     private static void injectInteger(Worklet worklet, WorkflowContext context, Field field, JsonDataModel model)
             throws WorkflowException {
-
         Integer number = ((JsonDataModelTree) context.data()).intAt(model.path());
         if (Objects.isNull(number)) {
             if (model.optional()) {
@@ -202,10 +207,11 @@
 
     /**
      * Injects boolean data model on the filed of work-let.
+     *
      * @param worklet work-let
      * @param context workflow context
-     * @param field the field of work-let
-     * @param model boolean data model for the field
+     * @param field   the field of work-let
+     * @param model   boolean data model for the field
      * @throws WorkflowException workflow exception
      */
     private static void injectBoolean(Worklet worklet, WorkflowContext context, Field field, JsonDataModel model)
@@ -233,10 +239,11 @@
 
     /**
      * Injects json node data model on the filed of work-let.
+     *
      * @param worklet work-let
      * @param context workflow context
-     * @param field the field of work-let
-     * @param model json node data model for the field
+     * @param field   the field of work-let
+     * @param model   json node data model for the field
      * @throws WorkflowException workflow exception
      */
     private static void injectJsonNode(Worklet worklet, WorkflowContext context, Field field, JsonDataModel model)
@@ -264,10 +271,11 @@
 
     /**
      * Injects json array node data model on the filed of work-let.
+     *
      * @param worklet work-let
      * @param context workflow context
-     * @param field the field of work-let
-     * @param model json array node data model for the field
+     * @param field   the field of work-let
+     * @param model   json array node data model for the field
      * @throws WorkflowException workflow exception
      */
     private static void injectArrayNode(Worklet worklet, WorkflowContext context, Field field, JsonDataModel model)
@@ -295,10 +303,11 @@
 
     /**
      * Injects json object node data model on the filed of work-let.
+     *
      * @param worklet work-let
      * @param context workflow context
-     * @param field the field of work-let
-     * @param model json object node data model for the field
+     * @param field   the field of work-let
+     * @param model   json object node data model for the field
      * @throws WorkflowException workflow exception
      */
     private static void injectObjectNode(Worklet worklet, WorkflowContext context, Field field, JsonDataModel model)
@@ -325,6 +334,7 @@
     }
 
     private static Map<Class, DataModelFieldBehavior> inhaleTypeMap = new HashMap<>();
+
     static {
         inhaleTypeMap.put(String.class, JsonDataModelInjector::inhaleText);
         inhaleTypeMap.put(Integer.class, JsonDataModelInjector::inhaleInteger);
@@ -336,28 +346,30 @@
 
     /**
      * Inhales data model on the filed of work-let.
+     *
      * @param worklet work-let
      * @param context workflow context
-     * @param field the field of work-let
-     * @param model data model for the field
+     * @param field   the field of work-let
+     * @param model   data model for the field
      * @throws WorkflowException workflow exception
      */
     private void inhaleModel(Worklet worklet, WorkflowContext context, Field field, JsonDataModel model)
             throws WorkflowException {
 
-        DataModelFieldBehavior behavior = inhaleTypeMap.get(model.type());
+        DataModelFieldBehavior behavior = inhaleTypeMap.get(field.getType());
         if (Objects.isNull(behavior)) {
-            throw new WorkflowException("Not supported type(" + model.type() + ")");
+            throw new WorkflowException("Not supported type(" + field.getType() + ")");
         }
         behavior.apply(worklet, context, field, model);
     }
 
     /**
      * Inhales text data model on the filed of work-let.
+     *
      * @param worklet work-let
      * @param context workflow context
-     * @param field the field of work-let
-     * @param model text data model for the field
+     * @param field   the field of work-let
+     * @param model   text data model for the field
      * @throws WorkflowException workflow exception
      */
     private static void inhaleText(Worklet worklet, WorkflowContext context, Field field, JsonDataModel model)
@@ -394,15 +406,15 @@
 
     /**
      * Inhales integer data model on the filed of work-let.
+     *
      * @param worklet work-let
      * @param context workflow context
-     * @param field the field of work-let
-     * @param model integer data model for the field
+     * @param field   the field of work-let
+     * @param model   integer data model for the field
      * @throws WorkflowException workflow exception
      */
     private static void inhaleInteger(Worklet worklet, WorkflowContext context, Field field, JsonDataModel model)
             throws WorkflowException {
-
         if (!(Objects.equals(field.getType(), Integer.class))) {
             throw new WorkflowException("Target field (" + field + ") is not Integer");
         }
@@ -434,10 +446,11 @@
 
     /**
      * Inhales boolean data model on the filed of work-let.
+     *
      * @param worklet work-let
      * @param context workflow context
-     * @param field the field of work-let
-     * @param model boolean data model for the field
+     * @param field   the field of work-let
+     * @param model   boolean data model for the field
      * @throws WorkflowException workflow exception
      */
     private static void inhaleBoolean(Worklet worklet, WorkflowContext context, Field field, JsonDataModel model)
@@ -474,10 +487,11 @@
 
     /**
      * Inhales json node data model on the filed of work-let.
+     *
      * @param worklet work-let
      * @param context workflow context
-     * @param field the field of work-let
-     * @param model json node data model for the field
+     * @param field   the field of work-let
+     * @param model   json node data model for the field
      * @throws WorkflowException workflow exception
      */
     private static void inhaleJsonNode(Worklet worklet, WorkflowContext context, Field field, JsonDataModel model)
@@ -513,10 +527,11 @@
 
     /**
      * Inhales json array node data model on the filed of work-let.
+     *
      * @param worklet work-let
      * @param context workflow context
-     * @param field the field of work-let
-     * @param model json array node data model for the field
+     * @param field   the field of work-let
+     * @param model   json array node data model for the field
      * @throws WorkflowException workflow exception
      */
     private static void inhaleArrayNode(Worklet worklet, WorkflowContext context, Field field, JsonDataModel model)
@@ -551,10 +566,11 @@
 
     /**
      * Inhales json object node data model on the filed of work-let.
+     *
      * @param worklet work-let
      * @param context workflow context
-     * @param field the field of work-let
-     * @param model json object node data model for the field
+     * @param field   the field of work-let
+     * @param model   json object node data model for the field
      * @throws WorkflowException workflow exception
      */
     private static void inhaleObjectNode(Worklet worklet, WorkflowContext context, Field field, JsonDataModel model)
diff --git a/apps/workflow/app/src/main/java/org/onosproject/workflow/impl/example/SampleWorkflow.java b/apps/workflow/app/src/main/java/org/onosproject/workflow/impl/example/SampleWorkflow.java
index 9d4e7b2..252c17d 100644
--- a/apps/workflow/app/src/main/java/org/onosproject/workflow/impl/example/SampleWorkflow.java
+++ b/apps/workflow/app/src/main/java/org/onosproject/workflow/impl/example/SampleWorkflow.java
@@ -180,7 +180,7 @@
      */
     public static class SampleWorklet1 extends AbsSampleWorklet {
 
-        @JsonDataModel(path = MODEL_COUNT, type = Integer.class)
+        @JsonDataModel(path = MODEL_COUNT)
         Integer intCount;
 
         @Override
@@ -208,7 +208,7 @@
      */
     public static class SampleWorklet2 extends AbsSampleWorklet {
 
-        @JsonDataModel(path = MODEL_COUNT, type = Integer.class)
+        @JsonDataModel(path = MODEL_COUNT)
         Integer intCount;
 
         @Override
@@ -238,7 +238,7 @@
 
     public static class SampleWorklet3 extends AbsSampleWorklet {
 
-        @JsonDataModel(path = MODEL_COUNT, type = Integer.class)
+        @JsonDataModel(path = MODEL_COUNT)
         Integer intCount;
 
         @Override
@@ -262,7 +262,7 @@
 
     public static class SampleWorklet4 extends AbsSampleWorklet {
 
-        @JsonDataModel(path = MODEL_COUNT, type = Integer.class)
+        @JsonDataModel(path = MODEL_COUNT)
         Integer intCount;
 
         @Override
@@ -286,7 +286,7 @@
 
     public static class SampleWorklet5 extends AbsSampleWorklet {
 
-        @JsonDataModel(path = MODEL_COUNT, type = Integer.class)
+        @JsonDataModel(path = MODEL_COUNT)
         Integer intCount;
 
         @Override