use of org.openlca.core.model.Version in project olca-modules by GreenDelta.
the class CategoryDao method updateModels.
private void updateModels(Category category) {
if (category == null)
return;
for (var d : getDescriptors(category.modelType, Optional.of(category))) {
Version v = new Version(d.version);
v.incUpdate();
long version = v.getValue();
long lastChange = System.currentTimeMillis();
d.version = version;
d.lastChange = lastChange;
String update = "UPDATE " + getTable(d.type) + " SET version = " + version + ", last_change = " + lastChange + " WHERE id = " + d.id;
NativeSql.on(db).runUpdate(update);
db.notifyUpdate(d);
}
}
use of org.openlca.core.model.Version in project olca-modules by GreenDelta.
the class ImpactMethods method exec.
private void exec() {
var version = block.version() != null ? new Version(block.version().major(), block.version().minor(), 0) : new Version(0, 0, 0);
var refId = KeyGen.get("SimaPro CSV", block.name(), version.toString());
var method = context.db().get(ImpactMethod.class, refId);
if (method != null) {
log.warn("an LCIA method refId='" + refId + "' already exists; skipped");
return;
}
method = new ImpactMethod();
method.refId = refId;
method.name = block.name();
method.version = version.getValue();
method.description = block.comment();
for (var csvImpact : block.impactCategories()) {
if (csvImpact.info() == null)
continue;
var impactId = KeyGen.get("SimaPro CSV", block.name(), version.toString(), csvImpact.info().name());
var impact = new ImpactCategory();
impact.refId = impactId;
impact.name = csvImpact.info().name();
impact.referenceUnit = csvImpact.info().unit();
addFactors(csvImpact, impact);
impact = context.insert(impact);
method.impactCategories.add(impact);
}
context.insert(method);
}
use of org.openlca.core.model.Version in project olca-modules by GreenDelta.
the class DocImportMapper method mapFileAttributes.
private void mapFileAttributes(AdminInfo adminInfo) {
if (adminInfo.fileAttributes == null)
return;
FileAttributes fileAtts = adminInfo.fileAttributes;
doc.creationDate = fileAtts.creationTimestamp;
if (fileAtts.lastEditTimestamp != null)
process.lastChange = fileAtts.lastEditTimestamp.getTime();
Version version = new Version(fileAtts.majorRelease, fileAtts.majorRevision, fileAtts.minorRelease);
process.version = version.getValue();
}
use of org.openlca.core.model.Version in project olca-modules by GreenDelta.
the class ProcessConverter method mapDataSetInformation.
private void mapDataSetInformation(ProcessDocumentation doc, DataSet dataSet) {
IDataSetInformation info = factory.createDataSetInformation();
dataSet.setDataSetInformation(info);
info.setEnergyValues(0);
info.setImpactAssessmentResult(false);
info.setLanguageCode(factory.getLanguageCode("en"));
info.setLocalLanguageCode(factory.getLanguageCode("en"));
if (process.lastChange != 0)
info.setTimestamp(Xml.calendar(process.lastChange));
else if (doc.creationDate != null)
info.setTimestamp(Xml.calendar(doc.creationDate));
else
info.setTimestamp(Xml.calendar(new Date()));
info.setType(getProcessType());
Version version = new Version(process.version);
info.setVersion(version.getMajor());
info.setInternalVersion(version.getMinor());
}
use of org.openlca.core.model.Version in project olca-app by GreenDelta.
the class DiffNodeViewer method toResolution.
private ConflictResolution toResolution(JsonNode node, int dialogResult) {
if (dialogResult == JsonDiffDialog.OVERWRITE_LOCAL || node.hasEqualValues())
return ConflictResolution.overwriteLocal();
if (dialogResult == JsonDiffDialog.KEEP_LOCAL_MODEL || node.leftEqualsOriginal())
return ConflictResolution.keepLocal();
var merged = node.left.getAsJsonObject();
Version version = Version.fromString(node.right.getAsJsonObject().get("version").getAsString());
version.incUpdate();
merged.addProperty("version", Version.asString(version.getValue()));
merged.addProperty("lastChange", Instant.now().toString());
return ConflictResolution.merge(merged);
}
Aggregations