use of com.thinkbiganalytics.discovery.model.DefaultTag in project kylo by Teradata.
the class FeedModelTransform method domainToFeedMetadata.
/**
* Transforms the specified Metadata feed to a Feed Manager feed.
*
* @param domain the Metadata feed
* @param userFieldMap cache map from category to user-defined fields, or {@code null}
* @return the Feed Manager feed
*/
@Nonnull
private FeedMetadata domainToFeedMetadata(@Nonnull final Feed domain, @Nullable final Map<Category, Set<UserFieldDescriptor>> userFieldMap) {
FeedMetadata feed = deserializeFeedMetadata(domain, false);
feed.setId(domain.getId().toString());
feed.setFeedId(domain.getId().toString());
feed.setFeedName(domain.getDisplayName());
feed.setSystemFeedName(domain.getName());
feed.setDescription(domain.getDescription());
feed.setAllowIndexing(domain.isAllowIndexing());
feed.setHistoryReindexingStatus(domain.getCurrentHistoryReindexingStatus().getHistoryReindexingState().toString());
feed.setOwner(domain.getOwner() != null ? new User(domain.getOwner().getName()) : null);
if (domain.getCreatedTime() != null) {
feed.setCreateDate(domain.getCreatedTime().toDate());
}
if (domain.getModifiedTime() != null) {
feed.setUpdateDate(domain.getModifiedTime().toDate());
}
FeedManagerTemplate template = domain.getTemplate();
if (template != null) {
RegisteredTemplate registeredTemplate = templateModelTransform.DOMAIN_TO_REGISTERED_TEMPLATE.apply(template);
feed.setRegisteredTemplate(registeredTemplate);
feed.setTemplateId(registeredTemplate.getId());
feed.setTemplateName(registeredTemplate.getTemplateName());
}
Category category = domain.getCategory();
if (category != null) {
feed.setCategory(categoryModelTransform.domainToFeedCategorySimple(category));
}
feed.setState(domain.getState() != null ? domain.getState().name() : null);
feed.setVersionName(domain.getVersionName() != null ? domain.getVersionName() : null);
// Set user-defined properties
final Set<UserFieldDescriptor> userFields;
if (userFieldMap == null) {
userFields = getUserFields(category);
} else if (userFieldMap.containsKey(category)) {
userFields = userFieldMap.get(category);
} else {
userFields = getUserFields(category);
userFieldMap.put(category, userFields);
}
@SuppressWarnings("unchecked") final Set<UserProperty> userProperties = UserPropertyTransform.toUserProperties(domain.getUserProperties(), userFields);
feed.setUserProperties(userProperties);
// Convert JCR securitygroup to DTO
List<com.thinkbiganalytics.feedmgr.rest.model.HadoopSecurityGroup> restSecurityGroups = new ArrayList<>();
if (domain.getSecurityGroups() != null && domain.getSecurityGroups().size() > 0) {
for (Object group : domain.getSecurityGroups()) {
HadoopSecurityGroup hadoopSecurityGroup = (HadoopSecurityGroup) group;
com.thinkbiganalytics.feedmgr.rest.model.HadoopSecurityGroup restSecurityGroup = new com.thinkbiganalytics.feedmgr.rest.model.HadoopSecurityGroup();
restSecurityGroup.setDescription(hadoopSecurityGroup.getDescription());
restSecurityGroup.setId(hadoopSecurityGroup.getGroupId());
restSecurityGroup.setName(hadoopSecurityGroup.getName());
restSecurityGroups.add(restSecurityGroup);
}
}
feed.setSecurityGroups(restSecurityGroups);
feed.setTags(domain.getTags().stream().map(name -> new DefaultTag(name)).collect(Collectors.toList()));
if (domain.getUsedByFeeds() != null) {
final List<FeedSummary> usedByFeeds = domain.getUsedByFeeds().stream().map(this::domainToFeedSummary).collect(Collectors.toList());
feed.setUsedByFeeds(usedByFeeds);
}
// add in access control items
securityTransform.applyAccessControl(domain, feed);
return feed;
}
use of com.thinkbiganalytics.discovery.model.DefaultTag in project kylo by Teradata.
the class FeedModelTransform method domainToFeedMetadata.
/**
* Transforms the specified Metadata feed to a Feed Manager feed.
*
* @param domain the Metadata feed
* @param userFieldMap cache map from category to user-defined fields, or {@code null}
* @return the Feed Manager feed
*/
@Nonnull
private FeedMetadata domainToFeedMetadata(@Nonnull final Feed domain, @Nullable final Map<Category, Set<UserFieldDescriptor>> userFieldMap, @Nullable ActionGroup actionGroup) {
FeedMetadata feed = deserializeFeedMetadata(domain, false);
feed.setId(domain.getId().toString());
feed.setFeedId(domain.getId().toString());
feed.setFeedName(domain.getDisplayName());
feed.setSystemFeedName(domain.getName());
feed.setDescription(domain.getDescription());
feed.setAllowIndexing(domain.isAllowIndexing());
feed.setHistoryReindexingStatus(domain.getCurrentHistoryReindexingStatus().getHistoryReindexingState().toString());
feed.setOwner(domain.getOwner() != null ? new User(domain.getOwner().getName()) : null);
if (domain.getCreatedTime() != null) {
feed.setCreateDate(domain.getCreatedTime().toDate());
}
if (domain.getModifiedTime() != null) {
feed.setUpdateDate(domain.getModifiedTime().toDate());
}
setFeedMetadataRegisteredTemplate(domain, feed);
Category category = domain.getCategory();
if (category != null) {
feed.setCategory(categoryModelTransform.domainToFeedCategorySimple(category));
}
feed.setState(domain.getState() != null ? domain.getState().name() : null);
// Set user-defined properties
final Set<UserFieldDescriptor> userFields;
if (userFieldMap == null) {
userFields = getUserFields(category);
} else if (userFieldMap.containsKey(category)) {
userFields = userFieldMap.get(category);
} else {
userFields = getUserFields(category);
userFieldMap.put(category, userFields);
}
@SuppressWarnings("unchecked") final Set<UserProperty> userProperties = UserPropertyTransform.toUserProperties(domain.getUserProperties(), userFields);
feed.setUserProperties(userProperties);
// Convert JCR securitygroup to DTO
List<com.thinkbiganalytics.feedmgr.rest.model.HadoopSecurityGroup> restSecurityGroups = new ArrayList<>();
if (domain.getSecurityGroups() != null && domain.getSecurityGroups().size() > 0) {
for (Object group : domain.getSecurityGroups()) {
HadoopSecurityGroup hadoopSecurityGroup = (HadoopSecurityGroup) group;
com.thinkbiganalytics.feedmgr.rest.model.HadoopSecurityGroup restSecurityGroup = new com.thinkbiganalytics.feedmgr.rest.model.HadoopSecurityGroup();
restSecurityGroup.setDescription(hadoopSecurityGroup.getDescription());
restSecurityGroup.setId(hadoopSecurityGroup.getGroupId());
restSecurityGroup.setName(hadoopSecurityGroup.getName());
restSecurityGroups.add(restSecurityGroup);
}
}
feed.setSecurityGroups(restSecurityGroups);
feed.setTags(domain.getTags().stream().map(name -> new DefaultTag(name)).collect(Collectors.toList()));
if (domain.getUsedByFeeds() != null) {
final List<FeedSummary> usedByFeeds = domain.getUsedByFeeds().stream().map(this::domainToFeedSummary).collect(Collectors.toList());
feed.setUsedByFeeds(usedByFeeds);
}
List<DataSet> srcDataSets = domain.getSources().stream().map(FeedConnection::getDataSet).filter(Optional::isPresent).map(Optional::get).map(dataSet -> {
try {
return catalogModelTransform.dataSetToRestModel().apply(dataSet);
} catch (final AccessControlException e) {
log.debug("Denied access to data set: {}: {}", domain.getId(), e);
final DataSource dataSource = new DataSource();
dataSource.setAllowedActions(new ActionGroup());
dataSource.getAllowedActions().setActions(Collections.emptyList());
final DataSet model = new DataSet();
model.setId(domain.getId().toString());
model.setDataSource(dataSource);
return model;
}
}).collect(Collectors.toList());
feed.setSourceDataSets(srcDataSets);
if (actionGroup == null) {
// add in access control items
securityTransform.applyAccessControl(domain, feed);
} else {
feed.setAllowedActions(actionGroup);
}
return feed;
}
use of com.thinkbiganalytics.discovery.model.DefaultTag in project kylo by Teradata.
the class AvroFeedIT method getTags.
protected List<Tag> getTags() {
List<Tag> tags = new ArrayList<>();
tags.add(new DefaultTag("users"));
tags.add(new DefaultTag("registrations"));
return tags;
}
use of com.thinkbiganalytics.discovery.model.DefaultTag in project kylo by Teradata.
the class JsonFeedIT method getTags.
protected List<Tag> getTags() {
List<Tag> tags = new ArrayList<>();
tags.add(new DefaultTag("books"));
return tags;
}
use of com.thinkbiganalytics.discovery.model.DefaultTag in project kylo by Teradata.
the class DomainTypeIT method testCreateAndUpdateDatasource.
@Test
public void testCreateAndUpdateDatasource() {
FieldStandardizationRule toUpperCase = new FieldStandardizationRule();
FieldValidationRule email = new FieldValidationRule();
toUpperCase.setName("Uppercase");
toUpperCase.setDisplayName("Uppercase");
toUpperCase.setDescription("Convert string to uppercase");
toUpperCase.setObjectClassType("com.thinkbiganalytics.policy.standardization.UppercaseStandardizer");
toUpperCase.setObjectShortClassType("UppercaseStandardizer");
email.setName("email");
email.setDisplayName("Email");
email.setDescription("Valid email address");
email.setObjectClassType("com.thinkbiganalytics.policy.validation.EmailValidator");
email.setObjectShortClassType("EmailValidator");
DomainType[] initialDomainTypes = getDomainTypes();
// create new domain type
DomainType dt = new DomainType();
dt.setTitle("Domain Type 1");
dt.setDescription("domain type created by integration tests");
DomainType response = createDomainType(dt);
assertEquals(dt.getTitle(), response.getTitle());
assertEquals(dt.getDescription(), response.getDescription());
assertEquals(null, response.getIcon());
assertEquals(null, response.getIconColor());
// assert new domain type was added
DomainType[] currentDomainTypes = getDomainTypes();
assertEquals(initialDomainTypes.length + 1, currentDomainTypes.length);
// update existing domain type
dt = getDomainType(response.getId());
dt.setTitle("Domain Type 1 with updated title");
dt.setDescription("domain type description updated by integration tests");
dt.setIcon("stars");
dt.setIconColor("green");
DefaultField field = new DefaultField();
Tag tag1 = new DefaultTag("tag1");
Tag tag2 = new DefaultTag("tag2");
field.setTags(Arrays.asList(tag1, tag2));
field.setName("field-name");
field.setDerivedDataType("decimal");
field.setPrecisionScale("9, 3");
dt.setField(field);
dt.setFieldNamePattern("field-name-pattern");
dt.setFieldPolicy(newPolicyBuilder(null).withStandardisation(toUpperCase).withValidation(email).toPolicy());
dt.setRegexPattern("regex-pattern");
DomainType updated = createDomainType(dt);
assertEquals(dt.getTitle(), updated.getTitle());
assertEquals(dt.getDescription(), updated.getDescription());
assertEquals("stars", updated.getIcon());
assertEquals("green", updated.getIconColor());
Field updatedField = updated.getField();
assertEquals(field.getName(), updatedField.getName());
assertEquals(field.getDerivedDataType(), updatedField.getDerivedDataType());
assertEquals(field.getPrecisionScale(), updatedField.getPrecisionScale());
assertEquals(field.getTags().size(), updatedField.getTags().size());
assertEquals(tag1.getName(), updatedField.getTags().get(0).getName());
assertEquals(tag2.getName(), updatedField.getTags().get(1).getName());
assertEquals(dt.getFieldNamePattern(), updated.getFieldNamePattern());
assertEquals(dt.getRegexPattern(), updated.getRegexPattern());
FieldStandardizationRule updatedStandardisation = updated.getFieldPolicy().getStandardization().get(0);
assertEquals(toUpperCase.getName(), updatedStandardisation.getName());
assertEquals(toUpperCase.getObjectShortClassType(), updatedStandardisation.getObjectShortClassType());
FieldValidationRule updatedValidation = updated.getFieldPolicy().getValidation().get(0);
assertEquals(email.getName(), updatedValidation.getName());
assertEquals(email.getObjectShortClassType(), updatedValidation.getObjectShortClassType());
// assert domain type was updated, rather than added
currentDomainTypes = getDomainTypes();
assertEquals(initialDomainTypes.length + 1, currentDomainTypes.length);
// delete domain type
deleteDomainType(dt.getId());
currentDomainTypes = getDomainTypes();
assertEquals(initialDomainTypes.length, currentDomainTypes.length);
// assert domain type was removed
getDomainTypeExpectingStatus(dt.getId(), HTTP_NOT_FOUND);
}
Aggregations