@Override public boolean isSupportedMethod(IMethodContext dataObject) { return (dataObject.getCurrentWidget()==null && dataObject.getDisplayObjectModel()==null && "testData".equals(filterData) ); }
@Override public boolean isSupportedMethod(IMethodContext dataObject) { if (filterData!=null && dataObject.getCurrentWidgetType()!=null){ return dataObject.getCurrentWidgetType().matches(filterData); } return false; }
@OMethod( order = 20,bootstrap=BootstrapType.WARNING,icon = FAIconType.pause, filters={ @OFilter(fClass = PlaceFilter.class, fData = "STRUCTURE_TABLE"), @OFilter(fClass = WidgetTypeFilter.class, fData = "parameters"), }, behaviors={OIntegrationConfigStopBehavior.class} ) public void suspend(IMethodContext data){ final CamelContext context = getOrMakeContext(data.getCurrentWidget()); new Thread(new Runnable() { @Override public void run() { try { ServiceStatus status = context.getStatus(); if (status.isSuspended()){ context.start(); }else if(status.isStarted()){ context.suspend(); } } catch (Exception e) { LOG.error("Cannot start or suspend Camel Context",e); } } }).start(); waitingRefresh(context); } /////////////////////////////////////////////////////////////////////////////////////////////////////
private OClass getOClass(IMethodContext dataObject){ if (dataObject.getDisplayObjectModel()!=null){ Object obj = dataObject.getDisplayObjectModel().getObject(); if (obj instanceof OClass){ return (OClass) obj; }else if (obj instanceof ODocument){ return ((ODocument)obj).getSchemaClass(); } } return null; } }
public Command<?> createCommand(String id) { if (displayComponent == null && getContext().getRelatedComponent()!=null && getContext().getRelatedComponent() instanceof OrienteerDataTable){ String titleKey = getConfig().getTitleKey(); if (titleKey.isEmpty()){ titleKey = getConfig().getMethodId(); OrienteerDataTable<ODocument, ?> table=(OrienteerDataTable<ODocument, ?>) getContext().getRelatedComponent(); displayComponent = new AbstractCheckBoxEnabledCommand<ODocument>(getTitleModel(),table){ private static final long serialVersionUID = 1L;
@OMethod( order = 30,bootstrap=BootstrapType.DANGER,icon = FAIconType.stop, filters={@OFilter(fClass = PlaceFilter.class, fData = "STRUCTURE_TABLE"), @OFilter(fClass = WidgetTypeFilter.class, fData = "parameters"), }, behaviors={OIntegrationConfigStopBehavior.class} ) public void stop(IMethodContext data){ CamelContext context = getOrMakeContextByRid(getDocument().getIdentity().toString(),data.getCurrentWidget()); try { context.stop(); } catch (Exception e) { LOG.error("Cannot stop Camel Context",e); } waitingRefresh(context); } /////////////////////////////////////////////////////////////////////////////////////////////////////
@Override public boolean isSupportedMethod(IMethodContext dataObject) { IModel<?> model = dataObject.getDisplayObjectModel(); if (model!=null && model.getObject()!=null && model.getObject() instanceof OClass){ return ((OClass) (model.getObject())).isSubClassOf(this.filterData); } return false; } }
final CamelContext context = getOrMakeContextByRid(getDocument().getIdentity().toString(),data.getCurrentWidget()); new Thread(new Runnable() { @Override
@Override public Command<?> getWrappedCommand(String id) { try { Constructor<?> c = javaClass.getConstructor(String.class, IModel.class); return (Command<?>) c.newInstance(id, getContext().getDisplayObjectModel()); } catch (Exception e) { LOG.error("Can't create a command", e); return null; } } };
@Override public IMethod getMethod(IMethodContext dataObject) { try { IMethod newMethod=null; if(MethodPlace.DATA_TABLE.equals(dataObject.getPlace())){ newMethod = getTableIMethodClass().newInstance(); }else{ newMethod = getIMethodClass().newInstance(); } if (newMethod!=null){ newMethod.init(this, dataObject); return newMethod; } } catch (InstantiationException | IllegalAccessException e) { LOG.error("Can't obtain a method", e); } return null; }
@OMethod( icon = FAIconType.stop, bootstrap=BootstrapType.DANGER, filters={@OFilter(fClass = PlaceFilter.class, fData = "STRUCTURE_TABLE"), @OFilter(fClass = WidgetTypeFilter.class, fData = "parameters"), }, behaviors={OTaskSessionInterruptBehavior.class} ) public void interrupt( IMethodContext data){ try { interrupt(); } catch (Exception e) { AbstractWidget<?> widget = data.getCurrentWidget(); if(widget!=null) { widget.error(widget.getLocalizer().getString("errors.session.cantinterupt", widget, Model.of(e.getMessage()))); } LOG.error("Can't interrupt the session", e); } } ///////////////////////////////////////////////////////////////////////
protected IModel<?> getObjectModelForUrlMapping() { return getContext().getDisplayObjectModel(); }
@OMethod( order=10,bootstrap=BootstrapType.SUCCESS,icon = FAIconType.play, permission="EXECUTE", filters={ @OFilter(fClass = PlaceFilter.class, fData = "STRUCTURE_TABLE"), @OFilter(fClass = WidgetTypeFilter.class, fData = "parameters"), // @OFilter(fClass = PlaceFilter.class, fData = "STRUCTURE_TABLE|DATA_TABLE"), } ) public void run(IMethodContext data){ OTaskSessionRuntime newSession = startNewSession(); AbstractWidgetDisplayModeAwarePage<ODocument> page = new ODocumentPage(new ODocumentModel(newSession.getOTaskSessionPersisted().getDocument())).setModeObject(DisplayMode.VIEW); data.getCurrentWidget().setResponsePage(page); }
@Override public void invokeLinkedFunction(IMethodContext dataObject,ODocument doc) { try { Constructor<?> constructor=null; try { constructor = javaClass.getConstructor(ODocument.class); } catch (NoSuchMethodException e1) { // TODO it is correct catch block with muffling } Method javaMethod = javaClass.getMethod(javaMethodName, IMethodContext.class); Object inputDoc = doc!=null?doc:dataObject.getDisplayObjectModel().getObject(); if (constructor!=null && inputDoc instanceof ODocument){ Object newInstance = constructor.newInstance(inputDoc); javaMethod.invoke(newInstance,dataObject); }else{ javaMethod.invoke(null,dataObject); } } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException | SecurityException | InstantiationException e) { LOG.error("Error during method invokation", e); } }
@Override public boolean isSupportedMethod(IMethodContext dataObject) { IModel<?> model = dataObject.getDisplayObjectModel(); if (model!=null && model.getObject()!=null && model.getObject() instanceof ODocument){ return ((ODocument) (model.getObject())).getSchemaClass().isSubClassOf(this.filterData); } return false; }
@Override public boolean isSupportedMethod(IMethodContext dataObject) { if (orientPermission!=null){ Object obj = dataObject.getDisplayObjectModel().getObject(); if(obj instanceof ODocument){ return OSecurityHelper.isAllowed((ODocument)obj, orientPermission); }else if(obj instanceof OClass){ return OSecurityHelper.isAllowed((OClass)obj, orientPermission); } } return true; } }
@SuppressWarnings("unchecked") @Override public Command<?> createCommand(String id) { if (displayComponent==null){ IModel<Object> model = (IModel<Object>) getContext().getDisplayObjectModel(); displayComponent = new AjaxCommand<Object>(id, getTitleModel(),model) { private static final long serialVersionUID = 1L; @Override protected void onInitialize() { super.onInitialize(); applyVisualSettings(this); } @Override public void onClick(Optional<AjaxRequestTarget> target) { invoke(); } }; applyBehaviors(displayComponent); } return displayComponent; } }
@SuppressWarnings("unchecked") @Override public Command<?> createCommand(String id) { if (displayComponent==null){ IModel<Object> model = (IModel<Object>) getContext().getDisplayObjectModel(); displayComponent = new AbstractModalWindowCommand<Object>(id, getTitleModel(),model) { private static final long serialVersionUID = 1L; @Override protected void onInitialize() { super.onInitialize(); applyVisualSettings(this); } @Override protected void initializeContent(ModalWindow modal) { modal.setTitle(getTitleModel()); modal.setContent(getModalContent(modal.getContentId(),modal,this)); } @Override public void onAfterModalSubmit() { sendActionPerformed(); } }; applyBehaviors(displayComponent); } return displayComponent; }