Search in sources :

Example 1 with UnitGroup

use of org.openlca.ilcd.units.UnitGroup in project olca-modules by GreenDelta.

the class UnitGroupExport method run.

public UnitGroup run(org.openlca.core.model.UnitGroup unitGroup) {
    if (config.store.contains(UnitGroup.class, unitGroup.refId))
        return config.store.get(UnitGroup.class, unitGroup.refId);
    this.unitGroup = unitGroup;
    UnitGroup iUnitGroup = new UnitGroup();
    iUnitGroup.version = "1.1";
    UnitGroupInfo info = new UnitGroupInfo();
    iUnitGroup.unitGroupInfo = info;
    info.dataSetInfo = makeDataSetInfo();
    info.quantitativeReference = makeQRef();
    iUnitGroup.adminInfo = makeAdminInfo();
    makeUnits(iUnitGroup);
    config.store.put(iUnitGroup);
    this.unitGroup = null;
    return iUnitGroup;
}
Also used : UnitGroup(org.openlca.ilcd.units.UnitGroup) UnitGroupInfo(org.openlca.ilcd.units.UnitGroupInfo)

Example 2 with UnitGroup

use of org.openlca.ilcd.units.UnitGroup in project olca-modules by GreenDelta.

the class NetworkPutUnitGroupTest method testPutUnitGroup.

@Test
public void testPutUnitGroup() throws Exception {
    Assume.assumeTrue(TestServer.isAvailable());
    String id = UUID.randomUUID().toString();
    UnitGroup ug = new UnitGroup();
    UnitGroupInfo info = new UnitGroupInfo();
    ug.unitGroupInfo = info;
    info.dataSetInfo = makeDataInfo(id);
    ug.adminInfo = makeAdminInfo();
    client.put(ug);
}
Also used : UnitGroup(org.openlca.ilcd.units.UnitGroup) UnitGroupInfo(org.openlca.ilcd.units.UnitGroupInfo) LangString(org.openlca.ilcd.commons.LangString) Test(org.junit.Test)

Example 3 with UnitGroup

use of org.openlca.ilcd.units.UnitGroup in project olca-modules by GreenDelta.

the class FileStoreTest method testGet.

@Test
public void testGet() throws Exception {
    UnitGroup group = fileStore.get(UnitGroup.class, "93a60a57-a4c8-11da-a746-0800200c9a66");
    assertNotNull(group);
    UnitGroupBag bag = new UnitGroupBag(group, "en");
    assertEquals("Units of mass", bag.getName());
}
Also used : UnitGroup(org.openlca.ilcd.units.UnitGroup) UnitGroupBag(org.openlca.ilcd.util.UnitGroupBag) Test(org.junit.Test)

Example 4 with UnitGroup

use of org.openlca.ilcd.units.UnitGroup in project olca-modules by GreenDelta.

the class DescriptorTest method setUp.

@Before
public void setUp() throws Exception {
    if (!TestServer.isAvailable())
        return;
    SodaClient client = TestServer.newClient();
    XmlBinder binder = new XmlBinder();
    UnitGroup group = binder.fromStream(UnitGroup.class, getClass().getResourceAsStream("unit.xml"));
    UnitGroupBag bag = new UnitGroupBag(group, "en");
    if (client.contains(UnitGroup.class, bag.getId()))
        return;
    client.put(group);
}
Also used : SodaClient(org.openlca.ilcd.io.SodaClient) XmlBinder(org.openlca.ilcd.io.XmlBinder) UnitGroup(org.openlca.ilcd.units.UnitGroup) UnitGroupBag(org.openlca.ilcd.util.UnitGroupBag) Before(org.junit.Before)

Example 5 with UnitGroup

use of org.openlca.ilcd.units.UnitGroup in project olca-modules by GreenDelta.

the class DataSets method putUnitGroup.

private static void putUnitGroup(SodaClient client) throws Exception {
    UnitGroup group = load(UnitGroup.class, "unit.xml");
    UnitGroupBag bag = new UnitGroupBag(group, "en");
    if (!client.contains(UnitGroup.class, bag.getId()))
        client.put(group);
}
Also used : UnitGroup(org.openlca.ilcd.units.UnitGroup) UnitGroupBag(org.openlca.ilcd.util.UnitGroupBag)

Aggregations

UnitGroup (org.openlca.ilcd.units.UnitGroup)7 Test (org.junit.Test)3 UnitGroupBag (org.openlca.ilcd.util.UnitGroupBag)3 Before (org.junit.Before)2 UnitGroupInfo (org.openlca.ilcd.units.UnitGroupInfo)2 LangString (org.openlca.ilcd.commons.LangString)1 Contact (org.openlca.ilcd.contacts.Contact)1 FlowProperty (org.openlca.ilcd.flowproperties.FlowProperty)1 Flow (org.openlca.ilcd.flows.Flow)1 SodaClient (org.openlca.ilcd.io.SodaClient)1 XmlBinder (org.openlca.ilcd.io.XmlBinder)1 Source (org.openlca.ilcd.sources.Source)1