Search in sources :

Example 1 with RootDescriptor

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

the class FlowPropertyFactorUseSearchTest method testFindInImpactCategory.

@Test
public void testFindInImpactCategory() {
    ImpactFactor iFactor = new ImpactFactor();
    iFactor.flow = flow;
    iFactor.flowPropertyFactor = factor;
    ImpactCategory category = new ImpactCategory();
    category.impactFactors.add(iFactor);
    ImpactCategoryDao dao = new ImpactCategoryDao(database);
    dao.insert(category);
    List<RootDescriptor> results = search.findUses(factor);
    dao.delete(category);
    Assert.assertEquals(1, results.size());
    Descriptor expected = Descriptor.of(category);
    Assert.assertEquals(expected, results.get(0));
}
Also used : ImpactFactor(org.openlca.core.model.ImpactFactor) RootDescriptor(org.openlca.core.model.descriptors.RootDescriptor) Descriptor(org.openlca.core.model.descriptors.Descriptor) RootDescriptor(org.openlca.core.model.descriptors.RootDescriptor) ImpactCategory(org.openlca.core.model.ImpactCategory) ImpactCategoryDao(org.openlca.core.database.ImpactCategoryDao) Test(org.junit.Test)

Example 2 with RootDescriptor

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

the class FlowPropertyFactorUseSearchTest method testFindInProcesses.

@Test
public void testFindInProcesses() {
    Process process = createProcess();
    List<RootDescriptor> results = search.findUses(factor);
    new ProcessDao(database).delete(process);
    Descriptor expected = Descriptor.of(process);
    Assert.assertEquals(1, results.size());
    Assert.assertEquals(expected, results.get(0));
}
Also used : ProcessDao(org.openlca.core.database.ProcessDao) RootDescriptor(org.openlca.core.model.descriptors.RootDescriptor) Descriptor(org.openlca.core.model.descriptors.Descriptor) RootDescriptor(org.openlca.core.model.descriptors.RootDescriptor) Process(org.openlca.core.model.Process) Test(org.junit.Test)

Example 3 with RootDescriptor

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

the class RefEntityDaoTest method testGetDescriptorsForCategory.

private <T extends RootEntity, V extends RootDescriptor> void testGetDescriptorsForCategory(RootEntityDao<T, V> dao, T instance, Category category) {
    List<V> descriptors = dao.getDescriptors(Optional.ofNullable(category));
    Descriptor descriptor = ListUtils.findDescriptor(instance.id, descriptors);
    Assert.assertNotNull(descriptor);
    new CategoryDao(Tests.getDb()).delete(category);
}
Also used : Descriptor(org.openlca.core.model.descriptors.Descriptor) RootDescriptor(org.openlca.core.model.descriptors.RootDescriptor)

Example 4 with RootDescriptor

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

the class RefEntityDaoTest method testFindForNullCategory.

private <T extends RootEntity, V extends RootDescriptor> void testFindForNullCategory(RootEntityDao<T, V> dao, T instance) {
    List<V> descriptors = dao.getDescriptors(Optional.empty());
    Descriptor descriptor = ListUtils.findDescriptor(instance.id, descriptors);
    Assert.assertNotNull(descriptor);
}
Also used : Descriptor(org.openlca.core.model.descriptors.Descriptor) RootDescriptor(org.openlca.core.model.descriptors.RootDescriptor)

Example 5 with RootDescriptor

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

the class ProcessGrouping method split.

private static List<RootDescriptor> split(List<String> processIds, List<RootDescriptor> processes) {
    List<RootDescriptor> matches = new ArrayList<>();
    for (String id : processIds) {
        for (RootDescriptor p : processes) {
            if (p.refId != null && p.refId.equals(id))
                matches.add(p);
        }
    }
    processes.removeAll(matches);
    return matches;
}
Also used : ArrayList(java.util.ArrayList) RootDescriptor(org.openlca.core.model.descriptors.RootDescriptor)

Aggregations

RootDescriptor (org.openlca.core.model.descriptors.RootDescriptor)19 ProcessDao (org.openlca.core.database.ProcessDao)4 Descriptor (org.openlca.core.model.descriptors.Descriptor)4 ArrayList (java.util.ArrayList)3 Test (org.junit.Test)3 ProductSystemDao (org.openlca.core.database.ProductSystemDao)3 Process (org.openlca.core.model.Process)3 RootEntity (org.openlca.core.model.RootEntity)3 TLongIntHashMap (gnu.trove.map.hash.TLongIntHashMap)2 TLongHashSet (gnu.trove.set.hash.TLongHashSet)2 HashMap (java.util.HashMap)2 Composite (org.eclipse.swt.widgets.Composite)2 ImageHyperlink (org.eclipse.ui.forms.widgets.ImageHyperlink)2 ProcessNode (org.openlca.app.editors.graphical.model.ProcessNode)2 FlowDao (org.openlca.core.database.FlowDao)2 TechFlow (org.openlca.core.matrix.index.TechFlow)2 Category (org.openlca.core.model.Category)2 ImpactCategory (org.openlca.core.model.ImpactCategory)2 ModelType (org.openlca.core.model.ModelType)2 ProcessLink (org.openlca.core.model.ProcessLink)2