Search in sources :

Example 1 with Device

use of org.dcm4che3.net.Device in project dcm4che by dcm4che.

the class JsonImageReaderConfiguration method loadDeviceExtension.

@Override
public boolean loadDeviceExtension(Device device, JsonReader reader, ConfigurationDelegate config) {
    if (!reader.getString().equals("dcmImageReader"))
        return false;
    ImageReaderFactory factory = new ImageReaderFactory();
    reader.next();
    reader.expect(JsonParser.Event.START_ARRAY);
    while (reader.next() == JsonParser.Event.START_OBJECT) {
        String tsuid = null;
        String formatName = null;
        String className = null;
        String patchJPEGLS = null;
        String[] imageReadParam = {};
        while (reader.next() == JsonParser.Event.KEY_NAME) {
            switch(reader.getString()) {
                case "dicomTransferSyntax":
                    tsuid = reader.stringValue();
                    break;
                case "dcmIIOFormatName":
                    formatName = reader.stringValue();
                    break;
                case "dcmJavaClassName":
                    className = reader.stringValue();
                    break;
                case "dcmPatchJPEGLS":
                    patchJPEGLS = reader.stringValue();
                    break;
                case "dcmImageReadParam":
                    imageReadParam = reader.stringArray();
                    break;
                default:
                    reader.skipUnknownProperty();
            }
        }
        reader.expect(JsonParser.Event.END_OBJECT);
        factory.put(tsuid, new ImageReaderFactory.ImageReaderParam(formatName, className, patchJPEGLS, imageReadParam));
    }
    device.addDeviceExtension(new ImageReaderExtension(factory));
    return true;
}
Also used : ImageReaderFactory(org.dcm4che3.imageio.codec.ImageReaderFactory) ImageReaderExtension(org.dcm4che3.net.imageio.ImageReaderExtension)

Example 2 with Device

use of org.dcm4che3.net.Device in project dcm4che by dcm4che.

the class JsonImageWriterConfiguration method storeTo.

@Override
protected void storeTo(Device device, JsonWriter writer) {
    ImageWriterExtension ext = device.getDeviceExtension(ImageWriterExtension.class);
    if (ext == null)
        return;
    writer.writeStartArray("dcmImageWriter");
    for (Map.Entry<String, ImageWriterFactory.ImageWriterParam> entry : ext.getImageWriterFactory().getEntries()) {
        writer.writeStartObject();
        String tsuid = entry.getKey();
        ImageWriterFactory.ImageWriterParam param = entry.getValue();
        writer.writeNotNullOrDef("dicomTransferSyntax", tsuid, null);
        writer.writeNotNullOrDef("dcmIIOFormatName", param.formatName, null);
        writer.writeNotNullOrDef("dcmJavaClassName", param.className, null);
        writer.writeNotNullOrDef("dcmPatchJPEGLS", param.patchJPEGLS, null);
        writer.writeNotEmpty("dcmImageWriteParam", param.imageWriteParams);
        writer.writeEnd();
    }
    writer.writeEnd();
}
Also used : ImageWriterFactory(org.dcm4che3.imageio.codec.ImageWriterFactory) ImageWriterExtension(org.dcm4che3.net.imageio.ImageWriterExtension) Map(java.util.Map)

Example 3 with Device

use of org.dcm4che3.net.Device in project dcm4che by dcm4che.

the class JsonConfigurationTest method testLoadDevice.

