Search in sources :

Example 26 with SchemaNode

use of org.structr.core.entity.SchemaNode in project structr by structr.

the class GetTypeInfoCommand method processMessage.

@Override
public void processMessage(final WebSocketMessage webSocketData) {
    final String type = (String) webSocketData.getNodeData().get("type");
    if (type == null) {
        logger.warn("Node type given not found");
        getWebSocket().send(MessageBuilder.status().code(400).build(), true);
    }
    final SecurityContext securityContext = getWebSocket().getSecurityContext();
    final App app = StructrApp.getInstance(securityContext);
    final SchemaNode typeNode;
    try {
        typeNode = app.nodeQuery(SchemaNode.class).andName(type).getFirst();
        if (typeNode != null) {
            webSocketData.setResult(Arrays.asList(typeNode));
            // send only over local connection (no broadcast)
            getWebSocket().send(webSocketData, true);
        }
    } catch (FrameworkException ex) {
        logger.error("", ex);
        getWebSocket().send(MessageBuilder.status().code(500).build(), true);
    }
}
Also used : StructrApp(org.structr.core.app.StructrApp) App(org.structr.core.app.App) SchemaNode(org.structr.core.entity.SchemaNode) FrameworkException(org.structr.common.error.FrameworkException) SecurityContext(org.structr.common.SecurityContext)

Example 27 with SchemaNode

use of org.structr.core.entity.SchemaNode in project structr by structr.

the class StructrSchemaPath method getDirectoryStream.

@Override
public DirectoryStream<Path> getDirectoryStream(final DirectoryStream.Filter<? super Path> filter) {
    return new DirectoryStream() {

        boolean closed = false;

        @Override
        public Iterator iterator() {
            if (!closed) {
                final App app = StructrApp.getInstance(fs.getSecurityContext());
                final List<StructrPath> nodes = new LinkedList<>();
                try (final Tx tx = app.tx()) {
                    for (final SchemaNode schemaNode : app.nodeQuery(SchemaNode.class).getAsList()) {
                        nodes.add(new StructrSchemaNodePath(fs, StructrSchemaPath.this, schemaNode.getName()));
                    }
                    for (final SchemaRelationshipNode rel : app.nodeQuery(SchemaRelationshipNode.class).getAsList()) {
                        nodes.add(new StructrSchemaNodePath(fs, StructrSchemaPath.this, rel.getName()));
                    }
                    tx.success();
                } catch (FrameworkException fex) {
                    logger.warn("", fex);
                }
                return nodes.iterator();
            }
            return Collections.emptyIterator();
        }

        @Override
        public void close() throws IOException {
            closed = true;
        }
    };
}
Also used : StructrApp(org.structr.core.app.StructrApp) App(org.structr.core.app.App) SchemaNode(org.structr.core.entity.SchemaNode) Tx(org.structr.core.graph.Tx) FrameworkException(org.structr.common.error.FrameworkException) StructrPath(org.structr.files.ssh.filesystem.StructrPath) SchemaRelationshipNode(org.structr.core.entity.SchemaRelationshipNode) DirectoryStream(java.nio.file.DirectoryStream) LinkedList(java.util.LinkedList)

Example 28 with SchemaNode

use of org.structr.core.entity.SchemaNode in project structr by structr.

the class StructrConfigHtmlWriter method beginDocument.

