Skip to content

Commit

Permalink
[DCMEEREQ-306] Upgrades/Migration of Configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
romank-agfa committed Jun 1, 2015
1 parent ea769dc commit d2322d9
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,13 @@
*/
package org.dcm4chee.conf.cdi;

import org.dcm4che3.conf.api.DicomConfigurationCustomizer;
import org.dcm4che3.conf.api.DicomConfigurationBuilderAddon;
import org.dcm4che3.conf.api.internal.DicomConfigurationManager;
import org.dcm4che3.conf.api.migration.MigrationScript;
import org.dcm4che3.conf.core.api.Configuration;
import org.dcm4che3.conf.core.api.ConfigurationException;
import org.dcm4che3.conf.dicom.DicomConfigurationBuilder;
import org.dcm4che3.conf.migration.MigrationRunner;
import org.dcm4che3.net.AEExtension;
import org.dcm4che3.net.DeviceExtension;
import org.dcm4che3.net.hl7.HL7ApplicationExtension;
Expand All @@ -53,6 +56,9 @@
import javax.enterprise.inject.Instance;
import javax.enterprise.inject.Produces;
import javax.inject.Inject;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

/**
* Centralized handling for all Java EE - based enhancements,
Expand All @@ -61,10 +67,11 @@
*
* @author Roman K
*/
public class DicomConfigurationExtenderEE {
@ApplicationScoped
public class DicomConfigurationEEAddon implements DicomConfigurationBuilderAddon {

private static Logger log = LoggerFactory
.getLogger(DicomConfigurationExtenderEE.class);
.getLogger(DicomConfigurationEEAddon.class);

@Inject
Instance<DeviceExtension> deviceExtensions;
Expand All @@ -78,27 +85,30 @@ public class DicomConfigurationExtenderEE {
@Inject
Instance<Configuration> customConfigStorage;

@Produces
@ApplicationScoped
public DicomConfigurationCustomizer getConfigurationEECustomizer()
throws ConfigurationException {
@Inject
Instance<MigrationScript> migrationScripts;

return new DicomConfigurationCustomizer() {
@Override
public void customize(DicomConfigurationBuilder builder) {
@Override
public void beforeBuild(DicomConfigurationBuilder builder) {
for (DeviceExtension ext : deviceExtensions) builder.registerDeviceExtension(ext.getClass());
for (AEExtension ext : aeExtensions) builder.registerAEExtension(ext.getClass());
for (HL7ApplicationExtension ext : hl7ApplicationExtensions)
builder.registerHL7ApplicationExtension(ext.getClass());

for (DeviceExtension ext : deviceExtensions) builder.registerDeviceExtension(ext.getClass());
for (AEExtension ext : aeExtensions) builder.registerAEExtension(ext.getClass());
for (HL7ApplicationExtension ext : hl7ApplicationExtensions)
builder.registerHL7ApplicationExtension(ext.getClass());
if (!customConfigStorage.isUnsatisfied()) {
builder.registerCustomConfigurationStorage(customConfigStorage.get());
}

}

if (!customConfigStorage.isUnsatisfied()) {
builder.registerCustomConfigurationStorage(customConfigStorage.get());
}
@Override
public void afterBuild(DicomConfigurationManager manager) throws ConfigurationException {

}
};
}
// trigger migration
List<MigrationScript> scripts = new ArrayList<>();
for (MigrationScript migrationScript : migrationScripts) scripts.add(migrationScript);

new MigrationRunner(manager.getConfigurationStorage(), scripts, manager).migrate();

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -136,4 +136,9 @@ public Iterator search(String liteXPathExpression) throws IllegalArgumentExcepti
throw new RuntimeException("Not implemented");
}

@Override
public void lock() {
//TODO
}

}

0 comments on commit d2322d9

Please sign in to comment.