Search in sources :

Example 6 with Category

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

the class ProductSystemReferenceSearchTest method createModel.

@Override
protected ProductSystem createModel() {
    ProductSystem system = new ProductSystem();
    system.category = insertAndAddExpected("category", new Category());
    system.referenceProcess = createProcess();
    system.referenceExchange = system.referenceProcess.exchanges.get(0);
    system.targetFlowPropertyFactor = system.referenceExchange.flowPropertyFactor;
    system.targetUnit = system.targetFlowPropertyFactor.flowProperty.unitGroup.units.get(0);
    system.processes.add(system.referenceProcess.id);
    Process p1 = insertAndAddExpected("processes", new Process());
    Process p2 = insertAndAddExpected("processes", new Process());
    Process p3 = insertAndAddExpected("processes", new Process());
    system.processes.add(p1.id);
    system.processes.add(p2.id);
    system.processes.add(p3.id);
    system.processLinks.add(createLink(p1, p2));
    system.processLinks.add(createLink(p2, p3));
    String n1 = generateName();
    String n2 = generateName();
    String n3 = generateName();
    // TODO: find parameter references
    // system.parameterRedefs.add(createParameterRedef(n1, p1.id));
    // formula with parameter to see if added as reference (unexpected)
    // system.parameterRedefs.add(createParameterRedef(n2, n3 + "*5"));
    Parameter globalUnreferenced = createParameter(n1, "3*3", true);
    Parameter globalUnreferenced2 = createParameter(n3, "3*3", true);
    // must be inserted manually
    globalUnreferenced = db.insert(globalUnreferenced);
    globalUnreferenced2 = db.insert(globalUnreferenced2);
    return db.insert(system);
}
Also used : Category(org.openlca.core.model.Category) ProductSystem(org.openlca.core.model.ProductSystem) Parameter(org.openlca.core.model.Parameter) Process(org.openlca.core.model.Process)

Example 7 with Category

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

the class CurrencyReferenceSearchTest method createModel.

@Override
protected Currency createModel() {
    Currency currency = new Currency();
    currency.category = insertAndAddExpected("category", new Category());
    currency.referenceCurrency = insertAndAddExpected("referenceCurrency", new Currency());
    currency = db.insert(currency);
    currencies.add(currency);
    return currency;
}
Also used : Category(org.openlca.core.model.Category) Currency(org.openlca.core.model.Currency)

Example 8 with Category

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

the class UnitGroupReferenceSearchTest method createModel.

@Override
protected UnitGroup createModel() {
    UnitGroup group = new UnitGroup();
    group.category = insertAndAddExpected("category", new Category());
    group.defaultFlowProperty = insertAndAddExpected("defaultFlowProperty", new FlowProperty());
    return db.insert(group);
}
Also used : UnitGroup(org.openlca.core.model.UnitGroup) Category(org.openlca.core.model.Category) FlowProperty(org.openlca.core.model.FlowProperty)

Example 9 with Category

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

the class RefEntityDaoTest method addCategory.

private <T extends RootEntity, V extends RootDescriptor> Category addCategory(Class<T> clazz, RootEntityDao<T, V> dao, T instance) {
    Category category = new Category();
    category.refId = UUID.randomUUID().toString();
    category.name = "test_category";
    category.modelType = ModelType.forModelClass(clazz);
    CategoryDao catDao = new CategoryDao(Tests.getDb());
    catDao.insert(category);
    instance.category = category;
    dao.update(instance);
    return category;
}
Also used : ImpactCategory(org.openlca.core.model.ImpactCategory) Category(org.openlca.core.model.Category)

Example 10 with Category

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

the class CategoryDaoTest method testFindRoot.

@Test
public void testFindRoot() {
    Category parent = create();
    Category child = create();
    parent.childCategories.add(child);
    child.category = parent;
    dao.insert(parent);
    Tests.emptyCache();
    List<Category> roots = dao.getRootCategories(ModelType.FLOW);
    Assert.assertTrue(roots.contains(parent));
    Assert.assertFalse(roots.contains(child));
    dao.delete(parent);
}
Also used : Category(org.openlca.core.model.Category) Test(org.junit.Test)

Aggregations

Category (org.openlca.core.model.Category)77 Test (org.junit.Test)11 CategoryDao (org.openlca.core.database.CategoryDao)11 Flow (org.openlca.core.model.Flow)6 Parameter (org.openlca.core.model.Parameter)6 CategoryElement (org.openlca.app.navigation.elements.CategoryElement)4 ModelElement (org.openlca.app.navigation.elements.ModelElement)4 IDatabase (org.openlca.core.database.IDatabase)4 FlowProperty (org.openlca.core.model.FlowProperty)4 Location (org.openlca.core.model.Location)4 Process (org.openlca.core.model.Process)4 UnitGroup (org.openlca.core.model.UnitGroup)4 ArrayList (java.util.ArrayList)3 ImpactCategory (org.openlca.core.model.ImpactCategory)3 ImpactMethod (org.openlca.core.model.ImpactMethod)3 ModelType (org.openlca.core.model.ModelType)3 IsicNode (org.openlca.io.ecospold2.input.IsicTree.IsicNode)3 Actor (org.openlca.core.model.Actor)2 Currency (org.openlca.core.model.Currency)2 DQSystem (org.openlca.core.model.DQSystem)2