Class BaseCrudEntityService<P>

    • Method Detail

      • setSortPositionStrategy

        @Autowired
        public void setSortPositionStrategy​(@Nullable
                                            SortPositionStrategy<P> sortPositionStrategy)
      • readByContextId

        public P readByContextId​(@NonNull
                                 String id,
                                 @Nullable
                                 ContextInfo context)
        Description copied from interface: CrudEntityService
        Read a single instance of an entity in the form of a business domain.
        Specified by:
        readByContextId in interface CrudEntityService<P>
        Parameters:
        id - The context id for the entity. This is the id by which the business recognizes the item.
        context - Context information used to discriminate the correct version of an entity by context id when multiple verions may be available across sandboxes, catalogs and applications.
        Returns:
        The narrowed entity instance in the form of a business instance
      • readAllByContextId

        public Iterable<P> readAllByContextId​(@NonNull
                                              Iterable<String> ids,
                                              @Nullable
                                              ContextInfo context)
        Description copied from interface: CrudEntityService
        Retrieve all business instances based on a list of context ids.
        Specified by:
        readAllByContextId in interface CrudEntityService<P>
        Parameters:
        ids - A list of context ids for the entitys. This is the id by which the business recognizes the item.
        context - Context information used to discriminate the correct version of an entity by context id when multiple verions may be available across sandboxes, catalogs and applications.
        Returns:
        The narrowed iterable collection of data in the form of business instances
      • readAll

        public org.springframework.data.domain.Page<P> readAll​(@NonNull
                                                               org.springframework.data.domain.Pageable pageable,
                                                               @Nullable
                                                               ContextInfo context)
        Description copied from interface: CrudEntityService
        Read a page of narrowed instances in the form of the business instance.
        Specified by:
        readAll in interface CrudEntityService<P>
        Parameters:
        pageable - The current page information
        context - Context information used to discriminate the correct version of an entity by context id when multiple verions may be available across sandboxes, catalogs and applications.
        Returns:
        The narrowed page of data in the form of business instances
      • readAll

        public List<P> readAll​(@Nullable
                               ContextInfo context)
        Description copied from interface: CrudEntityService
        Read a list of narrowed instances in the form of the business instance.
        Specified by:
        readAll in interface CrudEntityService<P>
        Parameters:
        context - Context information used to discriminate the correct version of an entity by context id when multiple verions may be available across sandboxes, catalogs and applications.
        Returns:
        The narrowed list of data in the form of business instances
      • readAll

        public List<P> readAll​(@NonNull
                               org.springframework.data.domain.Sort sort,
                               @Nullable
                               ContextInfo context)
        Description copied from interface: CrudEntityService
        Read a list of narrowed instances in the form of the business instance. Also apply the given sort.
        Specified by:
        readAll in interface CrudEntityService<P>
        Parameters:
        sort - The sort to be performed on the results
        context - Context information used to discriminate the correct version of an entity by context id when multiple verions may be available across sandboxes, catalogs and applications.
        Returns:
        The narrowed list of sorted data in the form of business instances
      • update

        public P update​(@NonNull
                        String id,
                        @NonNull
                        P businessInstance,
                        @Nullable
                        ContextInfo context)
        Description copied from interface: CrudEntityService
        Update a single, narrowed instance of an entity based on a business instance containing relevant property values. See TrackableRepository for more information on entity persistence behavior in light of sandboxing and multitenant concerns.
        Specified by:
        update in interface CrudEntityService<P>
        Parameters:
        id - The context id for the entity. This is the id by which the business recognizes the item.
        businessInstance - The payload type that domain class should be converted to. In general, the payload is what the rest API responds with.
        context - Context information used to discriminate the correct version of an entity by context id when multiple verions may be available across sandboxes, catalogs and applications.
        Returns:
        The updated, narrowed entity instance in the form of a payload instance, or EntityMissingException if not available.
        See Also:
        CrudEntityService.updateAll(List, ContextInfo), CrudEntityService.updateAllAllowingPartialSuccess(List, ContextInfo)
      • updateAllAllowingPartialSuccess

        public BulkPersistenceResponse<P> updateAllAllowingPartialSuccess​(List<Update<P>> updates,
                                                                          ContextInfo context)
        Description copied from interface: CrudEntityService
        Updates all of the items managed by the backing repository in the form of the business instances containing property values.

        Each item contained within updates must exist in the backing repository and pass validation, or it will be added to the failed list in the response and not persisted. All successfully found and validated items will be persisted.

        For an alternative that does not allow partial success, see CrudEntityService.updateAll(List, ContextInfo).

        Specified by:
        updateAllAllowingPartialSuccess in interface CrudEntityService<P>
        Parameters:
        updates - each update to the repository domain
        context - Context information used to discriminate the correct version of an entity by context id when multiple verions may be available across sandboxes, catalogs and applications.
        Returns:
        a response containing a list of any entities which failed, and a list of the successfully updated, narrowed entity instances in the form of a payload instance
        See Also:
        CrudEntityService.updateAll(List, ContextInfo)
      • updateSort

        public P updateSort​(@NonNull
                            SortPositionRequest sortPositionRequest,
                            @Nullable
                            ContextInfo context)
        Description copied from interface: CrudEntityService
        Apply a sort field value change
        Specified by:
        updateSort in interface CrudEntityService<P>
        Parameters:
        sortPositionRequest - Information about the item being moved and the position to which it's moving
        context - ontext information used to discriminate the correct version of an entity by context id when multiple verions may be available across sandboxes, catalogs and applications.
        Returns:
        The updated business domain
      • replace

        public P replace​(@NonNull
                         String id,
                         @NonNull
                         P businessInstance,
                         @Nullable
                         ContextInfo context)
        Description copied from interface: CrudEntityService
        Replace a single, narrowed instance of an entity based on a business instance containing relevant property values.
        Specified by:
        replace in interface CrudEntityService<P>
        Parameters:
        id - The context id for the entity. This is the id by which the business recognizes the item.
        businessInstance - The payload type that domain class should be converted to. In general, the payload is what the rest API responds with.
        context - Context information used to discriminate the correct version of an entity by context id when multiple verions may be available across sandboxes, catalogs and applications.
        Returns:
        The replaced, narrowed entity instance in the form of a payload instance, or EntityMissingException if not available.
        See Also:
        CrudEntityService.replaceAll(List, ContextInfo), CrudEntityService.replaceAllAllowingPartialSuccess(List, ContextInfo)
      • replaceAllAllowingPartialSuccess

        public BulkPersistenceResponse<P> replaceAllAllowingPartialSuccess​(List<Update<P>> replacements,
                                                                           ContextInfo context)
        Description copied from interface: CrudEntityService
        Replace multiple narrowed instances of an entity at once based on the business instances containing relevant property values.

        Each item contained within replacements must exist in the backing repository and pass validation, or it will be added to the failed list in the response and not persisted. All successfully found and validated items will be persisted.

        See CrudEntityService.replaceAll(List, ContextInfo) for an alternative that does not allow partial success.

        Specified by:
        replaceAllAllowingPartialSuccess in interface CrudEntityService<P>
        Parameters:
        replacements - all replacements to the repository domain
        context - Context information used to discriminate the correct version of an entity by context id when multiple verions may be available across sandboxes, catalogs and applications.
        Returns:
        a response containing a list of any entities which failed, and a list of the successfully replaced, narrowed entity instances in the form of a payload instance
        See Also:
        CrudEntityService.replaceAll(List, ContextInfo)
      • createAllAllowingPartialSuccess

        public BulkPersistenceResponse<P> createAllAllowingPartialSuccess​(List<P> businessInstances,
                                                                          ContextInfo context)
        Description copied from interface: CrudEntityService
        Creates multiple narrowed instances of an entity at once based on the business instances containing relevant property values.

        Each item contained within businessInstances will be validated, and if it fails validation, it will be added to the failed list in the response and not persisted. All successfully validated items will be persisted.

        See CrudEntityService.createAll(List, ContextInfo) for an alternative that does not allow partial success.

        Specified by:
        createAllAllowingPartialSuccess in interface CrudEntityService<P>
        Parameters:
        businessInstances - all instances to create in the data store
        context - Context information used to discriminate the correct version of an entity by context id when multiple versions may be available across sandboxes, catalogs and applications.
        Returns:
        a response containing a list of any entities which failed, and a list of the successfully created, narrowed entity instances in the form of a payload instance
        See Also:
        CrudEntityService.createAll(List, ContextInfo)
      • delete

        public void delete​(@NonNull
                           String id,
                           @Nullable
                           ContextInfo context)
        Description copied from interface: CrudEntityService
        Perform a delete operation on the entity identified by the context id. This could result in an archival, or a raw delete, depending on the result of processing through DomainMapper.deleteMap(Object, ContextInfo).
        Specified by:
        delete in interface CrudEntityService<P>
        Parameters:
        id - The context id for the entity. This is the id by which the business recognizes the item.
        context - Context information used to discriminate the correct version of an entity by context id when multiple verions may be available across sandboxes, catalogs and applications.
      • convertFromPersistentDomain

        protected P convertFromPersistentDomain​(Trackable domain,
                                                ContextInfo contextInfo)