Search in sources :

Example 21 with PropertyMap

use of org.structr.core.property.PropertyMap in project structr by structr.

the class StructrODFModuleTest method createTestNodes.

protected <T extends AbstractNode> List<T> createTestNodes(final Class<T> type, final int number, final long delay) throws FrameworkException {
    try (final Tx tx = app.tx()) {
        final PropertyMap properties = new PropertyMap();
        final List<T> nodes = new LinkedList<>();
        properties.put(NodeInterface.visibleToAuthenticatedUsers, false);
        properties.put(NodeInterface.visibleToPublicUsers, false);
        properties.put(NodeInterface.deleted, false);
        properties.put(NodeInterface.hidden, false);
        for (int i = 0; i < number; i++) {
            nodes.add(app.create(type, properties));
            try {
                Thread.sleep(delay);
            } catch (InterruptedException ex) {
            }
        }
        tx.success();
        return nodes;
    } catch (Throwable t) {
        logger.warn("", t);
    }
    return null;
}
Also used : PropertyMap(org.structr.core.property.PropertyMap) Tx(org.structr.core.graph.Tx) LinkedList(java.util.LinkedList)

Example 22 with PropertyMap

use of org.structr.core.property.PropertyMap in project structr by structr.

the class StructrKnowledgeModuleTest method createTestNodes.

protected <T extends AbstractNode> List<T> createTestNodes(final Class<T> type, final int number, final long delay) throws FrameworkException {
    try (final Tx tx = app.tx()) {
        final PropertyMap properties = new PropertyMap();
        final List<T> nodes = new LinkedList<>();
        properties.put(NodeInterface.visibleToAuthenticatedUsers, false);
        properties.put(NodeInterface.visibleToPublicUsers, false);
        properties.put(NodeInterface.deleted, false);
        properties.put(NodeInterface.hidden, false);
        for (int i = 0; i < number; i++) {
            nodes.add(app.create(type, properties));
            try {
                Thread.sleep(delay);
            } catch (InterruptedException ex) {
            }
        }
        tx.success();
        return nodes;
    } catch (Throwable t) {
        logger.warn("", t);
    }
    return null;
}
Also used : PropertyMap(org.structr.core.property.PropertyMap) Tx(org.structr.core.graph.Tx) LinkedList(java.util.LinkedList)

Example 23 with PropertyMap

use of org.structr.core.property.PropertyMap in project structr by structr.

the class MQTTClient method onModification.

static void onModification(MQTTClient thisClient, final SecurityContext securityContext, final ErrorBuffer errorBuffer, final ModificationQueue modificationQueue) throws FrameworkException {
    if (modificationQueue.isPropertyModified(thisClient, StructrApp.key(MQTTClient.class, "protocol")) || modificationQueue.isPropertyModified(thisClient, StructrApp.key(MQTTClient.class, "url")) || modificationQueue.isPropertyModified(thisClient, StructrApp.key(MQTTClient.class, "port"))) {
        MQTTContext.disconnect(thisClient);
    }
    if (modificationQueue.isPropertyModified(thisClient, StructrApp.key(MQTTClient.class, "isEnabled")) || modificationQueue.isPropertyModified(thisClient, StructrApp.key(MQTTClient.class, "protocol")) || modificationQueue.isPropertyModified(thisClient, StructrApp.key(MQTTClient.class, "url")) || modificationQueue.isPropertyModified(thisClient, StructrApp.key(MQTTClient.class, "port"))) {
        MQTTClientConnection connection = MQTTContext.getClientForId(thisClient.getUuid());
        boolean enabled = thisClient.getIsEnabled();
        if (!enabled) {
            if (connection != null && connection.isConnected()) {
                MQTTContext.disconnect(thisClient);
                thisClient.setProperties(securityContext, new PropertyMap(StructrApp.key(MQTTClient.class, "isConnected"), false));
            }
        } else {
            if (connection == null || !connection.isConnected()) {
                MQTTContext.connect(thisClient);
                MQTTContext.subscribeAllTopics(thisClient);
            }
            connection = MQTTContext.getClientForId(thisClient.getUuid());
            if (connection != null) {
                if (connection.isConnected()) {
                    thisClient.setProperties(securityContext, new PropertyMap(StructrApp.key(MQTTClient.class, "isConnected"), true));
                } else {
                    thisClient.setProperties(securityContext, new PropertyMap(StructrApp.key(MQTTClient.class, "isConnected"), false));
                }
            }
        }
    }
}
Also used : PropertyMap(org.structr.core.property.PropertyMap) MQTTClientConnection(org.structr.messaging.implementation.mqtt.MQTTClientConnection)

Example 24 with PropertyMap

use of org.structr.core.property.PropertyMap in project structr by structr.

the class JavaParserModuleTest method createTestNode.

protected <T extends AbstractNode> T createTestNode(final Class<T> type, final String name) throws FrameworkException {
    final PropertyMap map = new PropertyMap();
    map.put(AbstractNode.name, name);
    return (T) createTestNode(type, map);
}
Also used : PropertyMap(org.structr.core.property.PropertyMap)

Example 25 with PropertyMap

use of org.structr.core.property.PropertyMap in project structr by structr.

the class Importer method readPage.

public Page readPage(final String uuid) throws FrameworkException {
    Page page = Page.createNewPage(securityContext, uuid, name);
    if (page != null) {
        final PropertyMap changedProperties = new PropertyMap();
        changedProperties.put(AbstractNode.visibleToAuthenticatedUsers, authVisible);
        changedProperties.put(AbstractNode.visibleToPublicUsers, publicVisible);
        page.setProperties(securityContext, changedProperties);
        createChildNodes(parsedDocument, page, page);
        if (!isDeployment) {
            logger.info("##### Finished fetching {} for page {} #####", new Object[] { address, name });
        }
    }
    return page;
}
Also used : PropertyMap(org.structr.core.property.PropertyMap) Page(org.structr.web.entity.dom.Page)

Aggregations

PropertyMap (org.structr.core.property.PropertyMap)233 FrameworkException (org.structr.common.error.FrameworkException)100 Tx (org.structr.core.graph.Tx)93 Test (org.junit.Test)60 App (org.structr.core.app.App)34 StructrApp (org.structr.core.app.StructrApp)34 PropertyKey (org.structr.core.property.PropertyKey)34 LinkedList (java.util.LinkedList)28 NodeInterface (org.structr.core.graph.NodeInterface)25 SchemaProperty (org.structr.core.entity.SchemaProperty)23 SecurityContext (org.structr.common.SecurityContext)22 StructrUiTest (org.structr.web.StructrUiTest)21 GraphObject (org.structr.core.GraphObject)20 Result (org.structr.core.Result)19 File (org.structr.web.entity.File)19 DOMNode (org.structr.web.entity.dom.DOMNode)19 TestOne (org.structr.core.entity.TestOne)17 AbstractNode (org.structr.core.entity.AbstractNode)16 Folder (org.structr.web.entity.Folder)15 Page (org.structr.web.entity.dom.Page)15