@@ -44,7 +44,7 @@ public StateService(StateRepository repository, ObjectMapper mapper) {
4444 * @param activityId the activityId
4545 * @param agent the agent
4646 * @param stateId the stateId
47- * @param registration the registration (nullable)
47+ * @param registration the registration
4848 * @return the state entity or Optional.empty() if not found
4949 */
5050 public Optional <StateEntity > getState (String activityId , Agent agent , String stateId ,
@@ -54,7 +54,8 @@ public Optional<StateEntity> getState(String activityId, Agent agent, String sta
5454 stateId , registration );
5555
5656 final String agentJson = serializeAgent (agent );
57- final StateEntity .StateId id = new StateEntity .StateId (activityId , agentJson , stateId );
57+ final StateEntity .StateId id =
58+ new StateEntity .StateId (activityId , agentJson , stateId , registration );
5859
5960 return repository .findById (id );
6061 }
@@ -64,7 +65,7 @@ public Optional<StateEntity> getState(String activityId, Agent agent, String sta
6465 *
6566 * @param activityId the activityId
6667 * @param agent the agent
67- * @param registration the registration (nullable)
68+ * @param registration the registration
6869 * @return list of stateIds
6970 */
7071 public List <String > getStateIds (String activityId , Agent agent , UUID registration ) {
@@ -74,7 +75,10 @@ public List<String> getStateIds(String activityId, Agent agent, UUID registratio
7475
7576 final String agentJson = serializeAgent (agent );
7677
77- return repository .findStateIds (activityId , agentJson , registration );
78+ return repository
79+ .findByActivityIdAndAgentJsonAndRegistration (activityId , agentJson , registration ).stream ()
80+ .map (StateEntity ::getStateId )
81+ .toList ();
7882 }
7983
8084 /**
@@ -83,7 +87,7 @@ public List<String> getStateIds(String activityId, Agent agent, UUID registratio
8387 * @param activityId the activityId
8488 * @param agent the agent
8589 * @param stateId the stateId
86- * @param registration the registration (nullable)
90+ * @param registration the registration
8791 * @param stateDocument the state document
8892 * @param contentType the content type
8993 */
@@ -106,7 +110,7 @@ public void putState(String activityId, Agent agent, String stateId, UUID regist
106110 * @param activityId the activityId
107111 * @param agent the agent
108112 * @param stateId the stateId
109- * @param registration the registration (nullable)
113+ * @param registration the registration
110114 * @param stateDocument the state document to merge
111115 * @param contentType the content type
112116 */
@@ -117,7 +121,8 @@ public void postState(String activityId, Agent agent, String stateId, UUID regis
117121 stateId , registration );
118122
119123 final String agentJson = serializeAgent (agent );
120- final StateEntity .StateId id = new StateEntity .StateId (activityId , agentJson , stateId );
124+ final StateEntity .StateId id =
125+ new StateEntity .StateId (activityId , agentJson , stateId , registration );
121126
122127 final Optional <StateEntity > existingEntity = repository .findById (id );
123128
@@ -144,15 +149,16 @@ public void postState(String activityId, Agent agent, String stateId, UUID regis
144149 * @param activityId the activityId
145150 * @param agent the agent
146151 * @param stateId the stateId
147- * @param registration the registration (nullable)
152+ * @param registration the registration
148153 */
149154 public void deleteState (String activityId , Agent agent , String stateId , UUID registration ) {
150155
151156 log .info ("delete state: activityId={}, agent={}, stateId={}, registration={}" , activityId ,
152157 agent , stateId , registration );
153158
154159 final String agentJson = serializeAgent (agent );
155- final StateEntity .StateId id = new StateEntity .StateId (activityId , agentJson , stateId );
160+ final StateEntity .StateId id =
161+ new StateEntity .StateId (activityId , agentJson , stateId , registration );
156162
157163 repository .deleteById (id );
158164 }
@@ -162,7 +168,7 @@ public void deleteState(String activityId, Agent agent, String stateId, UUID reg
162168 *
163169 * @param activityId the activityId
164170 * @param agent the agent
165- * @param registration the registration (nullable)
171+ * @param registration the registration
166172 */
167173 @ Transactional
168174 public void deleteStates (String activityId , Agent agent , UUID registration ) {
@@ -172,7 +178,7 @@ public void deleteStates(String activityId, Agent agent, UUID registration) {
172178
173179 final String agentJson = serializeAgent (agent );
174180
175- repository .deleteByActivityIdAndAgentJson (activityId , agentJson , registration );
181+ repository .deleteByActivityIdAndAgentJsonAndRegistration (activityId , agentJson , registration );
176182 }
177183
178184 private String serializeAgent (Agent agent ) {
0 commit comments