Search in sources :

Example 31 with MDMServerObjectItem

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

the class DataModelMainPage2 method doSave.

@Override
protected void doSave(WSDataModel wsObject) throws Exception {
    XObjectEditorInput2 editorInput = (XObjectEditorInput2) getEditorInput();
    MDMServerObjectItem serverObjectItem = (MDMServerObjectItem) editorInput.getInputItem();
    // 
    updateSchemaToItem(serverObjectItem);
    xsdSchema = ((SchemaTreeContentProvider) viewer.getContentProvider()).getXsdSchema();
    Item newItem = RepositoryResourceUtil.assertItem(serverObjectItem);
    if (newItem != serverObjectItem) {
        editorInput.updateViewObject(ContainerCacheService.get(newItem.getProperty()));
        getEditorSite();
        serverObjectItem = (MDMServerObjectItem) newItem;
    }
    EObject eObj = Bean2EObjUtil.getInstance().convertFromBean2EObj(wsObject, serverObjectItem.getMDMServerObject());
    if (eObj != null) {
        RepositoryResourceUtil.saveItem(serverObjectItem);
    }
    refreshDirtyCue();
}
Also used : WSDataModelItem(org.talend.mdm.repository.model.mdmproperties.WSDataModelItem) Item(org.talend.core.model.properties.Item) MDMServerObjectItem(org.talend.mdm.repository.model.mdmproperties.MDMServerObjectItem) MDMServerObjectItem(org.talend.mdm.repository.model.mdmproperties.MDMServerObjectItem) EObject(org.eclipse.emf.ecore.EObject)

Example 32 with MDMServerObjectItem

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

the class RenameViewAction method renameViewObject.

private void renameViewObject(IRepositoryViewObject viewObj) {
    MDMServerObjectItem item = (MDMServerObjectItem) viewObj.getProperty().getItem();
    MDMServerObject serverObject = item.getMDMServerObject();
    IProxyRepositoryFactory factory = getFactory();
    try {
        if (serverObject != null) {
            String oldName = serverObject.getName();
            RenameViewDialog dialog = getRenameDialog(oldName);
            int returnCode = dialog.open();
            if (returnCode == IDialogConstants.OK_ID) {
                String newName = dialog.getValue();
                if (RepositoryTransformUtil.getInstance().getViewType(oldName) == TYPE_WEBFILTER) {
                    newName = PREFIX_VIEW_UPPER + newName;
                } else {
                    if (newName.startsWith(PREFIX_VIEW_UPPER)) {
                        viewTypeChanged = true;
                        item.getState().setPath(IPath.SEPARATOR + PATH_WEBFILTER);
                    }
                }
                if (newName != null && factory.isEditableAndLockIfPossible(item)) {
                    serverObject.setName(newName);
                    viewObj.getProperty().setLabel(newName);
                    viewObj.getProperty().setDisplayName(newName);
                    factory.save(viewObj.getProperty().getItem(), false);
                    MDMServerDef lastServerDef = RepositoryResourceUtil.getLastServerDef(viewObj);
                    if (lastServerDef != null) {
                        CommandManager.getInstance().pushCommand(ICommand.CMD_RENAME, viewObj.getId(), new String[] { oldName, newName });
                    }
                }
                commonViewer.refresh(viewObj);
            }
        }
    } catch (PersistenceException e) {
        log.error(e.getMessage(), e);
    } finally {
        try {
            factory.unlock(item);
        } catch (PersistenceException e) {
            log.error(e.getMessage(), e);
        } catch (LoginException e) {
            log.error(e.getMessage(), e);
        }
    }
}
Also used : MDMServerObjectItem(org.talend.mdm.repository.model.mdmproperties.MDMServerObjectItem) PersistenceException(org.talend.commons.exception.PersistenceException) RenameViewDialog(org.talend.mdm.repository.ui.dialogs.RenameViewDialog) LoginException(org.talend.commons.exception.LoginException) MDMServerObject(org.talend.mdm.repository.model.mdmserverobject.MDMServerObject) IProxyRepositoryFactory(org.talend.repository.model.IProxyRepositoryFactory) MDMServerDef(org.talend.mdm.repository.model.mdmmetadata.MDMServerDef)

