HashMap<Long,ProcessInstanceDAO> instances = new HashMap<Long,ProcessInstanceDAO>();
// Migrate correlation set values
Collection<CorrelationSetDAO> csets = connection.getActiveCorrelationSets();
for (CorrelationSetDAO cset : csets) {
CorrelationKey ckey = cset.getValue();
instances.put(cset.getInstance().getInstanceId(), cset.getInstance());
if (ckey != null) {
__log.debug("Correlation set id " + cset.getCorrelationSetId() + " key " + ckey);
Integer ckeyInt = asInt(ckey.getCorrelationSetName());
if (ckeyInt != null) {
OScope.CorrelationSet ocset = findCorrelationById(ckeyInt, registeredProcesses, cset.getProcess().getProcessId());
if (ocset == null) __log.debug("Correlation set not found, couldn't upgrade set " + ckey.toCanonicalString());
else {
cset.setValue(null, new CorrelationKey(ocset.name, ckey.getValues()));
}
}
}
}
// Migrate routes and message queue for each correlator
for (BpelProcess process : registeredProcesses) {
__log.debug("Migrating correlators for process " + process.getConf().getProcessId());
ProcessDAO processDao = connection.getProcess(process.getConf().getProcessId());
for (OPartnerLink plink : process.getOProcess().getAllPartnerLinks()) {
if (plink.hasMyRole()) {
for (Iterator opI = plink.myRolePortType.getOperations().iterator(); opI.hasNext();) {
Operation op = (Operation)opI.next();
try {
CorrelatorDAO corr = processDao.getCorrelator(plink.getName() + "." + op.getName());
// Changing all routes
if (corr != null) {
for (MessageRouteDAO routeDAO : corr.getAllRoutes()) {
CorrelationKey oldKey = routeDAO.getCorrelationKey();
if (oldKey != null) {
Integer ckeyInt = asInt(oldKey.getCorrelationSetName());
if (ckeyInt != null) {
OScope.CorrelationSet ocset = findCorrelationById(ckeyInt, registeredProcesses, process.getConf().getProcessId());
if (ocset == null) __log.debug("Correlation set not found, couldn't upgrade route " + oldKey.toCanonicalString());
else {
routeDAO.setCorrelationKey(new CorrelationKey(ocset.name, oldKey.getValues()));
}
}
}
}
// Changing all queued messages
for (CorrelatorMessageDAO corrMsgDAO : corr.getAllMessages()) {
CorrelationKey oldKey = corrMsgDAO.getCorrelationKey();
if (oldKey != null) {
Integer ckeyInt = asInt(oldKey.getCorrelationSetName());
if (ckeyInt != null) {
OScope.CorrelationSet ocset = findCorrelationById(ckeyInt, registeredProcesses, process.getConf().getProcessId());
if (ocset == null) __log.debug("Correlation set not found, couldn't upgrade route " + oldKey.toCanonicalString());
else {
corrMsgDAO.setCorrelationKey(new CorrelationKey(ocset.name, oldKey.getValues()));
}
}
}
}
__log.debug("Migrated routes and message queue for correlator " + plink.getName() + "." + op.getName());