@Override
public RestWriter beginDocument(final String baseUrl, final String propertyView) throws IOException {
    String currentType = baseUrl.replace(restPath + "/", "").replace("/" + propertyView, "");
    if (!propertyView.equals("public")) {
        this.propertyView = "/" + propertyView;
    }
    Tag head = doc.block("head");
    // head.empty("link").attr(new Rel("stylesheet"), new Type("text/css"), new Href("/structr/css/rest.css"));
    // head.inline("script").attr(new Type("text/javascript"), new Src("/structr/js/CollapsibleLists.js"));
    head.inline("style").attr(new Type("text/css")).text("body,html{font-family:\"Liberation Mono\",\"DejaVu Sans Mono\",Consolas,Monaco,\"Vera Sans Mono\",\"Lucida Console\",\"Courier New\",monospace!important;font-size:9pt;padding:0;margin:0}div#top{border-bottom:1px solid #a5a5a5;line-height:2em;background:#363636;background:-webkit-gradient(linear,left bottom,left top,from(#363636),to(#666)) no-repeat;background:-moz-linear-gradient(90deg,#363636,#666) no-repeat;filter:progid:DXImageTransform.Microsoft.Gradient(StartColorStr='#666666', EndColorStr='#363636', GradientType=0);padding:20px;font-family:Arial,Helvetica,Sans-serif}div#top a{color:#fff;text-decoration:none;font-weight:700;margin-right:1em}div#left{background-color:#eee;padding:10px 20px}div#left a{color:#666;text-decoration:none;font-weight:700;margin-right:1em}div#right{clear:both;padding-left:20px}ul{list-style-type:none}b{font-weight:700;color:#444}a.id,a.id:visited{color:#00a}span.type{font-weight:400;color:#080}span.id{font-weight:400;color:#999}span.name{font-weight:700;color:#666}span.string{color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Tk5OXl5ebm5ufn5+jo6Onp6erq6uvr6+zs7O3t7e7u7u/v7/Dw8PHx8fLy8vPz8/T09PX19fb29vf39/j4+Pn5+fr6+vv7+/z8/P39/f7+/v///yH5BAEKAP8ALAAAAAAHAAcAAAgXAP8JHEgwE0GBBgdmWriw4MF/CR8KDAgAOw==);cursor:pointer}.collapsibleList{cursor:default}button.collapse,button.expand{font-family:\"Liberation Mono\",\"DejaVu Sans Mono\",Consolas,Monaco,\"Vera Sans Mono\",\"Lucida Console\",\"Courier New\",monospace!important;float:right;margin:-.3em 1em 0 0}");
    head.inline("script").attr(new Type("text/javascript")).text("var CollapsibleLists=new function(){function g(b){return function(a){a||(a=window.event);for(a=a.target?a.target:a.srcElement;\"LI\"!=a.nodeName;)a=a.parentNode;a==b&&f(b)}}function f(b){for(var a=b.className.match(/(^| )collapsibleListClosed( |$)/),c=b.getElementsByTagName(\"ul\"),d=0;d<c.length;d++){for(var e=c[d];\"LI\"!=e.nodeName;)e=e.parentNode;e==b&&(c[d].style.display=a?\"block\":\"none\")}b.className=b.className.replace(/(^| )collapsibleList(Open|Closed)( |$)/,\"\");0<c.length&&(b.className+=\" collapsibleList\"+\n" + "(a?\"Open\":\"Closed\"))}this.apply=function(b){for(var a=document.getElementsByTagName(\"ul\"),c=0;c<a.length;c++)if(a[c].className.match(/(^| )collapsibleList( |$)/)&&(this.applyTo(a[c],!0),!b))for(var d=a[c].getElementsByTagName(\"ul\"),e=0;e<d.length;e++)d[e].className+=\" collapsibleList\"};this.applyTo=function(b,a){for(var c=b.getElementsByTagName(\"li\"),d=0;d<c.length;d++)a&&b!=c[d].parentNode||(c[d].addEventListener?c[d].addEventListener(\"click\",g(c[d]),!1):c[d].attachEvent(\"onclick\",g(c[d])),f(c[d]))};\n" + "this.openAll=function(){var b = [].slice.call(document.getElementsByClassName(\"collapsibleListClosed\")); [].forEach.call(b, function (el) { f(el); });};this.closeAll=function(){var b = [].slice.call(document.getElementsByClassName(\"collapsibleListOpen\")); [].forEach.call(b, function (el) { f(el); });}};");
    head.inline("title").text(baseUrl);
    Tag body = doc.block("body").attr(new Onload("if (document.querySelectorAll('#right > ul > li > ul > li > ul.collapsibleList > li').length > 5) { CollapsibleLists.apply(true); }"));
    Tag top = body.block("div").id("top");
    final App app = StructrApp.getInstance(securityContext);
    final Tag left = body.block("div").id("left");
    left.inline("button").attr(new Css("collapse right")).attr(new Attr("onclick", "CollapsibleLists.closeAll()")).text(" - ");
    left.inline("button").attr(new Css("expand right")).attr(new Attr("onclick", "CollapsibleLists.openAll()")).text(" + ");
    try (final Tx tx = app.tx()) {
        final List<SchemaNode> schemaNodes = app.nodeQuery(SchemaNode.class).getAsList();
        Collections.sort(schemaNodes);
        for (SchemaNode node : schemaNodes) {
            final String rawType = node.getName();
            top.inline("a").attr(new Href(restPath + "/" + rawType), new If(rawType.equals(currentType), new Css("active"))).text(rawType);
        }
    } catch (Throwable t) {
        logger.warn("", t);
    }
    for (String view : StructrApp.getConfiguration().getPropertyViews()) {
        if (!hiddenViews.contains(view)) {
            left.inline("a").attr(new Href(restPath + "/" + currentType + "/" + view), new If(view.equals(propertyView), new Css("active"))).text(view);
        }
    }
    // main div
    currentElement = body.block("div").id("right");
    // h1 title
    currentElement.block("h1").text(baseUrl);
    // begin ul
    currentElement = currentElement.block("ul");
    return this;
}
Also used : StructrApp(org.structr.core.app.StructrApp) App(org.structr.core.app.App) Css(org.structr.api.util.html.attr.Css) Tx(org.structr.core.graph.Tx) Href(org.structr.api.util.html.attr.Href) Onload(org.structr.api.util.html.attr.Onload) Attr(org.structr.api.util.html.Attr) SchemaNode(org.structr.core.entity.SchemaNode) Type(org.structr.api.util.html.attr.Type) Tag(org.structr.api.util.html.Tag) If(org.structr.api.util.html.attr.If)

