Documentation changes

- Document changes to JPA Entity model, persistence
  facilities and related new interfaces and services.
- Relates to #429
- Relates to #476
This commit is contained in:
Janne Valkealahti
2018-01-21 11:40:50 +00:00
parent 3481140126
commit 744d138944
14 changed files with 307 additions and 17 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2016-2017 the original author or authors.
* Copyright 2016-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -246,6 +246,28 @@ public class JpaRepositoryTests extends AbstractRepositoryTests {
assertThat(transitionsRepository.count(), is(2l));
}
@Test
public void testRepository7() {
context.register(TestConfig.class);
context.refresh();
JpaStateMachineRepository stateMachineRepository = context.getBean(JpaStateMachineRepository.class);
JpaRepositoryStateMachine machine1 = new JpaRepositoryStateMachine();
machine1.setMachineId("machine1");
machine1.setState("S1");
machine1.setStateMachineContext(new byte[] { 0 });
assertThat(stateMachineRepository.count(), is(0l));
stateMachineRepository.save(machine1);
assertThat(stateMachineRepository.count(), is(1l));
JpaRepositoryStateMachine machine1x = stateMachineRepository.findOne("machine1");
assertThat(machine1x.getMachineId(), is(machine1.getMachineId()));
assertThat(machine1x.getState(), is(machine1.getState()));
assertThat(machine1x.getStateMachineContext().length, is(1));
}
@Override
protected AnnotationConfigApplicationContext buildContext() {
return new AnnotationConfigApplicationContext();

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2016 the original author or authors.
* Copyright 2016-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -21,11 +21,13 @@ import java.util.HashSet;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.statemachine.data.ActionRepository;
import org.springframework.statemachine.data.GuardRepository;
import org.springframework.statemachine.data.StateMachineRepository;
import org.springframework.statemachine.data.StateRepository;
import org.springframework.statemachine.data.TransitionRepository;
import org.springframework.statemachine.data.jpa.JpaRepositoryAction;
import org.springframework.statemachine.data.jpa.JpaRepositoryGuard;
import org.springframework.statemachine.data.jpa.JpaRepositoryState;
import org.springframework.statemachine.data.jpa.JpaRepositoryStateMachine;
import org.springframework.statemachine.data.jpa.JpaRepositoryTransition;
import org.springframework.statemachine.transition.TransitionKind;
@@ -206,4 +208,23 @@ public class DocsJpaRepositorySampleTests1 {
// end::snippetC4[]
}
}
public static class Config4 {
// tag::snippetD[]
@Autowired
StateMachineRepository<JpaRepositoryStateMachine> stateMachineRepository;
void persist() {
JpaRepositoryStateMachine machine = new JpaRepositoryStateMachine();
machine.setMachineId("machine");
machine.setState("S1");
// raw byte[] representation of a context
machine.setStateMachineContext(new byte[] { 0 });
stateMachineRepository.save(machine);
}
// end::snippetD[]
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2016 the original author or authors.
* Copyright 2016-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,9 +16,11 @@
package org.springframework.statemachine.data.mongodb.docs;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.statemachine.data.StateMachineRepository;
import org.springframework.statemachine.data.StateRepository;
import org.springframework.statemachine.data.TransitionRepository;
import org.springframework.statemachine.data.mongodb.MongoDbRepositoryState;
import org.springframework.statemachine.data.mongodb.MongoDbRepositoryStateMachine;
import org.springframework.statemachine.data.mongodb.MongoDbRepositoryTransition;
public class DocsMongoDbRepositorySampleTests1 {
@@ -83,4 +85,24 @@ public class DocsMongoDbRepositorySampleTests1 {
}
// end::snippetB[]
}
public static class Config3 {
// tag::snippetC[]
@Autowired
StateMachineRepository<MongoDbRepositoryStateMachine> stateMachineRepository;
void persist() {
MongoDbRepositoryStateMachine machine = new MongoDbRepositoryStateMachine();
machine.setMachineId("machine");
machine.setState("S1");
// raw byte[] representation of a context
machine.setStateMachineContext(new byte[] { 0 });
stateMachineRepository.save(machine);
}
// end::snippetC[]
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2016 the original author or authors.
* Copyright 2016-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,9 +16,11 @@
package org.springframework.statemachine.data.redis.docs;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.statemachine.data.StateMachineRepository;
import org.springframework.statemachine.data.StateRepository;
import org.springframework.statemachine.data.TransitionRepository;
import org.springframework.statemachine.data.redis.RedisRepositoryState;
import org.springframework.statemachine.data.redis.RedisRepositoryStateMachine;
import org.springframework.statemachine.data.redis.RedisRepositoryTransition;
public class DocsRedisRepositorySampleTests1 {
@@ -76,4 +78,23 @@ public class DocsRedisRepositorySampleTests1 {
}
// end::snippetB[]
}
public static class Config3 {
// tag::snippetC[]
@Autowired
StateMachineRepository<RedisRepositoryStateMachine> stateMachineRepository;
void persist() {
RedisRepositoryStateMachine machine = new RedisRepositoryStateMachine();
machine.setMachineId("machine");
machine.setState("S1");
// raw byte[] representation of a context
machine.setStateMachineContext(new byte[] { 0 });
stateMachineRepository.save(machine);
}
// end::snippetC[]
}
}