use of com.haulmont.cuba.core.global.View in project cuba by cuba-platform.
the class SoftDeleteTest method testReferenceToDeletedEntityThroughOneToMany.
@Test
public void testReferenceToDeletedEntityThroughOneToMany() throws Exception {
View userRoleView = new View(UserRole.class).addProperty("role", new View(Role.class).addProperty("deleteTs"));
View userView = new View(User.class).addProperty("userRoles", userRoleView);
Role deleted = cont.persistence().callInTransaction((em) -> em.find(Role.class, role3Id));
assertNull(deleted);
UserRole userRole = cont.persistence().callInTransaction((em) -> em.find(UserRole.class, userRole3Id, userRoleView));
assertNotNull(userRole.getRole());
assertEquals(role3Id, userRole.getRole().getId());
assertTrue(userRole.getRole().isDeleted());
User user = cont.persistence().callInTransaction((em) -> em.find(User.class, user1Id, userView));
assertEquals(role3Id, user.getUserRoles().iterator().next().getRole().getId());
Assert.assertTrue(user.getUserRoles().iterator().next().getRole().isDeleted());
}
use of com.haulmont.cuba.core.global.View in project cuba by cuba-platform.
the class EntitiesMetadataControllerManager method getAllViewsForMetaClass.
public String getAllViewsForMetaClass(String entityName) {
MetaClass metaClass = restControllersUtils.getMetaClass(entityName);
StringBuilder sb = new StringBuilder();
sb.append("[");
List<String> jsonViews = new ArrayList<>();
for (String viewName : viewRepository.getViewNames(metaClass)) {
View view = viewRepository.getView(metaClass, viewName);
jsonViews.add(viewSerializationAPI.toJson(view));
}
sb.append(Joiner.on(",").join(jsonViews));
sb.append("]");
return sb.toString();
}
use of com.haulmont.cuba.core.global.View in project cuba by cuba-platform.
the class EntitiesMetadataControllerManager method getView.
public String getView(String entityName, String viewName) {
MetaClass metaClass = restControllersUtils.getMetaClass(entityName);
View view = viewRepository.findView(metaClass, viewName);
if (view == null) {
throw new RestAPIException("View not found", String.format("View %s for metaClass %s not found", viewName, entityName), HttpStatus.NOT_FOUND);
}
return viewSerializationAPI.toJson(view);
}
use of com.haulmont.cuba.core.global.View in project cuba by cuba-platform.
the class AbstractViewRepositoryTest method notIntersectPropertiesExtendedViews.
@Test
public void notIntersectPropertiesExtendedViews() {
View view = metadata.getViewRepository().getView(testMasterEntity, "detailAndDetails");
assertNotNull(view);
assertTrue(view.containsProperty("detail"));
assertTrue(view.containsProperty("details"));
}
use of com.haulmont.cuba.core.global.View in project cuba by cuba-platform.
the class AbstractViewRepositoryTest method intersectPropertiesExtendedViewsTwoLevel.
@Test
public void intersectPropertiesExtendedViewsTwoLevel() {
View view = metadata.getViewRepository().getView(testMasterEntity, "intersectViewTwo");
assertTrue(view.containsProperty("detail"));
ViewProperty detail = view.getProperty("detail");
assertTrue(detail.getView().containsProperty("embeddable"));
assertTrue(detail.getView().containsProperty("parts"));
}
Aggregations