Skip to content

Commit

Permalink
Generalize Attribute Coercion and enable to apply multiple matching A…
Browse files Browse the repository at this point in the history
…ttribute Coercions in configurable order #2967
  • Loading branch information
gunterze committed Nov 10, 2021
1 parent 4a689cd commit 1e77baa
Showing 1 changed file with 37 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,6 @@ public void store(StoreContext ctx, InputStream data, Consumer<Attributes> coerc
supplementDefaultCharacterSet(ctx);
storeMetadata(ctx);
coerceAttributes(ctx);
coerceAttributes2(ctx);
result = updateDB(ctx);
postUpdateDB(ctx, result);
} catch (DicomServiceException e) {
Expand Down Expand Up @@ -371,7 +370,6 @@ public void store(StoreContext ctx, Attributes attrs) throws IOException {
supplementDefaultCharacterSet(ctx);
storeMetadata(ctx);
coerceAttributes(ctx);
coerceAttributes2(ctx);
}
result = updateDB(ctx);
postUpdateDB(ctx, result);
Expand Down Expand Up @@ -399,7 +397,6 @@ public void importInstanceOnStorage(StoreContext ctx, Attributes attrs, ReadCont
supplementDefaultCharacterSet(ctx);
storeMetadata(ctx);
coerceAttributes(ctx);
coerceAttributes2(ctx);
result = updateDB(ctx);
postUpdateDB(ctx, result);
} catch (DicomServiceException e) {
Expand Down Expand Up @@ -556,18 +553,44 @@ private void coerceAttributes2(StoreContext ctx) throws Exception {

private void coerceAttributes(StoreContext ctx) throws Exception {
StoreSession session = ctx.getStoreSession();
ArchiveAttributeCoercion rule = session.getArchiveAEExtension().findAttributeCoercion(
Dimse.C_STORE_RQ,
TransferCapability.Role.SCU,
ctx.getSopClassUID(),
session.getRemoteHostName(),
session.getCallingAET(),
session.getLocalHostName(),
session.getCalledAET(),
ctx.getAttributes());
if (rule == null)
return;
List<ArchiveAttributeCoercion2> coercions = session.getArchiveAEExtension().attributeCoercions2()
.filter(descriptor -> descriptor.match(
TransferCapability.Role.SCU,
Dimse.C_STORE_RQ,
ctx.getSopClassUID(),
session.getRemoteHostName(),
session.getCallingAET(),
session.getLocalHostName(),
session.getCalledAET(),
ctx.getAttributes()))
.collect(Collectors.toList());
if (coercions.isEmpty()) {
ArchiveAttributeCoercion rule = session.getArchiveAEExtension().findAttributeCoercion(
Dimse.C_STORE_RQ,
TransferCapability.Role.SCU,
ctx.getSopClassUID(),
session.getRemoteHostName(),
session.getCallingAET(),
session.getLocalHostName(),
session.getCalledAET(),
ctx.getAttributes());
if (rule != null) coerceLegacy(ctx, session, rule);
} else {
for (ArchiveAttributeCoercion2 coercion : coercions) {
if (coercionFactory.getCoercionProcessor(coercion).coerce(
coercion,
session.getRemoteHostName(),
session.getCallingAET(),
session.getLocalHostName(),
session.getCalledAET(),
ctx.getAttributes(),
ctx.getCoercedAttributes())
&& coercion.isCoercionSufficient()) break;
}
}
}

private void coerceLegacy(StoreContext ctx, StoreSession session, ArchiveAttributeCoercion rule) throws Exception {
AttributesCoercion coercion = null;
coercion = coerceAttributesByXSL(ctx, rule, coercion);
coercion = mergeAttributesFromMWL(ctx, rule, coercion);
Expand Down

0 comments on commit 1e77baa

Please sign in to comment.