/** * Check if duplicates of this are allowed. If the operation wraps an action * duplicates are allowed. * @return True if duplicates are allowed, false otherwise. */ public boolean allowDuplicates() { return isAction(); }
/** * Returns {@code true} if execution of given operation caused the Engine session to be refreshed. */ boolean engineSessionRefreshed(VdcOperation<?, ?> operation) { // Actions always refresh the Engine session if (operation.isAction()) { return true; } else if (((QueryParametersBase) operation.getParameter()).getRefresh()) { // Queries optionally refresh the Engine session return true; } return false; }
@Override public void transmitOperationList(final List<VdcOperation<?, ?>> operations) { // Operations can be either actions or queries. Both require different handling so lets // Split them out into two lists so we can process them independently. List<VdcOperation<?, ?>> queriesList = new ArrayList<>(); Map<ActionType, List<VdcOperation<?, ?>>> actionsMap = new HashMap<>(); for (VdcOperation<?, ?> operation: operations) { if (operation.isAction()) { List<VdcOperation<?, ?>> actionsList = actionsMap.get(operation.getOperation()); if (actionsList == null) { actionsList = new ArrayList<>(); actionsMap.put((ActionType) operation.getOperation(), actionsList); } actionsList.add(operation); } else { queriesList.add(operation); } } if (!actionsMap.isEmpty()) { // We have some actions, call method to send actions. transmitMultipleActions(actionsMap); } if (!queriesList.isEmpty()) { // We have some queries, call method to send queries. transmitMultipleQueries(queriesList); } }
/** * Transmit a single operation, with the expectation of a single result object. * @param operation The operation to execute. */ void transmitOperation(final VdcOperation<?, ?> operation) { // Figure out if this is an action or a query. if (operation.isAction()) { // Action runAction(operation); } else { // Query if (operation.isPublic()) { runPublicQuery(operation); } else { runQuery(operation); } } }