/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package de.nplusc.izc.InstallPak;

import de.nplusc.izc.tools.IOtools.FileTK;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.Map;
import org.yaml.snakeyaml.DumperOptions;
import org.yaml.snakeyaml.Yaml;

/**
 *
 * @author LH
 */
public class CreateSampleFile
{
    public static void main(String[] devnulled) throws FileNotFoundException, IOException
    {
        //SHARED
        DumperOptions yamlOptions = new DumperOptions();
        yamlOptions.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK);
        Yaml y = new Yaml(yamlOptions);
        /*  
        Map<String,Object> izsetup = new LinkedHashMap<>();
        izsetup.put("comment:type","izsetup");
        ArrayList<String> rootEntries=new ArrayList<>();
        rootEntries.add("Group1");
        rootEntries.add("Runtimes");
        rootEntries.add("nichtWin8");
        izsetup.put("Segments",rootEntries);
        Map<String,String[]> group1 = new LinkedHashMap<>();
        group1.put("Condition",new String[]{"IsWin8"});
        group1.put("ifnode",new String[]{"Group1Win8"});
        group1.put("postCond",new String[]{"Group1Post"});
        izsetup.put("Group1",group1);
        Map<String,String[]> group1win8 = new LinkedHashMap<>();
        group1win8.put("Condition",new String[]{"Is64Bit"});
        group1win8.put("elsenode",new String[]{"Group1Win8_32"});
        izsetup.put("Group1",group1);
        Map<String,String[]> group1win8_32 = new LinkedHashMap<>();
        group1win8_32.put("Exec1",new String[]{"Installiere was 32-bit spezifisches","program","ping","google.de"});
        group1win8_32.put("Comment:exec",new String[]{"Beschreibung","Typ","Parameter1","...","parameterN"});
        izsetup.put("Group1Win8_32",group1win8_32);
        Map<String,String[]> group1post = new LinkedHashMap<>();
        group1post.put("Exec1",new String[]{"Group1Post","program","ping","amazon.de"});
        izsetup.put("Group1Post",group1post);
        Map<String,String[]> runtimes = new LinkedHashMap<>();
        runtimes.put("Exec1",new String[]{"Runtime1","program","ping","ccc.de"});
        runtimes.put("Exec2",new String[]{"Runtime2","program","ping","microsoft.de"});
        izsetup.put("Runtimes",runtimes);
        Map<String,String[]> nonwin8 = new LinkedHashMap<>();
        nonwin8.put("Condition",new String[]{"IsWin8"});
        nonwin8.put("elsenode",new String[]{"nonwin8Impl"});
        izsetup.put("nichtWin8",nonwin8);
        Map<String,String[]> nonwin8Impl = new LinkedHashMap<>();
        nonwin8Impl.put("Exec1",new String[]{"Nicht für wind00f 8","program","ping","example.com"});
        izsetup.put("nonwin8Impl",nonwin8Impl);*/
        
        Map<String,Object> izsetup = new LinkedHashMap<>();
        ArrayList<String> rootEntries=new ArrayList<>();
        rootEntries.add("GamesTls");
        izsetup.put("Segments",rootEntries);
        Map<String,String[]> addons = new LinkedHashMap<>();
        addons.put("Exec1",new String[]{"NOOP","program","ping","localhost"});
        izsetup.put("GamesTls", addons);
        String izbo = "000|izsetup|3.0.0|: valides YAML und trotzdem kompatibel" +"\n"+y.dump(izsetup);
        FileTK.writeFile(izbo, "D:\\src\\izsetup\\gamestls.izsetup");
        
        
        
        
        
