Search in sources :

Example 1 with SpecsRoot

use of eu.ggnet.dwoss.spec.ee.entity.xml.SpecsRoot in project dwoss by gg-net.

the class SpecGenerator method initSerialized.

private synchronized void initSerialized() {
    if (productSpecs != null && !productSpecs.isEmpty())
        return;
    try (InputStream is = getClass().getResourceAsStream("specs.ser");
        ObjectInputStream ois = new ObjectInputStream(is)) {
        SpecsRoot root = (SpecsRoot) ois.readObject();
        productSpecs = root.getProductSpecs();
    } catch (ClassNotFoundException | IOException e) {
        throw new RuntimeException(e);
    }
}
Also used : SpecsRoot(eu.ggnet.dwoss.spec.ee.entity.xml.SpecsRoot)

Example 2 with SpecsRoot

use of eu.ggnet.dwoss.spec.ee.entity.xml.SpecsRoot in project dwoss by gg-net.

the class SpecGenerator method initXml.

private synchronized void initXml() {
    if (productSpecs != null && !productSpecs.isEmpty())
        return;
    try (InputStream is = getClass().getResourceAsStream("specs.xml")) {
        SpecsRoot root = JAXB.unmarshal(is, SpecsRoot.class);
        productSpecs = root.getProductSpecs();
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
}
Also used : SpecsRoot(eu.ggnet.dwoss.spec.ee.entity.xml.SpecsRoot)

Example 3 with SpecsRoot

use of eu.ggnet.dwoss.spec.ee.entity.xml.SpecsRoot in project dwoss by gg-net.

the class SpecExporterOperation method toXml.

/**
 * Exports specs to an XML till the supplied amount.
 * <p>
 * @param amount the amount to export
 * @return a FileJacket containing all the found specs.
 */
@Override
public FileJacket toXml(int amount) {
    SubMonitor m = monitorFactory.newSubMonitor("Export ProductSpecs", amount + 10);
    m.start();
    m.message("init");
    ProductSpecEao specEao = new ProductSpecEao(em);
    int count = specEao.count();
    m.worked(2);
    if (count < amount) {
        m.setWorkRemaining(count + 8);
        amount = count;
    }
    // load in the batches of 10
    int step = 10;
    List<ProductSpec> exportSpecs = new ArrayList<>();
    for (int i = 0; i <= amount; i = i + step) {
        m.worked(step, "loading " + step + " Spec beginning by " + i);
        for (ProductSpec spec : specEao.findAll(i, step)) {
            if (spec instanceof DesktopBundle)
                continue;
            exportSpecs.add(spec);
        }
    }
    try {
        File f = File.createTempFile("specs", ".xml");
        try (OutputStream fw = new BufferedOutputStream(new FileOutputStream(f))) {
            m.message("marschaling");
            JAXB.marshal(new SpecsRoot(exportSpecs), fw);
        }
        return new FileJacket("specs", ".xml", f);
    } catch (IOException ex) {
        throw new RuntimeException("", ex);
    } finally {
        m.finish();
    }
}
Also used : SubMonitor(eu.ggnet.dwoss.progress.SubMonitor) ProductSpec(eu.ggnet.dwoss.spec.ee.entity.ProductSpec) DesktopBundle(eu.ggnet.dwoss.spec.ee.entity.DesktopBundle) FileJacket(eu.ggnet.dwoss.util.FileJacket) SpecsRoot(eu.ggnet.dwoss.spec.ee.entity.xml.SpecsRoot) ProductSpecEao(eu.ggnet.dwoss.spec.ee.eao.ProductSpecEao)

Aggregations

SpecsRoot (eu.ggnet.dwoss.spec.ee.entity.xml.SpecsRoot)3 SubMonitor (eu.ggnet.dwoss.progress.SubMonitor)1 ProductSpecEao (eu.ggnet.dwoss.spec.ee.eao.ProductSpecEao)1 DesktopBundle (eu.ggnet.dwoss.spec.ee.entity.DesktopBundle)1 ProductSpec (eu.ggnet.dwoss.spec.ee.entity.ProductSpec)1 FileJacket (eu.ggnet.dwoss.util.FileJacket)1