// Path: src/main/java/de/idrinth/stellaris/modtools/persistence/entity/Patch.java
// @NamedQueries({
//     @NamedQuery(
//             name = "patch.any",
//             query = "select f from Patch f"
//     )
// })
// @Entity
// public class Patch extends EntityCompareAndHash {
// 
//     @Id
//     @GeneratedValue
//     private long aid;
//     @ManyToOne(fetch = FetchType.LAZY)
//     protected Modification mod;
//     @ManyToOne(fetch = FetchType.LAZY)
//     protected Original file;
//     @OneToOne(fetch = FetchType.LAZY)
//     @Cascade({CascadeType.DELETE,CascadeType.PERSIST})
//     private LazyText diff;
// 
//     public Patch() {
//     }
// 
//     public Patch(Modification mod, Original file) {
//         setMod(mod);
//         setFile(file);
//     }
// 
//     @Override
//     public long getAid() {
//         return aid;
//     }
// 
//     @Override
//     public void setAid(long aid) {
//         this.aid = aid;
//     }
// 
//     public Modification getMod() {
//         return mod;
//     }
// 
//     public final void setMod(Modification mod) {
//         mod.getPatches().add(this);
//         this.mod = mod;
//     }
// 
//     public Original getFile() {
//         return file;
//     }
// 
//     public final void setFile(Original file) {
//         file.getPatches().add(this);
//         this.file = file;
//     }
// 
//     public String getDiff() {
//         return diff.getText();
//     }
// 
//     public void setDiff(String diff) {
//         if(null == this.diff) {
//             this.diff = new LazyText();
//         }
//         this.diff.setText(diff);
//     }
// }
// 
// Path: src/main/java/de/idrinth/stellaris/modtools/process/ProcessTask.java
// public interface ProcessTask {
// 
//     List<ProcessTask> handle(EntityManager manager) throws Exception;
//     String getIdentifier();
// }
// 
// Path: src/main/java/de/idrinth/stellaris/modtools/filesystem/FileExtensions.java
// public class FileExtensions {
// 
//     private static final String[] PATCH = "txt,yml,asset,csv,gfx,shader,fxh,gui".split(",");
//     private static final String[] REPLACE = "wav,ogg,ods,dds,bmp,png,psd,jpg,ani,cur,ttf,fnt,tga,otf,anim,mesh".split(",");
// 
//     private FileExtensions() {
//         //this is a static class only
//     }
// 
//     public static boolean isPatchable(String filename) {
//         return isInList(PATCH, filename);
//     }
// 
//     public static boolean isReplaceable(String filename) {
//         return isInList(REPLACE, filename);
//     }
// 
//     public static String[] getPatchable() {
//         return PATCH;
//     }
// 
//     public static String[] getReplaceable() {
//         return REPLACE;
//     }
// 
//     private static boolean isInList(String[] list, String filename) {
//         for (String ext : list) {
//             if (filename.endsWith("."+ext)) {
//                 return true;
//             }
//         }
//         return false;
//     }
// }


import com.sksamuel.diffpatch.DiffMatchPatch;
import de.idrinth.stellaris.modtools.persistence.entity.Patch;
import de.idrinth.stellaris.modtools.process.ProcessTask;
import de.idrinth.stellaris.modtools.filesystem.FileExtensions;
import java.util.ArrayList;
import java.util.List;
import javax.persistence.EntityManager;
/*
 * Copyright (C) 2017 Björn Büttner
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
package de.idrinth.stellaris.modtools.process3filepatch;


class GenerateFilePatch implements ProcessTask {

    private final long id;

    public GenerateFilePatch(long id) {
        this.id = id;
    }

    @Override
// Path: src/main/java/de/idrinth/stellaris/modtools/persistence/entity/Patch.java
// @NamedQueries({
//     @NamedQuery(
//             name = "patch.any",
//             query = "select f from Patch f"
//     )
// })
// @Entity
// public class Patch extends EntityCompareAndHash {
// 
//     @Id
//     @GeneratedValue
//     private long aid;
//     @ManyToOne(fetch = FetchType.LAZY)
//     protected Modification mod;
//     @ManyToOne(fetch = FetchType.LAZY)
//     protected Original file;
//     @OneToOne(fetch = FetchType.LAZY)
//     @Cascade({CascadeType.DELETE,CascadeType.PERSIST})
//     private LazyText diff;
// 
//     public Patch() {
//     }
// 
//     public Patch(Modification mod, Original file) {
//         setMod(mod);
//         setFile(file);
//     }
// 
//     @Override
//     public long getAid() {
//         return aid;
//     }
// 
//     @Override
//     public void setAid(long aid) {
//         this.aid = aid;
//     }
// 
//     public Modification getMod() {
//         return mod;
//     }
// 
//     public final void setMod(Modification mod) {
//         mod.getPatches().add(this);
//         this.mod = mod;
//     }
// 
//     public Original getFile() {
//         return file;
//     }
// 
//     public final void setFile(Original file) {
//         file.getPatches().add(this);
//         this.file = file;
//     }
// 
//     public String getDiff() {
//         return diff.getText();
//     }
// 
//     public void setDiff(String diff) {
//         if(null == this.diff) {
//             this.diff = new LazyText();
//         }
//         this.diff.setText(diff);
//     }
// }
// 
// Path: src/main/java/de/idrinth/stellaris/modtools/process/ProcessTask.java
// public interface ProcessTask {
// 
//     List<ProcessTask> handle(EntityManager manager) throws Exception;
//     String getIdentifier();
// }
// 
// Path: src/main/java/de/idrinth/stellaris/modtools/filesystem/FileExtensions.java
// public class FileExtensions {
// 
//     private static final String[] PATCH = "txt,yml,asset,csv,gfx,shader,fxh,gui".split(",");
//     private static final String[] REPLACE = "wav,ogg,ods,dds,bmp,png,psd,jpg,ani,cur,ttf,fnt,tga,otf,anim,mesh".split(",");
// 
//     private FileExtensions() {
//         //this is a static class only
//     }
// 
//     public static boolean isPatchable(String filename) {
//         return isInList(PATCH, filename);
//     }
// 
//     public static boolean isReplaceable(String filename) {
//         return isInList(REPLACE, filename);
//     }
// 
//     public static String[] getPatchable() {
//         return PATCH;
//     }
// 
//     public static String[] getReplaceable() {
//         return REPLACE;
//     }
// 
//     private static boolean isInList(String[] list, String filename) {
//         for (String ext : list) {
//             if (filename.endsWith("."+ext)) {
//                 return true;
//             }
//         }
//         return false;
//     }
// }


// Path: src/main/java/de/idrinth/stellaris/modtools/process3filepatch/GenerateFilePatch.java
import com.sksamuel.diffpatch.DiffMatchPatch;
import de.idrinth.stellaris.modtools.persistence.entity.Patch;
import de.idrinth.stellaris.modtools.process.ProcessTask;
import de.idrinth.stellaris.modtools.filesystem.FileExtensions;
import java.util.ArrayList;
import java.util.List;
import javax.persistence.EntityManager;

/*
 * Copyright (C) 2017 Björn Büttner
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
package de.idrinth.stellaris.modtools.process3filepatch;


class GenerateFilePatch implements ProcessTask {

    private final long id;

    public GenerateFilePatch(long id) {
        this.id = id;
    }

    @Override
    public List<ProcessTask> handle(EntityManager manager) {