Search in sources :

Example 1 with WSViewItem

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

the class ViewNodeResourceProvider method save.

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

Example 2 with WSViewItem

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

the class NewViewActionTest 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));
    NewViewAction action = new NewViewAction();
    NewViewAction 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("");
    WSViewItem item = MdmpropertiesFactory.eINSTANCE.createWSViewItem();
    WSViewItem spyViewItem = spy(item);
    Resource mockResource = mock(Resource.class);
    ResourceSet mockResourceSet = mock(ResourceSet.class);
    when(mockResource.getResourceSet()).thenReturn(mockResourceSet);
    when(spyViewItem.eResource()).thenReturn(mockResource);
    PowerMockito.whenNew(WSViewItemImpl.class).withNoArguments().thenReturn((WSViewItemImpl) spyViewItem);
    // run
    // $NON-NLS-1$
    Item addedItem = spyAction.createServerObject("abc");
    assertThat(addedItem, notNullValue());
}
Also used : Item(org.talend.core.model.properties.Item) WSViewItem(org.talend.mdm.repository.model.mdmproperties.WSViewItem) ContainerItem(org.talend.mdm.repository.model.mdmproperties.ContainerItem) ContainerItem(org.talend.mdm.repository.model.mdmproperties.ContainerItem) WSViewItem(org.talend.mdm.repository.model.mdmproperties.WSViewItem) 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) AbstractSimpleAddActionTest(org.talend.mdm.repository.ui.actions.AbstractSimpleAddActionTest) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 3 with WSViewItem

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

the class ViewOperatorUpdatorTest method test.

@Test
public void test() {
    WSViewItem wsViewItem = MdmpropertiesFactory.eINSTANCE.createWSViewItem();
    WSViewE wsViewE = MdmserverobjectFactory.eINSTANCE.createWSViewE();
    wsViewItem.setWsView(wsViewE);
    // $NON-NLS-1$
    String customAppend = "_Customed";
    String customContianOperator = WSWhereOperator.CONTAINS.name() + customAppend;
    WSWhereConditionE conditionA = MdmserverobjectFactory.eINSTANCE.createWSWhereConditionE();
    wsViewE.getWhereConditions().add(conditionA);
    WSWhereOperatorE operatorA = MdmserverobjectFactory.eINSTANCE.createWSWhereOperatorE();
    operatorA.setValue(customContianOperator);
    conditionA.setOperator(operatorA);
    WSWhereConditionE conditionB = MdmserverobjectFactory.eINSTANCE.createWSWhereConditionE();
    wsViewE.getWhereConditions().add(conditionB);
    WSWhereOperatorE operatorB = MdmserverobjectFactory.eINSTANCE.createWSWhereOperatorE();
    operatorB.setValue(WSWhereOperator.JOIN.name());
    conditionB.setOperator(operatorB);
    boolean updated = new ViewOperatorUpdator().updateConditionOperator(wsViewItem);
    assertTrue(updated);
    assertEquals(WSWhereOperator.CONTAINS.name(), operatorA.getValue());
    assertEquals(WSWhereOperator.JOIN.name(), operatorB.getValue());
}
Also used : WSWhereOperatorE(org.talend.mdm.repository.model.mdmserverobject.WSWhereOperatorE) WSViewItem(org.talend.mdm.repository.model.mdmproperties.WSViewItem) WSViewE(org.talend.mdm.repository.model.mdmserverobject.WSViewE) WSWhereConditionE(org.talend.mdm.repository.model.mdmserverobject.WSWhereConditionE) Test(org.junit.Test)

Example 4 with WSViewItem

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

the class BrowseViewAction method doRun.

