use of com.b2international.snowowl.snomed.core.store.SnomedModuleDependencyReferenceSetMemberBuilder in project snow-owl by b2ihealthcare.
the class SnomedModuleDependencyMemberCreateDelegate method execute.
@Override
public String execute(SnomedReferenceSet refSet, TransactionContext context) {
checkRefSetType(refSet, SnomedRefSetType.MODULE_DEPENDENCY);
checkReferencedComponent(refSet);
checkComponentExists(refSet, context, SnomedRf2Headers.FIELD_MODULE_ID, getModuleId());
checkComponentExists(refSet, context, SnomedRf2Headers.FIELD_REFERENCED_COMPONENT_ID, getReferencedComponentId());
SnomedModuleDependencyReferenceSetMemberBuilder builder = SnomedComponents.newModuleDependencyMember().withId(getId()).withActive(isActive()).withReferencedComponent(getReferencedComponentId()).withModuleId(getModuleId()).withRefSet(getReferenceSetId());
try {
if (hasProperty(SnomedRf2Headers.FIELD_SOURCE_EFFECTIVE_TIME)) {
String sourceEffectiveTime = getProperty(SnomedRf2Headers.FIELD_SOURCE_EFFECTIVE_TIME);
builder.withSourceEffectiveTime(Strings.isNullOrEmpty(sourceEffectiveTime) ? null : EffectiveTimes.parse(sourceEffectiveTime, DateFormats.SHORT));
}
} catch (IllegalArgumentException e) {
if (e.getMessage().contains("Error while parsing date")) {
throw new BadRequestException(e.getMessage());
}
}
try {
if (hasProperty(SnomedRf2Headers.FIELD_TARGET_EFFECTIVE_TIME)) {
String targetEffectiveTime = getProperty(SnomedRf2Headers.FIELD_TARGET_EFFECTIVE_TIME);
builder.withTargetEffectiveTime(Strings.isNullOrEmpty(targetEffectiveTime) ? null : EffectiveTimes.parse(targetEffectiveTime, DateFormats.SHORT));
}
} catch (IllegalArgumentException e) {
if (e.getMessage().contains("Error while parsing date")) {
throw new BadRequestException(e.getMessage());
}
}
return builder.addTo(context).getId();
}
Aggregations