当前位置: 首页>>代码示例>>Java>>正文


Java Iterables类代码示例

本文整理汇总了Java中org.neo4j.helpers.collection.Iterables的典型用法代码示例。如果您正苦于以下问题:Java Iterables类的具体用法?Java Iterables怎么用?Java Iterables使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Iterables类属于org.neo4j.helpers.collection包,在下文中一共展示了Iterables类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testOneMatchWithPlayers

import org.neo4j.helpers.collection.Iterables; //导入依赖的package包/类
@Test
public void testOneMatchWithPlayers() {
    Player white = new Player("Line");
    Player black = new Player("Ole-Martin");
    white = playerRepository.save(white);
    black = playerRepository.save(black);
    Match match = new Match(white, black);
    match.reportResult(Result.WHITE);
    matchRepository.save(match, 1);

    Iterable<Player> players = playerRepository.findAll();
    List<Player> list = new ArrayList<>();
    Iterables.addAll(list, players);

    assertThat(matchRepository.count(), equalTo(1L));
    assertThat(list.size(), equalTo(2));
    players.forEach(System.out::println);
}
 
开发者ID:olemartin,项目名称:chess-tournament,代码行数:19,代码来源:RepositoriesTest.java

示例2: testExplicitBasionyms

import org.neo4j.helpers.collection.Iterables; //导入依赖的package包/类
/**
 * Make sure explicit basionym i.e. original name usage relations make it into the backbone.
 * Dataset 21 contains a conflicting basionym for Martes martes, make sure we use the preferred source dataset 20.
 */
@Test
public void testExplicitBasionyms() throws Exception {
  ClasspathSourceList src = ClasspathSourceList.source(20, 21);
  build(src);

  assertEquals(1, Iterables.count(getCanonical("Mustela martes", Rank.SPECIES).node.getRelationships(RelType.BASIONYM_OF)));
  assertEquals(1, Iterables.count(getCanonical("Martes martes", Rank.SPECIES).node.getRelationships(RelType.BASIONYM_OF)));

  NameUsage u = getUsage(getCanonical("Martes martes", Rank.SPECIES).node);
  assertEquals("Mustela martes Linnaeus, 1758", u.getBasionym());

  u = getUsage(getCanonical("Martes markusis", Rank.SPECIES).node);
  assertEquals("Cellophania markusa Döring, 2001", u.getBasionym());

  u = getUsage(getCanonical("Cellophania markusa", Rank.SPECIES).node);
  assertNull(u.getBasionym());
}
 
开发者ID:gbif,项目名称:checklistbank,代码行数:22,代码来源:NubBuilderIT.java

示例3: testProParteSynonym

import org.neo4j.helpers.collection.Iterables; //导入依赖的package包/类
/**
 * Pro parte synonyms should exist as a single synonym node with multiple synonym relations
 */
@Test
public void testProParteSynonym() throws Exception {
  ClasspathSourceList src = ClasspathSourceList.source(15, 16);
  build(src);

  NubUsage u = assertCanonical("Poa pubescens", "Lej.", null, Rank.SPECIES, Origin.SOURCE, TaxonomicStatus.PROPARTE_SYNONYM, null);
  assertEquals(3, u.sourceIds.size());

  NameUsage nu = dao.readUsage(u.node, true);
  assertEquals("Poa pratensis L.", nu.getAccepted());

  List<Relationship> rels = Iterables.asList(u.node.getRelationships(RelType.PROPARTE_SYNONYM_OF, Direction.OUTGOING));
  Relationship acc = Iterables.single(u.node.getRelationships(RelType.SYNONYM_OF, Direction.OUTGOING));
  assertEquals(1, rels.size());
  assertNotEquals(rels.get(0).getEndNode(), acc.getEndNode());

  assertTree("15 16.txt");
}
 
开发者ID:gbif,项目名称:checklistbank,代码行数:22,代码来源:NubBuilderIT.java

示例4: assertTree

