本文整理汇总了Java中play.db.jpa.JPAApi类的典型用法代码示例。如果您正苦于以下问题:Java JPAApi类的具体用法?Java JPAApi怎么用?Java JPAApi使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
JPAApi类属于play.db.jpa包,在下文中一共展示了JPAApi类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: populaCidadaos
import play.db.jpa.JPAApi; //导入依赖的package包/类
private void populaCidadaos(JPAApi jpaAPI, CidadaoDAO dao, String adminEmail, Integer numeroDeCidadaos) {
Logger.info("Populando cidadãos.");
jpaAPI.withTransaction(() -> {
Cidadao admin = dao.findByLogin(adminEmail);
if (admin == null) {
Cidadao cidadao = new Cidadao("Governo Federal", adminEmail);
cidadao.setFuncionario(true);
cidadao.setMinisterioDeAfiliacao("Governo Federal");
admin = dao.saveAndUpdate(cidadao);
// Usuários para demonstração
for(int i = 0; i < numeroDeCidadaos; i++ ){
Cidadao cidadaoParaDemonstracao = new Cidadao("Anônimo", String.format("cidadao_%[email protected]", i));
cidadaoParaDemonstracao.setUrlDaFoto("http://www.gravatar.com/avatar/" + cidadaoParaDemonstracao.getLogin().hashCode()
+ "?f=y&d=retro");
cidadaos.add(dao.saveAndUpdate(cidadaoParaDemonstracao).getId());
}
Logger.info(numeroDeCidadaos + " cidadãos mais o admin cadastrados.");
} else {
Logger.info("Admin já cadastrado, assumimos que já temos usuários");
}
});
}
开发者ID:nazareno,项目名称:diferentonas-server,代码行数:24,代码来源:InitialData.java
示例2: limpaBancoParaTestes
import play.db.jpa.JPAApi; //导入依赖的package包/类
@Before
public void limpaBancoParaTestes() {
CidadaoDAO cidadaoDAO = app.injector().instanceOf(CidadaoDAO.class);
Configuration configuration = app.injector().instanceOf(Configuration.class);
JPAApi jpaAPI = app.injector().instanceOf(JPAApi.class);
jpaAPI.withTransaction(() -> {
String adminEmail = configuration.getString(Cidadao.ADMIN_EMAIL);
Cidadao cidadao = cidadaoDAO.findByLogin(adminEmail);
cidadao.setIniciativasAcompanhadas(new HashSet<>());
});
Cidade cidadeTeste = new Cidade(CIDADE_TESTE, "Pasárgada", "PB", 1f, 1f, 1f, 1f, 1000L, 1f, 1f, 0f);
Iniciativa iniciativaTeste = new Iniciativa(INICIATIVA_TESTE, 2015, "iniciativa para melhorar condições da cidade", "programa do governo federal", "area de atuação", "fonte", "concedente", "status", false, 1000f, 1000f, new Date(), new Date(), new Date());
cidadeTeste.addIniciativa(iniciativaTeste, new Date(), false);
CidadeDAO cidadeDAO = app.injector().instanceOf(CidadeDAO.class);
jpaAPI.withTransaction(() ->{
if(cidadeDAO.find(-1L) == null){
cidadeDAO.save(cidadeTeste);
}
});
}
开发者ID:nazareno,项目名称:diferentonas-server,代码行数:24,代码来源:IniciativaControllerTest.java
示例3: setUp
import play.db.jpa.JPAApi; //导入依赖的package包/类
@Before
public void setUp() {
this.controller = app.injector().instanceOf(OpiniaoController.class);
this.jpaAPI = app.injector().instanceOf(JPAApi.class);
this.daoOpiniao = app.injector().instanceOf(OpiniaoDAO.class);
Cidade cidadeTeste = new Cidade(CIDADE_TESTE, "Pasárgada", "PB", 1f, 1f, 1f, 1f, 1000L, 1f, 1f, 0f);
Iniciativa iniciativaTeste = new Iniciativa(INICIATIVA_TESTE, 2015, "iniciativa para melhorar condições da cidade", "programa do governo federal", "area de atuação", "fonte", "concedente", "status", false, 1000f, 1000f, new Date(), new Date(), new Date());
cidadeTeste.addIniciativa(iniciativaTeste, new Date(), false);
CidadeDAO cidadeDAO = app.injector().instanceOf(CidadeDAO.class);
jpaAPI.withTransaction(() ->{
if(cidadeDAO.find(-1L) == null){
cidadeDAO.save(cidadeTeste);
}
});
}
开发者ID:nazareno,项目名称:diferentonas-server,代码行数:19,代码来源:OpiniaoControllerTest.java
示例4: autenticaAdmin
import play.db.jpa.JPAApi; //导入依赖的package包/类
@Before
public void autenticaAdmin() throws JOSEException{
admin = app.injector().instanceOf(JPAApi.class).withTransaction(()->{
Configuration configuration = app.injector().instanceOf(Configuration.class);
String adminEmail = configuration.getString(Cidadao.ADMIN_EMAIL);
CidadaoDAO cidadaoDAO = app.injector().instanceOf(CidadaoDAO.class);
if(cidadaoDAO.findByLogin(adminEmail) == null){
Cidadao cidadao = new Cidadao("Governo Federal", adminEmail);
cidadao.setFuncionario(true);
cidadao.setMinisterioDeAfiliacao("Governo Federal");
return cidadaoDAO.saveAndUpdate(cidadao);
}
return cidadaoDAO.findByLogin(adminEmail);
});
AuthUtils authenticator = app.injector().instanceOf(AuthUtils.class);
token = authenticator.createToken("localhost", admin).getToken();
builder = new RequestBuilder().header("authorization", "token " + token);
}
开发者ID:nazareno,项目名称:diferentonas-server,代码行数:21,代码来源:WithAuthentication.java
示例5: preparaBancoParaTeste
import play.db.jpa.JPAApi; //导入依赖的package包/类
@Before
public void preparaBancoParaTeste() {
cidadaosCobaia = new LinkedList<>();
cidadaosCobaia.add(new Cidadao("root maria", "[email protected]"));
cidadaosCobaia.add(new Cidadao("raquel maria", "[email protected]"));
cidadaosCobaia.add(new Cidadao("toinho", "[email protected]"));
controller = app.injector().instanceOf(CidadaoController.class);
jpaAPI = app.injector().instanceOf(JPAApi.class);
limpaBanco();
jpaAPI.withTransaction(() -> {
for (Cidadao c:
cidadaosCobaia) {
controller.criaCidadao(c);
}
});
}
开发者ID:nazareno,项目名称:diferentonas-server,代码行数:18,代码来源:CidadaoControllerTest.java
示例6: AccountManager
import play.db.jpa.JPAApi; //导入依赖的package包/类
@Inject
public AccountManager(ElasticsearchService elasticsearchService,
PostManager postManager,
GroupManager groupManager,
GroupAccountManager groupAccountManager,
FriendshipManager friendshipManager,
MediaManager mediaManager,
NotificationManager notificationManager,
AvatarManager avatarManager,
FolderManager folderManager,
Configuration configuration, JPAApi jpaApi) {
this.elasticsearchService = elasticsearchService;
this.postManager = postManager;
this.groupManager = groupManager;
this.groupAccountManager = groupAccountManager;
this.friendshipManager = friendshipManager;
this.mediaManager = mediaManager;
this.notificationManager = notificationManager;
this.avatarManager = avatarManager;
this.folderManager = folderManager;
this.configuration = configuration;
this.jpaApi = jpaApi;
}
开发者ID:socia-platform,项目名称:htwplus,代码行数:24,代码来源:AccountManager.java
示例7: EmailService
import play.db.jpa.JPAApi; //导入依赖的package包/类
@Inject
public EmailService(Configuration configuration,
MailerClient mailerClient,
Email email,
NotificationManager notificationManager,
JPAApi jpaApi,
MessagesApi messagesApi) {
this.configuration = configuration;
this.mailerClient = mailerClient;
this.email = email;
this.notificationManager = notificationManager;
this.jpaApi = jpaApi;
this.messagesApi = messagesApi;
this.EMAIL_SENDER = configuration.getString("htwplus.email.sender");
}
开发者ID:socia-platform,项目名称:htwplus,代码行数:19,代码来源:EmailService.java
示例8: BaseJobService
import play.db.jpa.JPAApi; //导入依赖的package包/类
@Inject public BaseJobService(JPAApi jpaApi, Configuration configuration,
RemoteModelService<VirtualMachine> virtualMachineModelService, CloudService cloudService,
ModelService<Tenant> tenantModelService, RemoteModelService<Instance> instanceModelService,
@Named("jobQueue") SimpleBlockingQueue<Job> jobQueue, KeyPairStrategy keyPairStrategy,
RemoteConnectionStrategy.RemoteConnectionStrategyFactory remoteConnectionStrategyFactory,
PortProvidedService portProvidedService, ModelValidationService modelValidationService,
ModelService<MonitorInstance> monitorInstanceModelService, ModelService<RawMonitor> rawMonitorModelService) {
this.virtualMachineModelService = virtualMachineModelService;
this.tenantModelService = tenantModelService;
this.instanceModelService = instanceModelService;
this.keyPairStrategy = keyPairStrategy;
this.remoteConnectionStrategyFactory = remoteConnectionStrategyFactory;
this.portProvidedService = portProvidedService;
this.modelValidationService = modelValidationService;
this.colosseumComputeService = cloudService.computeService();
this.jobQueue = jobQueue;
this.configuration = configuration;
this.jpaApi = jpaApi;
this.monitorInstanceModelService = monitorInstanceModelService;
this.rawMonitorModelService = rawMonitorModelService;
}
开发者ID:cloudiator,项目名称:colosseum,代码行数:22,代码来源:BaseJobService.java
示例9: CreateInstanceJob
import play.db.jpa.JPAApi; //导入依赖的package包/类
public CreateInstanceJob(Configuration configuration, JPAApi jpaApi, Instance instance,
RemoteModelService<Instance> modelService, ModelService<Tenant> tenantModelService,
ColosseumComputeService colosseumComputeService, Tenant tenant,
ModelValidationService modelValidationService) {
super(jpaApi, instance, modelService, tenantModelService, colosseumComputeService, tenant);
checkNotNull(modelValidationService);
checkNotNull(configuration);
this.modelValidationService = modelValidationService;
applicationToApplicationId = new ApplicationToApplicationId();
applicationInstanceToApplicationInstanceId =
new ApplicationInstanceToApplicationInstanceId();
applicationComponentToComponentId = new ApplicationComponentToComponentId();
applicationComponentToDeployableComponent = new ApplicationComponentToDeployableComponent();
applicationComponentToContainerType =
new ApplicationComponentToContainerType(configuration);
osConverter = new OsConverter();
this.configuration = configuration;
}
开发者ID:cloudiator,项目名称:colosseum,代码行数:21,代码来源:CreateInstanceJob.java
示例10: CreateVirtualMachineJob
import play.db.jpa.JPAApi; //导入依赖的package包/类
public CreateVirtualMachineJob(JPAApi jpaApi, VirtualMachine virtualMachine,
RemoteModelService<VirtualMachine> modelService, ModelService<Tenant> tenantModelService,
ColosseumComputeService colosseumComputeService, Tenant tenant,
KeyPairStrategy keyPairStrategy,
RemoteConnectionStrategy.RemoteConnectionStrategyFactory remoteConnectionFactory,
PortProvidedService portProvidedService) {
super(jpaApi, virtualMachine, modelService, tenantModelService, colosseumComputeService,
tenant);
checkNotNull(keyPairStrategy);
checkNotNull(remoteConnectionFactory);
this.keyPairStrategy = keyPairStrategy;
this.remoteConnectionFactory = remoteConnectionFactory;
this.portProvidedService = portProvidedService;
}
开发者ID:cloudiator,项目名称:colosseum,代码行数:17,代码来源:CreateVirtualMachineJob.java
示例11: configure
import play.db.jpa.JPAApi; //导入依赖的package包/类
@Override protected void configure() {
bindInterceptor(Matchers.subclassesOf(Runnable.class), Matchers.annotatedWith(Loop.class),
new LoopRunnableInterceptor());
bindInterceptor(Matchers.subclassesOf(Runnable.class),
Matchers.annotatedWith(Transactional.class),
new TransactionalRunnableInterceptor(getProvider(JPAApi.class)));
final ThreadFactory threadFactory =
new ThreadFactoryBuilder().setNameFormat("ExecutionService-%d").build();
bind(ExecutionService.class).toInstance(new StableScheduledThreadExecutor(
new ScheduledThreadPoolExecutorExecutionService(new LoggingScheduledThreadPoolExecutor(
configuration.getInt("colosseum.execution.thread", 10), threadFactory))));
bind(ExecutionSystemInitialization.class).asEagerSingleton();
Multibinder.newSetBinder(binder(), Runnable.class);
Multibinder.newSetBinder(binder(), Schedulable.class);
}
开发者ID:cloudiator,项目名称:colosseum,代码行数:20,代码来源:ExecutionModule.java
示例12: LoginController
import play.db.jpa.JPAApi; //导入依赖的package包/类
@Inject
public LoginController(CidadaoDAO dao, WSClient ws, FormFactory formFactory,
Configuration configuration, JPAApi api, AuthUtils authenticator) {
this.dao = dao;
this.ws = ws;
this.formFactory = formFactory;
this.api = api;
this.authenticator = authenticator;
this.facebookSecret = configuration.getString(ProvedorDeLogin.FACEBOOK.getSecretProp());
this.googleSecret = configuration.getString(ProvedorDeLogin.GOOGLE.getSecretProp());
}
开发者ID:nazareno,项目名称:diferentonas-server,代码行数:12,代码来源:LoginController.java
示例13: InitialData
import play.db.jpa.JPAApi; //导入依赖的package包/类
/**
* @param jpaAPI
*/
@Inject
public InitialData(JPAApi jpaAPI, CidadaoDAO daoCidadao, AtualizacaoDAO daoAtualizacao, Configuration configuration) throws SQLException {
Logger.debug("Iniciando a aplicação.");
dataDir = Paths.get(configuration.getString("diferentonas.data", DIST_DATA)).toAbsolutePath().toString();
String adminEmail = configuration.getString(Cidadao.ADMIN_EMAIL);
if(adminEmail == null || adminEmail.trim().isEmpty()){
throw new RuntimeException("Atribua um valor a diferentonas.admin.email no seu arquivo de configuração!");
}
for (ProvedorDeLogin provedorDeLogin : ProvedorDeLogin.values()) {
String token = configuration.getString(provedorDeLogin
.getSecretProp());
if (token == null || token.trim().isEmpty()) {
throw new RuntimeException(
"Atribua um valor a "
+ provedorDeLogin.getSecretProp()
+ " no seu arquivo de configuração ou seus usuários não poderão se autenticar usando o "
+ provedorDeLogin.getName());
}
}
populaCidadaos(jpaAPI, daoCidadao, adminEmail, configuration.getInt("diferentonas.demo.numerodecidadaos", 0));
populaCidades(jpaAPI);
}
开发者ID:nazareno,项目名称:diferentonas-server,代码行数:31,代码来源:InitialData.java
示例14: populaVizinhos
import play.db.jpa.JPAApi; //导入依赖的package包/类
private void populaVizinhos(JPAApi jpaAPI) throws SQLException {
String dataPath = dataDir + "/vizinhos.euclidiano.csv";
Logger.info("Cidades semelhantes vêm de " + dataPath);
int count = 0;
final ResultSet vizinhosResultSet = new Csv().read(dataPath, null, "utf-8");
count = 0;
while (vizinhosResultSet.next()) {
long originID = vizinhosResultSet.getLong(12);
LongStream similaresIDs = LongStream
.range(13, 23)
.map(value -> {
try {
return vizinhosResultSet.getLong((int) value);
} catch (Exception e) {
Logger.error("Não recuperou cidade " + value + " similar a " + originID, e);
return 0;
}
});
EntityManager em = jpaAPI.em();
Cidade o = em.find(Cidade.class, originID);
List<Cidade> similares = similaresIDs
.mapToObj(
value -> em
.find(Cidade.class, value))
.map(obj -> (Cidade) obj)
.collect(Collectors.toList());
o.setSimilares(similares);
em.persist(o);
count++;
if (count % 1000 == 0) {
Logger.info("Inseri vizinhos para " + count + " cidades...");
}
}
}
开发者ID:nazareno,项目名称:diferentonas-server,代码行数:38,代码来源:InitialData.java
示例15: limpaBancoDepoisDeTestes
import play.db.jpa.JPAApi; //导入依赖的package包/类
@After
public void limpaBancoDepoisDeTestes() {
JPAApi jpaAPI = app.injector().instanceOf(JPAApi.class);
CidadeDAO cidadeDAO = app.injector().instanceOf(CidadeDAO.class);
IniciativaDAO iniciativaDAO = app.injector().instanceOf(IniciativaDAO.class);
jpaAPI.withTransaction(() ->{
if(cidadeDAO.find(-1L) != null){
cidadeDAO.remove(cidadeDAO.find(-1L));
}
if(iniciativaDAO.find(-1L) != null){
iniciativaDAO.remove(iniciativaDAO.find(-1L));
}
});
}
开发者ID:nazareno,项目名称:diferentonas-server,代码行数:15,代码来源:IniciativaControllerTest.java
示例16: limpaBancoParaTestes
import play.db.jpa.JPAApi; //导入依赖的package包/类
@Before
public void limpaBancoParaTestes() {
JPAApi jpaAPI = app.injector().instanceOf(JPAApi.class);
Cidade cidadeTeste = new Cidade(CIDADE_TESTE, "Pasárgada", "PB", 1f, 1f, 1f, 1f, 1000L, 1f, 1f, 0f);
Iniciativa iniciativaTeste = new Iniciativa(INICIATIVA_TESTE, 2015, "iniciativa para melhorar condições da cidade", "programa do governo federal", "area de atuação", "fonte", "concedente", "status", false, 1000f, 1000f, new Date(), new Date(), new Date());
cidadeTeste.addIniciativa(iniciativaTeste, new Date(), false);
CidadeDAO cidadeDAO = app.injector().instanceOf(CidadeDAO.class);
jpaAPI.withTransaction(() ->{
if(cidadeDAO.find(-1L) == null){
cidadeDAO.save(cidadeTeste);
}
});
}
开发者ID:nazareno,项目名称:diferentonas-server,代码行数:15,代码来源:FeedControllerTest.java
示例17: limpaBancoAposTeste
import play.db.jpa.JPAApi; //导入依赖的package包/类
@After
public void limpaBancoAposTeste() {
IniciativaDAO daoIniciativa = app.injector().instanceOf(IniciativaDAO.class);
OpiniaoDAO daoOpiniao = app.injector().instanceOf(OpiniaoDAO.class);
JPAApi jpaAPI = app.injector().instanceOf(JPAApi.class);
jpaAPI.withTransaction(() -> {
Iniciativa i = daoIniciativa.find(iniciativaUsada);
for (UUID uuid : uuidDeOpinioesPraRemover) {
Opiniao paraRemover = new Opiniao();
paraRemover.setId(uuid);
i.removeOpiniao(paraRemover);
daoOpiniao.delete(daoOpiniao.find(uuid));
}
daoIniciativa.save(i);
});
desautenticaAdmin();
CidadeDAO cidadeDAO = app.injector().instanceOf(CidadeDAO.class);
IniciativaDAO iniciativaDAO = app.injector().instanceOf(IniciativaDAO.class);
jpaAPI.withTransaction(() ->{
if(cidadeDAO.find(-1L) != null){
cidadeDAO.remove(cidadeDAO.find(-1L));
}
if(iniciativaDAO.find(-1L) != null){
iniciativaDAO.remove(iniciativaDAO.find(-1L));
}
});
}
开发者ID:nazareno,项目名称:diferentonas-server,代码行数:31,代码来源:FeedControllerTest.java
示例18: tearDown
import play.db.jpa.JPAApi; //导入依赖的package包/类
@After
public void tearDown() {
IniciativaDAO daoIniciativa = app.injector().instanceOf(IniciativaDAO.class);
JPAApi jpaAPI = app.injector().instanceOf(JPAApi.class);
jpaAPI.withTransaction(() -> {
Iniciativa i = daoIniciativa.find(iniciativaExemplo);
for (UUID uuid : uuidDeOpinioesPraRemover) {
Opiniao paraRemover = new Opiniao();
paraRemover.setId(uuid);
i.removeOpiniao(paraRemover);
}
daoIniciativa.save(i);
});
uuidDeOpinioesPraRemover.clear();
desautenticaAdmin();
CidadeDAO cidadeDAO = app.injector().instanceOf(CidadeDAO.class);
IniciativaDAO iniciativaDAO = app.injector().instanceOf(IniciativaDAO.class);
jpaAPI.withTransaction(() ->{
if(cidadeDAO.find(-1L) != null){
cidadeDAO.remove(cidadeDAO.find(-1L));
}
if(iniciativaDAO.find(-1L) != null){
iniciativaDAO.remove(iniciativaDAO.find(-1L));
}
});
}
开发者ID:nazareno,项目名称:diferentonas-server,代码行数:30,代码来源:OpiniaoControllerTest.java
示例19: setUp
import play.db.jpa.JPAApi; //导入依赖的package包/类
@Before
public void setUp() {
this.dao = app.injector().instanceOf(CidadeDAO.class);
this.jpaAPI = app.injector().instanceOf(JPAApi.class);
this.jpaAPI.withTransaction(()->{
Cidade cidadeTeste = new Cidade(CIDADE_TESTE, "Pasárgada", "PB", 1f, 1f, 1f, 1f, 1000L, 1f, 1f, 0f);
if(dao.find(-1L) == null){
dao.save(cidadeTeste);
}
});
}
开发者ID:nazareno,项目名称:diferentonas-server,代码行数:13,代码来源:CidadeControllerTest.java
示例20: desautenticaAdmin
import play.db.jpa.JPAApi; //导入依赖的package包/类
@After
public void desautenticaAdmin() {
app.injector().instanceOf(JPAApi.class).withTransaction(()->{
Configuration configuration = app.injector().instanceOf(Configuration.class);
String adminEmail = configuration.getString(Cidadao.ADMIN_EMAIL);
CidadaoDAO cidadaoDAO = app.injector().instanceOf(CidadaoDAO.class);
Cidadao admin = cidadaoDAO.findByLogin(adminEmail);
if(admin != null){
cidadaoDAO.remove(admin);
}
});
}
开发者ID:nazareno,项目名称:diferentonas-server,代码行数:13,代码来源:WithAuthentication.java
注:本文中的play.db.jpa.JPAApi类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论