Search in sources :

Example 1 with Version

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);
    }
}
Also used : Version(org.openlca.core.model.Version)

Example 2 with Version

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);
}
Also used : Version(org.openlca.core.model.Version) ImpactCategory(org.openlca.core.model.ImpactCategory) ImpactMethod(org.openlca.core.model.ImpactMethod)

Example 3 with Version

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();
}
Also used : Version(org.openlca.core.model.Version) FileAttributes(spold2.FileAttributes)

Example 4 with Version

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());
}
Also used : Version(org.openlca.core.model.Version) IDataSetInformation(org.openlca.ecospold.IDataSetInformation) Date(java.util.Date)

Example 5 with Version

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);
}
Also used : Version(org.openlca.core.model.Version)

Aggregations

Version (org.openlca.core.model.Version)8 JsonObject (com.google.gson.JsonObject)1 Date (java.util.Date)1 ImpactCategory (org.openlca.core.model.ImpactCategory)1 ImpactMethod (org.openlca.core.model.ImpactMethod)1 IDataSetInformation (org.openlca.ecospold.IDataSetInformation)1 FileAttributes (spold2.FileAttributes)1