Example 29 with SchemaNode

use of org.structr.core.entity.SchemaNode in project structr by structr.

the class StructrJsonHtmlWriter method beginDocument.

@Override
public RestWriter beginDocument(final String baseUrl, final String propertyView) throws IOException {
    String currentType = baseUrl.replace(restPath + "/", "").replace("/" + propertyView, "");
    if (!propertyView.equals("public")) {
        this.propertyView = "/" + propertyView;
    }
    Tag head = doc.block("head");
    // head.empty("link").attr(new Rel("stylesheet"), new Type("text/css"), new Href("/structr/css/rest.css"));
    // head.inline("script").attr(new Type("text/javascript"), new Src("/structr/js/CollapsibleLists.js"));
    head.inline("style").attr(new Type("text/css")).text("body,html{font-family:\"Liberation Mono\",\"DejaVu Sans Mono\",Consolas,Monaco,\"Vera Sans Mono\",\"Lucida Console\",\"Courier New\",monospace!important;font-size:9pt;padding:0;margin:0}div#top{border-bottom:1px solid #a5a5a5;line-height:2em;background:#363636;background:-webkit-gradient(linear,left bottom,left top,from(#363636),to(#666)) no-repeat;background:-moz-linear-gradient(90deg,#363636,#666) no-repeat;filter:progid:DXImageTransform.Microsoft.Gradient(StartColorStr='#666666', EndColorStr='#363636', GradientType=0);padding:20px;font-family:Arial,Helvetica,Sans-serif}div#top a{color:#fff;text-decoration:none;font-weight:700;margin-right:1em}div#left{background-color:#eee;padding:10px 20px}div#left a{color:#666;text-decoration:none;font-weight:700;margin-right:1em}div#right{clear:both;padding-left:20px}ul{list-style-type:none}b{font-weight:700;color:#444}a.id,a.id:visited{color:#00a}span.type{font-weight:400;color:#080}span.id{font-weight:400;color:#999}span.name{font-weight:700;color:#666}span.string{color:#c60}span.boolean,span.number{color:#00a}span.null{color:#999}span.comma{color:#000}.collapsibleListOpen{list-style-image:url(data:image/gif;base64,R0lGODlhBwAHAOcYAAAAAAEBAQICAgMDAwQEBAUFBQYGBgcHBwgICAkJCQoKCgsLCwwMDA0NDQ4ODg8PDxAQEBERERISEhMTExQUFBUVFRYWFhcXFxgYGBkZGRoaGhsbGxwcHB0dHR4eHh8fHyAgICEhISIiIiMjIyQkJCUlJSYmJicnJygoKCkpKSoqKisrKywsLC0tLS4uLi8vLzAwMDExMTIyMjMzMzQ0NDU1NTY2Njc3Nzg4ODk5OTo6Ojs7Ozw8PD09PT4+Pj8/P0BAQEFBQUJCQkNDQ0REREVFR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DU1NTY2Njc3Nzg4ODk5OTo6Ojs7Ozw8PD09PT4+Pj8/P0BAQEFBQUJCQkNDQ0REREVFRUZGRkdHR0hISElJSUpKSktLS0xMTE1NTU5OTk9PT1BQUFFRUVJSUlNTU1RUVFVVVVZWVldXV1hYWFlZWVpaWltbW1xcXF1dXV5eXl9fX2BgYGFhYWJiYmNjY2RkZGVlZWZmZmdnZ2hoaGlpaWpqamtra2xsbG1tbW5ubm9vb3BwcHFxcXJycnNzc3R0dHV1dXZ2dnd3d3h4eHl5eXp6ent7e3x8fH19fX5+fn9/f4CAgIGBgYKCgoODg4SEhIWFhYaGhoeHh4iIiImJiYqKiouLi4yMjI2NjY6Ojo+Pj5CQkJGRkZKSkpOTk5SUlJWVlZaWlpeXl5iYmJmZmZqampubm5ycnJ2dnZ6enp+fn6CgoKGhoaKioqOjo6SkpKWlpaampqenp6ioqKmpqaqqqqurq6ysrK2tra6urq+vr7CwsLGxsbKysrOzs7S0tLW1tba2tre3t7i4uLm5ubq6uru7u7y8vL29vb6+vr+/v8DAwMHBwcLCwsPDw8TExMXFxcbGxsfHx8jIyMnJycrKysvLy8zMzM3Nzc7Ozs/Pz9DQ0NHR0dLS0tPT09TU1NXV1dbW1tfX19jY2NnZ2dra2tvb29zc3N3d3d7e3t/f3+Dg4OHh4eLi4uPj4+Tk5OXl5ebm5ufn5+jo6Onp6erq6uvr6+zs7O3t7e7u7u/v7/Dw8PHx8fLy8vPz8/T09PX19fb29vf39/j4+Pn5+fr6+vv7+/z8/P39/f7+/v///yH5BAEKAP8ALAAAAAAHAAcAAAgXAP8JHEgwE0GBBgdmWriw4MF/CR8KDAgAOw==);cursor:pointer}.collapsibleList{cursor:default}button.collapse,button.expand{font-family:\"Liberation Mono\",\"DejaVu Sans Mono\",Consolas,Monaco,\"Vera Sans Mono\",\"Lucida Console\",\"Courier New\",monospace!important;float:right;margin:-.3em 1em 0 0}li.collapsibleListClosed>ul.collapsibleList>li{display:none}li.collapsibleListClosed>ul.collapsibleList::before{content:\"…\"}li.collapsibleListClosed>ul.collapsibleList:empty{display:none}li.collapsibleListClosed>ul.collapsibleList{line-height:11px;display:inline-block;border:1px solid #aaa;border-radius:6px;padding-left:2px;cursor:pointer;background-color:#ddd;padding-right:3px;margin-left:-5px;margin-right:-5px;font-family:initial}");
    head.inline("script").attr(new Type("text/javascript")).text("var CollapsibleLists=new function(){function g(b){return function(a){a||(a=window.event);for(a=a.target?a.target:a.srcElement;\"LI\"!=a.nodeName;)a=a.parentNode;a==b&&f(b)}}function f(b){for(var a=b.className.match(/(^| )collapsibleListClosed( |$)/),c=b.getElementsByTagName(\"ul\"),d=0;d<c.length;d++){for(var e=c[d];\"LI\"!=e.nodeName;)e=e.parentNode}b.className=b.className.replace(/(^| )collapsibleList(Open|Closed)( |$)/,\"\");0<c.length&&(b.className+=\" collapsibleList\"+\n" + "(a?\"Open\":\"Closed\"))}this.apply=function(b){for(var a=document.getElementsByTagName(\"ul\"),c=0;c<a.length;c++)if(a[c].className.match(/(^| )collapsibleList( |$)/)&&(this.applyTo(a[c],!0),!b))for(var d=a[c].getElementsByTagName(\"ul\"),e=0;e<d.length;e++)d[e].className+=\" collapsibleList\"};this.applyTo=function(b,a){for(var c=b.getElementsByTagName(\"li\"),d=0;d<c.length;d++)a&&b!=c[d].parentNode||(c[d].addEventListener?c[d].addEventListener(\"click\",g(c[d]),!1):c[d].attachEvent(\"onclick\",g(c[d])),f(c[d]))};\n" + "this.openAll=function(){var b = [].slice.call(document.getElementsByClassName(\"collapsibleListClosed\")); [].forEach.call(b, function (el) { f(el); });};this.closeAll=function(){var b = [].slice.call(document.getElementsByClassName(\"collapsibleListOpen\")); [].forEach.call(b, function (el) { f(el); });}};");
    head.inline("title").text(baseUrl);
    Tag body = doc.block("body").attr(new Onload("if (document.querySelectorAll('#right > ul > li > ul > li > ul.collapsibleList > li').length > 5) { CollapsibleLists.apply(true); }"));
    Tag top = body.block("div").id("top");
    final App app = StructrApp.getInstance(securityContext);
    final Tag left = body.block("div").id("left");
    left.inline("button").attr(new Css("collapse right")).attr(new Attr("onclick", "CollapsibleLists.closeAll()")).text(" - ");
    left.inline("button").attr(new Css("expand right")).attr(new Attr("onclick", "CollapsibleLists.openAll()")).text(" + ");
    try (final Tx tx = app.tx()) {
        final List<SchemaNode> schemaNodes = app.nodeQuery(SchemaNode.class).getAsList();
        Collections.sort(schemaNodes);
        for (SchemaNode node : schemaNodes) {
            final String rawType = node.getName();
            top.inline("a").attr(new Href(restPath + "/" + rawType), new If(rawType.equals(currentType), new Css("active"))).text(rawType);
        }
    } catch (Throwable t) {
        logger.warn("", t);
    }
    for (String view : StructrApp.getConfiguration().getPropertyViews()) {
        if (!hiddenViews.contains(view)) {
            left.inline("a").attr(new Href(restPath + "/" + currentType + "/" + view), new If(view.equals(propertyView), new Css("active"))).text(view);
        }
    }
    // main div
    currentElement = body.block("div").id("right");
    // h1 title
    currentElement.block("h1").text(baseUrl);
    // begin ul
    currentElement = currentElement.block("ul");
    return this;
}
Also used : StructrApp(org.structr.core.app.StructrApp) App(org.structr.core.app.App) Css(org.structr.api.util.html.attr.Css) Tx(org.structr.core.graph.Tx) Href(org.structr.api.util.html.attr.Href) Onload(org.structr.api.util.html.attr.Onload) Attr(org.structr.api.util.html.Attr) SchemaNode(org.structr.core.entity.SchemaNode) Type(org.structr.api.util.html.attr.Type) Tag(org.structr.api.util.html.Tag) If(org.structr.api.util.html.attr.If)

