package com.spoon.backgroundfileupload;

import com.orm.SugarRecord;
import com.orm.dsl.Unique;
import com.orm.query.Condition;
import com.orm.query.Select;

import org.json.JSONObject;

import java.util.List;

public class PendingUpload extends SugarRecord {
    @Unique
    String uploadId;
    String data;

    public PendingUpload() {

    }

    public PendingUpload(JSONObject payload) {
        try {
            uploadId = payload.getString("id");
            data = payload.toString();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }


    public static void create(JSONObject payload) {
        new PendingUpload(payload).save();
    }


    public static void remove(String uploadId) {
        try {
            List<PendingUpload> results = Select.from(PendingUpload.class)
                    .where(Condition.prop("upload_id").eq(uploadId))
                    .list();
            if (results.size() > 0)
                results.get(0).delete();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public static List<PendingUpload> all() {
        return PendingUpload.listAll(PendingUpload.class);
    }
}

@@ -724,34 +724,16 @@
 adId) %7B%0A
-        try %7B%0A    
         
@@ -811,20 +811,16 @@
         
-   
- 
 .where(C
@@ -876,20 +876,16 @@
         
-    
 .list();
@@ -893,20 +893,16 @@
         
-  
-  
 if (resu
@@ -917,20 +917,16 @@
 () %3E 0)%0A
-    
         
@@ -958,83 +958,8 @@
 ();%0A
-        %7D catch (Exception e) %7B%0A            e.printStackTrace();%0A        %7D%0A
     

remove try catch