/** * Add multiple values in a classical JavaLite style. * * @param namesAndValues names and values (must pass even number). */ public static void put(String... namesAndValues) { contextTL.get().putAll(map(namesAndValues)); }
public Map<String, Object> toMap() { return map(CLASS, getClass().getName(), SOURCE, source.getName(), TARGET, target.getName()); }
protected String toJSON() { List models = new ArrayList(); metaModelsByTableName.values().forEach(metaModel -> { List associations = new ArrayList(); metaModel.getAssociations().forEach(association -> associations.add(association.toMap())); models.add(map( MODEL_CLASS, metaModel.getModelClass().getName(), DB_TYPE, metaModel.getDbType(), DB_NAME, metaModel.getDbName(), COLUMN_METADATA, metaModel.getColumnMetadata(), ASSOCIATIONS, associations )); }); return JsonHelper.toJsonString(models,false); }
((Map) metaModelMap.getOrDefault(COLUMN_METADATA, map())).forEach((column, map) -> { Map metadata = (Map) map; columnMetadataMap.put(
/** * Add multiple values in a classical JavaLite style. * * @param namesAndValues names and values (must pass even number). */ public static void put(String... namesAndValues) { contextTL.get().putAll(map(namesAndValues)); }
/** * Convenience method for {@link #redirect(Class, java.util.Map)}. * * @param controllerClass controller class where to send redirect. * @param id id to redirect to. * @return {@link HttpSupport.HttpBuilder}, to accept additional information. */ protected <T extends AppController> HttpBuilder redirect(Class<T> controllerClass, Object id){ return redirect(controllerClass, map("id", id)); }
/** * Convenience method to pass multiple names and corresponding values to a view. * * @param values - pairs of names and values. such as: name1, value1, name2, value2, etc. Number of arguments must be even. */ protected void view(Object ... values){ view(map(values)); }
/** * Renders a template by name. * * @param templateName name of template to render * @param namesAndValues - list of names and values, where first, third, etc argument is a name and second, * fourth, etc. argument is a corresponding value. * @return rendered template content as string */ protected String render(String templateName, String ... namesAndValues) { return render(templateName, map(namesAndValues)); }
/** * Convenience method for {@link #redirect(Class, java.util.Map)}. * * @param controllerClass controller class where to send redirect. * @param action action to redirect to. * @param id id to redirect to. * @return {@link HttpSupport.HttpBuilder}, to accept additional information. */ protected <T extends AppController> HttpBuilder redirect(Class<T> controllerClass, String action, Object id){ return redirect(controllerClass, map("action", action, "id", id)); }
/** * Flash method to display multiple flash messages. * Takes in a vararg of values for flash. Number of arguments must be even. * Format: name, value, name, value, etc. * * @see #flash(String, Object) * @param values values to flash. */ protected void flash(Object ... values){ flash(map(values)); }
/** * Convenience method for {@link #redirect(Class, java.util.Map)}. * * @param controllerClass controller class where to send redirect. * @param action action to redirect to. * @return {@link HttpSupport.HttpBuilder}, to accept additional information. */ protected <T extends AppController> HttpBuilder redirect(Class<T> controllerClass, String action){ return redirect(controllerClass, map("action", action)); }
private static void copyRequestProperties(Map assigns) { assigns.put("request_props", map("url", RequestContext.getHttpRequest().getRequestURL().toString())); } }
private Map getMapWithExceptionDataAndSession(Throwable e) { return map("message", e.getMessage() == null ? e.toString() : e.getMessage(), "stack_trace", Util.getStackTraceString(e), "session", SessionHelper.getSessionAttributes()); }
/** * Call this method once after a constructor in order to create a Netty instance to accept out of VM messages. * * @param host host to bind to * @param port port to listen on */ public void configureNetty(String host, int port){ Map<String, Object> params = map(TransportConstants.HOST_PROP_NAME, host, TransportConstants.PORT_PROP_NAME, port); config.getAcceptorConfigurations().add(new TransportConfiguration(NettyAcceptorFactory.class.getName(), params)); }
/** * Call this method once after a constructor in order to create a Netty instance to accept out of VM messages. * * @param host host to bind to * @param port port to listen on */ public void configureNetty(String host, int port){ Map<String, Object> params = map(TransportConstants.HOST_PROP_NAME, host, TransportConstants.PORT_PROP_NAME, port); config.getAcceptorConfigurations().add(new TransportConfiguration(NettyAcceptorFactory.class.getName(), params)); }
private static void insertActiveWebParamsInto(Map assigns) { assigns.put("context_path", RequestContext.getHttpRequest().getContextPath()); //in some cases the Route is missing - for example, when exception happened before Router was invoked. Route route = RequestContext.getRoute(); Map params = map("environment", Configuration.getEnv()); if(route != null){ params.put("controller", RequestContext.getRoute().getControllerPath()); params.put("action", RequestContext.getRoute().getActionName()); params.put("restful", RequestContext.getRoute().getController().restful()); } assigns.put("activeweb", params); }
@Override public void onMessage(Message message) { Context.clear(); try { Command command = parseCommand(message); command.setJMSMessageID(message.getJMSMessageID()); if (injector != null) { injector.injectMembers(command); } long start = System.currentTimeMillis(); onCommand(command); LOGGER.info(JsonHelper.toJsonString(map("processed_millis", (System.currentTimeMillis() - start), "command", command.getClass().getSimpleName()))); } catch (Exception e) { LOGGER.error("Failed to process message: {}", getCommandAsText(message), e); throw new AsyncException("Failed to process message", e); }finally { Context.clear(); } }
@Override public void onMessage(Message message) { Context.clear(); try { Command command = parseCommand(message); command.setJMSMessageID(message.getJMSMessageID()); if (injector != null) { injector.injectMembers(command); } long start = System.currentTimeMillis(); onCommand(command); LOGGER.info(JsonHelper.toJsonString(map("processed_millis", (System.currentTimeMillis() - start), "command", command.getClass().getSimpleName()))); } catch (Exception e) { LOGGER.error("Failed to process message: {}", getCommandAsText(message), e); throw new AsyncException("Failed to process message", e); }finally { Context.clear(); } }
@Override protected String getMessage() { Map m = map("request_url", url(), "context_path", context(), "query_string", queryString(), "uri_full_path", uri(), "uri_path", path(), "method", method()); return m.toString(); } }
Map<String, Object> log = map( "controller", controller, "action", action,