Search in sources :

Example 1 with SocialIndicator

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

the class SocialIndicatorImport method createSocialIndicator.

private void createSocialIndicator(SocialIndicatorDescriptor descriptor) {
    SocialIndicator src = srcDao.getForId(descriptor.id);
    SocialIndicator dest = src.copy();
    dest.refId = src.refId;
    dest.category = refs.switchRef(src.category);
    dest.activityQuantity = refs.switchRef(src.activityQuantity);
    dest.activityUnit = refs.switchRef(src.activityUnit);
    dest = destDao.insert(dest);
    seq.put(seq.SOCIAL_INDICATOR, src.refId, dest.id);
}
Also used : SocialIndicator(org.openlca.core.model.SocialIndicator)

Example 2 with SocialIndicator

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

the class DataUtil method toDataSet.

static ProtoDataSet.Builder toDataSet(IDatabase db, RefEntity e) {
    var ds = ProtoDataSet.newBuilder();
    var conf = WriterConfig.of(db);
    if (e instanceof Actor)
        return ds.setActor(new ActorWriter(conf).write((Actor) e));
    if (e instanceof Category)
        return ds.setCategory(new CategoryWriter(conf).write((Category) e));
    if (e instanceof Currency)
        return ds.setCurrency(new CurrencyWriter(conf).write((Currency) e));
    if (e instanceof DQSystem)
        return ds.setDqSystem(new DQSystemWriter(conf).write((DQSystem) e));
    if (e instanceof Flow)
        return ds.setFlow(new FlowWriter(conf).write((Flow) e));
    if (e instanceof FlowProperty)
        return ds.setFlowProperty(new FlowPropertyWriter(conf).write((FlowProperty) e));
    if (e instanceof ImpactCategory)
        return ds.setImpactCategory(new ImpactCategoryWriter(conf).write((ImpactCategory) e));
    if (e instanceof ImpactMethod)
        return ds.setImpactMethod(new ImpactMethodWriter(conf).write((ImpactMethod) e));
    if (e instanceof Location)
        return ds.setLocation(new LocationWriter(conf).write((Location) e));
    if (e instanceof Parameter)
        return ds.setParameter(new ParameterWriter(conf).write((Parameter) e));
    if (e instanceof Process)
        return ds.setProcess(new ProcessWriter(conf).write((Process) e));
    if (e instanceof ProductSystem)
        return ds.setProductSystem(new ProductSystemWriter(conf).write((ProductSystem) e));
    if (e instanceof Project)
        return ds.setProject(new ProjectWriter(conf).write((Project) e));
    if (e instanceof SocialIndicator)
        return ds.setSocialIndicator(new SocialIndicatorWriter(conf).write((SocialIndicator) e));
    if (e instanceof Source)
        return ds.setSource(new SourceWriter(conf).write((Source) e));
    if (e instanceof UnitGroup)
        return ds.setUnitGroup(new UnitGroupWriter(conf).write((UnitGroup) e));
    return ds;
}
Also used : ImpactCategory(org.openlca.core.model.ImpactCategory) Category(org.openlca.core.model.Category) UnitGroup(org.openlca.core.model.UnitGroup) ImpactCategoryWriter(org.openlca.proto.io.output.ImpactCategoryWriter) ProductSystem(org.openlca.core.model.ProductSystem) Process(org.openlca.core.model.Process) UnitGroupWriter(org.openlca.proto.io.output.UnitGroupWriter) ImpactMethod(org.openlca.core.model.ImpactMethod) ProductSystemWriter(org.openlca.proto.io.output.ProductSystemWriter) Source(org.openlca.core.model.Source) CurrencyWriter(org.openlca.proto.io.output.CurrencyWriter) FlowPropertyWriter(org.openlca.proto.io.output.FlowPropertyWriter) Actor(org.openlca.core.model.Actor) Currency(org.openlca.core.model.Currency) CategoryWriter(org.openlca.proto.io.output.CategoryWriter) ImpactCategoryWriter(org.openlca.proto.io.output.ImpactCategoryWriter) FlowProperty(org.openlca.core.model.FlowProperty) FlowWriter(org.openlca.proto.io.output.FlowWriter) ImpactCategory(org.openlca.core.model.ImpactCategory) SourceWriter(org.openlca.proto.io.output.SourceWriter) Flow(org.openlca.core.model.Flow) LocationWriter(org.openlca.proto.io.output.LocationWriter) Project(org.openlca.core.model.Project) DQSystemWriter(org.openlca.proto.io.output.DQSystemWriter) ParameterWriter(org.openlca.proto.io.output.ParameterWriter) DQSystem(org.openlca.core.model.DQSystem) ActorWriter(org.openlca.proto.io.output.ActorWriter) ImpactMethodWriter(org.openlca.proto.io.output.ImpactMethodWriter) ProjectWriter(org.openlca.proto.io.output.ProjectWriter) Parameter(org.openlca.core.model.Parameter) SocialIndicator(org.openlca.core.model.SocialIndicator) ProcessWriter(org.openlca.proto.io.output.ProcessWriter) Location(org.openlca.core.model.Location) SocialIndicatorWriter(org.openlca.proto.io.output.SocialIndicatorWriter)

