Commit 979200e7 by David Radley

=ATLAS2058 Add description to attributedefs and relationship enddefs

parent 586b5eb2
......@@ -60,9 +60,21 @@ public class AtlasRelationshipEndDef implements Serializable {
*/
private Cardinality cardinality;
/**
* When set this indicates that this end is is a legacy attribute
* When set this indicates that this end is a legacy attribute
*/
private boolean isLegacyAttribute;
/**
* Description of the end
*/
private String description;
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
/**
* Base constructor
......@@ -98,13 +110,44 @@ public class AtlasRelationshipEndDef implements Serializable {
public AtlasRelationshipEndDef(String typeName, String name, Cardinality cardinality, boolean isContainer) {
this(typeName, name, cardinality, isContainer, false);
}
/**
*
* @param typeName
* - The name of an entityDef type
* @param name
* - The name of the new attribute that the entity instance will pick up.
* @param cardinality
* - whether the end is SINGLE (1) or SET (many)
* @param isContainer
* - whether the end is a container or not
* @param isLegacyAttribute
* - whether this is a legacy attribute
*/
public AtlasRelationshipEndDef(String typeName, String name, Cardinality cardinality, boolean isContainer, boolean isLegacyAttribute) {
this(typeName, name, cardinality, isContainer, isLegacyAttribute,"");
}
/**
*
* @param typeName
* - The name of an entityDef type
* @param name
* - The name of the new attribute that the entity instance will pick up.
* @param cardinality
* - whether the end is SINGLE (1) or SET (many)
* @param isContainer
* - whether the end is a container or not
* @param isLegacyAttribute
* - whether this is a legacy attribute
* @param description
* - The description of this end of the relationship.
*/
public AtlasRelationshipEndDef(String typeName, String name, Cardinality cardinality, boolean isContainer, boolean isLegacyAttribute, String description) {
setType(typeName);
setName(name);
setCardinality(cardinality);
setIsContainer(isContainer);
setIsLegacyAttribute(isLegacyAttribute);
setDescription(description);
}
/**
......@@ -118,6 +161,7 @@ public class AtlasRelationshipEndDef implements Serializable {
setIsContainer(other.getIsContainer());
setCardinality(other.getCardinality());
setIsLegacyAttribute(other.isLegacyAttribute);
setDescription(other.description);
}
}
......@@ -177,6 +221,7 @@ public class AtlasRelationshipEndDef implements Serializable {
sb.append("AtlasRelationshipEndDef{");
sb.append("type='").append(type).append('\'');
sb.append(", name==>'").append(name).append('\'');
sb.append(", description==>'").append(description).append('\'');
sb.append(", isContainer==>'").append(isContainer).append('\'');
sb.append(", cardinality==>'").append(cardinality).append('\'');
sb.append(", isLegacyAttribute==>'").append(isLegacyAttribute).append('\'');
......@@ -195,6 +240,7 @@ public class AtlasRelationshipEndDef implements Serializable {
return Objects.equals(type, that.type) &&
Objects.equals(name, that.name) &&
Objects.equals(description, that.description) &&
isContainer == that.isContainer &&
cardinality == that.cardinality &&
isLegacyAttribute == that.isLegacyAttribute;
......@@ -202,7 +248,7 @@ public class AtlasRelationshipEndDef implements Serializable {
@Override
public int hashCode() {
return Objects.hash(type, getName(), isContainer, cardinality, isLegacyAttribute);
return Objects.hash(type, getName(), description, isContainer, cardinality, isLegacyAttribute);
}
@Override
......
......@@ -272,6 +272,7 @@ public class AtlasStructDef extends AtlasBaseTypeDef implements Serializable {
private boolean isUnique;
private boolean isIndexable;
private String defaultValue;
private String description;
private List<AtlasConstraintDef> constraints;
......@@ -281,14 +282,15 @@ public class AtlasStructDef extends AtlasBaseTypeDef implements Serializable {
this(name, typeName, false, Cardinality.SINGLE, COUNT_NOT_SET, COUNT_NOT_SET, false, false, null);
}
public AtlasAttributeDef(String name, String typeName, boolean isOptional, Cardinality cardinality,
int valuesMinCount, int valuesMaxCount, boolean isUnique, boolean isIndexable, List<AtlasConstraintDef> constraints) {
this(name, typeName, isOptional, cardinality, valuesMinCount, valuesMaxCount, isUnique, isIndexable, null, constraints);
this(name, typeName, isOptional, cardinality, valuesMinCount, valuesMaxCount, isUnique, isIndexable, null, constraints, "");
}
public AtlasAttributeDef(String name, String typeName, boolean isOptional, Cardinality cardinality,
int valuesMinCount, int valuesMaxCount, boolean isUnique, boolean isIndexable, String defaultValue,
List<AtlasConstraintDef> constraints) {
List<AtlasConstraintDef> constraints, String description) {
setName(name);
setTypeName(typeName);
setIsOptional(isOptional);
......@@ -299,6 +301,7 @@ public class AtlasStructDef extends AtlasBaseTypeDef implements Serializable {
setIsIndexable(isIndexable);
setDefaultValue(defaultValue);
setConstraints(constraints);
setDescription(description);
}
public AtlasAttributeDef(AtlasAttributeDef other) {
......@@ -313,6 +316,7 @@ public class AtlasStructDef extends AtlasBaseTypeDef implements Serializable {
setIsIndexable(other.getIsIndexable());
setDefaultValue(other.getDefaultValue());
setConstraints(other.getConstraints());
setDescription((other.getDescription()));
}
}
......@@ -412,6 +416,14 @@ public class AtlasStructDef extends AtlasBaseTypeDef implements Serializable {
cDefs.add(constraintDef);
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public StringBuilder toString(StringBuilder sb) {
if (sb == null) {
sb = new StringBuilder();
......@@ -420,6 +432,7 @@ public class AtlasStructDef extends AtlasBaseTypeDef implements Serializable {
sb.append("AtlasAttributeDef{");
sb.append("name='").append(name).append('\'');
sb.append(", typeName='").append(typeName).append('\'');
sb.append(", description='").append(description).append('\'');
sb.append(", getIsOptional=").append(isOptional);
sb.append(", cardinality=").append(cardinality);
sb.append(", valuesMinCount=").append(valuesMinCount);
......@@ -458,12 +471,13 @@ public class AtlasStructDef extends AtlasBaseTypeDef implements Serializable {
Objects.equals(typeName, that.typeName) &&
cardinality == that.cardinality &&
Objects.equals(defaultValue, that.defaultValue) &&
Objects.equals(description, that.description) &&
Objects.equals(constraints, that.constraints);
}
@Override
public int hashCode() {
return Objects.hash(name, typeName, isOptional, cardinality, valuesMinCount, valuesMaxCount, isUnique, isIndexable, defaultValue, constraints);
return Objects.hash(name, typeName, isOptional, cardinality, valuesMinCount, valuesMaxCount, isUnique, isIndexable, defaultValue, constraints, description);
}
@Override
......
......@@ -463,6 +463,7 @@ public class AtlasStructDefStoreV1 extends AtlasAbstractDefStoreV1<AtlasStructDe
attribInfo.put("isComposite", attribute.isOwnedRef());
attribInfo.put("reverseAttributeName", attribute.getInverseRefAttributeName());
attribInfo.put("defaultValue", attributeDef.getDefaultValue());
attribInfo.put("description", attributeDef.getDescription());
final int lower;
final int upper;
......@@ -502,6 +503,7 @@ public class AtlasStructDefStoreV1 extends AtlasAbstractDefStoreV1<AtlasStructDe
ret.setIsUnique((Boolean) attribInfo.get("isUnique"));
ret.setIsIndexable((Boolean) attribInfo.get("isIndexable"));
ret.setDefaultValue((String) attribInfo.get("defaultValue"));
ret.setDescription((String) attribInfo.get("description"));
if ((Boolean)attribInfo.get("isComposite")) {
ret.addConstraint(new AtlasConstraintDef(AtlasConstraintDef.CONSTRAINT_TYPE_OWNED_REF));
......
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