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;
}
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());
}
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());
}
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);
}
}
}
}
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;
}
Aggregations