use of com.thinkbiganalytics.metadata.api.sla.FeedServiceLevelAgreement in project kylo by Teradata.
the class DefaultServiceLevelAgreementService method getServiceLevelAgreement.
@Override
public ServiceLevelAgreement getServiceLevelAgreement(String slaId) {
com.thinkbiganalytics.metadata.rest.model.sla.FeedServiceLevelAgreement systemSla = findFeedServiceLevelAgreementAsAdmin(slaId, false);
// filter out if this SLA has feeds which the current user cannot access
ServiceLevelAgreement serviceLevelAgreement = metadataAccess.read(() -> {
FeedServiceLevelAgreement agreement = feedSlaProvider.findAgreement(slaProvider.resolve(slaId));
if (agreement != null) {
com.thinkbiganalytics.metadata.rest.model.sla.FeedServiceLevelAgreement entityAccessControlledSla = serviceLevelAgreementTransform.toModel(agreement, false);
if (systemSla.getFeedsCount() == entityAccessControlledSla.getFeedsCount()) {
return entityAccessControlledSla;
}
}
return null;
});
return serviceLevelAgreement;
}
use of com.thinkbiganalytics.metadata.api.sla.FeedServiceLevelAgreement in project kylo by Teradata.
the class DefaultServiceLevelAgreementService method getServiceLevelAgreementAsFormObject.
/**
* get a SLA and convert it to the editable SLA form object
*/
@Override
public ServiceLevelAgreementGroup getServiceLevelAgreementAsFormObject(String slaId) {
com.thinkbiganalytics.metadata.rest.model.sla.FeedServiceLevelAgreement systemSla = findFeedServiceLevelAgreementAsAdmin(slaId, true);
if (systemSla != null) {
return metadataAccess.read(() -> {
// read it in as the current user
FeedServiceLevelAgreement agreement = feedSlaProvider.findAgreement(slaProvider.resolve(slaId));
// ensure the feed count match
if (agreement.getFeeds().size() != systemSla.getFeeds().size()) {
throw new AccessControlException("Unable to access the SLA " + agreement.getName() + ". You dont have proper access to one or more of the feeds associated with this SLA");
}
if (agreement != null) {
com.thinkbiganalytics.metadata.rest.model.sla.FeedServiceLevelAgreement modelSla = serviceLevelAgreementTransform.toModel(agreement, true);
ServiceLevelAgreementMetricTransformerHelper transformer = new ServiceLevelAgreementMetricTransformerHelper();
ServiceLevelAgreementGroup serviceLevelAgreementGroup = transformer.toServiceLevelAgreementGroup(modelSla);
feedManagerFeedService.applyFeedSelectOptions(ServiceLevelAgreementMetricTransformer.instance().findPropertiesForRulesetMatchingRenderTypes(serviceLevelAgreementGroup.getRules(), new String[] { PolicyPropertyTypes.PROPERTY_TYPE.feedChips.name(), PolicyPropertyTypes.PROPERTY_TYPE.feedSelect.name(), PolicyPropertyTypes.PROPERTY_TYPE.currentFeed.name() }));
applyVelocityTemplateSelectionToActionActionItems(serviceLevelAgreementGroup.getActionConfigurations());
serviceLevelAgreementGroup.setCanEdit(modelSla.isCanEdit());
return serviceLevelAgreementGroup;
}
return null;
});
} else {
return null;
}
}
use of com.thinkbiganalytics.metadata.api.sla.FeedServiceLevelAgreement in project kylo by Teradata.
the class JcrFeedSlaTest method testCreateFeedSLAEntity.
@Test
public void testCreateFeedSLAEntity() {
// create 2 feeds
final int numberOfFeeds = 2;
Set<Feed.ID> feedIds = createFeeds(numberOfFeeds);
final String feedSlaTitle = "My New SLA";
final String nonFeedSlaTitle = "No Feed SLA";
ServiceLevelAgreement.ID feedSlaId = createFeedSla(feedIds, feedSlaTitle);
ServiceLevelAgreement.ID nonFeedSla = createGenericSla(nonFeedSlaTitle);
ServiceLevelAgreement.ID slaId = metadata.read(() -> {
JcrFeedServiceLevelAgreementProvider jcrFeedSlaProvider = (JcrFeedServiceLevelAgreementProvider) feedSlaProvider;
// ASSERT everything is good
// Assert query returns the correct result
List<FeedServiceLevelAgreementRelationship> rels = jcrFeedSlaProvider.findAllRelationships();
Assert.assertEquals(rels.size(), 1);
// Assert relationships are correct
JcrFeedServiceLevelAgreementRelationship relationship = (JcrFeedServiceLevelAgreementRelationship) jcrFeedSlaProvider.findRelationship(feedSlaId);
ServiceLevelAgreement feedSla = relationship.getAgreement();
Assert.assertNotNull(feedSla);
List<? extends ServiceLevelAgreement> agreements = slaProvider.getAgreements();
// assert both agreements are there
Assert.assertEquals(agreements.size(), 2);
Set<JcrFeed> feeds = relationship.getPropertyAsSet(JcrFeedServiceLevelAgreementRelationship.FEEDS, JcrFeed.class);
Assert.assertEquals(feeds.size(), numberOfFeeds);
for (JcrFeed feed : feeds) {
Assert.assertTrue(feedIds.contains(feed.getId()));
}
// find it by the SLA now
JcrFeedServiceLevelAgreementRelationship finalFeedSla = (JcrFeedServiceLevelAgreementRelationship) jcrFeedSlaProvider.findRelationship(feedSla.getId());
Assert.assertNotNull(finalFeedSla);
// query for SLA objects and assert the result is correct
List<FeedServiceLevelAgreement> feedAgreements = jcrFeedSlaProvider.findAllAgreements();
Assert.assertEquals(feedAgreements.size(), 1);
int nonFeedSlaCount = 0;
for (FeedServiceLevelAgreement agreement : feedAgreements) {
Set<? extends Feed> slaFeeds = agreement.getFeeds();
String title = agreement.getName();
if (slaFeeds != null) {
Assert.assertEquals(title, feedSlaTitle);
Assert.assertEquals(slaFeeds.size(), numberOfFeeds);
for (Feed feed : slaFeeds) {
Assert.assertTrue(feedIds.contains(feed.getId()));
}
} else {
Assert.assertEquals(title, nonFeedSlaTitle);
nonFeedSlaCount++;
}
}
Assert.assertEquals(nonFeedSlaCount, 0);
// find by Feed
for (Feed.ID feedId : feedIds) {
List<FeedServiceLevelAgreement> feedServiceLevelAgreements = jcrFeedSlaProvider.findFeedServiceLevelAgreements(feedId);
Assert.assertTrue(feedServiceLevelAgreements != null && !feedServiceLevelAgreements.isEmpty());
}
return feedSla.getId();
}, MetadataAccess.SERVICE);
// now remove the feed relationships
boolean removedFeedRelationships = metadata.commit(() -> {
ServiceLevelAgreement sla = slaProvider.getAgreement(slaId);
return feedSlaProvider.removeFeedRelationships(slaId);
}, MetadataAccess.SERVICE);
Assert.assertTrue(removedFeedRelationships);
// query for the feeds related to this SLA and verify there are none
metadata.read(() -> {
FeedServiceLevelAgreement feedServiceLevelAgreement = feedSlaProvider.findAgreement(slaId);
Assert.assertTrue(feedServiceLevelAgreement.getFeeds() == null || (feedServiceLevelAgreement.getFeeds().isEmpty()));
return null;
}, MetadataAccess.SERVICE);
}
Aggregations