|
24 | 24 | import java.util.LinkedHashSet; |
25 | 25 | import java.util.Map; |
26 | 26 | import java.util.UUID; |
| 27 | +import org.datatransferproject.types.common.ImportableItem; |
27 | 28 | import org.datatransferproject.types.common.models.DataModel; |
28 | 29 | import org.datatransferproject.types.common.models.photos.PhotoAlbum; |
29 | 30 |
|
30 | 31 | /* |
31 | 32 | * TempMediaData used to store personal camera media (album, photos, videos, etc) information before |
32 | 33 | * they are ready to be uploaded. |
33 | 34 | */ |
34 | | -// TODO(zacsh) update this to support Media* objects and/or Video data |
| 35 | +// TODO(zacsh) rename this to what it's for: ImportableItemContainerMap |
35 | 36 | @JsonTypeName("org.dataportability:TempMediaData") |
36 | 37 | public class TempMediaData extends DataModel { |
37 | 38 |
|
@@ -99,18 +100,36 @@ public void removeTempPhotoAlbum(String key) { |
99 | 100 | } |
100 | 101 |
|
101 | 102 | public void addContainedPhotoId(String photoId) { |
102 | | - containedPhotoIds.add(photoId); |
| 103 | + markContained(photoId); |
103 | 104 | } |
104 | 105 |
|
105 | 106 | public void addAllContainedPhotoIds(Collection<String> photoIds) { |
106 | 107 | containedPhotoIds.addAll(photoIds); |
107 | 108 | } |
108 | 109 |
|
109 | | - public Collection lookupContainedPhotoIds() { |
| 110 | + public Collection<String> lookupContainedPhotoIds() { |
110 | 111 | return containedPhotoIds; |
111 | 112 | } |
112 | 113 |
|
113 | 114 | 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()); |
115 | 134 | } |
116 | 135 | } |
0 commit comments