import org.neo4j.helpers.collection.Iterables; //导入依赖的package包/类
private void assertTree(String filename) throws IOException {
  System.out.println("assert tree from " + filename);
  NubTree expected = NubTree.read("trees/" + filename);

  // compare trees
  assertEquals("Number of roots differ", expected.getRoot().children.size(), Iterators.count(dao.allRootTaxa()));
  TreeAsserter treeAssert = new TreeAsserter(expected);
  TreeWalker.walkTree(dao.getNeo(), true, treeAssert);
  assertTrue("There should be more taxa", treeAssert.completed());

  // verify all nodes are walked in the tree and contains the expected numbers
  long neoCnt = Iterables.count(dao.getNeo().getAllNodes());
  // pro parte nodes are counted multiple times, so expected count can be higher than pure number of nodes - but never less!
  System.out.println("expected nodes: " + expected.getCount());
  System.out.println("counted nodes: " + neoCnt);
  assertTrue(expected.getCount() >= neoCnt);
}
 
开发者ID:gbif,项目名称:checklistbank,代码行数:18,代码来源:NubBuilderIT.java

示例5: shouldNotLeaveLuceneIndexFilesHangingAroundIfConstraintCreationFails

import org.neo4j.helpers.collection.Iterables; //导入依赖的package包/类
@Test
public void shouldNotLeaveLuceneIndexFilesHangingAroundIfConstraintCreationFails()
{
    // given
    GraphDatabaseAPI db = dbRule.getGraphDatabaseAPI();

    try ( Transaction tx = db.beginTx() )
    {
        for ( int i = 0; i < 2; i++ )
        {
            Node node1 = db.createNode( LABEL );
            node1.setProperty( "prop", true );
        }

        tx.success();
    }

    // when
    try ( Transaction tx = db.beginTx() )
    {
        db.schema().constraintFor( LABEL ).assertPropertyIsUnique( "prop" ).create();
        fail("Should have failed with ConstraintViolationException");
        tx.success();
    }
    catch ( ConstraintViolationException ignored )  { }

    // then
    try(Transaction ignore = db.beginTx())
    {
        assertEquals(0, Iterables.count(db.schema().getIndexes() ));
    }

    File schemaStorePath = SchemaIndexProvider
            .getRootDirectory( new File( db.getStoreDir() ), LuceneSchemaIndexProviderFactory.KEY );

    String indexId = "1";
    File[] files = new File(schemaStorePath, indexId ).listFiles();
    assertNotNull( files );
    assertEquals(0, files.length);
}
 
开发者ID:neo4j-contrib,项目名称:neo4j-lucene5-index,代码行数:41,代码来源:ConstraintCreationIT.java

示例6: removeNodeFromIndex

import org.neo4j.helpers.collection.Iterables; //导入依赖的package包/类
private void removeNodeFromIndex(Node node, String entityLabel) {
	List<Label> labels = Iterables.asList(node.getLabels());
	if(labels.contains(LABEL_ENTITY_TYPE_CLASS)) {
		graphdb.index().forNodes(ENTITY_TYPE_CLASS).remove(node);
	}
	if(labels.contains(LABEL_PROPERTY_ENTITY_TYPE)) {
		graphdb.index().forNodes(PROPERTY_ENTITY_TYPE).remove(node);
	}
	if(labels.contains(Label.label(entityLabel))) {
		graphdb.index().forNodes(entityLabel).remove(node);
	}
}
 
开发者ID:EsfingeFramework,项目名称:aomrolemapper,代码行数:13,代码来源:Neo4jAOM.java

示例7: findEntityByIDAndEntityType

