public int execute()

in plugins/baseplugin/src/main/java/org/apache/unomi/plugins/baseplugin/actions/CopyPropertiesAction.java [46:83]


    public int execute(Action action, Event event) {
        boolean atLeastOnechanged = false;
        List<String> mandatoryPropTypeSystemTags = (List<String>) action.getParameterValues().get("mandatoryPropTypeSystemTag");
        String singleValueStrategy = (String) action.getParameterValues().get("singleValueStrategy");
        for (Map.Entry<String, Object> entry : getEventPropsToCopy(action, event).entrySet()) {
            String mappedProperty = resolvePropertyName(entry.getKey());

            // propType Check
            PropertyType propertyType = profileService.getPropertyType(mappedProperty);
            Object previousValue = event.getProfile().getProperty(mappedProperty);
            if (mandatoryPropTypeSystemTags != null && mandatoryPropTypeSystemTags.size() > 0) {
                if (propertyType == null || propertyType.getMetadata() == null || propertyType.getMetadata().getSystemTags() == null
                        || !propertyType.getMetadata().getSystemTags().containsAll(mandatoryPropTypeSystemTags)) {
                    continue;
                }
            }
            String propertyName = "properties." + mappedProperty;
            boolean changed = false;
            if (previousValue == null && propertyType == null) {
                changed = PropertyHelper.setProperty(event.getProfile(), propertyName, entry.getValue(), "alwaysSet");
            } else {
                boolean propertyTypeIsMultiValued =
                        propertyType != null && propertyType.isMultivalued() != null && propertyType.isMultivalued();
                boolean multipleIsExpected = previousValue != null ? previousValue instanceof List : propertyTypeIsMultiValued;

                if (multipleIsExpected) {
                    changed = PropertyHelper.setProperty(event.getProfile(), propertyName, entry.getValue(), "addValues");
                } else if (entry.getValue() instanceof List) {
                    LOGGER.error("Impossible to copy the property of type List to the profile, either a single value already exist on the profile or the property type is declared as a single value property. Enable debug log level for more information");
                    LOGGER.debug("cannot copy property {}, because it's a List", mappedProperty);
                } else {
                    changed = PropertyHelper.setProperty(event.getProfile(), propertyName, entry.getValue(), singleValueStrategy);
                }
            }
            atLeastOnechanged = atLeastOnechanged || changed;
        }
        return atLeastOnechanged ? EventService.PROFILE_UPDATED : EventService.NO_CHANGE;
    }