use of org.structr.core.graph.RelationshipInterface in project structr by structr.
the class StructrUiTest method createTestRelationships.
protected List<RelationshipInterface> createTestRelationships(final Class relType, final int number) throws FrameworkException {
List<GenericNode> nodes = createTestNodes(GenericNode.class, 2);
final GenericNode startNode = nodes.get(0);
final GenericNode endNode = nodes.get(1);
List<RelationshipInterface> rels = new LinkedList<>();
for (int i = 0; i < number; i++) {
rels.add(app.create(startNode, endNode, relType));
}
return rels;
}
use of org.structr.core.graph.RelationshipInterface in project structr by structr.
the class Template method renderContent.
/*
public static final org.structr.common.View uiView = new org.structr.common.View(Content.class, PropertyView.Ui,
children, childrenIds, content, contentType, parent, pageId, hideOnDetail, hideOnIndex, sharedComponent, syncedNodes, dataKey, restQuery, cypherQuery, xpathQuery, functionQuery,
showForLocales, hideForLocales, showConditions, hideConditions, isContent
);
public static final org.structr.common.View publicView = new org.structr.common.View(Content.class, PropertyView.Public,
children, childrenIds, content, contentType, parent, pageId, hideOnDetail, hideOnIndex, sharedComponent, syncedNodes, dataKey, restQuery, cypherQuery, xpathQuery, functionQuery,
showForLocales, hideForLocales, showConditions, hideConditions, isContent
);
*/
public static void renderContent(final Template thisTemplate, final RenderContext renderContext, final int depth) throws FrameworkException {
final SecurityContext securityContext = thisTemplate.getSecurityContext();
final EditMode editMode = renderContext.getEditMode(securityContext.getUser(false));
if (EditMode.DEPLOYMENT.equals(editMode)) {
final DOMNode _syncedNode = thisTemplate.getSharedComponent();
final AsyncBuffer out = renderContext.getBuffer();
if (depth > 0) {
out.append(DOMNode.indent(depth, renderContext));
}
DOMNode.renderDeploymentExportComments(thisTemplate, out, true);
out.append("<structr:template src=\"");
if (_syncedNode != null) {
// use name of synced node
final String _name = _syncedNode.getProperty(AbstractNode.name);
out.append(_name != null ? _name.concat("-").concat(_syncedNode.getUuid()) : _syncedNode.getUuid());
} else {
// use name of local template
final String _name = thisTemplate.getProperty(AbstractNode.name);
out.append(_name != null ? _name.concat("-").concat(thisTemplate.getUuid()) : thisTemplate.getUuid());
}
out.append("\"");
DOMNode.renderSharedComponentConfiguration(thisTemplate, out, editMode);
// include custom attributes in templates as well!
DOMNode.renderCustomAttributes(thisTemplate, out, securityContext, renderContext);
out.append(">");
// fetch children
final List<RelationshipInterface> rels = thisTemplate.getChildRelationships();
if (rels.isEmpty()) {
// No child relationships, maybe this node is in sync with another node
if (_syncedNode != null) {
rels.addAll(_syncedNode.getChildRelationships());
}
}
for (final RelationshipInterface rel : rels) {
final DOMNode subNode = (DOMNode) rel.getTargetNode();
subNode.render(renderContext, depth + 1);
}
out.append(DOMNode.indent(depth, renderContext));
out.append("</structr:template>");
out.append(DOMNode.indent(depth - 1, renderContext));
} else {
// "super" call using static method..
Content.renderContent(thisTemplate, renderContext, depth);
}
}
use of org.structr.core.graph.RelationshipInterface in project structr by structr.
the class ValidationHelper method isValidGloballyUniqueProperty.
public static synchronized boolean isValidGloballyUniqueProperty(final GraphObject object, final PropertyKey key, final ErrorBuffer errorBuffer) {
if (key != null) {
final Object value = object.getProperty(key);
List<? extends GraphObject> result = null;
try {
if (object instanceof NodeInterface) {
result = StructrApp.getInstance().nodeQuery(NodeInterface.class).and(key, value).disableSorting().getAsList();
} else if (object instanceof RelationshipInterface) {
result = StructrApp.getInstance().relationshipQuery(RelationshipInterface.class).and(key, value).disableSorting().getAsList();
} else {
logger.error("GraphObject is neither NodeInterface nor RelationshipInterface");
return false;
}
} catch (FrameworkException fex) {
logger.warn("Unable to fetch list of nodes for uniqueness check", fex);
// handle error
}
if (result != null) {
for (final GraphObject foundNode : result) {
if (foundNode.getId() != object.getId()) {
// validation is aborted when the first validation failure occurs, so
// we can assume that the object currently exmained is the first
// existing object, hence all others get the error message with the
// UUID of the first one.
errorBuffer.add(new UniqueToken(object.getType(), key, object.getUuid()));
// error!
return false;
}
}
}
}
// no error
return true;
}
use of org.structr.core.graph.RelationshipInterface in project structr by structr.
the class EndNodeGroup method getGroupedProperties.
@Override
public PropertyMap getGroupedProperties(SecurityContext securityContext, GraphObject source) {
if (source instanceof RelationshipInterface) {
RelationshipInterface rel = (RelationshipInterface) source;
NodeInterface end = rel.getTargetNode();
return super.getGroupedProperties(securityContext, end);
}
return null;
}
use of org.structr.core.graph.RelationshipInterface 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;
}
Aggregations