// Path: batch/src/main/java/com/radcortez/wow/auctions/entity/AuctionFile.java
// @NoArgsConstructor
// @Data
// @EqualsAndHashCode(of = "id", callSuper = false)
// @ToString(exclude = "connectedRealm")
// 
// @Entity
// public class AuctionFile extends PanacheEntityBase {
//     @Id
//     @GeneratedValue
//     private Long id;
//     private String fileName;
//     @Enumerated(EnumType.STRING)
//     private FileStatus fileStatus;
//     private Long timestamp;
// 
//     @OneToMany(mappedBy = "auctionFile", cascade = CascadeType.ALL, orphanRemoval = true)
//     private Set<Auction> auctions = new HashSet<>();
//     @ManyToOne(optional = false)
//     private ConnectedRealm connectedRealm;
// 
//     @Builder
//     public AuctionFile(
//         final String fileName,
//         final FileStatus fileStatus,
//         final Long timestamp,
//         final Set<Auction> auctions,
//         final ConnectedRealm connectedRealm) {
// 
//         this.fileName = fileName;
//         this.fileStatus = fileStatus;
//         this.timestamp = timestamp;
//         this.auctions = Optional.ofNullable(auctions).map(HashSet::new).orElse(new HashSet<>());
//         this.connectedRealm = connectedRealm;
//     }
// 
//     public AuctionFile create() {
//         persist();
//         return this;
//     }
// }
// 
// Path: batch/src/main/java/com/radcortez/wow/auctions/entity/ConnectedRealm.java
// @NoArgsConstructor
// @Data
// @EqualsAndHashCode(of = "id", callSuper = false)
// 
// @Entity
// public class ConnectedRealm extends PanacheEntityBase {
//     @Id
//     private String id;
//     @Enumerated(EnumType.STRING)
//     private Region region;
//     @OneToMany(mappedBy = "connectedRealm", cascade = ALL, orphanRemoval = true)
//     private Set<Realm> realms = new HashSet<>();
//     @OneToMany(mappedBy = "connectedRealm", cascade = ALL, orphanRemoval = true, fetch = EAGER)
//     @MapKey(name = "id.folderType")
//     private Map<FolderType, Folder> folders = new HashMap<>();
//     @OneToMany(mappedBy = "connectedRealm", cascade = ALL, orphanRemoval = true)
//     private Set<AuctionFile> files = new HashSet<>();
// 
//     @Builder(toBuilder = true)
//     public ConnectedRealm(
//         final String id,
//         final Region region,
//         @Singular
//         final Set<Realm> realms,
//         final Map<FolderType, Folder> folders,
//         final Set<AuctionFile> files) {
// 
//         this.id = id;
//         this.region = region;
//         this.realms = Optional.ofNullable(realms).map(HashSet::new).orElse(new HashSet<>());
//         this.folders = Optional.ofNullable(folders).map(HashMap::new).orElse(new HashMap<>());
//         this.files = Optional.ofNullable(files).map(HashSet::new).orElse(new HashSet<>());
//     }
// 
//     public void addRealm(final Realm realm) {
//         realm.setConnectedRealm(this);
//         realms.add(realm);
//     }
// 
//     public ConnectedRealm create() {
//         realms.stream()
//               .filter(realm -> realm.getConnectedRealm() == null)
//               .forEach(realm -> realm.setConnectedRealm(this));
// 
//         persist();
//         return this;
//     }
// 
//     public ConnectedRealm update(final ConnectedRealm connectedRealm) {
//         return ConnectedRealmMapper.INSTANCE.toEntity(this, connectedRealm);
//     }
// }


