Search in sources :

Example 1 with WSRoutingRuleItem

use of org.talend.mdm.repository.model.mdmproperties.WSRoutingRuleItem in project tmdm-studio-se by Talend.

the class NewTriggerAction method createServerObject.

@Override
protected Item createServerObject(String key) {
    WSRoutingRuleItem item = MdmpropertiesFactory.eINSTANCE.createWSRoutingRuleItem();
    ItemState itemState = PropertiesFactory.eINSTANCE.createItemState();
    item.setState(itemState);
    WSRoutingRuleE routingRule = newRoutingRule(key);
    item.setWsRoutingRule(routingRule);
    if (parentItem != null) {
        item.getState().setPath(parentItem.getState().getPath());
        RepositoryResourceUtil.createItem(item, key);
    }
    return item;
}
Also used : ItemState(org.talend.core.model.properties.ItemState) WSRoutingRuleE(org.talend.mdm.repository.model.mdmserverobject.WSRoutingRuleE) WSRoutingRuleItem(org.talend.mdm.repository.model.mdmproperties.WSRoutingRuleItem)

Example 2 with WSRoutingRuleItem

use of org.talend.mdm.repository.model.mdmproperties.WSRoutingRuleItem in project tmdm-studio-se by Talend.

the class GenerateJobTriggerAction method AttachToTriggerView.

/**
 * DOC jsxie Comment method "AttachToTriggerView".
 *
 * @param filename
 * @param trigger
 */
private void AttachToTriggerView(String filename, WSRoutingRuleE trigger) {
    WSRoutingRuleItem item = MdmpropertiesFactory.eINSTANCE.createWSRoutingRuleItem();
    ItemState itemState = PropertiesFactory.eINSTANCE.createItemState();
    item.setState(itemState);
    item.setWsRoutingRule(trigger);
    // $NON-NLS-1$
    item.getState().setPath("");
    RepositoryResourceUtil.createItem(item, PREFIX + filename);
    getCommonViewer().refresh();
}
Also used : ItemState(org.talend.core.model.properties.ItemState) WSRoutingRuleItem(org.talend.mdm.repository.model.mdmproperties.WSRoutingRuleItem)

Example 3 with WSRoutingRuleItem

use of org.talend.mdm.repository.model.mdmproperties.WSRoutingRuleItem in project tmdm-studio-se by Talend.

the class NewTriggerActionTest method testCreateServerObject.

@Test
public void testCreateServerObject() throws Exception {
    // 
    ContainerItem newItem = MdmpropertiesFactory.eINSTANCE.createContainerItem();
    ContainerItem mockContainerItem = spy(newItem);
    PowerMockito.mockStatic(MDMWorbenchPlugin.class);
    when(MDMWorbenchPlugin.getImageDescriptor(anyString())).thenReturn(mock(ImageDescriptor.class));
    NewTriggerAction action = new NewTriggerAction();
    NewTriggerAction spyAction = spy(action);
    // $NON-NLS-1$
    Whitebox.setInternalState(spyAction, "parentItem", mockContainerItem);
    ItemState itemState = mock(ItemState.class);
    when(mockContainerItem.getState()).thenReturn(itemState);
    // $NON-NLS-1$
    when(mockContainerItem.getState().getPath()).thenReturn("");
    WSRoutingRuleItem item = MdmpropertiesFactory.eINSTANCE.createWSRoutingRuleItem();
    WSRoutingRuleItem spyRoutingRuleItem = spy(item);
    Resource mockResource = mock(Resource.class);
    ResourceSet mockResourceSet = mock(ResourceSet.class);
    when(mockResource.getResourceSet()).thenReturn(mockResourceSet);
    when(spyRoutingRuleItem.eResource()).thenReturn(mockResource);
    PowerMockito.whenNew(WSRoutingRuleItemImpl.class).withNoArguments().thenReturn((WSRoutingRuleItemImpl) spyRoutingRuleItem);
    // run
    // $NON-NLS-1$
    Item addedItem = spyAction.createServerObject("abc");
    assertThat(addedItem, notNullValue());
}
Also used : Item(org.talend.core.model.properties.Item) WSRoutingRuleItem(org.talend.mdm.repository.model.mdmproperties.WSRoutingRuleItem) ContainerItem(org.talend.mdm.repository.model.mdmproperties.ContainerItem) ContainerItem(org.talend.mdm.repository.model.mdmproperties.ContainerItem) ItemState(org.talend.core.model.properties.ItemState) Resource(org.eclipse.emf.ecore.resource.Resource) ImageDescriptor(org.eclipse.jface.resource.ImageDescriptor) ResourceSet(org.eclipse.emf.ecore.resource.ResourceSet) WSRoutingRuleItem(org.talend.mdm.repository.model.mdmproperties.WSRoutingRuleItem) AbstractSimpleAddActionTest(org.talend.mdm.repository.ui.actions.AbstractSimpleAddActionTest) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 4 with WSRoutingRuleItem

use of org.talend.mdm.repository.model.mdmproperties.WSRoutingRuleItem in project tmdm-studio-se by Talend.

the class RoutingRuleNodeResourceProvider method save.

@Override
public Resource save(Item item) throws PersistenceException {
    if (item instanceof WSRoutingRuleItem) {
        Resource resource = xmiResourceManager.getItemResource(item);
        resource.getContents().clear();
        resource.getContents().add(((WSRoutingRuleItem) item).getWsRoutingRule());
        Resource eResource = ((WSRoutingRuleItem) item).getWsRoutingRule().eResource();
        return resource;
    }
    return null;
}
Also used : Resource(org.eclipse.emf.ecore.resource.Resource) WSRoutingRuleItem(org.talend.mdm.repository.model.mdmproperties.WSRoutingRuleItem)

Example 5 with WSRoutingRuleItem

use of org.talend.mdm.repository.model.mdmproperties.WSRoutingRuleItem in project tmdm-studio-se by Talend.

the class TriggerDecorator method decorate.

public void decorate(Object element, IDecoration decoration) {
    IRepositoryViewObject viewObj = (IRepositoryViewObject) element;
    Item item = RepositoryResourceUtil.getItemFromRepViewObj(viewObj);
    if (item != null && item instanceof WSRoutingRuleItem) {
        WSRoutingRuleE routing = ((WSRoutingRuleItem) item).getWsRoutingRule();
        if (routing.isDeactive()) {
            decoration.addOverlay(IMG_TRIGGER_DEACTIVE, IDecoration.BOTTOM_LEFT);
        }
    }
}
Also used : Item(org.talend.core.model.properties.Item) WSRoutingRuleItem(org.talend.mdm.repository.model.mdmproperties.WSRoutingRuleItem) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) WSRoutingRuleE(org.talend.mdm.repository.model.mdmserverobject.WSRoutingRuleE) WSRoutingRuleItem(org.talend.mdm.repository.model.mdmproperties.WSRoutingRuleItem)

Aggregations

WSRoutingRuleItem (org.talend.mdm.repository.model.mdmproperties.WSRoutingRuleItem)5 ItemState (org.talend.core.model.properties.ItemState)3 Resource (org.eclipse.emf.ecore.resource.Resource)2 Item (org.talend.core.model.properties.Item)2 WSRoutingRuleE (org.talend.mdm.repository.model.mdmserverobject.WSRoutingRuleE)2 ResourceSet (org.eclipse.emf.ecore.resource.ResourceSet)1 ImageDescriptor (org.eclipse.jface.resource.ImageDescriptor)1 Test (org.junit.Test)1 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)1 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)1 ContainerItem (org.talend.mdm.repository.model.mdmproperties.ContainerItem)1 AbstractSimpleAddActionTest (org.talend.mdm.repository.ui.actions.AbstractSimpleAddActionTest)1