Search in sources :

Example 1 with EntityTypeShortDto

use of org.entando.entando.aps.system.services.entity.model.EntityTypeShortDto in project entando-core by entando.

the class EntityManagerServiceIntegrationTest method testGetEntityTypes_1.

@Test
public void testGetEntityTypes_1() {
    RestListRequest restListRequest = new RestListRequest();
    PagedMetadata<EntityTypeShortDto> dtos = this.entityManagerService.getShortEntityTypes(SystemConstants.USER_PROFILE_MANAGER, restListRequest);
    assertNotNull(dtos);
    assertEquals(1, dtos.getBody().size());
}
Also used : EntityTypeShortDto(org.entando.entando.aps.system.services.entity.model.EntityTypeShortDto) RestListRequest(org.entando.entando.web.common.model.RestListRequest) Test(org.junit.Test)

Example 2 with EntityTypeShortDto

use of org.entando.entando.aps.system.services.entity.model.EntityTypeShortDto in project entando-core by entando.

the class DataTypeController method getDataTypes.

@RestAccessControl(permission = Permission.SUPERUSER)
@RequestMapping(method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<RestResponse> getDataTypes(@Valid RestListRequest requestList) throws JsonProcessingException {
    this.getDataTypeValidator().validateRestListRequest(requestList);
    PagedMetadata<EntityTypeShortDto> result = this.getDataObjectService().getShortDataTypes(requestList);
    this.getDataTypeValidator().validateRestListResult(requestList, result);
    logger.debug("Main Response -> {}", result);
    return new ResponseEntity<>(new RestResponse(result.getBody(), null, result), HttpStatus.OK);
}
Also used : ResponseEntity(org.springframework.http.ResponseEntity) RestResponse(org.entando.entando.web.common.model.RestResponse) EntityTypeShortDto(org.entando.entando.aps.system.services.entity.model.EntityTypeShortDto) RestAccessControl(org.entando.entando.web.common.annotation.RestAccessControl) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 3 with EntityTypeShortDto

use of org.entando.entando.aps.system.services.entity.model.EntityTypeShortDto in project entando-core by entando.

the class ProfileTypeController method getUserProfileTypes.

@RestAccessControl(permission = Permission.SUPERUSER)
@RequestMapping(method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<RestResponse> getUserProfileTypes(RestListRequest requestList) throws JsonProcessingException {
    this.getProfileTypeValidator().validateRestListRequest(requestList);
    PagedMetadata<EntityTypeShortDto> result = this.getUserProfileTypeService().getShortUserProfileTypes(requestList);
    logger.debug("Main Response -> {}", result);
    this.getProfileTypeValidator().validateRestListResult(requestList, result);
    return new ResponseEntity<>(new RestResponse(result.getBody(), null, result), HttpStatus.OK);
}
Also used : ResponseEntity(org.springframework.http.ResponseEntity) RestResponse(org.entando.entando.web.common.model.RestResponse) EntityTypeShortDto(org.entando.entando.aps.system.services.entity.model.EntityTypeShortDto) RestAccessControl(org.entando.entando.web.common.annotation.RestAccessControl) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 4 with EntityTypeShortDto

use of org.entando.entando.aps.system.services.entity.model.EntityTypeShortDto in project entando-core by entando.

the class AbstractEntityService method getShortEntityTypes.

protected PagedMetadata<EntityTypeShortDto> getShortEntityTypes(String entityManagerCode, RestListRequest requestList) {
    IEntityManager entityManager = this.extractEntityManager(entityManagerCode);
    List<IApsEntity> entityTypes = new ArrayList<>(entityManager.getEntityPrototypes().values());
    Map<String, String> fieldMapping = this.getEntityTypeFieldNameMapping();
    entityTypes.stream().filter(i -> this.filterObjects(i, requestList.getFilter(), fieldMapping));
    Collections.sort(entityTypes, new BeanComparator(this.getFieldName(requestList.getSort(), fieldMapping)));
    if (!RestListRequest.DIRECTION_VALUE_DEFAULT.equals(requestList.getDirection())) {
        Collections.reverse(entityTypes);
    }
    List<IApsEntity> sublist = requestList.getSublist(entityTypes);
    SearcherDaoPaginatedResult<IApsEntity> result = new SearcherDaoPaginatedResult(entityTypes.size(), sublist);
    PagedMetadata<EntityTypeShortDto> pagedMetadata = new PagedMetadata<>(requestList, result);
    List<EntityTypeShortDto> body = this.getEntityTypeShortDtoBuilder().convert(sublist);
    for (EntityTypeShortDto entityTypeShortDto : body) {
        String code = entityTypeShortDto.getCode();
        entityTypeShortDto.setStatus(String.valueOf(entityManager.getStatus(code)));
    }
    pagedMetadata.setBody(body);
    return pagedMetadata;
}
Also used : PagedMetadata(org.entando.entando.web.common.model.PagedMetadata) EntityTypeShortDto(org.entando.entando.aps.system.services.entity.model.EntityTypeShortDto) ArrayList(java.util.ArrayList) SearcherDaoPaginatedResult(com.agiletec.aps.system.common.model.dao.SearcherDaoPaginatedResult) BeanComparator(org.apache.commons.beanutils.BeanComparator) IEntityManager(com.agiletec.aps.system.common.entity.IEntityManager) IApsEntity(com.agiletec.aps.system.common.entity.model.IApsEntity)

Example 5 with EntityTypeShortDto

use of org.entando.entando.aps.system.services.entity.model.EntityTypeShortDto in project entando-core by entando.

the class EntityManagerServiceIntegrationTest method testGetEntityTypes_2.

@Test
public void testGetEntityTypes_2() {
    RestListRequest restListRequest = new RestListRequest();
    PagedMetadata<EntityTypeShortDto> dtos = this.entityManagerService.getShortEntityTypes(JacmsSystemConstants.CONTENT_MANAGER, restListRequest);
    assertNotNull(dtos);
    assertEquals(4, dtos.getBody().size());
}
Also used : EntityTypeShortDto(org.entando.entando.aps.system.services.entity.model.EntityTypeShortDto) RestListRequest(org.entando.entando.web.common.model.RestListRequest) Test(org.junit.Test)

Aggregations

EntityTypeShortDto (org.entando.entando.aps.system.services.entity.model.EntityTypeShortDto)5 RestAccessControl (org.entando.entando.web.common.annotation.RestAccessControl)2 RestListRequest (org.entando.entando.web.common.model.RestListRequest)2 RestResponse (org.entando.entando.web.common.model.RestResponse)2 Test (org.junit.Test)2 ResponseEntity (org.springframework.http.ResponseEntity)2 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)2 IEntityManager (com.agiletec.aps.system.common.entity.IEntityManager)1 IApsEntity (com.agiletec.aps.system.common.entity.model.IApsEntity)1 SearcherDaoPaginatedResult (com.agiletec.aps.system.common.model.dao.SearcherDaoPaginatedResult)1 ArrayList (java.util.ArrayList)1 BeanComparator (org.apache.commons.beanutils.BeanComparator)1 PagedMetadata (org.entando.entando.web.common.model.PagedMetadata)1