use of com.haulmont.cuba.core.global.View in project cuba by cuba-platform.
the class ViewRepositoryInfo method dumpHtml.
public String dumpHtml() {
StringBuilder content = new StringBuilder("<html><head><title>Views</title></head><body>");
for (View view : viewRepository.getAll()) {
dumpHtml(view, content);
}
content.append("</body></html>");
return content.toString();
}
use of com.haulmont.cuba.core.global.View in project cuba by cuba-platform.
the class ViewRepositoryInfo method dumpHtml.
protected void dumpHtml(ViewProperty viewProperty, StringBuilder content, String indent) {
content.append("<br/>").append("\n");
content.append(indent);
content.append("- ").append(viewProperty.getName());
View innerView = viewProperty.getView();
if (innerView != null) {
if (StringUtils.isNotEmpty(innerView.getName())) {
String metaClassName = metadata.getSession().getClass(innerView.getEntityClass()).getName();
content.append(" -> <a href=\"#").append(metaClassName).append("__").append(innerView.getName()).append("\">").append(metaClassName).append("/").append(innerView.getName()).append("</a>");
} else {
for (ViewProperty innerProperty : innerView.getProperties()) {
dumpHtml(innerProperty, content, " " + indent);
}
}
}
}
use of com.haulmont.cuba.core.global.View in project cuba by cuba-platform.
the class SoftDeleteTest method testOneToMany_CleanupMode.
@Test
public void testOneToMany_CleanupMode() {
System.out.println("===================== BEGIN testOneToMany_CleanupMode =====================");
Transaction tx = cont.persistence().createTransaction();
try {
EntityManager em = cont.persistence().getEntityManager();
em.setSoftDeletion(false);
View view = new View(User.class, "testView").addProperty("name").addProperty("login").addProperty("userRoles", new View(UserRole.class, "testView").addProperty("role", new View(Role.class, "testView").addProperty("name")));
User user = em.find(User.class, userId, view);
List<UserRole> userRoles = user.getUserRoles();
assertEquals(2, userRoles.size());
for (UserRole ur : userRoles) {
assertNotNull(ur.getRole());
}
tx.commit();
} finally {
tx.end();
}
System.out.println("===================== END testOneToMany_CleanupMode =====================");
}
use of com.haulmont.cuba.core.global.View in project cuba by cuba-platform.
the class SoftDeleteTest method testOneToOne.
@Test
public void testOneToOne() {
System.out.println("===================== BEGIN testOneToOne =====================");
// test fetchMode = AUTO
System.out.println("===================== BEGIN testOneToOne fetchMode = AUTO =====================");
Transaction tx = cont.persistence().createTransaction();
try {
EntityManager em = cont.persistence().getEntityManager();
View view = new View(SoftDeleteOneToOneA.class, "testView").addProperty("name").addProperty("b", new View(SoftDeleteOneToOneB.class, "testView").addProperty("name"));
SoftDeleteOneToOneA oneToOneA = em.find(SoftDeleteOneToOneA.class, oneToOneA2Id, view);
assertNotNull(oneToOneA);
assertNotNull(oneToOneA.getB());
assertEquals(oneToOneA.getB().getId(), oneToOneB2Id);
tx.commit();
} finally {
tx.end();
}
// test fetchMode = BATCH
System.out.println("===================== BEGIN testOneToOneBy fetchMode = BATCH =====================");
tx = cont.persistence().createTransaction();
try {
EntityManager em = cont.persistence().getEntityManager();
View view = new View(SoftDeleteOneToOneA.class, "testView").addProperty("name").addProperty("b", new View(SoftDeleteOneToOneB.class, "testView").addProperty("name"), FetchMode.BATCH);
SoftDeleteOneToOneA oneToOneA = em.find(SoftDeleteOneToOneA.class, oneToOneA2Id, view);
assertNotNull(oneToOneA);
assertNotNull(oneToOneA.getB());
assertEquals(oneToOneA.getB().getId(), oneToOneB2Id);
tx.commit();
} finally {
tx.end();
}
// test fetchMode = UNDEFINED
System.out.println("===================== BEGIN testOneToOneBy fetchMode = UNDEFINED =====================");
tx = cont.persistence().createTransaction();
try {
EntityManager em = cont.persistence().getEntityManager();
View view = new View(SoftDeleteOneToOneA.class, "testView").addProperty("name").addProperty("b", new View(SoftDeleteOneToOneB.class, "testView").addProperty("name"), FetchMode.UNDEFINED);
SoftDeleteOneToOneA oneToOneA = em.find(SoftDeleteOneToOneA.class, oneToOneA2Id, view);
assertNotNull(oneToOneA);
assertNotNull(oneToOneA.getB());
assertEquals(oneToOneA.getB().getId(), oneToOneB2Id);
tx.commit();
} finally {
tx.end();
}
System.out.println("===================== END testOneToOne =====================");
}
use of com.haulmont.cuba.core.global.View in project cuba by cuba-platform.
the class SoftDeleteTest method testOneToOneMappedBy.
@Test
public void testOneToOneMappedBy() {
System.out.println("===================== BEGIN testOneToOneMappedBy =====================");
// test fetchMode = AUTO
System.out.println("===================== BEGIN testOneToOneMappedBy fetchMode = AUTO =====================");
Transaction tx = cont.persistence().createTransaction();
try {
EntityManager em = cont.persistence().getEntityManager();
View view = new View(SoftDeleteOneToOneB.class, "testView").addProperty("name").addProperty("a", new View(SoftDeleteOneToOneA.class, "testView").addProperty("name"));
SoftDeleteOneToOneB oneToOneB = em.find(SoftDeleteOneToOneB.class, oneToOneB1Id, view);
assertNotNull(oneToOneB);
assertNull(oneToOneB.getA());
tx.commit();
} finally {
tx.end();
}
// test fetchMode = BATCH
System.out.println("===================== BEGIN testOneToOneMappedBy fetchMode = BATCH =====================");
tx = cont.persistence().createTransaction();
try {
EntityManager em = cont.persistence().getEntityManager();
View view = new View(SoftDeleteOneToOneB.class, "testView").addProperty("name").addProperty("a", new View(SoftDeleteOneToOneA.class, "testView").addProperty("name"), FetchMode.BATCH);
SoftDeleteOneToOneB oneToOneB = em.find(SoftDeleteOneToOneB.class, oneToOneB1Id, view);
assertNotNull(oneToOneB);
assertNull(oneToOneB.getA());
tx.commit();
} finally {
tx.end();
}
// test fetchMode = UNDEFINED
System.out.println("===================== BEGIN testOneToOneMappedBy fetchMode = UNDEFINED =====================");
tx = cont.persistence().createTransaction();
try {
EntityManager em = cont.persistence().getEntityManager();
View view = new View(SoftDeleteOneToOneB.class, "testView").addProperty("name").addProperty("a", new View(SoftDeleteOneToOneA.class, "testView").addProperty("name"), FetchMode.UNDEFINED);
SoftDeleteOneToOneB oneToOneB = em.find(SoftDeleteOneToOneB.class, oneToOneB1Id, view);
assertNotNull(oneToOneB);
assertNull(oneToOneB.getA());
tx.commit();
} finally {
tx.end();
}
System.out.println("===================== END testOneToOneMappedBy =====================");
}
Aggregations