001    package de.deepamehta.plugins.csv;
002    
003    import java.util.List;
004    
005    import org.codehaus.jettison.json.JSONArray;
006    import org.codehaus.jettison.json.JSONObject;
007    
008    import de.deepamehta.core.JSONEnabled;
009    
010    public class ImportStatus implements JSONEnabled {
011    
012        private String message;
013    
014        private boolean success;
015    
016        private List<String> infos;
017    
018        public ImportStatus(boolean success, String message, List<String> infos) {
019            this.message = message;
020            this.success = success;
021            this.infos = infos;
022        }
023    
024        public JSONObject toJSON() {
025            try {
026                JSONObject json = new JSONObject()//
027                        .put("success", success)//
028                        .put("message", message)//
029                        .put("infos", new JSONArray(infos));
030                return json;
031            } catch (Exception e) {
032                throw new RuntimeException("Serialization failed (" + this + ")", e);
033            }
034        }
035    }