@Override public int compareTo( final Id o ) { int compare = UUIDComparator.staticCompare( uuid, o.getUuid() ); if(compare == 0){ compare = type.compareTo( o.getType() ); } return compare; } }
@Override protected ByteBuffer getPartitionKey(Id applicationId, String entityType, String fieldType, String fieldName, Object fieldValue ){ return serializeKey(applicationId.getUuid(), applicationId.getType(), entityType, fieldType, fieldName, fieldValue); }
@Override protected ByteBuffer getPartitionKey(Id applicationId, String entityType, String fieldType, String fieldName, Object fieldValue ){ return serializeKey(applicationId.getUuid(), applicationId.getType(), entityType, fieldType, fieldName, fieldValue); }
@Override public void queueNewEdge(final ApplicationScope applicationScope, final Id entityId, final Edge newEdge, QueueIndexingStrategy queueIndexingStrategy) { if (logger.isTraceEnabled()) { logger.trace("Offering EdgeIndexEvent for edge type {} entity {}:{}", newEdge.getType(), entityId.getUuid(), entityId.getType()); } offer( new EdgeIndexEvent( queueFig.getPrimaryRegion(), applicationScope, entityId, newEdge ), queueIndexingStrategy); }
/** * Missing fields */ private static Id nullEntityId() { final Id entityId = mock( Id.class ); when( entityId.getUuid() ).thenReturn( null ); when( entityId.getType() ).thenReturn( "test" ); return entityId; }
/** Incorrect fields */ private static MvccEntity wrongUuidType() { final Id id = mock( Id.class ); when( id.getUuid() ).thenReturn( UUIDGenerator.newTimeUUID() ); when( id.getType() ).thenReturn( "test" ); final MvccEntity entity = mock( MvccEntity.class ); when( entity.getId() ).thenReturn( id ); when( entity.getVersion() ).thenReturn( UUID.randomUUID() ); return entity; }
private static MvccEntity invalidId() { final Id id = mock( Id.class ); when( id.getUuid() ).thenReturn( UUIDGenerator.newTimeUUID() ); when( id.getType() ).thenReturn( "" ); final MvccEntity entity = mock( MvccEntity.class ); when( entity.getId() ).thenReturn( id ); when( entity.getVersion() ).thenReturn( UUID.randomUUID() ); return entity; }
@Before public void setup() { scope = mock( ApplicationScope.class ); Id orgId = mock( Id.class ); when( orgId.getType() ).thenReturn( "organization" ); when( orgId.getUuid() ).thenReturn( UUIDGenerator.newTimeUUID() ); when( scope.getApplication() ).thenReturn( orgId ); }
@Before public void setup() { scope = mock( ApplicationScope.class ); Id orgId = mock( Id.class ); when( orgId.getType() ).thenReturn( "organization" ); when( orgId.getUuid() ).thenReturn( UUIDGenerator.newTimeUUID() ); when( scope.getApplication() ).thenReturn( orgId ); }
@Before public void setup() { scope = mock( ApplicationScope.class ); Id orgId = mock( Id.class ); when( orgId.getType() ).thenReturn( "organization" ); when( orgId.getUuid() ).thenReturn( UUIDGenerator.newTimeUUID() ); when( scope.getApplication() ).thenReturn( orgId ); }
@Before public void mockApp() { this.scope = mock( ApplicationScope.class ); Id orgId = mock( Id.class ); when( orgId.getType() ).thenReturn( "organization" ); when( orgId.getUuid() ).thenReturn( UUIDGenerator.newTimeUUID() ); when( this.scope.getApplication() ).thenReturn( orgId ); }
public Entity convertMvccEntityToEntity( org.apache.usergrid.persistence.model.entity.Entity entity){ if(entity == null) { return null; } Class clazz = Schema.getDefaultSchema().getEntityClass(entity.getId().getType()); Entity oldFormatEntity = EntityFactory.newEntity(entity.getId().getUuid(), entity.getId().getType(), clazz); oldFormatEntity.setProperties(CpEntityMapUtils.toMap(entity)); return oldFormatEntity; }
@Override public MutationBatch removeIdTypeToTarget( final ApplicationScope scope, final Edge edge ) { return removeIdTypeToTarget( scope, edge.getTargetNode(), edge.getType(), edge.getSourceNode().getType(), edge.getTimestamp() ); }
@Override public void queueInitializeApplicationIndex( final ApplicationScope applicationScope) { IndexLocationStrategy indexLocationStrategy = indexLocationStrategyFactory.getIndexLocationStrategy( applicationScope); if (logger.isTraceEnabled()) { logger.trace("Offering InitializeApplicationIndexEvent for {}:{}", applicationScope.getApplication().getUuid(), applicationScope.getApplication().getType()); } offerTopic( new InitializeApplicationIndexEvent( queueFig.getPrimaryRegion(), new ReplicatedIndexLocationStrategy( indexLocationStrategy ) ), AsyncEventQueueType.REGULAR); }
@Override public void queueEntityIndexUpdate(final ApplicationScope applicationScope, final Entity entity, long updatedAfter, QueueIndexingStrategy queueIndexingStrategy) { if (logger.isTraceEnabled()) { logger.trace("Offering EntityIndexEvent for {}:{}", entity.getId().getUuid(), entity.getId().getType()); } EntityIndexEvent event = new EntityIndexEvent(queueFig.getPrimaryRegion(), new EntityIdScope(applicationScope, entity.getId()), updatedAfter); offer(event, queueIndexingStrategy); }
@Override public MutationBatch removeIdTypeFromSource( final ApplicationScope scope, final Edge edge ) { return removeIdTypeFromSource( scope, edge.getSourceNode(), edge.getType(), edge.getTargetNode().getType(), edge.getTimestamp() ); }
@Override public MutationBatch removeIdTypeToTarget( final ApplicationScope scope, final Edge edge ) { return removeIdTypeToTarget( scope, edge.getTargetNode(), edge.getType(), edge.getSourceNode().getType(), edge.getTimestamp() ); }
@Override public ByteBuffer toByteBuffer(final EntityVersion ev) { final UUID entityVersion = ev.getEntityVersion(); final Id entityId = ev.getEntityId(); final UUID entityUuid = entityId.getUuid(); final String entityType = entityId.getType(); CompositeBuilder builder = Composites.newDynamicCompositeBuilder(); builder.addUUID( entityVersion ); builder.addUUID( entityUuid ); builder.addString(entityType ); return builder.build(); }
@Test public void testCreateContextName() throws Exception { final ApplicationScopeImpl applicationScope = new ApplicationScopeImpl( new SimpleId( "application" ) ); final SearchEdgeImpl searchEdge = new SearchEdgeImpl( new SimpleId( "source" ), "users", SearchEdge.NodeType.TARGET ); final String output = IndexingUtils.createContextName( applicationScope, searchEdge ); final String expected = "appId(" + applicationScope.getApplication().getUuid() + ",application).nodeId(" + searchEdge.getNodeId() .getUuid() + "," + searchEdge.getNodeId().getType() + ").edgeName(users)"; assertEquals( output, expected ); }