package com.swandiggy.poe4j.vorici.calc;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.swandiggy.poe4j.data.DatFileReader;
import com.swandiggy.poe4j.data.DatFileReaderFactory;
import com.swandiggy.poe4j.data.rows.BaseItemType;
import com.swandiggy.poe4j.data.rows.ComponentAttributeRequirement;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.boot.ExitCodeGenerator;
import org.springframework.stereotype.Service;

import java.nio.file.Paths;
import java.util.List;

import static java.util.stream.Collectors.toList;

/**
 * @author Jacob Swanson
 * @since 1/16/2016
 */
@Service
public class VoriciDataExtractor implements ApplicationRunner, ExitCodeGenerator {

    @Autowired
    private DatFileReaderFactory datFileReaderFactory;

    private ObjectMapper objectMapper = new ObjectMapper();

    @Override
    public void run(ApplicationArguments args) throws Exception {
        DatFileReader<BaseItemType> baseItemTypeReader = datFileReaderFactory.create(BaseItemType.class);
        DatFileReader<ComponentAttributeRequirement> attrReqReader = datFileReaderFactory.create(ComponentAttributeRequirement.class);

        List<ItemData> items = baseItemTypeReader.read()
                .filter(row -> row.getInheritsFrom().equals("Metadata/Items/Armours/BodyArmours/AbstractBodyArmour"))
                .flatMap(baseItemType -> {
                    return attrReqReader.read()
                            .filter(componentAttributeRequirement -> componentAttributeRequirement.getBaseItemType().equals(baseItemType));
                }).map(ItemData::new)
                .collect(toList());

        objectMapper.writeValue(Paths.get("C:\\Users\\Jacob\\Downloads\\item-data.json").toFile(), items);
    }

    @Override
    public int getExitCode() {
        return 0;
    }
}

@@ -83,24 +83,75 @@
 jectMapper;%0A
+import com.swandiggy.poe4j.config.Poe4jProperties;%0A
 import com.s
@@ -181,24 +181,24 @@
 FileReader;%0A
-
 import com.s
@@ -945,16 +945,72 @@
 ctory;%0A%0A
+    @Autowired%0A    private Poe4jProperties properties;%0A%0A
     priv
@@ -1142,16 +1142,85 @@
 ption %7B%0A
+        properties.setGgpkDirectory(args.getNonOptionArgs().get(0));%0A
         
@@ -1964,54 +1964,58 @@
 rite
-Value(Paths.get(%22C:%5C%5CUsers%5C%5CJacob%5C%5CDownloads%5C%5C
+rWithDefaultPrettyPrinter().writeValue(Paths.get(%22
 item

Fix Vorici data extractor