Search in sources :

Example 1 with FeedDestination

use of com.thinkbiganalytics.metadata.api.feed.FeedDestination in project kylo by Teradata.

the class BaseFeed method addDestination.

public FeedDestination addDestination(Datasource ds) {
    FeedDestination dest = new Destination(ds);
    this.destinations.add(dest);
    return dest;
}
Also used : FeedDestination(com.thinkbiganalytics.metadata.api.feed.FeedDestination) FeedDestination(com.thinkbiganalytics.metadata.api.feed.FeedDestination)

Example 2 with FeedDestination

use of com.thinkbiganalytics.metadata.api.feed.FeedDestination in project kylo by Teradata.

the class FeedManagerFeedTest method testFeedDatasource.

@Test
public void testFeedDatasource() {
    String categorySystemName = "my_category2";
    String feedName = "my_feed2";
    String templateName = "my_template2";
    String description = " my feed description";
    setupFeedAndTemplate(categorySystemName, feedName, templateName);
    // boolean isDefineTable = true;
    // boolean isGetFile = false;
    metadata.commit(() -> {
        Feed feed = feedTestUtil.findFeed(categorySystemName, feedName);
        Set<Datasource.ID> sources = new HashSet<Datasource.ID>();
        Set<com.thinkbiganalytics.metadata.api.datasource.Datasource.ID> destinations = new HashSet<>();
        // Add Table Dependencies
        String uniqueName = FeedNameUtil.fullName(categorySystemName, feedName);
        DerivedDatasource srcDatasource = datasourceProvider.ensureDatasource(uniqueName, feed.getDescription(), DerivedDatasource.class);
        sources.add(srcDatasource.getId());
        DerivedDatasource destDatasource = datasourceProvider.ensureDatasource("destination", feed.getDescription(), DerivedDatasource.class);
        destinations.add(destDatasource.getId());
        sources.stream().forEach(sourceId -> feedProvider.ensureFeedSource(feed.getId(), sourceId));
        destinations.stream().forEach(destinationId -> feedProvider.ensureFeedDestination(feed.getId(), destinationId));
    }, MetadataAccess.SERVICE);
    // ensure the sources and dest got created
    metadata.read(() -> {
        Feed feed = feedTestUtil.findFeed(categorySystemName, feedName);
        Assert.assertNotNull(feed.getSources());
        Assert.assertTrue(feed.getSources().size() == 1, "Feed Sources should be 1");
        Assert.assertNotNull(feed.getDestinations());
        Assert.assertTrue(feed.getDestinations().size() == 1, "Feed Destinations should be 1");
        List<? extends FeedDestination> feedDestinations = feed.getDestinations();
        if (feedDestinations != null) {
            FeedDestination feedDestination = feedDestinations.get(0);
            Datasource ds = feedDestination.getDatasource().get();
            Assert.assertTrue(ds instanceof DerivedDatasource, "Datasource was not expected DerivedDatasource");
        }
    }, MetadataAccess.SERVICE);
}
Also used : DerivedDatasource(com.thinkbiganalytics.metadata.api.datasource.DerivedDatasource) Datasource(com.thinkbiganalytics.metadata.api.datasource.Datasource) DerivedDatasource(com.thinkbiganalytics.metadata.api.datasource.DerivedDatasource) FeedDestination(com.thinkbiganalytics.metadata.api.feed.FeedDestination) Feed(com.thinkbiganalytics.metadata.api.feed.Feed) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 3 with FeedDestination

use of com.thinkbiganalytics.metadata.api.feed.FeedDestination in project kylo by Teradata.

the class JcrFeedProvider method ensureFeedDestination.

