Search in sources :

Example 11 with ModelType

use of org.openlca.core.model.ModelType in project olca-modules by GreenDelta.

the class ProductSystemWriter method mapProcesses.

private void mapProcesses(JsonObject json) {
    var refs = exp.refs;
    if (refs == null)
        return;
    var array = new JsonArray();
    var types = new ModelType[] { ModelType.PROCESS, ModelType.PRODUCT_SYSTEM, ModelType.RESULT };
    for (var id : system.processes) {
        if (id == null)
            continue;
        long unboxedId = id;
        ModelType type = null;
        for (var t : types) {
            if (refs.descriptorOf(t, unboxedId) != null) {
                type = t;
                break;
            }
        }
        if (type == null)
            continue;
        var ref = exp.handleRef(type, unboxedId);
        if (ref == null)
            continue;
        array.add(ref);
    }
    Json.put(json, "processes", array);
}
Also used : JsonArray(com.google.gson.JsonArray) ModelType(org.openlca.core.model.ModelType)

Example 12 with ModelType

use of org.openlca.core.model.ModelType in project olca-modules by GreenDelta.

the class ExportConfig method visited.

void visited(RefEntity entity) {
    if (entity == null)
        return;
    ModelType type = ModelType.forModelClass(entity.getClass());
    Set<Long> set = visited.computeIfAbsent(type, k -> new HashSet<>());
    set.add(entity.id);
}
Also used : ModelType(org.openlca.core.model.ModelType)

Example 13 with ModelType

use of org.openlca.core.model.ModelType in project olca-modules by GreenDelta.

the class Categories method createRefId.

public static String createRefId(Category category) {
    if (category == null)
        return null;
    List<String> path = path(category);
    ModelType type = category.modelType;
    if (type != null)
        path.add(0, type.name());
    return KeyGen.get(path.toArray(new String[0]));
}
Also used : ModelType(org.openlca.core.model.ModelType)

Example 14 with ModelType

use of org.openlca.core.model.ModelType in project olca-app by GreenDelta.

the class Search method run.

@Override
public void run() {
    result.clear();
    if (rawTerm.isEmpty())
        return;
    log.trace("run search with term {}", rawTerm);
    ModelType[] types = typeFilter == null ? ModelTypeOrder.getOrderedTypes() : new ModelType[] { typeFilter };
    for (ModelType type : types) {
        List<?> descriptors = getDescriptors(type);
        fetchResults(descriptors);
    }
    Collections.sort(result, new ResultComparator());
    log.trace("{} results fetched and ranked", result.size());
}
Also used : ModelType(org.openlca.core.model.ModelType)

Example 15 with ModelType

use of org.openlca.core.model.ModelType in project olca-app by GreenDelta.

the class GroupElement method queryChilds.

@Override
protected List<INavigationElement<?>> queryChilds() {
    var group = getContent();
    if (group == null)
        return Collections.emptyList();
    // add the model type elements of this group
    var elements = new ArrayList<INavigationElement<?>>();
    for (ModelType type : getContent().types) {
        elements.add(new ModelTypeElement(this, type));
    }
    // if available
    if (group.type != GroupType.BACKGROUND_DATA)
        return elements;
    var lib = getLibrary();
    if (lib.isPresent())
        return elements;
    var db = Database.get();
    if (db == null)
        return elements;
    var names = new MappingFileDao(db).getNames();
    if (!names.isEmpty()) {
        elements.add(new MappingDirElement(this, names));
    }
    return elements;
}
Also used : ArrayList(java.util.ArrayList) ModelType(org.openlca.core.model.ModelType) MappingFileDao(org.openlca.core.database.MappingFileDao)

Aggregations

ModelType (org.openlca.core.model.ModelType)21 JsonObject (com.google.gson.JsonObject)4 Test (org.junit.Test)4 HashSet (java.util.HashSet)3 Category (org.openlca.core.model.Category)3 JsonArray (com.google.gson.JsonArray)2 File (java.io.File)2 HashMap (java.util.HashMap)2 Set (java.util.Set)2 JsonElement (com.google.gson.JsonElement)1 IOException (java.io.IOException)1 Files (java.nio.file.Files)1 Path (java.nio.file.Path)1 StandardCopyOption (java.nio.file.StandardCopyOption)1 ArrayList (java.util.ArrayList)1 Predicate (java.util.function.Predicate)1 Collectors (java.util.stream.Collectors)1 TextDropComponent (org.openlca.app.components.TextDropComponent)1 CommentControl (org.openlca.app.editors.comments.CommentControl)1 Tests (org.openlca.core.Tests)1