@Test
public void testLoadDevice() throws Exception {
    Device device = null;
    Path path = Paths.get("src/test/data/device.json");
    try (BufferedReader reader = Files.newBufferedReader(path, Charset.forName("UTF-8"))) {
        JsonConfiguration config = new JsonConfiguration();
        config.addJsonConfigurationExtension(new JsonAuditLoggerConfiguration());
        config.addJsonConfigurationExtension(new JsonAuditRecordRepositoryConfiguration());
        config.addJsonConfigurationExtension(new JsonImageReaderConfiguration());
        config.addJsonConfigurationExtension(new JsonImageWriterConfiguration());
        config.addJsonConfigurationExtension(new JsonHL7Configuration());
        device = config.loadDeviceFrom(Json.createParser(reader), configDelegate);
    }
    assertEquals("Test-Device-1", device.getDeviceName());
    List<Connection> conns = device.listConnections();
    assertEquals(3, conns.size());
    Connection conn = conns.get(0);
    assertEquals("host.dcm4che.org", conn.getHostname());
    assertEquals(11112, conn.getPort());
    Collection<ApplicationEntity> aes = device.getApplicationEntities();
    assertEquals(1, aes.size());
    ApplicationEntity ae = aes.iterator().next();
    assertEquals("TEST-AET1", ae.getAETitle());
    assertTrue(ae.isAssociationAcceptor());
    assertFalse(ae.isAssociationInitiator());
    List<Connection> aeconns = ae.getConnections();
    assertEquals(1, aeconns.size());
    assertSame(conn, aeconns.get(0));
    assertEquals(3, ae.getTransferCapabilities().size());
    TransferCapability echoSCP = ae.getTransferCapabilityFor(UID.Verification, TransferCapability.Role.SCP);
    assertNotNull(echoSCP);
    assertArrayEquals(new String[] { UID.ImplicitVRLittleEndian }, echoSCP.getTransferSyntaxes());
    assertNull(echoSCP.getCommonName());
    assertNull(echoSCP.getQueryOptions());
    assertNull(echoSCP.getStorageOptions());
    TransferCapability ctSCP = ae.getTransferCapabilityFor(UID.CTImageStorage, TransferCapability.Role.SCP);
    assertNotNull(ctSCP);
    StorageOptions storageOptions = ctSCP.getStorageOptions();
    assertNotNull(storageOptions);
    assertEquals(StorageOptions.LevelOfSupport.LEVEL_2, storageOptions.getLevelOfSupport());
    assertEquals(StorageOptions.DigitalSignatureSupport.LEVEL_1, storageOptions.getDigitalSignatureSupport());
    assertEquals(StorageOptions.ElementCoercion.YES, storageOptions.getElementCoercion());
    TransferCapability findSCP = ae.getTransferCapabilityFor(UID.StudyRootQueryRetrieveInformationModelFind, TransferCapability.Role.SCP);
    assertNotNull(findSCP);
    assertEquals(EnumSet.of(QueryOption.RELATIONAL), findSCP.getQueryOptions());
    assertImageReaderExtension(device.getDeviceExtension(ImageReaderExtension.class));
    assertImageWriterExtension(device.getDeviceExtension(ImageWriterExtension.class));
    assertAuditLoggerDeviceExtension(device.getDeviceExtension(AuditLoggerDeviceExtension.class));
    assertHL7DeviceExtension(device.getDeviceExtension(HL7DeviceExtension.class));
}
Also used : Path(java.nio.file.Path) AuditLoggerDeviceExtension(org.dcm4che3.net.audit.AuditLoggerDeviceExtension) JsonAuditLoggerConfiguration(org.dcm4che3.conf.json.audit.JsonAuditLoggerConfiguration) HL7DeviceExtension(org.dcm4che3.net.hl7.HL7DeviceExtension) JsonImageWriterConfiguration(org.dcm4che3.conf.json.imageio.JsonImageWriterConfiguration) ImageReaderExtension(org.dcm4che3.net.imageio.ImageReaderExtension) JsonImageReaderConfiguration(org.dcm4che3.conf.json.imageio.JsonImageReaderConfiguration) JsonAuditRecordRepositoryConfiguration(org.dcm4che3.conf.json.audit.JsonAuditRecordRepositoryConfiguration) BufferedReader(java.io.BufferedReader) JsonHL7Configuration(org.dcm4che3.conf.json.hl7.JsonHL7Configuration) ImageWriterExtension(org.dcm4che3.net.imageio.ImageWriterExtension) Test(org.junit.Test)

Example 4 with Device

use of org.dcm4che3.net.Device in project dcm4che by dcm4che.

the class JsonConfigurationTest method testLoadARR.

@Test
public void testLoadARR() throws Exception {
    Device device = loadARR();
    AuditRecordRepository arr = device.getDeviceExtension(AuditRecordRepository.class);
    assertNotNull(arr);
    List<Connection> conns = arr.getConnections();
    assertEquals(2, conns.size());
}
Also used : AuditRecordRepository(org.dcm4che3.net.audit.AuditRecordRepository) Test(org.junit.Test)

Example 5 with Device

use of org.dcm4che3.net.Device in project dcm4che by dcm4che.

the class JsonConfigurationTest method addAuditLoggerDeviceExtension.

private static void addAuditLoggerDeviceExtension(Device device, Device arrDevice) {
    Connection auditUDP = new Connection("audit-udp", "localhost");
    auditUDP.setProtocol(Connection.Protocol.SYSLOG_UDP);
    device.addConnection(auditUDP);
    AuditLoggerDeviceExtension ext = new AuditLoggerDeviceExtension();
    device.addDeviceExtension(ext);
    AuditLogger auditLogger = new AuditLogger("Audit Logger");
    auditLogger.addConnection(auditUDP);
    auditLogger.setAuditSourceID("SourceID");
    auditLogger.setAuditEnterpriseSiteID("EnterpriseID");
    auditLogger.setAuditSourceTypeCodes("4");
    auditLogger.setApplicationName("applicationName");
    auditLogger.setAuditRecordRepositoryDevice(arrDevice);
    auditLogger.setAuditSuppressCriteriaList(createSuppressCriteriaList());
    ext.addAuditLogger(auditLogger);
}
Also used : AuditLoggerDeviceExtension(org.dcm4che3.net.audit.AuditLoggerDeviceExtension) AuditLogger(org.dcm4che3.net.audit.AuditLogger)

Aggregations

Device (org.dcm4che3.net.Device)27 HL7DeviceExtension (org.dcm4che3.net.hl7.HL7DeviceExtension)12 ConfigurationException (org.dcm4che3.conf.api.ConfigurationException)11 ApplicationEntity (org.dcm4che3.net.ApplicationEntity)11 AuditLoggerDeviceExtension (org.dcm4che3.net.audit.AuditLoggerDeviceExtension)10 Connection (org.dcm4che3.net.Connection)9 AuditRecordRepository (org.dcm4che3.net.audit.AuditRecordRepository)9 HL7Application (org.dcm4che3.net.hl7.HL7Application)9 AuditLogger (org.dcm4che3.net.audit.AuditLogger)8 Test (org.junit.Test)8 ImageReaderExtension (org.dcm4che3.net.imageio.ImageReaderExtension)7 ImageWriterExtension (org.dcm4che3.net.imageio.ImageWriterExtension)7 ConfigurationNotFoundException (org.dcm4che3.conf.api.ConfigurationNotFoundException)5 BufferedReader (java.io.BufferedReader)4 Path (java.nio.file.Path)4 GeneralSecurityException (java.security.GeneralSecurityException)3 CertificateException (java.security.cert.CertificateException)3 ExecutorService (java.util.concurrent.ExecutorService)3 ScheduledExecutorService (java.util.concurrent.ScheduledExecutorService)3 JsonGenerator (javax.json.stream.JsonGenerator)3