// Path: app/src/main/java/com/w9jds/marketbot/classes/models/MarketGroup.java
// public final class MarketGroup extends MarketItemBase  {
// 
//     private String parentGroupRef;
//     private long parentId;
//     private String href;
//     private String description;
//     private String types;
// 
//     public MarketGroup() {
// 
//     }
// 
//     public String getDescription() {
//         return description;
//     }
// 
//     public String getHref() {
//         return href;
//     }
// 
//     public String getTypesLocation() {
//         return types;
//     }
// 
//     public String getParentGroup() {
//         return parentGroupRef;
//     }
// 
//     public long getParentId() {
//         return this.parentId;
//     }
// 
//     public boolean hasParent() {
//         return this.parentGroupRef != null && !this.parentGroupRef.equals("");
//     }
// 
//     public static class Builder {
// 
//         private long id;
//         private String name;
//         private String parentGroup;
//         private long parentId;
//         private String href;
//         private String description;
//         private String types;
// 
//         public Builder setParentGroup(String parentGroup) {
//             this.parentGroup = parentGroup;
//             return this;
//         }
// 
//         public Builder setHref(String href) {
//             this.href = href;
//             return this;
//         }
// 
//         public Builder setDescription(String description) {
//             this.description = description;
//             return this;
//         }
// 
//         public Builder setTypes(String types) {
//             this.types = types;
//             return this;
//         }
// 
//         public Builder setName(String name) {
//             this.name = name;
//             return this;
//         }
// 
//         public Builder setId(long id) {
//             this.id = id;
//             return this;
//         }
// 
//         public Builder setParentId(long id) {
//             this.parentId = id;
//             return this;
//         }
// 
//         public MarketGroup build() {
//             MarketGroup group = new MarketGroup();
//             group.id = id;
//             group.name = name;
// 
//             if (parentGroup != null) {
//                 group.parentGroupRef = this.parentGroup;
//                 group.parentId = this.parentId;
//             }
// 
//             group.href = this.href;
//             group.description = this.description;
//             group.types = this.types;
// 
//             return group;
//         }
//     }
// 
// }
// 
// Path: app/src/main/java/com/w9jds/marketbot/data/MarketDatabase.java
// @Database(name = MarketDatabase.NAME, version = MarketDatabase.VERSION)
// public class MarketDatabase {
// 
//     public static final String NAME = "MarketBotDb";
//     public static final int VERSION = 3;
// 
// 
//     public interface TransactionListener {
//         void onTransactionProgressUpdate(int progress, int max);
//     }
// }


import com.raizlabs.android.dbflow.annotation.Column;
import com.raizlabs.android.dbflow.annotation.PrimaryKey;
import com.raizlabs.android.dbflow.annotation.Table;
import com.raizlabs.android.dbflow.runtime.DBTransactionQueue;
import com.raizlabs.android.dbflow.runtime.TransactionManager;
import com.raizlabs.android.dbflow.runtime.transaction.process.ProcessModelInfo;
import com.raizlabs.android.dbflow.runtime.transaction.process.SaveModelTransaction;
import com.raizlabs.android.dbflow.sql.language.Condition;
import com.raizlabs.android.dbflow.sql.language.OrderBy;
import com.raizlabs.android.dbflow.sql.language.Select;
import com.raizlabs.android.dbflow.structure.BaseModel;
import com.w9jds.marketbot.classes.models.MarketGroup;
import com.w9jds.marketbot.data.MarketDatabase;
import org.devfleet.crest.model.CrestMarketGroup;
import java.util.ArrayList;
import java.util.List;
    @Column
    Long parentId;

    @Column
    String parent;

    @Column
    String types;

    public static void addNewMarketGroups(List<CrestMarketGroup> groups) {
        int count = groups.size();
        List<MarketGroupEntry> entries = new ArrayList<>(count);
        for (int i = 0; i < count; i++) {
            CrestMarketGroup group = groups.get(i);

            MarketGroupEntry entry = new MarketGroupEntry();
            entry.id = group.getId();
            entry.description = group.getDescription();
            entry.name = group.getName();
            entry.href = group.getHref();
            entry.parent = group.hasParent() ? group.getParentRef() : null;
            entry.parentId = group.hasParent() ? group.getParentId() : null;
            entry.types = group.getTypeRef();
            entries.add(entry);
        }

        TransactionManager.getInstance().addTransaction(new SaveModelTransaction<>(
                ProcessModelInfo.withModels(entries)));
    }

