private Map<String, Object> removeUnusedMapEntries(
            AtlasVertex instanceVertex, String propertyName,
            Map<String, Object> currentMap,
            Map<String, Object> newMap, IDataType elementType,
            AttributeInfo attributeInfo)
                    throws AtlasException {

        Map<String, Object> additionalMap = new HashMap<>();
        for (String currentKey : currentMap.keySet()) {

            boolean shouldDeleteKey = !newMap.containsKey(currentKey);
            if (GraphHelper.isReference(elementType)) {

                //Delete the edge reference if its not part of new edges created/updated
                AtlasEdge currentEdge = (AtlasEdge)currentMap.get(currentKey);

                if (!newMap.values().contains(currentEdge)) {

                    boolean deleted =
                            deleteHandler.deleteEdgeReference(currentEdge, elementType.getTypeCategory(), attributeInfo.isComposite, true);
                    if (!deleted) {
                        additionalMap.put(currentKey, currentEdge);
                        shouldDeleteKey = false;
                    }
                }
            }

            if (shouldDeleteKey) {
                String propertyNameForKey = GraphHelper.getQualifiedNameForMapKey(propertyName, currentKey);
                GraphHelper.setProperty(instanceVertex, propertyNameForKey, null);
            }
        }
        return additionalMap;
    }
private Map < String , Object > removeUnusedMapEntries ( AtlasVertex instanceVertex , String propertyName , Map < String , Object > currentMap , Map < String , Object > newMap , IDataType elementType , AttributeInfo attributeInfo ) throws AtlasException { Map < String , Object > additionalMap = new HashMap < > ( ) ; for ( String currentKey : currentMap . keySet ( ) ) { boolean shouldDeleteKey = ! newMap . containsKey ( currentKey ) ; if ( GraphHelper . isReference ( elementType ) ) { AtlasEdge currentEdge = ( AtlasEdge ) currentMap . get ( currentKey ) ; if ( ! newMap . values ( ) . contains ( currentEdge ) ) { boolean deleted = deleteHandler . deleteEdgeReference ( currentEdge , elementType . getTypeCategory ( ) , attributeInfo . isComposite , true ) ; if ( ! deleted ) { additionalMap . put ( currentKey , currentEdge ) ; shouldDeleteKey = false ; } } } if ( shouldDeleteKey ) { String propertyNameForKey = GraphHelper . getQualifiedNameForMapKey ( propertyName , currentKey ) ; GraphHelper . setProperty ( instanceVertex , propertyNameForKey , null ) ; } } return additionalMap ; }
Remove unused entries from map