Commit 0e947170 by Madhan Neethiraj

ATLAS-3653: rename Namespace to BusinessMetadata

parent e5037282
......@@ -29,7 +29,7 @@ public class AtlasEntityAccessRequest extends AtlasAccessRequest {
private final String entityId;
private final AtlasClassification classification;
private final String label;
private final String namespaceName;
private final String businessMetadata;
private final String attributeName;
private final AtlasTypeRegistry typeRegistry;
private final Set<String> entityClassifications;
......@@ -67,14 +67,14 @@ public class AtlasEntityAccessRequest extends AtlasAccessRequest {
this(typeRegistry, action, entity, classification, attributeName, null, null, userName, userGroups);
}
public AtlasEntityAccessRequest(AtlasTypeRegistry typeRegistry, AtlasPrivilege action, AtlasEntityHeader entity, AtlasClassification classification, String attributeName, String label, String namespaceName, String userName, Set<String> userGroups) {
public AtlasEntityAccessRequest(AtlasTypeRegistry typeRegistry, AtlasPrivilege action, AtlasEntityHeader entity, AtlasClassification classification, String attributeName, String label, String businessMetadata, String userName, Set<String> userGroups) {
super(action, userName, userGroups);
this.entity = entity;
this.entityId = super.getEntityId(entity, typeRegistry);
this.classification = classification;
this.label = label;
this.namespaceName = namespaceName;
this.businessMetadata = businessMetadata;
this.attributeName = attributeName;
this.typeRegistry = typeRegistry;
this.entityClassifications = super.getClassificationNames(entity);
......@@ -96,8 +96,8 @@ public class AtlasEntityAccessRequest extends AtlasAccessRequest {
return label;
}
public String getNamespaceName() {
return namespaceName;
public String getBusinessMetadata() {
return businessMetadata;
}
public String getAttributeName() {
......@@ -122,7 +122,7 @@ public class AtlasEntityAccessRequest extends AtlasAccessRequest {
@Override
public String toString() {
return "AtlasEntityAccessRequest[entity=" + entity + ", classification=" + classification + ", label=" + label + ", namespaceName=" + namespaceName + ", attributeName=" + attributeName +
return "AtlasEntityAccessRequest[entity=" + entity + ", classification=" + classification + ", label=" + label + ", businessMetadata=" + businessMetadata + ", attributeName=" + attributeName +
", action=" + getAction() + ", accessTime=" + getAccessTime() + ", user=" + getUser() +
", userGroups=" + getUserGroups() + ", clientIPAddress=" + getClientIPAddress() +
", forwardedAddresses=" + getForwardedAddresses() + ", remoteIPAddress=" + getRemoteIPAddress() + "]";
......@@ -136,7 +136,7 @@ public class AtlasEntityAccessRequest extends AtlasAccessRequest {
private AtlasEntityHeader entity;
private AtlasClassification classification;
private String label;
private String namespaceName;
private String businessMetadata;
private String attributeName;
public AtlasEntityAccessRequestBuilder(AtlasTypeRegistry typeRegistry, AtlasPrivilege action) {
......@@ -180,8 +180,8 @@ public class AtlasEntityAccessRequest extends AtlasAccessRequest {
return this;
}
public AtlasEntityAccessRequestBuilder setNamespaceName(String namespaceName) {
this.namespaceName = namespaceName;
public AtlasEntityAccessRequestBuilder setBusinessMetadata(String businessMetadata) {
this.businessMetadata = businessMetadata;
return this;
}
......@@ -193,7 +193,7 @@ public class AtlasEntityAccessRequest extends AtlasAccessRequest {
}
public AtlasEntityAccessRequest build() {
return new AtlasEntityAccessRequest(typeRegistry, action, entity, classification, attributeName, label, namespaceName, userName, userGroups);
return new AtlasEntityAccessRequest(typeRegistry, action, entity, classification, attributeName, label, businessMetadata, userName, userGroups);
}
}
}
......
......@@ -42,7 +42,7 @@ public enum AtlasPrivilege {
ENTITY_ADD_LABEL("entity-add-label"),
ENTITY_REMOVE_LABEL("entity-remove-label"),
ENTITY_UPDATE_NAMESPACE("entity-update-namespace");
ENTITY_UPDATE_BUSINESS_METADATA("entity-update-business-metadata");
private final String type;
......
......@@ -238,9 +238,9 @@ public final class AtlasSimpleAuthorizer implements AtlasAuthorizer {
if (permissions != null) {
for (AtlasEntityPermission permission : permissions) {
// match entity-type/entity-id/lable/namespace/attribute
// match entity-type/entity-id/label/business-metadata/attribute
if (isMatchAny(entityTypes, permission.getEntityTypes()) && isMatch(entityId, permission.getEntityIds()) && isMatch(attribute, permission.getAttributes())
&& isLabelMatch(request, permission) && isNamespaceMatch(request, permission)) {
&& isLabelMatch(request, permission) && isBusinessMetadataMatch(request, permission)) {
// match permission/classification
if (!hasEntityAccess) {
if (isMatch(action, permission.getPrivileges()) && isMatch(classification, permission.getClassifications())) {
......@@ -464,8 +464,8 @@ public final class AtlasSimpleAuthorizer implements AtlasAuthorizer {
return (AtlasPrivilege.ENTITY_ADD_LABEL.equals(request.getAction()) || AtlasPrivilege.ENTITY_REMOVE_LABEL.equals(request.getAction())) ? isMatch(request.getLabel(), permission.getLabels()) : true;
}
private boolean isNamespaceMatch(AtlasEntityAccessRequest request, AtlasEntityPermission permission) {
return AtlasPrivilege.ENTITY_UPDATE_NAMESPACE.equals(request.getAction()) ? isMatch(request.getNamespaceName(), permission.getNamespaces()) : true;
private boolean isBusinessMetadataMatch(AtlasEntityAccessRequest request, AtlasEntityPermission permission) {
return AtlasPrivilege.ENTITY_UPDATE_BUSINESS_METADATA.equals(request.getAction()) ? isMatch(request.getBusinessMetadata(), permission.getBusinessMetadata()) : true;
}
}
......
......@@ -205,13 +205,13 @@ public class AtlasSimpleAuthzPolicy implements Serializable {
public static class AtlasEntityPermission implements Serializable {
private static final long serialVersionUID = 1L;
private List<String> privileges; // name of AtlasPrivilege enum, wildcards supported
private List<String> entityTypes; // name of entity-type, wildcards supported
private List<String> entityIds; // value of entity-unique attribute, wildcards supported
private List<String> classifications; // name of classification-type, wildcards supported
private List<String> labels; // labels, wildcards supported
private List<String> namespaces; // name of namespace-type, wildcards supported
private List<String> attributes; // name of entity-attribute, wildcards supported
private List<String> privileges; // name of AtlasPrivilege enum, wildcards supported
private List<String> entityTypes; // name of entity-type, wildcards supported
private List<String> entityIds; // value of entity-unique attribute, wildcards supported
private List<String> classifications; // name of classification-type, wildcards supported
private List<String> labels; // labels, wildcards supported
private List<String> businessMetadata; // name of business-metadata, wildcards supported
private List<String> attributes; // name of entity-attribute, wildcards supported
public AtlasEntityPermission() {
}
......@@ -220,14 +220,14 @@ public class AtlasSimpleAuthzPolicy implements Serializable {
this(privileges, entityTypes, entityIds, classifications, attributes, null, null);
}
public AtlasEntityPermission(List<String> privileges, List<String> entityTypes, List<String> entityIds, List<String> classifications, List<String> labels, List<String> namespaces, List<String> attributes) {
this.privileges = privileges;
this.entityTypes = entityTypes;
this.entityIds = entityIds;
this.classifications = classifications;
this.labels = labels;
this.namespaces = namespaces;
this.attributes = attributes;
public AtlasEntityPermission(List<String> privileges, List<String> entityTypes, List<String> entityIds, List<String> classifications, List<String> labels, List<String> businessMetadata, List<String> attributes) {
this.privileges = privileges;
this.entityTypes = entityTypes;
this.entityIds = entityIds;
this.classifications = classifications;
this.labels = labels;
this.businessMetadata = businessMetadata;
this.attributes = attributes;
}
public List<String> getPrivileges() {
......@@ -270,12 +270,12 @@ public class AtlasSimpleAuthzPolicy implements Serializable {
this.labels = labels;
}
public List<String> getNamespaces() {
return namespaces;
public List<String> getBusinessMetadata() {
return businessMetadata;
}
public void setNamespaces(List<String> namespaces) {
this.namespaces = namespaces;
public void setBusinessMetadata(List<String> businessMetadata) {
this.businessMetadata = businessMetadata;
}
public List<String> getAttributes() {
......
......@@ -150,21 +150,21 @@ public class AtlasSimpleAuthorizerTest {
}
@Test(enabled = true)
public void testNamespaces() {
public void testBusinessMetadata() {
try {
AtlasEntityAccessRequest request = new AtlasEntityAccessRequest(null, AtlasPrivilege.ENTITY_UPDATE_NAMESPACE);
AtlasEntityAccessRequest request = new AtlasEntityAccessRequest(null, AtlasPrivilege.ENTITY_UPDATE_BUSINESS_METADATA);
request.setUser(USER_DATA_SCIENTIST, Collections.emptySet());
boolean isAccessAllowed = authorizer.isAccessAllowed(request);
AssertJUnit.assertEquals("user " + USER_DATA_SCIENTIST + " shouldn't be allowed to update namespace", false, isAccessAllowed);
AssertJUnit.assertEquals("user " + USER_DATA_SCIENTIST + " shouldn't be allowed to update business-metadata", false, isAccessAllowed);
request.setUser(USER_DATA_STEWARD, Collections.emptySet());
isAccessAllowed = authorizer.isAccessAllowed(request);
AssertJUnit.assertEquals("user " + USER_DATA_STEWARD + " should be allowed to update namespace", true, isAccessAllowed);
AssertJUnit.assertEquals("user " + USER_DATA_STEWARD + " should be allowed to update business-metadata", true, isAccessAllowed);
} catch (AtlasAuthorizationException e) {
LOG.error("Exception in AtlasSimpleAuthorizerTest", e);
......
......@@ -25,14 +25,14 @@
],
"relationshipPermissions": [
{
"privileges": [ ".*" ],
"relationshipTypes": [ ".*" ],
"endOneEntityType": [ ".*" ],
"endOneEntityId": [ ".*" ],
"endOneEntityClassification": [ ".*" ],
"endTwoEntityType": [ ".*" ],
"endTwoEntityId": [ ".*" ],
"endTwoEntityClassification": [ ".*" ]
"privileges": [ ".*" ],
"relationshipTypes": [ ".*" ],
"endOneEntityType": [ ".*" ],
"endOneEntityId": [ ".*" ],
"endOneEntityClassification": [ ".*" ],
"endTwoEntityType": [ ".*" ],
"endTwoEntityId": [ ".*" ],
"endTwoEntityClassification": [ ".*" ]
}
]
},
......@@ -40,12 +40,12 @@
"DATA_SCIENTIST": {
"entityPermissions": [
{
"privileges": [ "entity-read", "entity-read-classification" ],
"entityTypes": [ ".*" ],
"entityIds": [ ".*" ],
"classifications": [ ".*" ],
"labels": [ ".*" ],
"namespaces": [ ".*" ]
"privileges": [ "entity-read", "entity-read-classification" ],
"entityTypes": [ ".*" ],
"entityIds": [ ".*" ],
"classifications": [ ".*" ],
"labels": [ ".*" ],
"businessMetadata": [ ".*" ]
}
]
},
......@@ -53,22 +53,22 @@
"DATA_STEWARD": {
"entityPermissions": [
{
"privileges": [ "entity-read", "entity-create", "entity-update", "entity-read-classification", "entity-add-classification", "entity-update-classification", "entity-remove-classification", "entity-add-label", "entity-remove-label", "entity-update-namespace" ],
"entityTypes": [ ".*" ],
"entityIds": [ ".*" ],
"classifications": [ ".*" ],
"labels": [ ".*" ],
"namespaces": [ ".*" ]
"privileges": [ "entity-read", "entity-create", "entity-update", "entity-read-classification", "entity-add-classification", "entity-update-classification", "entity-remove-classification", "entity-add-label", "entity-remove-label", "entity-update-business-metadata" ],
"entityTypes": [ ".*" ],
"entityIds": [ ".*" ],
"classifications": [ ".*" ],
"labels": [ ".*" ],
"businessMetadata": [ ".*" ]
}
]
}
},
"userRoles": {
"admin": [ "ROLE_ADMIN" ],
"rangertagsync": [ "DATA_SCIENTIST" ],
"admin": [ "ROLE_ADMIN" ],
"rangertagsync": [ "DATA_SCIENTIST" ],
"dataScientist1": [ "DATA_SCIENTIST"],
"dataSteward1": [ "DATA_STEWARD"]
"dataSteward1": [ "DATA_STEWARD"]
},
"groupRoles": {
......
......@@ -161,12 +161,12 @@ public enum AtlasErrorCode {
INVALID_LABEL_LENGTH(400, "ATLAS-400-00-08F", "Invalid label: {0}, label size should not be greater than {1}"),
INVALID_LABEL_CHARACTERS(400, "ATLAS-400-00-090", "Invalid label: {0}, label should contain alphanumeric characters, '_' or '-'"),
INVALID_PROPAGATION_TYPE(400, "ATLAS-400-00-091", "Invalid propagation {0} for relationship-type={1}. Default value is {2}"),
DUPLICATE_NAMESPACE_ATTRIBUTE(400, "ATLAS-400-00-092", "Duplicate Namespace Attributes: {0} not allowed within the same namespace: {1}"),
APPLICABLE_ENTITY_TYPES_DELETION_NOT_SUPPORTED(400, "ATLAS-400-00-093", "Cannot remove applicableEntityTypes in Attribute Def: {0}, defined in namespace: {1}"),
NAMESPACE_DEF_ATTRIBUTE_TYPE_INVALID(400, "ATLAS-400-00-094", "{0}.{1}: invalid attribute type. Namespace attribute cannot be of type entity/classification/struct/namespace"),
INVALID_NAMESPACE_NAME_FOR_ENTITY_TYPE(400, "ATLAS-400-00-095", "Invalid Namespace: {0} specified for entity, applicable namespaces: {1}"),
NAMESPACE_ATTRIBUTE_DOES_NOT_EXIST(400, "ATLAS-400-00-096", "Namespace attribute does not exist in entity: {0}"),
NAMESPACE_ATTRIBUTE_ALREADY_EXISTS(400, "ATLAS-400-00-097", "Namespace attribute already exists in entity: {0}"),
DUPLICATE_BUSINESS_METADATA_ATTRIBUTE(400, "ATLAS-400-00-092", "Duplicate business-metadata attributes: {0} not allowed within the same business-metadata: {1}"),
APPLICABLE_ENTITY_TYPES_DELETION_NOT_SUPPORTED(400, "ATLAS-400-00-093", "Cannot remove applicableEntityTypes in Attribute Def: {0}, defined in business-metadata: {1}"),
BUSINESS_METADATA_DEF_ATTRIBUTE_TYPE_INVALID(400, "ATLAS-400-00-094", "{0}.{1}: invalid attribute type. Business-metadata attribute cannot be of type entity/classification/struct/business-metadata"),
INVALID_BUSINESS_METADATA_NAME_FOR_ENTITY_TYPE(400, "ATLAS-400-00-095", "Invalid business-metadata: {0} specified for entity, applicable business-metadata: {1}"),
BUSINESS_METADATA_ATTRIBUTE_DOES_NOT_EXIST(400, "ATLAS-400-00-096", "Business-metadata attribute does not exist in entity: {0}"),
BUSINESS_METADATA_ATTRIBUTE_ALREADY_EXISTS(400, "ATLAS-400-00-097", "Business-metadata attribute already exists in entity: {0}"),
UNAUTHORIZED_ACCESS(403, "ATLAS-403-00-001", "{0} is not authorized to perform {1}"),
......
......@@ -18,5 +18,5 @@
package org.apache.atlas.model;
public enum TypeCategory {
PRIMITIVE, OBJECT_ID_TYPE, ENUM, STRUCT, CLASSIFICATION, ENTITY, ARRAY, MAP, RELATIONSHIP, NAMESPACE
PRIMITIVE, OBJECT_ID_TYPE, ENUM, STRUCT, CLASSIFICATION, ENTITY, ARRAY, MAP, RELATIONSHIP, BUSINESS_METADATA
}
......@@ -93,7 +93,7 @@ public class AtlasEntity extends AtlasStruct implements Serializable {
private List<AtlasClassification> classifications;
private List<AtlasTermAssignmentHeader> meanings;
private Map<String, String> customAttributes;
private Map<String, Map<String, Object>> namespaceAttributes;
private Map<String, Map<String, Object>> businessAttributes;
private Set<String> labels;
@JsonIgnore
......@@ -218,7 +218,7 @@ public class AtlasEntity extends AtlasStruct implements Serializable {
setRelationshipAttributes(other.getRelationshipAttributes());
setMeanings(other.getMeanings());
setCustomAttributes(other.getCustomAttributes());
setNamespaceAttributes(other.getNamespaceAttributes());
setBusinessAttributes(other.getBusinessAttributes());
setLabels(other.getLabels());
}
}
......@@ -350,39 +350,39 @@ public class AtlasEntity extends AtlasStruct implements Serializable {
this.customAttributes = customAttributes;
}
public Map<String, Map<String, Object>> getNamespaceAttributes() {
return namespaceAttributes;
public Map<String, Map<String, Object>> getBusinessAttributes() {
return businessAttributes;
}
public void setNamespaceAttributes(Map<String, Map<String, Object>> namespaceAttributes) {
this.namespaceAttributes = namespaceAttributes;
public void setBusinessAttributes(Map<String, Map<String, Object>> businessAttributes) {
this.businessAttributes = businessAttributes;
}
public void setNamespaceAttribute(String nsName, String nsAttrName, Object nsValue) {
Map<String, Map<String, Object>> namespaceAttributes = this.namespaceAttributes;
public void setBusinessAttribute(String nsName, String nsAttrName, Object nsValue) {
Map<String, Map<String, Object>> businessAttributes = this.businessAttributes;
if (namespaceAttributes == null) {
namespaceAttributes = new HashMap<>();
if (businessAttributes == null) {
businessAttributes = new HashMap<>();
this.namespaceAttributes = namespaceAttributes;
this.businessAttributes = businessAttributes;
}
Map<String, Object> namespaceAttributeMap = namespaceAttributes.get(nsName);
Map<String, Object> businessAttributeMap = businessAttributes.get(nsName);
if (namespaceAttributeMap == null) {
namespaceAttributeMap = new HashMap<>();
if (businessAttributeMap == null) {
businessAttributeMap = new HashMap<>();
namespaceAttributes.put(nsName, namespaceAttributeMap);
businessAttributes.put(nsName, businessAttributeMap);
}
namespaceAttributeMap.put(nsAttrName, nsValue);
businessAttributeMap.put(nsAttrName, nsValue);
}
public Object getNamespaceAttribute(String nsName, String nsAttrName) {
Map<String, Map<String, Object>> namespaceAttributes = this.namespaceAttributes;
Map<String, Object> namespaceAttributeMap = namespaceAttributes == null ? null : namespaceAttributes.get(nsName);
public Object getBusinessAttribute(String bmName, String bmAttrName) {
Map<String, Map<String, Object>> businessAttributes = this.businessAttributes;
Map<String, Object> businessAttributeMap = businessAttributes == null ? null : businessAttributes.get(bmName);
return namespaceAttributeMap == null ? null : namespaceAttributeMap.get(nsAttrName);
return businessAttributeMap == null ? null : businessAttributeMap.get(bmAttrName);
}
public Set<String> getLabels() {
......@@ -441,7 +441,7 @@ public class AtlasEntity extends AtlasStruct implements Serializable {
setClassifications(null);
setMeanings(null);
setCustomAttributes(null);
setNamespaceAttributes(null);
setBusinessAttributes(null);
setLabels(null);
}
......@@ -480,8 +480,8 @@ public class AtlasEntity extends AtlasStruct implements Serializable {
sb.append(", customAttributes=[");
dumpObjects(customAttributes, sb);
sb.append("]");
sb.append(", namespaceAttributes=[");
dumpObjects(namespaceAttributes, sb);
sb.append(", businessAttributes=[");
dumpObjects(businessAttributes, sb);
sb.append("]");
sb.append(", labels=[");
dumpObjects(labels, sb);
......@@ -511,7 +511,7 @@ public class AtlasEntity extends AtlasStruct implements Serializable {
Objects.equals(version, that.version) &&
Objects.equals(relationshipAttributes, that.relationshipAttributes) &&
Objects.equals(customAttributes, that.customAttributes) &&
Objects.equals(namespaceAttributes, that.namespaceAttributes) &&
Objects.equals(businessAttributes, that.businessAttributes) &&
Objects.equals(labels, that.labels) &&
Objects.equals(classifications, that.classifications);
}
......@@ -519,7 +519,7 @@ public class AtlasEntity extends AtlasStruct implements Serializable {
@Override
public int hashCode() {
return Objects.hash(super.hashCode(), guid, homeId, isProxy, isIncomplete, provenanceType, status, createdBy, updatedBy,
createTime, updateTime, version, relationshipAttributes, classifications, customAttributes, namespaceAttributes, labels);
createTime, updateTime, version, relationshipAttributes, classifications, customAttributes, businessAttributes, labels);
}
@Override
......
......@@ -37,34 +37,34 @@ import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_
@JsonIgnoreProperties(ignoreUnknown=true)
@XmlRootElement
@XmlAccessorType(XmlAccessType.PROPERTY)
public class AtlasNamespaceDef extends AtlasStructDef implements Serializable {
public class AtlasBusinessMetadataDef extends AtlasStructDef implements Serializable {
private static final long serialVersionUID = 1L;
public static final String ATTR_OPTION_APPLICABLE_ENTITY_TYPES = "applicableEntityTypes";
public static final String ATTR_MAX_STRING_LENGTH = "maxStrLength";
public static final String ATTR_VALID_PATTERN = "validPattern";
public static final String ATTR_MAX_STRING_LENGTH = "maxStrLength";
public static final String ATTR_VALID_PATTERN = "validPattern";
public AtlasNamespaceDef() {
public AtlasBusinessMetadataDef() {
this(null, null, null, null);
}
public AtlasNamespaceDef(String name, String description) {
public AtlasBusinessMetadataDef(String name, String description) {
this(name, description, null, null, null);
}
public AtlasNamespaceDef(String name, String description, String typeVersion) {
public AtlasBusinessMetadataDef(String name, String description, String typeVersion) {
this(name, description, typeVersion, null, null);
}
public AtlasNamespaceDef(String name, String description, String typeVersion, List<AtlasAttributeDef> attributeDefs) {
public AtlasBusinessMetadataDef(String name, String description, String typeVersion, List<AtlasAttributeDef> attributeDefs) {
this(name, description, typeVersion, attributeDefs, null);
}
public AtlasNamespaceDef(String name, String description, String typeVersion, List<AtlasAttributeDef> attributeDefs, Map<String, String> options) {
super(TypeCategory.NAMESPACE, name, description, typeVersion, attributeDefs, options);
public AtlasBusinessMetadataDef(String name, String description, String typeVersion, List<AtlasAttributeDef> attributeDefs, Map<String, String> options) {
super(TypeCategory.BUSINESS_METADATA, name, description, typeVersion, attributeDefs, options);
}
public AtlasNamespaceDef(AtlasNamespaceDef other) {
public AtlasBusinessMetadataDef(AtlasBusinessMetadataDef other) {
super(other);
}
......@@ -79,7 +79,7 @@ public class AtlasNamespaceDef extends AtlasStructDef implements Serializable {
sb = new StringBuilder();
}
sb.append("AtlasNamespaceDef{");
sb.append("AtlasBusinessMetadataDef{");
super.toString(sb);
sb.append('}');
......
......@@ -66,8 +66,8 @@ public class AtlasEntityDef extends AtlasStructDef implements java.io.Serializab
private List<AtlasRelationshipAttributeDef> relationshipAttributeDefs;
// this is a read-only field, any value provided during create & update operation is ignored
// the value of this field is derived from all the namespaceDefs this entityType is referenced in
private Map<String, List<AtlasAttributeDef>> namespaceAttributeDefs;
// the value of this field is derived from all the businessMetadataDefs this entityType is referenced in
private Map<String, List<AtlasAttributeDef>> businessAttributeDefs;
public AtlasEntityDef() {
......@@ -132,7 +132,7 @@ public class AtlasEntityDef extends AtlasStructDef implements java.io.Serializab
setSuperTypes(other.getSuperTypes());
setSubTypes(other.getSubTypes());
setRelationshipAttributeDefs(other.getRelationshipAttributeDefs());
setNamespaceAttributeDefs(other.getNamespaceAttributeDefs());
setBusinessAttributeDefs(other.getBusinessAttributeDefs());
}
}
......@@ -170,12 +170,12 @@ public class AtlasEntityDef extends AtlasStructDef implements java.io.Serializab
this.relationshipAttributeDefs = relationshipAttributeDefs;
}
public Map<String, List<AtlasAttributeDef>> getNamespaceAttributeDefs() {
return namespaceAttributeDefs;
public Map<String, List<AtlasAttributeDef>> getBusinessAttributeDefs() {
return businessAttributeDefs;
}
public void setNamespaceAttributeDefs(Map<String, List<AtlasAttributeDef>> namespaceAttributeDefs) {
this.namespaceAttributeDefs = namespaceAttributeDefs;
public void setBusinessAttributeDefs(Map<String, List<AtlasAttributeDef>> businessAttributeDefs) {
this.businessAttributeDefs = businessAttributeDefs;
}
public boolean hasSuperType(String typeName) {
......@@ -235,11 +235,11 @@ public class AtlasEntityDef extends AtlasStructDef implements java.io.Serializab
}
}
sb.append(']');
sb.append(", namespaceAttributeDefs={");
if (MapUtils.isNotEmpty(namespaceAttributeDefs)) {
sb.append(", businessAttributeDefs={");
if (MapUtils.isNotEmpty(businessAttributeDefs)) {
int nsIdx = 0;
for (Map.Entry<String, List<AtlasAttributeDef>> entry : namespaceAttributeDefs.entrySet()) {
for (Map.Entry<String, List<AtlasAttributeDef>> entry : businessAttributeDefs.entrySet()) {
String nsName = entry.getKey();
List<AtlasAttributeDef> nsAttrs = entry.getValue();
......
......@@ -42,20 +42,20 @@ import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_
@XmlRootElement
@XmlAccessorType(XmlAccessType.PROPERTY)
public class AtlasTypesDef {
private List<AtlasEnumDef> enumDefs;
private List<AtlasStructDef> structDefs;
private List<AtlasClassificationDef> classificationDefs;
private List<AtlasEntityDef> entityDefs;
private List<AtlasRelationshipDef> relationshipDefs;
private List<AtlasNamespaceDef> namespaceDefs;
private List<AtlasEnumDef> enumDefs;
private List<AtlasStructDef> structDefs;
private List<AtlasClassificationDef> classificationDefs;
private List<AtlasEntityDef> entityDefs;
private List<AtlasRelationshipDef> relationshipDefs;
private List<AtlasBusinessMetadataDef> businessMetadataDefs;
public AtlasTypesDef() {
enumDefs = new ArrayList<>();
structDefs = new ArrayList<>();
classificationDefs = new ArrayList<>();
entityDefs = new ArrayList<>();
relationshipDefs = new ArrayList<>();
namespaceDefs = new ArrayList<>();
enumDefs = new ArrayList<>();
structDefs = new ArrayList<>();
classificationDefs = new ArrayList<>();
entityDefs = new ArrayList<>();
relationshipDefs = new ArrayList<>();
businessMetadataDefs = new ArrayList<>();
}
/**
......@@ -86,18 +86,18 @@ public class AtlasTypesDef {
this(enumDefs, structDefs, classificationDefs, entityDefs, relationshipDefs, new ArrayList<>());
}
public AtlasTypesDef(List<AtlasEnumDef> enumDefs,
List<AtlasStructDef> structDefs,
List<AtlasClassificationDef> classificationDefs,
List<AtlasEntityDef> entityDefs,
List<AtlasRelationshipDef> relationshipDefs,
List<AtlasNamespaceDef> namespaceDefs) {
this.enumDefs = enumDefs;
this.structDefs = structDefs;
this.classificationDefs = classificationDefs;
this.entityDefs = entityDefs;
this.relationshipDefs = relationshipDefs;
this.namespaceDefs = namespaceDefs;
public AtlasTypesDef(List<AtlasEnumDef> enumDefs,
List<AtlasStructDef> structDefs,
List<AtlasClassificationDef> classificationDefs,
List<AtlasEntityDef> entityDefs,
List<AtlasRelationshipDef> relationshipDefs,
List<AtlasBusinessMetadataDef> businessMetadataDefs) {
this.enumDefs = enumDefs;
this.structDefs = structDefs;
this.classificationDefs = classificationDefs;
this.entityDefs = entityDefs;
this.relationshipDefs = relationshipDefs;
this.businessMetadataDefs = businessMetadataDefs;
}
public List<AtlasEnumDef> getEnumDefs() {
......@@ -138,12 +138,12 @@ public class AtlasTypesDef {
this.relationshipDefs = relationshipDefs;
}
public void setNamespaceDefs(List<AtlasNamespaceDef> namespaceDefs) {
this.namespaceDefs = namespaceDefs;
public void setBusinessMetadataDefs(List<AtlasBusinessMetadataDef> businessMetadataDefs) {
this.businessMetadataDefs = businessMetadataDefs;
}
public List<AtlasNamespaceDef> getNamespaceDefs() {
return namespaceDefs;
public List<AtlasBusinessMetadataDef> getBusinessMetadataDefs() {
return businessMetadataDefs;
}
public boolean hasClassificationDef(String name) {
......@@ -165,8 +165,8 @@ public class AtlasTypesDef {
return hasTypeDef(relationshipDefs, name);
}
public boolean hasNamespaceDef(String name) {
return hasTypeDef(namespaceDefs, name);
public boolean hasBusinessMetadataDef(String name) {
return hasTypeDef(businessMetadataDefs, name);
}
private <T extends AtlasBaseTypeDef> boolean hasTypeDef(Collection<T> typeDefs, String name) {
......@@ -188,7 +188,7 @@ public class AtlasTypesDef {
CollectionUtils.isEmpty(classificationDefs) &&
CollectionUtils.isEmpty(entityDefs) &&
CollectionUtils.isEmpty(relationshipDefs) &&
CollectionUtils.isEmpty(namespaceDefs);
CollectionUtils.isEmpty(businessMetadataDefs);
}
public void clear() {
......@@ -211,8 +211,8 @@ public class AtlasTypesDef {
relationshipDefs.clear();
}
if (namespaceDefs != null) {
namespaceDefs.clear();
if (businessMetadataDefs != null) {
businessMetadataDefs.clear();
}
}
public StringBuilder toString(StringBuilder sb) {
......@@ -235,8 +235,8 @@ public class AtlasTypesDef {
sb.append("}");
sb.append("relationshipDefs={");
AtlasBaseTypeDef.dumpObjects(relationshipDefs, sb);
sb.append("namespaceDefs={");
AtlasBaseTypeDef.dumpObjects(namespaceDefs, sb);
sb.append("businessMetadataDefs={");
AtlasBaseTypeDef.dumpObjects(businessMetadataDefs, sb);
sb.append("}");
return sb;
......
......@@ -20,10 +20,10 @@ package org.apache.atlas.store;
import org.apache.atlas.exception.AtlasBaseException;
import org.apache.atlas.model.SearchFilter;
import org.apache.atlas.model.typedef.AtlasBaseTypeDef;
import org.apache.atlas.model.typedef.AtlasBusinessMetadataDef;
import org.apache.atlas.model.typedef.AtlasClassificationDef;
import org.apache.atlas.model.typedef.AtlasEntityDef;
import org.apache.atlas.model.typedef.AtlasEnumDef;
import org.apache.atlas.model.typedef.AtlasNamespaceDef;
import org.apache.atlas.model.typedef.AtlasRelationshipDef;
import org.apache.atlas.model.typedef.AtlasStructDef;
import org.apache.atlas.model.typedef.AtlasTypesDef;
......@@ -82,26 +82,26 @@ public interface AtlasTypeDefStore {
AtlasRelationshipDef getRelationshipDefByGuid(String guid) throws AtlasBaseException;
AtlasRelationshipDef updateRelationshipDefByName(String name, AtlasRelationshipDef structDef) throws AtlasBaseException;
AtlasRelationshipDef updateRelationshipDefByName(String name, AtlasRelationshipDef relationshipDef) throws AtlasBaseException;
AtlasRelationshipDef updateRelationshipDefByGuid(String guid, AtlasRelationshipDef structDef) throws AtlasBaseException;
AtlasRelationshipDef updateRelationshipDefByGuid(String guid, AtlasRelationshipDef relationshipDef) throws AtlasBaseException;
/* Namespace Def operations */
AtlasNamespaceDef getNamespaceDefByName(String name) throws AtlasBaseException;
/* business-metadata Def operations */
AtlasBusinessMetadataDef getBusinessMetadataDefByName(String name) throws AtlasBaseException;
AtlasNamespaceDef getNamespaceDefByGuid(String guid) throws AtlasBaseException;
AtlasBusinessMetadataDef getBusinessMetadataDefByGuid(String guid) throws AtlasBaseException;
/* Bulk Operations */
AtlasTypesDef createTypesDef(AtlasTypesDef atlasTypesDef) throws AtlasBaseException;
AtlasTypesDef createTypesDef(AtlasTypesDef typesDef) throws AtlasBaseException;
AtlasTypesDef updateTypesDef(AtlasTypesDef atlasTypesDef) throws AtlasBaseException;
AtlasTypesDef updateTypesDef(AtlasTypesDef typesDef) throws AtlasBaseException;
AtlasTypesDef createUpdateTypesDef(AtlasTypesDef typesToCreateUpdate) throws AtlasBaseException;
AtlasTypesDef createUpdateTypesDef(AtlasTypesDef typesToCreate, AtlasTypesDef typesToUpdate) throws AtlasBaseException;
void deleteTypesDef(AtlasTypesDef atlasTypesDef) throws AtlasBaseException;
void deleteTypesDef(AtlasTypesDef typesDef) throws AtlasBaseException;
AtlasTypesDef searchTypesDef(SearchFilter searchFilter) throws AtlasBaseException;
......
......@@ -20,7 +20,7 @@ package org.apache.atlas.type;
import org.apache.atlas.AtlasErrorCode;
import org.apache.atlas.exception.AtlasBaseException;
import org.apache.atlas.model.instance.AtlasStruct;
import org.apache.atlas.model.typedef.AtlasNamespaceDef;
import org.apache.atlas.model.typedef.AtlasBusinessMetadataDef;
import org.apache.atlas.model.typedef.AtlasStructDef.AtlasAttributeDef;
import org.apache.commons.collections.CollectionUtils;
import org.slf4j.Logger;
......@@ -28,45 +28,45 @@ import org.slf4j.LoggerFactory;
import java.util.*;
import static org.apache.atlas.model.typedef.AtlasNamespaceDef.*;
import static org.apache.atlas.model.typedef.AtlasBusinessMetadataDef.*;
public class AtlasNamespaceType extends AtlasStructType {
private static final Logger LOG = LoggerFactory.getLogger(AtlasNamespaceType.class);
public class AtlasBusinessMetadataType extends AtlasStructType {
private static final Logger LOG = LoggerFactory.getLogger(AtlasBusinessMetadataType.class);
private final AtlasNamespaceDef namespaceDef;
private final AtlasBusinessMetadataDef businessMetadataDef;
public AtlasNamespaceType(AtlasNamespaceDef namespaceDef) {
super(namespaceDef);
public AtlasBusinessMetadataType(AtlasBusinessMetadataDef businessMetadataDef) {
super(businessMetadataDef);
this.namespaceDef = namespaceDef;
this.businessMetadataDef = businessMetadataDef;
}
@Override
public boolean isValidValue(Object o) {
return true; // there is no runtime instance for Namespaces, so return true
return true; // there is no runtime instance for businessMetadataDef, so return true
}
@Override
public AtlasStruct createDefaultValue() {
return null; // there is no runtime instance for Namespaces, so return null
return null; // there is no runtime instance for businessMetadataDef, so return null
}
@Override
public Object getNormalizedValue(Object a) {
return null; // there is no runtime instance for Namespaces, so return null
return null; // there is no runtime instance for businessMetadataDef, so return null
}
public AtlasNamespaceDef getNamespaceDef() {
return namespaceDef;
public AtlasBusinessMetadataDef getBusinessMetadataDef() {
return businessMetadataDef;
}
@Override
void resolveReferences(AtlasTypeRegistry typeRegistry) throws AtlasBaseException {
super.resolveReferences(typeRegistry);
Map<String, AtlasNamespaceAttribute> a = new HashMap<>();
Map<String, AtlasBusinessAttribute> a = new HashMap<>();
for (AtlasAttribute attribute : super.allAttributes.values()) {
AtlasAttributeDef attributeDef = attribute.getAttributeDef();
......@@ -79,9 +79,9 @@ public class AtlasNamespaceType extends AtlasStructType {
attrType = ((AtlasMapType) attrType).getValueType();
}
// check if attribute type is not struct/classification/entity/namespace
// check if attribute type is not struct/classification/entity/business-metadata
if (attrType instanceof AtlasStructType) {
throw new AtlasBaseException(AtlasErrorCode.NAMESPACE_DEF_ATTRIBUTE_TYPE_INVALID, getTypeName(), attrName);
throw new AtlasBaseException(AtlasErrorCode.BUSINESS_METADATA_DEF_ATTRIBUTE_TYPE_INVALID, getTypeName(), attrName);
}
Set<String> entityTypeNames = attribute.getOptionSet(ATTR_OPTION_APPLICABLE_ENTITY_TYPES);
......@@ -99,7 +99,7 @@ public class AtlasNamespaceType extends AtlasStructType {
}
}
AtlasNamespaceAttribute nsAttribute;
AtlasBusinessAttribute bmAttribute;
if (attribute.getAttributeType() instanceof AtlasBuiltInTypes.AtlasStringType) {
Integer maxStringLength = attribute.getOptionInt(ATTR_MAX_STRING_LENGTH);
if (maxStringLength == null) {
......@@ -107,12 +107,12 @@ public class AtlasNamespaceType extends AtlasStructType {
}
String validPattern = attribute.getOptionString(ATTR_VALID_PATTERN);
nsAttribute = new AtlasNamespaceAttribute(attribute, entityTypes, maxStringLength, validPattern);
bmAttribute = new AtlasBusinessAttribute(attribute, entityTypes, maxStringLength, validPattern);
} else {
nsAttribute = new AtlasNamespaceAttribute(attribute, entityTypes);
bmAttribute = new AtlasBusinessAttribute(attribute, entityTypes);
}
a.put(attrName, nsAttribute);
a.put(attrName, bmAttribute);
}
super.allAttributes = Collections.unmodifiableMap(a);
......@@ -123,23 +123,23 @@ public class AtlasNamespaceType extends AtlasStructType {
super.resolveReferencesPhase2(typeRegistry);
for (AtlasAttribute attribute : super.allAttributes.values()) {
AtlasNamespaceAttribute nsAttribute = (AtlasNamespaceAttribute) attribute;
Set<AtlasEntityType> entityTypes = nsAttribute.getApplicableEntityTypes();
AtlasBusinessAttribute bmAttribute = (AtlasBusinessAttribute) attribute;
Set<AtlasEntityType> entityTypes = bmAttribute.getApplicableEntityTypes();
if (CollectionUtils.isNotEmpty(entityTypes)) {
for (AtlasEntityType entityType : entityTypes) {
entityType.addNamespaceAttribute(nsAttribute);
entityType.addBusinessAttribute(bmAttribute);
}
}
}
}
public static class AtlasNamespaceAttribute extends AtlasAttribute {
public static class AtlasBusinessAttribute extends AtlasAttribute {
private final Set<AtlasEntityType> applicableEntityTypes;
private final int maxStringLength;
private final String validPattern;
public AtlasNamespaceAttribute(AtlasAttribute attribute, Set<AtlasEntityType> applicableEntityTypes) {
public AtlasBusinessAttribute(AtlasAttribute attribute, Set<AtlasEntityType> applicableEntityTypes) {
super(attribute);
this.maxStringLength = 0;
......@@ -147,7 +147,7 @@ public class AtlasNamespaceType extends AtlasStructType {
this.applicableEntityTypes = applicableEntityTypes;
}
public AtlasNamespaceAttribute(AtlasAttribute attribute, Set<AtlasEntityType> applicableEntityTypes, int maxStringLength, String validPattern) {
public AtlasBusinessAttribute(AtlasAttribute attribute, Set<AtlasEntityType> applicableEntityTypes, int maxStringLength, String validPattern) {
super(attribute);
this.maxStringLength = maxStringLength;
......@@ -156,8 +156,8 @@ public class AtlasNamespaceType extends AtlasStructType {
}
@Override
public AtlasNamespaceType getDefinedInType() {
return (AtlasNamespaceType) super.getDefinedInType();
public AtlasBusinessMetadataType getDefinedInType() {
return (AtlasBusinessMetadataType) super.getDefinedInType();
}
public Set<AtlasEntityType> getApplicableEntityTypes() {
......
......@@ -112,7 +112,7 @@ public class AtlasStructType extends AtlasType {
throw new AtlasBaseException(AtlasErrorCode.ATTRIBUTE_TYPE_INVALID, getTypeName(), attributeDef.getName());
}
if (attrType instanceof AtlasNamespaceType) {
if (attrType instanceof AtlasBusinessMetadataType) {
throw new AtlasBaseException(AtlasErrorCode.ATTRIBUTE_TYPE_INVALID, getTypeName(), attributeDef.getName());
}
......@@ -227,7 +227,7 @@ public class AtlasStructType extends AtlasType {
}
if (ret == null) {
ret = getNamespaceAttribute(attributeName);
ret = getBusinesAAttribute(attributeName);
}
return ret;
......@@ -237,7 +237,7 @@ public class AtlasStructType extends AtlasType {
return null;
}
public AtlasAttribute getNamespaceAttribute(String attributeName) {
public AtlasAttribute getBusinesAAttribute(String attributeName) {
return null;
}
......
......@@ -28,7 +28,7 @@ import org.apache.atlas.model.typedef.AtlasClassificationDef;
import org.apache.atlas.model.typedef.AtlasEntityDef;
import org.apache.atlas.model.typedef.AtlasEnumDef;
import org.apache.atlas.model.typedef.AtlasEnumDef.AtlasEnumElementDef;
import org.apache.atlas.model.typedef.AtlasNamespaceDef;
import org.apache.atlas.model.typedef.AtlasBusinessMetadataDef;
import org.apache.atlas.model.typedef.AtlasRelationshipDef;
import org.apache.atlas.model.typedef.AtlasRelationshipDef.PropagateTags;
import org.apache.atlas.model.typedef.AtlasRelationshipDef.RelationshipCategory;
......@@ -321,8 +321,8 @@ public class AtlasTypeUtil {
List<AtlasClassificationDef> traits,
List<AtlasEntityDef> classes,
List<AtlasRelationshipDef> relations,
List<AtlasNamespaceDef> namespaces) {
return new AtlasTypesDef(enums, structs, traits, classes, relations, namespaces);
List<AtlasBusinessMetadataDef> businessMetadataDefs) {
return new AtlasTypesDef(enums, structs, traits, classes, relations, businessMetadataDefs);
}
public static List<AtlasTypeDefHeader> toTypeDefHeader(AtlasTypesDef typesDef) {
......
......@@ -31,6 +31,6 @@ public class DataTypes {
TRAIT,
CLASS,
RELATIONSHIP,
NAMESPACE
BUSINESS_METADATA
}
}
\ No newline at end of file
......@@ -23,11 +23,11 @@ import org.apache.atlas.model.instance.AtlasEntity;
import org.apache.atlas.model.instance.AtlasEntity.AtlasEntitiesWithExtInfo;
import org.apache.atlas.model.instance.AtlasObjectId;
import org.apache.atlas.model.instance.AtlasStruct;
import org.apache.atlas.model.typedef.AtlasBusinessMetadataDef;
import org.apache.atlas.model.typedef.AtlasClassificationDef;
import org.apache.atlas.model.typedef.AtlasEntityDef;
import org.apache.atlas.model.typedef.AtlasEnumDef;
import org.apache.atlas.model.typedef.AtlasEnumDef.AtlasEnumElementDef;
import org.apache.atlas.model.typedef.AtlasNamespaceDef;
import org.apache.atlas.model.typedef.AtlasRelationshipDef;
import org.apache.atlas.model.typedef.AtlasRelationshipEndDef;
import org.apache.atlas.model.typedef.AtlasStructDef;
......@@ -40,7 +40,7 @@ import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.*;
import static org.apache.atlas.model.typedef.AtlasNamespaceDef.ATTR_OPTION_APPLICABLE_ENTITY_TYPES;
import static org.apache.atlas.model.typedef.AtlasBusinessMetadataDef.ATTR_OPTION_APPLICABLE_ENTITY_TYPES;
import static org.apache.atlas.model.typedef.AtlasRelationshipDef.PropagateTags.BOTH;
import static org.apache.atlas.model.typedef.AtlasRelationshipDef.PropagateTags.ONE_TO_TWO;
import static org.apache.atlas.model.typedef.AtlasRelationshipDef.RelationshipCategory.AGGREGATION;
......@@ -155,14 +155,14 @@ public final class TestRelationshipUtilsV2 {
nsAttr2.setIsOptional(true);
nsAttr2.setIsUnique(false);
AtlasNamespaceDef namespaceDef = new AtlasNamespaceDef("test_namespace", "test_description", DEFAULT_VERSION, Arrays.asList(nsAttr1, nsAttr2));
AtlasBusinessMetadataDef businessMetadataDef = new AtlasBusinessMetadataDef("test_businessMetadata", "test_description", DEFAULT_VERSION, Arrays.asList(nsAttr1, nsAttr2));
return new AtlasTypesDef(Collections.singletonList(orgLevelType),
Collections.singletonList(addressType),
Collections.singletonList(securityClearanceType),
Arrays.asList(personType, employeeType, departmentType, managerType),
Arrays.asList(employeeDepartmentType, employeeManagerType, employeeMentorsType, employeeFriendsType, personSiblingType),
Collections.singletonList(namespaceDef));
Collections.singletonList(businessMetadataDef));
}
public static AtlasEntitiesWithExtInfo getDepartmentEmployeeInstances() {
......@@ -295,7 +295,7 @@ public final class TestRelationshipUtilsV2 {
new AtlasRelationshipEndDef(TYPE_A, "mapToB", SET));
return new AtlasTypesDef(Collections.<AtlasEnumDef>emptyList(), Collections.<AtlasStructDef>emptyList(), Collections.<AtlasClassificationDef>emptyList(), Arrays.asList(aType, bType),
Arrays.asList(relationshipType1, relationshipType2, relationshipType3, relationshipType4), Collections.<AtlasNamespaceDef>emptyList());
Arrays.asList(relationshipType1, relationshipType2, relationshipType3, relationshipType4), Collections.<AtlasBusinessMetadataDef>emptyList());
}
private static List<AtlasEnumElementDef> getOrgLevelElements() {
......
......@@ -23,54 +23,54 @@ import org.testng.annotations.Test;
import java.util.Arrays;
import java.util.Collections;
import static org.apache.atlas.model.typedef.AtlasNamespaceDef.ATTR_OPTION_APPLICABLE_ENTITY_TYPES;
import static org.apache.atlas.model.typedef.AtlasBusinessMetadataDef.ATTR_OPTION_APPLICABLE_ENTITY_TYPES;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNotEquals;
public class TestAtlasNamespaceDef {
public class TestAtlasBusinessMetadataDef {
@Test
public void namespaceDefSerDes() {
AtlasNamespaceDef namespaceDef = new AtlasNamespaceDef("test_namespace", "test_description", null);
String jsonString = AtlasType.toJson(namespaceDef);
public void businessMetadataDefSerDes() {
AtlasBusinessMetadataDef businessMetadataDef = new AtlasBusinessMetadataDef("test_businessMetadata", "test_description", null);
String jsonString = AtlasType.toJson(businessMetadataDef);
AtlasNamespaceDef namespaceDef1 = AtlasType.fromJson(jsonString, AtlasNamespaceDef.class);
assertEquals(namespaceDef, namespaceDef1,
"Incorrect serialization/deserialization of AtlasNamespaceDef");
AtlasBusinessMetadataDef businessMetadataDef1 = AtlasType.fromJson(jsonString, AtlasBusinessMetadataDef.class);
assertEquals(businessMetadataDef, businessMetadataDef1,
"Incorrect serialization/deserialization of AtlasBusinessMetadataDef");
}
@Test
public void namespaceDefEquality() {
AtlasNamespaceDef namespaceDef1 = new AtlasNamespaceDef("test_namespace", "test_description", null);
AtlasNamespaceDef namespaceDef2 = new AtlasNamespaceDef("test_namespace", "test_description", null);
assertEquals(namespaceDef1, namespaceDef2, "Namespaces should be equal because the name of the" +
"namespace is same");
public void businessMetadataDefEquality() {
AtlasBusinessMetadataDef businessMetadataDef1 = new AtlasBusinessMetadataDef("test_businessMetadata", "test_description", null);
AtlasBusinessMetadataDef businessMetadataDef2 = new AtlasBusinessMetadataDef("test_businessMetadata", "test_description", null);
assertEquals(businessMetadataDef1, businessMetadataDef2, "businessMetadatas should be equal because the name of the" +
"businessMetadata is same");
}
@Test
public void namespaceDefUnequality() {
AtlasNamespaceDef namespaceDef1 = new AtlasNamespaceDef("test_namespace", "test_description", null);
AtlasNamespaceDef namespaceDef2 = new AtlasNamespaceDef("test_namespace1", "test_description", null);
assertNotEquals(namespaceDef1, namespaceDef2, "Namespaces should not be equal since they have a" +
public void businessMetadataDefUnequality() {
AtlasBusinessMetadataDef businessMetadataDef1 = new AtlasBusinessMetadataDef("test_businessMetadata", "test_description", null);
AtlasBusinessMetadataDef businessMetadataDef2 = new AtlasBusinessMetadataDef("test_businessMetadata1", "test_description", null);
assertNotEquals(businessMetadataDef1, businessMetadataDef2, "businessMetadatas should not be equal since they have a" +
"different name");
}
@Test
public void namespaceDefWithNamespaceAttributes() {
AtlasNamespaceDef namespaceDef1 = new AtlasNamespaceDef("test_namespace", "test_description", null);
public void businessMetadataDefWithAttributes() {
AtlasBusinessMetadataDef businessMetadataDef1 = new AtlasBusinessMetadataDef("test_businessMetadata", "test_description", null);
AtlasStructDef.AtlasAttributeDef nsAttr1 = new AtlasStructDef.AtlasAttributeDef("attr1", "int");
AtlasStructDef.AtlasAttributeDef nsAttr2 = new AtlasStructDef.AtlasAttributeDef("attr2", "int");
nsAttr1.setOption(ATTR_OPTION_APPLICABLE_ENTITY_TYPES, AtlasType.toJson(Collections.singleton("hive_table")));
nsAttr2.setOption(ATTR_OPTION_APPLICABLE_ENTITY_TYPES, AtlasType.toJson(Collections.singleton("hive_table")));
namespaceDef1.setAttributeDefs(Arrays.asList(nsAttr1, nsAttr2));
assertEquals(namespaceDef1.getAttributeDefs().size(), 2);
businessMetadataDef1.setAttributeDefs(Arrays.asList(nsAttr1, nsAttr2));
assertEquals(businessMetadataDef1.getAttributeDefs().size(), 2);
}
@Test
public void namespaceDefWithNamespaceAttributesHavingCardinality() {
AtlasNamespaceDef namespaceDef1 = new AtlasNamespaceDef("test_namespace", "test_description", null);
public void businessMetadataDefWithAttributesHavingCardinality() {
AtlasBusinessMetadataDef businessMetadataDef1 = new AtlasBusinessMetadataDef("test_businessMetadata", "test_description", null);
AtlasStructDef.AtlasAttributeDef nsAttr1 = new AtlasStructDef.AtlasAttributeDef("attr1", "int");
AtlasStructDef.AtlasAttributeDef nsAttr2 = new AtlasStructDef.AtlasAttributeDef("attr2", "int");
......@@ -78,7 +78,7 @@ public class TestAtlasNamespaceDef {
nsAttr2.setOption(ATTR_OPTION_APPLICABLE_ENTITY_TYPES, AtlasType.toJson(Collections.singleton("hive_table")));
nsAttr2.setCardinality(AtlasStructDef.AtlasAttributeDef.Cardinality.SET);
namespaceDef1.setAttributeDefs(Arrays.asList(nsAttr1, nsAttr2));
assertEquals(namespaceDef1.getAttributeDefs().size(), 2);
businessMetadataDef1.setAttributeDefs(Arrays.asList(nsAttr1, nsAttr2));
assertEquals(businessMetadataDef1.getAttributeDefs().size(), 2);
}
}
\ No newline at end of file
......@@ -20,7 +20,7 @@ package org.apache.atlas.query;
import org.apache.atlas.AtlasErrorCode;
import org.apache.atlas.exception.AtlasBaseException;
import org.apache.atlas.type.AtlasNamespaceType;
import org.apache.atlas.type.AtlasBusinessMetadataType;
import org.apache.atlas.type.AtlasType;
import org.apache.commons.lang.StringUtils;
......@@ -186,12 +186,12 @@ public class IdentifierHelper {
private void updateTypeInfo(org.apache.atlas.query.Lookup lookup, GremlinQueryComposer.Context context) {
parts = StringUtils.split(raw, ".");
// check if this is a namespace attribute
// check if this is a business attribute
if (parts.length == 2) {
try {
AtlasType type = lookup.getType(parts[0]);
if (type instanceof AtlasNamespaceType) {
if (type instanceof AtlasBusinessMetadataType) {
parts = new String[1];
parts[0] = raw;
}
......
......@@ -33,7 +33,6 @@ import org.apache.atlas.model.TypeCategory;
import org.apache.atlas.model.typedef.AtlasBaseTypeDef;
import org.apache.atlas.model.typedef.AtlasEntityDef;
import org.apache.atlas.model.typedef.AtlasEnumDef;
import org.apache.atlas.model.typedef.AtlasNamespaceDef;
import org.apache.atlas.model.typedef.AtlasStructDef;
import org.apache.atlas.model.typedef.AtlasStructDef.AtlasAttributeDef;
import org.apache.atlas.repository.Constants;
......
......@@ -347,7 +347,7 @@ public class ExportService {
final Set<String> structTypes = new HashSet<>();
final Set<String> enumTypes = new HashSet<>();
final Set<String> relationshipTypes = new HashSet<>();
final Set<String> namespaceTypes = new HashSet<>();
final Set<String> businessMetadataTypes = new HashSet<>();
final AtlasExportResult result;
private final ZipSink sink;
......
......@@ -24,11 +24,11 @@ import org.apache.atlas.model.instance.AtlasClassification;
import org.apache.atlas.model.instance.AtlasEntity;
import org.apache.atlas.model.typedef.AtlasStructDef;
import org.apache.atlas.type.AtlasArrayType;
import org.apache.atlas.type.AtlasBusinessMetadataType;
import org.apache.atlas.type.AtlasClassificationType;
import org.apache.atlas.type.AtlasEntityType;
import org.apache.atlas.type.AtlasEnumType;
import org.apache.atlas.type.AtlasMapType;
import org.apache.atlas.type.AtlasNamespaceType;
import org.apache.atlas.type.AtlasRelationshipType;
import org.apache.atlas.type.AtlasStructType;
import org.apache.atlas.type.AtlasType;
......@@ -106,8 +106,8 @@ class ExportTypeProcessor {
addClassificationType((AtlasClassificationType)type, context);
} else if (type instanceof AtlasRelationshipType) {
addRelationshipType(type.getTypeName(), context);
} else if (type instanceof AtlasNamespaceType) {
addNamespaceType((AtlasNamespaceType) type, context);
} else if (type instanceof AtlasBusinessMetadataType) {
addBusinessMetadataType((AtlasBusinessMetadataType) type, context);
} else if (type instanceof AtlasStructType) {
addStructType((AtlasStructType)type, context);
} else if (type instanceof AtlasEnumType) {
......@@ -172,11 +172,11 @@ class ExportTypeProcessor {
}
}
private void addNamespaceType(AtlasNamespaceType namespaceType, ExportService.ExportContext context) {
if (!context.namespaceTypes.contains(namespaceType.getTypeName())) {
context.namespaceTypes.add(namespaceType.getTypeName());
private void addBusinessMetadataType(AtlasBusinessMetadataType businessMetadataType, ExportService.ExportContext context) {
if (!context.businessMetadataTypes.contains(businessMetadataType.getTypeName())) {
context.businessMetadataTypes.add(businessMetadataType.getTypeName());
addAttributeTypes(namespaceType, context);
addAttributeTypes(businessMetadataType, context);
}
}
......
......@@ -30,11 +30,11 @@ import org.apache.atlas.ha.HAConfiguration;
import org.apache.atlas.listener.ActiveStateChangeHandler;
import org.apache.atlas.model.patches.AtlasPatch.PatchStatus;
import org.apache.atlas.model.typedef.AtlasBaseTypeDef;
import org.apache.atlas.model.typedef.AtlasBusinessMetadataDef;
import org.apache.atlas.model.typedef.AtlasClassificationDef;
import org.apache.atlas.model.typedef.AtlasEntityDef;
import org.apache.atlas.model.typedef.AtlasEnumDef;
import org.apache.atlas.model.typedef.AtlasEnumDef.AtlasEnumElementDef;
import org.apache.atlas.model.typedef.AtlasNamespaceDef;
import org.apache.atlas.model.typedef.AtlasRelationshipDef;
import org.apache.atlas.model.typedef.AtlasRelationshipDef.RelationshipCategory;
import org.apache.atlas.model.typedef.AtlasRelationshipEndDef;
......@@ -252,10 +252,10 @@ public class AtlasTypeDefStoreInitializer implements ActiveStateChangeHandler {
}
}
if (CollectionUtils.isNotEmpty(typesDef.getNamespaceDefs())) {
for (AtlasNamespaceDef namespaceDef : typesDef.getNamespaceDefs()) {
if (!typeRegistry.isRegisteredType(namespaceDef.getName())) {
typesToCreate.getNamespaceDefs().add(namespaceDef);
if (CollectionUtils.isNotEmpty(typesDef.getBusinessMetadataDefs())) {
for (AtlasBusinessMetadataDef businessMetadataDef : typesDef.getBusinessMetadataDefs()) {
if (!typeRegistry.isRegisteredType(businessMetadataDef.getName())) {
typesToCreate.getBusinessMetadataDefs().add(businessMetadataDef);
}
}
}
......@@ -344,16 +344,16 @@ public class AtlasTypeDefStoreInitializer implements ActiveStateChangeHandler {
}
}
if (CollectionUtils.isNotEmpty(typesDef.getNamespaceDefs())) {
for (AtlasNamespaceDef namespaceDef : typesDef.getNamespaceDefs()) {
AtlasNamespaceDef oldNamespaceDef = typeRegistry.getNamespaceDefByName(namespaceDef.getName());
if (CollectionUtils.isNotEmpty(typesDef.getBusinessMetadataDefs())) {
for (AtlasBusinessMetadataDef businessMetadataDef : typesDef.getBusinessMetadataDefs()) {
AtlasBusinessMetadataDef oldDef = typeRegistry.getBusinessMetadataDefByName(businessMetadataDef.getName());
if (oldNamespaceDef == null) {
if (oldDef == null) {
continue;
}
if (updateTypeAttributes(oldNamespaceDef, namespaceDef, checkTypeVersion)) {
typesToUpdate.getNamespaceDefs().add(namespaceDef);
if (updateTypeAttributes(oldDef, businessMetadataDef, checkTypeVersion)) {
typesToUpdate.getBusinessMetadataDefs().add(businessMetadataDef);
}
}
}
......
......@@ -250,19 +250,19 @@ public interface AtlasEntityStore {
/**
*
* @param guid
* @param namespaceAttributes
* @param businessAttrbutes
* @param isOverwrite
* @throws AtlasBaseException
*/
void addOrUpdateNamespaceAttributes(String guid, Map<String, Map<String, Object>> namespaceAttributes, boolean isOverwrite) throws AtlasBaseException;
void addOrUpdateBusinessAttributes(String guid, Map<String, Map<String, Object>> businessAttrbutes, boolean isOverwrite) throws AtlasBaseException;
/**
*
* @param guid
* @param namespaceAttributes
* @param businessAttributes
* @throws AtlasBaseException
*/
void removeNamespaceAttributes(String guid, Map<String, Map<String, Object>> namespaceAttributes) throws AtlasBaseException;
void removeBusinessAttributes(String guid, Map<String, Map<String, Object>> businessAttributes) throws AtlasBaseException;
/**
* Remove given labels, if labels is null/empty, no labels will be removed. If any labels in
......
......@@ -101,8 +101,8 @@ public class AtlasTypeDefGraphStoreV2 extends AtlasTypeDefGraphStore {
}
@Override
protected AtlasDefStore<AtlasNamespaceDef> getNamespaceDefStore(AtlasTypeRegistry typeRegistry) {
return new AtlasNamespaceDefStoreV2(this, typeRegistry);
protected AtlasDefStore<AtlasBusinessMetadataDef> getBusinessMetadataDefStore(AtlasTypeRegistry typeRegistry) {
return new AtlasBusinessMetadataDefStoreV2(this, typeRegistry);
}
@Override
......@@ -498,8 +498,8 @@ public class AtlasTypeDefGraphStoreV2 extends AtlasTypeDefGraphStore {
case RELATIONSHIP:
return TypeCategory.RELATIONSHIP;
case NAMESPACE:
return TypeCategory.NAMESPACE;
case BUSINESS_METADATA:
return TypeCategory.BUSINESS_METADATA;
}
return null;
......
......@@ -48,7 +48,7 @@ import org.apache.atlas.type.AtlasArrayType;
import org.apache.atlas.type.AtlasBuiltInTypes.AtlasObjectIdType;
import org.apache.atlas.type.AtlasEntityType;
import org.apache.atlas.type.AtlasMapType;
import org.apache.atlas.type.AtlasNamespaceType.AtlasNamespaceAttribute;
import org.apache.atlas.type.AtlasBusinessMetadataType.AtlasBusinessAttribute;
import org.apache.atlas.type.AtlasRelationshipType;
import org.apache.atlas.type.AtlasStructType;
import org.apache.atlas.type.AtlasStructType.AtlasAttribute;
......@@ -221,33 +221,33 @@ public class EntityGraphRetriever {
return ret;
}
public Map<String, Map<String, Object>> getEntityNamespaces(AtlasVertex entityVertex) throws AtlasBaseException {
Map<String, Map<String, Object>> ret = null;
String entityTypeName = getTypeName(entityVertex);
AtlasEntityType entityType = typeRegistry.getEntityTypeByName(entityTypeName);
Map<String, Map<String, AtlasNamespaceAttribute>> entityTypeNamespaces = entityType != null ? entityType.getNamespaceAttributes() : null;
public Map<String, Map<String, Object>> getBusinessMetadata(AtlasVertex entityVertex) throws AtlasBaseException {
Map<String, Map<String, Object>> ret = null;
String entityTypeName = getTypeName(entityVertex);
AtlasEntityType entityType = typeRegistry.getEntityTypeByName(entityTypeName);
Map<String, Map<String, AtlasBusinessAttribute>> entityTypeBm = entityType != null ? entityType.getBusinessAttributes() : null;
if (MapUtils.isNotEmpty(entityTypeNamespaces)) {
for (Map.Entry<String, Map<String, AtlasNamespaceAttribute>> entry : entityTypeNamespaces.entrySet()) {
String nsName = entry.getKey();
Map<String, AtlasNamespaceAttribute> nsAttributes = entry.getValue();
Map<String, Object> entityNsAttrs = null;
if (MapUtils.isNotEmpty(entityTypeBm)) {
for (Map.Entry<String, Map<String, AtlasBusinessAttribute>> entry : entityTypeBm.entrySet()) {
String bmName = entry.getKey();
Map<String, AtlasBusinessAttribute> bmAttributes = entry.getValue();
Map<String, Object> entityBmAttrs = null;
for (AtlasNamespaceAttribute nsAttribute : nsAttributes.values()) {
Object nsAttrValue = mapVertexToAttribute(entityVertex, nsAttribute, null, false, false);
for (AtlasBusinessAttribute bmAttribute : bmAttributes.values()) {
Object bmAttrValue = mapVertexToAttribute(entityVertex, bmAttribute, null, false, false);
if (nsAttrValue != null) {
if (bmAttrValue != null) {
if (ret == null) {
ret = new HashMap<>();
}
if (entityNsAttrs == null) {
entityNsAttrs = new HashMap<>();
if (entityBmAttrs == null) {
entityBmAttrs = new HashMap<>();
ret.put(nsName, entityNsAttrs);
ret.put(bmName, entityBmAttrs);
}
entityNsAttrs.put(nsAttribute.getName(), nsAttrValue);
entityBmAttrs.put(bmAttribute.getName(), bmAttrValue);
}
}
}
......@@ -622,7 +622,7 @@ public class EntityGraphRetriever {
mapSystemAttributes(entityVertex, entity);
mapNamespaceAttributes(entityVertex, entity);
mapBusinessAttributes(entityVertex, entity);
mapAttributes(entityVertex, entity, entityExtInfo, isMinExtInfo, includeReferences);
......@@ -804,8 +804,8 @@ public class EntityGraphRetriever {
}
}
private void mapNamespaceAttributes(AtlasVertex entityVertex, AtlasEntity entity) throws AtlasBaseException {
entity.setNamespaceAttributes(getEntityNamespaces(entityVertex));
private void mapBusinessAttributes(AtlasVertex entityVertex, AtlasEntity entity) throws AtlasBaseException {
entity.setBusinessAttributes(getBusinessMetadata(entityVertex));
}
public List<AtlasClassification> getAllClassifications(AtlasVertex entityVertex) throws AtlasBaseException {
......
......@@ -154,8 +154,8 @@ public class FilterUtil {
return atlasType.getTypeCategory() == TypeCategory.ENUM;
case "RELATIONSHIP":
return atlasType.getTypeCategory() == TypeCategory.RELATIONSHIP;
case "NAMESPACE":
return atlasType.getTypeCategory() == TypeCategory.NAMESPACE;
case "BUSINESS_METADATA":
return atlasType.getTypeCategory() == TypeCategory.BUSINESS_METADATA;
default:
// This shouldn't have happened
return false;
......
......@@ -37,13 +37,13 @@ import org.apache.atlas.model.instance.EntityMutations.EntityOperation;
import org.apache.atlas.model.lineage.AtlasLineageInfo;
import org.apache.atlas.model.lineage.AtlasLineageInfo.LineageDirection;
import org.apache.atlas.model.lineage.AtlasLineageInfo.LineageRelation;
import org.apache.atlas.model.typedef.AtlasBusinessMetadataDef;
import org.apache.atlas.model.typedef.AtlasClassificationDef;
import org.apache.atlas.model.typedef.AtlasEntityDef;
import org.apache.atlas.model.typedef.AtlasNamespaceDef;
import org.apache.atlas.model.typedef.AtlasRelationshipDef;
import org.apache.atlas.model.typedef.AtlasRelationshipDef.PropagateTags;
import org.apache.atlas.model.typedef.AtlasStructDef.AtlasAttributeDef;
import org.apache.atlas.model.typedef.AtlasTypesDef;
import org.apache.atlas.model.typedef.AtlasRelationshipDef.PropagateTags;
import org.apache.atlas.type.AtlasType;
import org.apache.atlas.type.AtlasTypeUtil;
import org.apache.atlas.utils.AuthenticationUtil;
......@@ -56,7 +56,7 @@ import java.util.*;
import static java.util.Arrays.asList;
import static org.apache.atlas.AtlasClient.REFERENCEABLE_ATTRIBUTE_NAME;
import static org.apache.atlas.model.typedef.AtlasNamespaceDef.ATTR_OPTION_APPLICABLE_ENTITY_TYPES;
import static org.apache.atlas.model.typedef.AtlasBusinessMetadataDef.ATTR_OPTION_APPLICABLE_ENTITY_TYPES;
import static org.apache.atlas.model.typedef.AtlasRelationshipDef.RelationshipCategory.AGGREGATION;
import static org.apache.atlas.model.typedef.AtlasRelationshipDef.RelationshipCategory.COMPOSITION;
import static org.apache.atlas.model.typedef.AtlasStructDef.AtlasAttributeDef.Cardinality.SET;
......@@ -318,25 +318,25 @@ public class QuickStartV2 {
List<AtlasRelationshipDef> relationshipDefs = asList(tableDatabaseTypeDef, viewDatabaseTypeDef, viewTablesTypeDef, tableColumnsTypeDef, tableStorageDescTypeDef, processProcessExecutionTypeDef);
List<AtlasClassificationDef> classificationDefs = asList(dimClassifDef, factClassifDef, piiClassifDef, metricClassifDef, etlClassifDef, jdbcClassifDef, logClassifDef);
// Namespace definitions
AtlasAttributeDef nsAttrDef1 = new AtlasAttributeDef("attr1", "int");
AtlasAttributeDef nsAttrDef2 = new AtlasAttributeDef("attr2", "int");
// BusinessMetadata definitions
AtlasAttributeDef bmAttrDef1 = new AtlasAttributeDef("attr1", "int");
AtlasAttributeDef bmAttrDef2 = new AtlasAttributeDef("attr2", "int");
nsAttrDef1.setOption(ATTR_OPTION_APPLICABLE_ENTITY_TYPES, AtlasType.toJson(Collections.singleton(TABLE_TYPE)));
nsAttrDef1.setIsOptional(true);
nsAttrDef1.setIsUnique(false);
bmAttrDef1.setOption(ATTR_OPTION_APPLICABLE_ENTITY_TYPES, AtlasType.toJson(Collections.singleton(TABLE_TYPE)));
bmAttrDef1.setIsOptional(true);
bmAttrDef1.setIsUnique(false);
nsAttrDef2.setOption(ATTR_OPTION_APPLICABLE_ENTITY_TYPES, AtlasType.toJson(Collections.singleton(TABLE_TYPE)));
nsAttrDef2.setIsOptional(true);
nsAttrDef2.setIsUnique(false);
bmAttrDef2.setOption(ATTR_OPTION_APPLICABLE_ENTITY_TYPES, AtlasType.toJson(Collections.singleton(TABLE_TYPE)));
bmAttrDef2.setIsOptional(true);
bmAttrDef2.setIsUnique(false);
AtlasNamespaceDef testNamespaceDef = new AtlasNamespaceDef("test_namespace", "test_description", VERSION_1);
AtlasBusinessMetadataDef testBusinessMetadataDef = new AtlasBusinessMetadataDef("test_businessMetadata", "test_description", VERSION_1);
testNamespaceDef.setAttributeDefs(Arrays.asList(nsAttrDef1, nsAttrDef2));
testBusinessMetadataDef.setAttributeDefs(Arrays.asList(bmAttrDef1, bmAttrDef2));
List<AtlasNamespaceDef> namespaceDefs = asList(testNamespaceDef);
List<AtlasBusinessMetadataDef> businessMetadataDefs = asList(testBusinessMetadataDef);
return new AtlasTypesDef(Collections.emptyList(), Collections.emptyList(), classificationDefs, entityDefs, relationshipDefs, namespaceDefs);
return new AtlasTypesDef(Collections.emptyList(), Collections.emptyList(), classificationDefs, entityDefs, relationshipDefs, businessMetadataDefs);
}
void createEntities() throws Exception {
......
......@@ -857,72 +857,72 @@ public class EntityREST {
}
@POST
@Path("/guid/{guid}/namespaces")
@Path("/guid/{guid}/businessmetata")
@Produces(Servlets.JSON_MEDIA_TYPE)
@Consumes(Servlets.JSON_MEDIA_TYPE)
public void addOrUpdateNamespaceAttributes(@PathParam("guid") final String guid, @QueryParam("isOverwrite") @DefaultValue("false") boolean isOverwrite, Map<String, Map<String, Object>> entityNamespaces) throws AtlasBaseException {
public void addOrUpdateBusinessAttributes(@PathParam("guid") final String guid, @QueryParam("isOverwrite") @DefaultValue("false") boolean isOverwrite, Map<String, Map<String, Object>> businessAttributes) throws AtlasBaseException {
AtlasPerfTracer perf = null;
try {
if (AtlasPerfTracer.isPerfTraceEnabled(PERF_LOG)) {
perf = AtlasPerfTracer.getPerfTracer(PERF_LOG, "EntityREST.addOrUpdateNamespaceAttributes(" + guid + ", isOverwrite=" + isOverwrite + ")");
perf = AtlasPerfTracer.getPerfTracer(PERF_LOG, "EntityREST.addOrUpdateBusinessAttributes(" + guid + ", isOverwrite=" + isOverwrite + ")");
}
entitiesStore.addOrUpdateNamespaceAttributes(guid, entityNamespaces, isOverwrite);
entitiesStore.addOrUpdateBusinessAttributes(guid, businessAttributes, isOverwrite);
} finally {
AtlasPerfTracer.log(perf);
}
}
@DELETE
@Path("/guid/{guid}/namespaces")
@Path("/guid/{guid}/businessmetata")
@Produces(Servlets.JSON_MEDIA_TYPE)
@Consumes(Servlets.JSON_MEDIA_TYPE)
public void removeNamespaceAttributes(@PathParam("guid") final String guid, Map<String, Map<String, Object>> entityNamespaces) throws AtlasBaseException {
public void removeBusinessAttributes(@PathParam("guid") final String guid, Map<String, Map<String, Object>> businessAttributes) throws AtlasBaseException {
AtlasPerfTracer perf = null;
try {
if (AtlasPerfTracer.isPerfTraceEnabled(PERF_LOG)) {
perf = AtlasPerfTracer.getPerfTracer(PERF_LOG, "EntityREST.removeNamespaceAttributes(" + guid + ")");
perf = AtlasPerfTracer.getPerfTracer(PERF_LOG, "EntityREST.removeBusinessAttributes(" + guid + ")");
}
entitiesStore.removeNamespaceAttributes(guid, entityNamespaces);
entitiesStore.removeBusinessAttributes(guid, businessAttributes);
} finally {
AtlasPerfTracer.log(perf);
}
}
@POST
@Path("/guid/{guid}/namespace/{namespace}")
@Path("/guid/{guid}/businessmetata/{bmName}")
@Produces(Servlets.JSON_MEDIA_TYPE)
@Consumes(Servlets.JSON_MEDIA_TYPE)
public void addOrUpdateNamespaceAttributes(@PathParam("guid") final String guid, @PathParam("namespace") final String namespace, Map<String, Object> entityNsAttributes) throws AtlasBaseException {
public void addOrUpdateBusinessAttributes(@PathParam("guid") final String guid, @PathParam("bmName") final String bmName, Map<String, Object> businessAttributes) throws AtlasBaseException {
AtlasPerfTracer perf = null;
try {
if (AtlasPerfTracer.isPerfTraceEnabled(PERF_LOG)) {
perf = AtlasPerfTracer.getPerfTracer(PERF_LOG, "EntityREST.addOrUpdateNamespaceAttributes(" + guid + ", " + namespace + ")");
perf = AtlasPerfTracer.getPerfTracer(PERF_LOG, "EntityREST.addOrUpdateBusinessAttributes(" + guid + ", " + bmName + ")");
}
entitiesStore.addOrUpdateNamespaceAttributes(guid, Collections.singletonMap(namespace, entityNsAttributes), false);
entitiesStore.addOrUpdateBusinessAttributes(guid, Collections.singletonMap(bmName, businessAttributes), false);
} finally {
AtlasPerfTracer.log(perf);
}
}
@DELETE
@Path("/guid/{guid}/namespace/{namespace}")
@Path("/guid/{guid}/businessmetata/{bmName}")
@Produces(Servlets.JSON_MEDIA_TYPE)
@Consumes(Servlets.JSON_MEDIA_TYPE)
public void removeNamespaceAttributes(@PathParam("guid") final String guid, @PathParam("namespace") final String namespace, Map<String, Object> entityNsAttributes) throws AtlasBaseException {
public void removeBusinessAttributes(@PathParam("guid") final String guid, @PathParam("bmName") final String bmName, Map<String, Object> businessAttributes) throws AtlasBaseException {
AtlasPerfTracer perf = null;
try {
if (AtlasPerfTracer.isPerfTraceEnabled(PERF_LOG)) {
perf = AtlasPerfTracer.getPerfTracer(PERF_LOG, "EntityREST.removeNamespaceAttributes(" + guid + ", " + namespace + ")");
perf = AtlasPerfTracer.getPerfTracer(PERF_LOG, "EntityREST.removeBusinessAttributes(" + guid + ", " + bmName + ")");
}
entitiesStore.removeNamespaceAttributes(guid, Collections.singletonMap(namespace, entityNsAttributes));
entitiesStore.removeBusinessAttributes(guid, Collections.singletonMap(bmName, businessAttributes));
} finally {
AtlasPerfTracer.log(perf);
}
......
......@@ -20,10 +20,10 @@ package org.apache.atlas.web.rest;
import org.apache.atlas.exception.AtlasBaseException;
import org.apache.atlas.model.SearchFilter;
import org.apache.atlas.model.typedef.AtlasBaseTypeDef;
import org.apache.atlas.model.typedef.AtlasBusinessMetadataDef;
import org.apache.atlas.model.typedef.AtlasClassificationDef;
import org.apache.atlas.model.typedef.AtlasEntityDef;
import org.apache.atlas.model.typedef.AtlasEnumDef;
import org.apache.atlas.model.typedef.AtlasNamespaceDef;
import org.apache.atlas.model.typedef.AtlasRelationshipDef;
import org.apache.atlas.model.typedef.AtlasStructDef;
import org.apache.atlas.model.typedef.AtlasTypeDefHeader;
......@@ -320,37 +320,37 @@ public class TypesREST {
}
/**
* Get the namespace definition for the given guid
* @param guid namespace guid
* @return namespace definition
* Get the businessMetadata definition for the given guid
* @param guid businessMetadata guid
* @return businessMetadata definition
* @throws AtlasBaseException
* @HTTP 200 On successful lookup of the the namespace definition by it's guid
* @HTTP 200 On successful lookup of the the businessMetadata definition by it's guid
* @HTTP 404 On Failed lookup for the given guid
*/
@GET
@Path("/namespacedef/guid/{guid}")
public AtlasNamespaceDef getNamespaceDefByGuid(@PathParam("guid") String guid) throws AtlasBaseException {
@Path("/businessmetadatadef/guid/{guid}")
public AtlasBusinessMetadataDef getBusinessMetadataDefByGuid(@PathParam("guid") String guid) throws AtlasBaseException {
Servlets.validateQueryParamLength("guid", guid);
AtlasNamespaceDef ret = typeDefStore.getNamespaceDefByGuid(guid);
AtlasBusinessMetadataDef ret = typeDefStore.getBusinessMetadataDefByGuid(guid);
return ret;
}
/**
* Get the namespace definition by it's name (unique)
* @param name namespace name
* @return namespace definition
* Get the businessMetadata definition by it's name (unique)
* @param name businessMetadata name
* @return businessMetadata definition
* @throws AtlasBaseException
* @HTTP 200 On successful lookup of the the namespace definition by it's name
* @HTTP 200 On successful lookup of the the businessMetadata definition by it's name
* @HTTP 404 On Failed lookup for the given name
*/
@GET
@Path("/namespacedef/name/{name}")
public AtlasNamespaceDef getNamespaceDefByName(@PathParam("name") String name) throws AtlasBaseException {
@Path("/businessmetadatadef/name/{name}")
public AtlasBusinessMetadataDef getBusinessMetadataDefByName(@PathParam("name") String name) throws AtlasBaseException {
Servlets.validateQueryParamLength("name", name);
AtlasNamespaceDef ret = typeDefStore.getNamespaceDefByName(name);
AtlasBusinessMetadataDef ret = typeDefStore.getBusinessMetadataDefByName(name);
return ret;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment