Package org.structr.core.graph

Examples of org.structr.core.graph.NodeFactory


    return query;
  }

  public void setSecurityContext(SecurityContext securityContext) {
    this.securityContext = securityContext;
    this.nodeFactory     = new NodeFactory(securityContext);
    this.relFactory      = new RelationshipFactory(securityContext);
  }
View Full Code Here


  @Override
  public NodeInterface getOtherNode(final NodeInterface node) {

    try {

      NodeFactory nodeFactory = new NodeFactory(securityContext);
      return (NodeInterface)nodeFactory.instantiate(dbRelationship.getOtherNode(node.getNode()));

    } catch (FrameworkException t) {
      // ignore FrameworkException but let NotInTransactionException pass
    }
View Full Code Here

*/
public class SearchUserCommand extends NodeServiceCommand {

  public Object execute(Object... parameters) throws FrameworkException {

    final NodeFactory nodeFactory = new NodeFactory(securityContext);

    switch (parameters.length) {

      case 1 : {
        final Index<Node> index = getIndexFromArguments(NodeIndex.user, arguments);

        // we have only a simple user name
        if (parameters[0] instanceof String) {

          final String userName = (String) parameters[0];

          for (final Node n : index.get(AbstractNode.name.dbName(), userName)) {

            final NodeInterface s = nodeFactory.instantiate(n);

            if (s.getType().equals(Principal.class.getSimpleName())) {

              return s;

            }

          }

        }
      } break;

      case 3 : {

        final String userNickName = (String) parameters[0];
        final PropertyKey key = (PropertyKey) parameters[1];
        final NodeIndex idx = (NodeIndex) parameters[2];
        final Index<Node> index = getIndexFromArguments(idx, arguments);
        IndexHits<Node> indexHits = null;

        synchronized (index) {

          // see: http://docs.neo4j.org/chunked/milestone/indexing-create-advanced.html
          indexHits = index.query( key.dbName(), "\"" + userNickName + "\"" );
         
        }
       
        try {
          for (final Node n : indexHits) {
            final Object u = nodeFactory.instantiate(n);
            if (u != null) {
              return u;
            }
          }
        } finally {
View Full Code Here

*/
public class SearchNodeCommand<T extends NodeInterface> extends SearchCommand<Node, T> {

  @Override
  public Factory<Node, T> getFactory(SecurityContext securityContext, boolean includeDeletedAndHidden, boolean publicOnly, int pageSize, int page, String offsetId) {
    return new NodeFactory(securityContext, includeDeletedAndHidden, publicOnly, pageSize, page, offsetId);
  }
View Full Code Here

  }

  public OtherNodeTypeFilter(final SecurityContext securityContext, final Node thisNode, final Class desiredType, final Predicate<GraphObject> nodePredicate) {

    this.nodePredicate = nodePredicate;
    this.nodeFactory   = new NodeFactory(securityContext);
    this.desiredType   = desiredType;
    this.thisNode      = thisNode;
  }
View Full Code Here

          }
        }

        // instantiate spatial search results without paging,
        // as the results must be filtered by type anyway
        intermediateResult = new NodeFactory(securityContext).instantiate(hits);

      } else if (allExactMatch) {

        index = getKeywordIndex();
View Full Code Here

  private Node thisNode           = null;
  private Class desiredType       = null;

  public OtherNodeTypeRelationFilter(final SecurityContext securityContext, final Node thisNode, final Class desiredType) {

    this.nodeFactory = new NodeFactory(SecurityContext.getSuperUserInstance());
    this.desiredType = desiredType;
    this.thisNode    = thisNode;
  }
View Full Code Here

  private void migrateDatabase() {

    final GraphDatabaseService graphDb     = getService(NodeService.class).getGraphDb();
    final SecurityContext superUserContext = SecurityContext.getSuperUserInstance();
    final NodeFactory nodeFactory          = new NodeFactory(superUserContext);
    final RelationshipFactory relFactory   = new RelationshipFactory(superUserContext);
    final App app                          = StructrApp.getInstance();
    final StringProperty uuidProperty      = new StringProperty("uuid");
    final int txLimit                      = 2000;

    boolean hasChanges                     = true;
    int actualNodeCount                    = 0;
    int actualRelCount                     = 0;

    logger.log(Level.INFO, "Migration of ID properties from uuid to id requested.");

    while (hasChanges) {

      hasChanges = false;

      try (final Tx tx = app.tx(false, false)) {

        // iterate over all nodes,
        final Iterator<Node> allNodes = GlobalGraphOperations.at(graphDb).getAllNodes().iterator();
        while (allNodes.hasNext()) {

          final Node node = allNodes.next();

          // do migration of our own ID properties (and only our own!)
          if (node.hasProperty("uuid") && node.getProperty("uuid") instanceof String && !node.hasProperty("id")) {

            try {
              final NodeInterface nodeInterface = nodeFactory.instantiate(node);
              final String uuid = nodeInterface.getProperty(uuidProperty);

              if (uuid != null) {

                nodeInterface.setProperty(GraphObject.id, uuid);
View Full Code Here

TOP

Related Classes of org.structr.core.graph.NodeFactory

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.