use of org.openlca.core.model.ModelType in project olca-modules by GreenDelta.
the class ZipStoreTest method testWriteModels.
@Test
public void testWriteModels() {
Map<ModelType, String> entries = writeModels();
with(zip -> {
for (ModelType type : entries.keySet()) {
var refId = entries.get(type);
var json = zip.get(type, refId);
Assert.assertNotNull(json);
}
});
}
use of org.openlca.core.model.ModelType in project olca-modules by GreenDelta.
the class ZipStoreTest method testReadModels.
@Test
public void testReadModels() {
Map<ModelType, String> entries = writeModels();
with(zip -> {
for (ModelType type : entries.keySet()) {
String id = entries.get(type);
JsonObject obj = zip.get(type, id);
String name = obj.get("name").getAsString();
Assert.assertEquals(type.name(), name);
}
});
}
use of org.openlca.core.model.ModelType in project olca-modules by GreenDelta.
the class CategoryDao method getTable.
private String getTable(ModelType modelType) {
if (tables == null) {
tables = new HashMap<>();
for (ModelType type : ModelType.values()) {
if (type.getModelClass() == null || !RefEntity.class.isAssignableFrom(type.getModelClass()))
continue;
String table = Daos.refDao(db, type).getEntityTable();
tables.put(type, table);
}
}
return tables.get(modelType);
}
use of org.openlca.core.model.ModelType in project olca-modules by GreenDelta.
the class References method of.
public static <D extends RootDescriptor> List<Reference> of(IDatabase db, Collection<D> owners) {
ModelType type = null;
var ids = new HashSet<Long>();
for (var d : owners) {
if (d == null || d.id == 0)
continue;
if (type == null) {
type = d.type;
} else if (type != d.type) {
throw new IllegalArgumentException("Mixed descriptor " + "types are not allowed in reference search");
}
ids.add(d.id);
}
return type == null || ids.isEmpty() ? Collections.emptyList() : of(db, type, ids);
}
use of org.openlca.core.model.ModelType in project olca-app by GreenDelta.
the class Widgets method dropComponent.
public static TextDropComponent dropComponent(Composite parent, String label, String property, ModelEditor<?> editor, FormToolkit toolkit) {
ModelType modelType = getModelType(editor.getModel(), property);
toolkit.createLabel(parent, label, SWT.NONE);
TextDropComponent text = new TextDropComponent(parent, toolkit, modelType);
UI.gridData(text, true, false);
editor.getBinding().onModel(editor::getModel, property, text);
new CommentControl(parent, toolkit, property, editor.getComments());
return text;
}
Aggregations