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
Nested ClassesModifier and TypeClassDescriptionprotected classprotected static class -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected AccessManagerprotected DataManagerprotected EntityImportExportprotected EntityImportPlanJsonBuilderprotected EntitySerializationprotected EntityStatesprotected FetchPlanRepositoryprotected FetchPlansprotected Metadataprotected MetadataToolsprotected List<QueryStringProcessor>protected RestControllerUtilsprotected RestFilterParserprotected RestPropertiesprotected jakarta.validation.Validator -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected StringaddOrderBy(String queryString, String sort, MetaClass metaClass) protected CrudEntityContextapplyEntityConstraints(MetaClass metaClass) protected voidcheckCanCreateEntity(MetaClass metaClass) protected voidcheckCanDeleteEntity(MetaClass metaClass) protected voidcheckCanReadEntity(MetaClass metaClass) protected voidcheckCanUpdateEntity(MetaClass metaClass) protected voidcheckEntityIsNotNull(String entityName, String entityId, Object entity) protected longcountEntities(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 StringcreateEntitiesJson(Collection<Object> entities, MetaClass metaClass, FetchPlan responseFetchPlan, String version) createEntity(String entityJson, String entityName, String responseFetchPlanNameOrJson, String modelVersion, jakarta.servlet.http.HttpServletRequest request) protected ObjectcreateEntityFromJson(MetaClass metaClass, String entityJson) protected StringcreateEntityJson(Object entity, MetaClass metaClass, FetchPlan responseFetchPlan, 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 FetchPlancreateResponseFetchPlan(MetaClass metaClass) protected ResponseInfocreateResponseInfoEntities(jakarta.servlet.http.HttpServletRequest request, String entitiesJson, String entityName, String responseFetchPlanNameOrJson, String modelVersion) protected ResponseInfocreateResponseInfoEntity(jakarta.servlet.http.HttpServletRequest request, String entityJson, String entityName, String responseFetchPlanNameOrJson, String modelVersion) protected StringcreateSimpleSelect(MetaClass metaClass) voiddeleteEntities(String entityName, String entitiesIdJson, String modelVersion) voiddeleteEntity(String entityName, String entityId, String modelVersion) getEntityPropertySortExpression(MetaPropertyPath metaPropertyPath) protected ObjectgetMainEntity(Collection<Object> importedEntities, MetaClass metaClass) Finds entity with given metaClass.protected MetaClassgetMetaClass(String entityName, String modelVersion) protected Collection<Object>getUpdatedEntities(String entityName, String modelVersion, String transformedEntityName, MetaClass metaClass, com.google.gson.JsonArray entitiesJsonArray) protected ObjectgetUpdatedEntity(String entityName, String modelVersion, String transformedEntityName, MetaClass metaClass, String entityJson, String entityId) protected StringloadEntitiesJson(Condition condition, FetchPlan fetchPlan, Integer limit, Integer offset, String sort, Boolean returnNulls, Boolean dynamicAttributes, String modelVersion, MetaClass metaClass) loadEntitiesList(String entityName, String fetchPlanNameOrJson, Integer limit, Integer offset, String sort, Boolean returnNulls, Boolean returnCount, Boolean dynamicAttributes, String modelVersion) loadEntity(String entityName, String entityId, String fetchPlanNameOrJson, Boolean returnNulls, Boolean dynamicAttributes, String modelVersion) searchEntities(String entityName, String searchRequestBody) searchEntities(String entityName, String filterJson, FetchPlan fetchPlan, Integer limit, Integer offset, String sort, Boolean returnNulls, Boolean returnCount, Boolean dynamicAttributes, String modelVersion) searchEntities(String entityName, String filterJson, String fetchPlanNameOrJson, Integer limit, Integer offset, String sort, Boolean returnNulls, Boolean returnCount, Boolean dynamicAttributes, String modelVersion) updateEntities(String entitiesJson, String entityName, String responseFetchPlanName, String modelVersion) updateEntity(String entityJson, String entityName, String entityId, String responseFetchPlanNameOrJson, String modelVersion) protected voidvalidateEntities(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
public EntitiesSearchResult loadEntitiesList(String entityName, @Nullable String fetchPlanNameOrJson, @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 fetchPlanNameOrJson, @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 FetchPlan fetchPlan, @Nullable Integer limit, @Nullable Integer offset, @Nullable String sort, @Nullable Boolean returnNulls, @Nullable Boolean returnCount, @Nullable Boolean dynamicAttributes, @Nullable String modelVersion) -
getMetaClass
-
countEntities
-
createSimpleSelect
-
countSearchEntities
-
searchEntities
-
countSearchEntities
-
loadEntitiesJson
-
addOrderBy
-
getEntityPropertySortExpression
-
createEntity
public ResponseInfo createEntity(String entityJson, String entityName, String responseFetchPlanNameOrJson, String modelVersion, jakarta.servlet.http.HttpServletRequest request) -
createResponseInfoEntity
protected ResponseInfo createResponseInfoEntity(jakarta.servlet.http.HttpServletRequest request, String entityJson, String entityName, @Nullable String responseFetchPlanNameOrJson, String modelVersion) -
createResponseInfoEntities
protected ResponseInfo createResponseInfoEntities(jakarta.servlet.http.HttpServletRequest request, String entitiesJson, String entityName, String responseFetchPlanNameOrJson, 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.ValidatedListwith list of root entities. Also if the root object has the reference entity annotated asValidwe 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 responseFetchPlanName, 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, @Nullable FetchPlan responseFetchPlan, 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
-
createResponseFetchPlan
-