The pattern we suggest is two domain services, one being a repository for
an entity - ie QuickObjectRepository - and the other a menu - ie
QuickObjectMenu.  Not every entity will need a menu, and indeed it might
make sense to have menus that provide access to multiple entities, eg a
"Reference Data" or "Admin" menu.  In other words, the *Menu services are
really just to organize the UI, while the *Repository services do the real
work.

In this case, if you don't need a menu then just delete QuickObjectsMenu.
It doesn't have any behaviour other than delegating to
QuickObjectRepository.

You are correct that setting the nature=DOMAIN should suppress it from the
UI also; if that isn't the case, then please create a test example
application demonstrating the problem and push it to github.

HTH
Dan

On Wed, 15 Feb 2017 at 14:54 L Eder <[email protected]> wrote:

> The code. Actually it is the one at quickstart sample:
>
> QuickObjectRepository:
> "
> @DomainService(
>         nature = NatureOfService.DOMAIN,
>         repositoryFor = QuickObject.class
> )
> public class QuickObjectRepository {
>
>     //region > listAll (programmatic)
>
>     @Programmatic
>     public List<QuickObject> listAll() {
>         return container.allInstances(QuickObject.class);
>     }
>     //endregion
>
>     //region > findByName (programmatic)
>
>     @Programmatic
>     public QuickObject findByName(
>             final String name
>     ) {
>         return container.uniqueMatch(
>                 new QueryDefault<>(
>                         QuickObject.class,
>                         "findByName",
>                         "name", name));
>     }
>     //endregion
>
>     //region > findByNameContains (programmatic)
>
>     @Programmatic
>     public List<QuickObject> findByNameContains(
>             final String name
>     ) {
>         return container.allMatches(
>                 new QueryDefault<>(
>                         QuickObject.class,
>                         "findByNameContains",
>                         "name", name));
>     }
>     //endregion
>
>     //region > create (programmatic)
>
>     @Programmatic
>     public QuickObject create(final String name) {
>         final QuickObject obj =
> container.newTransientInstance(QuickObject.class);
>         obj.setName(name);
>         container.persistIfNotAlready(obj);
>         return obj;
>     }
>
>     //endregion
>
>     //region > findOrCreate (programmatic)
>
>     @Programmatic
>     public QuickObject findOrCreate(
>             final String name
>     ) {
>         QuickObject quickObject = findByName(name);
>         if(quickObject == null) {
>             quickObject = create(name);
>         }
>         return quickObject;
>     }
>     //endregion
>
>
>     //region > injected services
>
>     @javax.inject.Inject
>     DomainObjectContainer container;
>
>     //endregion
> }
> "
>
> QuickObjectMenu:
> "
> @DomainService(
>          nature = NatureOfService.VIEW_MENU_ONLY
>   //      nature = NatureOfService.DOMAIN
> )
> @DomainServiceLayout(
>         menuOrder = "700",
>         named = "Quick Objects"
> )
> public class QuickObjectMenu {
>
>     //region > listAll (action)
>     @Action(
>             semantics = SemanticsOf.SAFE
>     )
>     @ActionLayout(
>             bookmarking = BookmarkPolicy.AS_ROOT
>     )
>     @MemberOrder(sequence = "1")
>     public List<QuickObject> listAll() {
>         return quickObjectRepository.listAll();
>     }
>     //endregion
>
>     //region > findByName (action)
>     @Action(
>             semantics = SemanticsOf.SAFE
>     )
>     @ActionLayout(
>             bookmarking = BookmarkPolicy.AS_ROOT
>     )
>     @MemberOrder(sequence = "2")
>     public List<QuickObject> findByName(
>             @ParameterLayout(named="Name")
>             final String name
>     ) {
>         return quickObjectRepository.findByNameContains(name);
>     }
>     //endregion
>
>     //region > create (action)
>     public static class CreateDomainEvent extends
> ActionDomainEvent<QuickObjectMenu> { }
>
>     @Action(
>             domainEvent = CreateDomainEvent.class
>     )
>     @MemberOrder(sequence = "3")
>     public QuickObject create(
>             @ParameterLayout(named="Name")
>             final String name) {
>         return quickObjectRepository.create(name);
>     }
>
>     //endregion
>
>     //region > injected services
>
>     @javax.inject.Inject
>     QuickObjectRepository quickObjectRepository;
>
>     //endregion
> }
> "
>
>
>
> 2017-02-15 10:35 GMT-04:00, Dan Haywood <[email protected]>:
> > Should be easy ... can you post the code of the domain service that is
> > appearing as a menu that you want to suppress ?
> >
> >
> > On Wed, 15 Feb 2017 at 14:23 L Eder <[email protected]> wrote:
> >
> >> Hi Dan:
> >>
> >> I browsed the documentation for a way to hide a menu object but
> >> properties and actions. The closest thing found was @NotInServiceMenu.
> >> I tried some combinations, even using the NatureOfService enum, but no
> >> success so far.
> >>
> >> Idea is to omit, eg, prevent QuickObjects entity from being rendered
> >> in the menu bar.
> >>
> >> Thanks for you suggestion, Eder
> >>
> >
>

Reply via email to