@Override public List<String> getFilteredEventTypes(Profile profile) { if (profile == null) { return new ArrayList<String>(); } return (List<String>) profile.getProperty("filteredEventTypes"); }
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; } }
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; } }
public boolean mergeProperty(String propertyName, PropertyType propertyType, List<Profile> profilesToMerge, Profile targetProfile) { Object result = null; int i = profilesToMerge.size() - 1; while (result == null && i >=0) { result = profilesToMerge.get(i).getProperty(propertyName); i--; } if (result != null && (targetProfile.getProperty(propertyName) == null || !result.equals(targetProfile.getProperty(propertyName)))) { targetProfile.setProperty(propertyName, result); return true; } return false; } }
public boolean mergeProperty(String propertyName, PropertyType propertyType, List<Profile> profilesToMerge, Profile targetProfile) { Object result = null; int i = profilesToMerge.size() - 1; while (result == null && i >=0) { result = profilesToMerge.get(i).getProperty(propertyName); i--; } if (result != null && (targetProfile.getProperty(propertyName) == null || !result.equals(targetProfile.getProperty(propertyName)))) { targetProfile.setProperty(propertyName, result); return true; } return false; } }
@Override public Object extract(String valueAsString, Event event) throws IllegalAccessException, NoSuchMethodException, InvocationTargetException { return event.getProfile().getProperty(valueAsString); } });
@Override public Object extract(String valueAsString, Event event) throws IllegalAccessException, NoSuchMethodException, InvocationTargetException { return event.getProfile().getProperty(valueAsString); } });
private JsonNode isMemberOfMailChimpList(Profile profile, String listIdentifier) { String email = profile.getProperty(EMAIL).toString().toLowerCase(); String md5Hex = DigestUtils.md5Hex(email); JsonNode response = HttpUtils.executeGetRequest(httpClient, getBaseUrl() + "/lists/" + listIdentifier + "/members/" + md5Hex, getHeaders(), true); if (response != null) { if (response.has(EMAIL_ADDRESS)) { if (response.get(EMAIL_ADDRESS).asText().toLowerCase().equals(email)) { return response; } } } return null; }
@Override public int execute(Action action, Event event) { boolean updated = false; if (event.getProfile().getProperty("birthDate") != null) { Integer y = Years.yearsBetween(new DateTime(event.getProfile().getProperty("birthDate")), new DateTime()).getYears(); if (event.getProfile().getProperty("age") == null || event.getProfile().getProperty("age") != y) { updated = true; event.getProfile().setProperty("age", y); } } return updated ? EventService.PROFILE_UPDATED : EventService.NO_CHANGE; } }
@Override public MailChimpResult unsubscribeFromMCList(Profile profile, Action action) { if (!isMailChimpConnectorConfigured() || profile.getProperty(EMAIL) == null) { return MailChimpResult.ERROR; } String listIdentifier = (String) action.getParameterValues().get(LIST_IDENTIFIER); if (StringUtils.isBlank(listIdentifier)) { logger.warn("Couldn't get the list identifier from Unomi"); return MailChimpResult.ERROR; } JsonNode currentMember = isMemberOfMailChimpList(profile, listIdentifier); if (currentMember == null) { return MailChimpResult.REMOVED; } if (currentMember.get(STATUS).asText().equals(UNSUBSCRIBED)) { return MailChimpResult.NO_CHANGE; } JSONObject body = new JSONObject(); body.put(STATUS, UNSUBSCRIBED); return updateSubscription(listIdentifier, body.toString(), currentMember, false); }
public int execute(Action action, Event event) { String eventPropertyName = (String) action.getParameterValues().get("eventPropertyName"); String profilePropertyName = (String) action.getParameterValues().get("profilePropertyName"); if (event.getProfile().getProperty(profilePropertyName) == null || !event.getProfile().getProperty(profilePropertyName).equals(event.getProperty(eventPropertyName))) { event.getProfile().setProperty(profilePropertyName, event.getProperty(eventPropertyName)); return EventService.PROFILE_UPDATED; } return EventService.NO_CHANGE; } }
@Override public MailChimpResult removeFromMCList(Profile profile, Action action) { if (!isMailChimpConnectorConfigured() || profile.getProperty(EMAIL) == null) { return MailChimpResult.ERROR; } String listIdentifier = (String) action.getParameterValues().get(LIST_IDENTIFIER); if (StringUtils.isBlank(listIdentifier)) { logger.warn("Couldn't get the list identifier from Unomi"); return MailChimpResult.ERROR; } JsonNode currentMember = isMemberOfMailChimpList(profile, listIdentifier); if (currentMember == null) { return MailChimpResult.NO_CHANGE; } JsonNode response = HttpUtils.executeDeleteRequest(httpClient, getBaseUrl() + "/lists/" + listIdentifier + "/members/" + currentMember.get(ID).asText(), getHeaders()); if (response == null || (response.has(ERRORS) && response.get(ERRORS).size() > 0)) { logger.error("Couldn't remove the visitor from the MailChimp list, list identifier was {} and response was {}", listIdentifier, response); return MailChimpResult.ERROR; } return MailChimpResult.REMOVED; }
return false; String unomiIdentifierValue = (String) profile.getProperty(sfdcConfiguration.getUnomiIdentifierField()); Set<String> foundSfdcLeadIds = findLeadIdsByIdentifierValue(unomiIdentifierValue); if (foundSfdcLeadIds.size() == 0) { if (sfdcLead.get(sfdcFieldName) != null) { Object sfdcFieldValue = sfdcLead.get(sfdcFieldName); if (sfdcFieldValue != null && !sfdcFieldValue.equals(profile.getProperty(unomiFieldName))) { profile.setProperty(unomiFieldName, sfdcFieldValue); profileUpdated = true;
@Override public MailChimpResult addToMCList(Profile profile, Action action) { if (!isMailChimpConnectorConfigured() || profile.getProperty(EMAIL) == null) { logger.error("The visitor does not have an email address"); return MailChimpResult.ERROR; userData.put(EMAIL_ADDRESS, profile.getProperty(EMAIL).toString()); userData.put(STATUS, SUBSCRIBED);
@Override public MailChimpResult updateMCProfileProperties(Profile profile, Action action) { if (!isMailChimpConnectorConfigured() || profile.getProperty(EMAIL) == null) { return MailChimpResult.ERROR; } String listIdentifier = (String) action.getParameterValues().get(LIST_IDENTIFIER); if (StringUtils.isBlank(listIdentifier)) { logger.warn("MailChimp list identifier not found"); return MailChimpResult.ERROR; } JsonNode currentMember = isMemberOfMailChimpList(profile, listIdentifier); if (currentMember == null) { logger.warn("The visitor was not part of the list"); return MailChimpResult.NO_CHANGE; } JSONObject mergeFields = new JSONObject(); MailChimpResult result = addProfilePropertiesToMergeFieldsObject(profile, listIdentifier, mergeFields); if (result != MailChimpResult.SUCCESS) { return result; } JSONObject body = new JSONObject(); body.put(MERGE_FIELDS, mergeFields); JsonNode response = HttpUtils.executePatchRequest(httpClient, getBaseUrl() + "/lists/" + listIdentifier + "/members/" + currentMember.get(ID).asText(), getHeaders(), body.toString()); if (response == null || (response.has(ERRORS) && response.get(ERRORS).size() > 0)) { logger.error("Error when updating visitor properties to MailChimp list, list identifier was {} and response was {}", listIdentifier, response); return MailChimpResult.ERROR; } return MailChimpResult.UPDATED; }
@SuppressWarnings({"unchecked", "rawtypes"}) public int execute(Action action, Event event) { boolean changed = false; Map<String, Object> properties = new HashMap<String, Object>(); if (event.getProperties() != null) { properties.putAll(event.getProperties()); } try { Object targetProperties = BeanUtilsBean.getInstance().getPropertyUtils().getProperty(event.getTarget(), "properties"); if (targetProperties instanceof Map) { properties.putAll((Map) targetProperties); } } catch (Exception e) { // Ignore } for (Map.Entry<String, Object> entry : properties.entrySet()) { if (event.getProfile().getProperty(entry.getKey()) == null || !event.getProfile().getProperty(entry.getKey()).equals(event.getProperty(entry.getKey()))) { String propertyMapping = profileService.getPropertyTypeMapping(entry.getKey()); String propertyName = (propertyMapping != null) ? propertyMapping : entry.getKey(); event.getProfile().setProperty(propertyName, entry.getValue()); changed = true; } } return changed ? EventService.PROFILE_UPDATED : EventService.NO_CHANGE; } }
@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; } }
Object propertyValue = profile.getProperty(propertyName); if (propType != null && BooleanUtils.isTrue(propType.isMultivalued())) { if (propertyValue != null) {
public int execute(Action action, Event event) { boolean changed = false; HttpServletRequest httpServletRequest = (HttpServletRequest) event.getAttributes().get(Event.HTTP_REQUEST_ATTRIBUTE); if (httpServletRequest == null) { return EventService.NO_CHANGE; } String requestHeaderName = (String) action.getParameterValues().get("requestHeaderName"); String profilePropertyName = (String) action.getParameterValues().get("profilePropertyName"); String sessionPropertyName = (String) action.getParameterValues().get("sessionPropertyName"); String requestHeaderValue = httpServletRequest.getHeader(requestHeaderName); if (requestHeaderValue != null) { if (profilePropertyName != null) { if (event.getProfile().getProperty(profilePropertyName) == null || !event.getProfile().getProperty(profilePropertyName).equals(requestHeaderValue)) { event.getProfile().setProperty(profilePropertyName, requestHeaderValue); return EventService.PROFILE_UPDATED; } } else if (sessionPropertyName != null) { if (event.getSession().getProperty(sessionPropertyName) == null || !event.getSession().getProperty(sessionPropertyName).equals(requestHeaderValue)) { event.getSession().setProperty(sessionPropertyName, requestHeaderValue); return EventService.SESSION_UPDATED; } } } return EventService.NO_CHANGE; } }
public int execute(Action action, Event event) { boolean changed = false; HttpServletRequest httpServletRequest = (HttpServletRequest) event.getAttributes().get(Event.HTTP_REQUEST_ATTRIBUTE); if (httpServletRequest == null) { return EventService.NO_CHANGE; } String requestParameterName = (String) action.getParameterValues().get("requestParameterName"); String profilePropertyName = (String) action.getParameterValues().get("profilePropertyName"); String sessionPropertyName = (String) action.getParameterValues().get("sessionPropertyName"); String requestParameterValue = httpServletRequest.getParameter(requestParameterName); if (requestParameterValue != null) { if (profilePropertyName != null) { if (event.getProfile().getProperty(profilePropertyName) == null || !event.getProfile().getProperty(profilePropertyName).equals(requestParameterValue)) { event.getProfile().setProperty(profilePropertyName, requestParameterValue); return EventService.PROFILE_UPDATED; } } else if (sessionPropertyName != null) { if (event.getSession().getProperty(sessionPropertyName) == null || !event.getSession().getProperty(sessionPropertyName).equals(requestParameterValue)) { event.getSession().setProperty(sessionPropertyName, requestParameterValue); return EventService.SESSION_UPDATED; } } } return EventService.NO_CHANGE; } }