Commit 979200e7 by David Radley

=ATLAS2058 Add description to attributedefs and relationship enddefs

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