@Override public List<GraphObject> getProperty( SecurityContext securityContext, GraphObject obj, boolean applyConverter, Predicate<GraphObject> predicate) { if (obj instanceof AbstractNode) { try { final String query = Scripting.replaceVariables(new ActionContext(securityContext), obj, this.format); final Map<String, Object> parameters = new LinkedHashMap<>(); parameters.put("id", obj.getUuid()); parameters.put("type", obj.getType()); return StructrApp.getInstance(securityContext) .command(CypherQueryCommand.class) .execute(query, parameters); } catch (Throwable t) { t.printStackTrace(); } } return null; }
public Object transformOutput(final ActionContext actionContext, final GraphObject source) throws FrameworkException { if (outputFunction == null) { return source.getProperty(sourceProperty); } // output transformation requested actionContext.setConstant("input", source); return Scripting.evaluate(actionContext, null, "${" + outputFunction + "}"); }
public void transformInput(final ActionContext actionContext, final Map<String, Object> source) throws FrameworkException { // move / rename input value Object inputValue = source.remove(targetName); if (inputValue != null) { if (inputFunction != null) { // input transformation requested actionContext.setConstant("input", inputValue); inputValue = Scripting.evaluate(actionContext, null, "${" + inputFunction + "}"); } source.put(sourceName, inputValue); } }
public static Object execute( final SecurityContext securityContext, final GraphObject entity, final String source, final Map<String, Object> parameters) throws FrameworkException { final ActionContext context = new ActionContext(securityContext, parameters); final Object result = Scripting.evaluate(context, entity, source); // check for errors raised by scripting if (context.hasError()) { throw new FrameworkException(422, "Server-side scripting error", context.getErrorBuffer()); } return result; }