private void indexRelationship(final AbstractRelationship rel) throws FrameworkException { String uuid = rel.getStringProperty(AbstractRelationship.Key.uuid); // Don't index non-structr relationship if (uuid == null) { return; } String combinedKey = rel.getStringProperty(AbstractRelationship.HiddenKey.combinedType.name()); if (combinedKey == null) { AbstractNode startNode = rel.getStartNode(); AbstractNode endNode = rel.getEndNode(); if (startNode != null && endNode != null) { // add a special combinedType key, consisting of the relationship combinedType, the // combinedType of the start node and the combinedType of the end node String tripleKey = EntityContext.createCombinedRelationshipType( startNode.getType(), rel.getType(), endNode.getType()); rel.setProperty( AbstractRelationship.HiddenKey.combinedType.name(), Search.clean(tripleKey)); indexProperty(rel, AbstractRelationship.HiddenKey.combinedType.name()); } else { logger.log( Level.WARNING, "Unable to create combined type key, startNode or endNode was null!"); } } for (String key : rel.getPropertyKeys()) { indexProperty(rel, key); } }
static { EntityContext.registerPropertySet(Tbody.class, PropertyView.All, HtmlElement.UiKey.values()); EntityContext.registerPropertySet(Tbody.class, PropertyView.Public, HtmlElement.UiKey.values()); EntityContext.registerPropertySet( Tbody.class, PropertyView.Html, PropertyView.Html, htmlAttributes); }
@Override public void execute(Map<String, Object> attributes) throws FrameworkException { final String entityType = (String) attributes.get("type"); final String relType = (String) attributes.get("relType"); final GraphDatabaseService graphDb = (GraphDatabaseService) arguments.get("graphDb"); final SecurityContext superUserContext = SecurityContext.getSuperUserInstance(); final NodeFactory nodeFactory = new NodeFactory(superUserContext); final RelationshipFactory relFactory = new RelationshipFactory(superUserContext); if (entityType != null) { final Class type = EntityContext.getEntityClassForRawType(entityType); if (type != null) { // final Result<AbstractNode> result = Services.command(securityContext, // SearchNodeCommand.class).execute(true, false, Search.andExactType(type.getSimpleName())); final Result<AbstractNode> result = nodeFactory.instantiateAll(GlobalGraphOperations.at(graphDb).getAllNodes()); final List<AbstractNode> nodes = new ArrayList<AbstractNode>(); for (AbstractNode node : result.getResults()) { if (node.getClass().equals(type)) { nodes.add(node); } } logger.log( Level.INFO, "Start (re-)indexing all nodes of type {0}", new Object[] {type.getSimpleName()}); long count = bulkGraphOperation( securityContext, nodes, 1000, "RebuildIndex", new BulkGraphOperation<AbstractNode>() { @Override public void handleGraphObject( SecurityContext securityContext, AbstractNode node) { node.updateInIndex(); } @Override public void handleThrowable( SecurityContext securityContext, Throwable t, AbstractNode node) { logger.log( Level.WARNING, "Unable to index node {0}: {1}", new Object[] {node, t.getMessage()}); } @Override public void handleTransactionFailure( SecurityContext securityContext, Throwable t) { logger.log(Level.WARNING, "Unable to index node: {0}", t.getMessage()); } }); logger.log(Level.INFO, "Done with (re-)indexing {0} nodes", count); return; } } else if (relType != null) { // final Result<AbstractNode> result = Services.command(securityContext, // SearchNodeCommand.class).execute(true, false, Search.andExactType(type.getSimpleName())); final List<AbstractRelationship> unfilteredRels = relFactory.instantiate(GlobalGraphOperations.at(graphDb).getAllRelationships()); final List<AbstractRelationship> rels = new ArrayList<AbstractRelationship>(); for (AbstractRelationship rel : unfilteredRels) { if (!rel.getType().equals(relType)) { rels.add(rel); } } logger.log(Level.INFO, "Start setting UUID on all rels of type {0}", new Object[] {relType}); long count = bulkGraphOperation( securityContext, rels, 1000, "SetRelationshipUuid", new BulkGraphOperation<AbstractRelationship>() { @Override public void handleGraphObject( SecurityContext securityContext, AbstractRelationship rel) { rel.updateInIndex(); } @Override public void handleThrowable( SecurityContext securityContext, Throwable t, AbstractRelationship rel) { logger.log( Level.WARNING, "Unable to index relationship {0}: {1}", new Object[] {rel, t.getMessage()}); } @Override public void handleTransactionFailure(SecurityContext securityContext, Throwable t) { logger.log(Level.WARNING, "Unable to index relationship: {0}", t.getMessage()); } }); logger.log(Level.INFO, "Done with (re-)indexing {0} relationships", count); return; } logger.log(Level.INFO, "Unable to determine entity type to re-index."); }
static { EntityContext.registerPropertySet(FilterNode.class, PropertyView.All, Key.values()); }
static { EntityContext.registerPropertySet(Template.class, PropertyView.All, Key.values()); }