Skip to content

Commit dceac9b

Browse files
authored
refactor: (noop; new API) further carve out model-agnostic interface for (#1458)
refactor: TempMediaData techdebt-progress: this cleansup/unblocks upcoming 'static exporter' I've written that will utilize this exact same code, but won't be tied to any one DTP model.
1 parent 542ac9c commit dceac9b

1 file changed

Lines changed: 23 additions & 4 deletions

File tree

  • portability-spi-transfer/src/main/java/org/datatransferproject/spi/transfer/types

portability-spi-transfer/src/main/java/org/datatransferproject/spi/transfer/types/TempMediaData.java

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,15 @@
2424
import java.util.LinkedHashSet;
2525
import java.util.Map;
2626
import java.util.UUID;
27+
import org.datatransferproject.types.common.ImportableItem;
2728
import org.datatransferproject.types.common.models.DataModel;
2829
import org.datatransferproject.types.common.models.photos.PhotoAlbum;
2930

3031
/*
3132
* TempMediaData used to store personal camera media (album, photos, videos, etc) information before
3233
* they are ready to be uploaded.
3334
*/
34-
// TODO(zacsh) update this to support Media* objects and/or Video data
35+
// TODO(zacsh) rename this to what it's for: ImportableItemContainerMap
3536
@JsonTypeName("org.dataportability:TempMediaData")
3637
public class TempMediaData extends DataModel {
3738

@@ -99,18 +100,36 @@ public void removeTempPhotoAlbum(String key) {
99100
}
100101

101102
public void addContainedPhotoId(String photoId) {
102-
containedPhotoIds.add(photoId);
103+
markContained(photoId);
103104
}
104105

105106
public void addAllContainedPhotoIds(Collection<String> photoIds) {
106107
containedPhotoIds.addAll(photoIds);
107108
}
108109

109-
public Collection lookupContainedPhotoIds() {
110+
public Collection<String> lookupContainedPhotoIds() {
110111
return containedPhotoIds;
111112
}
112113

113114
public boolean isContainedPhotoId(String photoId) {
114-
return containedPhotoIds.contains(photoId);
115+
return isContained(photoId);
116+
}
117+
118+
// TODO(zacsh) finish making this model agnostic (we care only about idempotent IDs of a resource
119+
// and some containing resource.
120+
private boolean isContained(String idempotentId) {
121+
return containedPhotoIds.contains(idempotentId);
122+
}
123+
124+
private void markContained(String idempotentId) {
125+
containedPhotoIds.add(idempotentId);
126+
}
127+
128+
public boolean isContained(ImportableItem item) {
129+
return containedPhotoIds.contains(item.getIdempotentId());
130+
}
131+
132+
public void markContained(ImportableItem item) {
133+
containedPhotoIds.add(item.getIdempotentId());
115134
}
116135
}

0 commit comments

Comments
 (0)