Search in sources :

Example 1 with ImageReaderFactory

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;
}
Also used : ImageReaderFactory(org.dcm4che3.imageio.codec.ImageReaderFactory) ImageReaderExtension(org.dcm4che3.net.imageio.ImageReaderExtension)

Example 2 with ImageReaderFactory

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()));
    }
}
Also used : ImageReaderFactory(org.dcm4che3.imageio.codec.ImageReaderFactory)

Example 3 with ImageReaderFactory

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);
        }
    }
}
Also used : ConfigurationChanges(org.dcm4che3.conf.api.ConfigurationChanges) BasicAttributes(javax.naming.directory.BasicAttributes) ImageReaderParam(org.dcm4che3.imageio.codec.ImageReaderFactory.ImageReaderParam) ArrayList(java.util.ArrayList)

Example 4 with ImageReaderFactory

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));
}
Also used : ImageReaderParam(org.dcm4che3.imageio.codec.ImageReaderFactory.ImageReaderParam) NameNotFoundException(javax.naming.NameNotFoundException) ImageReaderFactory(org.dcm4che3.imageio.codec.ImageReaderFactory) BasicAttributes(javax.naming.directory.BasicAttributes) Attributes(javax.naming.directory.Attributes) SearchResult(javax.naming.directory.SearchResult) ImageReaderExtension(org.dcm4che3.net.imageio.ImageReaderExtension)

Aggregations

ImageReaderFactory (org.dcm4che3.imageio.codec.ImageReaderFactory)3 BasicAttributes (javax.naming.directory.BasicAttributes)2 ImageReaderParam (org.dcm4che3.imageio.codec.ImageReaderFactory.ImageReaderParam)2 ImageReaderExtension (org.dcm4che3.net.imageio.ImageReaderExtension)2 ArrayList (java.util.ArrayList)1 NameNotFoundException (javax.naming.NameNotFoundException)1 Attributes (javax.naming.directory.Attributes)1 SearchResult (javax.naming.directory.SearchResult)1 ConfigurationChanges (org.dcm4che3.conf.api.ConfigurationChanges)1