Example 30 with SchemaNode

use of org.structr.core.entity.SchemaNode in project structr by structr.

the class SchemaMethodResource method findMethodSource.

public static String findMethodSource(final Class type, final String methodName) throws IllegalPathException {
    try {
        final App app = StructrApp.getInstance();
        final String typeName = type.getSimpleName();
        Class currentType = type;
        // first step: schema node or one of its parents
        SchemaNode schemaNode = app.nodeQuery(SchemaNode.class).andName(typeName).getFirst();
        while (schemaNode != null) {
            for (final SchemaMethod method : schemaNode.getProperty(SchemaNode.schemaMethods)) {
                if (methodName.equals(method.getName()) && !method.isJava()) {
                    return method.getProperty(SchemaMethod.source);
                }
            }
            currentType = currentType.getSuperclass();
            if (currentType != null) {
                // skip non-dynamic types
                if (currentType.getSimpleName().equals(typeName) || !currentType.getName().startsWith("org.structr.dynamic.")) {
                    currentType = currentType.getSuperclass();
                }
                if (currentType != null && currentType.getName().startsWith("org.structr.dynamic.")) {
                    schemaNode = app.nodeQuery(SchemaNode.class).andName(currentType.getSimpleName()).getFirst();
                } else {
                    break;
                }
            } else {
                break;
            }
        }
    } catch (FrameworkException fex) {
    }
    throw new IllegalPathException("Type and method name do not match the given path.");
}
Also used : StructrApp(org.structr.core.app.StructrApp) App(org.structr.core.app.App) SchemaNode(org.structr.core.entity.SchemaNode) IllegalPathException(org.structr.rest.exception.IllegalPathException) SchemaMethod(org.structr.core.entity.SchemaMethod) FrameworkException(org.structr.common.error.FrameworkException)

Aggregations

SchemaNode (org.structr.core.entity.SchemaNode)54 Tx (org.structr.core.graph.Tx)44 FrameworkException (org.structr.common.error.FrameworkException)41 Test (org.junit.Test)34 App (org.structr.core.app.App)18 StructrApp (org.structr.core.app.StructrApp)18 NodeAttribute (org.structr.core.graph.NodeAttribute)14 LinkedList (java.util.LinkedList)13 PropertyMap (org.structr.core.property.PropertyMap)13 NodeInterface (org.structr.core.graph.NodeInterface)12 PropertyKey (org.structr.core.property.PropertyKey)11 StructrTest (org.structr.common.StructrTest)10 SchemaMethod (org.structr.core.entity.SchemaMethod)10 SchemaRelationshipNode (org.structr.core.entity.SchemaRelationshipNode)9 StringProperty (org.structr.core.property.StringProperty)9 List (java.util.List)8 ConfigurationProvider (org.structr.schema.ConfigurationProvider)8 SchemaProperty (org.structr.core.entity.SchemaProperty)7 LinkedHashSet (java.util.LinkedHashSet)6 FrontendTest (org.structr.web.basic.FrontendTest)6