@Override
public FeedDestination ensureFeedDestination(ID feedId, DataSet.ID dsId) {
    JcrFeed feed = (JcrFeed) findById(feedId);
    FeedDestination source = feed.getDestination(dsId);
    if (source == null) {
        return dataSetProvider.find(dsId).map(ds -> feed.ensureFeedDestination((JcrDataSet) ds)).orElseThrow(() -> new DataSetNotFoundException(dsId));
    } else {
        return source;
    }
}
Also used : EntityUtil(com.thinkbiganalytics.metadata.modeshape.common.EntityUtil) Category(com.thinkbiganalytics.metadata.api.category.Category) DatasourceNotFoundException(com.thinkbiganalytics.metadata.api.datasource.DatasourceNotFoundException) ChangeType(com.thinkbiganalytics.metadata.api.event.MetadataChange.ChangeType) Metric(com.thinkbiganalytics.metadata.sla.api.Metric) Obligation(com.thinkbiganalytics.metadata.sla.api.Obligation) FeedProvider(com.thinkbiganalytics.metadata.api.feed.FeedProvider) SecurityRole(com.thinkbiganalytics.security.role.SecurityRole) FeedAccessControl(com.thinkbiganalytics.metadata.api.feed.security.FeedAccessControl) Map(java.util.Map) FeedPropertyChangeEvent(com.thinkbiganalytics.metadata.api.event.feed.FeedPropertyChangeEvent) AccessController(com.thinkbiganalytics.security.AccessController) SecurityContextHolder(org.springframework.security.core.context.SecurityContextHolder) Path(java.nio.file.Path) CategoryNotFoundException(com.thinkbiganalytics.metadata.api.category.CategoryNotFoundException) CategoryDetails(com.thinkbiganalytics.metadata.modeshape.category.CategoryDetails) Session(javax.jcr.Session) FeedOpsAccessControlProvider(com.thinkbiganalytics.metadata.api.feed.security.FeedOpsAccessControlProvider) Set(java.util.Set) MetadataEventService(com.thinkbiganalytics.metadata.api.event.MetadataEventService) FeedCriteria(com.thinkbiganalytics.metadata.api.feed.FeedCriteria) Serializable(java.io.Serializable) Predicate(com.google.common.base.Predicate) CategoryProvider(com.thinkbiganalytics.metadata.api.category.CategoryProvider) JcrServiceLevelAgreement(com.thinkbiganalytics.metadata.modeshape.sla.JcrServiceLevelAgreement) DraftVersionProviderMixin(com.thinkbiganalytics.metadata.modeshape.common.mixin.DraftVersionProviderMixin) JcrAllowedActions(com.thinkbiganalytics.metadata.modeshape.security.action.JcrAllowedActions) PropertyChange(com.thinkbiganalytics.metadata.api.event.feed.PropertyChange) JcrMetadataAccess(com.thinkbiganalytics.metadata.modeshape.JcrMetadataAccess) NodeIterator(javax.jcr.NodeIterator) JcrEntity(com.thinkbiganalytics.metadata.modeshape.common.JcrEntity) MetadataRepositoryException(com.thinkbiganalytics.metadata.modeshape.MetadataRepositoryException) ServiceLevelAgreementBuilder(com.thinkbiganalytics.metadata.sla.spi.ServiceLevelAgreementBuilder) ArrayList(java.util.ArrayList) Strings(com.google.common.base.Strings) Datasource(com.thinkbiganalytics.metadata.api.datasource.Datasource) JcrChangeComment(com.thinkbiganalytics.metadata.modeshape.template.JcrChangeComment) FeedManagerTemplate(com.thinkbiganalytics.metadata.api.template.FeedManagerTemplate) HadoopSecurityGroup(com.thinkbiganalytics.metadata.api.security.HadoopSecurityGroup) ID(com.thinkbiganalytics.metadata.api.feed.Feed.ID) JcrUtil(com.thinkbiganalytics.metadata.modeshape.support.JcrUtil) JcrObject(com.thinkbiganalytics.metadata.modeshape.common.JcrObject) DatasourceProvider(com.thinkbiganalytics.metadata.api.datasource.DatasourceProvider) VersionProviderMixin(com.thinkbiganalytics.metadata.modeshape.common.mixin.VersionProviderMixin) Version(javax.jcr.version.Version) ServiceLevelAgreementActionConfiguration(com.thinkbiganalytics.metadata.sla.api.ServiceLevelAgreementActionConfiguration) QueryResult(javax.jcr.query.QueryResult) FeedChange(com.thinkbiganalytics.metadata.api.event.feed.FeedChange) ChangeComment(com.thinkbiganalytics.metadata.api.template.ChangeComment) JcrPropertyConstants(com.thinkbiganalytics.metadata.modeshape.common.JcrPropertyConstants) AbstractMetadataCriteria(com.thinkbiganalytics.metadata.modeshape.AbstractMetadataCriteria) DataSetProvider(com.thinkbiganalytics.metadata.api.catalog.DataSetProvider) JcrQueryUtil(com.thinkbiganalytics.metadata.modeshape.support.JcrQueryUtil) JcrDatasource(com.thinkbiganalytics.metadata.modeshape.datasource.JcrDatasource) Pageable(org.springframework.data.domain.Pageable) UserFieldDescriptors(com.thinkbiganalytics.metadata.modeshape.common.UserFieldDescriptors) JcrAllowedEntityActionsProvider(com.thinkbiganalytics.metadata.modeshape.security.action.JcrAllowedEntityActionsProvider) ServiceLevelAgreement(com.thinkbiganalytics.metadata.sla.api.ServiceLevelAgreement) FeedDestination(com.thinkbiganalytics.metadata.api.feed.FeedDestination) PreconditionBuilder(com.thinkbiganalytics.metadata.api.feed.PreconditionBuilder) DataSetNotFoundException(com.thinkbiganalytics.metadata.api.catalog.DataSetNotFoundException) Collectors(java.util.stream.Collectors) SecurityRoleProvider(com.thinkbiganalytics.security.role.SecurityRoleProvider) List(java.util.List) Principal(java.security.Principal) AccessControlException(java.security.AccessControlException) Optional(java.util.Optional) BaseJcrProvider(com.thinkbiganalytics.metadata.modeshape.BaseJcrProvider) Feed(com.thinkbiganalytics.metadata.api.feed.Feed) DataSet(com.thinkbiganalytics.metadata.api.catalog.DataSet) HashMap(java.util.HashMap) VersionNotFoundException(com.thinkbiganalytics.metadata.api.versioning.VersionNotFoundException) EntityVersion(com.thinkbiganalytics.metadata.api.versioning.EntityVersion) AllowedActions(com.thinkbiganalytics.security.action.AllowedActions) HashSet(java.util.HashSet) Inject(javax.inject.Inject) JcrDataSet(com.thinkbiganalytics.metadata.modeshape.catalog.dataset.JcrDataSet) ObligationGroupBuilder(com.thinkbiganalytics.metadata.sla.spi.ObligationGroupBuilder) RepositoryException(javax.jcr.RepositoryException) JcrVersionUtil(com.thinkbiganalytics.metadata.modeshape.support.JcrVersionUtil) Node(javax.jcr.Node) FeedChangeEvent(com.thinkbiganalytics.metadata.api.event.feed.FeedChangeEvent) FeedSource(com.thinkbiganalytics.metadata.api.feed.FeedSource) VersionAlreadyExistsException(com.thinkbiganalytics.metadata.api.versioning.VersionAlreadyExistsException) JcrEntityVersion(com.thinkbiganalytics.metadata.modeshape.versioning.JcrEntityVersion) Nonnull(javax.annotation.Nonnull) FeedNotFoundException(com.thinkbiganalytics.metadata.api.feed.FeedNotFoundException) FeedNameUtil(com.thinkbiganalytics.support.FeedNameUtil) DateTime(org.joda.time.DateTime) ServiceLevelAgreementProvider(com.thinkbiganalytics.metadata.sla.spi.ServiceLevelAgreementProvider) UserFieldDescriptor(com.thinkbiganalytics.metadata.api.extension.UserFieldDescriptor) JcrServiceLevelAgreementProvider(com.thinkbiganalytics.metadata.modeshape.sla.JcrServiceLevelAgreementProvider) Consumer(java.util.function.Consumer) JcrCategory(com.thinkbiganalytics.metadata.modeshape.category.JcrCategory) Condition(com.thinkbiganalytics.metadata.sla.api.ObligationGroup.Condition) ObligationBuilder(com.thinkbiganalytics.metadata.sla.spi.ObligationBuilder) RoleMembership(com.thinkbiganalytics.security.role.RoleMembership) Collections(java.util.Collections) FeedDestination(com.thinkbiganalytics.metadata.api.feed.FeedDestination) DataSetNotFoundException(com.thinkbiganalytics.metadata.api.catalog.DataSetNotFoundException)

