public SchemaVersion(String schemaText, String description, Byte initialState, byte [] stateDetails) { this.description = description; this.schemaText = schemaText; this.initialState = initialState != null ? initialState : SchemaVersionLifecycleStates.ENABLED.getId(); this.stateDetails = stateDetails; }
public void registerReviewedState(SchemaVersionLifecycleStateMachine.Builder builder) { builder.transition(new SchemaVersionLifecycleStateTransition(CustomReviewCycleStates.TECHNICAL_LEAD_REVIEW_STATE.getId(), SchemaVersionLifecycleStates.REVIEWED.getId(), SchemaVersionLifecycleStates.REVIEWED.getName(), SchemaVersionLifecycleStates.REVIEWED.getDescription()), (SchemaVersionLifecycleContext context) -> { // Plugin a custom code to trigger as a part of the state transition, here we just record the state change in the database LOG.debug("Making a transition from 'TECHNICAL LEAD REVIEW' to 'REVIEWED' state"); transitionToState(context, SchemaVersionLifecycleStates.REVIEWED); }); }
public void disableSchemaVersion(Long schemaVersionId) throws SchemaNotFoundException, SchemaLifecycleException { ImmutablePair<SchemaVersionLifecycleContext, SchemaVersionLifecycleState> pair = createSchemaVersionLifeCycleContextAndState(schemaVersionId); ((InbuiltSchemaVersionLifecycleState) pair.getRight()).disable(pair.getLeft()); }
public void enableSchemaVersion(Long schemaVersionId) throws SchemaNotFoundException, SchemaLifecycleException, IncompatibleSchemaException, SchemaBranchNotFoundException { ImmutablePair<SchemaVersionLifecycleContext, SchemaVersionLifecycleState> pair = createSchemaVersionLifeCycleContextAndState(schemaVersionId); ((InbuiltSchemaVersionLifecycleState) pair.getRight()).enable(pair.getLeft()); }
public void deleteSchemaVersion(Long schemaVersionId) throws SchemaNotFoundException, SchemaLifecycleException { ImmutablePair<SchemaVersionLifecycleContext, SchemaVersionLifecycleState> pair = createSchemaVersionLifeCycleContextAndState(schemaVersionId); ((InbuiltSchemaVersionLifecycleState) pair.getRight()).delete(pair.getLeft()); }
public void archiveSchemaVersion(Long schemaVersionId) throws SchemaNotFoundException, SchemaLifecycleException { ImmutablePair<SchemaVersionLifecycleContext, SchemaVersionLifecycleState> pair = createSchemaVersionLifeCycleContextAndState(schemaVersionId); ((InbuiltSchemaVersionLifecycleState) pair.getRight()).archive(pair.getLeft()); }
public SchemaVersion(String schemaText, String description, Byte initialState, byte [] stateDetails) { this.description = description; this.schemaText = schemaText; this.initialState = initialState != null ? initialState : SchemaVersionLifecycleStates.ENABLED.getId(); this.stateDetails = stateDetails; }
public void registerChangesRequiredState(SchemaVersionLifecycleStateMachine.Builder builder) { builder.transition(new SchemaVersionLifecycleStateTransition(CustomReviewCycleStates.PEER_REVIEW_STATE.getId(), SchemaVersionLifecycleStates.CHANGES_REQUIRED.getId(), SchemaVersionLifecycleStates.CHANGES_REQUIRED.getName(), SchemaVersionLifecycleStates.CHANGES_REQUIRED.getDescription()), (SchemaVersionLifecycleContext context) -> { // Plugin a custom code to trigger as a part of the state transition, here we just record the state change in the database LOG.debug("Making a transition from 'PEER REVIEW' to 'REJECTED' state"); transitionToState(context, SchemaVersionLifecycleStates.CHANGES_REQUIRED); }); builder.transition(new SchemaVersionLifecycleStateTransition(CustomReviewCycleStates.TECHNICAL_LEAD_REVIEW_STATE.getId(), SchemaVersionLifecycleStates.CHANGES_REQUIRED.getId(), SchemaVersionLifecycleStates.CHANGES_REQUIRED.getName(), SchemaVersionLifecycleStates.CHANGES_REQUIRED.getDescription()), (SchemaVersionLifecycleContext context) -> { // Plugin a custom code to trigger as a part of the state transition, here we just record the state change in the database LOG.debug("Making a transition from 'TECHNICAL LEAD REVIEW' to 'REJECTED' state"); transitionToState(context, SchemaVersionLifecycleStates.CHANGES_REQUIRED); }); }
public SchemaVersionInfo(Long id, String name, Integer version, Long schemaMetadataId, String schemaText, Long timestamp, String description, Byte stateId) { this.id = id; this.name = name; this.schemaMetadataId = schemaMetadataId; this.description = description; this.version = version; this.schemaText = schemaText; this.timestamp = timestamp; this.stateId = stateId == null ? SchemaVersionLifecycleStates.ENABLED.getId() : stateId; }
public SchemaVersionInfo(Long id, String name, Integer version, Long schemaMetadataId, String schemaText, Long timestamp, String description, Byte stateId) { this.id = id; this.name = name; this.schemaMetadataId = schemaMetadataId; this.description = description; this.version = version; this.schemaText = schemaText; this.timestamp = timestamp; this.stateId = stateId == null ? SchemaVersionLifecycleStates.ENABLED.getId() : stateId; }
public SchemaVersionInfo getLatestEnabledSchemaVersionInfo(String schemaBranchName, String schemaName) throws SchemaNotFoundException, SchemaBranchNotFoundException { Preconditions.checkNotNull(schemaBranchName, "Schema branch name can't be null"); Preconditions.checkNotNull(schemaName, "schemaName can't be null"); return getLatestSchemaVersionInfo(schemaBranchName, schemaName, SchemaVersionLifecycleStates.ENABLED.getId()); }
@Path("/review/peer/schema/{versionId}/modify") @POST @Timed public Response changesRequiredPeerReview(@ApiParam(value = "Details about schema version",required = true) @PathParam("versionId") Long schemaVersionId) { return transition(schemaVersionId, SchemaVersionLifecycleStates.CHANGES_REQUIRED.getId(), "Changes requested by - B" ); }
@Path("/review/technical/schema/{versionId}/accept") @POST @Timed public Response declineTechnicalReview(@ApiParam(value = "Details about schema version",required = true) @PathParam("versionId") Long schemaVersionId) { return transition(schemaVersionId, SchemaVersionLifecycleStates.REVIEWED.getId(), "Reviewed by :- M and N" ); }
@Path("/review/technical/schema/{versionId}/modify") @POST @Timed public Response changesRequiredTechnicalReview(@ApiParam(value = "Details about schema version",required = true) @PathParam("versionId") Long schemaVersionId) { return transition(schemaVersionId, SchemaVersionLifecycleStates.CHANGES_REQUIRED.getId(), "Changes requested by - N" ); }
private CustomSchemaStateExecutor createSchemaReviewExecutor(Map<String, Object> props, SchemaVersionLifecycleStateMachine.Builder builder) { Map<String, Object> schemaReviewExecConfig = (Map<String, Object>) props.getOrDefault("customSchemaStateExecutor", Collections.emptyMap()); String className = (String) schemaReviewExecConfig.getOrDefault("className", DEFAULT_SCHEMA_REVIEW_EXECUTOR_CLASS); Map<String, ?> executorProps = (Map<String, ?>) schemaReviewExecConfig.getOrDefault("props", Collections.emptyMap()); CustomSchemaStateExecutor customSchemaStateExecutor; try { customSchemaStateExecutor = (CustomSchemaStateExecutor) Class.forName(className, true, Thread.currentThread() .getContextClassLoader()) .newInstance(); } catch (InstantiationException | IllegalAccessException | ClassNotFoundException e) { LOG.error("Error encountered while loading class [{}]", className, e); throw new IllegalArgumentException(e); } customSchemaStateExecutor.init(builder, SchemaVersionLifecycleStates.REVIEWED.getId(), SchemaVersionLifecycleStates.CHANGES_REQUIRED.getId(), executorProps); return customSchemaStateExecutor; }
public void registerNotificationsWithSchemaEnabled(SchemaVersionLifecycleStateMachine.Builder builder, Map<String, ?> props) { builder.getTransitionsWithActions().entrySet().stream(). filter(transitionAction -> transitionAction.getKey().getTargetStateId().equals(SchemaVersionLifecycleStates.ENABLED.getId())). forEach(transitionAction -> builder.registerListener(transitionAction.getKey(), new SchemaVersionLifecycleStateTransitionListener() { @Override public void preStateTransition(SchemaVersionLifecycleContext context) { LOG.debug("preStateTransition() does nothing for this state transition"); } @Override public void postStateTransition(SchemaVersionLifecycleContext context) { LOG.debug("postStateTransition() calling external review service to notify the state transition"); Long schemaVersionId = context.getSchemaVersionId(); WebTarget webTarget = ClientBuilder.newClient().target(props.get("review.service.url").toString()). path("/v1/transition/schema/"+schemaVersionId+"/notify"); webTarget.request().post(null); } })); }
private static Pair<SchemaVersionLifecycleStateTransition, SchemaVersionLifecycleStateAction> createDisableAction(Byte sourceStateId) { return Pair.of(new SchemaVersionLifecycleStateTransition(sourceStateId, DISABLED.getId(), "Disable", "Disables the schema version"), context -> { try { transitionToDisableState(context); } catch (SchemaNotFoundException e) { throw new SchemaLifecycleException(e); } }); }
private static Pair<SchemaVersionLifecycleStateTransition, SchemaVersionLifecycleStateAction> createDisableAction(Byte sourceStateId) { return Pair.of(new SchemaVersionLifecycleStateTransition(sourceStateId, DISABLED.getId(), "Disable", "Disables the schema version"), context -> { try { transitionToDisableState(context); } catch (SchemaNotFoundException e) { throw new SchemaLifecycleException(e); } }); }
private static Pair<SchemaVersionLifecycleStateTransition, SchemaVersionLifecycleStateAction> createArchiveTransitionAction(Byte sourceStateId) { return Pair.of(new SchemaVersionLifecycleStateTransition(sourceStateId, ARCHIVED.getId(), "Archive", "Archives the schema version"), context -> { try { transitionToArchiveState(context); } catch (SchemaNotFoundException e) { throw new SchemaLifecycleException(e); } }); }
private static Pair<SchemaVersionLifecycleStateTransition, SchemaVersionLifecycleStateAction> createStartReviewTransitionActionPair(Byte sourceStateId) { return Pair.of(new SchemaVersionLifecycleStateTransition(sourceStateId, START_REVIEW.getId(), "StartReview", "Starts review state"), context -> { try { transitionToStartReview(context); } catch (SchemaNotFoundException e) { throw new SchemaLifecycleException(e); } }); }