@@ -789,71 +789,81 @@ protected void deleteTypeVertex(AtlasVertex instanceVertex, boolean force) throw
789
789
}
790
790
791
791
String typeName = GraphHelper .getTypeName (instanceVertex );
792
- AtlasType parentType = typeRegistry .getType (typeName );
793
792
794
- if (parentType instanceof AtlasStructType ) {
795
- AtlasStructType structType = (AtlasStructType ) parentType ;
796
- boolean isEntityType = (parentType instanceof AtlasEntityType );
793
+ if (StringUtils .isNotEmpty (typeName )) {
794
+ AtlasType parentType = typeRegistry .getType (typeName );
797
795
798
- for (AtlasStructType .AtlasAttribute attributeInfo : structType .getAllAttributes ().values ()) {
799
- if (LOG .isDebugEnabled ()) {
800
- LOG .debug ("Deleting attribute {} for {}" , attributeInfo .getName (), string (instanceVertex ));
801
- }
796
+ if (parentType instanceof AtlasStructType ) {
797
+ AtlasStructType structType = (AtlasStructType ) parentType ;
798
+ boolean isEntityType = (parentType instanceof AtlasEntityType );
799
+
800
+ for (AtlasStructType .AtlasAttribute attributeInfo : structType .getAllAttributes ().values ()) {
801
+ if (LOG .isDebugEnabled ()) {
802
+ LOG .debug ("Deleting attribute {} for {}" , attributeInfo .getName (), string (instanceVertex ));
803
+ }
802
804
803
- boolean isOwned = isEntityType && attributeInfo .isOwnedRef ();
804
- AtlasType attrType = attributeInfo .getAttributeType ();
805
- String edgeLabel = attributeInfo .getRelationshipEdgeLabel ();
805
+ boolean isOwned = isEntityType && attributeInfo .isOwnedRef ();
806
+ AtlasType attrType = attributeInfo .getAttributeType ();
807
+ String edgeLabel = attributeInfo .getRelationshipEdgeLabel ();
806
808
807
- switch (attrType .getTypeCategory ()) {
808
- case OBJECT_ID_TYPE :
809
- //If its class attribute, delete the reference
810
- deleteEdgeReference (instanceVertex , edgeLabel , attrType .getTypeCategory (), isOwned );
811
- break ;
809
+ switch (attrType .getTypeCategory ()) {
810
+ case OBJECT_ID_TYPE :
811
+ //If its class attribute, delete the reference
812
+ deleteEdgeReference (instanceVertex , edgeLabel , attrType .getTypeCategory (), isOwned );
813
+ break ;
812
814
813
- case STRUCT :
814
- //If its struct attribute, delete the reference
815
- deleteEdgeReference (instanceVertex , edgeLabel , attrType .getTypeCategory (), false );
816
- break ;
815
+ case STRUCT :
816
+ //If its struct attribute, delete the reference
817
+ deleteEdgeReference (instanceVertex , edgeLabel , attrType .getTypeCategory (), false );
818
+ break ;
817
819
818
- case ARRAY :
819
- //For array attribute, if the element is struct/class, delete all the references
820
- AtlasArrayType arrType = (AtlasArrayType ) attrType ;
821
- AtlasType elemType = arrType .getElementType ();
820
+ case ARRAY :
821
+ //For array attribute, if the element is struct/class, delete all the references
822
+ AtlasArrayType arrType = (AtlasArrayType ) attrType ;
823
+ AtlasType elemType = arrType .getElementType ();
822
824
823
- if (isReference (elemType .getTypeCategory ())) {
824
- List <AtlasEdge > edges = getCollectionElementsUsingRelationship (instanceVertex , attributeInfo );
825
+ if (isReference (elemType .getTypeCategory ())) {
826
+ List <AtlasEdge > edges = getCollectionElementsUsingRelationship (instanceVertex , attributeInfo );
825
827
826
- if (CollectionUtils .isNotEmpty (edges )) {
827
- for (AtlasEdge edge : edges ) {
828
- deleteEdgeReference (edge , elemType .getTypeCategory (), isOwned , false , instanceVertex );
828
+ if (CollectionUtils .isNotEmpty (edges )) {
829
+ for (AtlasEdge edge : edges ) {
830
+ deleteEdgeReference (edge , elemType .getTypeCategory (), isOwned , false , instanceVertex );
831
+ }
829
832
}
830
833
}
831
- }
832
- break ;
834
+ break ;
833
835
834
- case MAP :
835
- //For map attribute, if the value type is struct/class, delete all the references
836
- AtlasMapType mapType = (AtlasMapType ) attrType ;
837
- TypeCategory valueTypeCategory = mapType .getValueType ().getTypeCategory ();
836
+ case MAP :
837
+ //For map attribute, if the value type is struct/class, delete all the references
838
+ AtlasMapType mapType = (AtlasMapType ) attrType ;
839
+ TypeCategory valueTypeCategory = mapType .getValueType ().getTypeCategory ();
838
840
839
- if (isReference (valueTypeCategory )) {
840
- List <AtlasEdge > edges = getMapValuesUsingRelationship (instanceVertex , attributeInfo );
841
+ if (isReference (valueTypeCategory )) {
842
+ List <AtlasEdge > edges = getMapValuesUsingRelationship (instanceVertex , attributeInfo );
841
843
842
- for (AtlasEdge edge : edges ) {
843
- deleteEdgeReference (edge , valueTypeCategory , isOwned , false , instanceVertex );
844
+ for (AtlasEdge edge : edges ) {
845
+ deleteEdgeReference (edge , valueTypeCategory , isOwned , false , instanceVertex );
846
+ }
844
847
}
845
- }
846
- break ;
848
+ break ;
847
849
848
- case PRIMITIVE :
849
- // This is different from upstream atlas.
850
- // Here we are not deleting the unique property thus users can only restore after deleting an entity.
851
- if (attributeInfo .getVertexUniquePropertyName () != null && force ) {
852
- instanceVertex .removeProperty (attributeInfo .getVertexUniquePropertyName ());
853
- }
854
- break ;
850
+ case PRIMITIVE :
851
+ // This is different from upstream atlas.
852
+ // Here we are not deleting the unique property thus users can only restore after deleting an entity.
853
+ if (attributeInfo .getVertexUniquePropertyName () != null && force ) {
854
+ instanceVertex .removeProperty (attributeInfo .getVertexUniquePropertyName ());
855
+ }
856
+ break ;
857
+ }
855
858
}
856
859
}
860
+ } else {
861
+ try {
862
+ LOG .error ("typeName not found for the vertex {}" , instanceVertex .getIdForDisplay ());
863
+ } catch (Exception e ) {
864
+ LOG .error ("Error while writing error log" );
865
+ e .printStackTrace ();
866
+ }
857
867
}
858
868
859
869
deleteVertex (instanceVertex , force );
0 commit comments