use of org.apache.nifi.registry.db.entity.FlowEntity in project nifi-registry by apache.
the class DataModelMapper method map.
// --- Map flows
public static FlowEntity map(final VersionedFlow versionedFlow) {
final FlowEntity flowEntity = new FlowEntity();
flowEntity.setId(versionedFlow.getIdentifier());
flowEntity.setName(versionedFlow.getName());
flowEntity.setDescription(versionedFlow.getDescription());
flowEntity.setCreated(new Date(versionedFlow.getCreatedTimestamp()));
flowEntity.setModified(new Date(versionedFlow.getModifiedTimestamp()));
flowEntity.setType(BucketItemEntityType.FLOW);
return flowEntity;
}
use of org.apache.nifi.registry.db.entity.FlowEntity in project nifi-registry by apache.
the class DatabaseMetadataService method getFlowByIdWithSnapshotCounts.
@Override
public FlowEntity getFlowByIdWithSnapshotCounts(final String flowIdentifier) {
final FlowEntity flowEntity = getFlowById(flowIdentifier);
if (flowEntity == null) {
return flowEntity;
}
final Long snapshotCount = getFlowSnapshotCount(flowIdentifier);
if (snapshotCount != null) {
flowEntity.setSnapshotCount(snapshotCount);
}
return flowEntity;
}
use of org.apache.nifi.registry.db.entity.FlowEntity in project nifi-registry by apache.
the class TestRegistryService method testGetLatestSnapshotMetadataWhenVersionsExist.
@Test
public void testGetLatestSnapshotMetadataWhenVersionsExist() {
final BucketEntity existingBucket = new BucketEntity();
existingBucket.setId("b1");
existingBucket.setName("My Bucket");
existingBucket.setDescription("This is my bucket");
existingBucket.setCreated(new Date());
when(metadataService.getBucketById(existingBucket.getId())).thenReturn(existingBucket);
// return a flow with the existing snapshot when getFlowById is called
final FlowEntity existingFlow = new FlowEntity();
existingFlow.setId("flow1");
existingFlow.setName("My Flow");
existingFlow.setDescription("This is my flow.");
existingFlow.setCreated(new Date());
existingFlow.setModified(new Date());
existingFlow.setBucketId(existingBucket.getId());
when(metadataService.getFlowById(existingFlow.getId())).thenReturn(existingFlow);
final FlowSnapshotEntity existingSnapshot1 = new FlowSnapshotEntity();
existingSnapshot1.setVersion(1);
existingSnapshot1.setFlowId(existingFlow.getId());
existingSnapshot1.setCreatedBy("user1");
existingSnapshot1.setCreated(new Date());
existingSnapshot1.setComments("This is snapshot 1");
when(metadataService.getLatestSnapshot(existingFlow.getId())).thenReturn(existingSnapshot1);
VersionedFlowSnapshotMetadata latestMetadata = registryService.getLatestFlowSnapshotMetadata(existingBucket.getId(), existingFlow.getId());
assertNotNull(latestMetadata);
assertEquals(1, latestMetadata.getVersion());
}
use of org.apache.nifi.registry.db.entity.FlowEntity in project nifi-registry by apache.
the class TestRegistryService method testDeleteBucketWithFlows.
@Test
public void testDeleteBucketWithFlows() {
final BucketEntity bucketToDelete = new BucketEntity();
bucketToDelete.setId("b1");
bucketToDelete.setName("My Bucket");
bucketToDelete.setDescription("This is my bucket");
bucketToDelete.setCreated(new Date());
final FlowEntity flowToDelete = new FlowEntity();
flowToDelete.setId("flow1");
flowToDelete.setName("Flow 1");
flowToDelete.setDescription("This is flow 1");
flowToDelete.setCreated(new Date());
final List<FlowEntity> flows = new ArrayList<>();
flows.add(flowToDelete);
when(metadataService.getBucketById(bucketToDelete.getId())).thenReturn(bucketToDelete);
when(metadataService.getFlowsByBucket(bucketToDelete.getId())).thenReturn(flows);
final Bucket deletedBucket = registryService.deleteBucket(bucketToDelete.getId());
assertNotNull(deletedBucket);
assertEquals(bucketToDelete.getId(), deletedBucket.getIdentifier());
verify(flowPersistenceProvider, times(1)).deleteAllFlowContent(eq(bucketToDelete.getId()), eq(flowToDelete.getId()));
}
use of org.apache.nifi.registry.db.entity.FlowEntity in project nifi-registry by apache.
the class TestRegistryService method createFlowEntity.
private FlowEntity createFlowEntity(final String bucketId) {
final FlowEntity existingFlow = new FlowEntity();
existingFlow.setId("flow1");
existingFlow.setName("My Flow");
existingFlow.setDescription("This is my flow.");
existingFlow.setCreated(new Date());
existingFlow.setModified(new Date());
existingFlow.setBucketId(bucketId);
return existingFlow;
}
Aggregations