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;
}
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();
}
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));
}
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());
}
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);
}
Aggregations