use of org.openlca.core.model.DQSystem in project olca-modules by GreenDelta.
the class ProcessReferenceSearchTest method createModel.
@Override
protected Process createModel() {
Process process = new Process();
process.category = insertAndAddExpected("category", new Category());
process.location = insertAndAddExpected("location", new Location());
process.dqSystem = insertAndAddExpected("dqSystem", new DQSystem());
process.exchangeDqSystem = insertAndAddExpected("exchangeDqSystem", new DQSystem());
process.socialDqSystem = insertAndAddExpected("socialDqSystem", new DQSystem());
String n1 = generateName();
String n2 = generateName();
String n3 = generateName();
String n4 = generateName();
String n5 = generateName();
createExchange(process, 3d, true);
createExchange(process, "2*" + n4, false);
process.parameters.add(createParameter(n1, 3d, false));
process.parameters.add(createParameter(n2, n1 + "*2*" + n3, false));
process.socialAspects.add(createSocialAspect());
process.socialAspects.add(createSocialAspect());
process.documentation = createDocumentation();
insertAndAddExpected(n3, createParameter(n3, "5*5", true));
// formula with parameter to see if added as reference (unexpected)
insertAndAddExpected(n4, createParameter(n4, "3*" + n5, true));
Parameter globalUnreferenced = createParameter(n1, "3*3", true);
Parameter globalUnreferenced2 = createParameter(n5, "3*3", true);
// must be inserted manually
globalUnreferenced = db.insert(globalUnreferenced);
globalUnreferenced2 = db.insert(globalUnreferenced2);
process = db.insert(process);
for (Exchange e : process.exchanges) {
addExpected("flow", e.flow, "exchanges", Exchange.class, e.id);
addExpected("flowPropertyFactor", e.flowPropertyFactor, "exchanges", Exchange.class, e.id);
addExpected("flowProperty", e.flowPropertyFactor.flowProperty, "flowPropertyFactor", FlowPropertyFactor.class, e.flowPropertyFactor.id);
addExpected("unit", e.unit, "exchanges", Exchange.class, e.id);
Process provider = processes.get(e.defaultProviderId);
if (provider != null)
addExpected("defaultProviderId", provider, "exchanges", Exchange.class, e.id);
}
for (SocialAspect a : process.socialAspects) {
addExpected("indicator", a.indicator, "socialAspects", SocialAspect.class, a.id);
addExpected("source", a.source, "socialAspects", SocialAspect.class, a.id);
}
ProcessDocumentation doc = process.documentation;
addExpected("dataDocumentor", doc.dataDocumentor, "documentation", ProcessDocumentation.class, doc.id);
addExpected("dataGenerator", doc.dataGenerator, "documentation", ProcessDocumentation.class, doc.id);
addExpected("dataSetOwner", doc.dataSetOwner, "documentation", ProcessDocumentation.class, doc.id);
addExpected("reviewer", doc.reviewer, "documentation", ProcessDocumentation.class, doc.id);
addExpected("publication", doc.publication, "documentation", ProcessDocumentation.class, doc.id);
for (Source s : process.documentation.sources) addExpected("sources", s, "documentation", ProcessDocumentation.class, doc.id);
return process;
}
use of org.openlca.core.model.DQSystem in project olca-modules by GreenDelta.
the class DQResultTest method createDQSystem.
private void createDQSystem() {
dqSystem = new DQSystem();
for (int i = 1; i <= 5; i++) {
DQIndicator indicator = new DQIndicator();
indicator.position = i;
dqSystem.indicators.add(indicator);
for (int j = 1; j <= 5; j++) {
DQScore score = new DQScore();
score.position = j;
indicator.scores.add(score);
}
}
dqSystem = new DQSystemDao(db).insert(dqSystem);
}
use of org.openlca.core.model.DQSystem in project olca-modules by GreenDelta.
the class SourceUseSearchTest method setUp.
@Before
public void setUp() {
source = db.insert(Source.of("test source"));
process = new Process();
process.name = "test process";
process.documentation = new ProcessDocumentation();
process = db.insert(process);
method = db.insert(ImpactMethod.of("test method"));
dqSystem = db.insert(new DQSystem());
}
use of org.openlca.core.model.DQSystem 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;
}
use of org.openlca.core.model.DQSystem in project olca-modules by GreenDelta.
the class DqSystemImport method of.
@Override
public ImportStatus<DQSystem> of(String id) {
var dqSystem = imp.get(DQSystem.class, id);
// check if we are in update mode
var update = false;
if (dqSystem != null) {
update = imp.shouldUpdate(dqSystem);
if (!update) {
return ImportStatus.skipped(dqSystem);
}
}
// resolve the proto object
var proto = imp.reader.getDQSystem(id);
if (proto == null)
return dqSystem != null ? ImportStatus.skipped(dqSystem) : ImportStatus.error("Could not resolve DQSystem " + id);
var wrap = ProtoWrap.of(proto);
if (update) {
if (imp.skipUpdate(dqSystem, wrap))
return ImportStatus.skipped(dqSystem);
}
// map the data
if (dqSystem == null) {
dqSystem = new DQSystem();
dqSystem.refId = id;
}
wrap.mapTo(dqSystem, imp);
map(proto, dqSystem);
// insert or update it
var dao = new DQSystemDao(imp.db);
dqSystem = update ? dao.update(dqSystem) : dao.insert(dqSystem);
imp.putHandled(dqSystem);
return update ? ImportStatus.updated(dqSystem) : ImportStatus.created(dqSystem);
}
Aggregations