        //izpackage
        /*
        Map<String,Object> izpackage = new LinkedHashMap<>();
        izpackage.put("comment:type","izpackage");
        ArrayList<String> flags = new ArrayList<>();
        flags.add("multidisk");
        izpackage.put("flags",flags);
        izpackage.put("comment:packagebases","Namen der IDs der echten Packages die auch in der Liste auftauchen\nDer Rest ist von diesen referenziert");
        ArrayList<String> packageBases=new ArrayList<>();
        packageBases.add("BaseSystem");
        packageBases.add("Addons");
        packageBases.add("XPTools");
        packageBases.add("Games");
        packageBases.add("Game-Tools");
        izpackage.put("packagebases",packageBases);
        Map<String,String> BaseSystem = new LinkedHashMap<>();
        BaseSystem.put("Name","BaseSystem");
        BaseSystem.put("script","#basedir#\\pack001.izsetup");
        BaseSystem.put("detectInstall","File://C:\\kernel.etl2");
        BaseSystem.put("desc","Die minimal nötigen Tools und Komponenten fürs System");
        BaseSystem.put("defaultEnabled","true");
        izpackage.put("BaseSystem",BaseSystem);
        Map<String,String> Addons = new LinkedHashMap<>();
        Addons.put("Name","AddOns");
        Addons.put("dependsOn","BaseSystem");
        Addons.put("script","#basedir#\\addons.izsetup");
        Addons.put("detectInstall","File://%userprofile%\\appdata\\programname\\datei1.dat");
        Addons.put("desc","Addons und sosntiges was nicht zwingend notwendig ist");
        Addons.put("defaultEnabled","true");
        izpackage.put("Addons",Addons);
        Map<String,String> XPAddons = new LinkedHashMap<>();
        XPAddons.put("Condition","IsWin7");
        XPAddons.put("Comment:Condition","Bei Erfüllt das Package aus If enablen, sonst das aus Else verwenden");
        XPAddons.put("ifnode","XPAddonsIf");
        izpackage.put("XPTools", XPAddons);
        Map<String,String> XPAddonsIf = new LinkedHashMap<>();
        XPAddonsIf.put("Name","XPAddOns");
        XPAddonsIf.put("dependsOn","BaseSystem");
        XPAddonsIf.put("script","#basedir#\\xprevocer.izsetup");
        XPAddonsIf.put("detectInstall","File://C:\\ornder2\\datei2.bin");
        XPAddonsIf.put("desc","Sach das bei XP defult war aber dort fehlt");
        XPAddonsIf.put("defaultEnabled","true");
        izpackage.put("XPAddonsIf", XPAddonsIf);
        Map<String,String> Games = new LinkedHashMap<>();
        Games.put("Name","Games");
        Games.put("comment:waitDisk","Prüft ob spezifizierte datei vorhanden ist und fordert zum einlegen der disk auf falls nicht\n spezifisierte datei sollte nur auf der entsprechenden disk sein");
        Games.put("waitDisk", "#basedir#\\games.izsetup");
        Games.put("comment:waitMessage","WaitMessage ist optional, defaulted wenn nur waitDisk");
        Games.put("waitMessage","Bitte Games-Disk einlegen");
        Games.put("dependsOn","BaseSystem");
        Games.put("script","#basedir#\\games.izsetup");
        Games.put("detectInstall","File://C:\\Program Files\\ImgBurn\\ImgBurn.exexexe");
        Games.put("desc","Die Games die nicht fehlen dürfen");
        Games.put("defaultEnabled","true");
        izpackage.put("Games",Games);
        Map<String,String> Gamest = new LinkedHashMap<>();
        Gamest.put("Name","game-Tools");
        Gamest.put("waitDisk", "#basedir#\\gamestls.izsetup");
        Gamest.put("comment:dependsOn","Dependency geht zu games und zu den dependencys von games");
        Gamest.put("dependsOn","Games");
        Gamest.put("script","#basedir#\\gamestls.izsetup");
        Gamest.put("detectInstall","File://C:\\Program Files\\ImgBurn\\ImgBurn.exexexe");
        Gamest.put("desc","Tools für die games aus dem Package");
        Gamest.put("defaultEnabled","true");
        izpackage.put("Game-Tools", Gamest);
        //Yaml y = new Yaml();
        String izbo = "000|izsetup|3.0.0|: valides YAML und trotzdem kompatibel" +"\n"+y.dump(izpackage);
        FileTK.writeFile(izbo, "D:\\src\\izsetup\\sample.izpackage");
        */
        //bundle.izmeta
        /*
        Map<String,String> izbundle = new LinkedHashMap<>();
        izbundle.put("comment:type","izbundle");
        izbundle.put("meta:isZipped","true");
        izbundle.put("comment:meta:isZipped","bei false sind die dateien als normale dateien neben dieser bundle gelagert -> kein entzippern\n" +
                    "CMM|in tempdir nötig. Muss bei multidisk-bundles deaktiviert sein. bei diskbundles wird Deaktivierung empfohlen\n" +
                        "CMM|da es die Festplatte nicht so vollstopft");
        izbundle.put("bundlename","Sample");
        izbundle.put("packagedata","sample.iZpackage");
        izbundle.put("description","Beispieldaten und testdaten");
        izbundle.put("extractSize","123556");
        
        String izbo = "000|izsetup|3.0.0|: valides YAML und trotzdem kompatibel" +"\n"+y.dump(izbundle);
        FileTK.writeFile(izbo, "D:\\src\\izsetup\\bundle.izmeta");
        */
        
        //temp code
        
        //FileTK.writeFile(y.dump(y.load(new FileInputStream("D:\\src\\izsetup\\sample.izpackage"))), "D:\\src\\izsetup\\valid");
        /*System.out.println(FileTK.fileAsString("D:\\src\\izsetup\\valid"));
        */
        
        
    
    }

}
