private void resolveViews(final Operations<?> operations) { for (final Operation operation : operations.getOperations()) { if (operation instanceof OperationView) { final OperationView opView = ((OperationView) operation); if (opView.getView() instanceof NamedView) { opView.setView(resolveView((NamedView) opView.getView())); } } else if (operation instanceof Operations) { resolveViews((Operations<?>) operation); } } }
private List<Operation> migrateOperation(final Operation op) { final OperationView opView = OperationView.class.cast(op); final Map<String, ViewMigration> migratedEntities = migrateViewElements(entities, opView.getView()::getEntity); final Map<String, ViewMigration> migratedEdges = migrateViewElements(edges, opView.getView()::getEdge); final View.Builder viewBuilder = new View.Builder().merge(opView.getView()); for (final Map.Entry<String, ViewMigration> entry : migratedEntities.entrySet()) { viewBuilder.entity(entry.getKey(), entry.getValue().buildViewElementDefinition()); } for (final Map.Entry<String, ViewMigration> entry : migratedEdges.entrySet()) { viewBuilder.edge(entry.getKey(), entry.getValue().buildViewElementDefinition()); } viewBuilder.config(ViewValidator.SKIP_VIEW_VALIDATION, TRUE); final View updatedView = viewBuilder.build(); LOGGER.debug("Migrated view: {}", updatedView); opView.setView(updatedView); final List<Operation> migrationOps = ViewMigration.createMigrationOps(aggregateAfter, migratedEdges.values(), migratedEntities.values()); if (LOGGER.isDebugEnabled()) { try { LOGGER.debug("Migrated operations: {}", StringUtil.toString(JSONSerialiser.serialise(new OperationChain<>(migrationOps), true))); } catch (final SerialisationException e) { LOGGER.debug("Failed to json serialise the migration operations: {}", new OperationChain<>(migrationOps)); } } return migrationOps; }
private void updateView(final OperationChain<?> opChain) { for (final Operation operation : opChain.flatten()) { if (operation instanceof OperationView) { final OperationView operationView = (OperationView) operation; final View.Builder viewBuilder = mergeView(operationView, getViewToMerge()); if ((null != whiteListElementGroups && !whiteListElementGroups.isEmpty()) || (null != blackListElementGroups && !blackListElementGroups.isEmpty())) { viewBuilder.removeEntities(this::removeElementGroups); viewBuilder.removeEdges(this::removeElementGroups); } if (!addExtraGroups && null != operationView.getView()) { final Set<String> entityGroups = operationView.getView().getEntityGroups(); viewBuilder.removeEntities(grp -> null == entityGroups || !entityGroups.contains(grp.getKey())); final Set<String> edgeGroups = operationView.getView().getEdgeGroups(); viewBuilder.removeEdges(grp -> null == edgeGroups || !edgeGroups.contains(grp.getKey())); } viewBuilder.expandGlobalDefinitions(); operationView.setView(viewBuilder.build()); } } }
((OperationView) resultOp).setView(validView); } else {
private static void updateOperationChainViews(final Operations<?> operations, final Schema schema) { for (final Operation operation : operations.getOperations()) { if (operation instanceof Operations) { updateOperationChainViews((Operations) operation, schema); } else if (operation instanceof OperationView) { View opView = ((OperationView) operation).getView(); if (null == opView) { opView = createView(schema); } else if (!(opView instanceof NamedView) && !opView.hasGroups() && !opView.isAllEdges() && !opView.isAllEntities()) { opView = new View.Builder() .merge(createView(schema)) .merge(opView) .build(); } else if (opView.isAllEdges() || opView.isAllEntities()) { View.Builder opViewBuilder = new View.Builder() .merge(opView); if (opView.isAllEdges()) { opViewBuilder.edges(schema.getEdgeGroups()); } if (opView.isAllEntities()) { opViewBuilder.entities(schema.getEntityGroups()); } opView = opViewBuilder.build(); } opView.expandGlobalDefinitions(); ((OperationView) operation).setView(opView); } } }
private void updateOperationChainView(final Operations<?> operations) { for (final Operation operation : operations.getOperations()) { if (operation instanceof Operations) { updateOperationChainView((Operations) operation); } else if (operation instanceof OperationView) { View opView = ((OperationView) operation).getView(); if (null == opView) { opView = config.getView(); } else if (!(opView instanceof NamedView) && !opView.hasGroups() && !opView.isAllEdges() && !opView.isAllEntities()) { opView = new View.Builder() .merge(config.getView()) .merge(opView) .build(); } else if (opView.isAllEdges() || opView.isAllEntities()) { View.Builder opViewBuilder = new View.Builder() .merge(opView); if (opView.isAllEdges()) { opViewBuilder.edges(getSchema().getEdgeGroups()); } if (opView.isAllEntities()) { opViewBuilder.entities(getSchema().getEntityGroups()); } opView = opViewBuilder.build(); } opView.expandGlobalDefinitions(); ((OperationView) operation).setView(opView); } } }