use of com.haulmont.bali.db.QueryRunner in project cuba by cuba-platform.
the class DataManagerTest method setUp.
@Before
public void setUp() throws Exception {
dataManager = AppBeans.get(DataManager.class);
QueryRunner runner = new QueryRunner(cont.persistence().getDataSource());
runner.update("delete from SYS_SERVER");
}
use of com.haulmont.bali.db.QueryRunner in project cuba by cuba-platform.
the class DynamicAttributesTest method tearDown.
@After
public void tearDown() throws Exception {
QueryRunner runner = new QueryRunner(cont.persistence().getDataSource());
runner.update("delete from SYS_ATTR_VALUE");
cont.deleteRecord(userRole, role, user, user2, group, group2);
cont.deleteRecord(userAttribute, userRoleAttribute, userGroupAttribute, userGroupCollectionAttribute, userIntCollectionAttribute);
cont.deleteRecord(userCategory, userRoleCategory);
}
use of com.haulmont.bali.db.QueryRunner in project cuba by cuba-platform.
the class NonEntityQueryTest method setUp.
@Before
public void setUp() throws Exception {
dataManager = AppBeans.get(DataManager.class);
passwordEncryption = AppBeans.get(PasswordEncryption.class);
QueryRunner runner = new QueryRunner(cont.persistence().getDataSource());
runner.update("delete from SYS_SERVER");
Transaction tx = cont.persistence().createTransaction();
try {
EntityManager em = cont.persistence().getEntityManager();
UserSessionSource uss = AppBeans.get(UserSessionSource.class);
UserSession userSession = uss.getUserSession();
Server server = new Server();
server.setName("someServer");
server.setRunning(false);
serverId = server.getId();
em.persist(server);
EntitySnapshot entitySnapshot = cont.metadata().create(EntitySnapshot.class);
entitySnapshot.setSnapshotDate(new Date());
entitySnapshot.setAuthor(userSession.getCurrentOrSubstitutedUser());
entitySnapshotId = entitySnapshot.getId();
em.persist(entitySnapshot);
Role role1 = new Role();
role1Id = role1.getId();
role1.setName("testRole1");
em.persist(role1);
Permission permission1 = new Permission();
permission1Id = permission1.getId();
permission1.setRole(role1);
permission1.setType(PermissionType.ENTITY_ATTR);
permission1.setTarget("sys$Server:name");
permission1.setValue(0);
em.persist(permission1);
Permission permission2 = new Permission();
permission2Id = permission2.getId();
permission2.setRole(role1);
permission2.setType(PermissionType.ENTITY_OP);
permission2.setTarget("sys$EntitySnapshot:read");
permission2.setValue(0);
em.persist(permission2);
Group group1 = new Group();
group1Id = group1.getId();
group1.setName("testGroup1");
em.persist(group1);
User user1 = new User();
user1Id = user1.getId();
user1.setName(USER_NAME_1);
user1.setLogin(USER_NAME_1);
user1.setPassword(passwordEncryption.getPasswordHash(user1Id, USER_PASSWORD));
user1.setGroup(group1);
em.persist(user1);
UserRole userRole1 = new UserRole();
userRole1Id = userRole1.getId();
userRole1.setUser(user1);
userRole1.setRole(role1);
em.persist(userRole1);
Group group2 = new Group();
group2Id = group2.getId();
group2.setName("testGroup2");
em.persist(group2);
Constraint constraint1 = new Constraint();
constraint1Id = constraint1.getId();
constraint1.setEntityName("sys$Server");
constraint1.setWhereClause("{E}.running = true");
constraint1.setGroup(group2);
em.persist(constraint1);
Constraint constraint2 = new Constraint();
constraint2Id = constraint2.getId();
constraint2.setEntityName("sys$EntitySnapshot");
constraint2.setCheckType(ConstraintCheckType.MEMORY);
constraint2.setGroovyScript("{E}.viewXml = 'xml'");
constraint2.setGroup(group2);
em.persist(constraint2);
User user2 = new User();
user2Id = user2.getId();
user2.setName(USER_NAME_2);
user2.setLogin(USER_NAME_2);
user2.setPassword(passwordEncryption.getPasswordHash(user2Id, USER_PASSWORD));
user2.setGroup(group2);
em.persist(user2);
tx.commit();
} finally {
tx.end();
}
}
use of com.haulmont.bali.db.QueryRunner in project cuba by cuba-platform.
the class PersistenceHelperTest method setUp.
@Before
public void setUp() throws Exception {
QueryRunner runner = new QueryRunner(cont.persistence().getDataSource());
runner.update("delete from SYS_SERVER");
}
use of com.haulmont.bali.db.QueryRunner in project cuba by cuba-platform.
the class QueryResultTest method setUp.
@Before
public void setUp() throws Exception {
QueryRunner runner = new QueryRunner(cont.persistence().getDataSource());
try {
runner.update("delete from SYS_QUERY_RESULT");
} catch (SQLException e) {
throw new RuntimeException(e);
}
createEntities();
}
Aggregations