@Override public void executeReviewState(SchemaVersionLifecycleContext schemaVersionLifecycleContext) throws SchemaLifecycleException, SchemaNotFoundException { schemaVersionLifecycleContext.setState(inReviewState); schemaVersionLifecycleContext.updateSchemaVersionState(); }
@Override public void executeReviewState(SchemaVersionLifecycleContext schemaVersionLifecycleContext) throws SchemaLifecycleException, SchemaNotFoundException { schemaVersionLifecycleContext.setState(CustomReviewCycleStates.PEER_REVIEW_STATE); schemaVersionLifecycleContext.updateSchemaVersionState(); } }
@Override public void executeReviewState(SchemaVersionLifecycleContext schemaVersionLifecycleContext) throws SchemaLifecycleException, SchemaNotFoundException { schemaVersionLifecycleContext.setState(inReviewState); schemaVersionLifecycleContext.updateSchemaVersionState(); }
private static void transitionToArchiveState(SchemaVersionLifecycleContext context) throws SchemaLifecycleException, SchemaNotFoundException { context.setState(ARCHIVED); context.updateSchemaVersionState(); }
private static void transitionToArchiveState(SchemaVersionLifecycleContext context) throws SchemaLifecycleException, SchemaNotFoundException { context.setState(ARCHIVED); context.updateSchemaVersionState(); }
private static void transitionToDisableState(SchemaVersionLifecycleContext context) throws SchemaLifecycleException, SchemaNotFoundException { context.setState(DISABLED); context.updateSchemaVersionState(); }
private static void transitionToDisableState(SchemaVersionLifecycleContext context) throws SchemaLifecycleException, SchemaNotFoundException { context.setState(DISABLED); context.updateSchemaVersionState(); }
private static void transitionToStartReview(SchemaVersionLifecycleContext context) throws SchemaLifecycleException, SchemaNotFoundException { context.setState(START_REVIEW); // execute start review process, updation of the state should be done by schemaReviewExecutor context.getCustomSchemaStateExecutor().executeReviewState(context); }
private static void transitionToStartReview(SchemaVersionLifecycleContext context) throws SchemaLifecycleException, SchemaNotFoundException { context.setState(START_REVIEW); // execute start review process, updation of the state should be done by schemaReviewExecutor context.getCustomSchemaStateExecutor().executeReviewState(context); }
private void transitionToState(SchemaVersionLifecycleContext context, SchemaVersionLifecycleState targetState) throws SchemaLifecycleException { if (context.getDetails() == null || context.getDetails().length == 0) throw new RuntimeException("This state transition should not be triggered through UI"); context.setState(targetState); try { context.updateSchemaVersionState(); } catch (SchemaNotFoundException e) { throw new SchemaLifecycleException(e); } }
private InReviewState(final SchemaVersionLifecycleState targetState) { super("InReview", (byte) 32, "Finish the schema version." ); SchemaVersionLifecycleStateTransition stateTransition = new SchemaVersionLifecycleStateTransition(getId(), targetState.getId(), "FinishReview", "Finish schema review process"); SchemaVersionLifecycleStateAction stateAction = context -> { context.setState(targetState); try { context.updateSchemaVersionState(); } catch (SchemaNotFoundException e) { throw new SchemaLifecycleException(e); } }; transitionActionPair = Collections.singletonList(Pair.of(stateTransition, stateAction)); }
private InReviewState(final SchemaVersionLifecycleState targetState) { super("InReview", (byte) 32, "Finish the schema version." ); SchemaVersionLifecycleStateTransition stateTransition = new SchemaVersionLifecycleStateTransition(getId(), targetState.getId(), "FinishReview", "Finish schema review process"); SchemaVersionLifecycleStateAction stateAction = context -> { context.setState(targetState); try { context.updateSchemaVersionState(); } catch (SchemaNotFoundException e) { throw new SchemaLifecycleException(e); } }; transitionActionPair = Collections.singletonList(Pair.of(stateTransition, stateAction)); }
private void updateSchemaVersionState(Long schemaVersionId, Integer sequence, Byte initialState, byte[] stateDetails) throws SchemaNotFoundException { try { SchemaVersionLifecycleContext schemaVersionLifecycleContext = new SchemaVersionLifecycleContext(schemaVersionId, sequence, createSchemaVersionService(), schemaVersionLifecycleStateMachine, customSchemaStateExecutor); schemaVersionLifecycleContext.setState(schemaVersionLifecycleStateMachine.getStates().get(initialState)); schemaVersionLifecycleContext.setDetails(stateDetails); schemaVersionLifecycleContext.updateSchemaVersionState(); } catch (SchemaLifecycleException e) { throw new RuntimeException(e); } }
private static void transitionToDeleteState(SchemaVersionLifecycleContext context) throws SchemaLifecycleException, SchemaNotFoundException { context.setState(DELETED); context.updateSchemaVersionState(); context.getSchemaVersionService().deleteSchemaVersion(context.getSchemaVersionId()); }
private static void transitionToDeleteState(SchemaVersionLifecycleContext context) throws SchemaLifecycleException, SchemaNotFoundException { context.setState(DELETED); context.updateSchemaVersionState(); context.getSchemaVersionService().deleteSchemaVersion(context.getSchemaVersionId()); }
public void executeState(Long schemaVersionId, Byte targetState, byte[] transitionDetails) throws SchemaLifecycleException, SchemaNotFoundException { ImmutablePair<SchemaVersionLifecycleContext, SchemaVersionLifecycleState> schemaLifeCycleContextAndState = createSchemaVersionLifeCycleContextAndState(schemaVersionId); SchemaVersionLifecycleContext schemaVersionLifecycleContext = schemaLifeCycleContextAndState.getLeft(); SchemaVersionLifecycleState currentState = schemaLifeCycleContextAndState.getRight(); schemaVersionLifecycleContext.setState(currentState); schemaVersionLifecycleContext.setDetails(transitionDetails); SchemaVersionLifecycleStateTransition transition = new SchemaVersionLifecycleStateTransition(currentState.getId(), targetState); SchemaVersionLifecycleStateAction action = schemaVersionLifecycleContext.getSchemaLifeCycleStatesMachine() .getTransitions() .get(transition); try { List<SchemaVersionLifecycleStateTransitionListener> listeners = schemaVersionLifecycleContext.getSchemaLifeCycleStatesMachine() .getListeners() .getOrDefault(transition, DEFAULT_LISTENERS); listeners.stream().forEach(listener -> listener.preStateTransition(schemaVersionLifecycleContext)); action.execute(schemaVersionLifecycleContext); listeners.stream().forEach(listener -> listener.postStateTransition(schemaVersionLifecycleContext)); } catch (SchemaLifecycleException e) { Throwable cause = e.getCause(); if (cause != null && cause instanceof SchemaNotFoundException) { throw (SchemaNotFoundException) cause; } throw e; } }
context.setState(ENABLED); context.updateSchemaVersionState();
context.setState(ENABLED); context.updateSchemaVersionState();