}
private QProfileName prepareTarget(String fromProfileKey, String toName) {
DbSession dbSession = db.openSession(false);
try {
QualityProfileDto fromProfile = db.qualityProfileDao().getNonNullByKey(dbSession, fromProfileKey);
QProfileName toProfileName = new QProfileName(fromProfile.getLanguage(), toName);
verify(fromProfile, toProfileName);
QualityProfileDto toProfile = db.qualityProfileDao().getByNameAndLanguage(toProfileName.getName(), toProfileName.getLanguage(), dbSession);
if (toProfile == null) {
// Do not delegate creation to QProfileBackuper because we need to keep
// the parent-child association, if exists.
toProfile = factory.create(dbSession, toProfileName);
toProfile.setParentKee(fromProfile.getParentKee());
db.qualityProfileDao().update(dbSession, toProfile);
dbSession.commit();
}
return toProfileName;