How to create custom methods for my entities - OrienteerBAP/Orienteer GitHub Wiki

There are multiple OOB generic methods to work with objects: Create, Edit, Delete, Select, Release and etc. But Orienteer has possibility to create custom methods for documents/objects of a specific class. For example, you can have button Invite on entity UserInvitation or Run on IntegrationConfiguration and etc.

There are 2 ways to do that:

Defining just your own Command with OMethod annotation

@OMethod(order=2,filters={
		@OFilter(fClass = PlaceFilter.class, fData = "DASHBOARD_SETTINGS"),
})
public class UnhideWidgetCommand<T> extends AbstractModalWindowCommand<ODocument> {
	private static final long serialVersionUID = 1L;
	
	public UnhideWidgetCommand(String id, IModel<ODocument> dashboardDocumentModel) {
		super(id, "command.unhide", dashboardDocumentModel);
		setIcon(FAIconType.plus);
	}

	@Override
	protected void initializeContent(final ModalWindow modal) {
		modal.setTitle(new ResourceModel("command.unhide"));
		modal.setContent(new UnhideWidgetDialog<T>(modal.getContentId()) {
			private static final long serialVersionUID = 1L;

			@Override
			protected void onSelectWidget(AbstractWidget<T> widget,
					Optional<AjaxRequestTarget> targetOptional) {
				targetOptional.ifPresent(modal::close);
				widget.setHidden(false);
				DashboardPanel<T> dashboard = getDashboardPanel();
				targetOptional.ifPresent(target -> dashboard.getDashboardSupport().ajaxAddWidget(widget, target));
			}
		});
		modal.setAutoSize(true);
		modal.setMinimalWidth(300);
	}

}

Defining your own IMethod

You can define your own class IMethod:

@OMethod(
        titleKey = "command.crm.new.contact",
        icon = FAIconType.plus,
        bootstrap = BootstrapType.PRIMARY,
        order = 20,
        filters = {
                @OFilter(fClass = ODocumentFilter.class, fData = OfferAIUserContact.CLASS_NAME),
                @OFilter(fClass = PlaceFilter.class, fData = "STRUCTURE_TABLE"),
                @OFilter(fClass = OrienteerUIFilter.class, fData = "ORIENTEER"),
                @OFilter(fClass = ORoleFilter.class, fData = OfferAIUsersModule.ROLE_BUYER_AGENT),
        }
)
public class NewContactMethod extends AbstractOMethod {
    @Override
    public Command<?> createCommand(String id) {
        return new AjaxFormCommand<Object>(id, getTitleModel()) {

            @Override
            protected void onInstantiation() {
                super.onInstantiation();
                applyVisualSettings(this);
            }

            @Override
            public void onSubmit(AjaxRequestTarget target) {
                throw new RedirectToUrlException("/browse/" + OfferAIUserContact.CLASS_NAME);
            }
        };
    }
}
⚠️ **GitHub.com Fallback** ⚠️