- Add the Codota plugin to your IDE and get smart completions
private void myMethod () {}
/** * Create update entry from maps. * * @param system * @param user * @param targetType * @param target * @param oldMap * @param newMap * @return */ public static Tapahtuma createUPDATEMaps(String system, String user, String targetType, String target, Map<String, String> oldMap, Map<String, String> newMap) { Tapahtuma t = createUPDATE(system, user, targetType, target); try { Collection<String> changedProperties = SimpleBeanSerializer.getDiffProperties(oldMap, newMap); for (String propertyName : changedProperties) { t.addValueChange(propertyName, oldMap != null ? oldMap.get(propertyName) : null, newMap != null ? newMap.get(propertyName) : null); } } catch (Throwable ex) { t.addValue("DIFF FAILED", ex.toString()); ex.printStackTrace(); } return t; }
/** * Create UPDATE message, tries to generate field change information - best approximaption. * * @param system * @param user * @param targetType * @param target * @param oldObject * @param newObject * @return created event */ public static Tapahtuma createUPDATEBeans(String system, String user, String targetType, String target, Object oldObject, Object newObject) { Tapahtuma t = createUPDATE(system, user, targetType, target); try { Map<String, String> oldMap = SimpleBeanSerializer.getBeanAsMap(oldObject); Map<String, String> newMap = SimpleBeanSerializer.getBeanAsMap(newObject); Collection<String> changedProperties = SimpleBeanSerializer.getDiffProperties(oldMap, newMap); for (String propertyName : changedProperties) { t.addValueChange(propertyName, oldMap.get(propertyName), newMap.get(propertyName)); } } catch (Throwable ex) { t.addValue("SERIALIZATION/DIFF FAILED", ex.toString()); } return t; }
/** * Logs event when a form phase is successfully saved * as application data in data store. */ @AfterReturning(pointcut = "execution(* fi.vm.sade.haku.oppija.hakemus.service.ApplicationService.submitApplication(..)) && args(applicationSystemId,..)", returning = "application") public void logSubmitApplication(final String applicationSystemId, final Application application) { try { Tapahtuma t = new Tapahtuma(); t.setTarget("Haku: " + applicationSystemId + ", käyttäjä: " + userSession.getUser().getUserName() + ", hakemus oid: " + application.getOid()); t.setTimestamp(new Date()); t.setUserActsForUser("" + userSession.getUser().getUserName()); t.setType("Hakemus lähetetty"); t.setUser("Hakemus Service"); Map<String, String> answers = application.getVastauksetMerged(); for (Map.Entry<String, String> answer : answers.entrySet()) { t.addValueChange(answer.getKey(), null, answer.getValue()); } LOGGER.debug(t.toString()); logger.log(t); } catch (Exception e) { LOGGER.warn("Could not log submit application event"); } }
public void logUpdateApplication(final Application application, final ApplicationPhase applicationPhase) { try { MapDifference<String, String> diffAnswers = ApplicationDiffUtil.diffAnswers(application, applicationPhase); AnswersDifference answersDifference = new AnswersDifference(diffAnswers); List<Difference> differences = answersDifference.getDifferences(); Tapahtuma tapahtuma = new Tapahtuma(); tapahtuma.setTarget("hakemus: " + application.getOid() + ", vaihe: " + applicationPhase.getPhaseId()); tapahtuma.setTimestamp(new Date()); tapahtuma.setUserActsForUser(userSession.getUser().getUserName()); tapahtuma.setType("Hakemuksen muokkaus"); tapahtuma.setUser(userSession.getUser().getUserName()); for (Difference difference : differences) { tapahtuma.addValueChange(difference.getKey(), difference.getOldValue(), difference.getNewValue()); } LOGGER.debug(tapahtuma.toString()); logger.log(tapahtuma); } catch (Exception e) { LOGGER.warn("Could not log update application event"); } }