Class EntitiesControllerManager

java.lang.Object
io.jmix.rest.impl.service.EntitiesControllerManager

@Component("rest_EntitiesControllerManager") public class EntitiesControllerManager extends Object
Class that executes business logic required by the EntitiesController. It performs CRUD operations with entities
  • Field Details

    • dataManager

      @Autowired protected DataManager dataManager
    • metadata

      @Autowired protected Metadata metadata
    • entitySerialization

      @Autowired protected EntitySerialization entitySerialization
    • entityImportPlanJsonBuilder

      @Autowired protected EntityImportPlanJsonBuilder entityImportPlanJsonBuilder
    • entityImportExport

      @Autowired protected EntityImportExport entityImportExport
    • accessManager

      @Autowired protected AccessManager accessManager
    • restControllerUtils

      @Autowired protected RestControllerUtils restControllerUtils
    • restFilterParser

      @Autowired protected RestFilterParser restFilterParser
    • restProperties

      @Autowired protected RestProperties restProperties
    • entityStates

      @Autowired protected EntityStates entityStates
    • fetchPlanRepository

      @Autowired protected FetchPlanRepository fetchPlanRepository
    • metadataTools

      @Autowired protected MetadataTools metadataTools
    • fetchPlans

      @Autowired protected FetchPlans fetchPlans
    • validator

      @Autowired protected javax.validation.Validator validator
  • Constructor Details

    • EntitiesControllerManager

      public EntitiesControllerManager()
  • Method Details

    • loadEntity

      public String loadEntity(String entityName, String entityId, @Nullable String viewName, @Nullable Boolean returnNulls, @Nullable Boolean dynamicAttributes, @Nullable String modelVersion)
    • loadEntitiesList

      public EntitiesSearchResult loadEntitiesList(String entityName, @Nullable String viewName, @Nullable Integer limit, @Nullable Integer offset, @Nullable String sort, @Nullable Boolean returnNulls, @Nullable Boolean returnCount, @Nullable Boolean dynamicAttributes, @Nullable String modelVersion)
    • searchEntities

      public EntitiesSearchResult searchEntities(String entityName, String filterJson, @Nullable String viewName, @Nullable Integer limit, @Nullable Integer offset, @Nullable String sort, @Nullable Boolean returnNulls, @Nullable Boolean returnCount, @Nullable Boolean dynamicAttributes, @Nullable String modelVersion)
    • countSearchEntities

      public Long countSearchEntities(String entityName, String filterJson, @Nullable String modelVersion)
    • searchEntities

      public EntitiesSearchResult searchEntities(String entityName, String searchRequestBody)
    • countSearchEntities

      public Long countSearchEntities(String entityName, String searchRequestBody)
    • _loadEntitiesList

      protected String _loadEntitiesList(String queryString, @Nullable String viewName, @Nullable Integer limit, @Nullable Integer offset, @Nullable String sort, @Nullable Boolean returnNulls, @Nullable Boolean dynamicAttributes, @Nullable String modelVersion, MetaClass metaClass, Map<String,Object> queryParameters)
    • addOrderBy

      protected String addOrderBy(String queryString, @Nullable String sort, MetaClass metaClass)
    • getEntityPropertySortExpression

      protected List<String> getEntityPropertySortExpression(MetaPropertyPath metaPropertyPath)
    • createEntity

      public ResponseInfo createEntity(String entityJson, String entityName, String responseView, String modelVersion, javax.servlet.http.HttpServletRequest request)
    • createResponseInfoEntity

      protected ResponseInfo createResponseInfoEntity(javax.servlet.http.HttpServletRequest request, String entityJson, String entityName, String responseView, String modelVersion)
    • createResponseInfoEntities

      protected ResponseInfo createResponseInfoEntities(javax.servlet.http.HttpServletRequest request, String entitiesJson, String entityName, String responseView, String modelVersion)
    • validateEntities

      protected void validateEntities(Collection<Object> rootEntities, Collection<Object> entities)
      Validates entities using EntitiesControllerManager.ValidatedList. If validate the collection of entities using the "n validation for n objects" approach we can not handle the information about which entity failed validation. To achieve that we collect the root entities (what entities should be saved, except composition references, etc) and validate the EntitiesControllerManager.ValidatedList with list of root entities. Also if the root object has the reference entity annotated as Valid we should exclude that entity from the validation.
      Parameters:
      rootEntities - collection of main entity
      entities - collection of entities to validate
    • createEntityFromJson

      protected Object createEntityFromJson(MetaClass metaClass, String entityJson)
    • createEntitiesFromJson

      protected List<Object> createEntitiesFromJson(MetaClass metaClass, com.google.gson.JsonArray entitiesJsonArray)
    • updateEntity

      public ResponseInfo updateEntity(String entityJson, String entityName, String entityId, String responseView, String modelVersion)
    • updateEntities

      public ResponseInfo updateEntities(String entitiesJson, String entityName, String responseView, String modelVersion)
    • getUpdatedEntities

      protected Collection<Object> getUpdatedEntities(String entityName, String modelVersion, String transformedEntityName, MetaClass metaClass, com.google.gson.JsonArray entitiesJsonArray)
    • getUpdatedEntity

      protected Object getUpdatedEntity(String entityName, String modelVersion, String transformedEntityName, MetaClass metaClass, String entityJson, String entityId)
    • deleteEntity

      public void deleteEntity(String entityName, String entityId, String modelVersion)
    • deleteEntities

      public void deleteEntities(String entityName, String entitiesIdJson, String modelVersion)
    • checkEntityIsNotNull

      protected void checkEntityIsNotNull(String entityName, String entityId, Object entity)
    • checkCanReadEntity

      protected void checkCanReadEntity(MetaClass metaClass)
    • checkCanCreateEntity

      protected void checkCanCreateEntity(MetaClass metaClass)
    • checkCanDeleteEntity

      protected void checkCanDeleteEntity(MetaClass metaClass)
    • checkCanUpdateEntity

      protected void checkCanUpdateEntity(MetaClass metaClass)
    • applyEntityConstraints

      protected CrudEntityContext applyEntityConstraints(MetaClass metaClass)
    • getMainEntity

      @Nullable protected Object getMainEntity(Collection<Object> importedEntities, MetaClass metaClass)
      Finds entity with given metaClass.
    • createEntityJson

      protected String createEntityJson(Object entity, MetaClass metaClass, String responseView, String version)
      We pass the EntitySerializationOption.DO_NOT_SERIALIZE_RO_NON_PERSISTENT_PROPERTIES because for create and update operations in the result JSON we don't want to return results for entity methods annotated with @MetaProperty annotation. We do this because such methods may use other entities properties (references to other entities) and as a result we get an UnfetchedAttributeException while producing the JSON for response
    • createEntitiesJson

      protected String createEntitiesJson(Collection<Object> entities, MetaClass metaClass, String responseView, String version)
    • findOrCreateResponseView

      protected FetchPlan findOrCreateResponseView(MetaClass metaClass, String responseView)