Example 33 with MDMServerObjectItem

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

the class ConsistencyService method updateDigestValue.

public void updateDigestValue(MDMServerDef serverDef, IRepositoryViewObject viewObj) throws XtentisException {
    Item item = viewObj.getProperty().getItem();
    if (item instanceof MDMServerObjectItem) {
        TMDMService service = RepositoryWebServiceAdapter.getMDMService(serverDef);
        updateLocalDigestValue(viewObj);
        // key
        String type = viewObj.getRepositoryObjectType().getKey();
        String objectName = getObjectName(viewObj);
        WSDigestKey key = new WSDigestKey(objectName, type);
        // value
        WSDigest value = new WSDigest(getLocalDigestValue(item), 0L, key);
        WSLong timeValue = service.updateDigest(value);
        // 
        if (timeValue != null) {
            updateLocalTimestamp(item, timeValue.getValue());
        }
        if (!viewObj.getRepositoryObjectType().equals(IServerObjectRepositoryType.TYPE_MATCH_RULE_MAPINFO)) {
            item = RepositoryResourceUtil.assertItem(item);
            Property property = item.getProperty();
            boolean eDeliver = property.eDeliver();
            property.eSetDeliver(false);
            RepositoryResourceUtil.saveItem(item);
            property.eSetDeliver(eDeliver);
        }
    }
}
Also used : ReferenceFileItem(org.talend.core.model.properties.ReferenceFileItem) Item(org.talend.core.model.properties.Item) ProcessItem(org.talend.core.model.properties.ProcessItem) MDMServerObjectItem(org.talend.mdm.repository.model.mdmproperties.MDMServerObjectItem) WSLong(com.amalto.workbench.webservices.WSLong) TMDMService(com.amalto.workbench.webservices.TMDMService) MDMServerObjectItem(org.talend.mdm.repository.model.mdmproperties.MDMServerObjectItem) WSDigestKey(com.amalto.workbench.webservices.WSDigestKey) WSDigest(com.amalto.workbench.webservices.WSDigest) Property(org.talend.core.model.properties.Property)

Example 34 with MDMServerObjectItem

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

the class AbstractLabelProvider method getDescription.

public String getDescription(Object anElement) {
    if (anElement instanceof IRepositoryViewObject) {
        Property property = ((IRepositoryViewObject) anElement).getProperty();
        Item item = property.getItem();
        if (item instanceof MDMServerObjectItem) {
            String label = getServerObjectItemText(item);
            if (label != null) {
                return label;
            }
        }
        String label = property.getLabel();
        return label;
    }
    return null;
}
Also used : Item(org.talend.core.model.properties.Item) MDMServerObjectItem(org.talend.mdm.repository.model.mdmproperties.MDMServerObjectItem) ContainerItem(org.talend.mdm.repository.model.mdmproperties.ContainerItem) MDMServerObjectItem(org.talend.mdm.repository.model.mdmproperties.MDMServerObjectItem) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) Property(org.talend.core.model.properties.Property)

Example 35 with MDMServerObjectItem

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

the class AbstractLabelProvider method getServerObjectItemText.

protected String getServerObjectItemText(Item item) {
    item = RepositoryResourceUtil.assertItem(item);
    MDMServerObject serverObject = ((MDMServerObjectItem) item).getMDMServerObject();
    if (serverObject != null) {
        return serverObject.getName();
    }
    return null;
}
Also used : MDMServerObjectItem(org.talend.mdm.repository.model.mdmproperties.MDMServerObjectItem) MDMServerObject(org.talend.mdm.repository.model.mdmserverobject.MDMServerObject)

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