Example 3 with SocialIndicator

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

the class SocialIndicatorTest method doImport.

private void doImport(SocialIndicatorDao dao, SocialIndicator indicator) {
    with(zip -> {
        JsonImport jImport = new JsonImport(zip, Tests.getDb());
        jImport.run();
    });
    Assert.assertTrue(dao.contains(indicator.refId));
    SocialIndicator clone = dao.getForRefId(indicator.refId);
    Assert.assertEquals(indicator.name, clone.name);
}
Also used : JsonImport(org.openlca.jsonld.input.JsonImport) SocialIndicator(org.openlca.core.model.SocialIndicator)

Example 4 with SocialIndicator

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

the class SocialIndicatorTest method testSocialIndicator.

@Test
public void testSocialIndicator() {
    SocialIndicatorDao dao = new SocialIndicatorDao(Tests.getDb());
    SocialIndicator indicator = createModel(dao);
    doExport(indicator, dao);
    doImport(dao, indicator);
    dao.delete(indicator);
}
Also used : SocialIndicator(org.openlca.core.model.SocialIndicator) SocialIndicatorDao(org.openlca.core.database.SocialIndicatorDao) AbstractZipTest(org.openlca.jsonld.AbstractZipTest) Test(org.junit.Test)

Example 5 with SocialIndicator

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

the class SocialIndicatorTest method createModel.

private SocialIndicator createModel(SocialIndicatorDao dao) {
    SocialIndicator indicator = new SocialIndicator();
    indicator.name = "indicator";
    indicator.refId = UUID.randomUUID().toString();
    dao.insert(indicator);
    return indicator;
}
Also used : SocialIndicator(org.openlca.core.model.SocialIndicator)

Aggregations

SocialIndicator (org.openlca.core.model.SocialIndicator)14 SocialIndicatorDao (org.openlca.core.database.SocialIndicatorDao)4 SocialAspect (org.openlca.core.model.SocialAspect)3 Test (org.junit.Test)2 Category (org.openlca.core.model.Category)2 FlowProperty (org.openlca.core.model.FlowProperty)2 Process (org.openlca.core.model.Process)2 Source (org.openlca.core.model.Source)2 UnitGroup (org.openlca.core.model.UnitGroup)2 Before (org.junit.Before)1 Ignore (org.junit.Ignore)1 IDatabase (org.openlca.core.database.IDatabase)1 ProcessDao (org.openlca.core.database.ProcessDao)1 Actor (org.openlca.core.model.Actor)1 Currency (org.openlca.core.model.Currency)1 DQSystem (org.openlca.core.model.DQSystem)1 Flow (org.openlca.core.model.Flow)1 ImpactCategory (org.openlca.core.model.ImpactCategory)1 ImpactMethod (org.openlca.core.model.ImpactMethod)1 Location (org.openlca.core.model.Location)1