Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Address backend DQ feedback #12150

Merged
merged 5 commits into from
Jun 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@
import org.openmetadata.service.resources.EntityResource;
import org.openmetadata.service.security.Authorizer;
import org.openmetadata.service.security.policyevaluator.OperationContext;
import org.openmetadata.service.security.policyevaluator.ResourceContext;
import org.openmetadata.service.util.EntityUtil;
import org.openmetadata.service.util.FullyQualifiedName;
import org.openmetadata.service.util.RestUtil;
import org.openmetadata.service.util.ResultList;
Expand Down Expand Up @@ -143,7 +145,14 @@ public ResultList<TestSuite> list(
throws IOException {
ListFilter filter = new ListFilter(include);
filter.addQueryParam("testSuiteType", testSuiteType);
return super.listInternal(uriInfo, securityContext, fieldsParam, filter, limitParam, before, after);
EntityUtil.Fields fields = getFields(fieldsParam);

ResourceContext resourceContext;
resourceContext = getResourceContext(entityType, repository).build();
OperationContext operationContext = new OperationContext(Entity.TABLE, MetadataOperation.VIEW_TESTS);

return super.listInternal(
uriInfo, securityContext, fields, filter, limitParam, before, after, operationContext, resourceContext);
}

@GET
Expand Down Expand Up @@ -298,6 +307,7 @@ public Response createExecutable(
Entity.getEntityByName(Entity.TABLE, create.getExecutableEntityReference(), null, null); // check if entity exists
TestSuite testSuite = getTestSuite(create, securityContext.getUserPrincipal().getName());
testSuite.setExecutable(true);
testSuite = setExecutableTestSuiteOwner(testSuite);
testSuite = setExecutableTestSuiteName(testSuite);
return create(uriInfo, securityContext, testSuite);
}
Expand Down Expand Up @@ -550,6 +560,17 @@ private TestSuite setExecutableTestSuiteName(TestSuite testSuite) {
return testSuite.withDisplayName(name).withName(hashedName);
}

private TestSuite setExecutableTestSuiteOwner(TestSuite testSuite) throws IOException {
Table tableEntity =
Entity.getEntity(
testSuite.getExecutableEntityReference().getType(),
testSuite.getExecutableEntityReference().getId(),
"owner",
ALL);
EntityReference ownerReference = tableEntity.getOwner();
return testSuite.withOwner(ownerReference);
}

@Override
public TestSuite getByNameInternal(
UriInfo uriInfo, SecurityContext securityContext, String name, String fieldsParam, Include include)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,325 @@
{
"settings": {
"analysis": {
"normalizer": {
"lowercase_normalizer": {
"type": "custom",
"char_filter": [],
"filter": [
"lowercase"
]
}
},
"analyzer": {
"om_analyzer": {
"tokenizer": "letter",
"filter": [
"lowercase",
"om_stemmer"
]
},
"om_analyzer_jp" : {
"tokenizer" : "kuromoji_tokenizer",
"type" : "custom",
"filter" : [
"kuromoji_baseform",
"kuromoji_part_of_speech",
"kuromoji_number",
"kuromoji_stemmer"
]
},
"om_ngram": {
"tokenizer": "ngram",
"min_gram": 1,
"max_gram": 2,
"filter": [
"lowercase"
]
}
},
"filter": {
"om_stemmer": {
"type": "stemmer",
"name": "english"
}
}
}
},
"mappings": {
"properties": {
"id": {
"type": "text"
},
"name": {
"type": "text",
"analyzer": "om_analyzer_jp",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
},
"ngram": {
"type": "text",
"analyzer": "om_ngram"
}
}
},
"fullyQualifiedName": {
"type": "keyword",
"normalizer": "lowercase_normalizer"
},
"displayName": {
"type": "text",
"analyzer": "om_analyzer_jp",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
},
"ngram": {
"type": "text",
"analyzer": "om_ngram"
}
}
},
"description": {
"type": "text",
"analyzer": "om_analyzer_jp",
"fields": {
"ngram": {
"type": "text",
"analyzer": "om_ngram"
}
}
},
"entityLink": {
"type": "text"
},
"entityFQN": {
"type": "keyword",
"normalizer": "lowercase_normalizer"
},
"parameterValues": {
"properties": {
"name": {
"type": "text",
"analyzer": "om_analyzer_jp",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
},
"ngram": {
"type": "text",
"analyzer": "om_ngram"
}
}
},
"value": {
"type": "text"
}
}
},
"testDefinition": {
"properties": {
"id": {
"type": "text"
},
"name": {
"type": "text",
"analyzer": "om_analyzer_jp",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
},
"ngram": {
"type": "text",
"analyzer": "om_ngram"
}
}
},
"fullyQualifiedName": {
"type": "keyword",
"normalizer": "lowercase_normalizer"
},
"displayName": {
"type": "text",
"analyzer": "om_analyzer_jp",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
},
"ngram": {
"type": "text",
"analyzer": "om_ngram"
}
}
},
"description": {
"type": "text",
"analyzer": "om_analyzer_jp",
"fields": {
"ngram": {
"type": "text",
"analyzer": "om_ngram"
}
}
},
"entityType": {
"type": "keyword"
},
"testPlatforms": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
}
}
},
"owner": {
"properties": {
"id": {
"type": "text"
},
"type": {
"type": "keyword"
},
"name": {
"type": "keyword",
"normalizer": "lowercase_normalizer",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"displayName": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"fullyQualifiedName": {
"type": "text"
},
"description": {
"type": "text"
},
"deleted": {
"type": "text"
},
"href": {
"type": "text"
}
}
},
"testSuite": {
"properties": {
"id": {
"type": "text"
},
"name": {
"type": "keyword",
"normalizer": "lowercase_normalizer",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"displayName": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"fullyQualifiedName": {
"type": "text"
},
"description": {
"type": "text"
},
"deleted": {
"type": "text"
},
"href": {
"type": "text"
},
"executable": {
"type": "text"
}
}
},
"testSuites": {
"properties": {
"id": {
"type": "text"
},
"name": {
"type": "keyword",
"normalizer": "lowercase_normalizer",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"displayName": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"fullyQualifiedName": {
"type": "text"
},
"description": {
"type": "text"
},
"deleted": {
"type": "text"
},
"href": {
"type": "text"
},
"executable": {
"type": "text"
}
}
},
"version": {
"type": "float"
},
"updatedAt": {
"type": "date",
"format": "epoch_second"
},
"updatedBy": {
"type": "text"
},
"href": {
"type": "text"
},
"deleted": {
"type": "text"
}
}
}
}
Loading