Modify

Opened 22 months ago

Last modified 22 months ago

#22605 new defect

No indication of and no option to delete automatically added CS-tag "hashtag"

Reported by: skyper Owned by: team
Priority: normal Milestone:
Component: Core Version: latest
Keywords: template_report changeset tag hashtag Cc:

Description

What steps will reproduce the problem?

  1. Upload some data
  2. In the upload dialog add something like repair routes #403303 and #2114080

What is the expected result?

An indication that hashtag=#403303;#2114080 is added as additional CS-tag plus an option to delete this tag

What happens instead?

No indication and the tag is always added again despite manually deleting it.

Please provide any additional information below. Attach a screenshot if possible.

See osmwww:changeset/130575508 as example.

Relative:URL: ^/trunk
Repository:UUID: 0c6e7542-c601-0410-84e7-c038aed88b3b
Last:Changed Date: 2022-12-27 16:51:43 +0100 (Tue, 27 Dec 2022)
Revision:18619
Build-Date:2022-12-28 02:30:57
URL:https://josm.openstreetmap.de/svn/trunk

Identification: JOSM/1.5 (18619 en) Linux Debian GNU/Linux 11 (bullseye)
Memory Usage: 180 MB / 256 MB (57 MB allocated, but free)
Java version: 17.0.4+8-Debian-1deb11u1, Debian, OpenJDK 64-Bit Server VM

VM arguments: [-Djosm.home=<josm.pref>]
Dataset consistency test: No problems found

Attachments (0)

Change History (2)

comment:1 by taylor.smock, 22 months ago

It looks like the behavior is controlled by the advanced preference upload.changeset.hashtags.

Anyway, sample patch:

  • src/org/openstreetmap/josm/gui/io/UploadDialogModel.java

    IDEA additional info:
    Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
    <+>UTF-8
    diff --git a/src/org/openstreetmap/josm/gui/io/UploadDialogModel.java b/src/org/openstreetmap/josm/gui/io/UploadDialogModel.java
    a b  
    55import java.util.LinkedHashSet;
    66import java.util.List;
    77import java.util.Map;
     8import java.util.Objects;
     9import java.util.Optional;
    810import java.util.Set;
    911import java.util.stream.Collectors;
    1012
     
    2729    public static final String COMMENT = "comment";
    2830    /** the "source" changeset OSM key */
    2931    public static final String SOURCE = "source";
     32    /** The "hashtag" changeset OSM key */
     33    private static final String HASHTAGS = "hashtags";
    3034    /** the user-agent */
    3135    private final String agent = Version.getInstance().getAgentString(false);
    3236    /** whether to extract hashtags from comment */
    33     private final boolean hashtags = Config.getPref().getBoolean("upload.changeset.hashtags", true);
     37    private boolean hashtags = Config.getPref().getBoolean("upload.changeset.hashtags", true);
    3438
    3539    /** a lock to prevent loops  */
    3640    private boolean locked;
     
    4246                locked = true;
    4347                // add "hashtags" if any
    4448                if (hashtags) {
    45                     put("hashtags", findHashTags(getValue(COMMENT)));
     49                    final String hashTags = findHashTags(getValue(COMMENT));
     50                    Optional<TagModel> hashTagModel = tags.stream().filter(tm -> HASHTAGS.equals(tm.getName())).findFirst();
     51                    if ((hashTagModel.isPresent() && !hashTagModel.get().hasValue(hashTags))
     52                            || (!hashTagModel.isPresent() && !Utils.isBlank(hashTags))) {
     53                        put(HASHTAGS, hashTags);
     54                        UploadDialog.getUploadDialog().setChangesetTagsModifiedProgramatically();
     55                    }
    4656                }
    4757                // add/update "created_by"
    4858                final String createdBy = getValue(CREATED_BY);
     
    106116        return result.toString();
    107117    }
    108118
     119    @Override
     120    public void deleteTagNames(int... tagIndices) {
     121        handleTagModelDeletion(getTagModels(tagIndices));
     122        super.deleteTagNames(tagIndices);
     123    }
     124
     125    @Override
     126    public void deleteTagValues(int... tagIndices) {
     127        handleTagModelDeletion(getTagModels(tagIndices));
     128        super.deleteTagValues(tagIndices);
     129    }
     130
     131    @Override
     132    public void delete(String name) {
     133        if (HASHTAGS.equals(name)) {
     134            this.hashtags = false;
     135        }
     136        super.delete(name);
     137    }
     138
     139    @Override
     140    public void deleteTags(int... tagIndices) {
     141        handleTagModelDeletion(getTagModels(tagIndices));
     142        super.deleteTags(tagIndices);
     143    }
     144
     145    private TagModel[] getTagModels(int... tagIndices) {
     146        return Arrays.stream(tagIndices).mapToObj(tags::get).filter(Objects::nonNull).toArray(TagModel[]::new);
     147    }
     148
     149    private void handleTagModelDeletion(TagModel[] tagModels) {
     150        for (TagModel tagModel : tagModels) {
     151            if (HASHTAGS.equals(tagModel.getName())) {
     152                this.hashtags = false;
     153            }
     154        }
     155    }
     156
    109157    /**
    110158     * Inserts/updates/deletes a tag.
    111159     *

Really, we should probably update TagEditorModel to fire the appropriate deletion/addition events, possibly subclassing the TableModelChanged event so that we can pass a list of the models changed, instead of just a generic table changed event.

in reply to:  1 comment:2 by skyper, 22 months ago

Replying to taylor.smock:

It looks like the behavior is controlled by the advanced preference upload.changeset.hashtags.

Thanks, this should be documented but wiki:Help/Action/Upload is already huge, partly outdated and messy. E.g. it needs quite some rework.

Modify Ticket

Change Properties
Set your email in Preferences
Action
as new The owner will remain team.
as The resolution will be set. Next status will be 'closed'.
to The owner will be changed from team to the specified user.
Next status will be 'needinfo'. The owner will be changed from team to skyper.
as duplicate The resolution will be set to duplicate. Next status will be 'closed'. The specified ticket will be cross-referenced with this ticket.
The owner will be changed from team to anonymous. Next status will be 'assigned'.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.