Package io.jmix.rest.impl.service
Class EntitiesControllerManager
java.lang.Object
io.jmix.rest.impl.service.EntitiesControllerManager
Class that executes business logic required by the
EntitiesController
. It
performs CRUD operations with entities-
Nested Class Summary
Modifier and TypeClassDescriptionprotected class
protected static class
-
Field Summary
Modifier and TypeFieldDescriptionprotected AccessManager
protected DataManager
protected EntityImportExport
protected EntityImportPlanJsonBuilder
protected EntitySerialization
protected EntityStates
protected FetchPlanRepository
protected FetchPlans
protected Metadata
protected MetadataTools
protected List<QueryStringProcessor>
protected RestControllerUtils
protected RestFilterParser
protected RestProperties
protected jakarta.validation.Validator
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected String
addOrderBy
(String queryString, String sort, MetaClass metaClass) protected CrudEntityContext
applyEntityConstraints
(MetaClass metaClass) protected void
checkCanCreateEntity
(MetaClass metaClass) protected void
checkCanDeleteEntity
(MetaClass metaClass) protected void
checkCanReadEntity
(MetaClass metaClass) protected void
checkCanUpdateEntity
(MetaClass metaClass) protected void
checkEntityIsNotNull
(String entityName, String entityId, Object entity) protected long
countEntities
(MetaClass metaClass, Condition jmixCondition) countSearchEntities
(String entityName, String searchRequestBody) countSearchEntities
(String entityName, String filterJson, String modelVersion) createEntitiesFromJson
(MetaClass metaClass, com.google.gson.JsonArray entitiesJsonArray) protected String
createEntitiesJson
(Collection<Object> entities, MetaClass metaClass, String responseView, String version) createEntity
(String entityJson, String entityName, String responseView, String modelVersion, jakarta.servlet.http.HttpServletRequest request) protected Object
createEntityFromJson
(MetaClass metaClass, String entityJson) 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.protected ResponseInfo
createResponseInfoEntities
(jakarta.servlet.http.HttpServletRequest request, String entitiesJson, String entityName, String responseView, String modelVersion) protected ResponseInfo
createResponseInfoEntity
(jakarta.servlet.http.HttpServletRequest request, String entityJson, String entityName, String responseView, String modelVersion) protected String
createSimpleSelect
(MetaClass metaClass) void
deleteEntities
(String entityName, String entitiesIdJson, String modelVersion) void
deleteEntity
(String entityName, String entityId, String modelVersion) protected FetchPlan
findOrCreateResponseView
(MetaClass metaClass, String responseView) getEntityPropertySortExpression
(MetaPropertyPath metaPropertyPath) protected Object
getMainEntity
(Collection<Object> importedEntities, MetaClass metaClass) Finds entity with given metaClass.protected Collection<Object>
getUpdatedEntities
(String entityName, String modelVersion, String transformedEntityName, MetaClass metaClass, com.google.gson.JsonArray entitiesJsonArray) protected Object
getUpdatedEntity
(String entityName, String modelVersion, String transformedEntityName, MetaClass metaClass, String entityJson, String entityId) protected String
loadEntitiesJson
(Condition condition, String viewName, Integer limit, Integer offset, String sort, Boolean returnNulls, Boolean dynamicAttributes, String modelVersion, MetaClass metaClass) loadEntitiesList
(String entityName, String viewName, Integer limit, Integer offset, String sort, Boolean returnNulls, Boolean returnCount, Boolean dynamicAttributes, String modelVersion) loadEntity
(String entityName, String entityId, String viewName, Boolean returnNulls, Boolean dynamicAttributes, String modelVersion) searchEntities
(String entityName, String searchRequestBody) searchEntities
(String entityName, String filterJson, String viewName, Integer limit, Integer offset, String sort, Boolean returnNulls, Boolean returnCount, Boolean dynamicAttributes, String modelVersion) updateEntities
(String entitiesJson, String entityName, String responseView, String modelVersion) updateEntity
(String entityJson, String entityName, String entityId, String responseView, String modelVersion) protected void
validateEntities
(Collection<Object> rootEntities, Collection<Object> entities) Validates entities usingEntitiesControllerManager.ValidatedList
.
-
Field Details
-
dataManager
-
metadata
-
entitySerialization
-
entityImportPlanJsonBuilder
-
entityImportExport
-
accessManager
-
restControllerUtils
-
restFilterParser
-
restProperties
-
entityStates
-
fetchPlanRepository
-
metadataTools
-
fetchPlans
-
validator
@Autowired protected jakarta.validation.Validator validator -
queryStringProcessors
-
-
Constructor Details
-
EntitiesControllerManager
public EntitiesControllerManager()
-
-
Method Details
-
loadEntity
-
loadEntitiesList
-
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
-
createSimpleSelect
-
countSearchEntities
-
searchEntities
-
countSearchEntities
-
loadEntitiesJson
-
addOrderBy
-
getEntityPropertySortExpression
-
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
Validates entities usingEntitiesControllerManager.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 theEntitiesControllerManager.ValidatedList
with list of root entities. Also if the root object has the reference entity annotated asValid
we should exclude that entity from the validation.- Parameters:
rootEntities
- collection of main entityentities
- collection of entities to validate
-
createEntityFromJson
-
createEntitiesFromJson
-
updateEntity
-
updateEntities
public ResponseInfo updateEntities(String entitiesJson, String entityName, String responseView, String modelVersion) -
getUpdatedEntities
-
getUpdatedEntity
-
deleteEntity
-
deleteEntities
-
checkEntityIsNotNull
-
checkCanReadEntity
-
checkCanCreateEntity
-
checkCanDeleteEntity
-
checkCanUpdateEntity
-
applyEntityConstraints
-
getMainEntity
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
-
findOrCreateResponseView
-