Class BioMaterialServiceImpl
java.lang.Object
ubic.gemma.persistence.service.AbstractService<BioMaterial>
ubic.gemma.persistence.service.AbstractVoEnabledService<BioMaterial, BioMaterialValueObject>
ubic.gemma.persistence.service.expression.biomaterial.BioMaterialServiceImpl
- All Implemented Interfaces:
BaseImmutableService<BioMaterial>, BaseReadOnlyService<BioMaterial>, BaseService<BioMaterial>, BaseVoEnabledService<BioMaterial, BioMaterialValueObject>, SecurableBaseImmutableService<BioMaterial>, SecurableBaseReadOnlyService<BioMaterial>, SecurableBaseService<BioMaterial>, SecurableBaseVoEnabledService<BioMaterial, BioMaterialValueObject>, BioMaterialService
@Service
public class BioMaterialServiceImpl
extends AbstractVoEnabledService<BioMaterial, BioMaterialValueObject>
implements BioMaterialService
- Author:
- pavlidis, keshav
- See Also:
-
Field Summary
Fields inherited from class AbstractService
log -
Constructor Summary
ConstructorsConstructorDescriptionBioMaterialServiceImpl(BioMaterialDao bioMaterialDao, FactorValueDao factorValueDao, BioAssayDao bioAssayDao, ExperimentalFactorDao experimentalFactorDao, CharacteristicService characteristicService, BioMaterialReadService bioMaterialReadService) -
Method Summary
Modifier and TypeMethodDescriptionaddAnnotation(ExpressionExperiment owner, BioMaterial bm, Characteristic vc) Per-tag add of a characteristic to a biomaterial, the sample-level counterpart ofExpressionExperimentService.addAnnotation(ExpressionExperiment, Characteristic).addAnnotation(ExpressionExperiment owner, BioMaterial bm, Characteristic vc, String reason) Reason-carrying overload.voidWill persist the give vocab characteristic to the given biomaterial<T> voidassociateBatchFactor(Map<BioMaterial, T> descriptors, Map<T, FactorValue> d2fv) Associate dates with bioassays and any new factors with the biomaterials.copy(BioMaterial bioMaterial) Copies a bioMaterial.findByExperiment(ExpressionExperiment experiment) findByFactor(ExperimentalFactor experimentalFactor) findSiblings(BioMaterial bioMaterial) Find the siblings of a given biomaterial.findSubBioMaterials(BioMaterial bioMaterial, boolean direct) <T extends Exception>
BioMaterialloadAndThawOrFail(Long bmId, Function<String, T> exceptionSupplier, String message) removeAnnotation(ExpressionExperiment owner, BioMaterial bm, Long annotationId) Per-tag remove of a characteristic from a biomaterial by id, the sample-level counterpart ofExpressionExperimentService.removeAnnotation(ExpressionExperiment, Long).removeAnnotation(ExpressionExperiment owner, BioMaterial bm, Long annotationId, String reason) Reason-carrying overload; seeaddAnnotation(ExpressionExperiment, BioMaterial, Characteristic, String).voidremoveCharacteristics(BioMaterial bm, Collection<Characteristic> characteristicsToRemove) Remove the given characteristic from the given biomaterialthaw(Collection<BioMaterial> bioMaterials) thaw(BioMaterial bioMaterial) intupdateAnnotations(ExpressionExperiment owner, BioMaterial bm, Collection<Characteristic> desired) Idempotent set-replace for a biomaterial's direct characteristic set, the sample-level counterpart ofExpressionExperimentService.updateAnnotations(ExpressionExperiment, Collection).updateBioMaterials(Collection<BioMaterialValueObject> valueObjects) Update the biomaterials that are described by the given valueObjects.Methods inherited from class AbstractVoEnabledService
loadAllValueObjects, loadValueObject, loadValueObjectById, loadValueObjects, loadValueObjectsByIdsMethods inherited from class AbstractService
countAll, create, create, ensureInSession, ensureInSession, find, findOrCreate, findOrFail, getElementClass, load, load, loadAll, loadOrFail, loadOrFail, loadOrFail, loadOrFail, loadOrFail, loadOrFail, remove, remove, save, save, streamAll, streamAll, update, updateMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface BaseReadOnlyService
countAll, getElementClass, loadOrFail, loadOrFailMethods inherited from interface SecurableBaseImmutableService
create, create, findOrCreate, remove, removeMethods inherited from interface SecurableBaseReadOnlyService
find, findOrFail, load, load, loadAll, loadOrFail, loadOrFail, loadOrFail, loadOrFail, streamAll, streamAllMethods inherited from interface SecurableBaseService
save, save, update, updateMethods inherited from interface SecurableBaseVoEnabledService
loadAllValueObjects, loadValueObject, loadValueObjectById, loadValueObjects, loadValueObjectsByIds
-
Constructor Details
-
BioMaterialServiceImpl
@Autowired public BioMaterialServiceImpl(BioMaterialDao bioMaterialDao, FactorValueDao factorValueDao, BioAssayDao bioAssayDao, ExperimentalFactorDao experimentalFactorDao, CharacteristicService characteristicService, BioMaterialReadService bioMaterialReadService)
-
-
Method Details
-
copy
Description copied from interface:BioMaterialServiceCopies a bioMaterial.- Specified by:
copyin interfaceBioMaterialService- Parameters:
bioMaterial- ba to copy- Returns:
- the copy
-
findSubBioMaterials
- Specified by:
findSubBioMaterialsin interfaceBioMaterialService- See Also:
-
findSiblings
Description copied from interface:BioMaterialServiceFind the siblings of a given biomaterial.- Specified by:
findSiblingsin interfaceBioMaterialService
-
findByExperiment
- Specified by:
findByExperimentin interfaceBioMaterialService
-
findByFactor
- Specified by:
findByFactorin interfaceBioMaterialService
-
loadAndThawOrFail
public <T extends Exception> BioMaterial loadAndThawOrFail(Long bmId, Function<String, T> exceptionSupplier, String message) throws T- Specified by:
loadAndThawOrFailin interfaceBioMaterialService- Throws:
T
-
getExpressionExperiments
public Map<BioMaterial, Map<BioAssay, ExpressionExperiment>> getExpressionExperiments(BioMaterial bm) - Specified by:
getExpressionExperimentsin interfaceBioMaterialService
-
thaw
- Specified by:
thawin interfaceBioMaterialService
-
thaw
- Specified by:
thawin interfaceBioMaterialService
-
updateBioMaterials
@Transactional public Collection<BioMaterial> updateBioMaterials(Collection<BioMaterialValueObject> valueObjects) Description copied from interface:BioMaterialServiceUpdate the biomaterials that are described by the given valueObjects. This is used to update experimental designs in particular.- Specified by:
updateBioMaterialsin interfaceBioMaterialService- Parameters:
valueObjects- VOs- Returns:
- the biomaterials that were modified.
-
associateBatchFactor
@Transactional public <T> void associateBatchFactor(Map<BioMaterial, T> descriptors, Map<T, FactorValue> d2fv) Description copied from interface:BioMaterialServiceAssociate dates with bioassays and any new factors with the biomaterials. Note we can have missing values.- Specified by:
associateBatchFactorin interfaceBioMaterialService- Parameters:
d2fv- map of dates to factor values
-
addCharacteristic
Description copied from interface:BioMaterialServiceWill persist the give vocab characteristic to the given biomaterial- Specified by:
addCharacteristicin interfaceBioMaterialService- See Also:
-
removeCharacteristics
@Transactional public void removeCharacteristics(BioMaterial bm, Collection<Characteristic> characteristicsToRemove) Description copied from interface:BioMaterialServiceRemove the given characteristic from the given biomaterial- Specified by:
removeCharacteristicsin interfaceBioMaterialService
-
updateAnnotations
@Transactional @AuditedConditional(value=ManualAnnotationEvent.class, when="#result > 0", messageSpel="'Replaced sample annotations via API (' + #result + ' change(s)) on biomaterial ' + #bm.id") public int updateAnnotations(ExpressionExperiment owner, BioMaterial bm, Collection<Characteristic> desired) Description copied from interface:BioMaterialServiceIdempotent set-replace for a biomaterial's direct characteristic set, the sample-level counterpart ofExpressionExperimentService.updateAnnotations(ExpressionExperiment, Collection).The
ownerexperiment is the audit + ACL target: theManualAnnotationEventis recorded on the experiment (not the sample) andACL_SECURABLE_EDITis checked against it, so all tag edits — experiment- or sample-level — surface on the experiment's history and share one permission gate. The diff is statement-aware (seeCharacteristicUtils.sameTag(Characteristic, Characteristic)).- Specified by:
updateAnnotationsin interfaceBioMaterialService- Parameters:
owner- the experiment that ownsbm(audit + ACL target)bm- the biomaterial whose characteristics are replaceddesired- the full desired characteristic set (empty clears)- Returns:
- the number of changes (adds + removes); zero means the set was already as desired
-
addAnnotation
@Transactional @Audited(value=TagAddedEvent.class, messageSpel="'Added tag ' + #vc.category + ' = ' + #vc.value + ' to biomaterial ' + #bm.id") public Characteristic addAnnotation(ExpressionExperiment owner, BioMaterial bm, Characteristic vc) Description copied from interface:BioMaterialServicePer-tag add of a characteristic to a biomaterial, the sample-level counterpart ofExpressionExperimentService.addAnnotation(ExpressionExperiment, Characteristic). Records aTagAddedEventonownerand rejects a duplicate (by statement-awaresameTag) withIllegalArgumentException.- Specified by:
addAnnotationin interfaceBioMaterialService- Parameters:
owner- the experiment that ownsbm(audit + ACL target)- Returns:
- the persisted characteristic
-
addAnnotation
@Transactional @Audited(value=TagAddedEvent.class, messageSpel="'Added tag ' + #vc.category + ' = ' + #vc.value + ' to biomaterial ' + #bm.id + (#reason != null ? ' \u2014 ' + #reason : '')") public Characteristic addAnnotation(ExpressionExperiment owner, BioMaterial bm, Characteristic vc, @Nullable String reason) Reason-carrying overload. A separate method rather than a parameter on the one above so every existing caller keeps its signature; the two differ only in the audit note the aspect writes. Both delegate to the same private body through a plainthiscall, which is not re-advised, so one call still writes one event.- Specified by:
addAnnotationin interfaceBioMaterialService
-
removeAnnotation
@Transactional @AuditedConditional(value=TagRemovedEvent.class, when="#result != null", messageSpel="'Removed tag ' + #result.category + ' = ' + #result.value + ' from biomaterial ' + #bm.id") @Nullable public Characteristic removeAnnotation(ExpressionExperiment owner, BioMaterial bm, Long annotationId) Description copied from interface:BioMaterialServicePer-tag remove of a characteristic from a biomaterial by id, the sample-level counterpart ofExpressionExperimentService.removeAnnotation(ExpressionExperiment, Long). Records aTagRemovedEventonowner; returnsnullwhen the id is not inbm's characteristic set so the caller can surface a 404.- Specified by:
removeAnnotationin interfaceBioMaterialService- Parameters:
owner- the experiment that ownsbm(audit + ACL target)
-
removeAnnotation
@Transactional @AuditedConditional(value=TagRemovedEvent.class, when="#result != null", messageSpel="'Removed tag ' + #result.category + ' = ' + #result.value + ' from biomaterial ' + #bm.id + (#reason != null ? ' \u2014 ' + #reason : '')") @Nullable public Characteristic removeAnnotation(ExpressionExperiment owner, BioMaterial bm, Long annotationId, @Nullable String reason) Reason-carrying overload; seeaddAnnotation(ExpressionExperiment, BioMaterial, Characteristic, String).- Specified by:
removeAnnotationin interfaceBioMaterialService
-