private static Attributes storeTo(CompressionRule rule, BasicAttributes attrs) { attrs.put("objectclass", "dcmCompressionRule"); attrs.put("cn", rule.getCommonName()); LdapUtils.storeNotEmpty(attrs, "dcmPhotometricInterpretation", rule.getPhotometricInterpretations()); LdapUtils.storeNotEmpty(attrs, "dcmBitsStored", rule.getBitsStored()); LdapUtils.storeNotDef(attrs, "dcmPixelRepresentation", rule.getPixelRepresentation(), -1); LdapUtils.storeNotEmpty(attrs, "dcmAETitle", rule.getAETitles()); LdapUtils.storeNotEmpty(attrs, "dcmSOPClass", rule.getSOPClasses()); LdapUtils.storeNotEmpty(attrs, "dcmBodyPartExamined", rule.getBodyPartExamined()); attrs.put("dicomTransferSyntax", rule.getTransferSyntax()); LdapUtils.storeNotEmpty(attrs, "dcmImageWriteParam", rule.getImageWriteParams()); return attrs; }
private List<ModificationItem> storeDiffs(ConfigurationChanges.ModifiedObject ldapObj, CompressionRule prev, CompressionRule rule, List<ModificationItem> mods) { LdapUtils.storeDiff(ldapObj, mods, "dcmPhotometricInterpretation", prev.getPhotometricInterpretations(), rule.getPhotometricInterpretations()); LdapUtils.storeDiffObject(ldapObj, mods, "dcmBitsStored", prev.getBitsStored(), rule.getBitsStored(), null); LdapUtils.storeDiff(ldapObj, mods, "dcmPixelRepresentation", prev.getPixelRepresentation(), rule.getPixelRepresentation(), -1); LdapUtils.storeDiff(ldapObj, mods, "dcmAETitle", prev.getAETitles(), rule.getAETitles()); LdapUtils.storeDiff(ldapObj, mods, "dcmSOPClass", prev.getSOPClasses(), rule.getSOPClasses()); LdapUtils.storeDiff(ldapObj, mods, "dcmBodyPartExamined", prev.getBodyPartExamined(), rule.getBodyPartExamined()); LdapUtils.storeDiffObject(ldapObj, mods, "dicomTransferSyntax", prev.getTransferSyntax(), rule.getTransferSyntax(), null); LdapUtils.storeDiff(ldapObj, mods, "dcmImageWriteParam", prev.getImageWriteParams(), rule.getImageWriteParams()); return mods; }
public CompressionRule findByCommonName(String commonName) { for (CompressionRule rule : list) if (commonName.equals(rule.getCommonName())) return rule; return null; }
private CompressionRule compressionRule(Attributes attrs) throws NamingException { return new CompressionRule( LdapUtils.stringValue(attrs.get("cn"), null), LdapUtils.stringArray(attrs.get("dcmPhotometricInterpretation")), LdapUtils.intArray(attrs.get("dcmBitsStored")), LdapUtils.intValue(attrs.get("dcmPixelRepresentation"), -1), LdapUtils.stringArray(attrs.get("dcmAETitle")), LdapUtils.stringArray(attrs.get("dcmSOPClass")), LdapUtils.stringArray(attrs.get("dcmBodyPartExamined")), LdapUtils.stringValue(attrs.get("dicomTransferSyntax"), null), LdapUtils.stringArray(attrs.get("dcmImageWriteParam"))); }
public void add(CompressionRule rule) { if (findByCommonName(rule.getCommonName()) != null) throw new IllegalStateException("CompressionRule with cn: '" + rule.getCommonName() + "' already exists"); int index = Collections.binarySearch(list, rule); if (index < 0) index = -(index+1); list.add(index, rule); }
public void store(CompressionRules rules, String parentDN) throws NamingException { for (CompressionRule rule : rules) config.createSubcontext( LdapUtils.dnOf("cn", rule.getCommonName(), parentDN), storeTo(rule, new BasicAttributes(true))); }
public void merge(ConfigurationChanges diffs, CompressionRules prevRules, CompressionRules rules, String parentDN) throws NamingException { for (CompressionRule prevRule : prevRules) { String cn = prevRule.getCommonName(); if (rules == null || rules.findByCommonName(cn) == null) { String dn = LdapUtils.dnOf("cn", cn, parentDN); config.destroySubcontext(dn); ConfigurationChanges.addModifiedObject(diffs, dn, ConfigurationChanges.ChangeType.D); } } for (CompressionRule rule : rules) { String cn = rule.getCommonName(); String dn = LdapUtils.dnOf("cn", cn, parentDN); CompressionRule prevRule = prevRules != null ? prevRules.findByCommonName(cn) : null; if (prevRule == null) { ConfigurationChanges.ModifiedObject ldapObj = ConfigurationChanges.addModifiedObject(diffs, dn, ConfigurationChanges.ChangeType.C); config.createSubcontext(dn, storeTo(rule, new BasicAttributes(true))); } else { ConfigurationChanges.ModifiedObject ldapObj = ConfigurationChanges.addModifiedObject(diffs, dn, ConfigurationChanges.ChangeType.U); config.modifyAttributes(dn, storeDiffs(ldapObj, prevRule, rule, new ArrayList<ModificationItem>())); ConfigurationChanges.removeLastIfEmpty(diffs, ldapObj); } } }