Package org.structr.core.entity

Examples of org.structr.core.entity.Relation


      return result;

    } else {

      final App app                         = StructrApp.getInstance(securityContext);
      final Relation template               = getRelationshipTemplate();
      final ErrorBuffer errorBuffer         = new ErrorBuffer();

      if (template != null) {

        final NodeInterface sourceNode        = identifyStartNode(template, propertySet);
        final NodeInterface targetNode        = identifyEndNode(template, propertySet);
        final PropertyMap properties          = PropertyMap.inputTypeToJavaType(securityContext, entityClass, propertySet);
        RelationshipInterface newRelationship = null;

        if (sourceNode == null) {
          errorBuffer.add(entityClass.getSimpleName(), new EmptyPropertyToken(template.getSourceIdProperty()));
        }

        if (targetNode == null) {
          errorBuffer.add(entityClass.getSimpleName(), new EmptyPropertyToken(template.getTargetIdProperty()));
        }

        if (errorBuffer.hasError()) {
          throw new FrameworkException(422, errorBuffer);
        }
View Full Code Here


    List<Class<? extends RelationshipInterface>> candidates = new ArrayList();

    for (final Class<? extends RelationshipInterface> candidate : getRelationshipEntities().values()) {

      Relation rel = instantiate(candidate);

      if (rel == null) {
        continue;
      }

      if (rel.name().equals(relType)) {
        candidates.add(candidate);
      }

    }
View Full Code Here

    Class sourceType = getNodeEntityClass(sourceTypeName);
    Class targetType = getNodeEntityClass(targetTypeName);

    for (final Class candidate : getRelationClassCanditatesForRelType(relType)) {

      Relation rel = instantiate(candidate);

      //System.out.println("? " + candidate.getSimpleName() + " for [" + sourceTypeName + " " + relType + " " + targetTypeName + "]");
      int distance = getDistance(rel.getSourceType(), sourceType, -1) + getDistance(rel.getTargetType(), targetType, -1);

      if (distance >= 2000) {

        candidates.put(distance - 2000, candidate);
        //System.out.println("\n=========================== Found " + candidate.getSimpleName() + " for " + sourceTypeName + " " + relType + " " + targetTypeName + " at distance " + (distance-2000));
View Full Code Here

      }

      //if (declaringClass != null && ("org.structr.dynamic".equals(declaringClass.getPackage().getName()))) {
      if (declaringClass != null && property instanceof RelationProperty) {

        Relation relation = ((RelationProperty) property).getRelation();
        if (relation != null) {

          propProperties.put("relationshipType", relation.name());
        }
      }

      propertyConverterMap.put(property.jsonName(), propProperties);
    }
View Full Code Here

          if (!typeResource.isNode) {

            final NodeInterface source = (NodeInterface) sourceEntity;
            final Node sourceNode = source.getNode();
            final Class relationshipType = typeResource.entityClass;
            final Relation relation = AbstractNode.getRelationshipForType(relationshipType);
            final Class destNodeType = relation.getOtherType(typedIdResource.getEntityClass());
            final Set partialResult = new LinkedHashSet<>(typeResource.doGet(sortKey, sortDescending, NodeFactory.DEFAULT_PAGE_SIZE, NodeFactory.DEFAULT_PAGE, null).getResults());

            // filter list according to end node type
            final Set<GraphObject> set = Iterables.toSet(Iterables.filter(new OtherNodeTypeRelationFilter(securityContext, sourceNode, destNodeType), source.getRelationships(relationshipType)));
View Full Code Here

TOP

Related Classes of org.structr.core.entity.Relation

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.