use of org.structr.core.function.XmlFunction in project structr by structr.
the class CoreModule method onLoad.
@Override
public void onLoad(final LicenseManager licenseManager) {
final boolean licensed = licenseManager == null || licenseManager.isEdition(LicenseManager.Basic);
// Basic Edition
Functions.put(licensed, LicenseManager.Basic, "error", new ErrorFunction());
Functions.put(licensed, LicenseManager.Basic, "config", new ConfigFunction());
Functions.put(licensed, LicenseManager.Basic, "changelog", new ChangelogFunction());
Functions.put(licensed, LicenseManager.Basic, "serverlog", new ServerLogFunction());
Functions.put(licensed, LicenseManager.Basic, "grant", new GrantFunction());
Functions.put(licensed, LicenseManager.Basic, "revoke", new RevokeFunction());
Functions.put(licensed, LicenseManager.Basic, "is_allowed", new IsAllowedFunction());
Functions.put(licensed, LicenseManager.Basic, "add_to_group", new AddToGroupFunction());
Functions.put(licensed, LicenseManager.Basic, "remove_from_group", new RemoveFromGroupFunction());
Functions.put(licensed, LicenseManager.Basic, "is_in_group", new IsInGroupFunction());
Functions.put(licensed, LicenseManager.Basic, "localize", new LocalizeFunction());
Functions.put(licensed, LicenseManager.Basic, "call", new CallFunction());
Functions.put(licensed, LicenseManager.Basic, "call_privileged", new CallPrivilegedFunction());
Functions.put(licensed, LicenseManager.Basic, "exec", new ExecFunction());
Functions.put(licensed, LicenseManager.Basic, "exec_binary", new ExecBinaryFunction());
Functions.put(licensed, LicenseManager.Basic, "unlock_readonly_properties_once", new UnlockReadonlyPropertiesFunction());
Functions.put(licensed, LicenseManager.Basic, "unlock_system_properties_once", new UnlockSystemPropertiesFunction());
Functions.put(licensed, LicenseManager.Basic, "set_privileged", new SetPrivilegedFunction());
Functions.put(licensed, LicenseManager.Basic, "find_privileged", new PrivilegedFindFunction());
Functions.put(licensed, LicenseManager.Basic, "read", new ReadFunction());
Functions.put(licensed, LicenseManager.Basic, "write", new WriteFunction());
Functions.put(licensed, LicenseManager.Basic, "append", new AppendFunction());
Functions.put(licensed, LicenseManager.Basic, "xml", new XmlFunction());
Functions.put(licensed, LicenseManager.Basic, "xpath", new XPathFunction());
Functions.put(licensed, LicenseManager.Basic, "geocode", new GeocodeFunction());
Functions.put(licensed, LicenseManager.Basic, "instantiate", new InstantiateFunction());
Functions.put(licensed, LicenseManager.Basic, "property_info", new PropertyInfoFunction());
Functions.put(licensed, LicenseManager.Basic, "type_info", new TypeInfoFunction());
Functions.put(licensed, LicenseManager.Basic, "enum_info", new EnumInfoFunction());
Functions.put(licensed, LicenseManager.Basic, "disable_notifications", new DisableNotificationsFunction());
Functions.put(licensed, LicenseManager.Basic, "enable_notifications", new EnableNotificationsFunction());
Functions.put(licensed, LicenseManager.Basic, "r", new RInterpreterFunction());
Functions.put(licensed, LicenseManager.Basic, "evaluate_script", new EvaluateScriptFunction());
Functions.put(licensed, LicenseManager.Basic, "ancestor_types", new AncestorTypesFunction());
Functions.put(licensed, LicenseManager.Basic, "inheriting_types", new InheritingTypesFunction());
Functions.put(licensed, LicenseManager.Basic, "template", new TemplateFunction());
Functions.put(licensed, LicenseManager.Basic, "jdbc", new JdbcFunction());
// Community Edition
Functions.put(true, LicenseManager.Community, "cypher", new CypherFunction());
Functions.put(true, LicenseManager.Community, "md5", new MD5Function());
Functions.put(true, LicenseManager.Community, "upper", new UpperFunction());
Functions.put(true, LicenseManager.Community, "lower", new LowerFunction());
Functions.put(true, LicenseManager.Community, "join", new JoinFunction());
Functions.put(true, LicenseManager.Community, "concat", new ConcatFunction());
Functions.put(true, LicenseManager.Community, "split", new SplitFunction());
Functions.put(true, LicenseManager.Community, "split_regex", new SplitRegexFunction());
Functions.put(true, LicenseManager.Community, "abbr", new AbbrFunction());
Functions.put(true, LicenseManager.Community, "capitalize", new CapitalizeFunction());
Functions.put(true, LicenseManager.Community, "titleize", new TitleizeFunction());
Functions.put(true, LicenseManager.Community, "num", new NumFunction());
Functions.put(true, LicenseManager.Community, "int", new IntFunction());
Functions.put(true, LicenseManager.Community, "random", new RandomFunction());
Functions.put(true, LicenseManager.Community, "rint", new RintFunction());
Functions.put(true, LicenseManager.Community, "index_of", new IndexOfFunction());
Functions.put(true, LicenseManager.Community, "contains", new ContainsFunction());
Functions.put(true, LicenseManager.Community, "copy_permissions", new CopyPermissionsFunction());
Functions.put(true, LicenseManager.Community, "substring", new SubstringFunction());
Functions.put(true, LicenseManager.Community, "length", new LengthFunction());
Functions.put(true, LicenseManager.Community, "replace", new ReplaceFunction());
Functions.put(true, LicenseManager.Community, "trim", new TrimFunction());
Functions.put(true, LicenseManager.Community, "clean", new CleanFunction());
Functions.put(true, LicenseManager.Community, "coalesce", new CoalesceFunction());
Functions.put(true, LicenseManager.Community, "urlencode", new UrlEncodeFunction());
Functions.put(true, LicenseManager.Community, "escape_javascript", new EscapeJavascriptFunction());
Functions.put(true, LicenseManager.Community, "escape_json", new EscapeJsonFunction());
Functions.put(true, LicenseManager.Community, "empty", new EmptyFunction());
Functions.put(true, LicenseManager.Community, "equal", new EqualFunction());
Functions.put(true, LicenseManager.Community, "eq", new EqualFunction());
Functions.put(true, LicenseManager.Community, "add", new AddFunction());
Functions.put(true, LicenseManager.Community, "double_sum", new DoubleSumFunction());
Functions.put(true, LicenseManager.Community, "int_sum", new IntSumFunction());
Functions.put(true, LicenseManager.Community, "is_collection", new IsCollectionFunction());
Functions.put(true, LicenseManager.Community, "is_entity", new IsEntityFunction());
Functions.put(true, LicenseManager.Community, "extract", new ExtractFunction());
Functions.put(true, LicenseManager.Community, "merge", new MergeFunction());
Functions.put(true, LicenseManager.Community, "merge_unique", new MergeUniqueFunction());
Functions.put(true, LicenseManager.Community, "complement", new ComplementFunction());
Functions.put(true, LicenseManager.Community, "unwind", new UnwindFunction());
Functions.put(true, LicenseManager.Community, "sort", new SortFunction());
Functions.put(true, LicenseManager.Community, "lt", new LtFunction());
Functions.put(true, LicenseManager.Community, "gt", new GtFunction());
Functions.put(true, LicenseManager.Community, "lte", new LteFunction());
Functions.put(true, LicenseManager.Community, "gte", new GteFunction());
Functions.put(true, LicenseManager.Community, "subt", new SubtFunction());
Functions.put(true, LicenseManager.Community, "mult", new MultFunction());
Functions.put(true, LicenseManager.Community, "quot", new QuotFunction());
Functions.put(true, LicenseManager.Community, "div", new DivFunction());
Functions.put(true, LicenseManager.Community, "mod", new ModFunction());
Functions.put(true, LicenseManager.Community, "floor", new FloorFunction());
Functions.put(true, LicenseManager.Community, "ceil", new CeilFunction());
Functions.put(true, LicenseManager.Community, "round", new RoundFunction());
Functions.put(true, LicenseManager.Community, "max", new MaxFunction());
Functions.put(true, LicenseManager.Community, "min", new MinFunction());
Functions.put(true, LicenseManager.Community, "date_format", new DateFormatFunction());
Functions.put(true, LicenseManager.Community, "parse_date", new ParseDateFunction());
Functions.put(true, LicenseManager.Community, "to_date", new ToDateFunction());
Functions.put(true, LicenseManager.Community, "number_format", new NumberFormatFunction());
Functions.put(true, LicenseManager.Community, "parse_number", new ParseNumberFunction());
Functions.put(true, LicenseManager.Community, "not", new NotFunction());
Functions.put(true, LicenseManager.Community, "and", new AndFunction());
Functions.put(true, LicenseManager.Community, "or", new OrFunction());
Functions.put(true, LicenseManager.Community, "get", new GetFunction());
Functions.put(true, LicenseManager.Community, "get_or_null", new GetOrNullFunction());
Functions.put(true, LicenseManager.Community, "size", new SizeFunction());
Functions.put(true, LicenseManager.Community, "first", new FirstFunction());
Functions.put(true, LicenseManager.Community, "last", new LastFunction());
Functions.put(true, LicenseManager.Community, "nth", new NthFunction());
Functions.put(true, LicenseManager.Community, "get_counter", new GetCounterFunction());
Functions.put(true, LicenseManager.Community, "inc_counter", new IncCounterFunction());
Functions.put(true, LicenseManager.Community, "reset_counter", new ResetCounterFunction());
Functions.put(true, LicenseManager.Community, "merge_properties", new MergePropertiesFunction());
Functions.put(true, LicenseManager.Community, "keys", new KeysFunction());
Functions.put(true, LicenseManager.Community, "values", new ValuesFunction());
Functions.put(true, LicenseManager.Community, "timer", new TimerFunction());
Functions.put(true, LicenseManager.Community, "str_replace", new StrReplaceFunction());
Functions.put(true, LicenseManager.Community, "search", new SearchFunction());
Functions.put(true, LicenseManager.Community, "incoming", new IncomingFunction());
Functions.put(true, LicenseManager.Community, "outgoing", new OutgoingFunction());
Functions.put(true, LicenseManager.Community, "has_relationship", new HasRelationshipFunction());
Functions.put(true, LicenseManager.Community, "has_outgoing_relationship", new HasOutgoingRelationshipFunction());
Functions.put(true, LicenseManager.Community, "has_incoming_relationship", new HasIncomingRelationshipFunction());
Functions.put(true, LicenseManager.Community, "get_relationships", new GetRelationshipsFunction());
Functions.put(true, LicenseManager.Community, "get_outgoing_relationships", new GetOutgoingRelationshipsFunction());
Functions.put(true, LicenseManager.Community, "get_incoming_relationships", new GetIncomingRelationshipsFunction());
Functions.put(true, LicenseManager.Community, "retrieve", new RetrieveFunction());
Functions.put(true, LicenseManager.Community, "store", new StoreFunction());
Functions.put(true, LicenseManager.Community, "print", new PrintFunction());
Functions.put(true, LicenseManager.Community, "log", new LogFunction());
Functions.put(true, LicenseManager.Community, "find", new FindFunction());
Functions.put(true, LicenseManager.Community, "get_or_create", new GetOrCreateFunction());
Functions.put(true, LicenseManager.Community, "find_relationship", new FindRelationshipFunction());
Functions.put(true, LicenseManager.Community, "starts_with", new StartsWithFunction());
Functions.put(true, LicenseManager.Community, "ends_with", new EndsWithFunction());
Functions.put(true, LicenseManager.Community, "base64encode", new Base64EncodeFunction());
Functions.put(true, LicenseManager.Community, "base64decode", new Base64DecodeFunction());
// ----- BEGIN functions with side effects -----
Functions.put(true, LicenseManager.Community, "set", new SetFunction());
Functions.put(true, LicenseManager.Community, "create", new CreateFunction());
Functions.put(true, LicenseManager.Community, "delete", new DeleteFunction());
Functions.put(true, LicenseManager.Community, "create_relationship", new CreateRelationshipFunction());
}
use of org.structr.core.function.XmlFunction in project structr by structr.
the class FromXmlFunction method apply.
@Override
public Object apply(final ActionContext ctx, final Object caller, Object[] sources) throws FrameworkException {
if (sources != null && sources.length > 0) {
if (sources[0] == null) {
return "";
}
try {
final GraphObjectMap result = new GraphObjectMap();
final XmlFunction xml = new XmlFunction();
final Document document = (Document) xml.apply(ctx, caller, sources);
if (document != null) {
convertNode(result, document);
return result;
} else {
logger.warn("Unable to parse XML document: {}", sources[0].toString());
}
} catch (Throwable t) {
logException(caller, t, sources);
}
return "";
} else {
logParameterError(caller, sources, ctx.isJavaScriptContext());
}
return usage(ctx.isJavaScriptContext());
}
use of org.structr.core.function.XmlFunction in project structr by structr.
the class ImportGPXFunction method apply.
@Override
public Object apply(final ActionContext ctx, final Object caller, final Object[] sources) throws FrameworkException {
if (arrayHasLengthAndAllElementsNotNull(sources, 1)) {
if (sources[0] instanceof String) {
final String source = (String) sources[0];
if (source != null) {
// parse source, create a list of points
final GraphObjectMap result = new GraphObjectMap();
final XmlFunction xmlParser = new XmlFunction();
final Document doc = (Document) xmlParser.apply(ctx, caller, sources);
final List<GraphObjectMap> waypoints = new LinkedList<>();
final List<GraphObjectMap> routes = new LinkedList<>();
final List<GraphObjectMap> tracks = new LinkedList<>();
if (doc != null) {
final Element root = doc.getDocumentElement();
final List<Element> children = getChildren(root);
for (final Element child : children) {
switch(child.getTagName()) {
case "metadata":
final GraphObjectMap metadata = readPoint(child);
if (metadata != null) {
result.put(metadataProperty, metadata);
}
break;
case "rte":
readRoute(child, routes);
break;
case "wpt":
readWaypoint(child, waypoints);
break;
case "trk":
readTrack(child, tracks);
break;
}
}
if (!waypoints.isEmpty()) {
result.put(waypointsProperty, waypoints);
}
if (!routes.isEmpty()) {
result.put(routesProperty, routes);
}
if (!tracks.isEmpty()) {
result.put(tracksProperty, tracks);
}
}
return result;
}
} else {
logger.warn("Invalid parameter for GPX import, expected string, got {}", sources[0].getClass().getSimpleName());
}
return "Invalid parameters";
}
return usage(ctx != null ? ctx.isJavaScriptContext() : false);
}
Aggregations