Example 4 with FeedDestination

use of com.thinkbiganalytics.metadata.api.feed.FeedDestination in project kylo by Teradata.

the class JcrFeedProvider method ensureFeedDestination.

@Override
public FeedDestination ensureFeedDestination(Feed.ID feedId, com.thinkbiganalytics.metadata.api.datasource.Datasource.ID dsId) {
    JcrFeed feed = (JcrFeed) findById(feedId);
    FeedDestination source = feed.getDestination(dsId);
    if (source == null) {
        JcrDatasource datasource = (JcrDatasource) datasourceProvider.getDatasource(dsId);
        if (datasource != null) {
            JcrFeedDestination jcrDest = feed.ensureFeedDestination(datasource);
            // save();
            return jcrDest;
        } else {
            throw new DatasourceNotFoundException(dsId);
        }
    } else {
        return source;
    }
}
Also used : JcrDatasource(com.thinkbiganalytics.metadata.modeshape.datasource.JcrDatasource) FeedDestination(com.thinkbiganalytics.metadata.api.feed.FeedDestination) DatasourceNotFoundException(com.thinkbiganalytics.metadata.api.datasource.DatasourceNotFoundException)

Example 5 with FeedDestination

use of com.thinkbiganalytics.metadata.api.feed.FeedDestination in project kylo by Teradata.

