Search in sources :

Example 1 with StartNodes

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

the class SchemaNode method getMultiplicity.

@Override
public String getMultiplicity(final String propertyNameToCheck) {
    String multiplicity = getMultiplicity(this, propertyNameToCheck);
    if (multiplicity == null) {
        try {
            final String parentClass = getProperty(SchemaNode.extendsClass);
            if (parentClass != null) {
                // check if property is defined in parent class
                final SchemaNode parentSchemaNode = StructrApp.getInstance().nodeQuery(SchemaNode.class).andName(StringUtils.substringAfterLast(parentClass, ".")).getFirst();
                if (parentSchemaNode != null) {
                    multiplicity = getMultiplicity(parentSchemaNode, propertyNameToCheck);
                }
            }
        } catch (FrameworkException ex) {
            logger.warn("Can't find schema node for parent class!", ex);
        }
    }
    if (multiplicity != null) {
        return multiplicity;
    }
    // fallback, search NodeInterface (this allows the owner relationship to be used in Notions!)
    final PropertyKey key = StructrApp.getConfiguration().getPropertyKeyForJSONName(NodeInterface.class, propertyNameToCheck, false);
    if (key != null) {
        if (key instanceof StartNode || key instanceof EndNode) {
            return "1X";
        }
        if (key instanceof StartNodes || key instanceof EndNodes) {
            return "*X";
        }
    }
    return null;
}
Also used : StartNode(org.structr.core.property.StartNode) FrameworkException(org.structr.common.error.FrameworkException) EndNode(org.structr.core.property.EndNode) StartNodes(org.structr.core.property.StartNodes) EndNodes(org.structr.core.property.EndNodes) PropertyKey(org.structr.core.property.PropertyKey)

Aggregations

FrameworkException (org.structr.common.error.FrameworkException)1 EndNode (org.structr.core.property.EndNode)1 EndNodes (org.structr.core.property.EndNodes)1 PropertyKey (org.structr.core.property.PropertyKey)1 StartNode (org.structr.core.property.StartNode)1 StartNodes (org.structr.core.property.StartNodes)1