Search in sources :

Example 11 with NodeInterface

use of org.structr.core.graph.NodeInterface in project structr by structr.

the class StructrODFModuleTest method createTestRelationships.

protected <T extends Relation> List<T> createTestRelationships(final Class<T> relType, final int number) throws FrameworkException {
    List<GenericNode> nodes = createTestNodes(GenericNode.class, 2);
    final NodeInterface startNode = nodes.get(0);
    final NodeInterface endNode = nodes.get(1);
    try (final Tx tx = app.tx()) {
        List<T> rels = new LinkedList<>();
        for (int i = 0; i < number; i++) {
            rels.add((T) app.create(startNode, endNode, relType));
        }
        tx.success();
        return rels;
    }
}
Also used : Tx(org.structr.core.graph.Tx) GenericNode(org.structr.core.entity.GenericNode) NodeInterface(org.structr.core.graph.NodeInterface) LinkedList(java.util.LinkedList)

Example 12 with NodeInterface

use of org.structr.core.graph.NodeInterface in project structr by structr.

the class StructrLDAPServerModuleTest method cleanDatabase.

@Before
public void cleanDatabase() {
    try (final Tx tx = app.tx()) {
        final List<? extends NodeInterface> nodes = app.nodeQuery().getAsList();
        logger.info("Cleaning database: {} nodes", nodes.size());
        for (final NodeInterface node : nodes) {
            app.delete(node);
        }
        // delete remaining nodes without UUIDs etc.
        app.cypher("MATCH (n)-[r]-(m) DELETE n, r, m", Collections.emptyMap());
        tx.success();
    } catch (FrameworkException fex) {
        logger.error("Exception while trying to clean database: {}", fex);
    }
}
Also used : Tx(org.structr.core.graph.Tx) FrameworkException(org.structr.common.error.FrameworkException) NodeInterface(org.structr.core.graph.NodeInterface) Before(org.junit.Before)

Example 13 with NodeInterface

use of org.structr.core.graph.NodeInterface in project structr by structr.

the class StructrLDAPServerModuleTest method createTestRelationships.

protected <T extends Relation> List<T> createTestRelationships(final Class<T> relType, final int number) throws FrameworkException {
    List<GenericNode> nodes = createTestNodes(GenericNode.class, 2);
    final NodeInterface startNode = nodes.get(0);
    final NodeInterface endNode = nodes.get(1);
    try (final Tx tx = app.tx()) {
        List<T> rels = new LinkedList<>();
        for (int i = 0; i < number; i++) {
            rels.add((T) app.create(startNode, endNode, relType));
        }
        tx.success();
        return rels;
    }
}
Also used : Tx(org.structr.core.graph.Tx) GenericNode(org.structr.core.entity.GenericNode) NodeInterface(org.structr.core.graph.NodeInterface) LinkedList(java.util.LinkedList)

Example 14 with NodeInterface

use of org.structr.core.graph.NodeInterface in project structr by structr.

the class StructrMediaModuleTest method cleanDatabase.

@Before
public void cleanDatabase() {
    try (final Tx tx = app.tx()) {
        final List<? extends NodeInterface> nodes = app.nodeQuery().getAsList();
        logger.info("Cleaning database: {} nodes", nodes.size());
        for (final NodeInterface node : nodes) {
            app.delete(node);
        }
        // delete remaining nodes without UUIDs etc.
        app.cypher("MATCH (n)-[r]-(m) DELETE n, r, m", Collections.emptyMap());
        tx.success();
    } catch (FrameworkException fex) {
        logger.error("Exception while trying to clean database: {}", fex);
    }
}
Also used : Tx(org.structr.core.graph.Tx) FrameworkException(org.structr.common.error.FrameworkException) NodeInterface(org.structr.core.graph.NodeInterface) Before(org.junit.Before)

Example 15 with NodeInterface

use of org.structr.core.graph.NodeInterface in project structr by structr.

the class StructrMediaModuleTest method createTestRelationships.

protected <T extends Relation> List<T> createTestRelationships(final Class<T> relType, final int number) throws FrameworkException {
    List<GenericNode> nodes = createTestNodes(GenericNode.class, 2);
    final NodeInterface startNode = nodes.get(0);
    final NodeInterface endNode = nodes.get(1);
    try (final Tx tx = app.tx()) {
        List<T> rels = new LinkedList<>();
        for (int i = 0; i < number; i++) {
            rels.add((T) app.create(startNode, endNode, relType));
        }
        tx.success();
        return rels;
    }
}
Also used : Tx(org.structr.core.graph.Tx) GenericNode(org.structr.core.entity.GenericNode) NodeInterface(org.structr.core.graph.NodeInterface) LinkedList(java.util.LinkedList)

Aggregations

NodeInterface (org.structr.core.graph.NodeInterface)186 FrameworkException (org.structr.common.error.FrameworkException)120 Tx (org.structr.core.graph.Tx)116 Test (org.junit.Test)81 PropertyKey (org.structr.core.property.PropertyKey)61 LinkedList (java.util.LinkedList)36 StructrTest (org.structr.common.StructrTest)29 PropertyMap (org.structr.core.property.PropertyMap)26 TestOne (org.structr.core.entity.TestOne)24 List (java.util.List)23 GraphObject (org.structr.core.GraphObject)22 App (org.structr.core.app.App)21 StructrApp (org.structr.core.app.StructrApp)21 GenericNode (org.structr.core.entity.GenericNode)21 Before (org.junit.Before)18 Result (org.structr.core.Result)18 AbstractRelationship (org.structr.core.entity.AbstractRelationship)16 Random (java.util.Random)15 RelationshipInterface (org.structr.core.graph.RelationshipInterface)14 ErrorToken (org.structr.common.error.ErrorToken)12