Skip to content

Commit

Permalink
Merge pull request #19 from blezek/2.0.0-M4
Browse files Browse the repository at this point in the history
2.0.0 m4
  • Loading branch information
blezek authored Nov 12, 2024
2 parents 82c9f55 + 784d625 commit 776b77b
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 35 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ deidentified.dcm
deidentified.dcm.bak
reidentified.dcm
src/test/resources/boxToken.txt
out
28 changes: 16 additions & 12 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@

plugins {
id 'io.github.lhotari.gradle-nar-plugin' version '0.5.1'
id "com.github.breadmoirai.github-release" version "2.2.12"
id 'io.github.lhotari.gradle-nar-plugin' version '0.5.1'
id "com.github.breadmoirai.github-release" version "2.2.12"
id 'java'
}

ext {
nifiVersion = '1.27.0'
nifiVersion = '2.0.0'
dcm4cheVersion = '5.33.0'
}

group 'com.blezek.nifi.dicom'
version '1.27.3'
version '2.0.0'
java.sourceCompatibility = JavaVersion.VERSION_1_8

// Adds the NAR taget for NIFI
Expand All @@ -32,8 +32,9 @@ test {
repositories {
mavenCentral()
// DCM4CHE has their own Maven...
maven { url "https://www.dcm4che.org/maven2/" }
maven { url "https://maven.dcm4che.org/" }
maven { url "https://jcenter.bintray.com/" }
maven { url "https://raw.github.com/nroduit/mvn-repo/master/" }
}

dependencies {
Expand All @@ -48,9 +49,11 @@ dependencies {
implementation group: 'com.google.guava', name: 'guava', version: '23.0'

// DCM4CHE
implementation group: 'org.dcm4che', name: 'dcm4che-core', version: '3.3.8'
implementation group: 'org.dcm4che', name: 'dcm4che-image', version: '3.3.8'
implementation group: 'org.dcm4che', name: 'dcm4che-net', version: '3.3.8'
implementation group: 'org.dcm4che', name: 'dcm4che-core', version: project.dcm4cheVersion
implementation group: 'org.dcm4che', name: 'dcm4che-image', version: project.dcm4cheVersion
implementation group: 'org.dcm4che', name: 'dcm4che-net', version: project.dcm4cheVersion

// nifi
implementation group: 'org.apache.nifi', name: 'nifi-api', version: project.nifiVersion
implementation group: 'org.apache.nifi', name: 'nifi-utils', version: project.nifiVersion

Expand All @@ -71,7 +74,7 @@ dependencies {
implementation "com.h2database:h2:1.3.170"
implementation "com.google.guava:guava:23.0"
implementation "org.flywaydb:flyway-core:5.0.7"
implementation 'com.google.code.gson:gson:2.8.2'
implementation 'com.google.code.gson:gson:2.11.0'

// Encryption
implementation 'org.bouncycastle:bcprov-jdk15on:1.52'
Expand All @@ -89,19 +92,20 @@ dependencies {
implementation "javax.activation:activation:1.1.1"
}


githubRelease {
token System.getenv('GITHUB_NIFI_TOKEN') ?: "0"
owner "blezek"
repo "nifi-dicom"

allowUploadToExisting true
releaseAssets = files("build/libs/nifi-dicom-${project.version}.nar")
releaseAssets.from(nar)

body = {
"""\
# Info
This release updates to NiFi version 1.27.0
This release updates to NiFi version 2.0.0-M4
## ChangeLog
Expand Down
10 changes: 6 additions & 4 deletions src/main/java/com/blezek/nifi/dicom/DecryptReidentifyDICOM.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import org.apache.nifi.annotation.documentation.SeeAlso;
import org.apache.nifi.annotation.documentation.Tags;
import org.apache.nifi.components.PropertyDescriptor;
import org.apache.nifi.expression.ExpressionLanguageScope;
import org.apache.nifi.flowfile.FlowFile;
import org.apache.nifi.processor.AbstractProcessor;
import org.apache.nifi.processor.ProcessContext;
Expand Down Expand Up @@ -56,19 +57,19 @@ public class DecryptReidentifyDICOM extends AbstractProcessor {
.displayName("Encryption password")
.description(
"Encryption password, leave empty or unset if deidintified or removed attributes are not to be encripted")
.required(true).expressionLanguageSupported(true)
.required(true).expressionLanguageSupported(ExpressionLanguageScope.ENVIRONMENT)
.addValidator(StandardValidators.ATTRIBUTE_EXPRESSION_LANGUAGE_VALIDATOR)
.addValidator(StandardValidators.NON_BLANK_VALIDATOR).build();

static final PropertyDescriptor BATCH_SIZE = new PropertyDescriptor.Builder().name("Batch size").defaultValue("100")
.description("Number of DICOM files to process in batch").required(false)
.addValidator(StandardValidators.NON_NEGATIVE_INTEGER_VALIDATOR).expressionLanguageSupported(false).build();
.addValidator(StandardValidators.NON_NEGATIVE_INTEGER_VALIDATOR).expressionLanguageSupported(ExpressionLanguageScope.ENVIRONMENT).build();

static final PropertyDescriptor ACCEPT_NEW_SERIES = new PropertyDescriptor.Builder().name("accept")
.displayName("Accept new series")
.description(
"If the encrypted, generated Series and Instance UIDs do not match the DICOM object, assume this DICOM image is a new series generated from a deidentified, encrypted DICOM image. Decrypt the original tags, but do not replace the Series and SOPInstance UIDs, effectively creating a new series")
.required(true).expressionLanguageSupported(true).allowableValues("true", "false").defaultValue("true").build();
.required(true).expressionLanguageSupported(ExpressionLanguageScope.ENVIRONMENT).allowableValues("true", "false").defaultValue("true").build();

static final DecimalFormat df = new DecimalFormat("#.00");

Expand Down Expand Up @@ -188,7 +189,8 @@ private boolean decryptAndReidentify(ProcessContext context, ProcessSession sess

// Remove the private tag...
originalTags.remove(DeidentifyEncryptDICOM.PRIVATE_CREATOR, DeidentifyEncryptDICOM.PRIVATE_TAG);
tags.updateRecursive(originalTags);
Attributes mergedTags = new Attributes();
tags.update(Attributes.UpdatePolicy.OVERWRITE, false, originalTags, mergedTags );

tags.remove(Tag.PatientIdentityRemoved);
tags.remove(Tag.DeidentificationMethod);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import org.apache.nifi.components.ValidationResult;
import org.apache.nifi.controller.AbstractControllerService;
import org.apache.nifi.controller.ConfigurationContext;
import org.apache.nifi.expression.ExpressionLanguageScope;
import org.apache.nifi.processor.util.StandardValidators;
import org.dcm4che3.util.UIDUtils;
import org.flywaydb.core.Flyway;
Expand All @@ -42,7 +43,7 @@ public class DeidentificationController extends AbstractControllerService implem
static final PropertyDescriptor DB_DIRECTORY = new PropertyDescriptor.Builder().name("DB_DIRECTORY")
.displayName("Database directory")
.description("Location of the deidentification database, will be created in the 'database' sub-directory.")
.required(true).expressionLanguageSupported(true)
.required(true).expressionLanguageSupported(ExpressionLanguageScope.ENVIRONMENT)
.addValidator(StandardValidators.createDirectoryExistsValidator(true, true))
.addValidator(StandardValidators.NON_EMPTY_VALIDATOR).build();

Expand All @@ -69,7 +70,7 @@ public class DeidentificationController extends AbstractControllerService implem
return new ValidationResult.Builder().subject(subject).input(value).valid(valid).explanation(explanation)
.build();

}).expressionLanguageSupported(true).build();
}).expressionLanguageSupported(ExpressionLanguageScope.ENVIRONMENT).build();

@Override
protected List<PropertyDescriptor> getSupportedPropertyDescriptors() {
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/com/blezek/nifi/dicom/ExtractDICOMTags.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import org.apache.nifi.components.ValidationResult;
import org.apache.nifi.components.Validator;
import org.apache.nifi.expression.AttributeExpression.ResultType;
import org.apache.nifi.expression.ExpressionLanguageScope;
import org.apache.nifi.flowfile.FlowFile;
import org.apache.nifi.processor.AbstractProcessor;
import org.apache.nifi.processor.ProcessContext;
Expand Down Expand Up @@ -113,7 +114,7 @@ protected PropertyDescriptor getSupportedDynamicPropertyDescriptor(final String
};

PropertyDescriptor descriptor = new PropertyDescriptor.Builder().dynamic(true).name(propertyDescriptorName)
.expressionLanguageSupported(true).displayName(propertyDescriptorName).addValidator(validator).build();
.expressionLanguageSupported(ExpressionLanguageScope.FLOWFILE_ATTRIBUTES).displayName(propertyDescriptorName).addValidator(validator).build();

return descriptor;
}
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/com/blezek/nifi/dicom/PutDICOM.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,23 +58,23 @@ public class PutDICOM extends AbstractProcessor {

static final PropertyDescriptor DICOM_PORT = new PropertyDescriptor.Builder().name("DICOM_PORT")
.displayName("Remote Port").description("The TCP port to send to.").required(true)
.expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY)
.expressionLanguageSupported(ExpressionLanguageScope.ENVIRONMENT)
.addValidator(StandardValidators.PORT_VALIDATOR).defaultValue("4096").build();
static final PropertyDescriptor CALLING_AE_TITLE = new PropertyDescriptor.Builder().name("CALLING_AE_TITLE")
.displayName("Local Application Entity").required(true)
.expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY)
.expressionLanguageSupported(ExpressionLanguageScope.ENVIRONMENT)
.addValidator(StandardValidators.NON_BLANK_VALIDATOR).addValidator(new AETitleValidator()).build();
static final PropertyDescriptor CALLED_AE_TITLE = new PropertyDescriptor.Builder().name("CALLED_AE_TITLE")
.displayName("Remote Application Entity Title").required(true)
.expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY)
.expressionLanguageSupported(ExpressionLanguageScope.ENVIRONMENT)
.addValidator(StandardValidators.NON_BLANK_VALIDATOR).addValidator(new AETitleValidator()).build();
static final PropertyDescriptor DICOM_HOSTNAME = new PropertyDescriptor.Builder().name("DICOM_HOSTNAME")
.displayName("Remote hostname of remote DICOM destination").required(true)
.expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY)
.expressionLanguageSupported(ExpressionLanguageScope.ENVIRONMENT)
.addValidator(StandardValidators.NON_BLANK_VALIDATOR).build();
static final PropertyDescriptor BATCH_SIZE = new PropertyDescriptor.Builder().name("BATCH_SIZE")
.displayName("batch size").description("maxmium number of DICOM images to send at once, 0 is unlimited")
.defaultValue("0").required(true).expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY)
.defaultValue("0").required(true).expressionLanguageSupported(ExpressionLanguageScope.ENVIRONMENT)
.addValidator(StandardValidators.NON_NEGATIVE_INTEGER_VALIDATOR)
.addValidator(StandardValidators.NON_BLANK_VALIDATOR).build();

Expand Down
26 changes: 15 additions & 11 deletions src/main/java/com/blezek/nifi/dicom/RelatedGeneralSOPClasses.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */

package com.blezek.nifi.dicom;


import java.util.HashMap;
import java.util.Properties;

Expand All @@ -51,16 +51,20 @@
*/
class RelatedGeneralSOPClasses {

private final HashMap<String, CommonExtendedNegotiation> commonExtNegs = new HashMap<String, CommonExtendedNegotiation>();
private final HashMap<String,CommonExtendedNegotiation> commonExtNegs =
new HashMap<String,CommonExtendedNegotiation>();

public void init(Properties props) {
for (String cuid : props.stringPropertyNames())
commonExtNegs.put(cuid, new CommonExtendedNegotiation(cuid, UID.StorageServiceClass,
StringUtils.split(props.getProperty(cuid), ',')));
}
public void init(Properties props) {
for (String cuid : props.stringPropertyNames())
commonExtNegs.put(cuid, new CommonExtendedNegotiation(cuid,
UID.Storage,
StringUtils.split(props.getProperty(cuid), ',')));
}

public CommonExtendedNegotiation getCommonExtendedNegotiation(String cuid) {
CommonExtendedNegotiation commonExtNeg = commonExtNegs.get(cuid);
return commonExtNeg != null ? commonExtNeg : new CommonExtendedNegotiation(cuid, UID.StorageServiceClass);
}
public CommonExtendedNegotiation getCommonExtendedNegotiation(String cuid) {
CommonExtendedNegotiation commonExtNeg = commonExtNegs.get(cuid);
return commonExtNeg != null
? commonExtNeg
: new CommonExtendedNegotiation(cuid, UID.Storage);
}
}

0 comments on commit 776b77b

Please sign in to comment.