package org.bdgp.MMSlide.DB;

import com.j256.ormlite.field.DataType;
import com.j256.ormlite.field.DatabaseField;
import com.j256.ormlite.table.DatabaseTable;

@DatabaseTable
public class Image {
    @DatabaseField(generatedId=true, canBeNull=false) private int id;
    @DatabaseField(canBeNull=false) private int slideId;
    @DatabaseField(canBeNull=false,dataType=DataType.LONG_STRING) private String path;
    @DatabaseField(canBeNull=false) private int slidePosId;
    
    public Image() {}
    public Image (int slideId, int slidePosId, String path) {
        this.slideId = slideId;
        this.slidePosId = slidePosId;
        this.path = path;
    }
    public String getName() {return String.format("I%05d", this.id);}
    public int getSlideId() {return this.slideId;}
    public int getSlidePosId() {return this.slidePosId;}
    public String getPath() {return this.path;}
}

@@ -23,16 +23,76 @@
 de.DB;%0A%0A
+import org.json.JSONException;%0Aimport org.json.JSONObject;%0A%0A
 import c
@@ -520,24 +520,66 @@
 slidePosId;%0A
+    @DatabaseField() private String tags;%0A
     %0A    pub
@@ -757,16 +757,478 @@
 ;%0A    %7D%0A
+    public Image (int slideId, int slidePosId, String path, String tags) %7B%0A        this.slideId = slideId;%0A        this.slidePosId = slidePosId;%0A        this.path = path;%0A        this.tags = tags;%0A    %7D%0A    public Image (int slideId, int slidePosId, String path, JSONObject tags) %7B%0A        this.slideId = slideId;%0A        this.slidePosId = slidePosId;%0A        this.path = path;%0A        this.tags = tags.toString();%0A    %7D%0A    public int getId() %7Breturn this.id;%7D%0A
     publ
@@ -1445,10 +1445,220 @@
 .path;%7D%0A
+    public JSONObject getTags() %7B%0A    %09try %7B return new JSONObject(this.tags); %7D %0A    %09catch (JSONException e) %7B throw new RuntimeException(e); %7D%0A    %7D%0A    public String getTagsAsString() %7B return this.tags; %7D%0A
 %7D%0A

store image tags in Image records