use of org.structr.core.graph.NodeInterface in project structr by structr.
the class StartNodeGroup method getGroupedProperties.
@Override
public PropertyMap getGroupedProperties(SecurityContext securityContext, GraphObject source) {
if (source instanceof AbstractRelationship) {
RelationshipInterface rel = (RelationshipInterface) source;
NodeInterface startNode = rel.getSourceNode();
return super.getGroupedProperties(securityContext, startNode);
}
return null;
}
use of org.structr.core.graph.NodeInterface in project structr by structr.
the class StartNodes method getSearchAttribute.
@Override
public SearchAttribute getSearchAttribute(SecurityContext securityContext, Occurrence occur, List<S> searchValue, boolean exactMatch, final Query query) {
final Predicate<GraphObject> predicate = query != null ? query.toPredicate() : null;
final SourceSearchAttribute attr = new SourceSearchAttribute(occur);
final Set<GraphObject> intersectionResult = new LinkedHashSet<>();
boolean alreadyAdded = false;
if (searchValue != null && !StringUtils.isBlank(searchValue.toString())) {
if (exactMatch) {
for (NodeInterface node : searchValue) {
switch(occur) {
case REQUIRED:
if (!alreadyAdded) {
// the first result is the basis of all subsequent intersections
intersectionResult.addAll(getRelatedNodesReverse(securityContext, node, declaringClass, predicate));
// the next additions are intersected with this one
alreadyAdded = true;
} else {
intersectionResult.retainAll(getRelatedNodesReverse(securityContext, node, declaringClass, predicate));
}
break;
case OPTIONAL:
intersectionResult.addAll(getRelatedNodesReverse(securityContext, node, declaringClass, predicate));
break;
case FORBIDDEN:
break;
}
}
} else {
// loose search behaves differently, all results must be combined
for (NodeInterface node : searchValue) {
intersectionResult.addAll(getRelatedNodesReverse(securityContext, node, declaringClass, predicate));
}
}
attr.setResult(intersectionResult);
} else {
// value in the given field
return new EmptySearchAttribute(this, null);
}
return attr;
}
use of org.structr.core.graph.NodeInterface in project structr by structr.
the class GeoTest 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;
}
}
use of org.structr.core.graph.NodeInterface in project structr by structr.
the class StructrDataFeedsModuleTest 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;
}
}
use of org.structr.core.graph.NodeInterface in project structr by structr.
the class StructrCsvModuleTest method cleanDatabase.
@After
@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);
}
}
Aggregations