use of org.openlca.core.database.ProductSystemDao in project olca-modules by GreenDelta.
the class ProductSystemWriter method mapProcesses.
private Map<Long, RootDescriptor> mapProcesses(ProductSystem system, ProtoProductSystem.Builder proto) {
var processes = new ProcessDao(config.db).descriptorMap();
var systems = new ProductSystemDao(config.db).descriptorMap();
Map<Long, RootDescriptor> map = new HashMap<>();
for (var id : system.processes) {
RootDescriptor d = processes.get(id);
if (d == null) {
d = systems.get(id);
}
if (d == null)
continue;
map.put(id, d);
proto.addProcesses(Refs.refOf(d));
Out.dep(config, d);
}
return map;
}
use of org.openlca.core.database.ProductSystemDao in project olca-modules by GreenDelta.
the class ModelImport method run.
public ProductSystem run(Model model) {
if (model == null)
return null;
var dao = new ProductSystemDao(config.db());
system = dao.getForRefId(model.getUUID());
if (system != null)
return system;
String origin = Models.getOrigin(model);
if (Strings.nullOrEqual("openLCA", origin)) {
system = new ProductSystem();
IO.mapMetaData(model, system);
String[] path = Categories.getPath(model);
system.category = new CategoryDao(config.db()).sync(ModelType.PRODUCT_SYSTEM, path);
mapModel(model);
system = dao.insert(system);
config.log().imported(system);
return system;
} else {
Graph g = Graph.build(model, config.db());
g = Transformation.on(g);
return new GraphSync(config).sync(model, g);
}
}
use of org.openlca.core.database.ProductSystemDao in project olca-app by GreenDelta.
the class Export method tryExportSystem.
private void tryExportSystem(ExportConfig config, Descriptor d) {
try {
ProductSystem system = new ProductSystemDao(database).getForId(d.id);
SystemExport export = new SystemExport(config);
export.run(system);
monitor.worked(1);
} catch (Exception e) {
log.error("System export failed", e);
}
}
use of org.openlca.core.database.ProductSystemDao in project olca-app by GreenDelta.
the class CalculateSystemAction method run.
@Override
public void run() {
var system = new ProductSystemDao(Database.get()).getForId(systemId);
if (system == null)
return;
CalculationWizard.open(system);
}
Aggregations