import org.neo4j.helpers.collection.Iterables; //导入依赖的package包/类
private Node findEntityByIDAndEntityType(Object id, IEntityType entityType) throws EsfingeAOMException {
	ResourceIterator<Node> findNodes = graphdb.findNodes(Label.label(entityType.getName()));
	for (Node entityTypeGraphNode : findNodes.stream().collect(Collectors.toList())) {
		Iterable<Relationship> typeObjectsRelationships = entityTypeGraphNode.getRelationships(RELATIONSHIP_ENTITY_TYPE_OBJECT);
		for (Relationship relationship : Iterables.asList(typeObjectsRelationships)) {
			Node entityGraphNode = relationship.getEndNode();
			if(entityGraphNode.getProperty(ID_FIELD_NAME).equals(id)){
				return entityGraphNode;
			}
		}
	}
	return null;
}
 
开发者ID:EsfingeFramework,项目名称:aomrolemapper,代码行数:14,代码来源:Neo4jAOM.java

示例8: existsRelationshipForPropertyType

import org.neo4j.helpers.collection.Iterables; //导入依赖的package包/类
private boolean existsRelationshipForPropertyType(Node entityTypeGraphNode, String propertyTypeName) {
	List<Relationship> relationships = Iterables.asList(entityTypeGraphNode.getRelationships());
	for (Relationship relationship : relationships) {
		Node propertyTypeGraphNode = relationship.getEndNode();
		if(propertyTypeGraphNode.hasProperty(PROPERTY_TYPE_NAME) &&
		   propertyTypeGraphNode.getProperty(PROPERTY_TYPE_NAME).equals(propertyTypeName)) {
			return true;
		}
	}
	return false;
}
 
开发者ID:EsfingeFramework,项目名称:aomrolemapper,代码行数:12,代码来源:Neo4jAOM.java

示例9: resetPropertiesValues

import org.neo4j.helpers.collection.Iterables; //导入依赖的package包/类
public void resetPropertiesValues() {
	long nodesCount = 0;

	if (graph != null) {
		nodesCount = Iterables.count(GlobalGraphOperations.at(graph).getAllNodes());
	}

	// Tuning
	if (nodesCount >= 100) {
		setScalingRatio(2.0);
	} else {
		setScalingRatio(10.0);
	}
	setStrongGravityMode(false);
	setGravity(1.);

	// Behavior
	setOutboundAttractionDistribution(false);
	setLinLogMode(false);
	setAdjustSizes(false);
	setEdgeWeightInfluence(1.);

	// Performance
	if (nodesCount >= 50000) {
		setJitterTolerance(10d);
	} else if (nodesCount >= 5000) {
		setJitterTolerance(1d);
	} else {
		setJitterTolerance(0.1d);
	}
	if (nodesCount >= 1000) {
		setBarnesHutOptimize(true);
	} else {
		setBarnesHutOptimize(false);
	}
	setBarnesHutTheta(1.2);
	setThreadsCount(2);
}
 
开发者ID:gsummer,项目名称:neoLayouts,代码行数:39,代码来源:ForceAtlas2.java

示例10: parents

import org.neo4j.helpers.collection.Iterables; //导入依赖的package包/类
/**
 * @return the parent (or accepted) nodes for a given node.
 */
public List<Node> parents(Node n) {
  return Iterables.asList(Traversals.PARENTS
      .relationships(RelType.SYNONYM_OF, Direction.OUTGOING)
      .traverse(n)
      .nodes());
}
 
开发者ID:gbif,项目名称:checklistbank,代码行数:10,代码来源:NubDb.java

示例11: testListSources

import org.neo4j.helpers.collection.Iterables; //导入依赖的package包/类
/**
 * Test reading the source list
 */
@Test
public void testListSources() throws Exception {
  List<NubSource> sources = Iterables.asList(src);
  assertEquals(3, sources.size());
  assertEquals(Rank.PHYLUM, sources.get(0).ignoreRanksAbove);
  assertEquals(Rank.FAMILY, sources.get(1).ignoreRanksAbove);
  assertEquals(Rank.FAMILY, sources.get(2).ignoreRanksAbove);
  assertEquals(CHECKLIST_KEY, sources.get(0).key);
  assertEquals(oldDKey, sources.get(1).key);
}
 
