use of org.openlca.ilcd.models.QuantitativeReference in project olca-modules by GreenDelta.
the class SystemExport method initModel.
private Model initModel() {
Model model = new Model();
Models.setOrigin(model, "openLCA");
model.version = "1.1";
model.locations = "../ILCDLocations.xml";
DataSetInfo info = Models.forceDataSetInfo(model);
info.uuid = system.refId;
ModelName name = Models.forceModelName(model);
name.name.add(LangString.of(system.name, config.lang));
if (system.description != null) {
info.comment.add(LangString.of(system.description, config.lang));
}
CategoryConverter conv = new CategoryConverter();
Classification c = conv.getClassification(system.category);
if (c != null)
Models.forceClassifications(model).add(c);
if (system.referenceProcess != null) {
long refId = system.referenceProcess.id;
QuantitativeReference qRef = Models.forceQuantitativeReference(model);
qRef.refProcess = processIDs.getOrDefault(refId, -1);
}
Models.forcePublication(model).version = Version.asString(system.version);
model.modelling = new Modelling();
return model;
}
use of org.openlca.ilcd.models.QuantitativeReference in project olca-modules by GreenDelta.
the class Graph method build.
/**
* Creates a graph that synchronizes the given eILCD model with the given
* database.
*/
static Graph build(Model model, IDatabase db) {
Graph g = new Graph();
Logger log = LoggerFactory.getLogger(Graph.class);
if (model == null || model.info == null || db == null) {
log.warn("Invalid constraints; return empty index");
return g;
}
Technology tech = model.info.technology;
if (tech == null) {
log.warn("No processes in model; return empty index");
return g;
}
Map<Integer, Group> groups = tech.groups.stream().collect(Collectors.toMap(group -> group.id, group -> group));
ProcessDao dao = new ProcessDao(db);
for (ProcessInstance pi : tech.processes) {
if (pi.process == null || pi.process.uuid == null) {
log.warn("Invalid process reference node={}", pi.id);
continue;
}
String refID = pi.process.uuid;
Process process = dao.getForRefId(refID);
if (process == null) {
log.warn("Could not find process {}; skip node {}", refID, pi.id);
continue;
}
Node n = Node.init(pi, process);
if (!pi.groupRefs.isEmpty()) {
GroupRef gr = pi.groupRefs.get(0);
n.group = groups.get(gr.groupID);
}
g.putNode(n);
}
buildLinks(g, model);
QuantitativeReference qRef = model.info.quantitativeReference;
if (qRef != null && qRef.refProcess != null) {
g.root = g.getNode(qRef.refProcess);
}
return g;
}
Aggregations