the class JcrDatasource method setDestinations.

public void setDestinations(List<FeedDestination> destinations) {
    JcrPropertyUtil.setProperty(getNode(), DESTINATION_NAME, null);
    for (FeedDestination dest : destinations) {
        Node destNode = ((JcrFeedSource) dest).getNode();
        addDestinationNode(destNode);
    }
}
Also used : FeedDestination(com.thinkbiganalytics.metadata.api.feed.FeedDestination) JcrFeedDestination(com.thinkbiganalytics.metadata.modeshape.feed.JcrFeedDestination) Node(javax.jcr.Node) JcrFeedSource(com.thinkbiganalytics.metadata.modeshape.feed.JcrFeedSource)

Aggregations

FeedDestination (com.thinkbiganalytics.metadata.api.feed.FeedDestination)6 DataSetNotFoundException (com.thinkbiganalytics.metadata.api.catalog.DataSetNotFoundException)3 DataSetProvider (com.thinkbiganalytics.metadata.api.catalog.DataSetProvider)3 Category (com.thinkbiganalytics.metadata.api.category.Category)3 CategoryProvider (com.thinkbiganalytics.metadata.api.category.CategoryProvider)3 Datasource (com.thinkbiganalytics.metadata.api.datasource.Datasource)3 Feed (com.thinkbiganalytics.metadata.api.feed.Feed)3 HashSet (java.util.HashSet)3 DatasourceNotFoundException (com.thinkbiganalytics.metadata.api.datasource.DatasourceNotFoundException)2 DerivedDatasource (com.thinkbiganalytics.metadata.api.datasource.DerivedDatasource)2 MetadataEventService (com.thinkbiganalytics.metadata.api.event.MetadataEventService)2 FeedChange (com.thinkbiganalytics.metadata.api.event.feed.FeedChange)2 FeedChangeEvent (com.thinkbiganalytics.metadata.api.event.feed.FeedChangeEvent)2 FeedPropertyChangeEvent (com.thinkbiganalytics.metadata.api.event.feed.FeedPropertyChangeEvent)2 UserFieldDescriptor (com.thinkbiganalytics.metadata.api.extension.UserFieldDescriptor)2 FeedNotFoundException (com.thinkbiganalytics.metadata.api.feed.FeedNotFoundException)2 FeedProvider (com.thinkbiganalytics.metadata.api.feed.FeedProvider)2 FeedSource (com.thinkbiganalytics.metadata.api.feed.FeedSource)2 FeedAccessControl (com.thinkbiganalytics.metadata.api.feed.security.FeedAccessControl)2 HadoopSecurityGroup (com.thinkbiganalytics.metadata.api.security.HadoopSecurityGroup)2