@Test public void shouldFindLinkPropsByDestEndpoint() { createLinkProps(2); List<LinkProps> foundLinkProps = Lists.newArrayList( linkPropsRepository.findByEndpoints(null, null, TEST_SWITCH_B_ID, 2)); assertThat(foundLinkProps, Matchers.hasSize(1)); }
@Override public Collection<LinkProps> findByEndpoints(SwitchId srcSwitch, Integer srcPort, SwitchId dstSwitch, Integer dstPort) { return framedGraph().traverse(g -> { GraphTraversal<Vertex, Vertex> traversal = g.V() .hasLabel(LinkPropsFrame.FRAME_LABEL); if (srcSwitch != null) { traversal = traversal.has(LinkPropsFrame.SRC_SWITCH_PROPERTY, SwitchIdConverter.INSTANCE.toGraphProperty(srcSwitch)); } if (srcPort != null) { traversal = traversal.has(LinkPropsFrame.SRC_PORT_PROPERTY, srcPort); } if (dstSwitch != null) { traversal = traversal.has(LinkPropsFrame.DST_SWITCH_PROPERTY, SwitchIdConverter.INSTANCE.toGraphProperty(dstSwitch)); } if (dstPort != null) { traversal = traversal.has(LinkPropsFrame.DST_PORT_PROPERTY, dstPort); } return traversal; }).toListExplicit(LinkPropsFrame.class).stream() .map(LinkProps::new) .collect(Collectors.toList()); }
FermaLinkPropsRepository extends FermaGenericRepository<LinkProps, LinkPropsData, LinkPropsFrame> implements LinkPropsRepository { @Override public Collection<LinkProps> findByEndpoints(SwitchId srcSwitch, Integer srcPort, SwitchId dstSwitch, Integer dstPort) { return framedGraph().traverse(g -> { GraphTraversal<Vertex, Vertex> traversal = g.V() .hasLabel(LinkPropsFrame.FRAME_LABEL); if (srcSwitch != null) { traversal = traversal.has(LinkPropsFrame.SRC_SWITCH_PROPERTY, SwitchIdConverter.INSTANCE.toGraphProperty(srcSwitch)); } if (srcPort != null) { traversal = traversal.has(LinkPropsFrame.SRC_PORT_PROPERTY, srcPort); } if (dstSwitch != null) { traversal = traversal.has(LinkPropsFrame.DST_SWITCH_PROPERTY, SwitchIdConverter.INSTANCE.toGraphProperty(dstSwitch)); } if (dstPort != null) { traversal = traversal.has(LinkPropsFrame.DST_PORT_PROPERTY, dstPort); } return traversal; }).toListExplicit(LinkPropsFrame.class).stream() .map(LinkProps::new) .collect(Collectors.toList()); } }
FermaLinkPropsRepository extends FermaGenericRepository<LinkProps, LinkPropsData, LinkPropsFrame> implements LinkPropsRepository { @Override public Collection<LinkProps> findByEndpoints(SwitchId srcSwitch, Integer srcPort, SwitchId dstSwitch, Integer dstPort) { return framedGraph().traverse(g -> { GraphTraversal<Vertex, Vertex> traversal = g.V() .hasLabel(LinkPropsFrame.FRAME_LABEL); if (srcSwitch != null) { traversal = traversal.has(LinkPropsFrame.SRC_SWITCH_PROPERTY, SwitchIdConverter.INSTANCE.toGraphProperty(srcSwitch)); } if (srcPort != null) { traversal = traversal.has(LinkPropsFrame.SRC_PORT_PROPERTY, srcPort); } if (dstSwitch != null) { traversal = traversal.has(LinkPropsFrame.DST_SWITCH_PROPERTY, SwitchIdConverter.INSTANCE.toGraphProperty(dstSwitch)); } if (dstPort != null) { traversal = traversal.has(LinkPropsFrame.DST_PORT_PROPERTY, dstPort); } return traversal; }).toListExplicit(LinkPropsFrame.class).stream() .map(LinkProps::new) .collect(Collectors.toList()); } FermaLinkPropsRepository(FramedGraphFactory<?> graphFactory, TransactionManager transactionManager); }
FermaLinkPropsRepository extends FermaGenericRepository<LinkProps, LinkPropsData, LinkPropsFrame> implements LinkPropsRepository { @Override public Collection<LinkProps> findByEndpoints(SwitchId srcSwitch, Integer srcPort, SwitchId dstSwitch, Integer dstPort) { return framedGraph().traverse(g -> { GraphTraversal<Vertex, Vertex> traversal = g.V() .hasLabel(LinkPropsFrame.FRAME_LABEL); if (srcSwitch != null) { traversal = traversal.has(LinkPropsFrame.SRC_SWITCH_PROPERTY, SwitchIdConverter.INSTANCE.toGraphProperty(srcSwitch)); } if (srcPort != null) { traversal = traversal.has(LinkPropsFrame.SRC_PORT_PROPERTY, srcPort); } if (dstSwitch != null) { traversal = traversal.has(LinkPropsFrame.DST_SWITCH_PROPERTY, SwitchIdConverter.INSTANCE.toGraphProperty(dstSwitch)); } if (dstPort != null) { traversal = traversal.has(LinkPropsFrame.DST_PORT_PROPERTY, dstPort); } return traversal; }).toListExplicit(LinkPropsFrame.class).stream() .map(LinkProps::new) .collect(Collectors.toList()); } FermaLinkPropsRepository(FramedGraphFactory<?> graphFactory, TransactionManager transactionManager); @Override Collection<LinkProps> findAll(); @Override Collection<LinkProps> findByEndpoints(SwitchId srcSwitch, Integer srcPort,
                                                 SwitchId dstSwitch, Integer dstPort); }
FermaLinkPropsRepository extends FermaGenericRepository<LinkProps, LinkPropsData, LinkPropsFrame> implements LinkPropsRepository { @Override public Collection<LinkProps> findByEndpoints(SwitchId srcSwitch, Integer srcPort, SwitchId dstSwitch, Integer dstPort) { return framedGraph().traverse(g -> { GraphTraversal<Vertex, Vertex> traversal = g.V() .hasLabel(LinkPropsFrame.FRAME_LABEL); if (srcSwitch != null) { traversal = traversal.has(LinkPropsFrame.SRC_SWITCH_PROPERTY, SwitchIdConverter.INSTANCE.toGraphProperty(srcSwitch)); } if (srcPort != null) { traversal = traversal.has(LinkPropsFrame.SRC_PORT_PROPERTY, srcPort); } if (dstSwitch != null) { traversal = traversal.has(LinkPropsFrame.DST_SWITCH_PROPERTY, SwitchIdConverter.INSTANCE.toGraphProperty(dstSwitch)); } if (dstPort != null) { traversal = traversal.has(LinkPropsFrame.DST_PORT_PROPERTY, dstPort); } return traversal; }).toListExplicit(LinkPropsFrame.class).stream() .map(LinkProps::new) .collect(Collectors.toList()); } FermaLinkPropsRepository(FramedGraphFactory<?> graphFactory, TransactionManager transactionManager); @Override Collection<LinkProps> findAll(); @Override Collection<LinkProps> findByEndpoints(SwitchId srcSwitch, Integer srcPort,
                                                 SwitchId dstSwitch, Integer dstPort);  }