public Object execute() throws Exception { Rule rule = rulesService.getRule(ruleIdentifier); if (rule == null) { System.out.println("Couldn't find a rule with id=" + ruleIdentifier); return null; } String jsonRule = CustomObjectMapper.getObjectMapper().writerWithDefaultPrettyPrinter().writeValueAsString(rule); System.out.println(jsonRule); return null; } }
public CustomObjectMapper() { super(); super.registerModule(new JaxbAnnotationModule()); configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false); ISO8601DateFormat dateFormat = new ISO8601DateFormat(); dateFormat.setTimeZone(TimeZone.getTimeZone("UTC")); setDateFormat(dateFormat); SimpleModule deserializerModule = new SimpleModule("PropertyTypedObjectDeserializerModule",
public CustomObjectMapper() { super(); super.registerModule(new JaxbAnnotationModule()); configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false); ISO8601DateFormat dateFormat = new ISO8601DateFormat(); dateFormat.setTimeZone(TimeZone.getTimeZone("UTC")); setDateFormat(dateFormat); SimpleModule deserializerModule = new SimpleModule("PropertyTypedObjectDeserializerModule",
public Object execute() throws Exception { ConditionType conditionType = definitionsService.getConditionType(conditionTypeIdentifier); if (conditionType == null) { System.out.println("Couldn't find an action with id=" + conditionTypeIdentifier); return null; } String jsonRule = CustomObjectMapper.getObjectMapper().writerWithDefaultPrettyPrinter().writeValueAsString(conditionType); System.out.println(jsonRule); return null; }
public Object execute() throws Exception { ActionType actionType = definitionsService.getActionType(actionTypeIdentifier); if (actionType == null) { System.out.println("Couldn't find an action with id=" + actionTypeIdentifier); return null; } String jsonRule = CustomObjectMapper.getObjectMapper().writerWithDefaultPrettyPrinter().writeValueAsString(actionType); System.out.println(jsonRule); return null; } }
@Override protected Object doExecute() throws Exception { ActionType actionType = definitionsService.getActionType(actionTypeIdentifier); if (actionType == null) { System.out.println("Couldn't find an action with id=" + actionTypeIdentifier); return null; } String jsonRule = CustomObjectMapper.getObjectMapper().writerWithDefaultPrettyPrinter().writeValueAsString(actionType); System.out.println(jsonRule); return null; } }
@Override protected Object doExecute() throws Exception { Rule rule = rulesService.getRule(ruleIdentifier); if (rule == null) { System.out.println("Couldn't find a rule with id=" + ruleIdentifier); return null; } String jsonRule = CustomObjectMapper.getObjectMapper().writerWithDefaultPrettyPrinter().writeValueAsString(rule); System.out.println(jsonRule); return null; } }
public Object execute() throws Exception { Profile profile = profileService.load(profileIdentifier); if (profile == null) { System.out.println("Couldn't find a profile with id=" + profileIdentifier); return null; } String jsonProfile = CustomObjectMapper.getObjectMapper().writerWithDefaultPrettyPrinter().writeValueAsString(profile); System.out.println(jsonProfile); return null; } }
@Override protected Object doExecute() throws Exception { Segment segment = segmentService.getSegmentDefinition(segmentIdentifier); if (segment == null) { System.out.println("Couldn't find an action with id=" + segmentIdentifier); return null; } String jsonRule = CustomObjectMapper.getObjectMapper().writerWithDefaultPrettyPrinter().writeValueAsString(segment); System.out.println(jsonRule); return null; } }
public Object execute() throws Exception { Session session = profileService.loadSession(sessionIdentifier, null); if (session == null) { System.out.println("Couldn't find a session with id=" + sessionIdentifier); return null; } String jsonSession = CustomObjectMapper.getObjectMapper().writerWithDefaultPrettyPrinter().writeValueAsString(session); System.out.println(jsonSession); return null; } }
public Object execute() throws Exception { Segment segment = segmentService.getSegmentDefinition(segmentIdentifier); if (segment == null) { System.out.println("Couldn't find an action with id=" + segmentIdentifier); return null; } String jsonRule = CustomObjectMapper.getObjectMapper().writerWithDefaultPrettyPrinter().writeValueAsString(segment); System.out.println(jsonRule); return null; } }
public String getGeneratedPropertyKey(Condition condition, Condition parentCondition) { try { Map<String, Object> m = new HashMap<>(); m.put("condition", condition); m.put("numberOfDays", parentCondition.getParameter("numberOfDays")); String key = CustomObjectMapper.getObjectMapper().writeValueAsString(m); return "eventTriggered" + getMD5(key); } catch (JsonProcessingException e) { logger.error("Cannot generate key",e); return null; } }
/** * Retrieves an export of profiles matching the specified query as a downloadable file using the comma-separated values (CSV) format. * * @param query a String JSON representation of the query the profiles to export should match * @return a Response object configured to allow caller to download the CSV export file */ @GET @Path("/export") @Produces("text/csv") public Response getExportProfiles(@QueryParam("query") String query) { try { return exportProfiles(CustomObjectMapper.getObjectMapper().readValue(query, Query.class)); } catch (IOException e) { logger.error(e.getMessage(), e); return Response.serverError().build(); } }
/** * A version of {@link #getExportProfiles(String)} suitable to be called from an HTML form. * * @param query a form-encoded representation of the query the profiles to export should match * @return a Response object configured to allow caller to download the CSV export file */ @GET @Path("/export") @Produces("text/csv") @Consumes(MediaType.APPLICATION_FORM_URLENCODED) public Response formExportProfiles(@FormParam("query") String query) { try { return exportProfiles(CustomObjectMapper.getObjectMapper().readValue(query, Query.class)); } catch (IOException e) { logger.error(e.getMessage(), e); return Response.serverError().build(); } }
private void loadPredefinedPropertyMergeStrategies(BundleContext bundleContext) { Enumeration<URL> predefinedPropertyMergeStrategyEntries = bundleContext.getBundle().findEntries("META-INF/cxs/mergers", "*.json", true); if (predefinedPropertyMergeStrategyEntries == null) { return; } ArrayList<PluginType> pluginTypeArrayList = (ArrayList<PluginType>) pluginTypes.get(bundleContext.getBundle().getBundleId()); while (predefinedPropertyMergeStrategyEntries.hasMoreElements()) { URL predefinedPropertyMergeStrategyURL = predefinedPropertyMergeStrategyEntries.nextElement(); logger.debug("Found predefined property merge strategy type at " + predefinedPropertyMergeStrategyURL + ", loading... "); try { PropertyMergeStrategyType propertyMergeStrategyType = CustomObjectMapper.getObjectMapper().readValue(predefinedPropertyMergeStrategyURL, PropertyMergeStrategyType.class); propertyMergeStrategyType.setPluginId(bundleContext.getBundle().getBundleId()); propertyMergeStrategyTypeById.put(propertyMergeStrategyType.getId(), propertyMergeStrategyType); pluginTypeArrayList.add(propertyMergeStrategyType); } catch (Exception e) { logger.error("Error while loading property type definition " + predefinedPropertyMergeStrategyURL, e); } } }
private void loadPredefinedPropertyMergeStrategies(BundleContext bundleContext) { Enumeration<URL> predefinedPropertyMergeStrategyEntries = bundleContext.getBundle().findEntries("META-INF/cxs/mergers", "*.json", true); if (predefinedPropertyMergeStrategyEntries == null) { return; } ArrayList<PluginType> pluginTypeArrayList = (ArrayList<PluginType>) pluginTypes.get(bundleContext.getBundle().getBundleId()); while (predefinedPropertyMergeStrategyEntries.hasMoreElements()) { URL predefinedPropertyMergeStrategyURL = predefinedPropertyMergeStrategyEntries.nextElement(); logger.debug("Found predefined property merge strategy type at " + predefinedPropertyMergeStrategyURL + ", loading... "); try { PropertyMergeStrategyType propertyMergeStrategyType = CustomObjectMapper.getObjectMapper().readValue(predefinedPropertyMergeStrategyURL, PropertyMergeStrategyType.class); propertyMergeStrategyType.setPluginId(bundleContext.getBundle().getBundleId()); propertyMergeStrategyTypeById.put(propertyMergeStrategyType.getId(), propertyMergeStrategyType); pluginTypeArrayList.add(propertyMergeStrategyType); } catch (Exception e) { logger.error("Error while loading property type definition " + predefinedPropertyMergeStrategyURL, e); } } }
@Override protected Object doExecute() throws Exception { Metric metric = metricsService.getMetrics().get(metricName); if (metric == null) { System.out.println("Couldn't find a metric with name=" + metricName); return null; } // by default pretty printer will use spaces between array values, we change this to linefeeds to make // the caller values easier to read. DefaultPrettyPrinter defaultPrettyPrinter = new DefaultPrettyPrinter(); defaultPrettyPrinter = defaultPrettyPrinter.withArrayIndenter(DefaultIndenter.SYSTEM_LINEFEED_INSTANCE); String jsonMetric = CustomObjectMapper.getObjectMapper().writer(defaultPrettyPrinter).writeValueAsString(metric); System.out.println(jsonMetric); return null; } }
@Override protected Object doExecute() throws Exception { Metric metric = metricsService.getMetrics().get(metricName); if (metric == null) { System.out.println("Couldn't find a metric with name=" + metricName); return null; } // by default pretty printer will use spaces between array values, we change this to linefeeds to make // the caller values easier to read. DefaultPrettyPrinter defaultPrettyPrinter = new DefaultPrettyPrinter(); defaultPrettyPrinter = defaultPrettyPrinter.withArrayIndenter(DefaultIndenter.SYSTEM_LINEFEED_INSTANCE); String jsonMetric = CustomObjectMapper.getObjectMapper().writer(defaultPrettyPrinter).writeValueAsString(metric); System.out.println(jsonMetric); return null; } }
switch (definitionType) { case "condition": ConditionType conditionType = CustomObjectMapper.getObjectMapper().readValue(definitionURL, ConditionType.class); definitionsService.setConditionType(conditionType); break; case "action": ActionType actionType = CustomObjectMapper.getObjectMapper().readValue(definitionURL, ActionType.class); definitionsService.setActionType(actionType); break; case "goal": Goal goal = CustomObjectMapper.getObjectMapper().readValue(definitionURL, Goal.class); goalsService.setGoal(goal); break; case "campaign": Campaign campaign = CustomObjectMapper.getObjectMapper().readValue(definitionURL, Campaign.class); goalsService.setCampaign(campaign); break; case "persona": Persona persona = CustomObjectMapper.getObjectMapper().readValue(definitionURL, Persona.class); profileService.savePersona(persona); break; case "persona with session": PersonaWithSessions personaWithSessions = CustomObjectMapper.getObjectMapper().readValue(definitionURL, PersonaWithSessions.class); profileService.savePersonaWithSessions(personaWithSessions); break; case "property": PropertyType propertyType = CustomObjectMapper.getObjectMapper().readValue(definitionURL, PropertyType.class); profileService.setPropertyTypeTarget(definitionURL, propertyType); profileService.setPropertyType(propertyType);
ConditionType conditionType = CustomObjectMapper.getObjectMapper().readValue(definitionURL, ConditionType.class); definitionsService.setConditionType(conditionType); break; case "action": ActionType actionType = CustomObjectMapper.getObjectMapper().readValue(definitionURL, ActionType.class); definitionsService.setActionType(actionType); break; case "goal": Goal goal = CustomObjectMapper.getObjectMapper().readValue(definitionURL, Goal.class); goalsService.setGoal(goal); break; case "campaign": Campaign campaign = CustomObjectMapper.getObjectMapper().readValue(definitionURL, Campaign.class); goalsService.setCampaign(campaign); break; case "persona": PersonaWithSessions persona = CustomObjectMapper.getObjectMapper().readValue(definitionURL, PersonaWithSessions.class); profileService.savePersonaWithSessions(persona); break; case "property": PropertyType propertyType = CustomObjectMapper.getObjectMapper().readValue(definitionURL, PropertyType.class); profileService.setPropertyTypeTarget(definitionURL, propertyType); profileService.setPropertyType(propertyType); break; case "rule": Rule rule = CustomObjectMapper.getObjectMapper().readValue(definitionURL, Rule.class); rulesService.setRule(rule); break; case "segment":