import com.radcortez.wow.auctions.entity.AuctionFile;
import com.radcortez.wow.auctions.entity.ConnectedRealm;
import com.radcortez.wow.auctions.entity.FolderType;
import lombok.RequiredArgsConstructor;
import javax.annotation.PostConstruct;
import javax.batch.runtime.context.JobContext;
import javax.inject.Inject;
import java.io.File;
import static org.apache.commons.io.FileUtils.getFile;
            jobContext.setTransientUserData(new AuctionFileProcessContext(connectedRealmId));
        }
    }

    public AuctionFileProcessContext getContext() {
        return (AuctionFileProcessContext) jobContext.getTransientUserData();
    }

    @RequiredArgsConstructor
    public static class AuctionFileProcessContext {
        private final String connectedRealmId;

        private ConnectedRealm connectedRealm;
        private AuctionFile auctionFile;

        public ConnectedRealm getConnectedRealm() {
            if (connectedRealm == null) {
                connectedRealm = ConnectedRealm.findById(connectedRealmId);
            }
            return connectedRealm;
        }

        public AuctionFile getAuctionFile() {
            if (auctionFile == null) {
                throw new IllegalStateException();
            }
            return auctionFile;
        }

        public void setAuctionFile(AuctionFile auctionFile) {
// Path: batch/src/main/java/com/radcortez/wow/auctions/entity/AuctionFile.java
// @NoArgsConstructor
// @Data
// @EqualsAndHashCode(of = "id", callSuper = false)
// @ToString(exclude = "connectedRealm")
// 
// @Entity
// public class AuctionFile extends PanacheEntityBase {
//     @Id
//     @GeneratedValue
//     private Long id;
//     private String fileName;
//     @Enumerated(EnumType.STRING)
//     private FileStatus fileStatus;
//     private Long timestamp;
// 
//     @OneToMany(mappedBy = "auctionFile", cascade = CascadeType.ALL, orphanRemoval = true)
//     private Set<Auction> auctions = new HashSet<>();
//     @ManyToOne(optional = false)
//     private ConnectedRealm connectedRealm;
// 
//     @Builder
//     public AuctionFile(
//         final String fileName,
//         final FileStatus fileStatus,
//         final Long timestamp,
//         final Set<Auction> auctions,
//         final ConnectedRealm connectedRealm) {
// 
//         this.fileName = fileName;
//         this.fileStatus = fileStatus;
//         this.timestamp = timestamp;
//         this.auctions = Optional.ofNullable(auctions).map(HashSet::new).orElse(new HashSet<>());
//         this.connectedRealm = connectedRealm;
//     }
// 
//     public AuctionFile create() {
//         persist();
//         return this;
//     }
// }
// 
// Path: batch/src/main/java/com/radcortez/wow/auctions/entity/ConnectedRealm.java
// @NoArgsConstructor
// @Data
// @EqualsAndHashCode(of = "id", callSuper = false)
// 
// @Entity
// public class ConnectedRealm extends PanacheEntityBase {
//     @Id
//     private String id;
//     @Enumerated(EnumType.STRING)
//     private Region region;
//     @OneToMany(mappedBy = "connectedRealm", cascade = ALL, orphanRemoval = true)
//     private Set<Realm> realms = new HashSet<>();
//     @OneToMany(mappedBy = "connectedRealm", cascade = ALL, orphanRemoval = true, fetch = EAGER)
//     @MapKey(name = "id.folderType")
//     private Map<FolderType, Folder> folders = new HashMap<>();
//     @OneToMany(mappedBy = "connectedRealm", cascade = ALL, orphanRemoval = true)
//     private Set<AuctionFile> files = new HashSet<>();
// 
//     @Builder(toBuilder = true)
//     public ConnectedRealm(
//         final String id,
//         final Region region,
//         @Singular
//         final Set<Realm> realms,
//         final Map<FolderType, Folder> folders,
//         final Set<AuctionFile> files) {
// 
//         this.id = id;
//         this.region = region;
//         this.realms = Optional.ofNullable(realms).map(HashSet::new).orElse(new HashSet<>());
//         this.folders = Optional.ofNullable(folders).map(HashMap::new).orElse(new HashMap<>());
//         this.files = Optional.ofNullable(files).map(HashSet::new).orElse(new HashSet<>());
//     }
// 
//     public void addRealm(final Realm realm) {
//         realm.setConnectedRealm(this);
//         realms.add(realm);
//     }
// 
//     public ConnectedRealm create() {
//         realms.stream()
//               .filter(realm -> realm.getConnectedRealm() == null)
//               .forEach(realm -> realm.setConnectedRealm(this));
// 
//         persist();
//         return this;
//     }
// 
//     public ConnectedRealm update(final ConnectedRealm connectedRealm) {
//         return ConnectedRealmMapper.INSTANCE.toEntity(this, connectedRealm);
//     }
// }


// Path: batch/src/main/java/com/radcortez/wow/auctions/batch/process/AbstractAuctionFileProcess.java
import com.radcortez.wow.auctions.entity.AuctionFile;
import com.radcortez.wow.auctions.entity.ConnectedRealm;
import com.radcortez.wow.auctions.entity.FolderType;
import lombok.RequiredArgsConstructor;
import javax.annotation.PostConstruct;
import javax.batch.runtime.context.JobContext;
import javax.inject.Inject;
import java.io.File;
import static org.apache.commons.io.FileUtils.getFile;

            jobContext.setTransientUserData(new AuctionFileProcessContext(connectedRealmId));
        }
    }

    public AuctionFileProcessContext getContext() {
        return (AuctionFileProcessContext) jobContext.getTransientUserData();
    }

    @RequiredArgsConstructor
    public static class AuctionFileProcessContext {
        private final String connectedRealmId;

        private ConnectedRealm connectedRealm;
        private AuctionFile auctionFile;

        public ConnectedRealm getConnectedRealm() {
            if (connectedRealm == null) {
                connectedRealm = ConnectedRealm.findById(connectedRealmId);
            }
            return connectedRealm;
        }

        public AuctionFile getAuctionFile() {
            if (auctionFile == null) {
                throw new IllegalStateException();
            }
            return auctionFile;
        }

        public void setAuctionFile(AuctionFile auctionFile) {
            this.auctionFile = auctionFile;