public Profile getAnonymousProfile(Profile profile) { Profile anonymousProfile = new Profile(); anonymousProfile.getSystemProperties().put("isAnonymousProfile", true); anonymousProfile.getProperties().putAll(profile.getProperties()); anonymousProfile.getProperties().keySet().removeAll(getDeniedProperties(profile.getItemId())); // profileService.save(anonymousProfile); return anonymousProfile; }
public boolean mergeProperty(String propertyName, PropertyType propertyType, List<Profile> profilesToMerge, Profile targetProfile) { boolean modified = false; for (Profile profileToMerge : profilesToMerge) { if (profileToMerge.getProperty(propertyName) != null && profileToMerge.getProperty(propertyName).toString().length() > 0) { targetProfile.setProperty(propertyName, profileToMerge.getProperty(propertyName)); modified = true; } } return modified; } }
if (!filteredProfile.getItemId().equals(masterProfile.getItemId())) { filteredProfilesToMerge.add(filteredProfile); allProfileProperties.addAll(profile.getProperties().keySet()); profileIdsToMerge.add(profileToMerge.getItemId()); logger.info("Merging profiles " + profileIdsToMerge + " into profile " + masterProfile.getItemId()); if (profile.getSegments() != null && profile.getSegments().size() > 0) { masterProfile.getSegments().addAll(profile.getSegments()); masterProfileChanged = true; if (profile.getConsents() != null && profile.getConsents().size() > 0) { for(String consentId : profile.getConsents().keySet()) { if(masterProfile.getConsents().containsKey(consentId)) { if(masterProfile.getConsents().get(consentId).getRevokeDate().before(new Date())) { masterProfile.getConsents().remove(consentId); masterProfileChanged = true; } else if(masterProfile.getConsents().get(consentId).getStatusDate().before(profile.getConsents().get(consentId).getStatusDate())) { masterProfile.getConsents().replace(consentId, profile.getConsents().get(consentId)); masterProfileChanged = true; masterProfile.getConsents().put(consentId, profile.getConsents().get(consentId)); masterProfileChanged = true;
public boolean saveMergeDeleteImportedProfile(ProfileToImport profileToImport) throws InvocationTargetException, IllegalAccessException { logger.debug("Importing profile with ID : {}", profileToImport.getItemId()); Profile existingProfile = new Profile(); if(profileToImport.getProperties().get(profileToImport.getMergingProperty()) != null) { List<Profile> existingProfiles = persistenceService.query("properties." + profileToImport.getMergingProperty(), profileToImport.getProperties().get(profileToImport.getMergingProperty()).toString(), null, Profile.class); if (profileToImport.isProfileToDelete()) { logger.debug("Profile is to delete!"); persistenceService.remove(existingProfile.getItemId(), Profile.class); return true; logger.debug("Properties to overwrite: {}", propertiesToOverwrite); for (String propName : propertiesToOverwrite) { existingProfile.getProperties().put(propName, profileToImport.getProperties().get(propName)); existingProfile.setProperties(profileToImport.getProperties()); existingProfile.setSegments(profileToImport.getSegments()); existingProfile.setScores(profileToImport.getScores()); } else if (existingProfiles.size() == 0 && !profileToImport.isProfileToDelete()) { logger.debug("New profile to add...");
/** * Sets the associated Profile. * * @param profile the associated Profile */ public void setProfile(Profile profile) { this.profileId = profile.getItemId(); this.profile = profile; }
@java.lang.Override protected DataTable buildDataTable() { Query query = new Query(); query.setSortby("properties.lastVisit:desc"); query.setLimit(maxEntries); Condition matchAllCondition = new Condition(definitionsService.getConditionType("matchAllCondition")); query.setCondition(matchAllCondition); PartialList<Profile> lastModifiedProfiles = profileService.search(query, Profile.class); DataTable dataTable = new DataTable(); for (Profile profile : lastModifiedProfiles.getList()) { ArrayList<Comparable> rowData = new ArrayList<>(); rowData.add(profile.getItemId()); rowData.add(profile.getScope()); rowData.add(StringUtils.join(profile.getSegments(), ",")); rowData.add(StringUtils.join(profile.getConsents().keySet(), ",")); rowData.add((String) profile.getProperty("lastVisit")); dataTable.addRow(rowData.toArray(new Comparable[rowData.size()])); } return dataTable; } }
@Override public List<String> getFilteredEventTypes(Profile profile) { if (profile == null) { return new ArrayList<String>(); } return (List<String>) profile.getProperty("filteredEventTypes"); }
if (profile instanceof Persona || profile.isAnonymousProfile()) { return EventService.NO_CHANGE; final String mergeProfilePreviousPropertyValue = profile.getSystemProperties().get(mergeProfilePropertyName) != null ? profile.getSystemProperties().get(mergeProfilePropertyName).toString() : ""; String profileId = profile.getItemId(); } else { profile = new Profile(UUID.randomUUID().toString()); profile.setProperty("firstVisit", currentSession.getTimeStamp()); profile.getSystemProperties().put(mergeProfilePropertyName, mergeProfilePropertyValue); logger.info("Different users, switch to " + profile.getItemId()); event.setProfileId(profile.getItemId()); event.setProfile(profile); } else { profile.getSystemProperties().put(mergeProfilePropertyName, mergeProfilePropertyValue); add = add && !StringUtils.equals(p.getItemId(), profile.getItemId()); if (!masterProfile.getItemId().equals(profileId)) { HttpServletResponse httpServletResponse = (HttpServletResponse) event.getAttributes().get(Event.HTTP_RESPONSE_ATTRIBUTE); final String masterProfileId = masterProfile.getItemId();
@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); } }
Profile profile = (Profile) item; if ("segments".equals(expression)) { return profile.getSegments(); return profile.getConsents(); return profile.getScores().get(expression.substring("scores.".length())); return getNestedPropertyValue(expression.substring("properties.".length()), profile.getProperties()); return getNestedPropertyValue(expression.substring("systemProperties.".length()), profile.getSystemProperties());
for (String key : profile.getProperties().keySet()) { if (!propertyTypesById.containsKey(key)) { propertyTypesById.put(key, null); sb.append(profile.getItemId()); sb.append(";"); for (Map.Entry<String, PropertyType> propertyIdAndType : propertyTypesById.entrySet()) { String propertyId = propertyIdAndType.getKey(); if (profile.getProperties().get(propertyId) != null) { handleExportProperty(sb, profile.getProperties().get(propertyId), propertyIdAndType.getValue()); } else { sb.append(""); for (String segment : profile.getSegments()) { Segment s = segmentService.getSegmentDefinition(segment); segmentNames.add(csvEncode(s.getMetadata().getName()));
@Override public Boolean isRequireAnonymousBrowsing(Profile profile) { if (profile == null) { return false; } Boolean anonymous = (Boolean) profile.getSystemProperties().get("requireAnonymousProfile"); return anonymous != null && anonymous; }
long t2= System.currentTimeMillis(); 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); long t2= System.currentTimeMillis(); 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); while (profilesToRemove.getList().size() > 0) { for (Profile profileToRemove : profilesToRemove.getList()) { profileToRemove.getSegments().remove(segment.getItemId()); persistenceService.update(profileToRemove.getItemId(), null, Profile.class, "segments", profileToRemove.getSegments()); updatedProfileCount++;
@Override public Boolean anonymizeProfile(String profileId, String scope) { Profile profile = profileService.load(profileId); if (profile == null) { return false; } // first we send out the anonymize profile event to make sure other systems can still use external identifiers to lookup the profile and anonymize it. Event anonymizeProfileEvent = new Event("anonymizeProfile", null, profile, scope, null, profile, new Date()); anonymizeProfileEvent.setPersistent(true); eventService.send(anonymizeProfileEvent); boolean res = profile.getProperties().keySet().removeAll(getDeniedProperties(profile.getItemId())); Event profileUpdatedEvent = new Event("profileUpdated", null, profile, scope, null, profile, new Date()); profileUpdatedEvent.setPersistent(false); eventService.send(profileUpdatedEvent); profileService.save(profile); return res; }
String unomiIdentifierValue = (String) profile.getProperty(sfdcConfiguration.getUnomiIdentifierField()); if (isProfileInContacts(unomiIdentifierValue)) { logger.info("Contact {} found in SFDC... No SFDC field value to send, will not send anything to " + for (String profilePropertyKey : profile.getProperties().keySet()) { String sfdcFieldName = sfdcConfiguration.getUnomiToSfdcFieldMappings().get(profilePropertyKey); if (sfdcFieldName == null) { Object unomiPropertyValue = profile.getProperties().get(profilePropertyKey); if (existingSfdcLeadFields.get(sfdcFieldName) == null) {
@Override public int execute(Action action, Event event) { if (event.getProfile().isAnonymousProfile()) { return EventService.NO_CHANGE; } boolean updated = false; SegmentsAndScores segmentsAndScoringForProfile = segmentService.getSegmentsAndScoresForProfile(event.getProfile()); Set<String> segments = segmentsAndScoringForProfile.getSegments(); if (!segments.equals(event.getProfile().getSegments())) { event.getProfile().setSegments(segments); updated = true; } Map<String, Integer> scores = segmentsAndScoringForProfile.getScores(); if (!scores.equals(event.getProfile().getScores())) { event.getProfile().setScores(scores); updated = true; } return updated ? EventService.PROFILE_UPDATED : EventService.NO_CHANGE; } }
@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; } });
public Session saveSession(Session session) { if (session.getItemId() == null) { return null; } if (session.getProfile() != null && session.getProfile().getProperties() != null) { session.getProfile().setProperties(removePersonalIdentifiersFromSessionProfile(session.getProfile().getProperties())); } return persistenceService.save(session) ? session : null; }
Map<String,Integer> interestValues = (Map<String, Integer>) profile.getProperties().get("interests"); for (String interest : interestList.split(" ")) { if (interestValues.get(interest) != null) { Map<String,Integer> scoreValues = (Map<String, Integer>) profile.getScores(); for (String scoringPlan : scoringPlanList.split(" ")) { if (scoreValues.get(scoringPlan) != null) {
@Override public Boolean removeProperty(String profileId, String propertyName) { Profile profile = profileService.load(profileId); if (profile == null) { return null; } if (!profile.getProperties().containsKey(propertyName)) { return false; } Object propertyValue = profile.getProperties().remove(propertyName); profileService.save(profile); return true; } }