@Override
protected void doRun() {
    Object obj = getSelectedObject().get(0);
    if (obj instanceof IRepositoryViewObject) {
        IRepositoryViewObject viewObject = (IRepositoryViewObject) obj;
        WSViewItem item = (WSViewItem) viewObject.getProperty().getItem();
        WSViewE wsView = item.getWsView();
        MDMServerDef lastServerDef = RepositoryResourceUtil.getLastServerDef(item);
        SelectServerDefDialog dlg = new SelectServerDefDialog(getShell());
        dlg.create();
        dlg.setSelectServer(lastServerDef);
        if (dlg.open() == IDialogConstants.OK_ID) {
            ViewBrowserInput input = new ViewBrowserInput(viewObject);
            input.setServerDef(dlg.getSelectedServerDef());
            if (page == null) {
                page = commonViewer.getCommonNavigator().getSite().getWorkbenchWindow().getActivePage();
            }
            try {
                IEditorPart oldEditor = page.findEditor(input);
                if (oldEditor != null) {
                    page.closeEditor(oldEditor, false);
                }
                page.openEditor(input, XObjectBrowser2.EDITOR_ID);
            } catch (PartInitException e) {
                log.error(e.getMessage(), e);
            }
        }
    }
}
Also used : WSViewItem(org.talend.mdm.repository.model.mdmproperties.WSViewItem) ViewBrowserInput(org.talend.mdm.repository.ui.editors.ViewBrowserInput) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) SelectServerDefDialog(org.talend.mdm.workbench.serverexplorer.ui.dialogs.SelectServerDefDialog) WSViewE(org.talend.mdm.repository.model.mdmserverobject.WSViewE) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) IEditorPart(org.eclipse.ui.IEditorPart) PartInitException(org.eclipse.ui.PartInitException) MDMServerDef(org.talend.mdm.repository.model.mdmmetadata.MDMServerDef)

Example 5 with WSViewItem

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

the class NewViewAction method createServerObject.

@Override
protected Item createServerObject(String key) {
    WSViewItem item = MdmpropertiesFactory.eINSTANCE.createWSViewItem();
    ItemState itemState = PropertiesFactory.eINSTANCE.createItemState();
    item.setState(itemState);
    // 
    WSViewE view = newView(key);
    item.setWsView(view);
    int viewType = RepositoryTransformUtil.getInstance().getViewType(key);
    if (parentItem != null) {
        String path = parentItem.getState().getPath();
        if (path.isEmpty()) {
            if (viewType == TYPE_WEBFILTER) {
                path = IPath.SEPARATOR + PATH_WEBFILTER;
            } else {
                path = IPath.SEPARATOR + PATH_SEARCHFILTER;
            }
        }
        item.getState().setPath(path);
    } else {
        if (viewType == TYPE_WEBFILTER) {
            item.getState().setPath(IPath.SEPARATOR + PATH_WEBFILTER);
        } else {
            item.getState().setPath(IPath.SEPARATOR + PATH_SEARCHFILTER);
        }
    }
    RepositoryResourceUtil.createItem(item, key);
    return item;
}
Also used : WSViewItem(org.talend.mdm.repository.model.mdmproperties.WSViewItem) ItemState(org.talend.core.model.properties.ItemState) WSViewE(org.talend.mdm.repository.model.mdmserverobject.WSViewE) Point(org.eclipse.swt.graphics.Point)

Aggregations

WSViewItem (org.talend.mdm.repository.model.mdmproperties.WSViewItem)8 WSViewE (org.talend.mdm.repository.model.mdmserverobject.WSViewE)5 WSWhereConditionE (org.talend.mdm.repository.model.mdmserverobject.WSWhereConditionE)3 Resource (org.eclipse.emf.ecore.resource.Resource)2 Test (org.junit.Test)2 Item (org.talend.core.model.properties.Item)2 ItemState (org.talend.core.model.properties.ItemState)2 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)2 WSWhereOperatorE (org.talend.mdm.repository.model.mdmserverobject.WSWhereOperatorE)2 ResourceSet (org.eclipse.emf.ecore.resource.ResourceSet)1 ImageDescriptor (org.eclipse.jface.resource.ImageDescriptor)1 Point (org.eclipse.swt.graphics.Point)1 IEditorPart (org.eclipse.ui.IEditorPart)1 PartInitException (org.eclipse.ui.PartInitException)1 ValidationMessage (org.eclipse.wst.xml.core.internal.validation.core.ValidationMessage)1 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)1 MDMServerDef (org.talend.mdm.repository.model.mdmmetadata.MDMServerDef)1 ContainerItem (org.talend.mdm.repository.model.mdmproperties.ContainerItem)1 WSTransformerV2Item (org.talend.mdm.repository.model.mdmproperties.WSTransformerV2Item)1 AbstractSimpleAddActionTest (org.talend.mdm.repository.ui.actions.AbstractSimpleAddActionTest)1