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

  • 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)
    • countEntities

      protected long countEntities(MetaClass metaClass, Condition jmixCondition)
    • createSimpleSelect

      @Nullable protected String createSimpleSelect(MetaClass metaClass)
    • 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)
    • loadEntitiesJson

      protected String loadEntitiesJson(Condition condition, @Nullable String viewName, @Nullable Integer limit, @Nullable Integer offset, @Nullable String sort, @Nullable Boolean returnNulls, @Nullable Boolean dynamicAttributes, @Nullable String modelVersion, MetaClass metaClass)
    • 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, jakarta.servlet.http.HttpServletRequest request)
    • createResponseInfoEntity

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

      protected ResponseInfo createResponseInfoEntities(jakarta.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)