use of ubic.gemma.model.IdentifiableValueObject in project Gemma by PavlidisLab.
the class BioAssayDimensionValueObject method makeDummyBioAssayDimension.
private BioAssayDimension makeDummyBioAssayDimension() {
assert this.id == null;
BioAssayDimension fakeBd = BioAssayDimension.Factory.newInstance("Placeholder representing: " + name, description, new ArrayList<BioAssay>());
Map<Long, ExperimentalFactor> fakeEfs = new HashMap<>();
for (BioAssayValueObject bav : this.bioAssays) {
BioAssay ba = BioAssay.Factory.newInstance();
ba.setId(bav.getId());
ba.setName(bav.getName());
ba.setDescription("Fake placeholder");
BioMaterial sampleUsed = BioMaterial.Factory.newInstance();
BioMaterialValueObject bmVo = bav.getSample();
assert bmVo != null;
sampleUsed.setId(bmVo.getId());
sampleUsed.setName(bmVo.getName());
sampleUsed.setDescription("Fake placeholder");
for (IdentifiableValueObject iVo : bmVo.getFactorValueObjects()) {
FactorValueValueObject fvVo = (FactorValueValueObject) iVo;
FactorValue fv = FactorValue.Factory.newInstance();
assert fvVo.getId() != null;
fv.setId(fvVo.getId());
assert fvVo.getValue() != null;
fv.setValue(fvVo.getValue());
Long efId = fvVo.getFactorId();
ExperimentalFactor ef;
if (fakeEfs.containsKey(efId)) {
ef = fakeEfs.get(efId);
} else {
ef = ExperimentalFactor.Factory.newInstance();
ef.setId(efId);
ef.setName(fvVo.getCategory());
ef.setType(fvVo.isMeasurement() ? FactorType.CONTINUOUS : FactorType.CATEGORICAL);
fakeEfs.put(efId, ef);
}
ef.getFactorValues().add(fv);
fv.setExperimentalFactor(ef);
sampleUsed.getFactorValues().add(fv);
}
ba.setSampleUsed(sampleUsed);
ArrayDesign ad = ArrayDesign.Factory.newInstance();
ArrayDesignValueObject adVo = bav.getArrayDesign();
assert adVo != null;
ad.setId(adVo.getId());
ad.setShortName(adVo.getShortName());
ad.setDescription("Fake placeholder");
ba.setArrayDesignUsed(ad);
fakeBd.getBioAssays().add(ba);
}
return fakeBd;
}
Aggregations