@Override public List<Cookie> map(String project, List<? extends ISingleUserBatchOperation> user, RequestParams requestParams, InetAddress sourceAddress) { for (ISingleUserBatchOperation operation : user) { if (operation.getUser() == null) { throw new RakamException("_user cannot be null", BAD_REQUEST); } } return null; } }
default CompletableFuture<Void> batch(String project, List<? extends ISingleUserBatchOperation> operations) { for (ISingleUserBatchOperation operation : operations) { if (operation.getSetPropertiesOnce() != null) { setUserProperties(project, operation.getUser(), operation.getSetProperties()); } if (operation.getSetPropertiesOnce() != null) { setUserPropertiesOnce(project, operation.getUser(), operation.getSetPropertiesOnce()); } if (operation.getUnsetProperties() != null) { unsetProperties(project, operation.getUser(), operation.getUnsetProperties()); } if (operation.getIncrementProperties() != null) { for (Map.Entry<String, Double> entry : operation.getIncrementProperties().entrySet()) { incrementProperty(project, operation.getUser(), entry.getKey(), entry.getValue()); } } } return CompletableFuture.completedFuture(null); }
default void applyOperations(String project, List<? extends ISingleUserBatchOperation> req) { for (ISingleUserBatchOperation data : req) { if (data.getSetProperties() != null) { setUserProperties(project, data.getUser(), data.getSetPropertiesOnce()); } if (data.getSetProperties() != null) { setUserPropertiesOnce(project, data.getUser(), data.getSetPropertiesOnce()); } if (data.getUnsetProperties() != null) { unsetProperties(project, data.getUser(), data.getUnsetProperties()); } if (data.getIncrementProperties() != null) { for (Map.Entry<String, Double> entry : data.getIncrementProperties().entrySet()) { incrementProperty(project, data.getUser(), entry.getKey(), entry.getValue()); } } } }
for (ISingleUserBatchOperation operation : operations) { if (operation.getSetProperties() != null) { setUserProperties(conn, project, operation.getUser(), () -> operation.getSetProperties().fields(), false); setUserProperties(conn, project, operation.getUser(), () -> operation.getSetPropertiesOnce().fields(), true); unsetProperties(conn, project, operation.getUser(), operation.getUnsetProperties()); incrementProperty(conn, project, operation.getUser(), entry.getKey(), entry.getValue());
.withTableName(tableConfig.getTableName()) .withKey(ImmutableMap.of("project", new AttributeValue(project), "id", new AttributeValue(operation.getUser().toString()))) ); .withTableName(tableConfig.getTableName()) .withKey(ImmutableMap.of("project", new AttributeValue(project), "id", new AttributeValue(operation.getUser().toString()))) .withUpdateExpression(query.toString()));