开发者ID:gbif,项目名称:checklistbank,代码行数:14,代码来源:ClbSourceListTest.java

示例12: testListSources

import org.neo4j.helpers.collection.Iterables; //导入依赖的package包/类
@Test
public void testListSources() throws Exception {
  ClasspathSourceList src = ClasspathSourceList.source(1, 2, 3, 4, 5, 10, 11, 23, 12, 31);
  src.setSourceRank(23, Rank.KINGDOM);
  List<NubSource> sources = Iterables.asList(src);
  assertEquals(10, sources.size());
  assertEquals(Rank.FAMILY, sources.get(0).ignoreRanksAbove);
  assertEquals(Rank.KINGDOM, sources.get(7).ignoreRanksAbove);
}
 
开发者ID:gbif,项目名称:checklistbank,代码行数:10,代码来源:ClasspathSourceListTest.java

示例13: testNeoIndices

import org.neo4j.helpers.collection.Iterables; //导入依赖的package包/类
@Test
public void testNeoIndices() throws Exception {
  final UUID datasetKey = datasetKey(1);

  Normalizer norm = Normalizer.create(cfg, datasetKey);
  norm.run();

  openDb(datasetKey);
  compareStats(norm.getStats());

  Set<String> taxonIndices = Sets.newHashSet();
  taxonIndices.add(NeoProperties.TAXON_ID);
  taxonIndices.add(NeoProperties.SCIENTIFIC_NAME);
  taxonIndices.add(NeoProperties.CANONICAL_NAME);
  try (Transaction tx = beginTx()) {
    Schema schema = dao.getNeo().schema();
    for (IndexDefinition idf : schema.getIndexes(Labels.TAXON)) {
      List<String> idxProps = Iterables.asList(idf.getPropertyKeys());
      assertTrue(idxProps.size() == 1);
      assertTrue(taxonIndices.remove(idxProps.get(0)));
    }

    assertNotNull(Iterators.singleOrNull(dao.getNeo().findNodes(Labels.TAXON, NeoProperties.TAXON_ID, "1001")));
    assertNotNull(Iterators.singleOrNull(dao.getNeo().findNodes(Labels.TAXON, NeoProperties.SCIENTIFIC_NAME, "Crepis bakeri Greene")));
    assertNotNull(Iterators.singleOrNull(dao.getNeo().findNodes(Labels.TAXON, NeoProperties.CANONICAL_NAME, "Crepis bakeri")));

    assertNull(Iterators.singleOrNull(dao.getNeo().findNodes(Labels.TAXON, NeoProperties.TAXON_ID, "x1001")));
    assertNull(Iterators.singleOrNull(dao.getNeo().findNodes(Labels.TAXON, NeoProperties.SCIENTIFIC_NAME, "xCrepis bakeri Greene")));
    assertNull(Iterators.singleOrNull(dao.getNeo().findNodes(Labels.TAXON, NeoProperties.CANONICAL_NAME, "xCrepis bakeri")));
  }
}
 
开发者ID:gbif,项目名称:checklistbank,代码行数:32,代码来源:NormalizerTest.java

示例14: getSingleRelationship

import org.neo4j.helpers.collection.Iterables; //导入依赖的package包/类
@Override
public Relationship getSingleRelationship(RelationshipType relationshipType, Direction direction) {
    return Iterables.single(getRelationships(relationshipType, direction));
}
 
开发者ID:neo4j-contrib,项目名称:neo4j-ml-procedures,代码行数:5,代码来源:VirtualNode.java

示例15: getDegree

import org.neo4j.helpers.collection.Iterables; //导入依赖的package包/类
@Override
public int getDegree(RelationshipType relationshipType) {
    return (int) Iterables.count(getRelationships(relationshipType));
}
 
开发者ID:neo4j-contrib,项目名称:neo4j-ml-procedures,代码行数:5,代码来源:VirtualNode.java


注:本文中的org.neo4j.helpers.collection.Iterables类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。