// Path: app/src/main/java/com/w9jds/marketbot/classes/models/MarketGroup.java
// public final class MarketGroup extends MarketItemBase  {
// 
//     private String parentGroupRef;
//     private long parentId;
//     private String href;
//     private String description;
//     private String types;
// 
//     public MarketGroup() {
// 
//     }
// 
//     public String getDescription() {
//         return description;
//     }
// 
//     public String getHref() {
//         return href;
//     }
// 
//     public String getTypesLocation() {
//         return types;
//     }
// 
//     public String getParentGroup() {
//         return parentGroupRef;
//     }
// 
//     public long getParentId() {
//         return this.parentId;
//     }
// 
//     public boolean hasParent() {
//         return this.parentGroupRef != null && !this.parentGroupRef.equals("");
//     }
// 
//     public static class Builder {
// 
//         private long id;
//         private String name;
//         private String parentGroup;
//         private long parentId;
//         private String href;
//         private String description;
//         private String types;
// 
//         public Builder setParentGroup(String parentGroup) {
//             this.parentGroup = parentGroup;
//             return this;
//         }
// 
//         public Builder setHref(String href) {
//             this.href = href;
//             return this;
//         }
// 
//         public Builder setDescription(String description) {
//             this.description = description;
//             return this;
//         }
// 
//         public Builder setTypes(String types) {
//             this.types = types;
//             return this;
//         }
// 
//         public Builder setName(String name) {
//             this.name = name;
//             return this;
//         }
// 
//         public Builder setId(long id) {
//             this.id = id;
//             return this;
//         }
// 
//         public Builder setParentId(long id) {
//             this.parentId = id;
//             return this;
//         }
// 
//         public MarketGroup build() {
//             MarketGroup group = new MarketGroup();
//             group.id = id;
//             group.name = name;
// 
//             if (parentGroup != null) {
//                 group.parentGroupRef = this.parentGroup;
//                 group.parentId = this.parentId;
//             }
// 
//             group.href = this.href;
//             group.description = this.description;
//             group.types = this.types;
// 
//             return group;
//         }
//     }
// 
// }
// 
// Path: app/src/main/java/com/w9jds/marketbot/data/MarketDatabase.java
// @Database(name = MarketDatabase.NAME, version = MarketDatabase.VERSION)
// public class MarketDatabase {
// 
//     public static final String NAME = "MarketBotDb";
//     public static final int VERSION = 3;
// 
// 
//     public interface TransactionListener {
//         void onTransactionProgressUpdate(int progress, int max);
//     }
// }


// Path: app/src/main/java/com/w9jds/marketbot/data/storage/MarketGroupEntry.java
import com.raizlabs.android.dbflow.annotation.Column;
import com.raizlabs.android.dbflow.annotation.PrimaryKey;
import com.raizlabs.android.dbflow.annotation.Table;
import com.raizlabs.android.dbflow.runtime.DBTransactionQueue;
import com.raizlabs.android.dbflow.runtime.TransactionManager;
import com.raizlabs.android.dbflow.runtime.transaction.process.ProcessModelInfo;
import com.raizlabs.android.dbflow.runtime.transaction.process.SaveModelTransaction;
import com.raizlabs.android.dbflow.sql.language.Condition;
import com.raizlabs.android.dbflow.sql.language.OrderBy;
import com.raizlabs.android.dbflow.sql.language.Select;
import com.raizlabs.android.dbflow.structure.BaseModel;
import com.w9jds.marketbot.classes.models.MarketGroup;
import com.w9jds.marketbot.data.MarketDatabase;
import org.devfleet.crest.model.CrestMarketGroup;
import java.util.ArrayList;
import java.util.List;

    @Column
    Long parentId;

    @Column
    String parent;

    @Column
    String types;

    public static void addNewMarketGroups(List<CrestMarketGroup> groups) {
        int count = groups.size();
        List<MarketGroupEntry> entries = new ArrayList<>(count);
        for (int i = 0; i < count; i++) {
            CrestMarketGroup group = groups.get(i);

            MarketGroupEntry entry = new MarketGroupEntry();
            entry.id = group.getId();
            entry.description = group.getDescription();
            entry.name = group.getName();
            entry.href = group.getHref();
            entry.parent = group.hasParent() ? group.getParentRef() : null;
            entry.parentId = group.hasParent() ? group.getParentId() : null;
            entry.types = group.getTypeRef();
            entries.add(entry);
        }

        TransactionManager.getInstance().addTransaction(new SaveModelTransaction<>(
                ProcessModelInfo.withModels(entries)));
    }

    public static ArrayList<MarketGroup> getMarketGroupsForParent(Long parentId) {