use of org.dcm4che3.imageio.codec.ImageReaderFactory 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.imageio.codec.ImageReaderFactory in project dcm4che by dcm4che.
the class JsonConfigurationTest method assertImageReaderExtension.
private void assertImageReaderExtension(ImageReaderExtension ext) {
assertNotNull(ext);
ImageReaderFactory factory = ext.getImageReaderFactory();
assertNotNull(factory);
Set<Map.Entry<String, ImageReaderFactory.ImageReaderParam>> expectedEntries = ImageReaderFactory.getDefault().getEntries();
assertEquals(expectedEntries.size(), factory.getEntries().size());
for (Map.Entry<String, ImageReaderFactory.ImageReaderParam> expected : expectedEntries) {
assertEquals(expected.getValue(), factory.get(expected.getKey()));
}
}
use of org.dcm4che3.imageio.codec.ImageReaderFactory in project dcm4che by dcm4che.
the class LdapImageReaderConfiguration method merge.
private void merge(ConfigurationChanges diffs, ImageReaderFactory prev, ImageReaderFactory factory, String imageReadersDN) throws NamingException {
for (Entry<String, ImageReaderParam> entry : prev.getEntries()) {
String tsuid = entry.getKey();
if (factory.get(tsuid) == null) {
String dn = dnOf(tsuid, imageReadersDN);
config.destroySubcontext(dn);
ConfigurationChanges.addModifiedObject(diffs, dn, ConfigurationChanges.ChangeType.D);
}
}
for (Entry<String, ImageReaderParam> entry : factory.getEntries()) {
String tsuid = entry.getKey();
String dn = dnOf(tsuid, imageReadersDN);
ImageReaderParam prevParam = prev.get(tsuid);
if (prevParam == null) {
ConfigurationChanges.ModifiedObject ldapObj = ConfigurationChanges.addModifiedObject(diffs, dn, ConfigurationChanges.ChangeType.C);
config.createSubcontext(dn, storeTo(ConfigurationChanges.nullifyIfNotVerbose(diffs, ldapObj), tsuid, entry.getValue(), new BasicAttributes(true)));
} else {
ConfigurationChanges.ModifiedObject ldapObj = ConfigurationChanges.addModifiedObject(diffs, dn, ConfigurationChanges.ChangeType.U);
config.modifyAttributes(dn, storeDiffs(ldapObj, prevParam, entry.getValue(), new ArrayList<ModificationItem>()));
ConfigurationChanges.removeLastIfEmpty(diffs, ldapObj);
}
}
}
use of org.dcm4che3.imageio.codec.ImageReaderFactory in project dcm4che by dcm4che.
the class LdapImageReaderConfiguration method loadChilds.
@Override
protected void loadChilds(Device device, String deviceDN) throws NamingException, ConfigurationException {
String imageReadersDN = CN_IMAGE_READER_FACTORY + deviceDN;
try {
config.getAttributes(imageReadersDN);
} catch (NameNotFoundException e) {
return;
}
ImageReaderFactory factory = new ImageReaderFactory();
NamingEnumeration<SearchResult> ne = config.search(imageReadersDN, "(objectclass=dcmImageReader)");
try {
while (ne.hasMore()) {
SearchResult sr = ne.next();
Attributes attrs = sr.getAttributes();
factory.put(LdapUtils.stringValue(attrs.get("dicomTransferSyntax"), null), new ImageReaderParam(LdapUtils.stringValue(attrs.get("dcmIIOFormatName"), null), LdapUtils.stringValue(attrs.get("dcmJavaClassName"), null), LdapUtils.stringValue(attrs.get("dcmPatchJPEGLS"), null), LdapUtils.stringArray(attrs.get("dcmImageReadParam"))));
}
} finally {
LdapUtils.safeClose(ne);
}
device.addDeviceExtension(new ImageReaderExtension(factory));
}
Aggregations