void persistConfiguration() { List<PastSnapshot> pastSnapshots = configuration.getProjectPastSnapshots(); for (PastSnapshot pastSnapshot : pastSnapshots) { projectSnapshot = session.reattach(Snapshot.class, projectSnapshot.getId()); projectSnapshot.setPeriodMode(pastSnapshot.getIndex(), pastSnapshot.getMode()); projectSnapshot.setPeriodModeParameter( pastSnapshot.getIndex(), pastSnapshot.getModeParameter()); projectSnapshot.setPeriodDate(pastSnapshot.getIndex(), pastSnapshot.getTargetDate()); session.save(projectSnapshot); } session.commit(); }
public ValidationMessages restoreProfile(String xmlBackup) { ValidationMessages messages = ValidationMessages.create(); RulesProfile profile = xmlProfileParser.parse(new StringReader(xmlBackup), messages); if (profile != null) { DatabaseSession session = sessionFactory.getSession(); RulesProfile existingProfile = session.getSingleResult( RulesProfile.class, "name", profile.getName(), "language", profile.getLanguage()); if (existingProfile != null) { messages.addErrorText( "The profile " + profile + " already exists. Please delete it before restoring."); } else if (!messages.hasErrors()) { session.saveWithoutFlush(profile); session.commit(); } } return messages; }
/** Important : the ruby controller has already create the profile */ public ValidationMessages importProfile( String profileName, String language, String importerKey, String profileDefinition) { ValidationMessages messages = ValidationMessages.create(); ProfileImporter importer = getProfileImporter(importerKey); RulesProfile profile = importer.importProfile(new StringReader(profileDefinition), messages); if (!messages.hasErrors()) { DatabaseSession session = sessionFactory.getSession(); RulesProfile persistedProfile = session.getSingleResult(RulesProfile.class, "name", profileName, "language", language); for (ActiveRule activeRule : profile.getActiveRules()) { ActiveRule persistedActiveRule = persistedProfile.activateRule(activeRule.getRule(), activeRule.getSeverity()); for (ActiveRuleParam activeRuleParam : activeRule.getActiveRuleParams()) { persistedActiveRule.setParameter(activeRuleParam.getKey(), activeRuleParam.getValue()); } } session.saveWithoutFlush(persistedProfile); session.commit(); } return messages; }
public void start() { TimeProfiler profiler = new TimeProfiler(); DatabaseSession session = sessionFactory.getSession(); disableAllRules(session); for (RuleRepository repository : repositories) { profiler.start( "Register rules [" + repository.getKey() + "/" + StringUtils.defaultString(repository.getLanguage(), "-") + "]"); registerRepository(repository, session); profiler.stop(); } profiler.start("Disable deprecated user rules"); disableDeprecatedUserRules(session); profiler.stop(); session.commit(); }
public void onSensorExecution(SensorExecutionEvent event) { if (event.isEnd()) { flushMemory(); session.commit(); } }
public void onDecoratorsPhase(DecoratorsPhaseEvent event) { if (event.isEnd()) { session.commit(); } }