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);
}
}
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);
}
}
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();
}
}
Aggregations