Search in sources :

Example 16 with MDMServerObjectItem

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

the class MdmPropertiesWizard method performFinish.

@Override
public boolean performFinish() {
    if (alreadyEditedByUser) {
        return false;
    }
    IProxyRepositoryFactory factory = CoreRuntimePlugin.getInstance().getProxyRepositoryFactory();
    Item item = object.getProperty().getItem();
    String newName = object.getLabel();
    MDMServerObject serverObject = ((MDMServerObjectItem) item).getMDMServerObject();
    if (serverObject != null) {
        String oldName = serverObject.getName();
        try {
            if (newName != null && factory.isEditableAndLockIfPossible(item)) {
                serverObject.setName(newName);
                item = RepositoryResourceUtil.assertItem(item);
                factory.save(item, false);
                MDMServerDef lastServerDef = RepositoryResourceUtil.getLastServerDef(item);
                if (!oldName.equals(newName) && lastServerDef != null) {
                    CommandManager.getInstance().pushCommand(ICommand.CMD_RENAME, object.getId(), new String[] { oldName, newName });
                }
            }
        } catch (PersistenceException e) {
            MessageBoxExceptionHandler.process(e);
            return false;
        } finally {
            try {
                factory.unlock(item);
            } catch (PersistenceException e) {
                MessageBoxExceptionHandler.process(e);
                return false;
            } catch (LoginException e) {
                MessageBoxExceptionHandler.process(e);
                return false;
            }
        }
    }
    return true;
}
Also used : Item(org.talend.core.model.properties.Item) WSResourceItem(org.talend.mdm.repository.model.mdmproperties.WSResourceItem) MDMServerObjectItem(org.talend.mdm.repository.model.mdmproperties.MDMServerObjectItem) MDMServerObjectItem(org.talend.mdm.repository.model.mdmproperties.MDMServerObjectItem) PersistenceException(org.talend.commons.exception.PersistenceException) LoginException(org.talend.commons.exception.LoginException) IProxyRepositoryFactory(org.talend.repository.model.IProxyRepositoryFactory) MDMServerObject(org.talend.mdm.repository.model.mdmserverobject.MDMServerObject) MDMServerDef(org.talend.mdm.repository.model.mdmmetadata.MDMServerDef)

Example 17 with MDMServerObjectItem

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

the class ViewBrowserInput method init.

protected void init(Item item) {
    MDMServerObject serverObject = ((MDMServerObjectItem) item).getMDMServerObject();
    Object treeObject = Bean2EObjUtil.getInstance().wrapEObjWithTreeObject(serverObject);
    setModel(treeObject);
    setName(serverObject.getName());
}
Also used : MDMServerObjectItem(org.talend.mdm.repository.model.mdmproperties.MDMServerObjectItem) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) TreeObject(com.amalto.workbench.models.TreeObject) MDMServerObject(org.talend.mdm.repository.model.mdmserverobject.MDMServerObject) MDMServerObject(org.talend.mdm.repository.model.mdmserverobject.MDMServerObject)

Example 18 with MDMServerObjectItem

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

the class XObjectBrowserInput2 method init.

protected void init(Item item) {
    MDMServerObject serverObject = ((MDMServerObjectItem) item).getMDMServerObject();
    Object treeObject = Bean2EObjUtil.getInstance().wrapEObjWithTreeObject(serverObject);
    setModel(treeObject);
    setName(serverObject.getName());
}
Also used : MDMServerObjectItem(org.talend.mdm.repository.model.mdmproperties.MDMServerObjectItem) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) TreeObject(com.amalto.workbench.models.TreeObject) MDMServerObject(org.talend.mdm.repository.model.mdmserverobject.MDMServerObject) MDMServerObject(org.talend.mdm.repository.model.mdmserverobject.MDMServerObject)

Example 19 with MDMServerObjectItem

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

the class XObjectEditorInput2 method init.

protected void init(Item item) {
    MDMServerObject serverObject = ((MDMServerObjectItem) item).getMDMServerObject();
    Object treeObject = Bean2EObjUtil.getInstance().wrapEObjWithTreeObject(serverObject);
    setModel(treeObject);
    setName(serverObject.getName());
}
Also used : MDMServerObjectItem(org.talend.mdm.repository.model.mdmproperties.MDMServerObjectItem) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) TreeObject(com.amalto.workbench.models.TreeObject) MDMServerObject(org.talend.mdm.repository.model.mdmserverobject.MDMServerObject) MDMServerObject(org.talend.mdm.repository.model.mdmserverobject.MDMServerObject)

Example 20 with MDMServerObjectItem

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

the class ConsistencyServiceTest method testGetLocalDigestValue.

@Test
public void testGetLocalDigestValue() {
    assertNull(ConsistencyService.getInstance().getLocalDigestValue(null));
    // $NON-NLS-1$
    String localDigestValue = "local_digest_value_0123";
    MDMServerObject mockMDMServerObj = Mockito.mock(MDMServerObject.class);
    Mockito.when(mockMDMServerObj.getDigestValue()).thenReturn(localDigestValue);
    MDMServerObjectItem mockItem = Mockito.mock(MDMServerObjectItem.class);
    Mockito.when(mockItem.getMDMServerObject()).thenReturn(mockMDMServerObj);
    // 
    assertEquals(localDigestValue, ConsistencyService.getInstance().getLocalDigestValue(mockItem));
    EMap mockProperties = Mockito.mock(EMap.class);
    // $NON-NLS-1$
    Mockito.when(mockProperties.get(eq("digestValue"))).thenReturn(localDigestValue);
    Property mockProperty = Mockito.mock(Property.class);
    Mockito.when(mockProperty.getAdditionalProperties()).thenReturn(mockProperties);
    ProcessItem mockProcessItem = Mockito.mock(ProcessItem.class);
    Mockito.when(mockProcessItem.getProperty()).thenReturn(mockProperty);
    // 
    assertEquals(localDigestValue, ConsistencyService.getInstance().getLocalDigestValue(mockProcessItem));
}
Also used : ProcessItem(org.talend.core.model.properties.ProcessItem) MDMServerObjectItem(org.talend.mdm.repository.model.mdmproperties.MDMServerObjectItem) EMap(org.eclipse.emf.common.util.EMap) Property(org.talend.core.model.properties.Property) MDMServerObject(org.talend.mdm.repository.model.mdmserverobject.MDMServerObject) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Aggregations

MDMServerObjectItem (org.talend.mdm.repository.model.mdmproperties.MDMServerObjectItem)50 MDMServerObject (org.talend.mdm.repository.model.mdmserverobject.MDMServerObject)33 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)28 Item (org.talend.core.model.properties.Item)22 Property (org.talend.core.model.properties.Property)15 PersistenceException (org.talend.commons.exception.PersistenceException)13 ContainerItem (org.talend.mdm.repository.model.mdmproperties.ContainerItem)12 IProxyRepositoryFactory (org.talend.repository.model.IProxyRepositoryFactory)11 ERepositoryObjectType (org.talend.core.model.repository.ERepositoryObjectType)10 LoginException (org.talend.commons.exception.LoginException)9 MDMServerDef (org.talend.mdm.repository.model.mdmmetadata.MDMServerDef)9 TreeObject (com.amalto.workbench.models.TreeObject)7 Test (org.junit.Test)7 TMDMService (com.amalto.workbench.webservices.TMDMService)6 LinkedList (java.util.LinkedList)6 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)6 BusinessException (org.talend.commons.exception.BusinessException)5 FolderItem (org.talend.core.model.properties.FolderItem)5 ProcessItem (org.talend.core.model.properties.ProcessItem)5 ArrayList (java.util.ArrayList)4