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);
}
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);
}
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]));
}
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());
}
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;
}
Aggregations