src/main/java/de/blau/android/osm/StorageDelegator.java
/**
     * Redo all backlinks
     * 
     * This may throw an IllegalStateException if existing data was inconsistent
     * 
     * @param tempCurrent temp storage
     * @param nodeIndex index to the nodes in temp
     * @param wayIndex index to the ways in temp
     * @param relationIndex index to the relations in temp
     * @return true if successful
     */
Redo all backlinks

This may throw an IllegalStateException if existing data was inconsistent


Redo all backlinks This may throw an IllegalStateException if existing data was inconsistent
private boolean redoBacklinks(@NonNull Storage tempCurrent, @NonNull LongOsmElementMap<Node> nodeIndex, @NonNull LongOsmElementMap<Way> wayIndex,
            @NonNull LongOsmElementMap<Relation> relationIndex) {
        for (Relation r : currentStorage.getRelations()) {
            final List<RelationMember> members = r.getMembers();
            if (members != null) {
                for (RelationMember rm : members) {
                    checkMember(r.getOsmId(), rm);
                    final long ref = rm.getRef();
                    final String type = rm.getType();
                    OsmElement e = elementFromIndex(r, type, ref, nodeIndex, wayIndex, relationIndex);
                    if (e != null) {
                        e.clearParentRelations();
                    }
                }
            } else {
                Log.e(DEBUG_TAG, "Relation has no members " + r.getOsmId());
            }
        }
        for (Relation r : tempCurrent.getRelations()) {
            final List<RelationMember> members = r.getMembers();
            if (members != null) {
                for (RelationMember rm : members) {
                    checkMember(r.getOsmId(), rm);
                    final long ref = rm.getRef();
                    final String type = rm.getType();
                    OsmElement e = elementFromIndex(r, type, ref, nodeIndex, wayIndex, relationIndex);
                    if (e != null) {
                        rm.setElement(e);
                        e.addParentRelation(r);
                    } else if (memberIsDeleted(r, rm)) {
                        Log.e(DEBUG_TAG, "redoBacklinks relation " + r.getOsmId() + " member " + type + " " + ref + " missing");
                        return false;
                    } else if (rm.downloaded()) {
                        Log.w(DEBUG_TAG, "redoBacklinks relation " + r.getOsmId() + " member " + type + " " + ref + " not in target storage");
                        rm.setElement(null);
                    }
                }
            } else {
                Log.e(DEBUG_TAG, "Relation has no members " + r.getOsmId());
            }
        }
        return true; 
    }
private boolean redoBacklinks ( @ NonNull Storage tempCurrent , @ NonNull LongOsmElementMap < Node > nodeIndex , @ NonNull LongOsmElementMap < Way > wayIndex , @ NonNull LongOsmElementMap < Relation > relationIndex ) { for ( Relation r : currentStorage . getRelations ( ) ) { final List < RelationMember > members = r . getMembers ( ) ; if ( members != null ) { for ( RelationMember rm : members ) { checkMember ( r . getOsmId ( ) , rm ) ; final long ref = rm . getRef ( ) ; final String type = rm . getType ( ) ; OsmElement e = elementFromIndex ( r , type , ref , nodeIndex , wayIndex , relationIndex ) ; if ( e != null ) { e . clearParentRelations ( ) ; } } } else { Log . e ( DEBUG_TAG , "Relation has no members " + r . getOsmId ( ) ) ; } } for ( Relation r : tempCurrent . getRelations ( ) ) { final List < RelationMember > members = r . getMembers ( ) ; if ( members != null ) { for ( RelationMember rm : members ) { checkMember ( r . getOsmId ( ) , rm ) ; final long ref = rm . getRef ( ) ; final String type = rm . getType ( ) ; OsmElement e = elementFromIndex ( r , type , ref , nodeIndex , wayIndex , relationIndex ) ; if ( e != null ) { rm . setElement ( e ) ; e . addParentRelation ( r ) ; } else if ( memberIsDeleted ( r , rm ) ) { Log . e ( DEBUG_TAG , "redoBacklinks relation " + r . getOsmId ( ) + " member " + type + " " + ref + " missing" ) ; return false ; } else if ( rm . downloaded ( ) ) { Log . w ( DEBUG_TAG , "redoBacklinks relation " + r . getOsmId ( ) + " member " + type + " " + ref + " not in target storage" ) ; rm . setElement ( null ) ; } } } else { Log . e ( DEBUG_TAG , "Relation has no members " + r . getOsmId ( ) ) ; } } return true ; }
Redo all backlinks
Redo all backlinks
// zap all existing backlinks for our "old" relations // add backlinks for all "new" relations // successful