@Override public boolean execute() { try { for (Profile profile : profiles) { String profileId = profile.getItemId(); if (!StringUtils.equals(profileId, masterProfileId)) { List<Session> sessions = persistenceService.query("profileId", profileId, null, Session.class); if (masterProfileId.equals(profileId) && !sessions.contains(currentSession)) { sessions.add(currentSession); } for (Session session : sessions) { persistenceService.update(session.getItemId(), session.getTimeStamp(), Session.class, "profileId", anonymousBrowsing ? null : masterProfileId); } List<Event> events = persistenceService.query("profileId", profileId, null, Event.class); for (Event event : events) { persistenceService.update(event.getItemId(), event.getTimeStamp(), Event.class, "profileId", anonymousBrowsing ? null : masterProfileId); } // we must mark all the profiles that we merged into the master as merged with the master, and they will // be deleted upon next load profile.setMergedWith(masterProfileId); persistenceService.update(profile.getItemId(), null, Profile.class, "mergedWith", masterProfileId); } } } catch (Exception e) { logger.error("unable to execute callback action, profile and session will not be saved", e); return false; } return true; } });
private void clearAutoGeneratedRules(List<Rule> rules, String idWithScope) { for (Rule previousRule : rules) { previousRule.getLinkedItems().remove(idWithScope); if (previousRule.getLinkedItems().isEmpty()) { // todo remove profile properties ? persistenceService.remove(previousRule.getItemId(), Rule.class); } else { persistenceService.update(previousRule.getItemId(), null, Rule.class, "linkedItems", previousRule.getLinkedItems()); } } }
private void clearAutoGeneratedRules(List<Rule> rules, String idWithScope) { for (Rule previousRule : rules) { previousRule.getLinkedItems().remove(idWithScope); if (previousRule.getLinkedItems().isEmpty()) { // todo remove profile properties ? persistenceService.remove(previousRule.getItemId(), Rule.class); } else { persistenceService.update(previousRule.getItemId(), null, Rule.class, "linkedItems", previousRule.getLinkedItems()); } } }
@Override public void delete(String listId) { Condition query = new Condition(definitionsService.getConditionType("profilePropertyCondition")); query.setParameter("propertyName", "systemProperties.lists"); query.setParameter("comparisonOperator", "equals"); query.setParameter("propertyValue", listId); List<Profile> profiles = persistenceService.query(query, null, Profile.class); Map<String, Object> profileProps; for (Profile p : profiles) { profileProps = p.getSystemProperties(); if(profileProps != null && profileProps.get("lists") != null) { int index = ((List) profileProps.get("lists")).indexOf(listId); if(index != -1){ ((List) profileProps.get("lists")).remove(index); persistenceService.update(p.getItemId(), null, Profile.class, "systemProperties", profileProps); } } } persistenceService.remove(listId, UserList.class); } }
systemProperties.put("pastEvents", pastEventCounts); try { persistenceService.update(profileId, null, Profile.class, "systemProperties", systemProperties); } catch (Exception e) { logger.error("Error updating profile {} past event system properties", profileId, e);
@Override public void delete(String listId) { Condition query = new Condition(definitionsService.getConditionType("profilePropertyCondition")); query.setParameter("propertyName", "systemProperties.lists"); query.setParameter("comparisonOperator", "equals"); query.setParameter("propertyValue", listId); List<Profile> profiles = persistenceService.query(query, null, Profile.class); Map<String, Object> profileProps; for (Profile p : profiles) { profileProps = p.getSystemProperties(); if(profileProps != null && profileProps.get("lists") != null) { int index = ((List) profileProps.get("lists")).indexOf(listId); if(index != -1){ ((List) profileProps.get("lists")).remove(index); persistenceService.update(p.getItemId(), null, Profile.class, "systemProperties", profileProps); } } } persistenceService.remove(listId, UserList.class); } }
systemProperties.put("pastEvents", pastEventCounts); try { persistenceService.update(profileId, null, Profile.class, "systemProperties", systemProperties); } catch (Exception e) { logger.error("Error updating profile {} past event system properties", profileId, e);
persistenceService.update(event.getProfile().getItemId(), null, Profile.class, "systemProperties", event.getProfile().getSystemProperties());
for (Profile profileToAdd : profilesToAdd.getList()) { profileToAdd.getSegments().add(segment.getItemId()); persistenceService.update(profileToAdd.getItemId(), null, Profile.class, "segments", profileToAdd.getSegments()); Event profileUpdated = new Event("profileUpdated", null, profileToAdd, null, null, profileToAdd, new Date()); profileUpdated.setPersistent(false); for (Profile profileToRemove : profilesToRemove.getList()) { profileToRemove.getSegments().remove(segment.getItemId()); persistenceService.update(profileToRemove.getItemId(), null, Profile.class, "segments", profileToRemove.getSegments()); Event profileUpdated = new Event("profileUpdated", null, profileToRemove, null, null, profileToRemove, new Date()); profileUpdated.setPersistent(false); for (Profile profileToRemove : profilesToRemove.getList()) { profileToRemove.getSegments().remove(segment.getItemId()); persistenceService.update(profileToRemove.getItemId(), null, Profile.class, "segments", profileToRemove.getSegments()); updatedProfileCount++;
for (Profile profileToAdd : profilesToAdd.getList()) { profileToAdd.getSegments().add(segment.getItemId()); persistenceService.update(profileToAdd.getItemId(), null, Profile.class, "segments", profileToAdd.getSegments()); Event profileUpdated = new Event("profileUpdated", null, profileToAdd, null, null, profileToAdd, new Date()); profileUpdated.setPersistent(false); for (Profile profileToRemove : profilesToRemove.getList()) { profileToRemove.getSegments().remove(segment.getItemId()); persistenceService.update(profileToRemove.getItemId(), null, Profile.class, "segments", profileToRemove.getSegments()); Event profileUpdated = new Event("profileUpdated", null, profileToRemove, null, null, profileToRemove, new Date()); profileUpdated.setPersistent(false); for (Profile profileToRemove : profilesToRemove.getList()) { profileToRemove.getSegments().remove(segment.getItemId()); persistenceService.update(profileToRemove.getItemId(), null, Profile.class, "segments", profileToRemove.getSegments()); updatedProfileCount++;
@Override public Boolean anonymizeBrowsingData(String profileId) { Profile profile = profileService.load(profileId); if (profile == null) { return false; } List<Session> sessions = profileService.getProfileSessions(profileId, null, 0, -1, null).getList(); if (sessions.isEmpty()) { return false; } for (Session session : sessions) { Profile newProfile = getAnonymousProfile(session.getProfile()); session.setProfile(newProfile); persistenceService.save(session); List<Event> events = eventService.searchEvents(session.getItemId(), new String[0], null, 0, -1, null).getList(); for (Event event : events) { persistenceService.update(event.getItemId(), event.getTimeStamp(), Event.class, "profileId", newProfile.getItemId()); } } return true; }
for (Profile profileToRemove : previousProfiles) { profileToRemove.getSegments().remove(segmentId); persistenceService.update(profileToRemove.getItemId(), null, Profile.class, "segments", profileToRemove.getSegments());
for (Profile profileToRemove : previousProfiles) { profileToRemove.getSegments().remove(segmentId); persistenceService.update(profileToRemove.getItemId(), null, Profile.class, "segments", profileToRemove.getSegments());