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 RestControllerUtilsprotected RestFilterParserprotected RestPropertiesprotected javax.validation.Validator -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected String_loadEntitiesList(String queryString, String viewName, Integer limit, Integer offset, String sort, Boolean returnNulls, Boolean dynamicAttributes, String modelVersion, MetaClass metaClass, Map<String, Object> queryParameters) protected 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) 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, String responseView, String version) createEntity(String entityJson, String entityName, String responseView, String modelVersion, javax.servlet.http.HttpServletRequest request) protected ObjectcreateEntityFromJson(MetaClass metaClass, String entityJson) protected StringcreateEntityJson(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 ResponseInfocreateResponseInfoEntities(javax.servlet.http.HttpServletRequest request, String entitiesJson, String entityName, String responseView, String modelVersion) protected ResponseInfocreateResponseInfoEntity(javax.servlet.http.HttpServletRequest request, String entityJson, String entityName, String responseView, String modelVersion) voiddeleteEntities(String entityName, String entitiesIdJson, String modelVersion) voiddeleteEntity(String entityName, String entityId, String modelVersion) protected FetchPlanfindOrCreateResponseView(MetaClass metaClass, String responseView) getEntityPropertySortExpression(MetaPropertyPath metaPropertyPath) protected ObjectgetMainEntity(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 ObjectgetUpdatedEntity(String entityName, String modelVersion, String transformedEntityName, MetaClass metaClass, String entityJson, String entityId) 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 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 javax.validation.Validator validator
-
-
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) -
countSearchEntities
-
searchEntities
-
countSearchEntities
-
_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
-
getEntityPropertySortExpression
-
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
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 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
-