public AtlasArrayType(String elementTypeName, int minCount, int maxCount) { super(AtlasBaseTypeDef.getArrayTypeName(elementTypeName), TypeCategory.ARRAY); this.elementTypeName = elementTypeName; this.minCount = minCount; this.maxCount = maxCount; this.elementType = null; }
protected AtlasType(AtlasBaseTypeDef typeDef) { this(typeDef.getName(), typeDef.getCategory()); }
protected AtlasBaseTypeDef(AtlasBaseTypeDef other) { if (other != null) { this.category = other.category; setGuid(other.getGuid()); setCreatedBy(other.getCreatedBy()); setUpdatedBy(other.getUpdatedBy()); setCreateTime(other.getCreateTime()); setUpdateTime(other.getUpdateTime()); setVersion(other.getVersion()); setName(other.getName()); setDescription(other.getDescription()); setTypeVersion(other.getTypeVersion()); setOptions(other.getOptions()); } else { this.category = TypeCategory.PRIMITIVE; setGuid(null); setCreatedBy(null); setUpdatedBy(null); setCreateTime(null); setUpdateTime(null); setVersion(null); setName(null); setDescription(null); setTypeVersion(null); setOptions(null); } }
public AtlasTypeDefHeader(AtlasBaseTypeDef typeDef) { this(typeDef.getGuid(), typeDef.getName(), typeDef.getCategory()); }
protected AtlasBaseTypeDef(TypeCategory category, String name, String description, String typeVersion, Map<String, String> options) { super(); this.category = category; setGuid(null); setCreatedBy(null); setUpdatedBy(null); setCreateTime(null); setUpdateTime(null); setVersion(null); setName(name); setDescription(description); setTypeVersion(typeVersion); setOptions(options); }
Preconditions.checkArgument(StringUtils.isNotBlank(typeDef.getName()), "Type name can't be null/empty"); if (StringUtils.isBlank(typeDef.getTypeVersion())) { typeDef.setTypeVersion("1.0"); if (typeDef.getVersion() == null) { typeDef.setVersion(1L); if (StringUtils.isBlank(typeDef.getGuid())) { typeDef.setGuid(UUID.randomUUID().toString()); if (typeDef.getCreateTime() == null) { typeDef.setCreateTime(new Date()); if (typeDef.getUpdateTime() == null) { typeDef.setUpdateTime(new Date()); ret.setProperty(Constants.TYPENAME_PROPERTY_KEY, typeDef.getName()); ret.setProperty(Constants.TYPEDESCRIPTION_PROPERTY_KEY, StringUtils.isNotBlank(typeDef.getDescription()) ? typeDef.getDescription() : typeDef.getName()); if (StringUtils.isNotEmpty(typeDef.getServiceType())) { ret.setProperty(Constants.TYPESERVICETYPE_PROPERTY_KEY, typeDef.getServiceType()); ret.setProperty(Constants.TYPEVERSION_PROPERTY_KEY, typeDef.getTypeVersion()); ret.setProperty(Constants.GUID_PROPERTY_KEY, typeDef.getGuid()); ret.setProperty(Constants.CREATED_BY_KEY, getCurrentUser()); ret.setProperty(Constants.TIMESTAMP_PROPERTY_KEY, typeDef.getCreateTime().getTime()); ret.setProperty(Constants.MODIFIED_BY_KEY, getCurrentUser());
private <T extends AtlasBaseTypeDef> boolean hasTypeDef(Collection<T> typeDefs, String name) { if (CollectionUtils.isNotEmpty(typeDefs)) { for (T typeDef : typeDefs) { if (typeDef.getName().equals(name)) { return true; } } } return false; }
void updateTypeVertex(AtlasBaseTypeDef typeDef, AtlasVertex vertex) { if (!isTypeVertex(vertex)) { LOG.warn("updateTypeVertex(): not a type-vertex - {}", vertex); return; } updateVertexProperty(vertex, Constants.GUID_PROPERTY_KEY, typeDef.getGuid()); /* * rename of a type is supported yet - as the typename is used to in the name of the edges from this vertex * To support rename of types, he edge names should be derived from an internal-name - not directly the typename * updateVertexProperty(vertex, Constants.TYPENAME_PROPERTY_KEY, typeDef.getName()); */ updateVertexProperty(vertex, Constants.TYPEDESCRIPTION_PROPERTY_KEY, typeDef.getDescription()); updateVertexProperty(vertex, Constants.TYPEVERSION_PROPERTY_KEY, typeDef.getTypeVersion()); updateVertexProperty(vertex, Constants.TYPEOPTIONS_PROPERTY_KEY, AtlasType.toJson(typeDef.getOptions())); if (StringUtils.isNotEmpty(typeDef.getServiceType())) { updateVertexProperty(vertex, Constants.TYPESERVICETYPE_PROPERTY_KEY, typeDef.getServiceType()); } markVertexUpdated(vertex); }
ret.add(getAttributeDef(attrNamePrefix, ENUM_DEF_WITH_NO_DEFAULT.getName())); ret.add(getAttributeDef(attrNamePrefix, AtlasBaseTypeDef.getArrayTypeName(ENUM_DEF.getName()))); ret.add(getAttributeDef(attrNamePrefix, AtlasBaseTypeDef.getArrayTypeName(ENUM_DEF_WITH_NO_DEFAULT.getName()))); ret.add(getAttributeDef(attrNamePrefix, AtlasBaseTypeDef.getArrayTypeName(attributeType))); AtlasBaseTypeDef.getMapTypeName(ENUM_DEF.getName(), attributeType))); AtlasBaseTypeDef.getMapTypeName(ENUM_DEF_WITH_NO_DEFAULT.getName(), attributeType))); AtlasBaseTypeDef.getMapTypeName(attributeType, ENUM_DEF_WITH_NO_DEFAULT.getName()))); AtlasBaseTypeDef.getMapTypeName(attributeType, ENUM_DEF.getName()))); AtlasBaseTypeDef.getMapTypeName(attributeType, attributeType2))); AtlasBaseTypeDef.getArrayTypeName(AtlasBaseTypeDef.getArrayTypeName(attributeType2)))); ret.add(getAttributeDef(attrNamePrefix, AtlasBaseTypeDef.getArrayTypeName( AtlasBaseTypeDef.getMapTypeName(attributeType, attributeType2)))); ret.add(getAttributeDef(attrNamePrefix, AtlasBaseTypeDef.getMapTypeName(attributeType, AtlasBaseTypeDef.getArrayTypeName(attributeType2)))); ret.add(getAttributeDef(attrNamePrefix, AtlasBaseTypeDef.getMapTypeName(attributeType, AtlasBaseTypeDef.getMapTypeName(attributeType, attributeType2))));
public static void populateSystemAttributes(AtlasBaseTypeDef typeDef) { typeDef.setCreatedBy(TestUtilsV2.TEST_USER); typeDef.setUpdatedBy(TestUtilsV2.TEST_USER); } }
private void removeTypeByGuidWithNoRefResolve(AtlasBaseTypeDef typeDef) { switch (typeDef.getCategory()) { case ENUM: registryData.enumDefs.removeTypeDefByGuid(typeDef.getGuid()); break; case STRUCT: registryData.structDefs.removeTypeDefByGuid(typeDef.getGuid()); break; case CLASSIFICATION: registryData.classificationDefs.removeTypeDefByGuid(typeDef.getGuid()); break; case ENTITY: registryData.entityDefs.removeTypeDefByGuid(typeDef.getGuid()); break; case RELATIONSHIP: registryData.relationshipDefs.removeTypeDefByGuid(typeDef.getGuid()); break; } deletedTypes.add(typeDef); }
public void updateGuid(String typeName, String newGuid) { if (typeName != null) { T1 typeDef = typeDefNameMap.get(typeName); if (typeDef != null) { String currGuid = typeDef.getGuid(); if (!typeDefGuidMap.containsKey(newGuid) || !StringUtils.equals(currGuid, newGuid)) { if(LOG.isDebugEnabled()) { if (!typeDefGuidMap.containsKey(newGuid)) { LOG.debug("TypeDefGuidMap doesn't contain entry for guid {}. Adding new entry", newGuid); } else { LOG.debug("Removing entry for guid {} and adding entry for guid {}", currGuid, newGuid); } } if (currGuid != null) { typeDefGuidMap.remove(currGuid); } typeDef.setGuid(newGuid); if (newGuid != null) { typeDefGuidMap.put(newGuid, typeDef); } typeCache.updateGuid(typeName, currGuid, newGuid); } } } }
public AtlasMapType(String keyTypeName, String valueTypeName) { super(AtlasBaseTypeDef.getMapTypeName(keyTypeName, valueTypeName), TypeCategory.MAP); this.keyTypeName = keyTypeName; this.valueTypeName = valueTypeName; }
TypeCategory getTypeCategory(AtlasBaseTypeDef typeDef) { switch (typeDef.getCategory()) { case ENTITY: return TypeCategory.CLASS; case CLASSIFICATION: return TypeCategory.TRAIT; case STRUCT: return TypeCategory.STRUCT; case ENUM: return TypeCategory.ENUM; case RELATIONSHIP: return TypeCategory.RELATIONSHIP; } return null; }
public void removeTypeDefByName(String name) { if (name != null) { T1 typeDef = typeDefNameMap.remove(name); typeNameMap.remove(name); typeCache.removeTypeByName(name); String guid = typeDef != null ? typeDef.getGuid() : null; if (guid != null) { typeDefGuidMap.remove(guid); typeCache.removeTypeByGuid(guid); } } }
protected AtlasBaseTypeDef(TypeCategory category, String name, String description, String typeVersion, Map<String, String> options) { super(); this.category = category; setGuid(null); setCreatedBy(null); setUpdatedBy(null); setCreateTime(null); setUpdateTime(null); setVersion(null); setName(name); setDescription(description); setTypeVersion(typeVersion); setOptions(options); }
Preconditions.checkArgument(StringUtils.isNotBlank(typeDef.getName()), "Type name can't be null/empty"); if (StringUtils.isBlank(typeDef.getTypeVersion())) { typeDef.setTypeVersion("1.0"); if (typeDef.getVersion() == null) { typeDef.setVersion(1L); if (StringUtils.isBlank(typeDef.getGuid())) { typeDef.setGuid(UUID.randomUUID().toString()); if (typeDef.getCreateTime() == null) { typeDef.setCreateTime(new Date()); if (typeDef.getUpdateTime() == null) { typeDef.setUpdateTime(new Date()); ret.setProperty(Constants.TYPENAME_PROPERTY_KEY, typeDef.getName()); ret.setProperty(Constants.TYPEDESCRIPTION_PROPERTY_KEY, StringUtils.isNotBlank(typeDef.getDescription()) ? typeDef.getDescription() : typeDef.getName()); ret.setProperty(Constants.TYPEVERSION_PROPERTY_KEY, typeDef.getTypeVersion()); ret.setProperty(Constants.GUID_PROPERTY_KEY, typeDef.getGuid()); ret.setProperty(Constants.CREATED_BY_KEY, getCurrentUser()); ret.setProperty(Constants.TIMESTAMP_PROPERTY_KEY, typeDef.getCreateTime().getTime()); ret.setProperty(Constants.MODIFIED_BY_KEY, getCurrentUser()); ret.setProperty(Constants.MODIFICATION_TIMESTAMP_PROPERTY_KEY, typeDef.getUpdateTime().getTime()); ret.setProperty(Constants.VERSION_PROPERTY_KEY, typeDef.getVersion()); ret.setProperty(Constants.TYPEOPTIONS_PROPERTY_KEY, AtlasType.toJson(typeDef.getOptions()));
private <T extends AtlasBaseTypeDef> boolean hasTypeDef(Collection<T> typeDefs, String name) { if (CollectionUtils.isNotEmpty(typeDefs)) { for (T typeDef : typeDefs) { if (typeDef.getName().equals(name)) { return true; } } } return false; }
void updateTypeVertex(AtlasBaseTypeDef typeDef, AtlasVertex vertex) { if (!isTypeVertex(vertex)) { LOG.warn("updateTypeVertex(): not a type-vertex - {}", vertex); return; } updateVertexProperty(vertex, Constants.GUID_PROPERTY_KEY, typeDef.getGuid()); /* * rename of a type is supported yet - as the typename is used to in the name of the edges from this vertex * To support rename of types, he edge names should be derived from an internal-name - not directly the typename * updateVertexProperty(vertex, Constants.TYPENAME_PROPERTY_KEY, typeDef.getName()); */ updateVertexProperty(vertex, Constants.TYPEDESCRIPTION_PROPERTY_KEY, typeDef.getDescription()); updateVertexProperty(vertex, Constants.TYPEVERSION_PROPERTY_KEY, typeDef.getTypeVersion()); updateVertexProperty(vertex, Constants.TYPEOPTIONS_PROPERTY_KEY, AtlasType.toJson(typeDef.getOptions())); markVertexUpdated(vertex); }