Search in sources :

Example 6 with IInteractiveHandler

use of org.talend.mdm.repository.core.service.IInteractiveHandler in project tmdm-studio-se by Talend.

the class RepositoryResourceUtilTest method testFindAllViewObjects.

/**
 * Test for: findAllViewObjects(ERepositoryObjectType type, boolean useRepositoryViewObject, boolean withDeleted)
 */
@Test
public void testFindAllViewObjects() throws Exception {
    boolean withDeleted = false;
    boolean useRepositoryViewObject = true;
    ERepositoryObjectType mockType = mock(ERepositoryObjectType.class);
    IProxyRepositoryFactory mockFactory = mock(IProxyRepositoryFactory.class);
    when(CoreRuntimePlugin.getInstance().getProxyRepositoryFactory()).thenReturn(mockFactory);
    List<IRepositoryViewObject> viewObjects = new ArrayList<IRepositoryViewObject>();
    IRepositoryViewObject mockViewObject = mock(IRepositoryViewObject.class);
    Property mockProperty = mock(Property.class);
    when(mockViewObject.getProperty()).thenReturn(mockProperty);
    when(mockViewObject.getRepositoryObjectType()).thenReturn(mockType);
    Item mockItem = mock(Item.class);
    when(mockProperty.getItem()).thenReturn(mockItem);
    ItemState mockItemState = mock(ItemState.class);
    when(mockItemState.isDeleted()).thenReturn(false);
    when(mockItem.getState()).thenReturn(mockItemState);
    viewObjects.add(mockViewObject);
    when(mockFactory.getAll(mockType, withDeleted)).thenReturn(viewObjects);
    PowerMockito.mockStatic(InteractiveService.class);
    IInteractiveHandler mockHandler = mock(IInteractiveHandler.class);
    when(InteractiveService.findHandler(mockType)).thenReturn(mockHandler);
    PowerMockito.mockStatic(RepositoryResourceUtil.class);
    IRepositoryViewObject mockResultViewObject = mock(IRepositoryViewObject.class);
    PowerMockito.when(RepositoryResourceUtil.class, "getCacheViewObject", mockProperty, mockViewObject).thenReturn(mockResultViewObject);
    PowerMockito.when(RepositoryResourceUtil.class, "assertViewObject", mockViewObject).thenReturn(mockViewObject);
    PowerMockito.doCallRealMethod().when(RepositoryResourceUtil.class, "findAllViewObjects", mockType, useRepositoryViewObject, withDeleted);
    List<IRepositoryViewObject> viewObjectss = RepositoryResourceUtil.findAllViewObjects(mockType, useRepositoryViewObject, withDeleted);
    assertEquals(1, viewObjectss.size());
    PowerMockito.verifyStatic(Mockito.atLeastOnce());
    InteractiveService.findHandler(mockType);
}
Also used : Item(org.talend.core.model.properties.Item) ContainerItem(org.talend.mdm.repository.model.mdmproperties.ContainerItem) ItemState(org.talend.core.model.properties.ItemState) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) ArrayList(java.util.ArrayList) IInteractiveHandler(org.talend.mdm.repository.core.service.IInteractiveHandler) ERepositoryObjectType(org.talend.core.model.repository.ERepositoryObjectType) Property(org.talend.core.model.properties.Property) IProxyRepositoryFactory(org.talend.repository.model.IProxyRepositoryFactory) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 7 with IInteractiveHandler

use of org.talend.mdm.repository.core.service.IInteractiveHandler in project tmdm-studio-se by Talend.

the class RepositoryViewObjectCheckedWidget method getAssociatedObjectCommand.

private List<AbstractDeployCommand> getAssociatedObjectCommand(IRepositoryViewObject viewObj, int cmdType) {
    ERepositoryObjectType type = viewObj.getRepositoryObjectType();
    CommandManager commandManager = CommandManager.getInstance();
    if (type != null) {
        IInteractiveHandler handler = InteractiveService.findHandler(type);
        if (handler != null) {
            List<IRepositoryViewObject> associatedObjects = handler.getAssociatedObjects(viewObj);
            if (associatedObjects != null) {
                return commandManager.getDeployCommands(associatedObjects, cmdType);
            }
        }
    }
    return null;
}
Also used : CommandManager(org.talend.mdm.repository.core.command.CommandManager) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) IInteractiveHandler(org.talend.mdm.repository.core.service.IInteractiveHandler) ERepositoryObjectType(org.talend.core.model.repository.ERepositoryObjectType)

Example 8 with IInteractiveHandler

use of org.talend.mdm.repository.core.service.IInteractiveHandler in project tmdm-studio-se by Talend.

the class DeleteCommand method execute.

@Override
public IStatus execute(Object receiver, IProgressMonitor monitor) {
    IInteractiveHandler handler = InteractiveService.findHandler(getViewObjectType());
    String objectName = getObjLastName();
    if (handler != null) {
        String typeLabel = handler.getLabel();
        monitor.subTask(Messages.bind(Messages._SubTaskTitle, typeLabel));
        try {
            handler.remove(this);
            return DeployStatus.getOKStatus(this, Messages.bind(Messages._OkDeleteStatusMsg, typeLabel, objectName));
        } catch (Exception e) {
            return getDetailErrorMsg(Messages._ErrorStatusMsg1, typeLabel, objectName, e);
        }
    } else {
        return DeployStatus.getErrorStatus(null, Messages.bind(Messages._ErrorStatusMsg2, objectName));
    }
}
Also used : IInteractiveHandler(org.talend.mdm.repository.core.service.IInteractiveHandler)

Example 9 with IInteractiveHandler

use of org.talend.mdm.repository.core.service.IInteractiveHandler in project tmdm-studio-se by Talend.

the class DeployCompoundCommand method getOKStatusMsg.

@Override
protected String getOKStatusMsg() {
    ERepositoryObjectType type = getViewObjectType();
    String objectName = deployCommand.getObjLastName();
    IInteractiveHandler handler = InteractiveService.findHandler(type);
    if (handler != null) {
        String typeLabel = handler.getLabel();
        return Messages.bind(Messages._OkStatusMsg, typeLabel, objectName);
    }
    return null;
}
Also used : IInteractiveHandler(org.talend.mdm.repository.core.service.IInteractiveHandler) ERepositoryObjectType(org.talend.core.model.repository.ERepositoryObjectType)

Aggregations

IInteractiveHandler (org.talend.mdm.repository.core.service.IInteractiveHandler)9 ERepositoryObjectType (org.talend.core.model.repository.ERepositoryObjectType)6 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)4 XtentisException (com.amalto.workbench.utils.XtentisException)2 ArrayList (java.util.ArrayList)2 LinkedList (java.util.LinkedList)2 IStatus (org.eclipse.core.runtime.IStatus)2 MultiStatus (org.eclipse.core.runtime.MultiStatus)2 Item (org.talend.core.model.properties.Item)2 ItemState (org.talend.core.model.properties.ItemState)2 ContainerItem (org.talend.mdm.repository.model.mdmproperties.ContainerItem)2 IProxyRepositoryFactory (org.talend.repository.model.IProxyRepositoryFactory)2 OperationIgnoredException (com.amalto.workbench.utils.OperationIgnoredException)1 FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 HashMap (java.util.HashMap)1 List (java.util.List)1 WebServiceException (javax.xml.ws.WebServiceException)1 CoreException (org.eclipse.core.runtime.CoreException)1