/*
 * oxTrust is available under the MIT License (2008). See http://opensource.org/licenses/MIT for full text.
 *
 * Copyright (c) 2015, Gluu
 */
package org.gluu.oxtrust.model.scim2.bulk;

import org.codehaus.jackson.annotate.JsonIgnoreProperties;
import org.codehaus.jackson.map.ObjectMapper;
import org.codehaus.jackson.map.annotate.JsonSerialize;

import java.util.Map;

/**
 * A class representing the components of a SCIM Bulk operation as per section 3.7 of RFC 7644.
 * @author Rahat Ali Date: 05.08.2015
 */
/*
 * Updated by jgomer on 2017-11-21.
 */
@JsonIgnoreProperties(ignoreUnknown = true)
public class BulkOperation {

    private static ObjectMapper mapper=new ObjectMapper();

    private String method;
    private String bulkId;
    //private String version;
    private String path;
    private String data;
    private String location;
    private Object response;
    private String status;

    public String getMethod() {
        return method;
    }

    public void setMethod(String method) {
        this.method = method;
    }

    public String getBulkId() {
        return bulkId;
    }

    public void setBulkId(String bulkId) {
        this.bulkId = bulkId;
    }
/*
    public String getVersion() {
        return version;
    }

    public void setVersion(String version) {
        this.version = version;
    }
*/

    @JsonSerialize(include=JsonSerialize.Inclusion.NON_EMPTY)
    public String getPath() {
        return path;
    }

    public void setPath(String path) {
        this.path = path;
    }

    @JsonSerialize(include=JsonSerialize.Inclusion.NON_EMPTY)
    public String getData() {
        return data;
    }

    public void setData(Map<String, Object> map) {

        try {
            data = mapper.writeValueAsString(map);
        }
        catch (Exception e){
            data=null;
        }

    }

    @JsonSerialize(include=JsonSerialize.Inclusion.NON_EMPTY)
    public String getLocation() {
        return location;
    }

    public void setLocation(String location) {
        this.location = location;
    }

    @JsonSerialize(include=JsonSerialize.Inclusion.NON_EMPTY)
    public Object getResponse() {
        return response;
    }

    public void setResponse(Object response) {
        this.response = response;
    }

    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status;
    }

}

@@ -183,16 +183,65 @@
 .bulk;%0A%0A
+import org.codehaus.jackson.annotate.JsonIgnore;%0A
 import o
@@ -291,16 +291,16 @@
 erties;%0A
-
 import o
@@ -857,22 +857,35 @@
 private 
+Map%3C
 String
+, Object%3E
  data;%0A 
@@ -969,16 +969,61 @@
 tatus;%0A%0A
+    @JsonIgnore%0A    private String dataStr;%0A%0A
     publ
@@ -1635,32 +1635,96 @@
  = path;%0A    %7D%0A%0A
+    public String getDataStr() %7B%0A        return dataStr;%0A    %7D%0A%0A
     @JsonSeriali
@@ -1772,38 +1772,51 @@
 PTY)%0A    public 
+Map%3C
 String
+, Object%3E
  getData() %7B%0A   
@@ -1922,16 +1922,41 @@
     data
+=map;%0A            dataStr
  = mappe
@@ -2021,16 +2021,16 @@
 ion e)%7B%0A
-
         
@@ -2037,16 +2037,19 @@
     data
+Str
 =null;%0A 

Add convenience method for "data" sub-attribute